MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / dukglue_register_function

Function dukglue_register_function

Source/Utils/dukglue/register_function.h:24–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22// Register a function.
23template<typename RetType, typename... Ts>
24void dukglue_register_function(duk_context* ctx, RetType(*funcToCall)(Ts...), const char* name)
25{
26 duk_c_function evalFunc = dukglue::detail::FuncInfoHolder<RetType, Ts...>::FuncRuntime::call_native_function;
27
28 duk_push_c_function(ctx, evalFunc, sizeof...(Ts));
29
30 static_assert(sizeof(RetType(*)(Ts...)) == sizeof(void*), "Function pointer and data pointer are different sizes");
31 duk_push_pointer(ctx, reinterpret_cast<void*>(funcToCall));
32 duk_put_prop_string(ctx, -2, "\xFF" "func_ptr");
33
34 duk_put_global_string(ctx, name);
35}

Callers 1

initMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected