mirror of
https://github.com/phpv8/v8js.git
synced 2024-11-09 23:08:41 +00:00
Merge branch 'clear-exception'
This commit is contained in:
commit
b77ba3773c
@ -117,6 +117,9 @@ PHP API
|
||||
// Returns uncaught pending exception or null if there is no pending exception.
|
||||
public V8JsScriptException V8Js::getPendingException( )
|
||||
|
||||
// Clears the uncaught pending exception
|
||||
public clearPendingException( )
|
||||
|
||||
// Starts V8 debug agent for use with Google Chrome Developer Tools (Eclipse Plugin)
|
||||
public bool startDebugAgent( [ string $agent_name = "V8Js" [, $port = 9222 [, $auto_break = V8Js::DEBUG_AUTO_BREAK_NEVER ] ] ] )
|
||||
|
||||
|
73
tests/exception_clearing.phpt
Normal file
73
tests/exception_clearing.phpt
Normal file
@ -0,0 +1,73 @@
|
||||
--TEST--
|
||||
Test V8::executeString() : Exception clearing test
|
||||
--SKIPIF--
|
||||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$v8 = new V8Js(null, array(), array(), false);
|
||||
|
||||
var_dump($v8->getPendingException());
|
||||
|
||||
$v8->clearPendingException();
|
||||
var_dump($v8->getPendingException());
|
||||
|
||||
$v8->executeString('fooobar', 'throw_0');
|
||||
var_dump($v8->getPendingException());
|
||||
|
||||
$v8->clearPendingException();
|
||||
var_dump($v8->getPendingException());
|
||||
|
||||
?>
|
||||
===EOF===
|
||||
--EXPECTF--
|
||||
NULL
|
||||
NULL
|
||||
object(V8JsScriptException)#%d (11) {
|
||||
["message":protected]=>
|
||||
string(49) "throw_0:1: ReferenceError: fooobar is not defined"
|
||||
["string":"Exception":private]=>
|
||||
string(0) ""
|
||||
["code":protected]=>
|
||||
int(0)
|
||||
["file":protected]=>
|
||||
string(%d) "%s"
|
||||
["line":protected]=>
|
||||
int(10)
|
||||
["trace":"Exception":private]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(6) {
|
||||
["file"]=>
|
||||
string(%d) "%s"
|
||||
["line"]=>
|
||||
int(10)
|
||||
["function"]=>
|
||||
string(13) "executeString"
|
||||
["class"]=>
|
||||
string(4) "V8Js"
|
||||
["type"]=>
|
||||
string(2) "->"
|
||||
["args"]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(7) "fooobar"
|
||||
[1]=>
|
||||
string(7) "throw_0"
|
||||
}
|
||||
}
|
||||
}
|
||||
["previous":"Exception":private]=>
|
||||
NULL
|
||||
["JsFileName":protected]=>
|
||||
string(7) "throw_0"
|
||||
["JsLineNumber":protected]=>
|
||||
int(1)
|
||||
["JsSourceLine":protected]=>
|
||||
string(7) "fooobar"
|
||||
["JsTrace":protected]=>
|
||||
string(57) "ReferenceError: fooobar is not defined
|
||||
at throw_0:1:1"
|
||||
}
|
||||
NULL
|
||||
===EOF===
|
23
v8js.cc
23
v8js.cc
@ -1466,6 +1466,25 @@ static PHP_METHOD(V8Js, getPendingException)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto void V8Js::clearPendingException()
|
||||
*/
|
||||
static PHP_METHOD(V8Js, clearPendingException)
|
||||
{
|
||||
php_v8js_ctx *c;
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
c = (php_v8js_ctx *) zend_object_store_get_object(getThis() TSRMLS_CC);
|
||||
|
||||
if (c->pending_exception) {
|
||||
zval_ptr_dtor(&c->pending_exception);
|
||||
c->pending_exception = NULL;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto void V8Js::setModuleLoader(string module)
|
||||
*/
|
||||
static PHP_METHOD(V8Js, setModuleLoader)
|
||||
@ -1694,6 +1713,9 @@ ZEND_END_ARG_INFO()
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_v8js_getpendingexception, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_v8js_clearpendingexception, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_v8js_setmoduleloader, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, callable)
|
||||
ZEND_END_ARG_INFO()
|
||||
@ -1731,6 +1753,7 @@ static const zend_function_entry v8js_methods[] = { /* {{{ */
|
||||
PHP_ME(V8Js, executeScript, arginfo_v8js_executescript, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(V8Js, checkString, arginfo_v8js_checkstring, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
|
||||
PHP_ME(V8Js, getPendingException, arginfo_v8js_getpendingexception, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(V8Js, clearPendingException, arginfo_v8js_clearpendingexception, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(V8Js, setModuleLoader, arginfo_v8js_setmoduleloader, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(V8Js, registerExtension, arginfo_v8js_registerextension, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
|
||||
PHP_ME(V8Js, getExtensions, arginfo_v8js_getextensions, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
|
||||
|
Loading…
Reference in New Issue
Block a user