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

Method AddBehaviourFunction

sdk/angelscript/source/as_scriptengine.cpp:2672–2715  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2670}
2671
2672int asCScriptEngine::AddBehaviourFunction(asCScriptFunction &func, asSSystemFunctionInterface &internal)
2673{
2674 asUINT n;
2675
2676 int id = GetNextScriptFunctionId();
2677
2678 asSSystemFunctionInterface *newInterface = asNEW(asSSystemFunctionInterface)(internal);
2679 if( newInterface == 0 )
2680 return asOUT_OF_MEMORY;
2681
2682 asCScriptFunction *f = asNEW(asCScriptFunction)(this, 0, asFUNC_SYSTEM);
2683 if( f == 0 )
2684 {
2685 asDELETE(newInterface, asSSystemFunctionInterface);
2686 return asOUT_OF_MEMORY;
2687 }
2688
2689 asASSERT(func.name != "" && func.name != "f");
2690 f->name = func.name;
2691 f->sysFuncIntf = newInterface;
2692 f->returnType = func.returnType;
2693 f->objectType = func.objectType;
2694 if( f->objectType )
2695 f->objectType->AddRefInternal();
2696 f->id = id;
2697 f->SetReadOnly(func.IsReadOnly());
2698 f->accessMask = defaultAccessMask;
2699 f->parameterTypes = func.parameterTypes;
2700 f->parameterNames = func.parameterNames;
2701 f->inOutFlags = func.inOutFlags;
2702 f->traits = func.traits;
2703 for( n = 0; n < func.defaultArgs.GetLength(); n++ )
2704 if( func.defaultArgs[n] )
2705 f->defaultArgs.PushLast(asNEW(asCString)(*func.defaultArgs[n]));
2706 else
2707 f->defaultArgs.PushLast(0);
2708
2709 AddScriptFunction(f);
2710
2711 // If parameter type from other groups are used, add references
2712 currentGroup->AddReferencesForFunc(this, f);
2713
2714 return id;
2715}
2716
2717// interface
2718int asCScriptEngine::RegisterGlobalProperty(const char *declaration, void *pointer)

Callers

nothing calls this directly

Calls 6

SetReadOnlyMethod · 0.80
PushLastMethod · 0.80
AddReferencesForFuncMethod · 0.80
AddRefInternalMethod · 0.45
IsReadOnlyMethod · 0.45
GetLengthMethod · 0.45

Tested by

no test coverage detected