MCPcopy Create free account
hub / github.com/anjo76/angelscript / RegisterObjectBehaviour

Method RegisterObjectBehaviour

sdk/angelscript/source/as_scriptengine.cpp:2100–2127  ·  view source on GitHub ↗

interface

Source from the content-addressed store, hash-verified

2098
2099// interface
2100int asCScriptEngine::RegisterObjectBehaviour(const char *datatype, asEBehaviours behaviour, const char *decl, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary, int compositeOffset, bool isCompositeIndirect)
2101{
2102 if( datatype == 0 ) return ConfigError(asINVALID_ARG, "RegisterObjectBehaviour", datatype, decl);
2103
2104 // Determine the object type
2105 asCBuilder bld(this, 0);
2106 asCDataType type;
2107 int r = bld.ParseDataType(datatype, &type, defaultNamespace);
2108 if( r < 0 )
2109 return ConfigError(r, "RegisterObjectBehaviour", datatype, decl);
2110
2111 if( type.GetTypeInfo() == 0 || (type.IsObjectHandle() && !(type.GetTypeInfo()->GetFlags() & asOBJ_IMPLICIT_HANDLE)) )
2112 return ConfigError(asINVALID_TYPE, "RegisterObjectBehaviour", datatype, decl);
2113
2114 // Don't allow application to modify built-in types
2115 if( type.GetTypeInfo() == &functionBehaviours ||
2116 type.GetTypeInfo() == &scriptTypeBehaviours )
2117 return ConfigError(asINVALID_TYPE, "RegisterObjectBehaviour", datatype, decl);
2118
2119 if( type.IsReadOnly() || type.IsReference() )
2120 return ConfigError(asINVALID_TYPE, "RegisterObjectBehaviour", datatype, decl);
2121
2122 // Don't allow modifying generated template instances
2123 if( type.GetTypeInfo() && (type.GetTypeInfo()->flags & asOBJ_TEMPLATE) && generatedTemplateTypes.Exists(CastToObjectType(type.GetTypeInfo())) )
2124 return ConfigError(asINVALID_TYPE, "RegisterObjectBehaviour", datatype, decl);
2125
2126 return RegisterBehaviourToObjectType(CastToObjectType(type.GetTypeInfo()), behaviour, decl, funcPointer, callConv, auxiliary, compositeOffset, isCompositeIndirect);
2127}
2128
2129// internal
2130int asCScriptEngine::RegisterBehaviourToObjectType(asCObjectType *objectType, asEBehaviours behaviour, const char *decl, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary, int compositeOffset, bool isCompositeIndirect)

Calls 8

CastToObjectTypeFunction · 0.85
GetTypeInfoMethod · 0.80
IsObjectHandleMethod · 0.80
GetFlagsMethod · 0.80
ParseDataTypeMethod · 0.45
IsReadOnlyMethod · 0.45
IsReferenceMethod · 0.45
ExistsMethod · 0.45

Tested by 15

TestMultipleInheritance2Function · 0.64
asRegisterMethod · 0.64
asRegisterObjectMethod · 0.64
TestFunction · 0.64
TestFunction · 0.64
Test4Function · 0.64
Test7Function · 0.64
TestRetRefFunction · 0.64
TestFunction · 0.64
TestFunction · 0.64
TestConditionFunction · 0.64
RegisterAFunction · 0.64