| 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 10 matching lines...) Expand all  Loading... | 
| 49     WebCore::initializeScriptWrappableForInterface(object); | 51     WebCore::initializeScriptWrappableForInterface(object); | 
| 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 | 
|  | 61 {# ############################################## Attributes #} | 
| 59 {% for attribute in attributes %} | 62 {% for attribute in attributes %} | 
| 60 static void {{attribute.name}}AttrGetter(v8::Local<v8::String> name, const v8::P
     ropertyCallbackInfo<v8::Value>& info) | 63 {{attribute_getter(attribute) -}} | 
| 61 { | 64 {{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     v8::Handle<v8::Value> wrapper = result.get() ? v8::Handle<v8::Value>(DOMData
     Store::getWrapper<{{attribute.v8_type}}>(result.get(), info.GetIsolate())) : v8U
     ndefined(); |  | 
| 65     if (wrapper.IsEmpty()) { |  | 
| 66         wrapper = toV8(result.get(), info.Holder(), info.GetIsolate()); |  | 
| 67         if (!wrapper.IsEmpty()) |  | 
| 68             V8HiddenPropertyName::setNamedHiddenReference(info.Holder(), "{{attr
     ibute.name}}", wrapper); |  | 
| 69     } |  | 
| 70     v8SetReturnValue(info, wrapper); |  | 
| 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 | 65 } // namespace {{cpp_class_name}}V8Internal | 
| 83 | 66 | 
|  | 67 {# FIXME: pass a list of normal_attributes, instead of length and is_normal #} | 
| 84 {% if attributes %} | 68 {% if attributes %} | 
| 85 static const V8DOMConfiguration::BatchedAttribute {{v8_class_name}}Attributes[] 
     = { | 69 {{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 %} | 70 {% endif %} | 
| 92 | 71 {# WIP #} | 
| 93 | 72 {% if constants %} | 
|  | 73 {{class_consts()}} | 
|  | 74 {% endif %} | 
| 94 static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::H
     andle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType current
     WorldType) | 75 static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::H
     andle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType current
     WorldType) | 
| 95 { | 76 { | 
| 96     desc->ReadOnlyPrototype(); | 77     desc->ReadOnlyPrototype(); | 
| 97 | 78 | 
| 98     v8::Local<v8::Signature> defaultSignature; | 79     v8::Local<v8::Signature> defaultSignature; | 
| 99     defaultSignature = V8DOMConfiguration::configureTemplate(desc, "{{interface_
     name}}", v8::Local<v8::FunctionTemplate>(), {{v8_class_name}}::internalFieldCoun
     t, | 80     defaultSignature = V8DOMConfiguration::configureTemplate(desc, "{{interface_
     name}}", v8::Local<v8::FunctionTemplate>(), {{v8_class_name}}::internalFieldCoun
     t, | 
| 100         {{attribute_templates}}, {{number_of_attributes}}, | 81         {{attribute_templates}}, {{number_of_attributes}}, | 
| 101         0, 0, isolate, currentWorldType); | 82         0, 0, isolate, currentWorldType); | 
| 102     UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | 83     UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | 
|  | 84 {# WIP #} | 
|  | 85 {% if constants %} | 
|  | 86     v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | 
|  | 87     v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | 
|  | 88     UNUSED_PARAM(instance); // In some cases, it will not be used. | 
|  | 89     UNUSED_PARAM(proto); // In some cases, it will not be used. | 
|  | 90 {% endif %} | 
|  | 91 {% for constant in constants %}{{const_data(constant)}}{% endfor %} | 
|  | 92 {% if constants %} | 
|  | 93     {{batch_configure_constants()}} | 
|  | 94 {% endif %} | 
| 103 | 95 | 
| 104     // Custom toString template | 96     // Custom toString template | 
| 105     desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to
     StringTemplate()); | 97     desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to
     StringTemplate()); | 
| 106     return desc; | 98     return desc; | 
| 107 } | 99 } | 
| 108 | 100 | 
| 109 v8::Handle<v8::FunctionTemplate> {{v8_class_name}}::GetTemplate(v8::Isolate* iso
     late, WrapperWorldType currentWorldType) | 101 v8::Handle<v8::FunctionTemplate> {{v8_class_name}}::GetTemplate(v8::Isolate* iso
     late, WrapperWorldType currentWorldType) | 
| 110 { | 102 { | 
| 111     V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 103     V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 
| 112     V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
     rldType).find(&info); | 104     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); | 118     return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor
     ldType); | 
| 127 } | 119 } | 
| 128 | 120 | 
| 129 bool {{v8_class_name}}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::I
     solate* isolate) | 121 bool {{v8_class_name}}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::I
     solate* isolate) | 
| 130 { | 122 { | 
| 131     return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) | 123     return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) | 
| 132         || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo
     rld) | 124         || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo
     rld) | 
| 133         || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl
     d); | 125         || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl
     d); | 
| 134 } | 126 } | 
| 135 | 127 | 
|  | 128 | 
| 136 v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_n
     ame}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 129 v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_n
     ame}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 
| 137 { | 130 { | 
| 138     ASSERT(impl.get()); | 131     ASSERT(impl.get()); | 
| 139     ASSERT(DOMDataStore::getWrapper<{{v8_class_name}}>(impl.get(), isolate).IsEm
     pty()); | 132     ASSERT(DOMDataStore::getWrapper<{{v8_class_name}}>(impl.get(), isolate).IsEm
     pty()); | 
| 140     if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | 133     if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | 
| 141         const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
     ct(impl.get()); | 134         const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
     ct(impl.get()); | 
| 142         // Might be a XXXConstructor::info instead of an XXX::info. These will b
     oth have | 135         // 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. | 136         // 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); | 137         RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
      == info.derefObjectFunction); | 
| 145     } | 138     } | 
| 146 | 139 | 
|  | 140 | 
| 147     v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
     , &info, toInternalPointer(impl.get()), isolate); | 141     v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
     , &info, toInternalPointer(impl.get()), isolate); | 
| 148     if (UNLIKELY(wrapper.IsEmpty())) | 142     if (UNLIKELY(wrapper.IsEmpty())) | 
| 149         return wrapper; | 143         return wrapper; | 
| 150 |  | 
| 151     installPerContextProperties(wrapper, impl.get(), isolate); | 144     installPerContextProperties(wrapper, impl.get(), isolate); | 
| 152     V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &info, wra
     pper, isolate, WrapperConfiguration::Independent); | 145     V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &info, wra
     pper, isolate, WrapperConfiguration::Independent); | 
| 153     return wrapper; | 146     return wrapper; | 
| 154 } | 147 } | 
| 155 |  | 
| 156 void {{v8_class_name}}::derefObject(void* object) | 148 void {{v8_class_name}}::derefObject(void* object) | 
| 157 { | 149 { | 
| 158     fromInternalPointer(object)->deref(); | 150     fromInternalPointer(object)->deref(); | 
| 159 } | 151 } | 
| 160 | 152 | 
| 161 } // namespace WebCore | 153 } // namespace WebCore | 
|  | 154 {% if conditional_string %} | 
| 162 | 155 | 
| 163 {% if conditional_string %} |  | 
| 164 #endif // {{conditional_string}} | 156 #endif // {{conditional_string}} | 
| 165 {% endif %} | 157 {% endif %} | 
| 166 | 158 | 
| OLD | NEW | 
|---|