Commit e1674a24 authored by jochen's avatar jochen Committed by Commit bot

Revert of [api] Restrict Template::Set to take templates or primitive values...

Revert of [api] Restrict Template::Set to take templates or primitive values (patchset #1 id:1 of https://codereview.chromium.org/1839983002/ )

Reason for revert:
Breaks node.js

Original issue's description:
> [api] Restrict Template::Set to take templates or primitive values
>
> Embedders that passed in non-primitive values should either use
> getters/setters (templates) or install a native data property,
> otherwise, the values would all result in cross-context leaks
>
> BUG=none
> R=verwaest@chromium.org
> LOG=y
>
> Committed: https://crrev.com/eebdee8eafa97849cc70c25f3fecf1b075bac248
> Cr-Commit-Position: refs/heads/master@{#35244}

TBR=verwaest@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=none

Review URL: https://codereview.chromium.org/1860003002

Cr-Commit-Position: refs/heads/master@{#35264}
parent 0ce296f1
...@@ -4111,11 +4111,7 @@ enum Intrinsic { ...@@ -4111,11 +4111,7 @@ enum Intrinsic {
*/ */
class V8_EXPORT Template : public Data { class V8_EXPORT Template : public Data {
public: public:
/** /** Adds a property to each instance created by this template.*/
* Adds a property to each instance created by this template.
*
* The property must be defined either as a primitive value, or a template.
*/
void Set(Local<Name> name, Local<Data> value, void Set(Local<Name> name, Local<Data> value,
PropertyAttribute attributes = None); PropertyAttribute attributes = None);
V8_INLINE void Set(Isolate* isolate, const char* name, Local<Data> value); V8_INLINE void Set(Isolate* isolate, const char* name, Local<Data> value);
......
...@@ -1028,13 +1028,13 @@ void Template::Set(v8::Local<Name> name, v8::Local<Data> value, ...@@ -1028,13 +1028,13 @@ void Template::Set(v8::Local<Name> name, v8::Local<Data> value,
ENTER_V8(isolate); ENTER_V8(isolate);
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
auto value_obj = Utils::OpenHandle(*value); auto value_obj = Utils::OpenHandle(*value);
CHECK(!value_obj->IsJSReceiver() || value_obj->IsTemplateInfo());
if (value_obj->IsObjectTemplateInfo()) { if (value_obj->IsObjectTemplateInfo()) {
templ->set_serial_number(i::Smi::FromInt(0)); templ->set_serial_number(i::Smi::FromInt(0));
if (templ->IsFunctionTemplateInfo()) { if (templ->IsFunctionTemplateInfo()) {
i::Handle<i::FunctionTemplateInfo>::cast(templ)->set_do_not_cache(true); i::Handle<i::FunctionTemplateInfo>::cast(templ)->set_do_not_cache(true);
} }
} }
// TODO(dcarney): split api to allow values of v8::Value or v8::TemplateInfo.
i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name),
value_obj, value_obj,
static_cast<i::PropertyAttributes>(attribute)); static_cast<i::PropertyAttributes>(attribute));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment