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

Method GetFunctionByDecl

sdk/angelscript/source/as_module.cpp:923–986  ·  view source on GitHub ↗

interface

Source from the content-addressed store, hash-verified

921
922// interface
923asIScriptFunction *asCModule::GetFunctionByDecl(const char *decl) const
924{
925 asCBuilder bld(m_engine, const_cast<asCModule*>(this));
926
927 // Don't write parser errors to the message callback
928 bld.silent = true;
929
930 asCScriptFunction func(m_engine, const_cast<asCModule*>(this), asFUNC_DUMMY);
931 int r = bld.ParseFunctionDeclaration(0, decl, &func, false, 0, 0, m_defaultNamespace);
932 if( r < 0 )
933 {
934 // Invalid declaration
935 // TODO: Write error to message stream
936 return 0;
937 }
938
939 // Use the defaultNamespace implicitly unless an explicit namespace has been provided
940 asSNameSpace *ns = func.nameSpace == m_engine->nameSpaces[0] ? m_defaultNamespace : func.nameSpace;
941
942 // Search script functions for matching interface
943 while( ns )
944 {
945 asIScriptFunction *f = 0;
946 const asCArray<unsigned int> &idxs = m_globalFunctions.GetIndexes(ns, func.name);
947 for( unsigned int n = 0; n < idxs.GetLength(); n++ )
948 {
949 const asCScriptFunction *funcPtr = m_globalFunctions.Get(idxs[n]);
950 if( funcPtr->objectType == 0 &&
951 func.returnType == funcPtr->returnType &&
952 func.parameterTypes.GetLength() == funcPtr->parameterTypes.GetLength()
953 )
954 {
955 bool match = true;
956 for( asUINT p = 0; p < func.parameterTypes.GetLength(); ++p )
957 {
958 if( func.parameterTypes[p] != funcPtr->parameterTypes[p] )
959 {
960 match = false;
961 break;
962 }
963 }
964
965 if( match )
966 {
967 if( f == 0 )
968 f = const_cast<asCScriptFunction*>(funcPtr);
969 else
970 // Multiple functions
971 return 0;
972 }
973 }
974 }
975
976 if( f )
977 return f;
978 else
979 {
980 // Search for matching functions in the parent namespace

Callers 15

mainFunction · 0.80
RunApplicationFunction · 0.80
ExecuteScriptFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
RunApplicationFunction · 0.80
BuildMethod · 0.80
Test3Function · 0.80
TestFunction · 0.80
TestSwitchFunction · 0.80
TestFunction · 0.80

Calls 4

GetParentNameSpaceMethod · 0.80
GetLengthMethod · 0.45
GetMethod · 0.45

Tested by 15

Test3Function · 0.64
TestFunction · 0.64
TestSwitchFunction · 0.64
TestFunction · 0.64
TestStackFunction · 0.64
TestFunction · 0.64
TestNalinFunction · 0.64
TestFunction · 0.64
TestFunction · 0.64
TestModuleRefFunction · 0.64
TestFunction · 0.64
TestFunction · 0.64