diff options
author | Benoit Germain <bnt.germain@gmail.com> | 2016-11-21 15:02:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-21 15:02:50 +0100 |
commit | 8d2e855c7d043a7cbf4bed111e1402c327e62eda (patch) | |
tree | 96b35ae2c5aea2785d7bd57d1a639837fa71e8db | |
parent | 24256bd35a9d228f4ecd2a9edfd88ce63932e359 (diff) | |
parent | b36919cac89309e2aa75e8575243be33c9fd5944 (diff) | |
download | lanes-8d2e855c7d043a7cbf4bed111e1402c327e62eda.tar.gz lanes-8d2e855c7d043a7cbf4bed111e1402c327e62eda.tar.bz2 lanes-8d2e855c7d043a7cbf4bed111e1402c327e62eda.zip |
Merge pull request #124 from trukanduk/master
Added __lanesignore field for metatables
-rw-r--r-- | src/tools.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/tools.c b/src/tools.c index 3a19605..9a1c19d 100644 --- a/src/tools.c +++ b/src/tools.c | |||
@@ -1392,10 +1392,26 @@ static void push_cached_func( struct s_Universe* U, lua_State* L2, uint_t L2_cac | |||
1392 | static bool_t inter_copy_one_( struct s_Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint_t i, enum e_vt vt, enum eLookupMode mode_, char const* upName_) | 1392 | static bool_t inter_copy_one_( struct s_Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint_t i, enum e_vt vt, enum eLookupMode mode_, char const* upName_) |
1393 | { | 1393 | { |
1394 | bool_t ret = TRUE; | 1394 | bool_t ret = TRUE; |
1395 | bool_t ignore = FALSE; | ||
1395 | STACK_GROW( L2, 1); | 1396 | STACK_GROW( L2, 1); |
1396 | STACK_CHECK( L2); | 1397 | STACK_CHECK( L2); |
1397 | 1398 | ||
1398 | switch( lua_type( L, i)) | 1399 | /* Skip the object if it has metatable with { __lanesignore = true } */ |
1400 | if( lua_getmetatable( L, i)) // ... mt | ||
1401 | { | ||
1402 | lua_pushstring( L, "__lanesignore"); // ... mt "__lanesignore" | ||
1403 | lua_gettable( L, -2); // ... mt ignore? | ||
1404 | |||
1405 | if( lua_isboolean( L, -1) && lua_toboolean( L, -1)) | ||
1406 | { | ||
1407 | ignore = TRUE; | ||
1408 | } | ||
1409 | |||
1410 | lua_pop( L, 2); // ... | ||
1411 | } | ||
1412 | |||
1413 | /* Lets push nil to L2 if the object should be ignored */ | ||
1414 | switch( ignore ? LUA_TNIL : lua_type( L, i)) | ||
1399 | { | 1415 | { |
1400 | /* Basic types allowed both as values, and as table keys */ | 1416 | /* Basic types allowed both as values, and as table keys */ |
1401 | 1417 | ||