When calling API->object_create() in a chugin, it instantiates the object, but does not call the pre-constructor. This means that chugin_ctor is not called when objects are created this way.
An example:
Chuck_DL_Api::Object obj = API->object->create(API, SHRED, API->object->get_type(API, SHRED, "Hydra"));
// Need to be cast from Object to Chuck_Object in a separate line for some reason...
Chuck_Object * object = (Chuck_Object *) obj;
Hydra * obj_class = (Hydra *) OBJ_MEMBER_INT(object, hydra_data_offset);
// because hydra_ctor was never called, this Hydra object was never initializes, this segfaults.
obj_class->init(config_path, config_name);
If you +d on declaring an object inside chuck itself you get this vm code:
When calling API->object_create() in a chugin, it instantiates the object, but does not call the pre-constructor. This means that
chugin_ctor
is not called when objects are created this way.An example:
If you +d on declaring an object inside chuck itself you get this vm code:
Since the code emitter doesn't come into play inside chugin code, these steps need to be done inside
ck_create
.