コード例 #1
0
ファイル: wrap_Joystick.cpp プロジェクト: AnisB/love
	int luaopen_love_joystick(lua_State * L)
	{
		if(instance == 0)
		{
			try
			{
				instance = new Joystick();
			}
			catch(Exception & e)
			{
				return luaL_error(L, e.what());
			}
		}
		else
			instance->retain();


		WrappedModule w;
		w.module = instance;
		w.name = "joystick";
		w.flags = MODULE_T;
		w.functions = functions;
		w.types = 0;

		return luax_register_module(L, w);
	}
コード例 #2
0
ファイル: wrap_Graphics.cpp プロジェクト: AnisB/love
	int luaopen_love_graphics(lua_State * L)
	{
		if(instance == 0)
		{
			try
			{
				instance = new Graphics();
			}
			catch(Exception & e)
			{
				return luaL_error(L, e.what());
			}
		}
		else
			instance->retain();

		WrappedModule w;
		w.module = instance;
		w.name = "graphics";
		w.flags = MODULE_T;
		w.functions = functions;
		w.types = types;

		luax_register_module(L, w);

		if (luaL_loadbuffer(L, (const char *)graphics_lua, sizeof(graphics_lua), "graphics.lua") == 0)
			lua_call(L, 0, 0);

		return 0;
	}
コード例 #3
0
ファイル: wrap_Sound.cpp プロジェクト: ascetic85/love2d
extern "C" int luaopen_love_sound(lua_State *L)
{
    if (instance == 0)
    {
        try
        {
            instance = new lullaby::Sound();
        }
        catch(Exception &e)
        {
            return luaL_error(L, e.what());
        }
    }
    else
        instance->retain();


    WrappedModule w;
    w.module = instance;
    w.name = "sound";
    w.flags = MODULE_SOUND_T;
    w.functions = functions;
    w.types = types;

    return luax_register_module(L, w);
}
コード例 #4
0
ファイル: wrap_Image.cpp プロジェクト: joedrago/love
extern "C" int luaopen_love_image(lua_State *L)
{
	if (instance == 0)
	{
		try
		{
			instance = new love::image::magpie::Image();
		}
		catch(Exception &e)
		{
			return luaL_error(L, "%s", e.what());
		}
	}
	else
		instance->retain();

	WrappedModule w;
	w.module = instance;
	w.name = "image";
	w.flags = MODULE_IMAGE_T;
	w.functions = functions;
	w.types = types;

	return luax_register_module(L, w);
}
コード例 #5
0
ファイル: wrap_Keyboard.cpp プロジェクト: ascetic85/love2d
extern "C" int luaopen_love_keyboard(lua_State *L)
{
	if (instance == 0)
	{
		try
		{
			instance = new love::keyboard::sdl::Keyboard();
		}
		catch(Exception &e)
		{
			return luaL_error(L, e.what());
		}
	}
	else
		instance->retain();

	WrappedModule w;
	w.module = instance;
	w.name = "keyboard";
	w.flags = MODULE_T;
	w.functions = functions;
	w.types = 0;

	return luax_register_module(L, w);
}
コード例 #6
0
ファイル: wrap_Thread.cpp プロジェクト: PaulForey/lovepd
	extern "C" int luaopen_love_thread(lua_State *L)
	{
		if (instance == 0)
		{
			try
			{
				instance = new ThreadModule();
				lua_getglobal(L, "love");
				Thread *curthread = instance->getThread("main");
				curthread->lock();
				curthread->retain();
				curthread->unlock();
				luax_newtype(L, "Thread", THREAD_THREAD_T, (void*)curthread);
				lua_setfield(L, -2, "_curthread");
			}
			catch (Exception & e)
			{
				return luaL_error(L, e.what());
			}
		}
		else
			instance->retain();

		WrappedModule w;
		w.module = instance;
		w.name = "thread";
		w.flags = MODULE_T;
		w.functions = module_functions;
		w.types = types;

		return luax_register_module(L, w);
	}
