v8js_class.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_CLASS_H
  14. #define V8JS_CLASS_H
  15. /* Abbreviate long type names */
  16. typedef v8::Persistent<v8::FunctionTemplate, v8::CopyablePersistentTraits<v8::FunctionTemplate> > v8js_tmpl_t;
  17. typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > v8js_persistent_obj_t;
  18. /* Forward declarations */
  19. struct v8js_v8object;
  20. struct v8js_accessor_ctx;
  21. struct _v8js_script;
  22. struct cmp_str {
  23. bool operator()(char const *a, char const *b) const {
  24. return strcmp(a, b) < 0;
  25. }
  26. };
  27. /* {{{ Context container */
  28. struct v8js_ctx {
  29. zend_object std;
  30. v8::Persistent<v8::String> object_name;
  31. v8::Persistent<v8::Context> context;
  32. zend_bool report_uncaught;
  33. zval *pending_exception;
  34. int in_execution;
  35. v8::Isolate *isolate;
  36. long flags;
  37. long time_limit;
  38. bool time_limit_hit;
  39. long memory_limit;
  40. bool memory_limit_hit;
  41. v8js_tmpl_t global_template;
  42. v8js_tmpl_t array_tmpl;
  43. zval *module_normaliser;
  44. zval *module_loader;
  45. std::vector<char *> modules_stack;
  46. std::vector<char *> modules_base;
  47. std::map<char *, v8js_persistent_obj_t, cmp_str> modules_loaded;
  48. std::map<const char *,v8js_tmpl_t> template_cache;
  49. std::map<zval *, v8js_persistent_obj_t> weak_objects;
  50. std::map<v8js_tmpl_t *, v8js_persistent_obj_t> weak_closures;
  51. std::map<v8js_tmpl_t *, v8js_tmpl_t> call_impls;
  52. std::map<zend_function *, v8js_tmpl_t> method_tmpls;
  53. std::list<v8js_v8object *> v8js_v8objects;
  54. std::vector<v8js_accessor_ctx *> accessor_list;
  55. std::vector<struct _v8js_script *> script_objects;
  56. char *tz;
  57. #ifdef ZTS
  58. void ***zts_ctx;
  59. #endif
  60. };
  61. /* }}} */
  62. #ifdef ZTS
  63. # define V8JS_TSRMLS_FETCH() TSRMLS_FETCH_FROM_CTX(((v8js_ctx *) isolate->GetData(0))->zts_ctx);
  64. #else
  65. # define V8JS_TSRMLS_FETCH()
  66. #endif
  67. PHP_MINIT_FUNCTION(v8js_class);
  68. #endif /* V8JS_CLASS_H */
  69. /*
  70. * Local variables:
  71. * tab-width: 4
  72. * c-basic-offset: 4
  73. * End:
  74. * vim600: noet sw=4 ts=4 fdm=marker
  75. * vim<600: noet sw=4 ts=4
  76. */