r110235 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110234‎ | r110235 | r110236 >
Date:12:28, 29 January 2012
Author:vvv
Status:deferred
Tags:
Comment:
* Fix the previous revision.
* Implement passing Lua functions from PHP.
Modified paths:
  • /trunk/php/luasandbox/luasandbox.c (modified) (history)

Diff [purge]

Index: trunk/php/luasandbox/luasandbox.c
@@ -1201,11 +1201,26 @@
12021202 return 0;
12031203 }
12041204 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+
12061220 if (!luasandbox_push_hashtable(L, Z_OBJPROP_P(z))) {
12071221 return 0;
12081222 }
12091223 break;
 1224+ }
12101225 case IS_STRING:
12111226 lua_pushlstring(L, Z_STRVAL_P(z), Z_STRLEN_P(z));
12121227 break;
@@ -1395,7 +1410,7 @@
13961411 }
13971412
13981413 // Put the function together with other chunks
1399 - lua_pushvalue(L, index);
 1414+ lua_pushvalue(L, index - 1);
14001415 lua_rawseti(L, -2, (int)func_index);
14011416
14021417 // Create a LuaSandboxFunction object to hold a reference to the function

Status & tagging log