@@ -123,7 +123,7 @@ class HScriptedClassMacro
123123 for (arg in args )
124124 {name : arg .name , opt : arg .opt , type : Context .toComplexType (arg .t )}
125125 ];
126- var initField : Field = buildScriptedClassInit (cls , superCls , constArgs );
126+ var initField : Field = buildScriptedClassInit (cls , superCls );
127127 fields .push (initField );
128128 constructor = buildScriptedClassConstructor (constArgs );
129129 case TLazy (builder ):
@@ -136,7 +136,7 @@ class HScriptedClassMacro
136136 for (arg in args )
137137 {name : arg .name , opt : arg .opt , type : Context .toComplexType (arg .t )}
138138 ];
139- var initField : Field = buildScriptedClassInit (cls , superCls , constArgs );
139+ var initField : Field = buildScriptedClassInit (cls , superCls );
140140 fields .push (initField );
141141 constructor = buildScriptedClassConstructor (constArgs );
142142 default :
@@ -151,7 +151,7 @@ class HScriptedClassMacro
151151 constructor = buildEmptyScriptedClassConstructor ();
152152 // Create scripted class utility functions.
153153 Context .info (' Creating scripted class utils...' , Context .currentPos ());
154- var initField : Field = buildScriptedClassInit (cls , superCls , [] );
154+ var initField : Field = buildScriptedClassInit (cls , superCls );
155155 fields .push (initField );
156156 fields .push (constructor );
157157 }
@@ -166,13 +166,10 @@ class HScriptedClassMacro
166166 return fields ;
167167 }
168168
169- static function buildScriptedClassInit (cls : haxe.macro. Type . ClassType , superCls : haxe.macro. Type . ClassType , superConstArgs : Array < FunctionArg > ): Field
169+ static function buildScriptedClassInit (cls : haxe.macro. Type . ClassType , superCls : haxe.macro. Type . ClassType ): Field
170170 {
171171 // Context.info(' Building scripted class init() function', Context.currentPos());
172172 var clsTypeName : String = cls .pack .join (' .' ) != ' ' ? ' ${cls .pack .join (' .' )}. ${cls .name }' : cls .name ;
173- var superClsTypeName : String = superCls .pack .join (' .' ) != ' ' ? ' ${superCls .pack .join (' .' )}. ${superCls .name }' : superCls .name ;
174-
175- var constArgs = [for (arg in superConstArgs ) macro $i {arg .name }];
176173 var typePath : haxe.macro. TypePath = {
177174 pack : cls .pack ,
178175 name : cls .name ,
@@ -184,7 +181,7 @@ class HScriptedClassMacro
184181 meta : null ,
185182 pos : cls .pos ,
186183 kind : FFun ({
187- args : [{name : ' clsName' , type : macro :String },]. concat ( superConstArgs ) ,
184+ args : [{name : ' clsName' , type : macro :String }, { name : ' args ' , type : macro : ... Dynamic }] ,
188185 params : null ,
189186 ret : Context .toComplexType (Context .getType (clsTypeName )),
190187 expr : macro
@@ -198,7 +195,9 @@ class HScriptedClassMacro
198195 }
199196
200197 try {
201- var result = clsRef .instantiate ([$a {constArgs }]);
198+ if (args == null ) args = haxe. Rest .of ([]);
199+
200+ var result = clsRef .instantiate (args .toArray ());
202201 if (result == null )
203202 {
204203 polymod. Polymod .error (SCRIPT_RUNTIME_EXCEPTION , ' Could not construct instance of scripted class ( ${clsName } extends ' + $v {clsTypeName } + ' ):\n Unknown error instantiating class' );
0 commit comments