Misiur
Misiur

Reputation: 5307

Haxe generating super call with arguments

The context is type-building macro. My goal is to generate

super(arg1, arg2, arg3)

What I have:

Array<FunctionArg> => [{ meta => null, name => foo, type => TPath({ name => StdTypes, pack => [], params => [], sub => Int }), opt => null, value => null },{ meta => null, name => bar, type => TPath({ name => StdTypes, pack => [], params => [], sub => Int }), opt => null, value => null }]

I've tried macro super($a{ancestorArgs}) but that's just silly, as $a expects Array<Expr>.

I have no ideas left.

Upvotes: 2

Views: 86

Answers (1)

Francis Bourre
Francis Bourre

Reputation: 268

Try:

var args = [ for ( arg in funcArgs ) macro $i { arg.name } ];
func.expr = macro 
{
    super( $a{ args } );
};

Upvotes: 4

Related Questions