| Index: src/apinatives.js
|
| diff --git a/src/apinatives.js b/src/apinatives.js
|
| index 9bb52e2b7a007c5cf21ba4f7ce23d8c81aa569e6..50c753ec70e517aa38b1de60b5d6e02bf3e65b73 100644
|
| --- a/src/apinatives.js
|
| +++ b/src/apinatives.js
|
| @@ -30,10 +30,16 @@ function Instantiate(data, name) {
|
| var Constructor = %GetTemplateField(data, kApiConstructorOffset);
|
| // Note: Do not directly use a function template as a condition, our
|
| // internal ToBoolean doesn't handle that!
|
| - var result = typeof Constructor === 'undefined' ?
|
| - {} : new (Instantiate(Constructor))();
|
| - ConfigureTemplateInstance(result, data);
|
| - result = %ToFastProperties(result);
|
| + var result;
|
| + if (typeof Constructor === 'undefined') {
|
| + result = {};
|
| + ConfigureTemplateInstance(result, data);
|
| + } else {
|
| + // ConfigureTemplateInstance is implicitly called before calling the API
|
| + // constructor in HandleApiCall.
|
| + result = new (Instantiate(Constructor))();
|
| + result = %ToFastProperties(result);
|
| + }
|
| return result;
|
| default:
|
| throw 'Unknown API tag <' + tag + '>';
|
| @@ -93,15 +99,15 @@ function ConfigureTemplateInstance(obj, data) {
|
| var prop_data = properties[i + 2];
|
| var attributes = properties[i + 3];
|
| var value = Instantiate(prop_data, name);
|
| - %SetProperty(obj, name, value, attributes);
|
| + %AddProperty(obj, name, value, attributes);
|
| } else if (length == 4 || length == 5) {
|
| // TODO(verwaest): The 5th value used to be access_control. Remove once
|
| // the bindings are updated.
|
| var name = properties[i + 1];
|
| - var getter = properties[i + 2];
|
| - var setter = properties[i + 3];
|
| + var getter = Instantiate(properties[i + 2]);
|
| + var setter = Instantiate(properties[i + 3]);
|
| var attribute = properties[i + 4];
|
| - %SetAccessorProperty(obj, name, getter, setter, attribute);
|
| + %DefineAccessorPropertyUnchecked(obj, name, getter, setter, attribute);
|
| } else {
|
| throw "Bad properties array";
|
| }
|
|
|