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 #ifndef {{v8_class_name}}_h | 21 #ifndef {{v8_class_name}}_h |
| 22 #define {{v8_class_name}}_h | 22 #define {{v8_class_name}}_h |
| 23 | 23 |
| 24 {% if conditional_string %} | 24 {% if conditional_string %} |
| 25 #if {{conditional_string}} | 25 #if {{conditional_string}} |
| 26 {% endif %} | 26 {% endif %} |
| 27 {% for filename in header_includes %} | 27 {% for filename in header_includes %} |
| 28 #include "{{filename}}" | 28 #include "{{filename}}" |
| 29 {% endfor %} | 29 {% endfor %} |
| 30 | |
| 30 namespace WebCore { | 31 namespace WebCore { |
| 31 | 32 |
| 32 class {{v8_class_name}} { | 33 class {{v8_class_name}} { |
| 33 public: | 34 public: |
| 34 static bool HasInstance(v8::Handle<v8::Value>, v8::Isolate*, WrapperWorldTyp e); | 35 static bool HasInstance(v8::Handle<v8::Value>, v8::Isolate*, WrapperWorldTyp e); |
| 35 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); | 36 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); |
| 36 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor ldType); | 37 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor ldType); |
| 37 static {{cpp_class_name}}* toNative(v8::Handle<v8::Object> object) | 38 static {{cpp_class_name}}* toNative(v8::Handle<v8::Object> object) |
| 38 { | 39 { |
| 39 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8 DOMWrapperObjectIndex)); | 40 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8 DOMWrapperObjectIndex)); |
| 40 } | 41 } |
| 41 static void derefObject(void*); | 42 static void derefObject(void*); |
| 42 static WrapperTypeInfo info; | 43 static WrapperTypeInfo info; |
| 43 | |
| 44 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0 ; | 44 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0 ; |
| 45 | |
| 46 static inline void* toInternalPointer({{cpp_class_name}}* impl) | 45 static inline void* toInternalPointer({{cpp_class_name}}* impl) |
| 47 { | 46 { |
| 48 return impl; | 47 return impl; |
| 49 } | 48 } |
| 50 | 49 |
| 51 static inline {{cpp_class_name}}* fromInternalPointer(void* object) | 50 static inline {{cpp_class_name}}* fromInternalPointer(void* object) |
| 52 { | 51 { |
| 53 return static_cast<{{cpp_class_name}}*>(object); | 52 return static_cast<{{cpp_class_name}}*>(object); |
| 54 } | 53 } |
| 55 | |
| 56 static void installPerContextProperties(v8::Handle<v8::Object>, {{cpp_class_ name}}*, v8::Isolate*) { } | 54 static void installPerContextProperties(v8::Handle<v8::Object>, {{cpp_class_ name}}*, v8::Isolate*) { } |
| 57 static void installPerContextPrototypeProperties(v8::Handle<v8::Object>, v8: :Isolate*) { } | 55 static void installPerContextPrototypeProperties(v8::Handle<v8::Object>, v8: :Isolate*) { } |
| 58 | |
| 59 private: | 56 private: |
| 60 friend v8::Handle<v8::Object> wrap({{cpp_class_name}}*, v8::Handle<v8::Objec t> creationContext, v8::Isolate*); | 57 friend v8::Handle<v8::Object> wrap({{cpp_class_name}}*, v8::Handle<v8::Objec t> creationContext, v8::Isolate*); |
| 61 static v8::Handle<v8::Object> createWrapper(PassRefPtr<{{cpp_class_name}}>, v8::Handle<v8::Object> creationContext, v8::Isolate*); | 58 static v8::Handle<v8::Object> createWrapper(PassRefPtr<{{cpp_class_name}}>, v8::Handle<v8::Object> creationContext, v8::Isolate*); |
| 62 | |
| 63 }; | 59 }; |
| 64 | 60 |
| 65 template<> | 61 template<> |
| 66 class WrapperTypeTraits<{{cpp_class_name}} > { | 62 class WrapperTypeTraits<{{cpp_class_name}} > { |
| 67 public: | 63 public: |
| 68 static WrapperTypeInfo* info() { return &{{v8_class_name}}::info; } | 64 static WrapperTypeInfo* info() { return &{{v8_class_name}}::info; } |
| 69 }; | 65 }; |
| 70 | 66 |
| 67 | |
| 71 inline v8::Handle<v8::Object> wrap({{cpp_class_name}}* impl, v8::Handle<v8::Obje ct> creationContext, v8::Isolate* isolate) | 68 inline v8::Handle<v8::Object> wrap({{cpp_class_name}}* impl, v8::Handle<v8::Obje ct> creationContext, v8::Isolate* isolate) |
| 72 { | 69 { |
| 73 ASSERT(impl); | 70 ASSERT(impl); |
| 74 ASSERT(!DOMDataStore::containsWrapper<{{v8_class_name}}>(impl, isolate)); | 71 ASSERT(!DOMDataStore::containsWrapper<{{v8_class_name}}>(impl, isolate)); |
| 75 return {{v8_class_name}}::createWrapper(impl, creationContext, isolate); | 72 return {{v8_class_name}}::createWrapper(impl, creationContext, isolate); |
| 76 } | 73 } |
| 77 | 74 |
| 78 inline v8::Handle<v8::Value> toV8({{cpp_class_name}}* impl, v8::Handle<v8::Objec t> creationContext, v8::Isolate* isolate) | 75 inline v8::Handle<v8::Value> toV8({{cpp_class_name}}* impl, v8::Handle<v8::Objec t> creationContext, v8::Isolate* isolate) |
| 79 { | 76 { |
| 80 if (UNLIKELY(!impl)) | 77 if (UNLIKELY(!impl)) |
| 81 return v8NullWithCheck(isolate); | 78 return v8NullWithCheck(isolate); |
| 82 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper<{{v8_class_name}}>( impl, isolate); | 79 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper<{{v8_class_name}}>( impl, isolate); |
| 83 if (!wrapper.IsEmpty()) | 80 if (!wrapper.IsEmpty()) |
| 84 return wrapper; | 81 return wrapper; |
| 85 return wrap(impl, creationContext, isolate); | 82 return wrap(impl, creationContext, isolate); |
| 86 } | 83 } |
| 87 | 84 |
| 88 inline v8::Handle<v8::Value> toV8(PassRefPtr< {{cpp_class_name}} > impl, v8::Han dle<v8::Object> creationContext, v8::Isolate* isolate) | |
| 89 { | |
| 90 return toV8(impl.get(), creationContext, isolate); | |
| 91 } | |
| 92 | |
| 93 template<typename CallbackInfo> | 85 template<typename CallbackInfo> |
| 94 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class_name} }* impl, v8::Handle<v8::Object> creationContext) | 86 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class_name} }* impl, v8::Handle<v8::Object> creationContext) |
| 95 { | 87 { |
| 96 if (UNLIKELY(!impl)) { | 88 if (UNLIKELY(!impl)) { |
| 97 v8SetReturnValueNull(callbackInfo); | 89 v8SetReturnValueNull(callbackInfo); |
| 98 return; | 90 return; |
| 99 } | 91 } |
| 100 if (DOMDataStore::setReturnValueFromWrapper<{{v8_class_name}}>(callbackInfo. GetReturnValue(), impl)) | 92 if (DOMDataStore::setReturnValueFromWrapper<{{v8_class_name}}>(callbackInfo. GetReturnValue(), impl)) |
| 101 return; | 93 return; |
| 102 v8::Handle<v8::Object> wrapper = wrap(impl, creationContext, callbackInfo.Ge tIsolate()); | 94 v8::Handle<v8::Object> wrapper = wrap(impl, creationContext, callbackInfo.Ge tIsolate()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 117 v8SetReturnValue(callbackInfo, wrapper); | 109 v8SetReturnValue(callbackInfo, wrapper); |
| 118 } | 110 } |
| 119 | 111 |
| 120 template<class CallbackInfo, class Wrappable> | 112 template<class CallbackInfo, class Wrappable> |
| 121 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class_n ame}}* impl, Wrappable* wrappable) | 113 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class_n ame}}* impl, Wrappable* wrappable) |
| 122 { | 114 { |
| 123 if (UNLIKELY(!impl)) { | 115 if (UNLIKELY(!impl)) { |
| 124 v8SetReturnValueNull(callbackInfo); | 116 v8SetReturnValueNull(callbackInfo); |
| 125 return; | 117 return; |
| 126 } | 118 } |
| 127 if (DOMDataStore::setReturnValueFromWrapperFast<{{v8_class_name}}>(callbackI nfo.GetReturnValue(), impl, callbackInfo.GetHolder(), wrappable)) | 119 if (DOMDataStore::setReturnValueFromWrapperFast<{{v8_class_name}}>(callbackI nfo.GetReturnValue(), impl, callbackInfo.Holder(), wrappable)) |
| 128 return; | 120 return; |
| 129 v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackI nfo.GetIsolate()); | 121 v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackI nfo.GetIsolate()); |
| 130 v8SetReturnValue(callbackInfo, wrapper); | 122 v8SetReturnValue(callbackInfo, wrapper); |
| 131 } | 123 } |
| 132 | 124 |
| 125 | |
| 126 inline v8::Handle<v8::Value> toV8(PassRefPtr< {{cpp_class_name}} > impl, v8::Han dle<v8::Object> creationContext, v8::Isolate* isolate) | |
|
haraken
2013/08/22 07:31:33
Nit: You don't need a space before {{cpp_class_nam
Nils Barth (inactive)
2013/08/22 09:08:13
(Perl compatibility.)
| |
| 127 { | |
| 128 return toV8(impl.get(), creationContext, isolate); | |
| 129 } | |
| 130 | |
| 133 template<class CallbackInfo> | 131 template<class CallbackInfo> |
| 134 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, PassRefPtr<{{cpp_ class_name}}> impl, v8::Handle<v8::Object> creationContext) | 132 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, PassRefPtr< {{cpp _class_name}} > impl, v8::Handle<v8::Object> creationContext) |
| 135 { | 133 { |
| 136 v8SetReturnValue(callbackInfo, impl.get(), creationContext); | 134 v8SetReturnValue(callbackInfo, impl.get(), creationContext); |
| 137 } | 135 } |
| 138 | 136 |
| 139 template<class CallbackInfo> | 137 template<class CallbackInfo> |
| 140 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, PassR efPtr<{{cpp_class_name}}> impl, v8::Handle<v8::Object> creationContext) | 138 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, PassR efPtr< {{cpp_class_name}} > impl, v8::Handle<v8::Object> creationContext) |
| 141 { | 139 { |
| 142 v8SetReturnValueForMainWorld(callbackInfo, impl.get(), creationContext); | 140 v8SetReturnValueForMainWorld(callbackInfo, impl.get(), creationContext); |
| 143 } | 141 } |
| 144 | 142 |
| 145 template<class CallbackInfo, class Wrappable> | 143 template<class CallbackInfo, class Wrappable> |
| 146 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<{{ cpp_class_name}}> impl, Wrappable* wrappable) | 144 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr< { {cpp_class_name}} > impl, Wrappable* wrappable) |
| 147 { | 145 { |
| 148 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); | 146 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); |
| 149 } | 147 } |
| 150 | 148 |
| 151 } | 149 } |
| 150 {% if conditional_string %} | |
| 152 | 151 |
| 153 {% if conditional_string %} | |
| 154 #endif // {{conditional_string}} | 152 #endif // {{conditional_string}} |
| 155 {% endif %} | 153 {% endif %} |
| 156 | 154 |
| 157 #endif // {{v8_class_name}}_h | 155 #endif // {{v8_class_name}}_h |
| 156 | |
| OLD | NEW |