mirror of
https://github.com/phpv8/v8js.git
synced 2024-12-22 08:11:52 +00:00
Add StartColumn/EndColumn properties to script exception, closes #126
This commit is contained in:
parent
687459ba7c
commit
65148db31f
@ -136,12 +136,16 @@ PHP API
|
|||||||
/* Properties */
|
/* Properties */
|
||||||
protected string JsFileName = NULL;
|
protected string JsFileName = NULL;
|
||||||
protected int JsLineNumber = NULL;
|
protected int JsLineNumber = NULL;
|
||||||
|
protected int JsStartColumn = NULL;
|
||||||
|
protected int JsEndColumn = NULL;
|
||||||
protected string JsSourceLine = NULL;
|
protected string JsSourceLine = NULL;
|
||||||
protected string JsTrace = NULL;
|
protected string JsTrace = NULL;
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
final public string getJsFileName( )
|
final public string getJsFileName( )
|
||||||
final public int getJsLineNumber( )
|
final public int getJsLineNumber( )
|
||||||
|
final public int getJsStartColumn( )
|
||||||
|
final public int getJsEndColumn( )
|
||||||
final public string getJsSourceLine( )
|
final public string getJsSourceLine( )
|
||||||
final public string getJsTrace( )
|
final public string getJsTrace( )
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ try {
|
|||||||
?>
|
?>
|
||||||
===EOF===
|
===EOF===
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
object(V8JsScriptException)#%d (11) {
|
object(V8JsScriptException)#%d (13) {
|
||||||
["message":protected]=>
|
["message":protected]=>
|
||||||
string(75) "exception.js:1: ReferenceError: this_function_does_not_exist is not defined"
|
string(75) "exception.js:1: ReferenceError: this_function_does_not_exist is not defined"
|
||||||
["string":"Exception":private]=>
|
["string":"Exception":private]=>
|
||||||
@ -59,6 +59,10 @@ object(V8JsScriptException)#%d (11) {
|
|||||||
string(12) "exception.js"
|
string(12) "exception.js"
|
||||||
["JsLineNumber":protected]=>
|
["JsLineNumber":protected]=>
|
||||||
int(1)
|
int(1)
|
||||||
|
["JsStartColumn":protected]=>
|
||||||
|
int(0)
|
||||||
|
["JsEndColumn":protected]=>
|
||||||
|
int(1)
|
||||||
["JsSourceLine":protected]=>
|
["JsSourceLine":protected]=>
|
||||||
string(31) "this_function_does_not_exist();"
|
string(31) "this_function_does_not_exist();"
|
||||||
["JsTrace":protected]=>
|
["JsTrace":protected]=>
|
||||||
|
@ -33,7 +33,7 @@ try {
|
|||||||
?>
|
?>
|
||||||
===EOF===
|
===EOF===
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
object(V8JsScriptException)#%d (11) {
|
object(V8JsScriptException)#%d (13) {
|
||||||
["message":protected]=>
|
["message":protected]=>
|
||||||
string(49) "throw_0:1: ReferenceError: fooobar is not defined"
|
string(49) "throw_0:1: ReferenceError: fooobar is not defined"
|
||||||
["string":"Exception":private]=>
|
["string":"Exception":private]=>
|
||||||
@ -89,6 +89,10 @@ object(V8JsScriptException)#%d (11) {
|
|||||||
string(7) "throw_0"
|
string(7) "throw_0"
|
||||||
["JsLineNumber":protected]=>
|
["JsLineNumber":protected]=>
|
||||||
int(1)
|
int(1)
|
||||||
|
["JsStartColumn":protected]=>
|
||||||
|
int(0)
|
||||||
|
["JsEndColumn":protected]=>
|
||||||
|
int(1)
|
||||||
["JsSourceLine":protected]=>
|
["JsSourceLine":protected]=>
|
||||||
string(7) "fooobar"
|
string(7) "fooobar"
|
||||||
["JsTrace":protected]=>
|
["JsTrace":protected]=>
|
||||||
|
20
tests/exception_start_column.phpt
Normal file
20
tests/exception_start_column.phpt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
--TEST--
|
||||||
|
Test V8::executeString() : Test getJsStartColumn on script exception
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$v8 = new V8Js();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$v8->executeString("print(blar());");
|
||||||
|
}
|
||||||
|
catch(V8JsScriptException $e) {
|
||||||
|
var_dump($e->getJsStartColumn());
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
===EOF===
|
||||||
|
--EXPECT--
|
||||||
|
int(6)
|
||||||
|
===EOF===
|
@ -42,7 +42,7 @@ try {
|
|||||||
ctor called (php)
|
ctor called (php)
|
||||||
Hello John
|
Hello John
|
||||||
caught js exception
|
caught js exception
|
||||||
object(V8JsScriptException)#%d (11) {
|
object(V8JsScriptException)#%d (13) {
|
||||||
["message":protected]=>
|
["message":protected]=>
|
||||||
string(56) "ctor-test:4: Call to protected __construct() not allowed"
|
string(56) "ctor-test:4: Call to protected __construct() not allowed"
|
||||||
["string":"Exception":private]=>
|
["string":"Exception":private]=>
|
||||||
@ -87,6 +87,10 @@ object(V8JsScriptException)#%d (11) {
|
|||||||
string(9) "ctor-test"
|
string(9) "ctor-test"
|
||||||
["JsLineNumber":protected]=>
|
["JsLineNumber":protected]=>
|
||||||
int(4)
|
int(4)
|
||||||
|
["JsStartColumn":protected]=>
|
||||||
|
int(18)
|
||||||
|
["JsEndColumn":protected]=>
|
||||||
|
int(19)
|
||||||
["JsSourceLine":protected]=>
|
["JsSourceLine":protected]=>
|
||||||
string(55) " var ngGreeter = new PHP.greeter.constructor("Ringo");"
|
string(55) " var ngGreeter = new PHP.greeter.constructor("Ringo");"
|
||||||
["JsTrace":protected]=>
|
["JsTrace":protected]=>
|
||||||
|
26
v8js.cc
26
v8js.cc
@ -1791,7 +1791,7 @@ static void php_v8js_create_script_exception(zval *return_value, v8::TryCatch *t
|
|||||||
v8::Handle<v8::Message> tc_message = try_catch->Message();
|
v8::Handle<v8::Message> tc_message = try_catch->Message();
|
||||||
const char *filename_string, *sourceline_string;
|
const char *filename_string, *sourceline_string;
|
||||||
char *message_string;
|
char *message_string;
|
||||||
int linenum, message_len;
|
int linenum, start_col, end_col, message_len;
|
||||||
|
|
||||||
object_init_ex(return_value, php_ce_v8js_script_exception);
|
object_init_ex(return_value, php_ce_v8js_script_exception);
|
||||||
|
|
||||||
@ -1814,6 +1814,12 @@ static void php_v8js_create_script_exception(zval *return_value, v8::TryCatch *t
|
|||||||
linenum = tc_message->GetLineNumber();
|
linenum = tc_message->GetLineNumber();
|
||||||
PHPV8_EXPROP(_long, JsLineNumber, linenum);
|
PHPV8_EXPROP(_long, JsLineNumber, linenum);
|
||||||
|
|
||||||
|
start_col = tc_message->GetStartColumn();
|
||||||
|
PHPV8_EXPROP(_long, JsStartColumn, start_col);
|
||||||
|
|
||||||
|
end_col = tc_message->GetEndColumn();
|
||||||
|
PHPV8_EXPROP(_long, JsEndColumn, end_col);
|
||||||
|
|
||||||
message_len = spprintf(&message_string, 0, "%s:%d: %s", filename_string, linenum, exception_string);
|
message_len = spprintf(&message_string, 0, "%s:%d: %s", filename_string, linenum, exception_string);
|
||||||
|
|
||||||
v8::String::Utf8Value stacktrace(try_catch->StackTrace());
|
v8::String::Utf8Value stacktrace(try_catch->StackTrace());
|
||||||
@ -1869,6 +1875,16 @@ V8JS_EXCEPTION_METHOD(JsFileName);
|
|||||||
V8JS_EXCEPTION_METHOD(JsLineNumber);
|
V8JS_EXCEPTION_METHOD(JsLineNumber);
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
/* {{{ proto string V8JsScriptException::getJsStartColumn()
|
||||||
|
*/
|
||||||
|
V8JS_EXCEPTION_METHOD(JsStartColumn);
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
/* {{{ proto string V8JsScriptException::getJsEndColumn()
|
||||||
|
*/
|
||||||
|
V8JS_EXCEPTION_METHOD(JsEndColumn);
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ proto string V8JsScriptException::getJsSourceLine()
|
/* {{{ proto string V8JsScriptException::getJsSourceLine()
|
||||||
*/
|
*/
|
||||||
V8JS_EXCEPTION_METHOD(JsSourceLine);
|
V8JS_EXCEPTION_METHOD(JsSourceLine);
|
||||||
@ -1882,6 +1898,8 @@ V8JS_EXCEPTION_METHOD(JsTrace);
|
|||||||
static const zend_function_entry v8js_script_exception_methods[] = { /* {{{ */
|
static const zend_function_entry v8js_script_exception_methods[] = { /* {{{ */
|
||||||
PHP_ME(V8JsScriptException, getJsFileName, arginfo_v8jsscriptexception_no_args, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
|
PHP_ME(V8JsScriptException, getJsFileName, arginfo_v8jsscriptexception_no_args, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
|
||||||
PHP_ME(V8JsScriptException, getJsLineNumber, arginfo_v8jsscriptexception_no_args, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
|
PHP_ME(V8JsScriptException, getJsLineNumber, arginfo_v8jsscriptexception_no_args, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
|
||||||
|
PHP_ME(V8JsScriptException, getJsStartColumn, arginfo_v8jsscriptexception_no_args, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
|
||||||
|
PHP_ME(V8JsScriptException, getJsEndColumn, arginfo_v8jsscriptexception_no_args, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
|
||||||
PHP_ME(V8JsScriptException, getJsSourceLine, arginfo_v8jsscriptexception_no_args, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
|
PHP_ME(V8JsScriptException, getJsSourceLine, arginfo_v8jsscriptexception_no_args, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
|
||||||
PHP_ME(V8JsScriptException, getJsTrace, arginfo_v8jsscriptexception_no_args, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
|
PHP_ME(V8JsScriptException, getJsTrace, arginfo_v8jsscriptexception_no_args, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
|
||||||
{NULL, NULL, NULL}
|
{NULL, NULL, NULL}
|
||||||
@ -1973,8 +1991,10 @@ static PHP_MINIT_FUNCTION(v8js)
|
|||||||
|
|
||||||
/* Add custom JS specific properties */
|
/* Add custom JS specific properties */
|
||||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsFileName"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsFileName"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
||||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsLineNumber"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsLineNumber"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
||||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsSourceLine"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsStartColumn"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
||||||
|
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsEndColumn"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
||||||
|
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsSourceLine"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
||||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsTrace"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsTrace"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
||||||
|
|
||||||
/* V8JsTimeLimitException Class */
|
/* V8JsTimeLimitException Class */
|
||||||
|
Loading…
Reference in New Issue
Block a user