コード例 #7
0
ファイル: wrap_ThreadModule.cpp プロジェクト: joedrago/love
extern "C" int luaopen_love_thread(lua_State *L)
{
	if (instance == 0)
	{
		try
		{
			instance = new ThreadModule();
		}
		catch (Exception & e)
		{
			return luaL_error(L, "%s", e.what());
		}
	}
	else
		instance->retain();

	WrappedModule w;
	w.module = instance;
	w.name = "thread";
	w.flags = MODULE_T;
	w.functions = module_functions;
	w.types = types;

	return luax_register_module(L, w);
}
コード例 #8
0
ファイル: wrap_Filesystem.cpp プロジェクト: AnisB/love
	int luaopen_love_filesystem(lua_State * L)
	{
		if(instance == 0)
		{
			try
			{
				instance = new Filesystem();
				love::luax_register_searcher(L, loader);
			}
			catch(Exception & e)
			{
				return luaL_error(L, e.what());
			}
		}
		else
			instance->retain();

		WrappedModule w;
		w.module = instance;
		w.name = "filesystem";
		w.flags = MODULE_FILESYSTEM_T;
		w.functions = functions;
		w.types = types;

		return luax_register_module(L, w);
	}
コード例 #9
0
ファイル: wrap_Audio.cpp プロジェクト: Kivutar/love-libretro
extern "C" int luaopen_love_audio(lua_State *L)
{
	Audio *instance = instance();

#ifdef LOVE_ENABLE_AUDIO_OPENAL
	if (instance == nullptr)
	{
		// Try OpenAL first.
		try
		{
			instance = new love::audio::openal::Audio();
		}
		catch(love::Exception &e)
		{
			std::cout << e.what() << std::endl;
		}
	}
	else
		instance->retain();
#endif

#ifdef LOVE_ENABLE_AUDIO_NULL
	if (instance == nullptr)
	{
		// Fall back to nullaudio.
		try
		{
			instance = new love::audio::null::Audio();
		}
		catch(love::Exception &e)
		{
			std::cout << e.what() << std::endl;
		}
	}
#endif

	if (instance == nullptr)
		return luaL_error(L, "Could not open any audio module.");

	WrappedModule w;
	w.module = instance;
	w.name = "audio";
	w.type = MODULE_ID;
	w.functions = functions;
	w.types = types;

	int n = luax_register_module(L, w);

	return n;
}
コード例 #10
0
	int luaopen_love_audio(lua_State * L)
	{
		if(instance == 0)
		{
			// Try OpenAL first.
			try
			{
				instance = new love::audio::openal::Audio();
			}
			catch(love::Exception & e)
			{
				std::cout << e.what() << std::endl;
			}
		}
		else
			instance->retain();

		if(instance == 0)
		{
			// Fall back to nullaudio.
			try
			{
				instance = new love::audio::null::Audio();
			}
			catch(love::Exception & e)
			{
				std::cout << e.what() << std::endl;
			}
		}

		if(instance == 0)
			return luaL_error(L, "Could not open any audio module.");

		WrappedModule w;
		w.module = instance;
		w.name = "audio";
		w.flags = MODULE_T;
		w.functions = functions;
		w.types = types;

		luax_register_module(L, w);

		if (luaL_loadbuffer(L, (const char *)audio_lua, sizeof(audio_lua), "audio.lua") == 0)
			lua_call(L, 0, 0);

		return 0;
	}
コード例 #11
0
ファイル: wrap_Timer.cpp プロジェクト: JackDanger/love
	int wrap_Timer_open(lua_State * L)
	{
		if(instance == 0)
		{
			try 
			{
				instance = new Timer();
			} 
			catch(Exception & e)
			{
				return luaL_error(L, e.what());
			}
		}

		luax_register_gc(L, "love.timer", instance);

		return luax_register_module(L, wrap_Timer_functions, 0);
	}
