2014-12-12 23:59:28 +01:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2017-03-11 12:33:49 +01:00
|
|
|
| PHP Version 7 |
|
2014-12-12 23:59:28 +01:00
|
|
|
+----------------------------------------------------------------------+
|
2016-02-28 20:17:56 +01:00
|
|
|
| Copyright (c) 1997-2016 The PHP Group |
|
2014-12-12 23:59:28 +01:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| http://www.opensource.org/licenses/mit-license.php MIT License |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Author: Jani Taskinen <jani.taskinen@iki.fi> |
|
|
|
|
| Author: Patrick Reilly <preilly@php.net> |
|
2016-02-28 20:17:56 +01:00
|
|
|
| Author: Stefan Siegl <stesie@php.net> |
|
2014-12-12 23:59:28 +01:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef V8JS_CLASS_H
|
|
|
|
#define V8JS_CLASS_H
|
|
|
|
|
2014-12-13 00:43:19 +01:00
|
|
|
|
|
|
|
/* Abbreviate long type names */
|
2024-09-27 23:27:59 +02:00
|
|
|
typedef v8::Global<v8::FunctionTemplate> v8js_function_tmpl_t;
|
|
|
|
typedef v8::Global<v8::ObjectTemplate> v8js_object_tmpl_t;
|
|
|
|
typedef v8::Global<v8::Object> v8js_persistent_obj_t;
|
|
|
|
typedef v8::Global<v8::Value> v8js_persistent_value_t;
|
2014-12-13 00:43:19 +01:00
|
|
|
|
|
|
|
/* Forward declarations */
|
|
|
|
struct v8js_v8object;
|
2014-12-13 01:15:29 +01:00
|
|
|
struct v8js_accessor_ctx;
|
2015-08-02 23:35:47 +02:00
|
|
|
struct _v8js_script;
|
2014-12-13 00:43:19 +01:00
|
|
|
|
2015-08-01 17:49:11 +02:00
|
|
|
struct cmp_str {
|
|
|
|
bool operator()(char const *a, char const *b) const {
|
|
|
|
return strcmp(a, b) < 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-12-13 00:43:19 +01:00
|
|
|
/* {{{ Context container */
|
2014-12-13 01:15:29 +01:00
|
|
|
struct v8js_ctx {
|
2024-09-27 23:27:59 +02:00
|
|
|
v8::Global<v8::String> object_name;
|
|
|
|
v8::Global<v8::Context> context;
|
2014-12-13 00:43:19 +01:00
|
|
|
int in_execution;
|
|
|
|
v8::Isolate *isolate;
|
|
|
|
|
2015-08-21 16:12:12 +02:00
|
|
|
long flags;
|
|
|
|
|
2014-12-13 00:43:19 +01:00
|
|
|
long time_limit;
|
|
|
|
bool time_limit_hit;
|
2017-03-11 14:10:49 +01:00
|
|
|
size_t memory_limit;
|
2014-12-13 00:43:19 +01:00
|
|
|
bool memory_limit_hit;
|
2016-03-08 09:28:16 +01:00
|
|
|
long average_object_size;
|
2014-12-13 00:43:19 +01:00
|
|
|
|
2016-07-09 11:31:44 +02:00
|
|
|
v8js_object_tmpl_t global_template;
|
2016-07-09 11:31:15 +02:00
|
|
|
v8js_function_tmpl_t array_tmpl;
|
2014-12-13 00:43:19 +01:00
|
|
|
|
2015-12-31 20:25:24 +01:00
|
|
|
zval module_normaliser;
|
2015-08-24 22:05:27 +02:00
|
|
|
zval module_loader;
|
2022-06-24 12:04:11 +02:00
|
|
|
zval exception_filter;
|
2015-12-31 20:25:24 +01:00
|
|
|
|
2014-12-13 00:43:19 +01:00
|
|
|
std::vector<char *> modules_stack;
|
2017-11-12 16:25:59 +01:00
|
|
|
std::map<char *, v8js_persistent_value_t, cmp_str> modules_loaded;
|
2016-07-09 11:31:15 +02:00
|
|
|
std::map<const zend_string *,v8js_function_tmpl_t> template_cache;
|
2014-12-13 00:43:19 +01:00
|
|
|
|
2015-08-24 22:05:27 +02:00
|
|
|
std::map<zend_object *, v8js_persistent_obj_t> weak_objects;
|
2016-07-09 11:31:15 +02:00
|
|
|
std::map<v8js_function_tmpl_t *, v8js_persistent_obj_t> weak_closures;
|
|
|
|
std::map<v8js_function_tmpl_t *, v8js_function_tmpl_t> call_impls;
|
2019-06-22 19:13:45 +02:00
|
|
|
std::map<std::pair<zend_class_entry *, zend_function *>, v8js_function_tmpl_t> method_tmpls;
|
2014-12-13 00:43:19 +01:00
|
|
|
|
|
|
|
std::list<v8js_v8object *> v8js_v8objects;
|
|
|
|
|
2014-12-13 01:15:29 +01:00
|
|
|
std::vector<v8js_accessor_ctx *> accessor_list;
|
2015-08-02 23:35:47 +02:00
|
|
|
std::vector<struct _v8js_script *> script_objects;
|
2014-12-13 00:43:19 +01:00
|
|
|
char *tz;
|
2016-02-28 17:00:47 +01:00
|
|
|
|
|
|
|
v8::Isolate::CreateParams create_params;
|
2016-03-05 22:21:42 +01:00
|
|
|
zval zval_snapshot_blob;
|
2016-02-28 17:00:47 +01:00
|
|
|
v8::StartupData snapshot_blob;
|
2016-02-28 20:17:56 +01:00
|
|
|
|
2015-08-24 22:19:15 +02:00
|
|
|
zend_object std;
|
2014-12-13 00:43:19 +01:00
|
|
|
};
|
|
|
|
/* }}} */
|
|
|
|
|
2015-08-25 00:24:04 +02:00
|
|
|
static inline struct v8js_ctx *v8js_ctx_fetch_object(zend_object *obj) {
|
|
|
|
return (struct v8js_ctx *)((char *)obj - XtOffsetOf(struct v8js_ctx, std));
|
|
|
|
}
|
|
|
|
|
2022-05-29 21:48:47 +02:00
|
|
|
static inline zend_object *v8js_ctx_to_zend_object(struct v8js_ctx *ctx) {
|
|
|
|
return (zend_object *)((char *)ctx + XtOffsetOf(struct v8js_ctx, std));
|
|
|
|
}
|
|
|
|
|
2015-08-25 00:24:04 +02:00
|
|
|
#define Z_V8JS_CTX_OBJ_P(zv) v8js_ctx_fetch_object(Z_OBJ_P(zv));
|
2021-06-03 09:33:51 +08:00
|
|
|
#define Z_V8JS_CTX_OBJ(zv) v8js_ctx_fetch_object(zv);
|
2015-08-25 00:24:04 +02:00
|
|
|
|
2014-12-13 00:43:19 +01:00
|
|
|
|
2021-06-03 09:33:51 +08:00
|
|
|
#define ZEND_ACC_DTOR 0
|
|
|
|
|
2014-12-12 23:59:28 +01:00
|
|
|
PHP_MINIT_FUNCTION(v8js_class);
|
|
|
|
|
|
|
|
#endif /* V8JS_CLASS_H */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
2016-07-02 22:41:01 +02:00
|
|
|
* indent-tabs-mode: t
|
2014-12-12 23:59:28 +01:00
|
|
|
* End:
|
|
|
|
* vim600: noet sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: noet sw=4 ts=4
|
|
|
|
*/
|