0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-11-08 14:48:40 +00:00
phpv8/v8js_class.h
Stefan Siegl 0deb7d1802 Track list of valid script object in ctx
We don't know whether the V8Js object dtor or the script (resource)
dtor is called first.  Nevertheless they depend on each other as
we must not simply Reset the persistent v8::Script if the v8::Isolate
was disposed before.

Now the V8Js dtor iterates over all script resources and resets the
persistent v8::Script instances; leaving an invalidated resource
object (which cannot be called anymore).
2015-08-02 23:35:47 +02:00

83 lines
2.4 KiB
C++

/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2013 The PHP Group |
+----------------------------------------------------------------------+
| http://www.opensource.org/licenses/mit-license.php MIT License |
+----------------------------------------------------------------------+
| Author: Jani Taskinen <jani.taskinen@iki.fi> |
| Author: Patrick Reilly <preilly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef V8JS_CLASS_H
#define V8JS_CLASS_H
/* Abbreviate long type names */
typedef v8::Persistent<v8::FunctionTemplate, v8::CopyablePersistentTraits<v8::FunctionTemplate> > v8js_tmpl_t;
typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > v8js_persistent_obj_t;
/* Forward declarations */
struct v8js_v8object;
struct v8js_accessor_ctx;
struct _v8js_script;
/* {{{ Context container */
struct v8js_ctx {
zend_object std;
v8::Persistent<v8::String> object_name;
v8::Persistent<v8::Context> context;
zend_bool report_uncaught;
zval *pending_exception;
int in_execution;
v8::Isolate *isolate;
long time_limit;
bool time_limit_hit;
long memory_limit;
bool memory_limit_hit;
v8::Persistent<v8::FunctionTemplate> global_template;
zval *module_loader;
std::vector<char *> modules_stack;
std::vector<char *> modules_base;
std::map<char *, v8js_persistent_obj_t> modules_loaded;
std::map<const char *,v8js_tmpl_t> template_cache;
std::map<zval *, v8js_persistent_obj_t> weak_objects;
std::map<v8js_tmpl_t *, v8js_persistent_obj_t> weak_closures;
std::list<v8js_v8object *> v8js_v8objects;
std::vector<v8js_accessor_ctx *> accessor_list;
std::vector<struct _v8js_script *> script_objects;
char *tz;
#ifdef ZTS
void ***zts_ctx;
#endif
};
/* }}} */
#ifdef ZTS
# define V8JS_TSRMLS_FETCH() TSRMLS_FETCH_FROM_CTX(((v8js_ctx *) isolate->GetData(0))->zts_ctx);
#else
# define V8JS_TSRMLS_FETCH()
#endif
PHP_MINIT_FUNCTION(v8js_class);
#endif /* V8JS_CLASS_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/