Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
chakrashim: add shim for Template::SetAccessorProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
boingoing authored and kfarnung committed Jan 19, 2018
1 parent bed3bf9 commit c3abf1c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
8 changes: 8 additions & 0 deletions deps/chakrashim/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -2246,6 +2246,14 @@ class V8_EXPORT Template : public Data {
V8_INLINE void Set(Isolate* isolate, const char* name, Local<Data> value) {
Set(v8::String::NewFromUtf8(isolate, name), value);
}

void SetAccessorProperty(
Local<Name> name,
Local<FunctionTemplate> getter = Local<FunctionTemplate>(),
Local<FunctionTemplate> setter = Local<FunctionTemplate>(),
PropertyAttribute attribute = None,
AccessControl settings = DEFAULT);

private:
Template();
};
Expand Down
31 changes: 26 additions & 5 deletions deps/chakrashim/src/v8template.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,41 @@ namespace v8 {
Template::Template() {
}

void Template::Set(
Local<Name> name, Local<Data> value, PropertyAttribute attributes) {
Object* GetTemplateProperties(Template* const templ) {
ExternalData* externalData = nullptr;
if (!ExternalData::TryGet(this, &externalData)) {
if (!ExternalData::TryGet(templ, &externalData)) {
// This should never happen
CHAKRA_ASSERT(false);
return;
return nullptr;
}

TemplateData *templateData = static_cast<TemplateData*>(externalData);
Object* properties = templateData->EnsureProperties();
return templateData->EnsureProperties();
}

void Template::Set(
Local<Name> name, Local<Data> value, PropertyAttribute attributes) {
Object* properties = GetTemplateProperties(this);
if (properties != nullptr) {
properties->ForceSet(name, value.As<Value>(), attributes);
}
}

void Template::SetAccessorProperty(
Local<Name> name,
Local<FunctionTemplate> getter,
Local<FunctionTemplate> setter,
PropertyAttribute attribute,
AccessControl access_control) {
Object* properties = GetTemplateProperties(this);
if (properties != nullptr) {
properties->SetAccessorProperty(
name,
getter->GetFunction(),
setter->GetFunction(),
attribute,
access_control);
}
}

} // namespace v8

0 comments on commit c3abf1c

Please sign in to comment.