v8js_class.h 2.7 KB

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