示例#1
0
LUABIND_API object make_function_aux(lua_State* L, function_object* impl)
{
    void* storage = lua_newuserdata(L, sizeof(function_object*));
    push_function_metatable(L);
    *(function_object**)storage = impl;
    lua_setmetatable(L, -2);

    lua_pushlightuserdata(L, &function_tag);
    lua_pushcclosure(L, impl->entry, 2);
    stack_pop pop(L, 1);

    return object(from_stack(L, -1));
}
示例#2
0
LUABIND_API object make_function_aux(
    lua_State* L, int arity
  , function_callback const& call
  , function_callback const& score
  , signature_callback const& signature
)
{
    void* storage = lua_newuserdata(L, sizeof(function));
    push_function_metatable(L);
    new (storage) function(arity, call, score, signature);
    lua_setmetatable(L, -2);

    lua_pushcclosure(L, &function_dispatcher, 1);
    stack_pop pop(L, 1);

    return object(from_stack(L, -1));
}