Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 This file is part of the Blink open source project. | 2 This file is part of the Blink open source project. |
| 3 This file has been auto-generated by CodeGeneratorV8.pm. DO NOT MODIFY! | 3 This file has been auto-generated by CodeGeneratorV8.pm. DO NOT MODIFY! |
| 4 | 4 |
| 5 This library is free software; you can redistribute it and/or | 5 This library is free software; you can redistribute it and/or |
| 6 modify it under the terms of the GNU Library General Public | 6 modify it under the terms of the GNU Library General Public |
| 7 License as published by the Free Software Foundation; either | 7 License as published by the Free Software Foundation; either |
| 8 version 2 of the License, or (at your option) any later version. | 8 version 2 of the License, or (at your option) any later version. |
| 9 | 9 |
| 10 This library is distributed in the hope that it will be useful, | 10 This library is distributed in the hope that it will be useful, |
| 11 but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 Library General Public License for more details. | 13 Library General Public License for more details. |
| 14 | 14 |
| 15 You should have received a copy of the GNU Library General Public License | 15 You should have received a copy of the GNU Library General Public License |
| 16 along with this library; see the file COPYING.LIB. If not, write to | 16 along with this library; see the file COPYING.LIB. If not, write to |
| 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 18 Boston, MA 02111-1307, USA. | 18 Boston, MA 02111-1307, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 {% from 'attributes.cpp' import attribute_getter, attribute_getter_callback, bat ched_attribute with context %} | |
| 22 {% from 'constants.cpp' import class_consts, const_data, batch_configure_constan ts with context %} | |
| 21 #include "config.h" | 23 #include "config.h" |
| 22 {% if conditional_string %} | 24 {% if conditional_string %} |
| 23 #if {{conditional_string}} | 25 #if {{conditional_string}} |
| 24 {% endif %} | 26 {% endif %} |
| 25 #include "{{v8_class_name}}.h" | 27 #include "{{v8_class_name}}.h" |
| 26 | 28 |
| 27 {% for filename in cpp_includes %} | 29 {% for filename in cpp_includes %} |
| 28 #include "{{ filename }}" | 30 #include "{{filename}}" |
| 29 {% endfor %} | 31 {% endfor %} |
| 30 | 32 |
| 31 namespace WebCore { | 33 namespace WebCore { |
| 32 | 34 |
| 33 static void initializeScriptWrappableForInterface({{cpp_class_name}}* object) | 35 static void initializeScriptWrappableForInterface({{cpp_class_name}}* object) |
| 34 { | 36 { |
| 35 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) | 37 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) |
| 36 ScriptWrappable::setTypeInfoInObject(object, &{{v8_class_name}}::info); | 38 ScriptWrappable::setTypeInfoInObject(object, &{{v8_class_name}}::info); |
| 37 else | 39 else |
| 38 ASSERT_NOT_REACHED(); | 40 ASSERT_NOT_REACHED(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 50 } | 52 } |
| 51 | 53 |
| 52 namespace WebCore { | 54 namespace WebCore { |
| 53 WrapperTypeInfo {{v8_class_name}}::info = { {{v8_class_name}}::GetTemplate, {{v8 _class_name}}::derefObject, 0, 0, 0, {{v8_class_name}}::installPerContextPrototy peProperties, 0, WrapperTypeObjectPrototype }; | 55 WrapperTypeInfo {{v8_class_name}}::info = { {{v8_class_name}}::GetTemplate, {{v8 _class_name}}::derefObject, 0, 0, 0, {{v8_class_name}}::installPerContextPrototy peProperties, 0, WrapperTypeObjectPrototype }; |
| 54 | 56 |
| 55 namespace {{cpp_class_name}}V8Internal { | 57 namespace {{cpp_class_name}}V8Internal { |
| 56 | 58 |
| 57 template <typename T> void V8_USE(T) { } | 59 template <typename T> void V8_USE(T) { } |
| 58 | 60 |
| 59 {% for attribute in attributes %} | 61 {% for attribute in attributes %} |
| 60 static void {{attribute.name}}AttrGetter(v8::Local<v8::String> name, const v8::P ropertyCallbackInfo<v8::Value>& info) | 62 {{attribute_getter(attribute) -}} |
|
haraken
2013/08/22 07:31:33
What is the '-' ?
Nils Barth (inactive)
2013/08/22 09:08:13
For whitespace control; see above.
One annoyance w
| |
| 61 { | 63 {{attribute_getter_callback(attribute)}}{% endfor %} |
| 62 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); | |
| 63 {{attribute.cpp_type}} result = imp->{{attribute.cpp_method_name}}(); | |
| 64 if (result.get() && DOMDataStore::setReturnValueFromWrapper<{{attribute.v8_t ype}}>(info.GetReturnValue(), result.get())) | |
| 65 return; | |
| 66 v8::Handle<v8::Value> wrapper = toV8(result.get(), info.Holder(), info.GetIs olate()); | |
| 67 if (!wrapper.IsEmpty()) { | |
| 68 V8HiddenPropertyName::setNamedHiddenReference(info.Holder(), "{{attribut e.name}}", wrapper); | |
| 69 v8SetReturnValue(info, wrapper); | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 static void {{attribute.name}}AttrGetterCallback(v8::Local<v8::String> name, con st v8::PropertyCallbackInfo<v8::Value>& info) | |
| 74 { | |
| 75 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | |
| 76 {{cpp_class_name}}V8Internal::{{attribute.name}}AttrGetter(name, info); | |
| 77 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | |
| 78 } | |
| 79 | |
| 80 {% endfor %} | |
| 81 | |
| 82 } // namespace {{cpp_class_name}}V8Internal | 64 } // namespace {{cpp_class_name}}V8Internal |
| 83 | 65 |
| 84 {% if attributes %} | 66 {% if attributes %} |
| 85 static const V8DOMConfiguration::BatchedAttribute {{v8_class_name}}Attributes[] = { | 67 {{batched_attribute()}} |
| 86 {% for attribute in attributes %} | |
| 87 {"{{attribute.name}}", {{cpp_class_name}}V8Internal::{{attribute.name}}AttrG etterCallback, 0, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFA ULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, | |
| 88 {% endfor %} | |
| 89 }; | |
| 90 | |
| 91 {% endif %} | 68 {% endif %} |
| 92 | 69 {% if constants %} |
| 93 | 70 {{class_consts()}} |
| 71 {% endif %} | |
| 94 static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::H andle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType current WorldType) | 72 static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::H andle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType current WorldType) |
| 95 { | 73 { |
| 96 desc->ReadOnlyPrototype(); | 74 desc->ReadOnlyPrototype(); |
| 97 | 75 |
| 98 v8::Local<v8::Signature> defaultSignature; | 76 v8::Local<v8::Signature> defaultSignature; |
| 99 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "{{interface_ name}}", v8::Local<v8::FunctionTemplate>(), {{v8_class_name}}::internalFieldCoun t, | 77 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "{{interface_ name}}", v8::Local<v8::FunctionTemplate>(), {{v8_class_name}}::internalFieldCoun t, |
| 100 {{attribute_templates}}, {{number_of_attributes}}, | 78 {{attribute_templates}}, {{number_of_attributes}}, |
| 101 0, 0, isolate, currentWorldType); | 79 0, 0, isolate, currentWorldType); |
| 102 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | 80 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. |
| 81 {% if constants %} | |
| 82 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | |
| 83 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | |
| 84 UNUSED_PARAM(instance); // In some cases, it will not be used. | |
| 85 UNUSED_PARAM(proto); // In some cases, it will not be used. | |
| 86 {% endif %} | |
| 87 {% for constant in constants %}{{const_data(constant)}}{% endfor %} | |
| 88 {% if constants %} | |
| 89 {{batch_configure_constants()}} | |
| 90 {% endif %} | |
| 103 | 91 |
| 104 // Custom toString template | 92 // Custom toString template |
| 105 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate()); | 93 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate()); |
| 106 return desc; | 94 return desc; |
| 107 } | 95 } |
| 108 | 96 |
| 109 v8::Handle<v8::FunctionTemplate> {{v8_class_name}}::GetTemplate(v8::Isolate* iso late, WrapperWorldType currentWorldType) | 97 v8::Handle<v8::FunctionTemplate> {{v8_class_name}}::GetTemplate(v8::Isolate* iso late, WrapperWorldType currentWorldType) |
| 110 { | 98 { |
| 111 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 99 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 112 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&info); | 100 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&info); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 126 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor ldType); | 114 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor ldType); |
| 127 } | 115 } |
| 128 | 116 |
| 129 bool {{v8_class_name}}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::I solate* isolate) | 117 bool {{v8_class_name}}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::I solate* isolate) |
| 130 { | 118 { |
| 131 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) | 119 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) |
| 132 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld) | 120 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld) |
| 133 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d); | 121 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d); |
| 134 } | 122 } |
| 135 | 123 |
| 124 | |
|
haraken
2013/08/22 07:31:33
Nit: Unnecessary empty line.
Nils Barth (inactive)
2013/08/22 09:08:13
(Perl.)
| |
| 136 v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_n ame}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 125 v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_n ame}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
| 137 { | 126 { |
| 138 ASSERT(impl.get()); | 127 ASSERT(impl.get()); |
| 139 ASSERT(!DOMDataStore::containsWrapper<{{v8_class_name}}>(impl.get(), isolate )); | 128 ASSERT(!DOMDataStore::containsWrapper<{{v8_class_name}}>(impl.get(), isolate )); |
| 140 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | 129 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { |
| 141 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get()); | 130 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get()); |
| 142 // Might be a XXXConstructor::info instead of an XXX::info. These will b oth have | 131 // Might be a XXXConstructor::info instead of an XXX::info. These will b oth have |
| 143 // the same object de-ref functions, though, so use that as the basis of the check. | 132 // the same object de-ref functions, though, so use that as the basis of the check. |
| 144 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == info.derefObjectFunction); | 133 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == info.derefObjectFunction); |
| 145 } | 134 } |
| 146 | 135 |
| 136 | |
|
haraken
2013/08/22 07:31:33
Ditto.
Nils Barth (inactive)
2013/08/22 09:08:13
(Perl.)
| |
| 147 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &info, toInternalPointer(impl.get()), isolate); | 137 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &info, toInternalPointer(impl.get()), isolate); |
| 148 if (UNLIKELY(wrapper.IsEmpty())) | 138 if (UNLIKELY(wrapper.IsEmpty())) |
| 149 return wrapper; | 139 return wrapper; |
| 150 | |
| 151 installPerContextProperties(wrapper, impl.get(), isolate); | 140 installPerContextProperties(wrapper, impl.get(), isolate); |
| 152 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &info, wra pper, isolate, WrapperConfiguration::Independent); | 141 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &info, wra pper, isolate, WrapperConfiguration::Independent); |
| 153 return wrapper; | 142 return wrapper; |
| 154 } | 143 } |
| 155 | |
|
haraken
2013/08/22 07:31:33
Nit: This empty line would be needed.
Nils Barth (inactive)
2013/08/22 09:08:13
(Perl.)
| |
| 156 void {{v8_class_name}}::derefObject(void* object) | 144 void {{v8_class_name}}::derefObject(void* object) |
| 157 { | 145 { |
| 158 fromInternalPointer(object)->deref(); | 146 fromInternalPointer(object)->deref(); |
| 159 } | 147 } |
| 160 | 148 |
| 161 } // namespace WebCore | 149 } // namespace WebCore |
| 150 {% if conditional_string %} | |
| 162 | 151 |
| 163 {% if conditional_string %} | |
| 164 #endif // {{conditional_string}} | 152 #endif // {{conditional_string}} |
| 165 {% endif %} | 153 {% endif %} |
| OLD | NEW |