Index: trunk/php/luasandbox/luasandbox.c |
— | — | @@ -1201,11 +1201,26 @@ |
1202 | 1202 | return 0; |
1203 | 1203 | } |
1204 | 1204 | break; |
1205 | | - case IS_OBJECT: |
| 1205 | + case IS_OBJECT: { |
| 1206 | + zend_class_entry * objce; |
| 1207 | + |
| 1208 | + objce = Z_OBJCE_P(z); |
| 1209 | + if (instanceof_function(objce, luasandboxfunction_ce TSRMLS_CC)) { |
| 1210 | + php_luasandboxfunction_obj * func_obj; |
| 1211 | + |
| 1212 | + func_obj = (php_luasandboxfunction_obj *)zend_object_store_get_object(z TSRMLS_CC); |
| 1213 | + |
| 1214 | + lua_getfield(L, LUA_REGISTRYINDEX, "php_luasandbox_chunks"); |
| 1215 | + lua_rawgeti(L, -1, func_obj->index); |
| 1216 | + lua_remove(L, -2); |
| 1217 | + break; |
| 1218 | + } |
| 1219 | + |
1206 | 1220 | if (!luasandbox_push_hashtable(L, Z_OBJPROP_P(z))) { |
1207 | 1221 | return 0; |
1208 | 1222 | } |
1209 | 1223 | break; |
| 1224 | + } |
1210 | 1225 | case IS_STRING: |
1211 | 1226 | lua_pushlstring(L, Z_STRVAL_P(z), Z_STRLEN_P(z)); |
1212 | 1227 | break; |
— | — | @@ -1395,7 +1410,7 @@ |
1396 | 1411 | } |
1397 | 1412 | |
1398 | 1413 | // Put the function together with other chunks |
1399 | | - lua_pushvalue(L, index); |
| 1414 | + lua_pushvalue(L, index - 1); |
1400 | 1415 | lua_rawseti(L, -2, (int)func_index); |
1401 | 1416 | |
1402 | 1417 | // Create a LuaSandboxFunction object to hold a reference to the function |