mirror of
https://github.com/phpv8/v8js.git
synced 2024-12-22 14:01:53 +00:00
Throw V8JsException if source is not a script
This commit is contained in:
parent
c28c9f50f1
commit
0ea210f94e
@ -46,7 +46,7 @@ object(V8Object)#%d (0) {
|
|||||||
}
|
}
|
||||||
string(55) "Can't access V8Object after V8Js instance is destroyed!"
|
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:
|
Stack trace:
|
||||||
#0 %s%etests%ectx_lifetime.php(35): unknown()
|
#0 %s%etests%ectx_lifetime.php(35): unknown()
|
||||||
#1 {main}
|
#1 {main}
|
||||||
|
@ -9,12 +9,12 @@ Test V8::executeString() : direct construction is prohibited
|
|||||||
echo "-- NOT ALLOWED --\n";
|
echo "-- NOT ALLOWED --\n";
|
||||||
try {
|
try {
|
||||||
$a = new V8Object;
|
$a = new V8Object;
|
||||||
} catch (V8JsScriptException $e) {
|
} catch (V8JsException $e) {
|
||||||
var_dump($e->getMessage());
|
var_dump($e->getMessage());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$a = new V8Function;
|
$a = new V8Function;
|
||||||
} catch (V8JsScriptException $e) {
|
} catch (V8JsException $e) {
|
||||||
var_dump($e->getMessage());
|
var_dump($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,12 +30,12 @@ var_dump($f);
|
|||||||
echo "-- NOT ALLOWED --\n";
|
echo "-- NOT ALLOWED --\n";
|
||||||
try {
|
try {
|
||||||
$oo = new $o();
|
$oo = new $o();
|
||||||
} catch (V8JsScriptException $e) {
|
} catch (V8JsException $e) {
|
||||||
var_dump($e->getMessage());
|
var_dump($e->getMessage());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$ff = new $f;
|
$ff = new $f;
|
||||||
} catch (V8JsScriptException $e) {
|
} catch (V8JsException $e) {
|
||||||
var_dump($e->getMessage());
|
var_dump($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ unset($v8);
|
|||||||
try {
|
try {
|
||||||
var_dump(property_exists($foo->x, 'bla'));
|
var_dump(property_exists($foo->x, 'bla'));
|
||||||
}
|
}
|
||||||
catch(V8JsScriptException $e) {
|
catch(V8JsException $e) {
|
||||||
var_dump($e->getMessage());
|
var_dump($e->getMessage());
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -26,7 +26,7 @@ unset($v8);
|
|||||||
try {
|
try {
|
||||||
var_dump($foo->x);
|
var_dump($foo->x);
|
||||||
}
|
}
|
||||||
catch(V8JsScriptException $e) {
|
catch(V8JsException $e) {
|
||||||
var_dump($e->getMessage());
|
var_dump($e->getMessage());
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -21,7 +21,7 @@ try {
|
|||||||
// unset not valid, if $v8 object is disposed
|
// unset not valid, if $v8 object is disposed
|
||||||
unset($a->bla);
|
unset($a->bla);
|
||||||
}
|
}
|
||||||
catch(V8JsScriptException $e) {
|
catch(V8JsException $e) {
|
||||||
var_dump($e->getMessage());
|
var_dump($e->getMessage());
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -21,7 +21,7 @@ try {
|
|||||||
// writing not valid, if $v8 object is disposed
|
// writing not valid, if $v8 object is disposed
|
||||||
$a->bla = 5;
|
$a->bla = 5;
|
||||||
}
|
}
|
||||||
catch(V8JsScriptException $e) {
|
catch(V8JsException $e) {
|
||||||
var_dump($e->getMessage());
|
var_dump($e->getMessage());
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
20
v8js.cc
20
v8js.cc
@ -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);
|
php_v8js_object *obj = (php_v8js_object *) zend_object_store_get_object(object TSRMLS_CC);
|
||||||
|
|
||||||
if (!obj->ctx) {
|
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);
|
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||||
return retval;
|
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);
|
php_v8js_object *obj = (php_v8js_object *) zend_object_store_get_object(object TSRMLS_CC);
|
||||||
|
|
||||||
if (!obj->ctx) {
|
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);
|
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||||
ALLOC_INIT_ZVAL(retval);
|
ALLOC_INIT_ZVAL(retval);
|
||||||
return 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);
|
php_v8js_object *obj = (php_v8js_object *) zend_object_store_get_object(object TSRMLS_CC);
|
||||||
|
|
||||||
if (!obj->ctx) {
|
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);
|
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||||
return;
|
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);
|
php_v8js_object *obj = (php_v8js_object *) zend_object_store_get_object(object TSRMLS_CC);
|
||||||
|
|
||||||
if (!obj->ctx) {
|
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);
|
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -396,7 +396,7 @@ static HashTable *php_v8js_v8_get_properties(zval *object TSRMLS_DC) /* {{{ */
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!obj->ctx) {
|
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);
|
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -430,7 +430,7 @@ static zend_function *php_v8js_v8_get_method(zval **object_ptr, char *method, in
|
|||||||
zend_function *f;
|
zend_function *f;
|
||||||
|
|
||||||
if (!obj->ctx) {
|
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);
|
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||||
return NULL;
|
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);
|
obj = (php_v8js_object *) zend_object_store_get_object(object TSRMLS_CC);
|
||||||
|
|
||||||
if (!obj->ctx) {
|
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);
|
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||||
return FAILURE;
|
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);
|
php_v8js_object *obj = (php_v8js_object *) zend_object_store_get_object(object TSRMLS_CC);
|
||||||
|
|
||||||
if (!obj->ctx) {
|
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);
|
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
@ -609,7 +609,7 @@ static zend_object_value php_v8js_v8_new(zend_class_entry *ce TSRMLS_DC) /* {{{
|
|||||||
*/
|
*/
|
||||||
PHP_METHOD(V8Object,__construct)
|
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);
|
"Can't directly construct V8 objects!", 0 TSRMLS_CC);
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
@ -619,7 +619,7 @@ PHP_METHOD(V8Object,__construct)
|
|||||||
*/
|
*/
|
||||||
PHP_METHOD(V8Function,__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);
|
"Can't directly construct V8 objects!", 0 TSRMLS_CC);
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user