diff --git a/src/dobject.cpp b/src/dobject.cpp index d057a71d3..e21d07526 100644 --- a/src/dobject.cpp +++ b/src/dobject.cpp @@ -57,14 +57,15 @@ ClassReg DObject::RegistrationInfo = { - NULL, // MyClass - "DObject", // Name - NULL, // ParentType - NULL, // Pointers - &DObject::InPlaceConstructor, // ConstructNative - &DObject::InitNativeFields, - sizeof(DObject), // SizeOf - CLASSREG_PClass, // MetaClassNum + nullptr, // MyClass + "DObject", // Name + nullptr, // ParentType + &DVMObject::RegistrationInfo, // VMExport + nullptr, // Pointers + &DObject::InPlaceConstructor, // ConstructNative + &DObject::InitNativeFields, // InitNatives + sizeof(DObject), // SizeOf + CLASSREG_PClass, // MetaClassNum }; _DECLARE_TI(DObject) diff --git a/src/dobject.h b/src/dobject.h index fb631c91c..24ba4997c 100644 --- a/src/dobject.h +++ b/src/dobject.h @@ -109,6 +109,7 @@ struct ClassReg PClass *MyClass; const char *Name; ClassReg *ParentType; + ClassReg *VMExport; const size_t *Pointers; void (*ConstructNative)(void *); void(*InitNatives)(); @@ -186,11 +187,12 @@ protected: \ # define _DECLARE_TI(cls) ClassReg * const cls::RegistrationInfoPtr __attribute__((section(SECTION_CREG))) = &cls::RegistrationInfo; #endif -#define _IMP_PCLASS(cls, ptrs, create, initn) \ +#define _IMP_PCLASS(cls, ptrs, create, initn, vmexport) \ ClassReg cls::RegistrationInfo = {\ nullptr, \ #cls, \ &cls::Super::RegistrationInfo, \ + vmexport, \ ptrs, \ create, \ initn, \ @@ -199,9 +201,9 @@ protected: \ _DECLARE_TI(cls) \ PClass *cls::StaticType() const { return RegistrationInfo.MyClass; } -#define IMPLEMENT_CLASS(cls, isabstract, ptrs, fields) \ +#define IMPLEMENT_CLASS(cls, isabstract, ptrs, fields, vmexport) \ _X_CONSTRUCTOR_##isabstract##(cls) \ - _IMP_PCLASS(cls, _X_POINTERS_##ptrs##(cls), _X_ABSTRACT_##isabstract##(cls), _X_FIELDS_##fields##(cls)) + _IMP_PCLASS(cls, _X_POINTERS_##ptrs##(cls), _X_ABSTRACT_##isabstract##(cls), _X_FIELDS_##fields##(cls), _X_VMEXPORT_##vmexport##(cls)) // Taking the address of a field in an object at address 1 instead of // address 0 keeps GCC from complaining about possible misuse of offsetof. @@ -218,6 +220,8 @@ protected: \ #define _X_CONSTRUCTOR_false(cls) void cls::InPlaceConstructor(void *mem) { new((EInPlace *)mem) cls; } #define _X_ABSTRACT_true(cls) nullptr #define _X_ABSTRACT_false(cls) cls::InPlaceConstructor +#define _X_VMEXPORT_true(cls) &DVMObject::RegistrationInfo +#define _X_VMEXPORT_false(cls) nullptr enum EObjectFlags { @@ -643,6 +647,7 @@ ClassReg DVMObject::RegistrationInfo = DVMObject::FormatClassName(), &DVMObject::Super::RegistrationInfo, nullptr, + nullptr, DVMObject::InPlaceConstructor, nullptr, sizeof(DVMObject), diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 9d3022966..89b9986cc 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -2847,7 +2847,7 @@ PClass *ClassReg::RegisterClass() assert(0 && "Class registry has an invalid meta class identifier"); } - if (metaclasses[MetaClassNum]->MyClass == NULL) + if (metaclasses[MetaClassNum]->MyClass == nullptr) { // Make sure the meta class is already registered before registering this one metaclasses[MetaClassNum]->RegisterClass(); } @@ -2855,10 +2855,14 @@ PClass *ClassReg::RegisterClass() SetupClass(cls); cls->InsertIntoHash(); - if (ParentType != NULL) + if (ParentType != nullptr) { cls->ParentClass = ParentType->RegisterClass(); } + if (VMExport != nullptr) + { + cls->VMExported = VMExport->RegisterClass(); + } return cls; } diff --git a/src/dobjtype.h b/src/dobjtype.h index d907feeeb..e1f95a828 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -769,6 +769,7 @@ public: // Per-class information ------------------------------------- PClass *ParentClass; // the class this class derives from + PClass *VMExported; // this is here to allow script classes to override native virtual functions const size_t *Pointers; // object pointers defined by this class *only* const size_t *FlatPointers; // object pointers defined by this class and all its superclasses; not initialized by default BYTE *Defaults;