summaryrefslogtreecommitdiff
path: root/src/node_perf.cc
diff options
context:
space:
mode:
authorJure Triglav <juretriglav@gmail.com>2017-12-13 22:35:32 +0000
committerAnatoli Papirovski <apapirovski@mac.com>2017-12-17 12:45:39 -0500
commitefffcc262c77a58ad3c75787497df46863d1b7a6 (patch)
tree8f8897baa2900df6750b228c1c3791ef8ac89ea2 /src/node_perf.cc
parentb2432a7f00fc2e9bd05e97c242871999b983d4f5 (diff)
downloadandroid-node-v8-efffcc262c77a58ad3c75787497df46863d1b7a6.tar.gz
android-node-v8-efffcc262c77a58ad3c75787497df46863d1b7a6.tar.bz2
android-node-v8-efffcc262c77a58ad3c75787497df46863d1b7a6.zip
src: replace SetAccessor w/ SetAccessorProperty
PR-URL: https://github.com/nodejs/node/pull/17665 Fixes: https://github.com/nodejs/node/issues/17636 Refs: https://github.com/nodejs/node/pull/16482 Refs: https://github.com/nodejs/node/pull/16860 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/node_perf.cc')
-rw-r--r--src/node_perf.cc64
1 files changed, 48 insertions, 16 deletions
diff --git a/src/node_perf.cc b/src/node_perf.cc
index 94c3a0f8e0..37256a943c 100644
--- a/src/node_perf.cc
+++ b/src/node_perf.cc
@@ -19,7 +19,7 @@ using v8::Local;
using v8::Name;
using v8::Object;
using v8::ObjectTemplate;
-using v8::PropertyCallbackInfo;
+using v8::Signature;
using v8::String;
using v8::Value;
@@ -120,8 +120,7 @@ void Measure(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(obj);
}
-void GetPerformanceEntryName(const Local<String> prop,
- const PropertyCallbackInfo<Value>& info) {
+void GetPerformanceEntryName(const FunctionCallbackInfo<Value>& info) {
Isolate* isolate = info.GetIsolate();
PerformanceEntry* entry;
ASSIGN_OR_RETURN_UNWRAP(&entry, info.Holder());
@@ -129,8 +128,7 @@ void GetPerformanceEntryName(const Local<String> prop,
String::NewFromUtf8(isolate, entry->name().c_str(), String::kNormalString));
}
-void GetPerformanceEntryType(const Local<String> prop,
- const PropertyCallbackInfo<Value>& info) {
+void GetPerformanceEntryType(const FunctionCallbackInfo<Value>& info) {
Isolate* isolate = info.GetIsolate();
PerformanceEntry* entry;
ASSIGN_OR_RETURN_UNWRAP(&entry, info.Holder());
@@ -138,15 +136,13 @@ void GetPerformanceEntryType(const Local<String> prop,
String::NewFromUtf8(isolate, entry->type().c_str(), String::kNormalString));
}
-void GetPerformanceEntryStartTime(const Local<String> prop,
- const PropertyCallbackInfo<Value>& info) {
+void GetPerformanceEntryStartTime(const FunctionCallbackInfo<Value>& info) {
PerformanceEntry* entry;
ASSIGN_OR_RETURN_UNWRAP(&entry, info.Holder());
info.GetReturnValue().Set(entry->startTime());
}
-void GetPerformanceEntryDuration(const Local<String> prop,
- const PropertyCallbackInfo<Value>& info) {
+void GetPerformanceEntryDuration(const FunctionCallbackInfo<Value>& info) {
PerformanceEntry* entry;
ASSIGN_OR_RETURN_UNWRAP(&entry, info.Holder());
info.GetReturnValue().Set(entry->duration());
@@ -336,14 +332,50 @@ void Init(Local<Object> target,
Local<FunctionTemplate> pe = env->NewFunctionTemplate(PerformanceEntry::New);
pe->InstanceTemplate()->SetInternalFieldCount(1);
pe->SetClassName(performanceEntryString);
+
+ Local<Signature> signature = Signature::New(env->isolate(), pe);
+
+ Local<FunctionTemplate> get_performance_entry_name_templ =
+ FunctionTemplate::New(env->isolate(),
+ GetPerformanceEntryName,
+ env->as_external(),
+ signature);
+
+ Local<FunctionTemplate> get_performance_entry_type_templ =
+ FunctionTemplate::New(env->isolate(),
+ GetPerformanceEntryType,
+ env->as_external(),
+ signature);
+
+ Local<FunctionTemplate> get_performance_entry_start_time_templ =
+ FunctionTemplate::New(env->isolate(),
+ GetPerformanceEntryStartTime,
+ env->as_external(),
+ signature);
+
+ Local<FunctionTemplate> get_performance_entry_duration_templ =
+ FunctionTemplate::New(env->isolate(),
+ GetPerformanceEntryDuration,
+ env->as_external(),
+ signature);
+
Local<ObjectTemplate> ot = pe->InstanceTemplate();
- ot->SetAccessor(env->name_string(), GetPerformanceEntryName);
- ot->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "entryType"),
- GetPerformanceEntryType);
- ot->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "startTime"),
- GetPerformanceEntryStartTime);
- ot->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "duration"),
- GetPerformanceEntryDuration);
+ ot->SetAccessorProperty(env->name_string(),
+ get_performance_entry_name_templ,
+ Local<FunctionTemplate>());
+
+ ot->SetAccessorProperty(FIXED_ONE_BYTE_STRING(isolate, "entryType"),
+ get_performance_entry_type_templ,
+ Local<FunctionTemplate>());
+
+ ot->SetAccessorProperty(FIXED_ONE_BYTE_STRING(isolate, "startTime"),
+ get_performance_entry_start_time_templ,
+ Local<FunctionTemplate>());
+
+ ot->SetAccessorProperty(FIXED_ONE_BYTE_STRING(isolate, "duration"),
+ get_performance_entry_duration_templ,
+ Local<FunctionTemplate>());
+
Local<Function> fn = pe->GetFunction();
target->Set(performanceEntryString, fn);
env->set_performance_entry_template(fn);