| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 11f790d commit 3bfce6c
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -132,19 +132,18 @@ v8::EmbedderGraph::Node::Detachedness BaseObject::GetDetachedness() const { | |||
| 132 | 132 | ||
| 133 | 133 | template <int Field> | |
| 134 | 134 | void BaseObject::InternalFieldGet( | |
| 135 | - v8::Local<v8::Name> property, | ||
| 136 | - const v8::PropertyCallbackInfo<v8::Value>& info) { | ||
| 137 | - info.GetReturnValue().Set( | ||
| 138 | - info.This()->GetInternalField(Field).As<v8::Value>()); | ||
| 135 | + const v8::FunctionCallbackInfo<v8::Value>& args) { | ||
| 136 | + args.GetReturnValue().Set( | ||
| 137 | + args.This()->GetInternalField(Field).As<v8::Value>()); | ||
| 139 | 138 | } | |
| 140 | 139 | ||
| 141 | 140 | template <int Field, bool (v8::Value::*typecheck)() const> | |
| 142 | - void BaseObject::InternalFieldSet(v8::Local<v8::Name> property, | ||
| 143 | - v8::Local<v8::Value> value, | ||
| 144 | - const v8::PropertyCallbackInfo<void>& info) { | ||
| 141 | + void BaseObject::InternalFieldSet( | ||
| 142 | + const v8::FunctionCallbackInfo<v8::Value>& args) { | ||
| 143 | + v8::Local<v8::Value> value = args[0]; | ||
| 145 | 144 | // This could be e.g. value->IsFunction(). | |
| 146 | 145 | CHECK(((*value)->*typecheck)()); | |
| 147 | - info.This()->SetInternalField(Field, value); | ||
| 146 | + args.This()->SetInternalField(Field, value); | ||
| 148 | 147 | } | |
| 149 | 148 | ||
| 150 | 149 | bool BaseObject::has_pointer_data() const { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -111,12 +111,9 @@ class BaseObject : public MemoryRetainer { | |||
| 111 | 111 | ||
| 112 | 112 | // Setter/Getter pair for internal fields that can be passed to SetAccessor. | |
| 113 | 113 | template <int Field> | |
| 114 | - static void InternalFieldGet(v8::Local<v8::Name> property, | ||
| 115 | - const v8::PropertyCallbackInfo<v8::Value>& info); | ||
| 114 | + static void InternalFieldGet(const v8::FunctionCallbackInfo<v8::Value>& args); | ||
| 116 | 115 | template <int Field, bool (v8::Value::*typecheck)() const> | |
| 117 | - static void InternalFieldSet(v8::Local<v8::Name> property, | ||
| 118 | - v8::Local<v8::Value> value, | ||
| 119 | - const v8::PropertyCallbackInfo<void>& info); | ||
| 116 | + static void InternalFieldSet(const v8::FunctionCallbackInfo<v8::Value>& args); | ||
| 120 | 117 | ||
| 121 | 118 | // This is a bit of a hack. See the override in async_wrap.cc for details. | |
| 122 | 119 | virtual bool IsDoneInitializing() const; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -492,6 +492,29 @@ Local<Object> StreamBase::GetObject() { | |||
| 492 | 492 | return GetAsyncWrap()->object(); | |
| 493 | 493 | } | |
| 494 | 494 | ||
| 495 | + void StreamBase::AddAccessor(v8::Isolate* isolate, | ||
| 496 | + v8::Local<v8::Signature> signature, | ||
| 497 | + enum v8::PropertyAttribute attributes, | ||
| 498 | + v8::Local<v8::FunctionTemplate> t, | ||
| 499 | + JSMethodFunction* getter, | ||
| 500 | + JSMethodFunction* setter, | ||
| 501 | + v8::Local<v8::String> string) { | ||
| 502 | + Local<FunctionTemplate> getter_templ = | ||
| 503 | + NewFunctionTemplate(isolate, | ||
| 504 | + getter, | ||
| 505 | + signature, | ||
| 506 | + ConstructorBehavior::kThrow, | ||
| 507 | + SideEffectType::kHasNoSideEffect); | ||
| 508 | + Local<FunctionTemplate> setter_templ = | ||
| 509 | + NewFunctionTemplate(isolate, | ||
| 510 | + setter, | ||
| 511 | + signature, | ||
| 512 | + ConstructorBehavior::kThrow, | ||
| 513 | + SideEffectType::kHasSideEffect); | ||
| 514 | + t->PrototypeTemplate()->SetAccessorProperty( | ||
| 515 | + string, getter_templ, setter_templ, attributes); | ||
| 516 | + } | ||
| 517 | + | ||
| 495 | 518 | void StreamBase::AddMethod(Isolate* isolate, | |
| 496 | 519 | Local<Signature> signature, | |
| 497 | 520 | enum PropertyAttribute attributes, | |
@@ -561,11 +584,14 @@ void StreamBase::AddMethods(IsolateData* isolate_data, | |||
| 561 | 584 | JSMethod<&StreamBase::WriteString<LATIN1>>); | |
| 562 | 585 | t->PrototypeTemplate()->Set(FIXED_ONE_BYTE_STRING(isolate, "isStreamBase"), | |
| 563 | 586 | True(isolate)); | |
| 564 | - t->PrototypeTemplate()->SetAccessor( | ||
| 565 | - FIXED_ONE_BYTE_STRING(isolate, "onread"), | ||
| 566 | - BaseObject::InternalFieldGet<StreamBase::kOnReadFunctionField>, | ||
| 567 | - BaseObject::InternalFieldSet<StreamBase::kOnReadFunctionField, | ||
| 568 | - &Value::IsFunction>); | ||
| 587 | + AddAccessor(isolate, | ||
| 588 | + sig, | ||
| 589 | + static_cast<PropertyAttribute>(DontDelete | DontEnum), | ||
| 590 | + t, | ||
| 591 | + BaseObject::InternalFieldGet<StreamBase::kOnReadFunctionField>, | ||
| 592 | + BaseObject::InternalFieldSet<StreamBase::kOnReadFunctionField, | ||
| 593 | + &Value::IsFunction>, | ||
| 594 | + FIXED_ONE_BYTE_STRING(isolate, "onread")); | ||
| 569 | 595 | } | |
| 570 | 596 | ||
| 571 | 597 | void StreamBase::RegisterExternalReferences( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -413,6 +413,13 @@ class StreamBase : public StreamResource { | |||
| 413 | 413 | EmitToJSStreamListener default_listener_; | |
| 414 | 414 | ||
| 415 | 415 | void SetWriteResult(const StreamWriteResult& res); | |
| 416 | + static void AddAccessor(v8::Isolate* isolate, | ||
| 417 | + v8::Local<v8::Signature> sig, | ||
| 418 | + enum v8::PropertyAttribute attributes, | ||
| 419 | + v8::Local<v8::FunctionTemplate> t, | ||
| 420 | + JSMethodFunction* getter, | ||
| 421 | + JSMethodFunction* setter, | ||
| 422 | + v8::Local<v8::String> str); | ||
| 416 | 423 | static void AddMethod(v8::Isolate* isolate, | |
| 417 | 424 | v8::Local<v8::Signature> sig, | |
| 418 | 425 | enum v8::PropertyAttribute attributes, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments