aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES6
-rw-r--r--docs/index.html10
-rw-r--r--src/lanes.c2
-rw-r--r--src/tools.c22
-rw-r--r--tests/nameof.lua1
5 files changed, 28 insertions, 13 deletions
diff --git a/CHANGES b/CHANGES
index 8575e8d..e92c813 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,11 @@
1CHANGES: 1CHANGES:
2 2
3CHANGE 95: BGe 22-Jan-14
4 * version 3.8.3
5 * fixed a possible Lua stack overflow when sending complex function through lindas or as lane body
6 * experimental: lanes.nameof() scans the registry if a regular search didn't yield anything interesting
7 * fixed lanes.nameof() misbehaving when encountering a LUA_TTHREAD object
8
3CHANGE 94: BGe 22-Jan-14 9CHANGE 94: BGe 22-Jan-14
4 * version 3.8.2 10 * version 3.8.2
5 * new lane launcher option gc_cb to set a callback that is invoked when a lane is garbage collected 11 * new lane launcher option gc_cb to set a callback that is invoked when a lane is garbage collected
diff --git a/docs/index.html b/docs/index.html
index c662a14..f639f18 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -70,7 +70,7 @@
70 </p> 70 </p>
71 71
72 <p> 72 <p>
73 This document was revised on 22-Jan-14, and applies to version <tt>3.8.2</tt>. 73 This document was revised on 22-Jan-14, and applies to version <tt>3.8.3</tt>.
74 </p> 74 </p>
75 </font> 75 </font>
76 </center> 76 </center>
@@ -645,8 +645,8 @@
645</p> 645</p>
646 646
647<p> 647<p>
648 If a lane body pulls a C function imported by a module required before Lanes itself (thus not through a hooked <tt>require</tt>), the lane generator creation will raise an error. 648 If a lane body pulls a C function imported by a module required before Lanes itself (thus not through a hooked <tt>require</tt>), the lane generator creation will raise an error.
649 The function name it shows is a path where it was found by scanning <tt>_G</tt>. As a utility, the name guessing functionality is exposed as such: 649 The function name it shows is a path where it was found by scanning <tt>_G</tt>. As a utility, the name guessing functionality is exposed as such:
650 650
651 <table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"> 651 <table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%">
652 <tr> 652 <tr>
@@ -657,6 +657,10 @@
657 </table> 657 </table>
658</p> 658</p>
659 659
660<p>
661 Starting with version 3.8.3, <tt>lanes.nameof()</tt> searches the registry as well.
662</p>
663
660<h3>Free running lanes</h3> 664<h3>Free running lanes</h3>
661 665
662<p> 666<p>
diff --git a/src/lanes.c b/src/lanes.c
index a806c16..270c01d 100644
--- a/src/lanes.c
+++ b/src/lanes.c
@@ -52,7 +52,7 @@
52 * ... 52 * ...
53 */ 53 */
54 54
55char const* VERSION = "3.8.2"; 55char const* VERSION = "3.8.3";
56 56
57/* 57/*
58=============================================================================== 58===============================================================================
diff --git a/src/tools.c b/src/tools.c
index 9f36858..e456db7 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -1443,14 +1443,7 @@ static int discover_object_name_recur( lua_State* L, int shortest_, int depth_)
1443 break; 1443 break;
1444 1444
1445 case LUA_TTHREAD: // o "r" {c} {fqn} ... {?} k T 1445 case LUA_TTHREAD: // o "r" {c} {fqn} ... {?} k T
1446 // search in the object's uservalue if it is a table 1446 // TODO: explore the thread's stack frame looking for our culprit?
1447 lua_getuservalue( L, -1); // o "r" {c} {fqn} ... {?} k T {u}
1448 if( lua_istable( L, -1))
1449 {
1450 shortest_ = discover_object_name_recur( L, shortest_, depth_);
1451 }
1452 lua_pop( L, 1); // o "r" {c} {fqn} ... {?} k T
1453 STACK_MID( L, 2);
1454 break; 1447 break;
1455 1448
1456 case LUA_TUSERDATA: // o "r" {c} {fqn} ... {?} k U 1449 case LUA_TUSERDATA: // o "r" {c} {fqn} ... {?} k U
@@ -1531,9 +1524,19 @@ int luaG_nameof( lua_State* L)
1531 lua_newtable( L); // o nil {c} 1524 lua_newtable( L); // o nil {c}
1532 // push a table whose contents are strings that, when concatenated, produce unique name 1525 // push a table whose contents are strings that, when concatenated, produce unique name
1533 lua_newtable( L); // o nil {c} {fqn} 1526 lua_newtable( L); // o nil {c} {fqn}
1527 lua_pushliteral( L, "_G"); // o nil {c} {fqn} "_G"
1528 lua_rawseti( L, -2, 1); // o nil {c} {fqn}
1534 // this is where we start the search 1529 // this is where we start the search
1535 lua_pushglobaltable( L); // o nil {c} {fqn} _G 1530 lua_pushglobaltable( L); // o nil {c} {fqn} _G
1536 (void) discover_object_name_recur( L, 6666, 0); 1531 (void) discover_object_name_recur( L, 6666, 1);
1532 if( lua_isnil( L, 2)) // try again with registry, just in case...
1533 {
1534 lua_pop( L, 1); // o nil {c} {fqn}
1535 lua_pushliteral( L, "_R"); // o nil {c} {fqn} "_R"
1536 lua_rawseti( L, -2, 1); // o nil {c} {fqn}
1537 lua_pushvalue( L, LUA_REGISTRYINDEX); // o nil {c} {fqn} _R
1538 (void) discover_object_name_recur( L, 6666, 1);
1539 }
1537 lua_pop( L, 3); // o "result" 1540 lua_pop( L, 3); // o "result"
1538 STACK_END( L, 1); 1541 STACK_END( L, 1);
1539 lua_pushstring( L, luaL_typename( L, 1)); // o "result" "type" 1542 lua_pushstring( L, luaL_typename( L, 1)); // o "result" "type"
@@ -1606,6 +1609,7 @@ static void lookup_native_func( lua_State* L2, lua_State* L, uint_t i, enum eLoo
1606 STACK_END( L, 0); 1609 STACK_END( L, 0);
1607 // push the equivalent function in the destination's stack, retrieved from the lookup table 1610 // push the equivalent function in the destination's stack, retrieved from the lookup table
1608 STACK_CHECK( L2); 1611 STACK_CHECK( L2);
1612 STACK_GROW( L2, 2);
1609 if( mode_ == eLM_ToKeeper) 1613 if( mode_ == eLM_ToKeeper)
1610 { 1614 {
1611 // push a sentinel closure that holds the lookup name as upvalue 1615 // push a sentinel closure that holds the lookup name as upvalue
diff --git a/tests/nameof.lua b/tests/nameof.lua
index ed20a32..221c893 100644
--- a/tests/nameof.lua
+++ b/tests/nameof.lua
@@ -1,4 +1,5 @@
1lanes = require "lanes".configure() 1lanes = require "lanes".configure()
2 2
3print( lanes.nameof( {}))
3print( lanes.nameof( string.sub)) 4print( lanes.nameof( string.sub))
4print( lanes.nameof( print)) 5print( lanes.nameof( print))