Fix use of _constructor/C++ constructor when objects from C++ code #150

mgehre opened this Issue Nov 4, 2011 · 1 comment


None yet

2 participants

Lightspark member

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


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 :-)

Lightspark member

I agree that _constructor should not be called from getInstanceS. It's also a good idea to put a large commend above getInstanceS to remind that _constructor will not be called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment