Ejemplo n.º 1
0
    def test_register_global(self):
        state = _luabject.new()

        class Test(object):
            def __init__(self):
                self.ran = False
            def __call__(self):
                self.ran = True

        tester = Test()
        _luabject.register_global(state, "hi", tester)

        self.load_script_to_completion(state, "function foo() hi() end")
        thread = _luabject.new_thread(state)
        _luabject.load_function(thread, "foo")
        _luabject.pump_thread(thread)
        while _luabject.LUA_YIELD == _luabject.thread_status(thread):
            _luabject.pump_thread(thread)

        self.assertTrue(tester.ran)
Ejemplo n.º 2
0
 def register_global(self, name, fn):
     _luabject.register_global(self._state, name, fn)