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

Method RegisterScriptFunction

sdk/angelscript/source/as_builder.cpp:5211–5670  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5209}
5210
5211int asCBuilder::RegisterScriptFunction(asCScriptNode *node, asCScriptCode *file, asCObjectType *objType, bool isInterface, bool isGlobalFunction, asSNameSpace *ns, bool isExistingShared, bool isMixin, asCString &name, asCDataType &returnType, asCArray<asCString> &parameterNames, asCArray<asCDataType> &parameterTypes, asCArray<asETypeModifiers> &inOutFlags, asCArray<asCString *> &defaultArgs, asSFunctionTraits funcTraits, sClassDeclaration* classDecl)
5212{
5213 // Determine default namespace if not specified
5214 if( ns == 0 )
5215 {
5216 if( objType )
5217 ns = objType->nameSpace;
5218 else
5219 ns = engine->nameSpaces[0];
5220 }
5221
5222 if( isExistingShared )
5223 {
5224 asASSERT( objType );
5225
5226 // Should validate that the function really exists in the class/interface
5227 bool found = false;
5228 if(funcTraits.GetTrait(asTRAIT_CONSTRUCTOR) || funcTraits.GetTrait(asTRAIT_DESTRUCTOR) )
5229 {
5230 // TODO: shared: Should check the existance of these too
5231 found = true;
5232 }
5233 else
5234 {
5235 for( asUINT n = 0; n < objType->methods.GetLength(); n++ )
5236 {
5237 asCScriptFunction *func = engine->scriptFunctions[objType->methods[n]];
5238 if( func->name == name &&
5239 func->IsSignatureExceptNameEqual(returnType, parameterTypes, inOutFlags, objType, funcTraits.GetTrait(asTRAIT_CONST)) )
5240 {
5241 // Add the shared function in this module too
5242 module->AddScriptFunction(func);
5243
5244 found = true;
5245 break;
5246 }
5247 }
5248 }
5249
5250 if( !found )
5251 {
5252 asCString str;
5253 str.Format(TXT_SHARED_s_DOESNT_MATCH_ORIGINAL, objType->GetName());
5254 WriteError(str, file, node);
5255 }
5256
5257 // Free the default args
5258 for( asUINT n = 0; n < defaultArgs.GetLength(); n++ )
5259 if( defaultArgs[n] )
5260 asDELETE(defaultArgs[n], asCString);
5261
5262 node->Destroy(engine);
5263 return 0;
5264 }
5265
5266 // Check for name conflicts
5267 if( !funcTraits.GetTrait(asTRAIT_CONSTRUCTOR) && !funcTraits.GetTrait(asTRAIT_DESTRUCTOR) )
5268 {

Callers

nothing calls this directly

Calls 15

GetTraitMethod · 0.80
DestroyMethod · 0.80
SubStringMethod · 0.80
GetTypeInfoMethod · 0.80
PushLastMethod · 0.80
PopLastMethod · 0.80
PutMethod · 0.80
ConvertPosToRowColMethod · 0.80
IsObjectHandleMethod · 0.80

Tested by

no test coverage detected