interface
| 2098 | |
| 2099 | // interface |
| 2100 | int 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 |
| 2130 | int asCScriptEngine::RegisterBehaviourToObjectType(asCObjectType *objectType, asEBehaviours behaviour, const char *decl, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary, int compositeOffset, bool isCompositeIndirect) |