mirror of
https://github.com/phpv8/v8js.git
synced 2024-12-22 23:51:51 +00:00
Use php_v8js_compile_script for checkString.
This commit is contained in:
parent
9cb3711c66
commit
11f7311ab8
26
v8js.cc
26
v8js.cc
@ -1377,29 +1377,21 @@ static PHP_METHOD(V8Js, checkString)
|
|||||||
{
|
{
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
int str_len = 0;
|
int str_len = 0;
|
||||||
long flags = V8JS_FLAG_NONE, time_limit = 0, memory_limit = 0;
|
const char *identifier = "V8Js::checkString()";
|
||||||
|
int identifier_len = 19;
|
||||||
|
|
||||||
|
php_v8js_script *res = NULL;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
V8JS_BEGIN_CTX(c, getThis())
|
php_v8js_compile_script(getThis(), str, str_len, identifier, identifier_len, &res);
|
||||||
|
if (!res) {
|
||||||
/* Catch JS exceptions */
|
RETURN_FALSE;
|
||||||
v8::TryCatch try_catch;
|
|
||||||
|
|
||||||
/* Set script identifier */
|
|
||||||
v8::Local<v8::String> sname = V8JS_SYM("V8Js::checkString()");
|
|
||||||
|
|
||||||
/* Compiles a string context independently. TODO: Add a php function which calls this and returns the result as resource which can be executed later. */
|
|
||||||
v8::Local<v8::String> source = V8JS_STRL(str, str_len);
|
|
||||||
v8::Local<v8::Script> script = v8::Script::Compile(source, sname);
|
|
||||||
|
|
||||||
/* Compile errors? */
|
|
||||||
if (script.IsEmpty()) {
|
|
||||||
php_v8js_throw_script_exception(&try_catch TSRMLS_CC);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
php_v8js_script_free(res, true);
|
||||||
RETURN_TRUE;
|
RETURN_TRUE;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
Loading…
Reference in New Issue
Block a user