MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / function_dispatcher

Function function_dispatcher

ogsr_engine/Luabind/src/function.cpp:45–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43 }
44
45 int function_dispatcher(lua_State* L)
46 {
47 function_rep* rep = static_cast<function_rep*>(
48 lua_touserdata(L, lua_upvalueindex(1))
49 );
50
51 bool ambiguous = false;
52 int min_match = std::numeric_limits<int>::max();
53 int match_index = -1;
54 bool ret;
55
56#ifdef LUABIND_NO_ERROR_CHECKING
57 if (rep->overloads().size() == 1)
58 {
59 match_index = 0;
60 }
61 else
62 {
63#endif
64 int num_params = lua_gettop(L);
65 ret = find_best_match(
66 L
67 , &rep->overloads().front()
68 , rep->overloads().size()
69 , sizeof(overload_rep)
70 , ambiguous
71 , min_match
72 , match_index
73 , num_params
74 );
75#ifdef LUABIND_NO_ERROR_CHECKING
76 }
77#else
78 if (!ret)
79 {
80 // this bock is needed to make sure the string_class is destructed
81 {
82 string_class msg = "no match for function call '";
83 msg += rep->name();
84 msg += "' with the parameters (";
85 msg += stack_content_by_name(L, 1);
86 msg += ")\ncandidates are:\n";
87
88 msg += get_overload_signatures(
89 L
90 , rep->overloads().begin()
91 , rep->overloads().end()
92 , rep->name()
93 );
94
95 lua_pushstring(L, msg.c_str());
96 }
97
98 lua_error(L);
99 }
100
101 if (ambiguous)
102 {

Callers

nothing calls this directly

Calls 13

get_overload_signaturesFunction · 0.85
lua_touserdataFunction · 0.50
maxFunction · 0.50
lua_gettopFunction · 0.50
lua_pushstringFunction · 0.50
lua_errorFunction · 0.50
sizeMethod · 0.45
frontMethod · 0.45
nameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected