v8js_class.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 cmp_str {
  22. bool operator()(char const *a, char const *b) const {
  23. return strcmp(a, b) < 0;
  24. }
  25. };
  26. /* {{{ Context container */
  27. struct v8js_ctx {
  28. zend_object std;
  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 char *,v8js_tmpl_t> template_cache;
  45. std::map<zval *, 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. char *tz;
  50. #ifdef ZTS
  51. void ***zts_ctx;
  52. #endif
  53. };
  54. /* }}} */
  55. #ifdef ZTS
  56. # define V8JS_TSRMLS_FETCH() TSRMLS_FETCH_FROM_CTX(((v8js_ctx *) isolate->GetData(0))->zts_ctx);
  57. #else
  58. # define V8JS_TSRMLS_FETCH()
  59. #endif
  60. PHP_MINIT_FUNCTION(v8js_class);
  61. #endif /* V8JS_CLASS_H */
  62. /*
  63. * Local variables:
  64. * tab-width: 4
  65. * c-basic-offset: 4
  66. * End:
  67. * vim600: noet sw=4 ts=4 fdm=marker
  68. * vim<600: noet sw=4 ts=4
  69. */