interface
| 2881 | |
| 2882 | // interface |
| 2883 | int 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 |
| 2913 | int asCScriptEngine::RegisterMethodToObjectType(asCObjectType *objectType, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary, int compositeOffset, bool isCompositeIndirect) |