mirror of
https://github.com/love2d/love.git
synced 2026-08-19 12:14:20 +02:00
Say hello to the love module. Oh my!
Because technically, it *is* a module. Also renamed "launcher.cpp".
This commit is contained in:
@@ -364,7 +364,6 @@
|
|||||||
<ClCompile Include="..\..\src\libraries\luasocket\libluasocket\udp.c" />
|
<ClCompile Include="..\..\src\libraries\luasocket\libluasocket\udp.c" />
|
||||||
<ClCompile Include="..\..\src\libraries\luasocket\libluasocket\wsocket.c" />
|
<ClCompile Include="..\..\src\libraries\luasocket\libluasocket\wsocket.c" />
|
||||||
<ClCompile Include="..\..\src\libraries\luasocket\luasocket.cpp" />
|
<ClCompile Include="..\..\src\libraries\luasocket\luasocket.cpp" />
|
||||||
<ClCompile Include="..\..\src\love.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\modules\audio\Audio.cpp" />
|
<ClCompile Include="..\..\src\modules\audio\Audio.cpp" />
|
||||||
<ClCompile Include="..\..\src\modules\audio\null\Audio.cpp" />
|
<ClCompile Include="..\..\src\modules\audio\null\Audio.cpp" />
|
||||||
<ClCompile Include="..\..\src\modules\audio\null\Source.cpp" />
|
<ClCompile Include="..\..\src\modules\audio\null\Source.cpp" />
|
||||||
@@ -428,6 +427,7 @@
|
|||||||
<ClCompile Include="..\..\src\modules\keyboard\Keyboard.cpp" />
|
<ClCompile Include="..\..\src\modules\keyboard\Keyboard.cpp" />
|
||||||
<ClCompile Include="..\..\src\modules\keyboard\sdl\Keyboard.cpp" />
|
<ClCompile Include="..\..\src\modules\keyboard\sdl\Keyboard.cpp" />
|
||||||
<ClCompile Include="..\..\src\modules\keyboard\wrap_Keyboard.cpp" />
|
<ClCompile Include="..\..\src\modules\keyboard\wrap_Keyboard.cpp" />
|
||||||
|
<ClCompile Include="..\..\src\modules\love\love.cpp" />
|
||||||
<ClCompile Include="..\..\src\modules\mouse\Mouse.cpp" />
|
<ClCompile Include="..\..\src\modules\mouse\Mouse.cpp" />
|
||||||
<ClCompile Include="..\..\src\modules\mouse\sdl\Mouse.cpp" />
|
<ClCompile Include="..\..\src\modules\mouse\sdl\Mouse.cpp" />
|
||||||
<ClCompile Include="..\..\src\modules\mouse\wrap_Mouse.cpp" />
|
<ClCompile Include="..\..\src\modules\mouse\wrap_Mouse.cpp" />
|
||||||
@@ -655,6 +655,7 @@
|
|||||||
<ClInclude Include="..\..\src\modules\keyboard\Keyboard.h" />
|
<ClInclude Include="..\..\src\modules\keyboard\Keyboard.h" />
|
||||||
<ClInclude Include="..\..\src\modules\keyboard\sdl\Keyboard.h" />
|
<ClInclude Include="..\..\src\modules\keyboard\sdl\Keyboard.h" />
|
||||||
<ClInclude Include="..\..\src\modules\keyboard\wrap_Keyboard.h" />
|
<ClInclude Include="..\..\src\modules\keyboard\wrap_Keyboard.h" />
|
||||||
|
<ClInclude Include="..\..\src\modules\love\love.h" />
|
||||||
<ClInclude Include="..\..\src\modules\mouse\Mouse.h" />
|
<ClInclude Include="..\..\src\modules\mouse\Mouse.h" />
|
||||||
<ClInclude Include="..\..\src\modules\mouse\sdl\Mouse.h" />
|
<ClInclude Include="..\..\src\modules\mouse\sdl\Mouse.h" />
|
||||||
<ClInclude Include="..\..\src\modules\mouse\wrap_Mouse.h" />
|
<ClInclude Include="..\..\src\modules\mouse\wrap_Mouse.h" />
|
||||||
|
|||||||
@@ -130,9 +130,11 @@
|
|||||||
<Filter Include="modules\window\sdl">
|
<Filter Include="modules\window\sdl">
|
||||||
<UniqueIdentifier>{d46cbbf1-a76f-4401-83d4-1f20492f9889}</UniqueIdentifier>
|
<UniqueIdentifier>{d46cbbf1-a76f-4401-83d4-1f20492f9889}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="modules\love">
|
||||||
|
<UniqueIdentifier>{5fb201c1-9b39-48ca-8334-6862da260b43}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\src\love.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\common\Matrix.cpp">
|
<ClCompile Include="..\..\src\common\Matrix.cpp">
|
||||||
<Filter>common</Filter>
|
<Filter>common</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -733,6 +735,9 @@
|
|||||||
<ClCompile Include="..\..\src\modules\window\sdl\Window.cpp">
|
<ClCompile Include="..\..\src\modules\window\sdl\Window.cpp">
|
||||||
<Filter>modules\window\sdl</Filter>
|
<Filter>modules\window\sdl</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\modules\love\love.cpp">
|
||||||
|
<Filter>modules\love</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\src\scripts\boot.lua">
|
<None Include="..\..\src\scripts\boot.lua">
|
||||||
@@ -1412,6 +1417,9 @@
|
|||||||
<ClInclude Include="..\..\src\modules\window\sdl\Window.h">
|
<ClInclude Include="..\..\src\modules\window\sdl\Window.h">
|
||||||
<Filter>modules\window\sdl</Filter>
|
<Filter>modules\window\sdl</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\modules\love\love.h">
|
||||||
|
<Filter>modules\love</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="love.rc" />
|
<ResourceCompile Include="love.rc" />
|
||||||
|
|||||||
+12
-12
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
# Visual C++ Express 2010
|
# Visual C++ Express 2010
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "love", "love.vcxproj", "{B496CCF6-9B6D-0794-8F41-67A6EC86B4AA}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "love", "love.vcxproj", "{0078B97A-F6DB-E014-BED9-BE378D93CEA4}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{A3FCC735-3E18-4D6B-9DA9-01D9E910B7F8} = {A3FCC735-3E18-4D6B-9DA9-01D9E910B7F8}
|
{A3FCC735-3E18-4D6B-9DA9-01D9E910B7F8} = {A3FCC735-3E18-4D6B-9DA9-01D9E910B7F8}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
@@ -18,17 +18,17 @@ Global
|
|||||||
Release Static|x64 = Release Static|x64
|
Release Static|x64 = Release Static|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{B496CCF6-9B6D-0794-8F41-67A6EC86B4AA}.Debug Dynamic|Win32.ActiveCfg = Debug Dynamic|Win32
|
{0078B97A-F6DB-E014-BED9-BE378D93CEA4}.Debug Dynamic|Win32.ActiveCfg = Debug Dynamic|Win32
|
||||||
{B496CCF6-9B6D-0794-8F41-67A6EC86B4AA}.Debug Dynamic|Win32.Build.0 = Debug Dynamic|Win32
|
{0078B97A-F6DB-E014-BED9-BE378D93CEA4}.Debug Dynamic|Win32.Build.0 = Debug Dynamic|Win32
|
||||||
{B496CCF6-9B6D-0794-8F41-67A6EC86B4AA}.Debug Dynamic|x64.ActiveCfg = Debug Dynamic|x64
|
{0078B97A-F6DB-E014-BED9-BE378D93CEA4}.Debug Dynamic|x64.ActiveCfg = Debug Dynamic|x64
|
||||||
{B496CCF6-9B6D-0794-8F41-67A6EC86B4AA}.Release Dynamic|Win32.ActiveCfg = Release Dynamic|Win32
|
{0078B97A-F6DB-E014-BED9-BE378D93CEA4}.Release Dynamic|Win32.ActiveCfg = Release Dynamic|Win32
|
||||||
{B496CCF6-9B6D-0794-8F41-67A6EC86B4AA}.Release Dynamic|Win32.Build.0 = Release Dynamic|Win32
|
{0078B97A-F6DB-E014-BED9-BE378D93CEA4}.Release Dynamic|Win32.Build.0 = Release Dynamic|Win32
|
||||||
{B496CCF6-9B6D-0794-8F41-67A6EC86B4AA}.Release Dynamic|x64.ActiveCfg = Release Dynamic|x64
|
{0078B97A-F6DB-E014-BED9-BE378D93CEA4}.Release Dynamic|x64.ActiveCfg = Release Dynamic|x64
|
||||||
{B496CCF6-9B6D-0794-8F41-67A6EC86B4AA}.Release Dynamic|x64.Build.0 = Release Dynamic|x64
|
{0078B97A-F6DB-E014-BED9-BE378D93CEA4}.Release Dynamic|x64.Build.0 = Release Dynamic|x64
|
||||||
{B496CCF6-9B6D-0794-8F41-67A6EC86B4AA}.Release Static|Win32.ActiveCfg = Release Static|Win32
|
{0078B97A-F6DB-E014-BED9-BE378D93CEA4}.Release Static|Win32.ActiveCfg = Release Static|Win32
|
||||||
{B496CCF6-9B6D-0794-8F41-67A6EC86B4AA}.Release Static|Win32.Build.0 = Release Static|Win32
|
{0078B97A-F6DB-E014-BED9-BE378D93CEA4}.Release Static|Win32.Build.0 = Release Static|Win32
|
||||||
{B496CCF6-9B6D-0794-8F41-67A6EC86B4AA}.Release Static|x64.ActiveCfg = Release Static|x64
|
{0078B97A-F6DB-E014-BED9-BE378D93CEA4}.Release Static|x64.ActiveCfg = Release Static|x64
|
||||||
{B496CCF6-9B6D-0794-8F41-67A6EC86B4AA}.Release Static|x64.Build.0 = Release Static|x64
|
{0078B97A-F6DB-E014-BED9-BE378D93CEA4}.Release Static|x64.Build.0 = Release Static|x64
|
||||||
{A3FCC735-3E18-4D6B-9DA9-01D9E910B7F8}.Debug Dynamic|Win32.ActiveCfg = Debug Dynamic|Win32
|
{A3FCC735-3E18-4D6B-9DA9-01D9E910B7F8}.Debug Dynamic|Win32.ActiveCfg = Debug Dynamic|Win32
|
||||||
{A3FCC735-3E18-4D6B-9DA9-01D9E910B7F8}.Debug Dynamic|Win32.Build.0 = Debug Dynamic|Win32
|
{A3FCC735-3E18-4D6B-9DA9-01D9E910B7F8}.Debug Dynamic|Win32.Build.0 = Debug Dynamic|Win32
|
||||||
{A3FCC735-3E18-4D6B-9DA9-01D9E910B7F8}.Debug Dynamic|x64.ActiveCfg = Debug Dynamic|x64
|
{A3FCC735-3E18-4D6B-9DA9-01D9E910B7F8}.Debug Dynamic|x64.ActiveCfg = Debug Dynamic|x64
|
||||||
|
|||||||
@@ -244,9 +244,6 @@
|
|||||||
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="..\..\src\launcher.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="love.rc" />
|
<ResourceCompile Include="love.rc" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -260,6 +257,9 @@
|
|||||||
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
|
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\src\love.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="..\..\src\launcher.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="love.rc" />
|
<ResourceCompile Include="love.rc" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\src\love.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -24,4 +24,4 @@
|
|||||||
./modules/thread/sdl/*
|
./modules/thread/sdl/*
|
||||||
./modules/thread/win32/*
|
./modules/thread/win32/*
|
||||||
./modules/thread/posix/*
|
./modules/thread/posix/*
|
||||||
./launcher.cpp
|
./love.cpp
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ SUBDIRS =
|
|||||||
bin_PROGRAMS = love
|
bin_PROGRAMS = love
|
||||||
#love_LDFLAGS =
|
#love_LDFLAGS =
|
||||||
love_LDADD = liblove.la
|
love_LDADD = liblove.la
|
||||||
love_SOURCES = launcher.cpp
|
love_SOURCES = love.cpp
|
||||||
|
|
||||||
# libLÖVE
|
# libLÖVE
|
||||||
lib_LTLIBRARIES = liblove.la
|
lib_LTLIBRARIES = liblove.la
|
||||||
|
|||||||
+29
-189
@@ -18,158 +18,39 @@
|
|||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
// LOVE
|
#include "modules/love/love.h"
|
||||||
#include "common/config.h"
|
#include <SDL.h>
|
||||||
#include "common/version.h"
|
|
||||||
#include "common/runtime.h"
|
#ifdef LOVE_BUILD_EXE
|
||||||
|
|
||||||
|
// Lua
|
||||||
|
extern "C" {
|
||||||
|
#include <lua.h>
|
||||||
|
#include <lualib.h>
|
||||||
|
#include <lauxlib.h>
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef LOVE_WINDOWS
|
#ifdef LOVE_WINDOWS
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif // LOVE_WINDOWS
|
#endif // LOVE_WINDOWS
|
||||||
|
|
||||||
#ifdef LOVE_LEGENDARY_CONSOLE_IO_HACK
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <io.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#endif // LOVE_LEGENDARY_CONSOLE_IO_HACK
|
|
||||||
|
|
||||||
#ifdef LOVE_BUILD_EXE
|
|
||||||
|
|
||||||
// SDL
|
|
||||||
#include <SDL.h>
|
|
||||||
|
|
||||||
// Libraries.
|
|
||||||
#include "libraries/luasocket/luasocket.h"
|
|
||||||
|
|
||||||
// Scripts
|
|
||||||
#include "scripts/boot.lua.h"
|
|
||||||
|
|
||||||
#endif // LOVE_BUILD_EXE
|
|
||||||
|
|
||||||
#ifdef LOVE_BUILD_STANDALONE
|
|
||||||
|
|
||||||
// All modules define a c-accessible luaopen
|
|
||||||
// so let's make use of those, instead
|
|
||||||
// of addressing implementations directly.
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
extern int luaopen_love_audio(lua_State*);
|
|
||||||
extern int luaopen_love_event(lua_State*);
|
|
||||||
extern int luaopen_love_filesystem(lua_State*);
|
|
||||||
extern int luaopen_love_font(lua_State*);
|
|
||||||
extern int luaopen_love_graphics(lua_State*);
|
|
||||||
extern int luaopen_love_image(lua_State*);
|
|
||||||
extern int luaopen_love_joystick(lua_State*);
|
|
||||||
extern int luaopen_love_keyboard(lua_State*);
|
|
||||||
extern int luaopen_love_mouse(lua_State*);
|
|
||||||
extern int luaopen_love_physics(lua_State*);
|
|
||||||
extern int luaopen_love_sound(lua_State*);
|
|
||||||
extern int luaopen_love_timer(lua_State*);
|
|
||||||
extern int luaopen_love_thread(lua_State*);
|
|
||||||
extern int luaopen_love_boot(lua_State*);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const luaL_Reg modules[] = {
|
|
||||||
{ "love.audio", luaopen_love_audio },
|
|
||||||
{ "love.event", luaopen_love_event },
|
|
||||||
{ "love.filesystem", luaopen_love_filesystem },
|
|
||||||
{ "love.font", luaopen_love_font },
|
|
||||||
{ "love.graphics", luaopen_love_graphics },
|
|
||||||
{ "love.image", luaopen_love_image },
|
|
||||||
{ "love.joystick", luaopen_love_joystick },
|
|
||||||
{ "love.keyboard", luaopen_love_keyboard },
|
|
||||||
{ "love.mouse", luaopen_love_mouse },
|
|
||||||
{ "love.physics", luaopen_love_physics },
|
|
||||||
{ "love.sound", luaopen_love_sound },
|
|
||||||
{ "love.timer", luaopen_love_timer },
|
|
||||||
{ "love.thread", luaopen_love_thread },
|
|
||||||
{ "love.boot", luaopen_love_boot },
|
|
||||||
{ 0, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // LOVE_BUILD_STANDALONE
|
|
||||||
|
|
||||||
#ifdef LOVE_LEGENDARY_CONSOLE_IO_HACK
|
|
||||||
int w__openConsole(lua_State * L);
|
|
||||||
#endif // LOVE_LEGENDARY_CONSOLE_IO_HACK
|
|
||||||
|
|
||||||
extern "C" LOVE_EXPORT int luaopen_love(lua_State * L)
|
|
||||||
{
|
|
||||||
love::luax_insistglobal(L, "love");
|
|
||||||
|
|
||||||
// Set version information.
|
|
||||||
lua_pushstring(L, love::VERSION);
|
|
||||||
lua_setfield(L, -2, "_version");
|
|
||||||
|
|
||||||
lua_pushnumber(L, love::VERSION_MAJOR);
|
|
||||||
lua_setfield(L, -2, "_version_major");
|
|
||||||
lua_pushnumber(L, love::VERSION_MINOR);
|
|
||||||
lua_setfield(L, -2, "_version_minor");
|
|
||||||
lua_pushnumber(L, love::VERSION_REV);
|
|
||||||
lua_setfield(L, -2, "_version_revision");
|
|
||||||
|
|
||||||
lua_pushstring(L, love::VERSION_CODENAME);
|
|
||||||
lua_setfield(L, -2, "_version_codename");
|
|
||||||
|
|
||||||
#ifdef LOVE_LEGENDARY_CONSOLE_IO_HACK
|
|
||||||
lua_pushcfunction(L, w__openConsole);
|
|
||||||
lua_setfield(L, -2, "_openConsole");
|
|
||||||
#endif // LOVE_LEGENDARY_CONSOLE_IO_HACK
|
|
||||||
|
|
||||||
lua_newtable(L);
|
|
||||||
|
|
||||||
for (int i = 0; love::VERSION_COMPATIBILITY[i] != 0; ++i)
|
|
||||||
{
|
|
||||||
lua_pushstring(L, love::VERSION_COMPATIBILITY[i]);
|
|
||||||
lua_rawseti(L, -2, i+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setfield(L, -2, "_version_compat");
|
|
||||||
|
|
||||||
#ifdef LOVE_WINDOWS
|
|
||||||
lua_pushstring(L, "Windows");
|
|
||||||
#elif defined(LOVE_MACOSX)
|
|
||||||
lua_pushstring(L, "OS X");
|
|
||||||
#elif defined(LOVE_LINUX)
|
|
||||||
lua_pushstring(L, "Linux");
|
|
||||||
#else
|
|
||||||
lua_pushstring(L, "Unknown");
|
|
||||||
#endif
|
|
||||||
lua_setfield(L, -2, "_os");
|
|
||||||
|
|
||||||
#ifdef LOVE_BUILD_STANDALONE
|
|
||||||
|
|
||||||
// Preload module loaders.
|
|
||||||
for (int i = 0; modules[i].name != 0; i++)
|
|
||||||
{
|
|
||||||
love::luax_preload(L, modules[i].func, modules[i].name);
|
|
||||||
}
|
|
||||||
|
|
||||||
love::luasocket::__open(L);
|
|
||||||
|
|
||||||
#endif // LOVE_BUILD_STANDALONE
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LOVE_LEGENDARY_UTF8_ARGV_HACK
|
#ifdef LOVE_LEGENDARY_UTF8_ARGV_HACK
|
||||||
|
|
||||||
void get_utf8_arguments(int & argc, char **& argv)
|
void get_utf8_arguments(int &argc, char **&argv)
|
||||||
{
|
{
|
||||||
LPWSTR cmd = GetCommandLineW();
|
LPWSTR cmd = GetCommandLineW();
|
||||||
|
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LPWSTR * argv_w = CommandLineToArgvW(cmd, &argc);
|
LPWSTR *argv_w = CommandLineToArgvW(cmd, &argc);
|
||||||
|
|
||||||
argv = new char*[argc];
|
argv = new char *[argc];
|
||||||
|
|
||||||
for (int i = 0; i<argc; ++i)
|
for (int i = 0; i < argc; ++i)
|
||||||
{
|
{
|
||||||
// Size of wide char buffer (plus one for trailing '\0').
|
// Size of wide char buffer (plus one for trailing '\0').
|
||||||
size_t wide_len = wcslen(argv_w[i])+1;
|
size_t wide_len = wcslen(argv_w[i]) + 1;
|
||||||
|
|
||||||
// Get size in UTF-8.
|
// Get size in UTF-8.
|
||||||
int utf8_size = WideCharToMultiByte(CP_UTF8, 0, argv_w[i], wide_len, argv[i], 0, 0, 0);
|
int utf8_size = WideCharToMultiByte(CP_UTF8, 0, argv_w[i], wide_len, argv[i], 0, 0, 0);
|
||||||
@@ -190,50 +71,6 @@ void get_utf8_arguments(int & argc, char **& argv)
|
|||||||
|
|
||||||
#endif // LOVE_LEGENDARY_UTF8_ARGV_HACK
|
#endif // LOVE_LEGENDARY_UTF8_ARGV_HACK
|
||||||
|
|
||||||
#ifdef LOVE_LEGENDARY_CONSOLE_IO_HACK
|
|
||||||
|
|
||||||
int w__openConsole(lua_State * L)
|
|
||||||
{
|
|
||||||
static bool is_open = false;
|
|
||||||
if (is_open)
|
|
||||||
return 0;
|
|
||||||
is_open = true;
|
|
||||||
|
|
||||||
if (GetConsoleWindow() != NULL || AllocConsole() == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
const int MAX_CONSOLE_LINES = 5000;
|
|
||||||
CONSOLE_SCREEN_BUFFER_INFO console_info;
|
|
||||||
|
|
||||||
// Set size.
|
|
||||||
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &console_info);
|
|
||||||
console_info.dwSize.Y = MAX_CONSOLE_LINES;
|
|
||||||
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), console_info.dwSize);
|
|
||||||
|
|
||||||
SetConsoleTitle(TEXT("LOVE Console"));
|
|
||||||
|
|
||||||
FILE * fp;
|
|
||||||
|
|
||||||
// Redirect stdout.
|
|
||||||
fp = freopen("CONOUT$", "w", stdout);
|
|
||||||
if (L && fp == NULL)
|
|
||||||
luaL_error(L, "Console redirection of stdout failed.");
|
|
||||||
|
|
||||||
// Redirect stdin.
|
|
||||||
fp = freopen("CONIN$", "r", stdin);
|
|
||||||
if (L && fp == NULL)
|
|
||||||
luaL_error(L, "Console redirection of stdin failed.");
|
|
||||||
|
|
||||||
// Redirect stderr.
|
|
||||||
fp = freopen("CONOUT$", "w", stderr);
|
|
||||||
if (L && fp == NULL)
|
|
||||||
luaL_error(L, "Console redirection of stderr failed.");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // LOVE_LEGENDARY_CONSOLE_IO_HACK
|
|
||||||
|
|
||||||
#ifdef LOVE_LEGENDARY_LIBSTDCXX_HACK
|
#ifdef LOVE_LEGENDARY_LIBSTDCXX_HACK
|
||||||
|
|
||||||
// Workarounds for symbols that are missing from Leopard stdlibc++.dylib.
|
// Workarounds for symbols that are missing from Leopard stdlibc++.dylib.
|
||||||
@@ -275,18 +112,20 @@ _GLIBCXX_END_NAMESPACE
|
|||||||
|
|
||||||
#endif // LOVE_LEGENDARY_LIBSTDCXX_HACK
|
#endif // LOVE_LEGENDARY_LIBSTDCXX_HACK
|
||||||
|
|
||||||
extern "C" int luaopen_love_boot(lua_State *L)
|
static int love_preload(lua_State *L, lua_CFunction f, const char *name)
|
||||||
{
|
{
|
||||||
if (luaL_loadbuffer(L, (const char *)love::boot_lua, sizeof(love::boot_lua), "boot.lua") == 0)
|
lua_getglobal(L, "package");
|
||||||
lua_call(L, 0, 1);
|
lua_getfield(L, -1, "preload");
|
||||||
return 1;
|
lua_pushcfunction(L, f);
|
||||||
|
lua_setfield(L, -2, name);
|
||||||
|
lua_pop(L, 2);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LOVE_EXPORT int lovemain(int argc, char ** argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
#ifdef LOVE_LEGENDARY_UTF8_ARGV_HACK
|
#ifdef LOVE_LEGENDARY_UTF8_ARGV_HACK
|
||||||
int hack_argc = 0;
|
int hack_argc = 0; char **hack_argv = 0;
|
||||||
char ** hack_argv = 0;
|
|
||||||
get_utf8_arguments(hack_argc, hack_argv);
|
get_utf8_arguments(hack_argc, hack_argv);
|
||||||
argc = hack_argc;
|
argc = hack_argc;
|
||||||
argv = hack_argv;
|
argv = hack_argv;
|
||||||
@@ -295,15 +134,15 @@ extern "C" LOVE_EXPORT int lovemain(int argc, char ** argv)
|
|||||||
// Oh, you just want the version? Okay!
|
// Oh, you just want the version? Okay!
|
||||||
if (argc > 1 && strcmp(argv[1],"--version") == 0)
|
if (argc > 1 && strcmp(argv[1],"--version") == 0)
|
||||||
{
|
{
|
||||||
printf("LOVE %s (%s)\n", love::VERSION, love::VERSION_CODENAME);
|
printf("LOVE %s (%s)\n", love_version(), love_codename());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the virtual machine.
|
// Create the virtual machine.
|
||||||
lua_State * L = lua_open();
|
lua_State *L = lua_open();
|
||||||
luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
|
|
||||||
love::luax_preload(L, luaopen_love, "love");
|
love_preload(L, luaopen_love, "love");
|
||||||
|
|
||||||
luaopen_love(L);
|
luaopen_love(L);
|
||||||
|
|
||||||
@@ -361,3 +200,4 @@ extern "C" LOVE_EXPORT int lovemain(int argc, char ** argv)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // LOVE_BUILD_EXE
|
||||||
|
|||||||
@@ -0,0 +1,217 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2012 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
|
// LOVE
|
||||||
|
#include "common/config.h"
|
||||||
|
#include "common/version.h"
|
||||||
|
#include "common/runtime.h"
|
||||||
|
|
||||||
|
#include "love.h"
|
||||||
|
|
||||||
|
#ifdef LOVE_WINDOWS
|
||||||
|
#include <windows.h>
|
||||||
|
#endif // LOVE_WINDOWS
|
||||||
|
|
||||||
|
#ifdef LOVE_LEGENDARY_CONSOLE_IO_HACK
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <io.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#endif // LOVE_LEGENDARY_CONSOLE_IO_HACK
|
||||||
|
|
||||||
|
#ifdef LOVE_BUILD_EXE
|
||||||
|
|
||||||
|
// Libraries.
|
||||||
|
#include "libraries/luasocket/luasocket.h"
|
||||||
|
|
||||||
|
// Scripts
|
||||||
|
#include "scripts/boot.lua.h"
|
||||||
|
|
||||||
|
#endif // LOVE_BUILD_EXE
|
||||||
|
|
||||||
|
#ifdef LOVE_BUILD_STANDALONE
|
||||||
|
|
||||||
|
// All modules define a c-accessible luaopen
|
||||||
|
// so let's make use of those, instead
|
||||||
|
// of addressing implementations directly.
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
extern int luaopen_love_audio(lua_State*);
|
||||||
|
extern int luaopen_love_event(lua_State*);
|
||||||
|
extern int luaopen_love_filesystem(lua_State*);
|
||||||
|
extern int luaopen_love_font(lua_State*);
|
||||||
|
extern int luaopen_love_graphics(lua_State*);
|
||||||
|
extern int luaopen_love_image(lua_State*);
|
||||||
|
extern int luaopen_love_joystick(lua_State*);
|
||||||
|
extern int luaopen_love_keyboard(lua_State*);
|
||||||
|
extern int luaopen_love_mouse(lua_State*);
|
||||||
|
extern int luaopen_love_physics(lua_State*);
|
||||||
|
extern int luaopen_love_sound(lua_State*);
|
||||||
|
extern int luaopen_love_timer(lua_State*);
|
||||||
|
extern int luaopen_love_thread(lua_State*);
|
||||||
|
extern int luaopen_love_boot(lua_State*);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const luaL_Reg modules[] = {
|
||||||
|
{ "love.audio", luaopen_love_audio },
|
||||||
|
{ "love.event", luaopen_love_event },
|
||||||
|
{ "love.filesystem", luaopen_love_filesystem },
|
||||||
|
{ "love.font", luaopen_love_font },
|
||||||
|
{ "love.graphics", luaopen_love_graphics },
|
||||||
|
{ "love.image", luaopen_love_image },
|
||||||
|
{ "love.joystick", luaopen_love_joystick },
|
||||||
|
{ "love.keyboard", luaopen_love_keyboard },
|
||||||
|
{ "love.mouse", luaopen_love_mouse },
|
||||||
|
{ "love.physics", luaopen_love_physics },
|
||||||
|
{ "love.sound", luaopen_love_sound },
|
||||||
|
{ "love.timer", luaopen_love_timer },
|
||||||
|
{ "love.thread", luaopen_love_thread },
|
||||||
|
{ "love.boot", luaopen_love_boot },
|
||||||
|
{ 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOVE_BUILD_STANDALONE
|
||||||
|
|
||||||
|
#ifdef LOVE_LEGENDARY_CONSOLE_IO_HACK
|
||||||
|
int w__openConsole(lua_State * L);
|
||||||
|
#endif // LOVE_LEGENDARY_CONSOLE_IO_HACK
|
||||||
|
|
||||||
|
extern "C" LOVE_EXPORT const char *love_version()
|
||||||
|
{
|
||||||
|
return love::VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" LOVE_EXPORT const char *love_codename()
|
||||||
|
{
|
||||||
|
return love::VERSION_CODENAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" LOVE_EXPORT int luaopen_love(lua_State * L)
|
||||||
|
{
|
||||||
|
love::luax_insistglobal(L, "love");
|
||||||
|
|
||||||
|
// Set version information.
|
||||||
|
lua_pushstring(L, love::VERSION);
|
||||||
|
lua_setfield(L, -2, "_version");
|
||||||
|
|
||||||
|
lua_pushnumber(L, love::VERSION_MAJOR);
|
||||||
|
lua_setfield(L, -2, "_version_major");
|
||||||
|
lua_pushnumber(L, love::VERSION_MINOR);
|
||||||
|
lua_setfield(L, -2, "_version_minor");
|
||||||
|
lua_pushnumber(L, love::VERSION_REV);
|
||||||
|
lua_setfield(L, -2, "_version_revision");
|
||||||
|
|
||||||
|
lua_pushstring(L, love::VERSION_CODENAME);
|
||||||
|
lua_setfield(L, -2, "_version_codename");
|
||||||
|
|
||||||
|
#ifdef LOVE_LEGENDARY_CONSOLE_IO_HACK
|
||||||
|
lua_pushcfunction(L, w__openConsole);
|
||||||
|
lua_setfield(L, -2, "_openConsole");
|
||||||
|
#endif // LOVE_LEGENDARY_CONSOLE_IO_HACK
|
||||||
|
|
||||||
|
lua_newtable(L);
|
||||||
|
|
||||||
|
for (int i = 0; love::VERSION_COMPATIBILITY[i] != 0; ++i)
|
||||||
|
{
|
||||||
|
lua_pushstring(L, love::VERSION_COMPATIBILITY[i]);
|
||||||
|
lua_rawseti(L, -2, i+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_setfield(L, -2, "_version_compat");
|
||||||
|
|
||||||
|
#ifdef LOVE_WINDOWS
|
||||||
|
lua_pushstring(L, "Windows");
|
||||||
|
#elif defined(LOVE_MACOSX)
|
||||||
|
lua_pushstring(L, "OS X");
|
||||||
|
#elif defined(LOVE_LINUX)
|
||||||
|
lua_pushstring(L, "Linux");
|
||||||
|
#else
|
||||||
|
lua_pushstring(L, "Unknown");
|
||||||
|
#endif
|
||||||
|
lua_setfield(L, -2, "_os");
|
||||||
|
|
||||||
|
#ifdef LOVE_BUILD_STANDALONE
|
||||||
|
|
||||||
|
// Preload module loaders.
|
||||||
|
for (int i = 0; modules[i].name != 0; i++)
|
||||||
|
{
|
||||||
|
love::luax_preload(L, modules[i].func, modules[i].name);
|
||||||
|
}
|
||||||
|
|
||||||
|
love::luasocket::__open(L);
|
||||||
|
|
||||||
|
#endif // LOVE_BUILD_STANDALONE
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef LOVE_LEGENDARY_CONSOLE_IO_HACK
|
||||||
|
|
||||||
|
int w__openConsole(lua_State * L)
|
||||||
|
{
|
||||||
|
static bool is_open = false;
|
||||||
|
if (is_open)
|
||||||
|
return 0;
|
||||||
|
is_open = true;
|
||||||
|
|
||||||
|
if (GetConsoleWindow() != NULL || AllocConsole() == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
const int MAX_CONSOLE_LINES = 5000;
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO console_info;
|
||||||
|
|
||||||
|
// Set size.
|
||||||
|
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &console_info);
|
||||||
|
console_info.dwSize.Y = MAX_CONSOLE_LINES;
|
||||||
|
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), console_info.dwSize);
|
||||||
|
|
||||||
|
SetConsoleTitle(TEXT("LOVE Console"));
|
||||||
|
|
||||||
|
FILE * fp;
|
||||||
|
|
||||||
|
// Redirect stdout.
|
||||||
|
fp = freopen("CONOUT$", "w", stdout);
|
||||||
|
if (L && fp == NULL)
|
||||||
|
luaL_error(L, "Console redirection of stdout failed.");
|
||||||
|
|
||||||
|
// Redirect stdin.
|
||||||
|
fp = freopen("CONIN$", "r", stdin);
|
||||||
|
if (L && fp == NULL)
|
||||||
|
luaL_error(L, "Console redirection of stdin failed.");
|
||||||
|
|
||||||
|
// Redirect stderr.
|
||||||
|
fp = freopen("CONOUT$", "w", stderr);
|
||||||
|
if (L && fp == NULL)
|
||||||
|
luaL_error(L, "Console redirection of stderr failed.");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // LOVE_LEGENDARY_CONSOLE_IO_HACK
|
||||||
|
|
||||||
|
extern "C" LOVE_EXPORT int luaopen_love_boot(lua_State *L)
|
||||||
|
{
|
||||||
|
if (luaL_loadbuffer(L, (const char *)love::boot_lua, sizeof(love::boot_lua), "boot.lua") == 0)
|
||||||
|
lua_call(L, 0, 1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -18,17 +18,13 @@
|
|||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
// LOVE
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include <SDL.h>
|
|
||||||
|
|
||||||
extern "C"
|
// Forward declare lua_State.
|
||||||
{
|
struct lua_State;
|
||||||
extern int lovemain(int argc, char **argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LOVE_BUILD_EXE
|
extern "C" LOVE_EXPORT const char *love_version();
|
||||||
int main(int argc, char **argv)
|
extern "C" LOVE_EXPORT const char *love_codename();
|
||||||
{
|
extern "C" LOVE_EXPORT int luaopen_love(lua_State *L);
|
||||||
return lovemain(argc, argv);
|
extern "C" LOVE_EXPORT int luaopen_love_boot(lua_State *L);
|
||||||
}
|
|
||||||
#endif // LOVE_BUILD_EXE
|
|
||||||
Reference in New Issue
Block a user