mirror of https://github.com/bjornbytes/lovr.git
Start compat system;
This commit is contained in:
parent
4b3e72a5f1
commit
89ccf750ba
|
@ -1,6 +1,7 @@
|
|||
#include "api.h"
|
||||
#include "version.h"
|
||||
#include "resources/logo.png.h"
|
||||
#include "resources/compat.lua.h"
|
||||
#include "lib/lua-cjson/lua_cjson.h"
|
||||
#include "lib/lua-enet/enet.h"
|
||||
|
||||
|
@ -81,5 +82,7 @@ int luaopen_lovr(lua_State* L) {
|
|||
luaL_register(L, NULL, lovr);
|
||||
lua_pushlstring(L, (const char*) logo_png, logo_png_len);
|
||||
lua_setfield(L, -2, "_logo");
|
||||
lua_pushlstring(L, (const char*) compat_lua, compat_lua_len);
|
||||
lua_setfield(L, -2, "_compat");
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ end
|
|||
-- Note: Cannot be overloaded
|
||||
function lovr.boot()
|
||||
local conf = {
|
||||
version = '0.12.0',
|
||||
compat = false,
|
||||
modules = {
|
||||
audio = true,
|
||||
data = true,
|
||||
|
@ -86,6 +88,10 @@ function lovr.boot()
|
|||
end
|
||||
end
|
||||
|
||||
if conf.compat then
|
||||
assert(loadstring(lovr._compat))(conf.version)
|
||||
end
|
||||
|
||||
lovr.handlers = setmetatable({}, { __index = lovr })
|
||||
if not confOk then error(confError) end
|
||||
if hasMain then require 'main' end
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,25 @@
|
|||
local function parseVersion(version)
|
||||
return version:match('(%d+)%.(%d+)%.(%d+)')
|
||||
end
|
||||
|
||||
local targetMajor, targetMinor, targetPatch = parseVersion(...)
|
||||
|
||||
local shims = {
|
||||
['master'] = function()
|
||||
--
|
||||
end
|
||||
}
|
||||
|
||||
for version, shim in pairs(shims) do
|
||||
if version == 'master' then
|
||||
shim()
|
||||
else
|
||||
local major, minor, patch = parseVersion(version)
|
||||
if major > targetMajor or
|
||||
(major == targetMajor and minor > targetMinor) or
|
||||
(major == targetMajor and minor == targetMinor and patch >= targetPatch)
|
||||
then
|
||||
shim()
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,50 @@
|
|||
unsigned char compat_lua[] = {
|
||||
0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x20, 0x70, 0x61, 0x72, 0x73, 0x65, 0x56, 0x65, 0x72, 0x73,
|
||||
0x69, 0x6f, 0x6e, 0x28, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x29,
|
||||
0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x76, 0x65,
|
||||
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x28,
|
||||
0x27, 0x28, 0x25, 0x64, 0x2b, 0x29, 0x25, 0x2e, 0x28, 0x25, 0x64, 0x2b,
|
||||
0x29, 0x25, 0x2e, 0x28, 0x25, 0x64, 0x2b, 0x29, 0x27, 0x29, 0x0a, 0x65,
|
||||
0x6e, 0x64, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x74, 0x61,
|
||||
0x72, 0x67, 0x65, 0x74, 0x4d, 0x61, 0x6a, 0x6f, 0x72, 0x2c, 0x20, 0x74,
|
||||
0x61, 0x72, 0x67, 0x65, 0x74, 0x4d, 0x69, 0x6e, 0x6f, 0x72, 0x2c, 0x20,
|
||||
0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x50, 0x61, 0x74, 0x63, 0x68, 0x20,
|
||||
0x3d, 0x20, 0x70, 0x61, 0x72, 0x73, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69,
|
||||
0x6f, 0x6e, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x0a, 0x6c, 0x6f, 0x63,
|
||||
0x61, 0x6c, 0x20, 0x73, 0x68, 0x69, 0x6d, 0x73, 0x20, 0x3d, 0x20, 0x7b,
|
||||
0x0a, 0x20, 0x20, 0x5b, 0x27, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x27,
|
||||
0x5d, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x28, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x0a, 0x20, 0x20,
|
||||
0x65, 0x6e, 0x64, 0x0a, 0x7d, 0x0a, 0x0a, 0x66, 0x6f, 0x72, 0x20, 0x76,
|
||||
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x73, 0x68, 0x69, 0x6d,
|
||||
0x20, 0x69, 0x6e, 0x20, 0x70, 0x61, 0x69, 0x72, 0x73, 0x28, 0x73, 0x68,
|
||||
0x69, 0x6d, 0x73, 0x29, 0x20, 0x64, 0x6f, 0x0a, 0x20, 0x20, 0x69, 0x66,
|
||||
0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x3d, 0x20,
|
||||
0x27, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x27, 0x20, 0x74, 0x68, 0x65,
|
||||
0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x73, 0x68, 0x69, 0x6d, 0x28, 0x29,
|
||||
0x0a, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20,
|
||||
0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6d, 0x61, 0x6a, 0x6f, 0x72, 0x2c,
|
||||
0x20, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x2c, 0x20, 0x70, 0x61, 0x74, 0x63,
|
||||
0x68, 0x20, 0x3d, 0x20, 0x70, 0x61, 0x72, 0x73, 0x65, 0x56, 0x65, 0x72,
|
||||
0x73, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6d, 0x61, 0x6a,
|
||||
0x6f, 0x72, 0x20, 0x3e, 0x20, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4d,
|
||||
0x61, 0x6a, 0x6f, 0x72, 0x20, 0x6f, 0x72, 0x0a, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x28, 0x6d, 0x61, 0x6a, 0x6f, 0x72, 0x20, 0x3d, 0x3d, 0x20,
|
||||
0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4d, 0x61, 0x6a, 0x6f, 0x72, 0x20,
|
||||
0x61, 0x6e, 0x64, 0x20, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x20, 0x3e, 0x20,
|
||||
0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4d, 0x69, 0x6e, 0x6f, 0x72, 0x29,
|
||||
0x20, 0x6f, 0x72, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x28, 0x6d,
|
||||
0x61, 0x6a, 0x6f, 0x72, 0x20, 0x3d, 0x3d, 0x20, 0x74, 0x61, 0x72, 0x67,
|
||||
0x65, 0x74, 0x4d, 0x61, 0x6a, 0x6f, 0x72, 0x20, 0x61, 0x6e, 0x64, 0x20,
|
||||
0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x20, 0x3d, 0x3d, 0x20, 0x74, 0x61, 0x72,
|
||||
0x67, 0x65, 0x74, 0x4d, 0x69, 0x6e, 0x6f, 0x72, 0x20, 0x61, 0x6e, 0x64,
|
||||
0x20, 0x70, 0x61, 0x74, 0x63, 0x68, 0x20, 0x3e, 0x3d, 0x20, 0x74, 0x61,
|
||||
0x72, 0x67, 0x65, 0x74, 0x50, 0x61, 0x74, 0x63, 0x68, 0x29, 0x0a, 0x20,
|
||||
0x20, 0x20, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x73, 0x68, 0x69, 0x6d, 0x28, 0x29, 0x0a, 0x20, 0x20, 0x20,
|
||||
0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65,
|
||||
0x6e, 0x64, 0x0a
|
||||
};
|
||||
unsigned int compat_lua_len = 555;
|
Loading…
Reference in New Issue