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

Method RegisterObjectMethod

sdk/angelscript/source/as_scriptengine.cpp:2883–2910  ·  view source on GitHub ↗

interface

Source from the content-addressed store, hash-verified

2881
2882// interface
2883int asCScriptEngine::RegisterObjectMethod(const char *obj, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary, int compositeOffset, bool isCompositeIndirect)
2884{
2885 if( obj == 0 )
2886 return ConfigError(asINVALID_ARG, "RegisterObjectMethod", obj, declaration);
2887
2888 // Determine the object type
2889 asCDataType dt;
2890 asCBuilder bld(this, 0);
2891 int r = bld.ParseDataType(obj, &dt, defaultNamespace);
2892 if( r < 0 )
2893 return ConfigError(r, "RegisterObjectMethod", obj, declaration);
2894
2895 // Don't allow application to modify primitives or handles
2896 if( dt.GetTypeInfo() == 0 || (dt.IsObjectHandle() && !(dt.GetTypeInfo()->GetFlags() & asOBJ_IMPLICIT_HANDLE)))
2897 return ConfigError(asINVALID_ARG, "RegisterObjectMethod", obj, declaration);
2898
2899 // Don't allow application to modify built-in types or funcdefs
2900 if( dt.GetTypeInfo() == &functionBehaviours ||
2901 dt.GetTypeInfo() == &scriptTypeBehaviours ||
2902 CastToFuncdefType(dt.GetTypeInfo()) )
2903 return ConfigError(asINVALID_ARG, "RegisterObjectMethod", obj, declaration);
2904
2905 // Don't allow modifying generated template instances
2906 if( dt.GetTypeInfo() && (dt.GetTypeInfo()->flags & asOBJ_TEMPLATE) && generatedTemplateTypes.Exists(CastToObjectType(dt.GetTypeInfo())) )
2907 return ConfigError(asINVALID_TYPE, "RegisterObjectMethod", obj, declaration);
2908
2909 return RegisterMethodToObjectType(CastToObjectType(dt.GetTypeInfo()), declaration, funcPointer, callConv, auxiliary, compositeOffset, isCompositeIndirect);
2910}
2911
2912// internal
2913int asCScriptEngine::RegisterMethodToObjectType(asCObjectType *objectType, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary, int compositeOffset, bool isCompositeIndirect)

Calls 7

CastToFuncdefTypeFunction · 0.85
CastToObjectTypeFunction · 0.85
GetTypeInfoMethod · 0.80
IsObjectHandleMethod · 0.80
GetFlagsMethod · 0.80
ParseDataTypeMethod · 0.45
ExistsMethod · 0.45

Tested by 15

TestFunction · 0.64
TestMultipleInheritanceFunction · 0.64
TestMultipleInheritance2Function · 0.64
asRegisterMethod · 0.64
TestFunction · 0.64
TestFunction · 0.64
Test2Function · 0.64
Test4Function · 0.64
Test7Function · 0.64
TestRetRefFunction · 0.64
TestFunction · 0.64
TestFunction · 0.64