| OLD | NEW |
| 1 {# http://www.chromium.org/blink/coding-style#TOC-License #} | 1 {# http://www.chromium.org/blink/coding-style#TOC-License #} |
| 2 /* | 2 /* |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 return static_cast<{{cpp_class}}*>(object); | 90 return static_cast<{{cpp_class}}*>(object); |
| 91 } | 91 } |
| 92 static void installPerContextEnabledProperties(v8::Handle<v8::Object>, {{cpp
_class}}*, v8::Isolate*){% if has_per_context_enabled_attributes %}; | 92 static void installPerContextEnabledProperties(v8::Handle<v8::Object>, {{cpp
_class}}*, v8::Isolate*){% if has_per_context_enabled_attributes %}; |
| 93 {% else %} { } | 93 {% else %} { } |
| 94 {% endif %} | 94 {% endif %} |
| 95 static void installPerContextEnabledMethods(v8::Handle<v8::Object>, v8::Isol
ate*){% if has_per_context_enabled_attributes %}; | 95 static void installPerContextEnabledMethods(v8::Handle<v8::Object>, v8::Isol
ate*){% if has_per_context_enabled_attributes %}; |
| 96 {% else %} { } | 96 {% else %} { } |
| 97 {% endif %} | 97 {% endif %} |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 {% if not has_custom_to_v8 %} |
| 100 friend v8::Handle<v8::Object> wrap({{cpp_class}}*, v8::Handle<v8::Object> cr
eationContext, v8::Isolate*); | 101 friend v8::Handle<v8::Object> wrap({{cpp_class}}*, v8::Handle<v8::Object> cr
eationContext, v8::Isolate*); |
| 101 static v8::Handle<v8::Object> createWrapper(PassRefPtr<{{cpp_class}}>, v8::H
andle<v8::Object> creationContext, v8::Isolate*); | 102 static v8::Handle<v8::Object> createWrapper(PassRefPtr<{{cpp_class}}>, v8::H
andle<v8::Object> creationContext, v8::Isolate*); |
| 103 {% endif %} |
| 102 }; | 104 }; |
| 103 | 105 |
| 104 template<> | 106 template<> |
| 105 class WrapperTypeTraits<{{cpp_class}} > { | 107 class WrapperTypeTraits<{{cpp_class}} > { |
| 106 public: | 108 public: |
| 107 static const WrapperTypeInfo* wrapperTypeInfo() { return &{{v8_class}}::wrap
perTypeInfo; } | 109 static const WrapperTypeInfo* wrapperTypeInfo() { return &{{v8_class}}::wrap
perTypeInfo; } |
| 108 }; | 110 }; |
| 109 | 111 |
| 112 {% if has_custom_to_v8 %} |
| 113 class {{cpp_class}}; |
| 114 v8::Handle<v8::Value> toV8({{cpp_class}}*, v8::Handle<v8::Object> creationContex
t, v8::Isolate*); |
| 115 |
| 116 template<class CallbackInfo> |
| 117 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* im
pl) |
| 118 { |
| 119 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); |
| 120 } |
| 121 |
| 122 template<class CallbackInfo> |
| 123 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp
_class}}* impl) |
| 124 { |
| 125 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackIn
fo.GetIsolate())); |
| 126 } |
| 127 |
| 128 template<class CallbackInfo, class Wrappable> |
| 129 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}
* impl, Wrappable*) |
| 130 { |
| 131 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackIn
fo.GetIsolate())); |
| 132 } |
| 133 {% else %}{# has_custom_to_v8 #} |
| 110 {% if has_custom_wrap %} | 134 {% if has_custom_wrap %} |
| 111 v8::Handle<v8::Object> wrap({{cpp_class}}* impl, v8::Handle<v8::Object> creation
Context, v8::Isolate*); | 135 v8::Handle<v8::Object> wrap({{cpp_class}}* impl, v8::Handle<v8::Object> creation
Context, v8::Isolate*); |
| 112 {% else %} | 136 {% else %} |
| 113 inline v8::Handle<v8::Object> wrap({{cpp_class}}* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) | 137 inline v8::Handle<v8::Object> wrap({{cpp_class}}* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) |
| 114 { | 138 { |
| 115 ASSERT(impl); | 139 ASSERT(impl); |
| 116 ASSERT(!DOMDataStore::containsWrapper<{{v8_class}}>(impl, isolate)); | 140 ASSERT(!DOMDataStore::containsWrapper<{{v8_class}}>(impl, isolate)); |
| 117 return {{v8_class}}::createWrapper(impl, creationContext, isolate); | 141 return {{v8_class}}::createWrapper(impl, creationContext, isolate); |
| 118 } | 142 } |
| 119 {% endif %} | 143 {% endif %} |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 { | 184 { |
| 161 if (UNLIKELY(!impl)) { | 185 if (UNLIKELY(!impl)) { |
| 162 v8SetReturnValueNull(callbackInfo); | 186 v8SetReturnValueNull(callbackInfo); |
| 163 return; | 187 return; |
| 164 } | 188 } |
| 165 if (DOMDataStore::setReturnValueFromWrapperFast<{{v8_class}}>(callbackInfo.G
etReturnValue(), impl, callbackInfo.Holder(), wrappable)) | 189 if (DOMDataStore::setReturnValueFromWrapperFast<{{v8_class}}>(callbackInfo.G
etReturnValue(), impl, callbackInfo.Holder(), wrappable)) |
| 166 return; | 190 return; |
| 167 v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackI
nfo.GetIsolate()); | 191 v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackI
nfo.GetIsolate()); |
| 168 v8SetReturnValue(callbackInfo, wrapper); | 192 v8SetReturnValue(callbackInfo, wrapper); |
| 169 } | 193 } |
| 194 {% endif %}{# has_custom_to_v8 #} |
| 170 | 195 |
| 171 inline v8::Handle<v8::Value> toV8(PassRefPtr<{{cpp_class}} > impl, v8::Handle<v8
::Object> creationContext, v8::Isolate* isolate) | 196 inline v8::Handle<v8::Value> toV8(PassRefPtr<{{cpp_class}} > impl, v8::Handle<v8
::Object> creationContext, v8::Isolate* isolate) |
| 172 { | 197 { |
| 173 return toV8(impl.get(), creationContext, isolate); | 198 return toV8(impl.get(), creationContext, isolate); |
| 174 } | 199 } |
| 175 | 200 |
| 176 template<class CallbackInfo> | 201 template<class CallbackInfo> |
| 177 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, PassRefPtr<{{cpp_
class}} > impl) | 202 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, PassRefPtr<{{cpp_
class}} > impl) |
| 178 { | 203 { |
| 179 v8SetReturnValue(callbackInfo, impl.get()); | 204 v8SetReturnValue(callbackInfo, impl.get()); |
| 180 } | 205 } |
| 181 | 206 |
| 182 template<class CallbackInfo> | 207 template<class CallbackInfo> |
| 183 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, PassR
efPtr<{{cpp_class}} > impl) | 208 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, PassR
efPtr<{{cpp_class}} > impl) |
| 184 { | 209 { |
| 185 v8SetReturnValueForMainWorld(callbackInfo, impl.get()); | 210 v8SetReturnValueForMainWorld(callbackInfo, impl.get()); |
| 186 } | 211 } |
| 187 | 212 |
| 188 template<class CallbackInfo, class Wrappable> | 213 template<class CallbackInfo, class Wrappable> |
| 189 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<{{
cpp_class}} > impl, Wrappable* wrappable) | 214 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<{{
cpp_class}} > impl, Wrappable* wrappable) |
| 190 { | 215 { |
| 191 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); | 216 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); |
| 192 } | 217 } |
| 193 | 218 |
| 194 } | 219 } |
| 195 {% endfilter %} | 220 {% endfilter %} |
| 196 #endif // {{v8_class}}_h | 221 #endif // {{v8_class}}_h |
| OLD | NEW |