diff --git a/v8js.cc b/v8js.cc index 21fedcf..8d9ce86 100644 --- a/v8js.cc +++ b/v8js.cc @@ -1377,29 +1377,21 @@ static PHP_METHOD(V8Js, checkString) { char *str = NULL; 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) { return; } - V8JS_BEGIN_CTX(c, getThis()) - - /* Catch JS exceptions */ - v8::TryCatch try_catch; - - /* Set script identifier */ - v8::Local 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 source = V8JS_STRL(str, str_len); - v8::Local script = v8::Script::Compile(source, sname); - - /* Compile errors? */ - if (script.IsEmpty()) { - php_v8js_throw_script_exception(&try_catch TSRMLS_CC); - return; + php_v8js_compile_script(getThis(), str, str_len, identifier, identifier_len, &res); + if (!res) { + RETURN_FALSE; } + + php_v8js_script_free(res, true); RETURN_TRUE; } /* }}} */