GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: avoid prototype access in binding templates · nodejs/node@b25e704

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • async_wrap.cc
    • async_wrap.h
    • encoding_binding.cc
    • encoding_binding.h
    • env-inl.h
    • env.cc
    • env.h
    • env_properties.h
    • node_binding.cc
    • node_binding.h
    • node_blob.cc
    • node_blob.h
    • node_builtins.cc
    • node_builtins.h
    • node_contextify.cc
    • node_file.cc
    • node_i18n.cc
    • node_perf.cc
    • node_process_methods.cc
    • node_snapshotable.cc
    • node_stat_watcher.cc
    • node_stat_watcher.h
    • node_url.cc
    • node_url.h
    • node_worker.cc
    • timers.cc
    • timers.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/async_wrap.cc‎

Copy file name to clipboardExpand all lines: src/async_wrap.cc
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,8 @@ Local<FunctionTemplate> AsyncWrap::GetConstructorTemplate(
353353
}
354354

355355
void AsyncWrap::CreatePerIsolateProperties(IsolateData* isolate_data,
356-
Local<FunctionTemplate> ctor) {
356+
Local<ObjectTemplate> target) {
357357
Isolate* isolate = isolate_data->isolate();
358-
Local<ObjectTemplate> target = ctor->InstanceTemplate();
359358

360359
SetMethod(isolate, target, "setupHooks", SetupHooks);
361360
SetMethod(isolate, target, "setCallbackTrampoline", SetCallbackTrampoline);
Collapse file

‎src/async_wrap.h‎

Copy file name to clipboardExpand all lines: src/async_wrap.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ class AsyncWrap : public BaseObject {
149149
v8::Local<v8::Value> unused,
150150
v8::Local<v8::Context> context,
151151
void* priv);
152-
static void CreatePerIsolateProperties(
153-
IsolateData* isolate_data, v8::Local<v8::FunctionTemplate> target);
152+
static void CreatePerIsolateProperties(IsolateData* isolate_data,
153+
v8::Local<v8::ObjectTemplate> target);
154154

155155
static void GetAsyncId(const v8::FunctionCallbackInfo<v8::Value>& args);
156156
static void PushAsyncContext(const v8::FunctionCallbackInfo<v8::Value>& args);
Collapse file

‎src/encoding_binding.cc‎

Copy file name to clipboardExpand all lines: src/encoding_binding.cc
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ using v8::ArrayBuffer;
1616
using v8::BackingStore;
1717
using v8::Context;
1818
using v8::FunctionCallbackInfo;
19-
using v8::FunctionTemplate;
2019
using v8::Isolate;
2120
using v8::Local;
2221
using v8::MaybeLocal;
@@ -219,9 +218,8 @@ void BindingData::ToUnicode(const v8::FunctionCallbackInfo<v8::Value>& args) {
219218
}
220219

221220
void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data,
222-
Local<FunctionTemplate> ctor) {
221+
Local<ObjectTemplate> target) {
223222
Isolate* isolate = isolate_data->isolate();
224-
Local<ObjectTemplate> target = ctor->InstanceTemplate();
225223
SetMethod(isolate, target, "encodeInto", EncodeInto);
226224
SetMethodNoSideEffect(isolate, target, "encodeUtf8String", EncodeUtf8String);
227225
SetMethodNoSideEffect(isolate, target, "decodeUTF8", DecodeUTF8);
Collapse file

‎src/encoding_binding.h‎

Copy file name to clipboardExpand all lines: src/encoding_binding.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class BindingData : public SnapshotableObject {
3636
static void ToUnicode(const v8::FunctionCallbackInfo<v8::Value>& args);
3737

3838
static void CreatePerIsolateProperties(IsolateData* isolate_data,
39-
v8::Local<v8::FunctionTemplate> ctor);
39+
v8::Local<v8::ObjectTemplate> target);
4040
static void CreatePerContextProperties(v8::Local<v8::Object> target,
4141
v8::Local<v8::Value> unused,
4242
v8::Local<v8::Context> context,
Collapse file

‎src/env-inl.h‎

Copy file name to clipboardExpand all lines: src/env-inl.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ void Environment::set_process_exit_handler(
807807
#undef VY
808808
#undef VP
809809

810-
#define VM(PropertyName) V(PropertyName##_binding, v8::FunctionTemplate)
810+
#define VM(PropertyName) V(PropertyName##_binding_template, v8::ObjectTemplate)
811811
#define V(PropertyName, TypeName) \
812812
inline v8::Local<TypeName> IsolateData::PropertyName() const { \
813813
return PropertyName##_.Get(isolate_); \
Collapse file

‎src/env.cc‎

Copy file name to clipboardExpand all lines: src/env.cc
+6-7Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ using v8::Context;
3838
using v8::EmbedderGraph;
3939
using v8::EscapableHandleScope;
4040
using v8::Function;
41-
using v8::FunctionTemplate;
4241
using v8::HandleScope;
4342
using v8::HeapProfiler;
4443
using v8::HeapSpaceStatistics;
@@ -49,6 +48,7 @@ using v8::MaybeLocal;
4948
using v8::NewStringType;
5049
using v8::Number;
5150
using v8::Object;
51+
using v8::ObjectTemplate;
5252
using v8::Private;
5353
using v8::Script;
5454
using v8::SnapshotCreator;
@@ -326,7 +326,7 @@ IsolateDataSerializeInfo IsolateData::Serialize(SnapshotCreator* creator) {
326326
info.primitive_values.push_back(creator->AddData(async_wrap_provider(i)));
327327

328328
uint32_t id = 0;
329-
#define VM(PropertyName) V(PropertyName##_binding, FunctionTemplate)
329+
#define VM(PropertyName) V(PropertyName##_binding_template, ObjectTemplate)
330330
#define V(PropertyName, TypeName) \
331331
do { \
332332
Local<TypeName> field = PropertyName(); \
@@ -390,7 +390,7 @@ void IsolateData::DeserializeProperties(const IsolateDataSerializeInfo* info) {
390390
const std::vector<PropInfo>& values = info->template_values;
391391
i = 0; // index to the array
392392
uint32_t id = 0;
393-
#define VM(PropertyName) V(PropertyName##_binding, FunctionTemplate)
393+
#define VM(PropertyName) V(PropertyName##_binding_template, ObjectTemplate)
394394
#define V(PropertyName, TypeName) \
395395
do { \
396396
if (values.size() > i && id == values[i].id) { \
@@ -491,10 +491,9 @@ void IsolateData::CreateProperties() {
491491
NODE_ASYNC_PROVIDER_TYPES(V)
492492
#undef V
493493

494-
Local<FunctionTemplate> templ = FunctionTemplate::New(isolate());
495-
templ->InstanceTemplate()->SetInternalFieldCount(
496-
BaseObject::kInternalFieldCount);
497-
set_binding_data_ctor_template(templ);
494+
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate());
495+
templ->SetInternalFieldCount(BaseObject::kInternalFieldCount);
496+
set_binding_data_default_template(templ);
498497
binding::CreateInternalBindingTemplates(this);
499498

500499
contextify::ContextifyContext::InitializeGlobalTemplates(this);
Collapse file

‎src/env.h‎

Copy file name to clipboardExpand all lines: src/env.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class NODE_EXTERN_PRIVATE IsolateData : public MemoryRetainer {
166166
#undef VS
167167
#undef VP
168168

169-
#define VM(PropertyName) V(PropertyName##_binding, v8::FunctionTemplate)
169+
#define VM(PropertyName) V(PropertyName##_binding_template, v8::ObjectTemplate)
170170
#define V(PropertyName, TypeName) \
171171
inline v8::Local<TypeName> PropertyName() const; \
172172
inline void set_##PropertyName(v8::Local<TypeName> value);
@@ -194,7 +194,7 @@ class NODE_EXTERN_PRIVATE IsolateData : public MemoryRetainer {
194194
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
195195
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
196196
#define VR(PropertyName, TypeName) V(v8::Private, per_realm_##PropertyName)
197-
#define VM(PropertyName) V(v8::FunctionTemplate, PropertyName##_binding)
197+
#define VM(PropertyName) V(v8::ObjectTemplate, PropertyName##_binding_template)
198198
#define VT(PropertyName, TypeName) V(TypeName, PropertyName)
199199
#define V(TypeName, PropertyName) \
200200
v8::Eternal<TypeName> PropertyName ## _;
Collapse file

‎src/env_properties.h‎

Copy file name to clipboardExpand all lines: src/env_properties.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@
331331
#define PER_ISOLATE_TEMPLATE_PROPERTIES(V) \
332332
V(async_wrap_ctor_template, v8::FunctionTemplate) \
333333
V(async_wrap_object_ctor_template, v8::FunctionTemplate) \
334-
V(binding_data_ctor_template, v8::FunctionTemplate) \
334+
V(binding_data_default_template, v8::ObjectTemplate) \
335335
V(blob_constructor_template, v8::FunctionTemplate) \
336336
V(blob_reader_constructor_template, v8::FunctionTemplate) \
337337
V(blocklist_constructor_template, v8::FunctionTemplate) \
Collapse file

‎src/node_binding.cc‎

Copy file name to clipboardExpand all lines: src/node_binding.cc
+12-14Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ NODE_BUILTIN_BINDINGS(V)
101101

102102
#define V(modname) \
103103
void _register_isolate_##modname(node::IsolateData* isolate_data, \
104-
v8::Local<v8::FunctionTemplate> target);
104+
v8::Local<v8::ObjectTemplate> target);
105105
NODE_BINDINGS_WITH_PER_ISOLATE_INIT(V)
106106
#undef V
107107

@@ -235,11 +235,11 @@ using v8::Context;
235235
using v8::EscapableHandleScope;
236236
using v8::Exception;
237237
using v8::FunctionCallbackInfo;
238-
using v8::FunctionTemplate;
239238
using v8::HandleScope;
240239
using v8::Isolate;
241240
using v8::Local;
242241
using v8::Object;
242+
using v8::ObjectTemplate;
243243
using v8::String;
244244
using v8::Value;
245245

@@ -572,12 +572,11 @@ inline struct node_module* FindModule(struct node_module* list,
572572
void CreateInternalBindingTemplates(IsolateData* isolate_data) {
573573
#define V(modname) \
574574
do { \
575-
Local<FunctionTemplate> templ = \
576-
FunctionTemplate::New(isolate_data->isolate()); \
577-
templ->InstanceTemplate()->SetInternalFieldCount( \
578-
BaseObject::kInternalFieldCount); \
575+
Local<ObjectTemplate> templ = \
576+
ObjectTemplate::New(isolate_data->isolate()); \
577+
templ->SetInternalFieldCount(BaseObject::kInternalFieldCount); \
579578
_register_isolate_##modname(isolate_data, templ); \
580-
isolate_data->set_##modname##_binding(templ); \
579+
isolate_data->set_##modname##_binding_template(templ); \
581580
} while (0);
582581
NODE_BINDINGS_WITH_PER_ISOLATE_INIT(V)
583582
#undef V
@@ -586,21 +585,20 @@ void CreateInternalBindingTemplates(IsolateData* isolate_data) {
586585
static Local<Object> GetInternalBindingExportObject(IsolateData* isolate_data,
587586
const char* mod_name,
588587
Local<Context> context) {
589-
Local<FunctionTemplate> ctor;
588+
Local<ObjectTemplate> templ;
589+
590590
#define V(name) \
591591
if (strcmp(mod_name, #name) == 0) { \
592-
ctor = isolate_data->name##_binding(); \
592+
templ = isolate_data->name##_binding_template(); \
593593
} else // NOLINT(readability/braces)
594594
NODE_BINDINGS_WITH_PER_ISOLATE_INIT(V)
595595
#undef V
596596
{
597-
ctor = isolate_data->binding_data_ctor_template();
597+
// Default template.
598+
templ = isolate_data->binding_data_default_template();
598599
}
599600

600-
Local<Object> obj = ctor->GetFunction(context)
601-
.ToLocalChecked()
602-
->NewInstance(context)
603-
.ToLocalChecked();
601+
Local<Object> obj = templ->NewInstance(context).ToLocalChecked();
604602
return obj;
605603
}
606604

Collapse file

‎src/node_binding.h‎

Copy file name to clipboardExpand all lines: src/node_binding.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ namespace node {
8484
// list.
8585
#define NODE_BINDING_PER_ISOLATE_INIT(modname, per_isolate_func) \
8686
void _register_isolate_##modname(node::IsolateData* isolate_data, \
87-
v8::Local<v8::FunctionTemplate> target) { \
87+
v8::Local<v8::ObjectTemplate> target) { \
8888
per_isolate_func(isolate_data, target); \
8989
}
9090

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.