0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-09-16 18:05:18 +00:00

Throw V8JsException if source is not a script

This commit is contained in:
Stefan Siegl 2014-12-11 18:05:37 +01:00
parent c28c9f50f1
commit 0ea210f94e
7 changed files with 19 additions and 19 deletions

View File

@ -46,7 +46,7 @@ object(V8Object)#%d (0) {
}
string(55) "Can't access V8Object after V8Js instance is destroyed!"
Warning: Uncaught exception 'V8JsScriptException' with message 'Can't access V8Object after V8Js instance is destroyed!' in %s%etests%ectx_lifetime.php:35
Warning: Uncaught exception 'V8JsException' with message 'Can't access V8Object after V8Js instance is destroyed!' in %s%etests%ectx_lifetime.php:35
Stack trace:
#0 %s%etests%ectx_lifetime.php(35): unknown()
#1 {main}

View File

@ -9,12 +9,12 @@ Test V8::executeString() : direct construction is prohibited
echo "-- NOT ALLOWED --\n";
try {
$a = new V8Object;
} catch (V8JsScriptException $e) {
} catch (V8JsException $e) {
var_dump($e->getMessage());
}
try {
$a = new V8Function;
} catch (V8JsScriptException $e) {
} catch (V8JsException $e) {
var_dump($e->getMessage());
}
@ -30,12 +30,12 @@ var_dump($f);
echo "-- NOT ALLOWED --\n";
try {
$oo = new $o();
} catch (V8JsScriptException $e) {
} catch (V8JsException $e) {
var_dump($e->getMessage());
}
try {
$ff = new $f;
} catch (V8JsScriptException $e) {
} catch (V8JsException $e) {
var_dump($e->getMessage());
}

View File

@ -26,7 +26,7 @@ unset($v8);
try {
var_dump(property_exists($foo->x, 'bla'));
}
catch(V8JsScriptException $e) {
catch(V8JsException $e) {
var_dump($e->getMessage());
}
?>

View File

@ -26,7 +26,7 @@ unset($v8);
try {
var_dump($foo->x);
}
catch(V8JsScriptException $e) {
catch(V8JsException $e) {
var_dump($e->getMessage());
}
?>

View File

@ -21,7 +21,7 @@ try {
// unset not valid, if $v8 object is disposed
unset($a->bla);
}
catch(V8JsScriptException $e) {
catch(V8JsException $e) {
var_dump($e->getMessage());
}
?>

View File

@ -21,7 +21,7 @@ try {
// writing not valid, if $v8 object is disposed
$a->bla = 5;
}
catch(V8JsScriptException $e) {
catch(V8JsException $e) {
var_dump($e->getMessage());
}
?>

20
v8js.cc
View File

@ -164,7 +164,7 @@ static int php_v8js_v8_has_property(zval *object, zval *member, int has_set_exis
php_v8js_object *obj = (php_v8js_object *) zend_object_store_get_object(object TSRMLS_CC);
if (!obj->ctx) {
zend_throw_exception(php_ce_v8js_script_exception,
zend_throw_exception(php_ce_v8js_exception,
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
return retval;
}
@ -229,7 +229,7 @@ static zval *php_v8js_v8_read_property(zval *object, zval *member, int type ZEND
php_v8js_object *obj = (php_v8js_object *) zend_object_store_get_object(object TSRMLS_CC);
if (!obj->ctx) {
zend_throw_exception(php_ce_v8js_script_exception,
zend_throw_exception(php_ce_v8js_exception,
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
ALLOC_INIT_ZVAL(retval);
return retval;
@ -279,7 +279,7 @@ static void php_v8js_v8_write_property(zval *object, zval *member, zval *value Z
php_v8js_object *obj = (php_v8js_object *) zend_object_store_get_object(object TSRMLS_CC);
if (!obj->ctx) {
zend_throw_exception(php_ce_v8js_script_exception,
zend_throw_exception(php_ce_v8js_exception,
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
return;
}
@ -304,7 +304,7 @@ static void php_v8js_v8_unset_property(zval *object, zval *member ZEND_HASH_KEY_
php_v8js_object *obj = (php_v8js_object *) zend_object_store_get_object(object TSRMLS_CC);
if (!obj->ctx) {
zend_throw_exception(php_ce_v8js_script_exception,
zend_throw_exception(php_ce_v8js_exception,
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
return;
}
@ -396,7 +396,7 @@ static HashTable *php_v8js_v8_get_properties(zval *object TSRMLS_DC) /* {{{ */
}
if (!obj->ctx) {
zend_throw_exception(php_ce_v8js_script_exception,
zend_throw_exception(php_ce_v8js_exception,
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
return NULL;
}
@ -430,7 +430,7 @@ static zend_function *php_v8js_v8_get_method(zval **object_ptr, char *method, in
zend_function *f;
if (!obj->ctx) {
zend_throw_exception(php_ce_v8js_script_exception,
zend_throw_exception(php_ce_v8js_exception,
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
return NULL;
}
@ -472,7 +472,7 @@ static int php_v8js_v8_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS) /
obj = (php_v8js_object *) zend_object_store_get_object(object TSRMLS_CC);
if (!obj->ctx) {
zend_throw_exception(php_ce_v8js_script_exception,
zend_throw_exception(php_ce_v8js_exception,
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
return FAILURE;
}
@ -529,7 +529,7 @@ static int php_v8js_v8_get_closure(zval *object, zend_class_entry **ce_ptr, zend
php_v8js_object *obj = (php_v8js_object *) zend_object_store_get_object(object TSRMLS_CC);
if (!obj->ctx) {
zend_throw_exception(php_ce_v8js_script_exception,
zend_throw_exception(php_ce_v8js_exception,
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
return FAILURE;
}
@ -609,7 +609,7 @@ static zend_object_value php_v8js_v8_new(zend_class_entry *ce TSRMLS_DC) /* {{{
*/
PHP_METHOD(V8Object,__construct)
{
zend_throw_exception(php_ce_v8js_script_exception,
zend_throw_exception(php_ce_v8js_exception,
"Can't directly construct V8 objects!", 0 TSRMLS_CC);
RETURN_FALSE;
}
@ -619,7 +619,7 @@ PHP_METHOD(V8Object,__construct)
*/
PHP_METHOD(V8Function,__construct)
{
zend_throw_exception(php_ce_v8js_script_exception,
zend_throw_exception(php_ce_v8js_exception,
"Can't directly construct V8 objects!", 0 TSRMLS_CC);
RETURN_FALSE;
}