diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..51877e0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,68 @@
+--------------------------------------------------------------------
+ The PHP License, version 3.01
+Copyright (c) 1999 - 2011 The PHP Group. All rights reserved.
+--------------------------------------------------------------------
+
+Redistribution and use in source and binary forms, with or without
+modification, is permitted provided that the following conditions
+are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ 3. The name "PHP" must not be used to endorse or promote products
+ derived from this software without prior written permission. For
+ written permission, please contact group@php.net.
+
+ 4. Products derived from this software may not be called "PHP", nor
+ may "PHP" appear in their name, without prior written permission
+ from group@php.net. You may indicate that your software works in
+ conjunction with PHP by saying "Foo for PHP" instead of calling
+ it "PHP Foo" or "phpfoo"
+
+ 5. The PHP Group may publish revised and/or new versions of the
+ license from time to time. Each version will be given a
+ distinguishing version number.
+ Once covered code has been published under a particular version
+ of the license, you may always continue to use it under the terms
+ of that version. You may also choose to use such covered code
+ under the terms of any subsequent version of the license
+ published by the PHP Group. No one other than the PHP Group has
+ the right to modify the terms applicable to covered code created
+ under this License.
+
+ 6. Redistributions of any form whatsoever must retain the following
+ acknowledgment:
+ "This product includes PHP software, freely available from
+ ".
+
+THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
+ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
+DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+--------------------------------------------------------------------
+
+This software consists of voluntary contributions made by many
+individuals on behalf of the PHP Group.
+
+The PHP Group can be contacted via Email at group@php.net.
+
+For more information on the PHP Group and the PHP project,
+please see .
+
+PHP includes the Zend Engine, freely available at
+.
diff --git a/lua.c b/lua.c
index b34b1fd..2f6f3a9 100644
--- a/lua.c
+++ b/lua.c
@@ -638,7 +638,7 @@ static zval * php_lua_call_lua_function(zval *lua_obj, zval *func, zval *args, i
zend_hash_apply_with_argument(Z_ARRVAL_P(args), php_lua_arg_apply_func, (void *)L TSRMLS_CC);
}
- if (lua_pcall(L, arg_num, LUA_MULTRET, 0) != 0) {
+ if (lua_pcall(L, arg_num, LUA_MULTRET, 0) != LUA_OK) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"call to lua function %s failed", lua_tostring(L, -1));
lua_pop(L, lua_gettop(L) - bp);
@@ -678,6 +678,7 @@ PHP_METHOD(lua, eval) {
lua_State *L = NULL;
char *statements = NULL;
long bp, len = 0;
+ int ret;
L = Z_LUAVAL_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &statements, &len) == FAILURE) {
@@ -685,9 +686,8 @@ PHP_METHOD(lua, eval) {
}
bp = lua_gettop(L);
- if (luaL_loadbuffer(L, statements, len, "line") || lua_pcall(L, 0, LUA_MULTRET, 0)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,
- "lua error: %s", lua_tostring(L, -1));
+ if ((ret = luaL_loadbuffer(L, statements, len, "line")) != LUA_OK || (ret = lua_pcall(L, 0, LUA_MULTRET, 0) != LUA_OK)) {
+ zend_throw_exception_ex(lua_exception_ce, ret TSRMLS_CC, "%s", lua_tostring(L, -1));
lua_pop(L, 1);
RETURN_FALSE;
} else {
@@ -718,6 +718,7 @@ PHP_METHOD(lua, include) {
lua_State *L = NULL;
char *file = NULL;
long bp, len = 0;
+ int ret;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &len) == FAILURE) {
return;
@@ -728,16 +729,15 @@ PHP_METHOD(lua, include) {
|| (PG(safe_mode)
&& !php_checkuid(file, "rb+", CHECKUID_CHECK_MODE_PARAM))
#endif
- ){
+ ) {
RETURN_FALSE;
}
L = Z_LUAVAL_P(getThis());
bp = lua_gettop(L);
- if (luaL_dofile(L, file)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,
- "lua error: %s", lua_tostring(L, -1));
+ if ((ret = luaL_loadfile(L, file)) != LUA_OK || (ret = lua_pcall(L, 0, LUA_MULTRET, 0) != LUA_OK)) {
+ zend_throw_exception_ex(lua_exception_ce, ret TSRMLS_CC, "%s", lua_tostring(L, -1));
lua_pop(L, 1);
RETURN_FALSE;
} else {
@@ -887,6 +887,16 @@ PHP_MINIT_FUNCTION(lua) {
INIT_CLASS_ENTRY(ce, "Lua", lua_class_methods);
+ REGISTER_LONG_CONSTANT("LUA_OK", LUA_OK, CONST_PERSISTENT | CONST_CS);
+ REGISTER_LONG_CONSTANT("LUA_YIELD", LUA_YIELD, CONST_PERSISTENT | CONST_CS);
+ REGISTER_LONG_CONSTANT("LUA_ERRRUN", LUA_ERRRUN, CONST_PERSISTENT | CONST_CS);
+ REGISTER_LONG_CONSTANT("LUA_ERRSYNTAX", LUA_ERRSYNTAX, CONST_PERSISTENT | CONST_CS);
+ REGISTER_LONG_CONSTANT("LUA_ERRMEM", LUA_ERRMEM, CONST_PERSISTENT | CONST_CS);
+ REGISTER_LONG_CONSTANT("LUA_ERRGCMM", LUA_ERRGCMM, CONST_PERSISTENT | CONST_CS);
+ REGISTER_LONG_CONSTANT("LUA_ERRERR", LUA_ERRERR, CONST_PERSISTENT | CONST_CS);
+ REGISTER_LONG_CONSTANT("LUA_ERRFILE", LUA_ERRFILE, CONST_PERSISTENT | CONST_CS);
+
+
lua_ce = zend_register_internal_class(&ce TSRMLS_CC);
lua_ce->create_object = php_lua_create_object;
memcpy(&lua_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
diff --git a/package.xml b/package.xml
index 58becc8..06f984a 100644
--- a/package.xml
+++ b/package.xml
@@ -58,6 +58,7 @@
+
diff --git a/package2.xml b/package2.xml
index 006b240..426cd75 100644
--- a/package2.xml
+++ b/package2.xml
@@ -26,8 +26,8 @@
2013-10-23
- 0.9.5
- 0.9.5
+ 1.1.0
+ 1.1.0beta
@@ -49,6 +49,7 @@
+
@@ -82,8 +83,8 @@
2012-10-23
- 0.9.5
- 0.9.5
+ 1.1.0
+ 1.1.0beta
@@ -97,6 +98,21 @@
+
+ 2012-06-24
+
+ 1.0.0
+ 1.0.0
+
+
+ stable
+ stable
+
+ PHP License
+
+ - Release stable version
+
+ 2012-03-19
diff --git a/php_lua.h b/php_lua.h
index 672f09f..68d0bbf 100644
--- a/php_lua.h
+++ b/php_lua.h
@@ -49,7 +49,7 @@ extern zend_module_entry lua_module_entry;
#define Z_DELREF_P ZVAL_DELREF
#endif
-#define PHP_LUA_VERSION "0.9.6-dev"
+#define PHP_LUA_VERSION "1.1.0"
#define Z_LUAVAL_P(obj) ((php_lua_object*)(zend_object_store_get_object(obj TSRMLS_CC)))->L
struct _php_lua_object {
diff --git a/tests/001.phpt b/tests/001.phpt
index 1fa28c1..89e89b4 100644
--- a/tests/001.phpt
+++ b/tests/001.phpt
@@ -9,8 +9,13 @@ $l->assign("b", 12);
$l->eval("print(b)");
$l->eval('print("\n")');
$l->eval("print(math.sin(b))");
-$l->eval("invalid code");
+try {
+ $l->eval("invalid code");
+} catch (LuaException $e) {
+ assert($e->getCode() == LUA_ERRSYNTAX);
+ echo "\n", $e->getMessage();
+}
--EXPECTF--
12
-0.53657291800043
-Warning: Lua::eval(): lua error: [string "line"]:1: %s near 'code' in %s on line %d
+[string "line"]:1: syntax error near 'code'
diff --git a/tests/006.phpt b/tests/006.phpt
index ecb3dd9..fde0aec 100644
--- a/tests/006.phpt
+++ b/tests/006.phpt
@@ -17,19 +17,22 @@ $l = new lua();
foreach ($code as $n => $c) {
echo "\nTesting $n\n";
file_put_contents($filename, $c);
- $ret = $l->include($filename);
- if ($ret) print_r($ret);
+ try {
+ $ret = $l->include($filename);
+ if ($ret) print_r($ret);
+ } catch (LuaException $e) {
+ assert($e->getCode() == LUA_ERRSYNTAX);
+ echo "\n".$e->getMessage();
+ }
@unlink($filename);
}
?>
--EXPECTF--
-
Testing fine
Hello PHP
Testing broken
-Warning: Lua::include(): lua error: %s near 'fdrg' in %s on line %d
-
+%s:%d: syntax error near 'fdrg'
Testing return
Array
(
diff --git a/tests/012.phpt b/tests/012.phpt
index 95030df..b7b43d4 100644
--- a/tests/012.phpt
+++ b/tests/012.phpt
@@ -1,11 +1,18 @@
--TEST--
-Check for index 0
+Lua::include() with error codes
--SKIPIF--
--FILE--
assign("b", range(1, 0));
+try {
+ $ret = $l->include($filename);
+} catch (LuaException $e) {
+ assert($e->getCode() == LUA_ERRFILE);
+ echo "\n".$e->getMessage();
+}
?>
--EXPECTF--
-Strict Standards: Lua::assign(): attempt to pass an array index begin with 0 to lua in %s012.php on line %d
+cannot open %s012.php.tmp: No such file or directory