v8js_class.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. v8::Persistent<v8::String> object_name;
  30. v8::Persistent<v8::Context> context;
  31. zend_bool report_uncaught;
  32. zval pending_exception;
  33. int in_execution;
  34. v8::Isolate *isolate;
  35. long flags;
  36. long time_limit;
  37. bool time_limit_hit;
  38. long memory_limit;
  39. bool memory_limit_hit;
  40. v8js_tmpl_t global_template;
  41. v8js_tmpl_t array_tmpl;
  42. zval module_loader;
  43. std::vector<char *> modules_stack;
  44. std::vector<char *> modules_base;
  45. std::map<char *, v8js_persistent_obj_t, cmp_str> modules_loaded;
  46. std::map<const zend_string *,v8js_tmpl_t> template_cache;
  47. std::map<zend_object *, v8js_persistent_obj_t> weak_objects;
  48. std::map<v8js_tmpl_t *, v8js_persistent_obj_t> weak_closures;
  49. std::map<v8js_tmpl_t *, v8js_tmpl_t> call_impls;
  50. std::map<zend_function *, v8js_tmpl_t> method_tmpls;
  51. std::list<v8js_v8object *> v8js_v8objects;
  52. std::vector<v8js_accessor_ctx *> accessor_list;
  53. std::vector<struct _v8js_script *> script_objects;
  54. char *tz;
  55. #ifdef ZTS
  56. void ***zts_ctx;
  57. #endif
  58. zend_object std;
  59. };
  60. /* }}} */
  61. #ifdef ZTS
  62. # define V8JS_TSRMLS_FETCH() TSRMLS_FETCH_FROM_CTX(((v8js_ctx *) isolate->GetData(0))->zts_ctx);
  63. #else
  64. # define V8JS_TSRMLS_FETCH()
  65. #endif
  66. static inline struct v8js_ctx *v8js_ctx_fetch_object(zend_object *obj) {
  67. return (struct v8js_ctx *)((char *)obj - XtOffsetOf(struct v8js_ctx, std));
  68. }
  69. #define Z_V8JS_CTX_OBJ_P(zv) v8js_ctx_fetch_object(Z_OBJ_P(zv));
  70. PHP_MINIT_FUNCTION(v8js_class);
  71. #endif /* V8JS_CLASS_H */
  72. /*
  73. * Local variables:
  74. * tab-width: 4
  75. * c-basic-offset: 4
  76. * End:
  77. * vim600: noet sw=4 ts=4 fdm=marker
  78. * vim<600: noet sw=4 ts=4
  79. */