]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/mag/server/src/plugin.cc
5be3d9a4a6fa6ab22c39fafffcc631083445b945
[l4.git] / l4 / pkg / mag / server / src / plugin.cc
1 /*
2  * (c) 2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3  *          Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  */
10 #include "plugin"
11 #include "lua"
12
13 #include <lua.h>
14 #include <lauxlib.h>
15
16
17 namespace Mag_server {
18
19 Plugin *Plugin::_first;
20
21 Core_api::Core_api(Registry *r, lua_State *lua, User_state *u,
22                    L4::Cap<void> rcvc, L4::Cap<L4Re::Video::Goos> fb)
23 : _reg(r), _ust(u), _rcv_cap(rcvc), _fb(fb), _lua(lua)
24 {
25   lua_pushlightuserdata(_lua, this);
26   lua_newtable(_lua);
27   lua_rawset(_lua, LUA_REGISTRYINDEX);
28 }
29
30 void
31 Core_api::get_refs_table() const
32 {
33   lua_pushlightuserdata(_lua, const_cast<Core_api*>(this));
34   lua_rawget(_lua, LUA_REGISTRYINDEX);
35 }
36
37
38 void
39 Core_api::add_input_source(Input_source *i)
40 {
41   i->_next_active = _input;
42   _input = i;
43   get_refs_table();
44   i->add_lua_input_source(_lua, -1);
45   lua_pop(_lua, 1);
46 }
47
48
49 }
50