v8js_v8.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2013 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | http://www.opensource.org/licenses/mit-license.php MIT License |
  8. +----------------------------------------------------------------------+
  9. | Author: Jani Taskinen <[email protected]> |
  10. | Author: Patrick Reilly <[email protected]> |
  11. +----------------------------------------------------------------------+
  12. */
  13. #ifndef V8JS_V8_H
  14. #define V8JS_V8_H
  15. void v8js_v8_init(TSRMLS_D);
  16. void v8js_v8_call(php_v8js_ctx *c, zval **return_value,
  17. long flags, long time_limit, long memory_limit,
  18. std::function< v8::Local<v8::Value>(v8::Isolate *) >& v8_call TSRMLS_DC);
  19. void v8js_terminate_execution(php_v8js_ctx *c TSRMLS_DC);
  20. #define V8JS_CTX_PROLOGUE(ctx) \
  21. if (!V8JSG(v8_initialized)) { \
  22. zend_error(E_ERROR, "V8 not initialized"); \
  23. return; \
  24. } \
  25. \
  26. v8::Isolate *isolate = (ctx)->isolate; \
  27. v8::Locker locker(isolate); \
  28. v8::Isolate::Scope isolate_scope(isolate); \
  29. v8::HandleScope handle_scope(isolate); \
  30. v8::Local<v8::Context> v8_context = v8::Local<v8::Context>::New(isolate, (ctx)->context); \
  31. v8::Context::Scope context_scope(v8_context);
  32. #define V8JS_BEGIN_CTX(ctx, object) \
  33. php_v8js_ctx *(ctx); \
  34. (ctx) = (php_v8js_ctx *) zend_object_store_get_object(object TSRMLS_CC); \
  35. V8JS_CTX_PROLOGUE(ctx);
  36. #endif /* V8JS_V8_H */
  37. /*
  38. * Local variables:
  39. * tab-width: 4
  40. * c-basic-offset: 4
  41. * End:
  42. * vim600: noet sw=4 ts=4 fdm=marker
  43. * vim<600: noet sw=4 ts=4
  44. */