0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 08:11:52 +00:00

rename v8js_tmpl_t -> v8js_function_tmpl_t

This commit is contained in:
Stefan Siegl 2016-07-09 11:31:15 +02:00
parent 539c71a3d3
commit 7a947fe9d1
No known key found for this signature in database
GPG Key ID: 73942AF5642F3DDA
3 changed files with 25 additions and 25 deletions

View File

@ -113,21 +113,21 @@ static void v8js_free_storage(zend_object *object) /* {{{ */
c->array_tmpl.~Persistent();
/* Clear persistent call_impl & method_tmpls templates */
for (std::map<v8js_tmpl_t *, v8js_tmpl_t>::iterator it = c->call_impls.begin();
for (std::map<v8js_function_tmpl_t *, v8js_function_tmpl_t>::iterator it = c->call_impls.begin();
it != c->call_impls.end(); ++it) {
// No need to free it->first, as it is stored in c->template_cache and freed below
it->second.Reset();
}
c->call_impls.~map();
for (std::map<zend_function *, v8js_tmpl_t>::iterator it = c->method_tmpls.begin();
for (std::map<zend_function *, v8js_function_tmpl_t>::iterator it = c->method_tmpls.begin();
it != c->method_tmpls.end(); ++it) {
it->second.Reset();
}
c->method_tmpls.~map();
/* Clear persistent handles in template cache */
for (std::map<const zend_string *,v8js_tmpl_t>::iterator it = c->template_cache.begin();
for (std::map<const zend_string *,v8js_function_tmpl_t>::iterator it = c->template_cache.begin();
it != c->template_cache.end(); ++it) {
it->second.Reset();
}
@ -158,9 +158,9 @@ static void v8js_free_storage(zend_object *object) /* {{{ */
}
c->weak_objects.~map();
for (std::map<v8js_tmpl_t *, v8js_persistent_obj_t>::iterator it = c->weak_closures.begin();
for (std::map<v8js_function_tmpl_t *, v8js_persistent_obj_t>::iterator it = c->weak_closures.begin();
it != c->weak_closures.end(); ++it) {
v8js_tmpl_t *persist_tpl_ = it->first;
v8js_function_tmpl_t *persist_tpl_ = it->first;
persist_tpl_->Reset();
delete persist_tpl_;
it->second.Reset();
@ -229,13 +229,13 @@ static zend_object* v8js_new(zend_class_entry *ce) /* {{{ */
new(&c->modules_base) std::vector<char*>();
new(&c->modules_loaded) std::map<char *, v8js_persistent_obj_t, cmp_str>;
new(&c->template_cache) std::map<const zend_string *,v8js_tmpl_t>();
new(&c->template_cache) std::map<const zend_string *,v8js_function_tmpl_t>();
new(&c->accessor_list) std::vector<v8js_accessor_ctx *>();
new(&c->weak_closures) std::map<v8js_tmpl_t *, v8js_persistent_obj_t>();
new(&c->weak_closures) std::map<v8js_function_tmpl_t *, v8js_persistent_obj_t>();
new(&c->weak_objects) std::map<zend_object *, v8js_persistent_obj_t>();
new(&c->call_impls) std::map<v8js_tmpl_t *, v8js_tmpl_t>();
new(&c->method_tmpls) std::map<zend_function *, v8js_tmpl_t>();
new(&c->call_impls) std::map<v8js_function_tmpl_t *, v8js_function_tmpl_t>();
new(&c->method_tmpls) std::map<zend_function *, v8js_function_tmpl_t>();
new(&c->v8js_v8objects) std::list<v8js_v8object *>();
new(&c->script_objects) std::vector<v8js_script *>();
@ -589,7 +589,7 @@ static PHP_METHOD(V8Js, __construct)
ft = v8::FunctionTemplate::New(isolate, v8js_php_callback,
v8::External::New((isolate), method_ptr));
// @fixme add/check Signature v8::Signature::New((isolate), tmpl));
v8js_tmpl_t *persistent_ft = &c->method_tmpls[method_ptr];
v8js_function_tmpl_t *persistent_ft = &c->method_tmpls[method_ptr];
persistent_ft->Reset(isolate, ft);
}

View File

@ -17,7 +17,7 @@
/* Abbreviate long type names */
typedef v8::Persistent<v8::FunctionTemplate, v8::CopyablePersistentTraits<v8::FunctionTemplate> > v8js_tmpl_t;
typedef v8::Persistent<v8::FunctionTemplate, v8::CopyablePersistentTraits<v8::FunctionTemplate> > v8js_function_tmpl_t;
typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > v8js_persistent_obj_t;
/* Forward declarations */
@ -48,8 +48,8 @@ struct v8js_ctx {
bool memory_limit_hit;
long average_object_size;
v8js_tmpl_t global_template;
v8js_tmpl_t array_tmpl;
v8js_function_tmpl_t global_template;
v8js_function_tmpl_t array_tmpl;
zval module_normaliser;
zval module_loader;
@ -57,12 +57,12 @@ struct v8js_ctx {
std::vector<char *> modules_stack;
std::vector<char *> modules_base;
std::map<char *, v8js_persistent_obj_t, cmp_str> modules_loaded;
std::map<const zend_string *,v8js_tmpl_t> template_cache;
std::map<const zend_string *,v8js_function_tmpl_t> template_cache;
std::map<zend_object *, v8js_persistent_obj_t> weak_objects;
std::map<v8js_tmpl_t *, v8js_persistent_obj_t> weak_closures;
std::map<v8js_tmpl_t *, v8js_tmpl_t> call_impls;
std::map<zend_function *, v8js_tmpl_t> method_tmpls;
std::map<v8js_function_tmpl_t *, v8js_persistent_obj_t> weak_closures;
std::map<v8js_function_tmpl_t *, v8js_function_tmpl_t> call_impls;
std::map<zend_function *, v8js_function_tmpl_t> method_tmpls;
std::list<v8js_v8object *> v8js_v8objects;

View File

@ -291,10 +291,10 @@ static void v8js_weak_object_callback(const v8::WeakCallbackInfo<zend_object> &d
isolate->AdjustAmountOfExternalAllocatedMemory(-ctx->average_object_size);
}
static void v8js_weak_closure_callback(const v8::WeakCallbackInfo<v8js_tmpl_t> &data) {
static void v8js_weak_closure_callback(const v8::WeakCallbackInfo<v8js_function_tmpl_t> &data) {
v8::Isolate *isolate = data.GetIsolate();
v8js_tmpl_t *persist_tpl_ = data.GetParameter();
v8js_function_tmpl_t *persist_tpl_ = data.GetParameter();
persist_tpl_->Reset();
delete persist_tpl_;
@ -559,7 +559,7 @@ static void v8js_fake_call_impl(const v8::FunctionCallbackInfo<v8::Value>& info)
v8::Local<v8::FunctionTemplate> tmpl =
v8::Local<v8::FunctionTemplate>::New
(isolate, *reinterpret_cast<v8js_tmpl_t *>(self->GetAlignedPointerFromInternalField(0)));
(isolate, *reinterpret_cast<v8js_function_tmpl_t *>(self->GetAlignedPointerFromInternalField(0)));
// use v8js_php_callback to actually execute the method
v8::Local<v8::Function> cb = PHP_V8JS_CALLBACK(isolate, method_ptr, tmpl);
uint32_t i, argc = args->Length();
@ -597,7 +597,7 @@ v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::String> property
zval zobject;
ZVAL_OBJ(&zobject, object);
v8js_tmpl_t *tmpl_ptr = reinterpret_cast<v8js_tmpl_t *>(self->GetAlignedPointerFromInternalField(0));
v8js_function_tmpl_t *tmpl_ptr = reinterpret_cast<v8js_function_tmpl_t *>(self->GetAlignedPointerFromInternalField(0));
v8::Local<v8::FunctionTemplate> tmpl = v8::Local<v8::FunctionTemplate>::New(isolate, *tmpl_ptr);
ce = scope = object->ce;
@ -641,7 +641,7 @@ v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::String> property
ft = v8::FunctionTemplate::New(isolate,
v8js_fake_call_impl, V8JS_NULL,
v8::Signature::New(isolate, tmpl));
v8js_tmpl_t *persistent_ft = &ctx->call_impls[tmpl_ptr];
v8js_function_tmpl_t *persistent_ft = &ctx->call_impls[tmpl_ptr];
persistent_ft->Reset(isolate, ft);
}
v8::Local<v8::Function> cb = ft->GetFunction();
@ -657,7 +657,7 @@ v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::String> property
ft = v8::FunctionTemplate::New(isolate, v8js_php_callback,
v8::External::New((isolate), method_ptr),
v8::Signature::New((isolate), tmpl));
v8js_tmpl_t *persistent_ft = &ctx->method_tmpls[method_ptr];
v8js_function_tmpl_t *persistent_ft = &ctx->method_tmpls[method_ptr];
persistent_ft->Reset(isolate, ft);
}
ret_value = ft->GetFunction();
@ -815,7 +815,7 @@ static v8::MaybeLocal<v8::Object> v8js_wrap_object(v8::Isolate *isolate, zend_cl
{
v8js_ctx *ctx = (v8js_ctx *) isolate->GetData(0);
v8::Local<v8::FunctionTemplate> new_tpl;
v8js_tmpl_t *persist_tpl_;
v8js_function_tmpl_t *persist_tpl_;
try {
new_tpl = v8::Local<v8::FunctionTemplate>::New
@ -836,7 +836,7 @@ static v8::MaybeLocal<v8::Object> v8js_wrap_object(v8::Isolate *isolate, zend_cl
if (ce == zend_ce_closure) {
/* Got a closure, mustn't cache ... */
persist_tpl_ = new v8js_tmpl_t(isolate, new_tpl);
persist_tpl_ = new v8js_function_tmpl_t(isolate, new_tpl);
/* We'll free persist_tpl_ via v8js_weak_closure_callback, below */
new_tpl->InstanceTemplate()->SetCallAsFunctionHandler(v8js_php_callback);
} else {