lightspark/lightspark — Issue #150: Fix use of _constructor/C++ constructor when objects from C++ code
Author: mgehre
Created: 2011-11-04 09:26:28+00:00
State: open

Creating AS3 objects from C++ code is archieved by calling

Class::getInstanceS("someString");

and alike. getInstanceS calls

ASString* s = new ASString("someString")

and then

ASString::_constructor(/*obj:*/ s,/*args:*/ NULL, /*numArgs:*/ 0)

Actually, the call to _constructor without parameters should initalize s->data = "" (just as AS3 code 'var s:String = new String()' would do), but we use a hack to leave data unchanged in that case.

We should not call _constructor in getInstanceS. Then the _constructor will only be run when constructed from AS3 code.
On the other hand, it may be unexpected to new developers that the _constructor is not run in all cases.
Therefore we should make sure that getInstanceS() with parameter is only allowed for a small set of builtin classes like
ASString, Number, Integer, UInteger, Boolean, Event, Error.

Comments please :-)