mirror of
https://github.com/php-win-ext/php-lua.git
synced 2026-04-24 01:08:10 +02:00
Compare commits
75 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e16624fd1c | |||
| 44a0c089ca | |||
| a6c5162a7c | |||
| 0875f92328 | |||
| 445e886030 | |||
| 5c405f9746 | |||
| 9b25ea36a5 | |||
| 5b6ac82491 | |||
| 5663931ce7 | |||
| a5a8995b2e | |||
| ffae3062a4 | |||
| 13e26a383a | |||
| ef70d19a33 | |||
| d763f167d8 | |||
| 24fd1baf19 | |||
| a780d5623d | |||
| 0d73a2fdaa | |||
| aa1dd4f526 | |||
| 199a846d7a | |||
| 84c831e4cb | |||
| f588c88528 | |||
| ad31d5f7c6 | |||
| 15f58c43fb | |||
| c4c61f05bf | |||
| 9ef044896a | |||
| feb39efa86 | |||
| 4438a88e85 | |||
| 0c6a60d21b | |||
| db95520d2f | |||
| 8afc555bce | |||
| 486de80ebf | |||
| 1813b36307 | |||
| a2be2c935b | |||
| 6690ee0c70 | |||
| f64a8d6d27 | |||
| d6c7850afa | |||
| 257d46c1e4 | |||
| e350b425f4 | |||
| 527f927ead | |||
| 9be57325c6 | |||
| 1ff1eb10c9 | |||
| cbe65b9ad6 | |||
| 04f7106631 | |||
| 7406b07f2c | |||
| 17cbba8b77 | |||
| 7cdb287c33 | |||
| f3d6dca1a0 | |||
| f177b21ff1 | |||
| c7d9844cf1 | |||
| 12c53f28eb | |||
| 86cb62e0b8 | |||
| dc226c345d | |||
| 2d23b565e5 | |||
| 230a8af900 | |||
| 468203ce7c | |||
| 1bd4adf039 | |||
| 18e2bb493d | |||
| 0b28ef4f55 | |||
| f6a2f09b19 | |||
| 6c2a37f99c | |||
| 65764e0777 | |||
| cf3f69b274 | |||
| 49b95a64f3 | |||
| ca8cf30759 | |||
| 8bccbdc5db | |||
| a55478e449 | |||
| adb5146954 | |||
| b95ae16c6f | |||
| c3b50a5645 | |||
| bcc3bb67f8 | |||
| 5e5fefcdbf | |||
| dea4f594e4 | |||
| 6205c5c4ff | |||
| a2e9c435c4 | |||
| 061f22aac0 |
+38
@@ -0,0 +1,38 @@
|
||||
*.o
|
||||
*.lo
|
||||
*.la
|
||||
.*.swp
|
||||
.deps
|
||||
.libs/
|
||||
include/
|
||||
tests/*.diff
|
||||
tests/*.exp
|
||||
tests/*.log
|
||||
tests/*.php
|
||||
tests/*.out
|
||||
tests/*.sh
|
||||
Makefile
|
||||
Makefile.fragments
|
||||
Makefile.global
|
||||
Makefile.objects
|
||||
acinclude.m4
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
build/
|
||||
config.guess
|
||||
config.h
|
||||
config.h.in
|
||||
config.log
|
||||
config.nice
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
configure.ac
|
||||
configure.in
|
||||
install-sh
|
||||
libtool
|
||||
ltmain.sh
|
||||
missing
|
||||
mkinstalldirs
|
||||
modules/
|
||||
run-tests.php
|
||||
+6
-5
@@ -6,10 +6,11 @@ addons:
|
||||
- liblua5.2-dev
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.2
|
||||
- 7.3
|
||||
- 7.4
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
@@ -23,4 +24,4 @@ before_script:
|
||||
- ./travis/compile.sh
|
||||
|
||||
# Run PHPs run-tests.php
|
||||
script: make test
|
||||
script: TEST_PHP_ARGS="--show-diff" make test
|
||||
|
||||
@@ -2,3 +2,4 @@ lua
|
||||
Johannes Schlueter
|
||||
Marcelo Araujo
|
||||
Xinchen Hui
|
||||
Helmut Januschka
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
##PHP Lua
|
||||
# PHP Lua
|
||||
[](https://travis-ci.org/laruence/php-lua)
|
||||
|
||||
This extension embeds the lua interpreter and offers an OO-API to lua variables and functions.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
dnl $Id: config.m4 321796 2012-01-05 17:23:48Z laruence $
|
||||
PHP_ARG_WITH(lua, for lua support,
|
||||
[ --with-lua=[DIR] Include php lua support])
|
||||
PHP_ARG_WITH(lua-version, to specify a custom lua version, [ --with-lua-version=[VERSION]] Use the specified lua version.)
|
||||
|
||||
PHP_ARG_WITH(lua-version, to specify a custom lua version, [ --with-lua-version=[VERSION]] Use the specified lua version.)
|
||||
|
||||
@@ -16,6 +16,12 @@ if test "$PHP_LUA" != "no"; then
|
||||
break
|
||||
fi
|
||||
|
||||
if test -r $i/include/lua.h; then
|
||||
LUA_INCLUDE_DIR=$i/include
|
||||
AC_MSG_RESULT(found in $i)
|
||||
break
|
||||
fi
|
||||
|
||||
if test "$PHP_LUA_VERSION" != "yes"; then
|
||||
if test -r $i/include/lua$PHP_LUA_VERSION/lua.h; then
|
||||
LUA_INCLUDE_DIR=$i/include/lua$PHP_LUA_VERSION
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+51
-95
@@ -11,10 +11,10 @@
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author : Johannes Schlueter <johannes@php.net> |
|
||||
| Xinchen Hui <laruence@php.net> |
|
||||
| Xinchen Hui <laruence@php.net> |
|
||||
| Marcelo Araujo <msaraujo@php.net> |
|
||||
| Helmut Januschka <helmut@januschka.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
$Id: lua_closure.c 319740 2011-11-24 08:06:48Z laruence $
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "Zend/zend_exceptions.h"
|
||||
|
||||
#include "lua.h"
|
||||
#include "lua_closure.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
|
||||
@@ -33,6 +34,7 @@
|
||||
static zend_class_entry *lua_closure_ce;
|
||||
extern zend_class_entry *lua_ce;
|
||||
extern zend_class_entry *lua_exception_ce;
|
||||
static zend_object_handlers lua_closure_handlers;
|
||||
|
||||
/** {{{ ARG_INFO
|
||||
*
|
||||
@@ -43,12 +45,17 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_lua_invoke, 0, 0, 1)
|
||||
ZEND_END_ARG_INFO()
|
||||
/* }}} */
|
||||
|
||||
/** {{{ zval * php_lua_closure_instance(zval *instance, long ref_id, zval *lua_obj TSRMLS_DC)
|
||||
/** {{{ zval * php_lua_closure_instance(zval *instance, long ref_id, zval *lua_obj)
|
||||
*/
|
||||
zval * php_lua_closure_instance(zval *instance, long ref_id, zval *lua_obj TSRMLS_DC) {
|
||||
zval* php_lua_closure_instance(zval *instance, long ref_id, zval *lua_obj) {
|
||||
lua_closure_object *objval;
|
||||
|
||||
object_init_ex(instance, lua_closure_ce);
|
||||
zend_update_property_long(lua_closure_ce, instance, ZEND_STRL("_closure"), ref_id TSRMLS_CC);
|
||||
zend_update_property(lua_closure_ce, instance, ZEND_STRL("_lua_object"), lua_obj TSRMLS_CC);
|
||||
objval = php_lua_closure_object_from_zend_object(Z_OBJ_P(instance));
|
||||
objval->closure = ref_id;
|
||||
if (lua_obj) {
|
||||
ZVAL_ZVAL(&(objval->lua), lua_obj, 1, 0);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
@@ -60,74 +67,44 @@ PHP_METHOD(lua_closure, __construct) {
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/** {{{ proto LuaClosure::__destruct()
|
||||
*/
|
||||
PHP_METHOD(lua_closure, __destruct) {
|
||||
zval *lua_obj, *closure;
|
||||
|
||||
lua_obj = zend_read_property(lua_closure_ce, getThis(), ZEND_STRL("_lua_object"), 1 TSRMLS_CC);
|
||||
if (ZVAL_IS_NULL(lua_obj)
|
||||
|| Z_TYPE_P(lua_obj) != IS_OBJECT
|
||||
|| !instanceof_function(Z_OBJCE_P(lua_obj), lua_ce TSRMLS_CC)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
closure = zend_read_property(lua_closure_ce, getThis(), ZEND_STRL("_closure"), 1 TSRMLS_CC);
|
||||
if (!Z_LVAL_P(closure)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
luaL_unref(Z_LUAVAL_P(lua_obj), LUA_REGISTRYINDEX, Z_LVAL_P(closure));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/** {{{ proto LuaClosure::invoke(mxied $args)
|
||||
*/
|
||||
PHP_METHOD(lua_closure, invoke) {
|
||||
lua_closure_object *objval = php_lua_closure_object_from_zend_object(Z_OBJ_P(getThis()));
|
||||
int bp, sp;
|
||||
zval ***arguments = NULL;
|
||||
zval *lua_obj = NULL;
|
||||
zval *arguments = NULL;
|
||||
lua_State *L = NULL;
|
||||
zval *closure = NULL;
|
||||
zval rv;
|
||||
|
||||
if (ZEND_NUM_ARGS()) {
|
||||
arguments = emalloc(sizeof(zval**) * ZEND_NUM_ARGS());
|
||||
arguments = emalloc(sizeof(zval) * ZEND_NUM_ARGS());
|
||||
if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), arguments) == FAILURE) {
|
||||
efree(arguments);
|
||||
zend_throw_exception_ex(lua_exception_ce, 0 TSRMLS_CC, "cannot get arguments for calling closure");
|
||||
zend_throw_exception_ex(NULL, 0, "cannot get arguments for calling closure");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
lua_obj = zend_read_property(lua_closure_ce, getThis(), ZEND_STRL("_lua_object"), 1 TSRMLS_CC);
|
||||
|
||||
if (ZVAL_IS_NULL(lua_obj)
|
||||
|| Z_TYPE_P(lua_obj) != IS_OBJECT
|
||||
|| !instanceof_function(Z_OBJCE_P(lua_obj), lua_ce TSRMLS_CC)) {
|
||||
zend_throw_exception_ex(lua_exception_ce, 0 TSRMLS_CC, "corrupted Lua object");
|
||||
if (Z_TYPE(objval->lua) != IS_OBJECT
|
||||
|| !instanceof_function(Z_OBJCE(objval->lua), lua_ce)) {
|
||||
zend_throw_exception_ex(NULL, 0, "corrupted Lua object");
|
||||
return;
|
||||
}
|
||||
|
||||
closure = zend_read_property(lua_closure_ce, getThis(), ZEND_STRL("_closure"), 1 TSRMLS_CC);
|
||||
if (!Z_LVAL_P(closure)) {
|
||||
zend_throw_exception_ex(lua_exception_ce, 0 TSRMLS_CC, "invalid lua closure");
|
||||
return;
|
||||
}
|
||||
|
||||
L = Z_LUAVAL_P(lua_obj);
|
||||
L = (Z_LUAVAL(objval->lua))->L;
|
||||
|
||||
bp = lua_gettop(L);
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, Z_LVAL_P(closure));
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, objval->closure);
|
||||
if (LUA_TFUNCTION != lua_type(L, lua_gettop(L))) {
|
||||
lua_pop(L, -1);
|
||||
zend_throw_exception_ex(lua_exception_ce, 0 TSRMLS_CC, "call to lua closure failed");
|
||||
zend_throw_exception_ex(NULL, 0, "call to lua closure failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ZEND_NUM_ARGS()) {
|
||||
int i = 0;
|
||||
for(;i<ZEND_NUM_ARGS();i++) {
|
||||
php_lua_send_zval_to_lua(L, *(arguments[i]) TSRMLS_CC);
|
||||
php_lua_send_zval_to_lua(L, &arguments[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +113,7 @@ PHP_METHOD(lua_closure, invoke) {
|
||||
efree(arguments);
|
||||
}
|
||||
lua_pop(L, lua_gettop(L) - bp);
|
||||
zend_throw_exception_ex(lua_exception_ce, 0 TSRMLS_CC,
|
||||
zend_throw_exception_ex(NULL, 0,
|
||||
"call to lua function %s failed", lua_tostring(L, -1));
|
||||
return;
|
||||
}
|
||||
@@ -146,14 +123,14 @@ PHP_METHOD(lua_closure, invoke) {
|
||||
if (!sp) {
|
||||
RETURN_NULL();
|
||||
} else if (sp == 1) {
|
||||
zval *tmp = php_lua_get_zval_from_lua(L, -1, lua_obj TSRMLS_CC);
|
||||
RETURN_ZVAL(tmp, 0, 0);
|
||||
php_lua_get_zval_from_lua(L, -1, &(objval->lua), return_value);
|
||||
} else {
|
||||
zval rv;
|
||||
int i = 0;
|
||||
array_init(return_value);
|
||||
for (i = -sp; i < 0; i++) {
|
||||
zval *tmp = php_lua_get_zval_from_lua(L, i, lua_obj TSRMLS_CC);
|
||||
add_next_index_zval(return_value, tmp);
|
||||
php_lua_get_zval_from_lua(L, i, &(objval->lua), &rv);
|
||||
add_next_index_zval(return_value, &rv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,73 +142,52 @@ PHP_METHOD(lua_closure, invoke) {
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/** {{{ proto LuaClosure::__clone()
|
||||
*/
|
||||
PHP_METHOD(lua_closure, __clone) {
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ lua_class_methods[]
|
||||
*
|
||||
*/
|
||||
zend_function_entry lua_closure_methods[] = {
|
||||
PHP_ME(lua_closure, __construct, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_CTOR)
|
||||
PHP_ME(lua_closure, __destruct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_DTOR)
|
||||
PHP_ME(lua_closure, __clone, NULL, ZEND_ACC_PRIVATE)
|
||||
PHP_ME(lua_closure, invoke, arginfo_lua_invoke, ZEND_ACC_PUBLIC)
|
||||
PHP_MALIAS(lua_closure, __invoke, invoke, arginfo_lua_invoke, ZEND_ACC_PUBLIC)
|
||||
{NULL, NULL, NULL}
|
||||
PHP_FE_END
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
static void php_lua_closure_dtor_object(void *object, zend_object_handle handle TSRMLS_DC) /* {{{ */
|
||||
static void php_lua_closure_free_obj(zend_object *zobj) /* {{{ */
|
||||
{
|
||||
zend_object *obj = (zend_object*)object;
|
||||
lua_closure_object *objval = php_lua_closure_object_from_zend_object(zobj);
|
||||
|
||||
zend_object_std_dtor(obj TSRMLS_CC);
|
||||
|
||||
efree(obj);
|
||||
if ((Z_TYPE(objval->lua) == IS_OBJECT) &&
|
||||
instanceof_function(Z_OBJCE(objval->lua), lua_ce)) {
|
||||
luaL_unref((Z_LUAVAL(objval->lua))->L, LUA_REGISTRYINDEX, objval->closure);
|
||||
}
|
||||
zval_dtor(&(objval->lua));
|
||||
zend_object_std_dtor(zobj);
|
||||
} /* }}} */
|
||||
|
||||
static zend_object_value php_lua_closure_create_object(zend_class_entry *ce TSRMLS_DC) /* {{{ */
|
||||
zend_object *php_lua_closure_create_object(zend_class_entry *ce) /* {{{ */
|
||||
{
|
||||
zend_object_value obj = {0};
|
||||
zend_object *lua_closure_obj = NULL;
|
||||
lua_closure_object *objval = ecalloc(1, sizeof(lua_closure_object) + zend_object_properties_size(ce));
|
||||
zend_object *zobj = &(objval->std);
|
||||
|
||||
lua_closure_obj = emalloc(sizeof(zend_object));
|
||||
zend_object_std_init(zobj, ce);
|
||||
zobj->handlers = &lua_closure_handlers;
|
||||
|
||||
zend_object_std_init(lua_closure_obj, ce TSRMLS_CC);
|
||||
#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4)
|
||||
zend_hash_copy(lua_closure_obj->properties, &ce->default_properties,
|
||||
#if (PHP_MINOR_VERSION < 4)
|
||||
(copy_ctor_func_t) zval_add_ref,
|
||||
#else
|
||||
zval_copy_property_ctor(ce),
|
||||
#endif
|
||||
(void *)0, sizeof(zval *));
|
||||
#elif (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION > 3)
|
||||
object_properties_init(lua_closure_obj, ce);
|
||||
#endif
|
||||
|
||||
obj.handle = zend_objects_store_put(lua_closure_obj, php_lua_closure_dtor_object, NULL, NULL TSRMLS_CC);
|
||||
obj.handlers = zend_get_std_object_handlers();
|
||||
|
||||
return obj;
|
||||
return zobj;
|
||||
} /* }}} */
|
||||
|
||||
void php_lua_closure_register(TSRMLS_D) /* {{{ */
|
||||
void php_lua_closure_register() /* {{{ */
|
||||
{
|
||||
zend_class_entry ce;
|
||||
|
||||
INIT_CLASS_ENTRY(ce, "LuaClosure", lua_closure_methods);
|
||||
lua_closure_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
||||
lua_closure_ce = zend_register_internal_class(&ce);
|
||||
lua_closure_ce->create_object = php_lua_closure_create_object;
|
||||
lua_closure_ce->ce_flags |= ZEND_ACC_FINAL;
|
||||
|
||||
zend_declare_property_long(lua_closure_ce, ZEND_STRL("_closure"), 0, ZEND_ACC_PRIVATE TSRMLS_CC);
|
||||
zend_declare_property_null(lua_closure_ce, ZEND_STRL("_lua_object"), ZEND_ACC_PRIVATE TSRMLS_CC);
|
||||
|
||||
|
||||
memcpy(&lua_closure_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
lua_closure_handlers.offset = XtOffsetOf(lua_closure_object, std);
|
||||
lua_closure_handlers.clone_obj = NULL;
|
||||
lua_closure_handlers.free_obj = php_lua_closure_free_obj;
|
||||
} /* }}} */
|
||||
|
||||
zend_class_entry *php_lua_get_closure_ce() /* {{{ */
|
||||
|
||||
+18
-4
@@ -11,15 +11,29 @@
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author : Johannes Schlueter <johannes@php.net> |
|
||||
| Xinchen Hui <laruence@php.net> |
|
||||
| Xinchen Hui <laruence@php.net> |
|
||||
| Marcelo Araujo <msaraujo@php.net> |
|
||||
| Helmut Januschka <helmut@januschka.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
$Id: lua_closure.h 319733 2011-11-24 07:13:56Z laruence $
|
||||
*/
|
||||
|
||||
void php_lua_closure_register(TSRMLS_D);
|
||||
#ifndef LUA_CLOSURE_H
|
||||
#define LUA_CLOSURE_H
|
||||
typedef struct _lua_closure_object {
|
||||
long closure;
|
||||
zval lua;
|
||||
|
||||
zend_object std;
|
||||
} lua_closure_object;
|
||||
|
||||
static inline lua_closure_object* php_lua_closure_object_from_zend_object(zend_object *zobj) {
|
||||
return ((lua_closure_object*)(zobj + 1)) - 1;
|
||||
}
|
||||
|
||||
void php_lua_closure_register();
|
||||
zend_class_entry *php_lua_get_closure_ce();
|
||||
zval * php_lua_closure_instance(zval *instance, long ref_id, zval *lua_obj TSRMLS_DC);
|
||||
zval * php_lua_closure_instance(zval *instance, long ref_id, zval *lua_obj);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
|
||||
+133
-11
@@ -23,21 +23,19 @@
|
||||
<email>msaraujo@php.net</email>
|
||||
<active>yes</active>
|
||||
</developer>
|
||||
<date>2013-10-23</date>
|
||||
<time>12:04:27</time>
|
||||
<date>2020-03-10</date>
|
||||
<time>11:10:00</time>
|
||||
<version>
|
||||
<release>1.1.0</release>
|
||||
<api>1.1.0</api>
|
||||
<release>2.0.7</release>
|
||||
<api>2.0.7</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
<api>beta</api>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP</license>
|
||||
<notes>
|
||||
- Fixed #65097 (nApplyCount release missing) (emptyhua at gmail dot com)
|
||||
- Trigger E_STRICT when pass an array with index '0' to lua instead of ignoring it
|
||||
- added support for callable functions and closures as values returned injected into lua engine (harald at octris dot org)
|
||||
- Fixed windows build for 7.4
|
||||
</notes>
|
||||
<contents>
|
||||
<dir name="/">
|
||||
@@ -64,14 +62,17 @@
|
||||
<file name="011.phpt" role="test" />
|
||||
<file name="012.phpt" role="test" />
|
||||
<file name="013.phpt" role="test" />
|
||||
<file name="issue012.phpt" role="test" />
|
||||
<file name="bug65097.phpt" role="test" />
|
||||
<file name="bug71997.phpt" role="test" />
|
||||
<file name="bug73964.phpt" role="test" />
|
||||
</dir>
|
||||
</dir>
|
||||
</contents>
|
||||
<dependencies>
|
||||
<required>
|
||||
<php>
|
||||
<min>5.1.0</min>
|
||||
<min>7.0.0</min>
|
||||
</php>
|
||||
<pearinstaller>
|
||||
<min>1.4.0</min>
|
||||
@@ -81,6 +82,128 @@
|
||||
<providesextension>lua</providesextension>
|
||||
<extsrcrelease />
|
||||
<changelog>
|
||||
<release>
|
||||
<date>2020-03-10</date>
|
||||
<version>
|
||||
<release>2.0.7</release>
|
||||
<api>2.0.7</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
- Fixed windows build for 7.4
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<date>2018-12-21</date>
|
||||
<version>
|
||||
<release>2.0.6</release>
|
||||
<api>2.0.6</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
- Fixed Hash Recursive Detecting in PHP-7.3
|
||||
</notes>
|
||||
<release>
|
||||
<date>2017-12-31</date>
|
||||
<version>
|
||||
<release>2.0.5</release>
|
||||
<api>2.0.5</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
- Refactor LuaClosure. (SaraG)
|
||||
- Fix non-string member access in read/write prop. (SaraG)
|
||||
- Fix allocation of lua object. (SaraG)
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<date>2017-07-12</date>
|
||||
<version>
|
||||
<release>2.0.4</release>
|
||||
<api>2.0.4</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
- Fixed bug #73964 (Segmentation fault)
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<date>2017-02-10</date>
|
||||
<version>
|
||||
<release>2.0.3</release>
|
||||
<api>2.0.3</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
- Fixed issue #20 (PHP 7: Lua::eval(): unsupported type `unknown' for lua)
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<date>2016-05-26</date>
|
||||
<version>
|
||||
<release>2.0.2</release>
|
||||
<api>2.0.2</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
- Fixed issue #22 (Boolean FALSE is always TRUE)
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<date>2016-04-11</date>
|
||||
<version>
|
||||
<release>2.0.1</release>
|
||||
<api>2.0.1</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
<api>beta</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
- Fixed bug #71997 (One-Dimensional arrays cause segmentation faults)
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<date>2015-10-27</date>
|
||||
<version>
|
||||
<release>2.0.0</release>
|
||||
<api>2.0.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
<api>beta</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
- Release lua for PHP7
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<date>2012-10-23</date>
|
||||
<version>
|
||||
@@ -98,7 +221,6 @@
|
||||
- added support for callable functions and closures as values returned injected into lua engine (harald at octris dot org)
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<date>2012-06-24</date>
|
||||
<version>
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
| Author : Johannes Schlueter <johannes@php.net> |
|
||||
| Xinchen Hui <laruence@php.net> |
|
||||
| Marcelo Araujo <msaraujo@php.net> |
|
||||
| Helmut Januschka <helmut@januschka.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
$Id: php_lua.h 324349 2012-03-19 03:17:15Z laruence $
|
||||
*/
|
||||
|
||||
#ifndef PHP_LUA_H
|
||||
@@ -48,24 +48,24 @@ extern zend_module_entry lua_module_entry;
|
||||
#define LUA_G(v) (lua_globals.v)
|
||||
#endif
|
||||
|
||||
#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 3)) || (PHP_MAJOR_VERSION < 5)
|
||||
#define Z_ADDREF_P ZVAL_ADDREF
|
||||
#define Z_REFCOUNT_P ZVAL_REFCOUNT
|
||||
#define Z_DELREF_P ZVAL_DELREF
|
||||
#endif
|
||||
|
||||
#define PHP_LUA_VERSION "1.1.1-dev"
|
||||
#define Z_LUAVAL_P(obj) ((php_lua_object*)(zend_object_store_get_object(obj TSRMLS_CC)))->L
|
||||
#define PHP_LUA_VERSION "2.0.8-dev"
|
||||
|
||||
struct _php_lua_object {
|
||||
zend_object obj;
|
||||
lua_State *L;
|
||||
lua_State *L;
|
||||
zend_object obj;
|
||||
};
|
||||
|
||||
typedef struct _php_lua_object php_lua_object;
|
||||
|
||||
zval * php_lua_get_zval_from_lua(lua_State *L, int index, zval *lua_obj TSRMLS_DC);
|
||||
int php_lua_send_zval_to_lua(lua_State *L, zval *val TSRMLS_DC);
|
||||
static inline php_lua_object *php_lua_obj_from_obj(zend_object *obj) {
|
||||
return (php_lua_object*)((char*)(obj)-XtOffsetOf(php_lua_object, obj));
|
||||
}
|
||||
|
||||
#define Z_LUAVAL(obj) php_lua_obj_from_obj(Z_OBJ((obj)))
|
||||
#define Z_LUAVAL_P(obj) php_lua_obj_from_obj(Z_OBJ_P((obj)))
|
||||
|
||||
zval *php_lua_get_zval_from_lua(lua_State *L, int index, zval *lua_obj, zval *rv);
|
||||
int php_lua_send_zval_to_lua(lua_State *L, zval *val);
|
||||
|
||||
PHP_MINIT_FUNCTION(lua);
|
||||
PHP_MSHUTDOWN_FUNCTION(lua);
|
||||
@@ -74,8 +74,8 @@ PHP_MINFO_FUNCTION(lua);
|
||||
PHP_METHOD(lua, __construct);
|
||||
PHP_METHOD(lua, eval);
|
||||
PHP_METHOD(lua, require);
|
||||
#endif /* PHP_LUA_H */
|
||||
|
||||
#endif /* PHP_LUA_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
|
||||
Regular → Executable
+2
@@ -15,6 +15,8 @@ try {
|
||||
assert($e->getCode() == LUA_ERRSYNTAX);
|
||||
echo "\n", $e->getMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
12
|
||||
-0.53657291800043
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Check for Table Pass vic-a-verse
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("lua")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$l = new lua();
|
||||
$l->eval(<<<CODE
|
||||
function test(a)
|
||||
lua_fcn(a)
|
||||
end
|
||||
CODE
|
||||
);
|
||||
|
||||
$l->registerCallback("lua_fcn", function($a) {
|
||||
ksort($a);
|
||||
var_dump($a);
|
||||
});
|
||||
$l->test(array("key1"=>"v1",
|
||||
"key2"=>"v2"));
|
||||
|
||||
|
||||
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
["key1"]=>
|
||||
string(2) "v1"
|
||||
["key2"]=>
|
||||
string(2) "v2"
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
--TEST--
|
||||
PHP Object to lua
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("lua")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
class T {
|
||||
private $v;
|
||||
private $s;
|
||||
|
||||
public function __construct($v)
|
||||
{
|
||||
$this->v = $v;
|
||||
$this->s = "string = $v";
|
||||
}
|
||||
|
||||
static function create($arg)
|
||||
{
|
||||
return new self($arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$l = new lua();
|
||||
$l->registerCallback('create_object', [T::class, 'create']);
|
||||
|
||||
$l->eval(<<<CODE
|
||||
local t = create_object(2)
|
||||
|
||||
local keys = {}
|
||||
|
||||
for k, _ in pairs(t) do
|
||||
table.insert(keys, k)
|
||||
end
|
||||
|
||||
table.sort(keys)
|
||||
for _,k in ipairs(keys) do
|
||||
print(k, " -> ", t[k], ",")
|
||||
end
|
||||
CODE
|
||||
);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
s -> string = 2,v -> 2,
|
||||
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
Bug #71997 (One-Dimensional arrays cause segmentation faults)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("lua")) print "skip lua extension missing";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$mylua = new \lua();
|
||||
$mylua->eval(<<<CODE
|
||||
function nicefunction(args)
|
||||
print(args[1])
|
||||
return args[1]
|
||||
end
|
||||
CODE
|
||||
);
|
||||
|
||||
echo $mylua->call("nicefunction", array(array('hello', 'world')));
|
||||
?>
|
||||
done
|
||||
--EXPECT--
|
||||
worldworlddone
|
||||
@@ -0,0 +1,45 @@
|
||||
--TEST--
|
||||
Bug #73964 (Segmentation fault (11))
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("lua")) print "skip lua extension missing";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class LuaTest
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
$this->lua = new Lua();
|
||||
$this->lua->registerCallback("log", array($this, "API_LuaLog"));
|
||||
}
|
||||
|
||||
|
||||
function API_LuaLog( $entry)
|
||||
{
|
||||
echo("from lua: $entry");
|
||||
}
|
||||
|
||||
public function RunTest()
|
||||
{
|
||||
$this->lua->eval(<<<CODE
|
||||
function TestFunc(str)
|
||||
log(str)
|
||||
|
||||
end
|
||||
|
||||
CODE
|
||||
);
|
||||
$GamePackage = $this->lua->RootTable;
|
||||
|
||||
$this->lua->call("TestFunc", array("okey"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$a = new LuaTest();
|
||||
$a->runtest();
|
||||
?>
|
||||
--EXPECT--
|
||||
from lua: okey
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
ISSUE #022 (Boolean FALSE is always TRUE)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("lua")) print "skip lua extension missing";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$lua = new Lua();
|
||||
$lua->assign('TEST', false);
|
||||
$result = $lua->eval('return TEST');
|
||||
var_dump($result)
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
ISSUE #040 (segmentation fault)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("lua")) print "skip lua extension missing";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$lua = new Lua();
|
||||
$lua->eval(<<<CODE
|
||||
local a = {}
|
||||
print(a)
|
||||
CODE
|
||||
);
|
||||
?>
|
||||
--EXPECT--
|
||||
Array
|
||||
(
|
||||
)
|
||||
Binary file not shown.
@@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
print with tables - 1
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("lua")) print "skip lua extension missing";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$lua = new Lua();
|
||||
$lua->eval(<<<CODE
|
||||
local people = {
|
||||
{
|
||||
phone = "123456"
|
||||
},
|
||||
}
|
||||
print(people)
|
||||
CODE
|
||||
);
|
||||
?>
|
||||
--EXPECT--
|
||||
Array
|
||||
(
|
||||
[1] => Array
|
||||
(
|
||||
[phone] => 123456
|
||||
)
|
||||
|
||||
)
|
||||
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
print with tables - 2
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("lua")) print "skip lua extension missing";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$lua = new Lua();
|
||||
$lua->eval(<<<CODE
|
||||
local a = {
|
||||
LEFT = 1,
|
||||
}
|
||||
print(a)
|
||||
CODE
|
||||
);
|
||||
?>
|
||||
--EXPECT--
|
||||
Array
|
||||
(
|
||||
[LEFT] => 1
|
||||
)
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
#exit 1 on error
|
||||
echo "all ok ";
|
||||
ls ./modules/bartlby.so
|
||||
exit $?
|
||||
Reference in New Issue
Block a user