v8js_class.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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_tmpl_t;
  18. typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > v8js_persistent_obj_t;
  19. /* Forward declarations */
  20. struct v8js_v8object;
  21. struct v8js_accessor_ctx;
  22. struct _v8js_script;
  23. struct cmp_str {
  24. bool operator()(char const *a, char const *b) const {
  25. return strcmp(a, b) < 0;
  26. }
  27. };
  28. /* {{{ Context container */
  29. struct v8js_ctx {
  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. size_t memory_limit;
  40. bool memory_limit_hit;
  41. long average_object_size;
  42. v8js_tmpl_t global_template;
  43. v8js_tmpl_t array_tmpl;
  44. zval module_normaliser;
  45. zval module_loader;
  46. std::vector<char *> modules_stack;
  47. std::vector<char *> modules_base;
  48. std::map<char *, v8js_persistent_obj_t, cmp_str> modules_loaded;
  49. std::map<const zend_string *,v8js_tmpl_t> template_cache;
  50. std::map<zend_object *, v8js_persistent_obj_t> weak_objects;
  51. std::map<v8js_tmpl_t *, v8js_persistent_obj_t> weak_closures;
  52. std::map<v8js_tmpl_t *, v8js_tmpl_t> call_impls;
  53. std::map<zend_function *, v8js_tmpl_t> method_tmpls;
  54. std::list<v8js_v8object *> v8js_v8objects;
  55. std::vector<v8js_accessor_ctx *> accessor_list;
  56. std::vector<struct _v8js_script *> script_objects;
  57. char *tz;
  58. v8::Isolate::CreateParams create_params;
  59. zval zval_snapshot_blob;
  60. v8::StartupData snapshot_blob;
  61. zend_object std;
  62. };
  63. /* }}} */
  64. static inline struct v8js_ctx *v8js_ctx_fetch_object(zend_object *obj) {
  65. return (struct v8js_ctx *)((char *)obj - XtOffsetOf(struct v8js_ctx, std));
  66. }
  67. #define Z_V8JS_CTX_OBJ_P(zv) v8js_ctx_fetch_object(Z_OBJ_P(zv));
  68. PHP_MINIT_FUNCTION(v8js_class);
  69. #endif /* V8JS_CLASS_H */
  70. /*
  71. * Local variables:
  72. * tab-width: 4
  73. * c-basic-offset: 4
  74. * indent-tabs-mode: t
  75. * End:
  76. * vim600: noet sw=4 ts=4 fdm=marker
  77. * vim<600: noet sw=4 ts=4
  78. */