浏览代码

conditionally compile in snapshot functionality

Stefan Siegl 9 年之前
父节点
当前提交
2c8ef2aa66
共有 1 个文件被更改,包括 14 次插入3 次删除
  1. 14 3
      v8js_class.cc

+ 14 - 3
v8js_class.cc

@@ -207,9 +207,11 @@ static void v8js_free_storage(void *object TSRMLS_DC) /* {{{ */
 	c->modules_stack.~vector();
 	c->modules_base.~vector();
 
+#ifdef PHP_V8_USE_EXTERNAL_STARTUP_DATA
 	if (c->snapshot_blob.data) {
 		efree((void*)c->snapshot_blob.data);
 	}
+#endif
 
 	efree(object);
 }
@@ -368,14 +370,16 @@ static PHP_METHOD(V8Js, __construct)
 	c->create_params.array_buffer_allocator = &array_buffer_allocator;
 
 	new (&c->snapshot_blob) v8::StartupData();
+#ifdef PHP_V8_USE_EXTERNAL_STARTUP_DATA
 	if (snapshot_blob && snapshot_blob_len) {
 		c->snapshot_blob.data = snapshot_blob;
 		c->snapshot_blob.raw_size = snapshot_blob_len;
 		c->create_params.snapshot_blob = &c->snapshot_blob;
 	}
+#endif /* PHP_V8_USE_EXTERNAL_STARTUP_DATA */
 
 	c->isolate = v8::Isolate::New(c->create_params);
-#else
+#else /* PHP_V8_API_VERSION < 4004044 */
 	c->isolate = v8::Isolate::New();
 #endif
 
@@ -1077,6 +1081,7 @@ static PHP_METHOD(V8Js, getExtensions)
 }
 /* }}} */
 
+#ifdef PHP_V8_USE_EXTERNAL_STARTUP_DATA
 /* {{{ proto string|bool V8Js::createSnapshot(string embed_source)
  */
 static PHP_METHOD(V8Js, createSnapshot)
@@ -1107,6 +1112,8 @@ static PHP_METHOD(V8Js, createSnapshot)
 	delete[] snapshot_blob.data;
 }
 /* }}} */
+#endif  /* PHP_V8_USE_EXTERNAL_STARTUP_DATA */
+
 
 /* {{{ arginfo */
 ZEND_BEGIN_ARG_INFO_EX(arginfo_v8js_construct, 0, 0, 0)
@@ -1171,9 +1178,11 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_INFO(arginfo_v8js_getextensions, 0)
 ZEND_END_ARG_INFO()
 
+#ifdef PHP_V8_USE_EXTERNAL_STARTUP_DATA
 ZEND_BEGIN_ARG_INFO_EX(arginfo_v8js_createsnapshot, 0, 0, 1)
 	ZEND_ARG_INFO(0, script)
 ZEND_END_ARG_INFO()
+#endif
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_v8js_settimelimit, 0, 0, 1)
 	ZEND_ARG_INFO(0, time_limit)
@@ -1196,11 +1205,13 @@ const zend_function_entry v8js_methods[] = { /* {{{ */
 	PHP_ME(V8Js,	clearPendingException,	arginfo_v8js_clearpendingexception,	ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,	setModuleNormaliser,	arginfo_v8js_setmodulenormaliser,	ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,	setModuleLoader,		arginfo_v8js_setmoduleloader,		ZEND_ACC_PUBLIC)
+	PHP_ME(V8Js,	setTimeLimit,			arginfo_v8js_settimelimit,			ZEND_ACC_PUBLIC)
+	PHP_ME(V8Js,	setMemoryLimit,			arginfo_v8js_setmemorylimit,		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)
+#ifdef PHP_V8_USE_EXTERNAL_STARTUP_DATA
 	PHP_ME(V8Js,	createSnapshot,			arginfo_v8js_createsnapshot,		ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-	PHP_ME(V8Js,	setTimeLimit,			arginfo_v8js_settimelimit,			ZEND_ACC_PUBLIC)
-	PHP_ME(V8Js,	setMemoryLimit,			arginfo_v8js_setmemorylimit,		ZEND_ACC_PUBLIC)
+#endif
 	{NULL, NULL, NULL}
 };
 /* }}} */