I've played a little bit with AS code, and was able to modify it to support inheritence from other classes (for now: only single inheritence). Here are the steps: - (as_objecttype.h) asCObjectType:
- (as_scriptengine.h) asCScriptEngine (also modify angelscript.h):
RegisterObjectType(const char *objname, int byteSize, asDWORD flags, const char *objparent);
- (as_scriptengine.cpp) asCScriptEngine::RegisterObjectType:
asCObjectType *parent = 0;
for( n = 0; n < objectTypes.GetLength(); n++ )
{
if( objectTypes[n]->name == name )
return asALREADY_REGISTERED;
if ( objparent != 0 && objectTypes[n]->name == objparent )
parent = objectTypes[n];
}
for( n = 0; n < arrayTypes.GetLength(); n++ )
{
if( arrayTypes[n]->name == name )
return asALREADY_REGISTERED;
if ( objparent != 0 && arrayTypes[n]->name == objparent )
parent = arrayTypes[n];
}
if ( objparent !=0 && parent == 0)
return ConfigError(asINVALID_NAME);
.
.
.
type->parent = parent;
- (as_builder.cpp) GetObjectProperty
asCProperty *asCBuilder::GetObjectProperty(asCDataType &obj, const char *prop)
{
assert(obj.GetObjectType() >= 0);
// TODO: Only search in config groups to which the module has access
// TODO: Improve linear search
for ( asCObjectType *object = obj.GetObjectType(); object != 0; object = object->parent )
{
asCArray<asCProperty *> &props = object->properties;
for( asUINT n = 0; n < props.GetLength(); n++ )
if( props[n]->name == prop )
return props[n];
}
return 0;
}
- (as_builder.cpp) GetObjectMethodDescriptions Add:
if ( objectType->parent != 0 )
GetObjectMethodDescriptions(name, objectType->parent, methods, objIsConst);
Please add your comments...