diff options
author | Benoit Germain <bnt.germain@gmail.com> | 2012-10-23 15:53:46 +0300 |
---|---|---|
committer | Benoit Germain <bnt.germain@gmail.com> | 2012-10-23 15:53:46 +0300 |
commit | 1d2a314407f5e70a5b46b3166402d79b531099c4 (patch) | |
tree | b4151d167579667c584448c178339859cf9d4669 /src/lanes.c | |
parent | 527124d8516431a01475d2609774213d8bac1d9f (diff) | |
download | lanes-1d2a314407f5e70a5b46b3166402d79b531099c4.tar.gz lanes-1d2a314407f5e70a5b46b3166402d79b531099c4.tar.bz2 lanes-1d2a314407f5e70a5b46b3166402d79b531099c4.zip |
Lua version sanity check
Diffstat (limited to 'src/lanes.c')
-rw-r--r-- | src/lanes.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/lanes.c b/src/lanes.c index 8edf47b..092e282 100644 --- a/src/lanes.c +++ b/src/lanes.c | |||
@@ -2611,12 +2611,22 @@ int | |||
2611 | #if (defined PLATFORM_WIN32) || (defined PLATFORM_POCKETPC) | 2611 | #if (defined PLATFORM_WIN32) || (defined PLATFORM_POCKETPC) |
2612 | __declspec(dllexport) | 2612 | __declspec(dllexport) |
2613 | #endif // (defined PLATFORM_WIN32) || (defined PLATFORM_POCKETPC) | 2613 | #endif // (defined PLATFORM_WIN32) || (defined PLATFORM_POCKETPC) |
2614 | luaopen_lanes_core( lua_State *L ) | 2614 | luaopen_lanes_core( lua_State* L) |
2615 | { | 2615 | { |
2616 | // Create main module interface table | ||
2617 | // we only have 1 closure, which must be called to configure Lanes | ||
2618 | STACK_GROW( L, 3); | 2616 | STACK_GROW( L, 3); |
2619 | STACK_CHECK( L) | 2617 | STACK_CHECK( L) |
2618 | |||
2619 | // sanity check: let's see if _"VERSION" matches what we we built against | ||
2620 | lua_getglobal( L, "_VERSION"); | ||
2621 | lua_pushstring( L, LUA_VERSION_NUM == 501 ? "Lua 5.1" : "Lua 5.2"); | ||
2622 | if( !lua_rawequal( L, -1, -2)) | ||
2623 | { | ||
2624 | return luaL_error( L, "Lanes is built against %s, but you are running %s", lua_tostring( L, -1), lua_tostring( L, -2)); | ||
2625 | } | ||
2626 | lua_pop( L, 2); | ||
2627 | |||
2628 | // Create main module interface table | ||
2629 | // we only have 1 closure, which must be called to configure Lanes | ||
2620 | lua_newtable(L); | 2630 | lua_newtable(L); |
2621 | lua_pushvalue(L, 1); // module name | 2631 | lua_pushvalue(L, 1); // module name |
2622 | lua_pushvalue(L, -2); // module table | 2632 | lua_pushvalue(L, -2); // module table |
@@ -2631,6 +2641,7 @@ luaopen_lanes_core( lua_State *L ) | |||
2631 | lua_pushnil( L); // almost idem | 2641 | lua_pushnil( L); // almost idem |
2632 | lua_call( L, 2, 0); | 2642 | lua_call( L, 2, 0); |
2633 | } | 2643 | } |
2644 | |||
2634 | STACK_END( L, 1) | 2645 | STACK_END( L, 1) |
2635 | return 1; | 2646 | return 1; |
2636 | } | 2647 | } |