5 #include <l4/re/util/cap_alloc>
7 #include <l4/sys/factory>
16 namespace Lua { namespace {
21 int argc = lua_gettop(l);
22 Lua::Cap *n = check_cap(l, 1);
23 int objt = luaL_checkint(l, 2);
25 L4Re::Util::Auto_cap<L4::Kobject>::Cap obj
26 = L4Re::Util::cap_alloc.alloc<L4::Kobject>();
29 luaL_error(l, "out of caps");
31 L4::Cap<L4::Factory> f(n->cap<L4::Factory>().get());
32 L4::Factory::S s = f->create(obj.get(), objt);
33 for (int i = 3; i <= argc; ++i)
35 if (lua_isnumber(l, i))
36 s << (l4_mword_t)luaL_checkint(l, i);
37 else if (lua_isstring(l, i))
38 s << (char const *)luaL_checkstring(l, i);
39 else if (lua_isnil(l, i))
40 s << L4::Factory::Nil();
47 luaL_error(l, "runtime error %s (%d)", l4sys_errtostr(r), r);
49 lua_pushinteger(l, objt);
50 Cap *nc = Lua::push_new_cap(l, true);
61 register_methods(lua_State *l)
63 static const luaL_Reg l4_cap_class[] =
65 { "create", __alloc },
68 luaL_register(l, NULL, l4_cap_class);
69 Cap::add_class_metatable(l);
73 static Lua::Cap_type_lib<L4::Factory, Factory_model> __lib;