コード例 #12
0
ファイル: wrap_Event.cpp プロジェクト: JackDanger/love
	int wrap_Event_signal_open(lua_State * L)
	{
		if(instance == 0)
		{
			try 
			{
				instance = new Event();
			} 
			catch(Exception & e)
			{
				return luaL_error(L, e.what());
			}
		}

		luax_register_gc(L, "love.event.signal", instance);

		return luax_register_module(L, wrap_Event_signal_functions, 0);
	}
コード例 #13
0
ファイル: wrap_Image.cpp プロジェクト: JackDanger/love
	int wrap_Image_open(lua_State * L)
	{

		if(instance == 0)
		{
			try 
			{
				instance = new love::image::devil::Image();
			} 
			catch(Exception & e)
			{
				return luaL_error(L, e.what());
			}
		}

		luax_register_gc(L, "love.image", instance);

		return luax_register_module(L, wrap_Image_functions, wrap_Image_types);
	}
コード例 #14
0
ファイル: wrap_System.cpp プロジェクト: MikuAuahDark/livesim4
extern "C" int luaopen_love_system(lua_State *L)
{
	System *instance = instance();
	if (instance == nullptr)
	{
		instance = new love::system::sdl::System();
	}
	else
		instance->retain();

	WrappedModule w;
	w.module = instance;
	w.name = "system";
	w.type = &Module::type;
	w.functions = functions;
	w.types = nullptr;

	return luax_register_module(L, w);
}
コード例 #15
0
extern "C" int luaopen_love_thread(lua_State *L)
{
	ThreadModule *instance = instance();
	if (instance == nullptr)
	{
		luax_catchexcept(L, [&](){ instance = new love::thread::ThreadModule(); });
	}
	else
		instance->retain();

	WrappedModule w;
	w.module = instance;
	w.name = "thread";
	w.type = &Module::type;
	w.functions = module_functions;
	w.types = types;

	return luax_register_module(L, w);
}
コード例 #16
0
extern "C" int luaopen_love_keyboard(lua_State *L)
{
	Keyboard *instance = instance();
	if (instance == nullptr)
	{
		luax_catchexcept(L, [&](){ instance = new love::keyboard::sdl::Keyboard(); });
	}
	else
		instance->retain();

	WrappedModule w;
	w.module = instance;
	w.name = "keyboard";
	w.type = MODULE_ID;
	w.functions = functions;
	w.types = 0;

	return luax_register_module(L, w);
}
コード例 #17
0
ファイル: wrap_Font.cpp プロジェクト: Kivutar/love-libretro
extern "C" int luaopen_love_font(lua_State *L)
{
	Font *instance = instance();
	if (instance == nullptr)
	{
		luax_catchexcept(L, [&](){ instance = new freetype::Font(); });
	}
	else
		instance->retain();

	WrappedModule w;
	w.module = instance;
	w.name = "font";
	w.type = MODULE_ID;
	w.functions = functions;
	w.types = types;

	return luax_register_module(L, w);
}
コード例 #18
0
ファイル: wrap_Image.cpp プロジェクト: Kivutar/love-libretro
extern "C" int luaopen_love_image(lua_State *L)
{
	Image *instance = instance();
	if (instance == nullptr)
	{
		luax_catchexcept(L, [&](){ instance = new love::image::magpie::Image(); });
	}
	else
		instance->retain();

	WrappedModule w;
	w.module = instance;
	w.name = "image";
	w.type = MODULE_IMAGE_ID;
	w.functions = functions;
	w.types = types;

	return luax_register_module(L, w);
}
コード例 #19
0
extern "C" int luaopen_love_filesystem(lua_State *L)
{
	Filesystem *instance = instance();
	if (instance == nullptr)
	{
		luax_catchexcept(L, [&](){ instance = new physfs::Filesystem(); });
	}
	else
		instance->retain();

	// The love loaders should be tried after package.preload.
	love::luax_register_searcher(L, loader, 2);
	love::luax_register_searcher(L, extloader, 3);

	WrappedModule w;
	w.module = instance;
	w.name = "filesystem";
	w.type = MODULE_FILESYSTEM_ID;
	w.functions = functions;
	w.types = types;

	return luax_register_module(L, w);
}