diff options
author | Benoit Germain <bnt period germain arrobase gmail period com> | 2014-12-16 15:54:31 +0100 |
---|---|---|
committer | Benoit Germain <bnt period germain arrobase gmail period com> | 2014-12-16 15:54:31 +0100 |
commit | be58bb0bf683c5c15589ecf68367a1fbaa9e0a8f (patch) | |
tree | 42493e3ebe45433e86c85eb4109cc9dcaeede378 | |
parent | 49fc4082730b4908df82dea5ba68f2a5fde72953 (diff) | |
download | lanes-be58bb0bf683c5c15589ecf68367a1fbaa9e0a8f.tar.gz lanes-be58bb0bf683c5c15589ecf68367a1fbaa9e0a8f.tar.bz2 lanes-be58bb0bf683c5c15589ecf68367a1fbaa9e0a8f.zip |
preliminary Lua 5.3 support
Untested, but it might just work :).
-rw-r--r-- | src/compat.h | 25 | ||||
-rw-r--r-- | src/deep.c | 2 | ||||
-rw-r--r-- | src/keeper.c | 77 | ||||
-rw-r--r-- | src/lanes.c | 8 | ||||
-rw-r--r-- | src/tools.c | 9 | ||||
-rw-r--r-- | src/tools.h | 2 |
6 files changed, 68 insertions, 55 deletions
diff --git a/src/compat.h b/src/compat.h index 496986b..6048974 100644 --- a/src/compat.h +++ b/src/compat.h | |||
@@ -5,9 +5,10 @@ | |||
5 | #include "lualib.h" | 5 | #include "lualib.h" |
6 | #include "lauxlib.h" | 6 | #include "lauxlib.h" |
7 | 7 | ||
8 | // code is now using Lua 5.2 API | 8 | // code is now preferring Lua 5.3 API |
9 | // add Lua 5.2 API when building for Lua 5.1 | 9 | // add some Lua 5.3-style API when building for Lua 5.1 |
10 | #if LUA_VERSION_NUM == 501 | 10 | #if LUA_VERSION_NUM == 501 |
11 | #define lua501_equal lua_equal | ||
11 | #define lua_absindex( L, idx) (((idx) >= 0 || (idx) <= LUA_REGISTRYINDEX) ? (idx) : lua_gettop(L) + (idx) +1) | 12 | #define lua_absindex( L, idx) (((idx) >= 0 || (idx) <= LUA_REGISTRYINDEX) ? (idx) : lua_gettop(L) + (idx) +1) |
12 | #define lua_pushglobaltable(L) lua_pushvalue( L, LUA_GLOBALSINDEX) | 13 | #define lua_pushglobaltable(L) lua_pushvalue( L, LUA_GLOBALSINDEX) |
13 | #define lua_setuservalue lua_setfenv | 14 | #define lua_setuservalue lua_setfenv |
@@ -17,17 +18,31 @@ | |||
17 | #define LUA_OK 0 | 18 | #define LUA_OK 0 |
18 | #define LUA_ERRGCMM 666 // doesn't exist in Lua 5.1, we don't care about the actual value | 19 | #define LUA_ERRGCMM 666 // doesn't exist in Lua 5.1, we don't care about the actual value |
19 | void luaL_requiref (lua_State* L, const char* modname, lua_CFunction openf, int glb); // implementation copied from Lua 5.2 sources | 20 | void luaL_requiref (lua_State* L, const char* modname, lua_CFunction openf, int glb); // implementation copied from Lua 5.2 sources |
21 | #define lua503_dump( L, writer, data, strip) lua_dump( L, writer, data) | ||
20 | #endif // LUA_VERSION_NUM == 501 | 22 | #endif // LUA_VERSION_NUM == 501 |
21 | 23 | ||
22 | // wrap Lua 5.2 calls under Lua 5.1 API when it is simpler that way | 24 | // wrap Lua 5.2 calls under Lua 5.1 API when it is simpler that way |
23 | #if LUA_VERSION_NUM == 502 | 25 | #if LUA_VERSION_NUM == 502 |
24 | #ifndef lua_equal // already defined when compatibility is active in luaconf.h | 26 | #ifndef lua501_equal // already defined when compatibility is active in luaconf.h |
25 | #define lua_equal( L, a, b) lua_compare( L, a, b, LUA_OPEQ) | 27 | #define lua501_equal( L, a, b) lua_compare( L, a, b, LUA_OPEQ) |
26 | #endif // lua_equal | 28 | #endif // lua501_equal |
27 | #ifndef lua_lessthan // already defined when compatibility is active in luaconf.h | 29 | #ifndef lua_lessthan // already defined when compatibility is active in luaconf.h |
28 | #define lua_lessthan( L, a, b) lua_compare( L, a, b, LUA_OPLT) | 30 | #define lua_lessthan( L, a, b) lua_compare( L, a, b, LUA_OPLT) |
29 | #endif // lua_lessthan | 31 | #endif // lua_lessthan |
30 | #define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0) | 32 | #define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0) |
33 | #define lua503_dump( L, writer, data, strip) lua_dump( L, writer, data) | ||
31 | #endif // LUA_VERSION_NUM == 502 | 34 | #endif // LUA_VERSION_NUM == 502 |
32 | 35 | ||
36 | // wrap Lua 5.3 calls under Lua 5.1 API when it is simpler that way | ||
37 | #if LUA_VERSION_NUM == 503 | ||
38 | #ifndef lua501_equal // already defined when compatibility is active in luaconf.h | ||
39 | #define lua501_equal( L, a, b) lua_compare( L, a, b, LUA_OPEQ) | ||
40 | #endif // lua501_equal | ||
41 | #ifndef lua_lessthan // already defined when compatibility is active in luaconf.h | ||
42 | #define lua_lessthan( L, a, b) lua_compare( L, a, b, LUA_OPLT) | ||
43 | #endif // lua_lessthan | ||
44 | #define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0) | ||
45 | #define lua503_dump lua_dump | ||
46 | #endif // LUA_VERSION_NUM == 503 | ||
47 | |||
33 | #endif // __COMPAT_H__ | 48 | #endif // __COMPAT_H__ |
@@ -309,7 +309,7 @@ char const* push_deep_proxy( struct s_Universe* U, lua_State* L, DEEP_PRELUDE* p | |||
309 | return "Bad idfunc(eOP_metatable): unexpected pushed value"; | 309 | return "Bad idfunc(eOP_metatable): unexpected pushed value"; |
310 | } | 310 | } |
311 | luaG_pushdeepversion( L); // DPC proxy metatable deepversion deepversion | 311 | luaG_pushdeepversion( L); // DPC proxy metatable deepversion deepversion |
312 | if( !lua_equal( L, -1, -2)) | 312 | if( !lua501_equal( L, -1, -2)) |
313 | { | 313 | { |
314 | lua_pop( L, 5); // | 314 | lua_pop( L, 5); // |
315 | return "Bad idfunc(eOP_metatable): mismatched deep version"; | 315 | return "Bad idfunc(eOP_metatable): mismatched deep version"; |
diff --git a/src/keeper.c b/src/keeper.c index 8bece77..ea061ce 100644 --- a/src/keeper.c +++ b/src/keeper.c | |||
@@ -58,22 +58,22 @@ | |||
58 | 58 | ||
59 | typedef struct | 59 | typedef struct |
60 | { | 60 | { |
61 | int first; | 61 | lua_Integer first; |
62 | int count; | 62 | lua_Integer count; |
63 | int limit; | 63 | lua_Integer limit; |
64 | } keeper_fifo; | 64 | } keeper_fifo; |
65 | 65 | ||
66 | // replaces the fifo ud by its uservalue on the stack | 66 | // replaces the fifo ud by its uservalue on the stack |
67 | static keeper_fifo* prepare_fifo_access( lua_State* L, int idx) | 67 | static keeper_fifo* prepare_fifo_access( lua_State* L, int idx_) |
68 | { | 68 | { |
69 | keeper_fifo* fifo = (keeper_fifo*) lua_touserdata( L, idx); | 69 | keeper_fifo* fifo = (keeper_fifo*) lua_touserdata( L, idx_); |
70 | if( fifo != NULL) | 70 | if( fifo != NULL) |
71 | { | 71 | { |
72 | idx = lua_absindex( L, idx); | 72 | idx_ = lua_absindex( L, idx_); |
73 | STACK_GROW( L, 1); | 73 | STACK_GROW( L, 1); |
74 | // we can replace the fifo userdata in the stack without fear of it being GCed, there are other references around | 74 | // we can replace the fifo userdata in the stack without fear of it being GCed, there are other references around |
75 | lua_getuservalue( L, idx); | 75 | lua_getuservalue( L, idx_); |
76 | lua_replace( L, idx); | 76 | lua_replace( L, idx_); |
77 | } | 77 | } |
78 | return fifo; | 78 | return fifo; |
79 | } | 79 | } |
@@ -94,18 +94,18 @@ static void fifo_new( lua_State* L) | |||
94 | 94 | ||
95 | // in: expect fifo ... on top of the stack | 95 | // in: expect fifo ... on top of the stack |
96 | // out: nothing, removes all pushed values from the stack | 96 | // out: nothing, removes all pushed values from the stack |
97 | static void fifo_push( lua_State* L, keeper_fifo* fifo, int _count) | 97 | static void fifo_push( lua_State* L, keeper_fifo* fifo_, lua_Integer count_) |
98 | { | 98 | { |
99 | int idx = lua_gettop( L) - _count; | 99 | int const idx = lua_gettop( L) - (int) count_; |
100 | int start = fifo->first + fifo->count - 1; | 100 | lua_Integer start = fifo_->first + fifo_->count - 1; |
101 | int i; | 101 | lua_Integer i; |
102 | // pop all additional arguments, storing them in the fifo | 102 | // pop all additional arguments, storing them in the fifo |
103 | for( i = _count; i >= 1; -- i) | 103 | for( i = count_; i >= 1; -- i) |
104 | { | 104 | { |
105 | // store in the fifo the value at the top of the stack at the specified index, popping it from the stack | 105 | // store in the fifo the value at the top of the stack at the specified index, popping it from the stack |
106 | lua_rawseti( L, idx, start + i); | 106 | lua_rawseti( L, idx, start + i); |
107 | } | 107 | } |
108 | fifo->count += _count; | 108 | fifo_->count += count_; |
109 | } | 109 | } |
110 | 110 | ||
111 | // in: fifo | 111 | // in: fifo |
@@ -113,28 +113,28 @@ static void fifo_push( lua_State* L, keeper_fifo* fifo, int _count) | |||
113 | // expects exactly 1 value on the stack! | 113 | // expects exactly 1 value on the stack! |
114 | // currently only called with a count of 1, but this may change in the future | 114 | // currently only called with a count of 1, but this may change in the future |
115 | // function assumes that there is enough data in the fifo to satisfy the request | 115 | // function assumes that there is enough data in the fifo to satisfy the request |
116 | static void fifo_peek( lua_State* L, keeper_fifo* fifo, int count_) | 116 | static void fifo_peek( lua_State* L, keeper_fifo* fifo_, lua_Integer count_) |
117 | { | 117 | { |
118 | int i; | 118 | int i; |
119 | STACK_GROW( L, count_); | 119 | STACK_GROW( L, count_); |
120 | for( i = 0; i < count_; ++ i) | 120 | for( i = 0; i < count_; ++ i) |
121 | { | 121 | { |
122 | lua_rawgeti( L, 1, fifo->first + i); | 122 | lua_rawgeti( L, 1, fifo_->first + i); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | // in: fifo | 126 | // in: fifo |
127 | // out: remove the fifo from the stack, push as many items as required on the stack (function assumes they exist in sufficient number) | 127 | // out: remove the fifo from the stack, push as many items as required on the stack (function assumes they exist in sufficient number) |
128 | static void fifo_pop( lua_State* L, keeper_fifo* fifo, int count_) | 128 | static void fifo_pop( lua_State* L, keeper_fifo* fifo_, lua_Integer count_) |
129 | { | 129 | { |
130 | int fifo_idx = lua_gettop( L); // ... fifo | 130 | int const fifo_idx = lua_gettop( L); // ... fifo |
131 | int i; | 131 | int i; |
132 | // each iteration pushes a value on the stack! | 132 | // each iteration pushes a value on the stack! |
133 | STACK_GROW( L, count_ + 2); | 133 | STACK_GROW( L, count_ + 2); |
134 | // skip first item, we will push it last | 134 | // skip first item, we will push it last |
135 | for( i = 1; i < count_; ++ i) | 135 | for( i = 1; i < count_; ++ i) |
136 | { | 136 | { |
137 | int const at = fifo->first + i; | 137 | lua_Integer const at = fifo_->first + i; |
138 | // push item on the stack | 138 | // push item on the stack |
139 | lua_rawgeti( L, fifo_idx, at); // ... fifo val | 139 | lua_rawgeti( L, fifo_idx, at); // ... fifo val |
140 | // remove item from the fifo | 140 | // remove item from the fifo |
@@ -143,7 +143,7 @@ static void fifo_pop( lua_State* L, keeper_fifo* fifo, int count_) | |||
143 | } | 143 | } |
144 | // now process first item | 144 | // now process first item |
145 | { | 145 | { |
146 | int const at = fifo->first; | 146 | lua_Integer const at = fifo_->first; |
147 | lua_rawgeti( L, fifo_idx, at); // ... fifo vals val | 147 | lua_rawgeti( L, fifo_idx, at); // ... fifo vals val |
148 | lua_pushnil( L); // ... fifo vals val nil | 148 | lua_pushnil( L); // ... fifo vals val nil |
149 | lua_rawseti( L, fifo_idx, at); // ... fifo vals val | 149 | lua_rawseti( L, fifo_idx, at); // ... fifo vals val |
@@ -151,23 +151,23 @@ static void fifo_pop( lua_State* L, keeper_fifo* fifo, int count_) | |||
151 | } | 151 | } |
152 | { | 152 | { |
153 | // avoid ever-growing indexes by resetting each time we detect the fifo is empty | 153 | // avoid ever-growing indexes by resetting each time we detect the fifo is empty |
154 | int const new_count = fifo->count - count_; | 154 | lua_Integer const new_count = fifo_->count - count_; |
155 | fifo->first = (new_count == 0) ? 1 : (fifo->first + count_); | 155 | fifo_->first = (new_count == 0) ? 1 : (fifo_->first + count_); |
156 | fifo->count = new_count; | 156 | fifo_->count = new_count; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | // in: linda_ud expected at *absolute* stack slot idx | 160 | // in: linda_ud expected at *absolute* stack slot idx |
161 | // out: fifos[ud] | 161 | // out: fifos[ud] |
162 | static void* const fifos_key = (void*) prepare_fifo_access; | 162 | static void* const fifos_key = (void*) prepare_fifo_access; |
163 | static void push_table( lua_State* L, int idx) | 163 | static void push_table( lua_State* L, int idx_) |
164 | { | 164 | { |
165 | STACK_GROW( L, 4); | 165 | STACK_GROW( L, 4); |
166 | STACK_CHECK( L); | 166 | STACK_CHECK( L); |
167 | idx = lua_absindex( L, idx); | 167 | idx_ = lua_absindex( L, idx_); |
168 | lua_pushlightuserdata( L, fifos_key); // ud fifos_key | 168 | lua_pushlightuserdata( L, fifos_key); // ud fifos_key |
169 | lua_rawget( L, LUA_REGISTRYINDEX); // ud fifos | 169 | lua_rawget( L, LUA_REGISTRYINDEX); // ud fifos |
170 | lua_pushvalue( L, idx); // ud fifos ud | 170 | lua_pushvalue( L, idx_); // ud fifos ud |
171 | lua_rawget( L, -2); // ud fifos fifos[ud] | 171 | lua_rawget( L, -2); // ud fifos fifos[ud] |
172 | STACK_MID( L, 2); | 172 | STACK_MID( L, 2); |
173 | if( lua_isnil( L, -1)) | 173 | if( lua_isnil( L, -1)) |
@@ -175,7 +175,7 @@ static void push_table( lua_State* L, int idx) | |||
175 | lua_pop( L, 1); // ud fifos | 175 | lua_pop( L, 1); // ud fifos |
176 | // add a new fifos table for this linda | 176 | // add a new fifos table for this linda |
177 | lua_newtable( L); // ud fifos fifos[ud] | 177 | lua_newtable( L); // ud fifos fifos[ud] |
178 | lua_pushvalue( L, idx); // ud fifos fifos[ud] ud | 178 | lua_pushvalue( L, idx_); // ud fifos fifos[ud] ud |
179 | lua_pushvalue( L, -2); // ud fifos fifos[ud] ud fifos[ud] | 179 | lua_pushvalue( L, -2); // ud fifos fifos[ud] ud fifos[ud] |
180 | lua_rawset( L, -4); // ud fifos fifos[ud] | 180 | lua_rawset( L, -4); // ud fifos fifos[ud] |
181 | } | 181 | } |
@@ -183,16 +183,16 @@ static void push_table( lua_State* L, int idx) | |||
183 | STACK_END( L, 1); | 183 | STACK_END( L, 1); |
184 | } | 184 | } |
185 | 185 | ||
186 | int keeper_push_linda_storage( struct s_Universe* U, lua_State* L, void* ptr, unsigned long magic_) | 186 | int keeper_push_linda_storage( struct s_Universe* U, lua_State* L, void* ptr_, unsigned long magic_) |
187 | { | 187 | { |
188 | struct s_Keeper* K = keeper_acquire( U->keepers, magic_); | 188 | struct s_Keeper* const K = keeper_acquire( U->keepers, magic_); |
189 | lua_State* KL = K ? K->L : NULL; | 189 | lua_State* const KL = K ? K->L : NULL; |
190 | if( KL == NULL) return 0; | 190 | if( KL == NULL) return 0; |
191 | STACK_GROW( KL, 4); | 191 | STACK_GROW( KL, 4); |
192 | STACK_CHECK( KL); | 192 | STACK_CHECK( KL); |
193 | lua_pushlightuserdata( KL, fifos_key); // fifos_key | 193 | lua_pushlightuserdata( KL, fifos_key); // fifos_key |
194 | lua_rawget( KL, LUA_REGISTRYINDEX); // fifos | 194 | lua_rawget( KL, LUA_REGISTRYINDEX); // fifos |
195 | lua_pushlightuserdata( KL, ptr); // fifos ud | 195 | lua_pushlightuserdata( KL, ptr_); // fifos ud |
196 | lua_rawget( KL, -2); // fifos storage | 196 | lua_rawget( KL, -2); // fifos storage |
197 | lua_remove( KL, -2); // storage | 197 | lua_remove( KL, -2); // storage |
198 | if( !lua_istable( KL, -1)) | 198 | if( !lua_istable( KL, -1)) |
@@ -323,11 +323,11 @@ int keepercall_receive( lua_State* L) | |||
323 | //in: linda_ud key mincount [maxcount] | 323 | //in: linda_ud key mincount [maxcount] |
324 | int keepercall_receive_batched( lua_State* L) | 324 | int keepercall_receive_batched( lua_State* L) |
325 | { | 325 | { |
326 | int const min_count = (int) lua_tointeger( L, 3); | 326 | lua_Integer const min_count = lua_tointeger( L, 3); |
327 | if( min_count > 0) | 327 | if( min_count > 0) |
328 | { | 328 | { |
329 | keeper_fifo* fifo; | 329 | keeper_fifo* fifo; |
330 | int const max_count = (int) luaL_optinteger( L, 4, min_count); | 330 | lua_Integer const max_count = luaL_optinteger( L, 4, min_count); |
331 | lua_settop( L, 2); // ud key | 331 | lua_settop( L, 2); // ud key |
332 | lua_insert( L, 1); // key ud | 332 | lua_insert( L, 1); // key ud |
333 | push_table( L, 2); // key ud fifos | 333 | push_table( L, 2); // key ud fifos |
@@ -357,7 +357,7 @@ int keepercall_receive_batched( lua_State* L) | |||
357 | int keepercall_limit( lua_State* L) | 357 | int keepercall_limit( lua_State* L) |
358 | { | 358 | { |
359 | keeper_fifo* fifo; | 359 | keeper_fifo* fifo; |
360 | int limit = (int) lua_tointeger( L, 3); | 360 | lua_Integer limit = lua_tointeger( L, 3); |
361 | push_table( L, 1); // ud key n fifos | 361 | push_table( L, 1); // ud key n fifos |
362 | lua_replace( L, 1); // fifos key n | 362 | lua_replace( L, 1); // fifos key n |
363 | lua_pop( L, 1); // fifos key | 363 | lua_pop( L, 1); // fifos key |
@@ -429,7 +429,7 @@ int keepercall_set( lua_State* L) | |||
429 | } | 429 | } |
430 | else // set/replace contents stored at the specified key? | 430 | else // set/replace contents stored at the specified key? |
431 | { | 431 | { |
432 | int count = lua_gettop( L) - 2; // number of items we want to store | 432 | lua_Integer count = lua_gettop( L) - 2; // number of items we want to store |
433 | keeper_fifo* fifo; // fifos key [val [, ...]] | 433 | keeper_fifo* fifo; // fifos key [val [, ...]] |
434 | lua_pushvalue( L, 2); // fifos key [val [, ...]] key | 434 | lua_pushvalue( L, 2); // fifos key [val [, ...]] key |
435 | lua_rawget( L, 1); // fifos key [val [, ...]] fifo|nil | 435 | lua_rawget( L, 1); // fifos key [val [, ...]] fifo|nil |
@@ -466,7 +466,7 @@ int keepercall_set( lua_State* L) | |||
466 | int keepercall_get( lua_State* L) | 466 | int keepercall_get( lua_State* L) |
467 | { | 467 | { |
468 | keeper_fifo* fifo; | 468 | keeper_fifo* fifo; |
469 | int count = 1; | 469 | lua_Integer count = 1; |
470 | if( lua_gettop( L) == 3) // ud key count | 470 | if( lua_gettop( L) == 3) // ud key count |
471 | { | 471 | { |
472 | count = lua_tointeger( L, 3); | 472 | count = lua_tointeger( L, 3); |
@@ -482,7 +482,7 @@ int keepercall_get( lua_State* L) | |||
482 | count = __min( count, fifo->count); | 482 | count = __min( count, fifo->count); |
483 | // read <count> value off the fifo | 483 | // read <count> value off the fifo |
484 | fifo_peek( L, fifo, count); // fifo ... | 484 | fifo_peek( L, fifo, count); // fifo ... |
485 | return count; | 485 | return (int) count; |
486 | } | 486 | } |
487 | // no fifo was ever registered for this key, or it is empty | 487 | // no fifo was ever registered for this key, or it is empty |
488 | return 0; | 488 | return 0; |
@@ -491,7 +491,6 @@ int keepercall_get( lua_State* L) | |||
491 | // in: linda_ud [, key [, ...]] | 491 | // in: linda_ud [, key [, ...]] |
492 | int keepercall_count( lua_State* L) | 492 | int keepercall_count( lua_State* L) |
493 | { | 493 | { |
494 | int top; | ||
495 | push_table( L, 1); // ud keys fifos | 494 | push_table( L, 1); // ud keys fifos |
496 | switch( lua_gettop( L)) | 495 | switch( lua_gettop( L)) |
497 | { | 496 | { |
@@ -537,7 +536,7 @@ int keepercall_count( lua_State* L) | |||
537 | lua_replace( L, 1); // out keys fifos | 536 | lua_replace( L, 1); // out keys fifos |
538 | // shifts all keys up in the stack. potentially slow if there are a lot of them, but then it should be bearable | 537 | // shifts all keys up in the stack. potentially slow if there are a lot of them, but then it should be bearable |
539 | lua_insert( L, 2); // out fifos keys | 538 | lua_insert( L, 2); // out fifos keys |
540 | while( (top = lua_gettop( L)) > 2) | 539 | while( lua_gettop( L) > 2) |
541 | { | 540 | { |
542 | keeper_fifo* fifo; | 541 | keeper_fifo* fifo; |
543 | lua_pushvalue( L, -1); // out fifos keys key | 542 | lua_pushvalue( L, -1); // out fifos keys key |
diff --git a/src/lanes.c b/src/lanes.c index 7f641c3..9b95469 100644 --- a/src/lanes.c +++ b/src/lanes.c | |||
@@ -630,7 +630,7 @@ LUAG_FUNC( linda_receive) | |||
630 | { | 630 | { |
631 | int is_batched; | 631 | int is_batched; |
632 | lua_pushliteral( L, BATCH_SENTINEL); | 632 | lua_pushliteral( L, BATCH_SENTINEL); |
633 | is_batched = lua_equal( L, key_i, -1); | 633 | is_batched = lua501_equal( L, key_i, -1); |
634 | lua_pop( L, 1); | 634 | lua_pop( L, 1); |
635 | if( is_batched) | 635 | if( is_batched) |
636 | { | 636 | { |
@@ -846,7 +846,7 @@ LUAG_FUNC( linda_get) | |||
846 | { | 846 | { |
847 | struct s_Linda* const linda = lua_toLinda( L, 1); | 847 | struct s_Linda* const linda = lua_toLinda( L, 1); |
848 | int pushed; | 848 | int pushed; |
849 | int count = luaL_optint( L, 3, 1); | 849 | lua_Integer count = luaL_optinteger( L, 3, 1); |
850 | luaL_argcheck( L, count >= 1, 3, "count should be >= 1"); | 850 | luaL_argcheck( L, count >= 1, 3, "count should be >= 1"); |
851 | luaL_argcheck( L, lua_gettop( L) <= 3, 4, "too many arguments"); | 851 | luaL_argcheck( L, lua_gettop( L) <= 3, 4, "too many arguments"); |
852 | 852 | ||
@@ -1144,7 +1144,7 @@ static void* linda_id( lua_State* L, enum eDeepOp op_) | |||
1144 | 1144 | ||
1145 | case 2: // 2 parameters, a name and group, in that order | 1145 | case 2: // 2 parameters, a name and group, in that order |
1146 | linda_name = lua_tolstring( L, -2, &name_len); | 1146 | linda_name = lua_tolstring( L, -2, &name_len); |
1147 | linda_group = lua_tointeger( L, -1); | 1147 | linda_group = (unsigned long) lua_tointeger( L, -1); |
1148 | break; | 1148 | break; |
1149 | } | 1149 | } |
1150 | 1150 | ||
@@ -1982,7 +1982,7 @@ LUAG_FUNC( get_debug_threadname) | |||
1982 | 1982 | ||
1983 | LUAG_FUNC( set_thread_priority) | 1983 | LUAG_FUNC( set_thread_priority) |
1984 | { | 1984 | { |
1985 | int const prio = luaL_checkint( L, 1); | 1985 | int const prio = (int) luaL_checkinteger( L, 1); |
1986 | // public Lanes API accepts a generic range -3/+3 | 1986 | // public Lanes API accepts a generic range -3/+3 |
1987 | // that will be remapped into the platform-specific scheduler priority scheme | 1987 | // that will be remapped into the platform-specific scheduler priority scheme |
1988 | // On some platforms, -3 is equivalent to -2 and +3 to +2 | 1988 | // On some platforms, -3 is equivalent to -2 and +3 to +2 |
diff --git a/src/tools.c b/src/tools.c index e0f4c40..bd1ea85 100644 --- a/src/tools.c +++ b/src/tools.c | |||
@@ -286,7 +286,7 @@ FuncSubType luaG_getfuncsubtype( lua_State *L, int _i) | |||
286 | // the provided writer fails with code 666 | 286 | // the provided writer fails with code 666 |
287 | // therefore, anytime we get 666, this means that lua_dump() attempted a dump | 287 | // therefore, anytime we get 666, this means that lua_dump() attempted a dump |
288 | // all other cases mean this is either a C or LuaJIT-fast function | 288 | // all other cases mean this is either a C or LuaJIT-fast function |
289 | dumpres = lua_dump( L, dummy_writer, NULL); | 289 | dumpres = lua503_dump( L, dummy_writer, NULL, 1); |
290 | lua_pop( L, mustpush); | 290 | lua_pop( L, mustpush); |
291 | if( dumpres == 666) | 291 | if( dumpres == 666) |
292 | { | 292 | { |
@@ -1192,7 +1192,7 @@ static void inter_copy_func( struct s_Universe* U, lua_State* L2, uint_t L2_cach | |||
1192 | // "value returned is the error code returned by the last call | 1192 | // "value returned is the error code returned by the last call |
1193 | // to the writer" (and we only return 0) | 1193 | // to the writer" (and we only return 0) |
1194 | // not sure this could ever fail but for memory shortage reasons | 1194 | // not sure this could ever fail but for memory shortage reasons |
1195 | if( lua_dump( L, buf_writer, &b) != 0) | 1195 | if( lua503_dump( L, buf_writer, &b, 1) != 0) |
1196 | { | 1196 | { |
1197 | luaL_error( L, "internal error: function dump failed."); | 1197 | luaL_error( L, "internal error: function dump failed."); |
1198 | } | 1198 | } |
@@ -1400,9 +1400,8 @@ static bool_t inter_copy_one_( struct s_Universe* U, lua_State* L2, uint_t L2_ca | |||
1400 | 1400 | ||
1401 | case LUA_TNUMBER: | 1401 | case LUA_TNUMBER: |
1402 | /* LNUM patch support (keeping integer accuracy) */ | 1402 | /* LNUM patch support (keeping integer accuracy) */ |
1403 | // TODO: support for integer in Lua 5.3 | 1403 | #if defined LUA_LNUM || LUA_VERSION_NUM >= 503 |
1404 | #ifdef LUA_LNUM | 1404 | if( lua_isinteger( L, i)) |
1405 | if( lua_isinteger(L,i)) | ||
1406 | { | 1405 | { |
1407 | lua_Integer v = lua_tointeger( L, i); | 1406 | lua_Integer v = lua_tointeger( L, i); |
1408 | DEBUGSPEW_CODE( if( vt == VT_KEY) fprintf( stderr, INDENT_BEGIN "KEY: %d\n" INDENT_END, v)); | 1407 | DEBUGSPEW_CODE( if( vt == VT_KEY) fprintf( stderr, INDENT_BEGIN "KEY: %d\n" INDENT_END, v)); |
diff --git a/src/tools.h b/src/tools.h index b868440..a4bcf43 100644 --- a/src/tools.h +++ b/src/tools.h | |||
@@ -132,7 +132,7 @@ extern void* const UNIVERSE_REGKEY; | |||
132 | #endif | 132 | #endif |
133 | #define ASSERT_L(c) _ASSERT_L(L,c) | 133 | #define ASSERT_L(c) _ASSERT_L(L,c) |
134 | 134 | ||
135 | #define STACK_GROW(L,n) do { if (!lua_checkstack(L,n)) luaL_error( L, "Cannot grow stack!" ); } while( 0) | 135 | #define STACK_GROW( L, n) do { if (!lua_checkstack(L,(int)(n))) luaL_error( L, "Cannot grow stack!" ); } while( 0) |
136 | 136 | ||
137 | #define LUAG_FUNC( func_name ) static int LG_##func_name( lua_State* L) | 137 | #define LUAG_FUNC( func_name ) static int LG_##func_name( lua_State* L) |
138 | 138 | ||