v8js_class.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 7 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 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. | Author: Stefan Siegl <[email protected]> |
  12. +----------------------------------------------------------------------+
  13. */
  14. #ifndef V8JS_CLASS_H
  15. #define V8JS_CLASS_H
  16. /* Abbreviate long type names */
  17. typedef v8::Persistent<v8::FunctionTemplate, v8::CopyablePersistentTraits<v8::FunctionTemplate> > v8js_function_tmpl_t;
  18. typedef v8::Persistent<v8::ObjectTemplate, v8::CopyablePersistentTraits<v8::ObjectTemplate> > v8js_object_tmpl_t;
  19. typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > v8js_persistent_obj_t;
  20. typedef v8::Persistent<v8::Value, v8::CopyablePersistentTraits<v8::Value> > v8js_persistent_value_t;
  21. /* Forward declarations */
  22. struct v8js_v8object;
  23. struct v8js_accessor_ctx;
  24. struct _v8js_script;
  25. struct cmp_str {
  26. bool operator()(char const *a, char const *b) const {
  27. return strcmp(a, b) < 0;
  28. }
  29. };
  30. /* {{{ Context container */
  31. struct v8js_ctx {
  32. v8::Persistent<v8::String> object_name;
  33. v8::Persistent<v8::Context> context;
  34. zend_bool report_uncaught;
  35. zval pending_exception;
  36. int in_execution;
  37. v8::Isolate *isolate;
  38. long flags;
  39. long time_limit;
  40. bool time_limit_hit;
  41. size_t memory_limit;
  42. bool memory_limit_hit;
  43. long average_object_size;
  44. v8js_object_tmpl_t global_template;
  45. v8js_function_tmpl_t array_tmpl;
  46. zval module_normaliser;
  47. zval module_loader;
  48. std::vector<char *> modules_stack;
  49. std::map<char *, v8js_persistent_value_t, cmp_str> modules_loaded;
  50. std::map<const zend_string *,v8js_function_tmpl_t> template_cache;
  51. std::map<zend_object *, v8js_persistent_obj_t> weak_objects;
  52. std::map<v8js_function_tmpl_t *, v8js_persistent_obj_t> weak_closures;
  53. std::map<v8js_function_tmpl_t *, v8js_function_tmpl_t> call_impls;
  54. std::map<std::pair<zend_class_entry *, zend_function *>, v8js_function_tmpl_t> method_tmpls;
  55. std::list<v8js_v8object *> v8js_v8objects;
  56. std::vector<v8js_accessor_ctx *> accessor_list;
  57. std::vector<struct _v8js_script *> script_objects;
  58. char *tz;
  59. v8::Isolate::CreateParams create_params;
  60. zval zval_snapshot_blob;
  61. v8::StartupData snapshot_blob;
  62. zend_object std;
  63. };
  64. /* }}} */
  65. static inline struct v8js_ctx *v8js_ctx_fetch_object(zend_object *obj) {
  66. return (struct v8js_ctx *)((char *)obj - XtOffsetOf(struct v8js_ctx, std));
  67. }
  68. #define Z_V8JS_CTX_OBJ_P(zv) v8js_ctx_fetch_object(Z_OBJ_P(zv));
  69. #define Z_V8JS_CTX_OBJ(zv) v8js_ctx_fetch_object(zv);
  70. #if PHP_VERSION_ID >= 80000
  71. #define ZEND_ACC_DTOR 0
  72. #endif
  73. PHP_MINIT_FUNCTION(v8js_class);
  74. #endif /* V8JS_CLASS_H */
  75. /*
  76. * Local variables:
  77. * tab-width: 4
  78. * c-basic-offset: 4
  79. * indent-tabs-mode: t
  80. * End:
  81. * vim600: noet sw=4 ts=4 fdm=marker
  82. * vim<600: noet sw=4 ts=4
  83. */