Some hours hair pulling later, combination theory appliance to code, not really sure how to solve in a great way.
Currently trying bit shifting to choose "or" parameters, but wondering if somebody has ideas?
IDL transformator in C#
Input:void before(
(Node or DOMString) node,
(int or float) value,
(CssClass or DOMString) data)
Becomes:before(Node, int, CssClass)
before(Node, int, DOMString)
before(Node, float, CssClass)
before(Node, float, DOMString)
before(DOMString, int, CssClass)
before(DOMString, int, DOMString)
before(DOMString, float, CssClass)
before(DOMString, float, DOMString)
void before (Object node, Object value, Object data)
And later on use either some reflection magic or node.GetType(), value.GetType(), data.GetType() and react accordingly...
>>56197882
Yes, i know this one, but everything 100% needs to be verified at compiletime, thats the feature. When generating all variants, only absolute known data can be passed in.
Its External-Call code, so i cant have code inside those functions.
>>56197932
Wrap them into something like:public class NodeClass
{
public Node NodeValue { get; set; }
public DOMString DOMStringValue { get; set; }
}
From here you should be able to simplify things a lot...
>>56198086
The thing is, Node or DOMString has nothing to do with eath other, independent function arguments.
Managed to find some solvable solution on the internet. Takes integer index and maps to parameter "or" variant
[0:0][1:1][2:-1][3:0]
parameter 0 -> or[0]
parameter 1 -> or[1]
parameter 2 -> Non-Or datatype, take normal
parameter 3 -> or[0]
Anyhow, seems like im done here :)
>>56198170
They don't need to have anything together with each other. Abstract the shit that needs to get done, pass them as Actions into NodeClass for example, and Invoke them and let them do according to what is null...
But ok, you got it to work, have fun. Shitty language for a task like this tho, go with F# next time.
>>56198277
It just werks ;^)
But yes, "match" pattern-languages are better for this scenario, but kinda limited to use C# due the whole codebase is surrounded by it.
Altho, this thing is just a 1% part of the project with a specific purpose, kinda the last hard pussle part.void before(
(Node or DOMString) node,
(int or float) value,
int normal,
(CssClass or DOMString) data)
There, a kind of binary counter, where _ is normal parameters.
>>56198430
>but kinda limited to use C# due the whole codebase is surrounded by it
Just make a PCL and call the good F# bits from your project.
Anyway, cheers, fun thread!