Преглед на файлове

Use php_v8js_compile_script for checkString.

Stefan Siegl преди 10 години
родител
ревизия
11f7311ab8
променени са 1 файла, в които са добавени 9 реда и са изтрити 17 реда
  1. 9 17
      v8js.cc

+ 9 - 17
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<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_compile_script(getThis(), str, str_len, identifier, identifier_len, &res);
+	if (!res) {
+		RETURN_FALSE;
 	}
+
+	php_v8js_script_free(res, true);
 	RETURN_TRUE;
 }
 /* }}} */