| 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 | { |
nothing calls this directly
no test coverage detected