| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! | |
| 6 | |
| 7 #ifndef UnionTypeCore_h | |
| 8 #define UnionTypeCore_h | |
| 9 | |
| 10 #include "bindings/core/v8/Dictionary.h" | |
| 11 #include "bindings/core/v8/ExceptionState.h" | |
| 12 #include "bindings/core/v8/V8Binding.h" | |
| 13 #include "bindings/core/v8/V8TestDictionary.h" | |
| 14 #include "core/CoreExport.h" | |
| 15 #include "platform/heap/Handle.h" | |
| 16 | |
| 17 namespace blink { | |
| 18 | |
| 19 class DOMUint8Array; | |
| 20 class Node; | |
| 21 class NodeList; | |
| 22 class TestArrayBuffer; | |
| 23 class TestArrayBufferView; | |
| 24 class TestInterface2; | |
| 25 class TestInterfaceEmpty; | |
| 26 class TestInterfaceGarbageCollected; | |
| 27 class TestInterfaceImplementation; | |
| 28 | |
| 29 class CORE_EXPORT ArrayBufferOrArrayBufferViewOrDictionary final { | |
| 30 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 31 public: | |
| 32 ArrayBufferOrArrayBufferViewOrDictionary(); | |
| 33 bool isNull() const { return m_type == SpecificTypeNone; } | |
| 34 | |
| 35 bool isArrayBuffer() const { return m_type == SpecificTypeArrayBuffer; } | |
| 36 TestArrayBuffer* getAsArrayBuffer() const; | |
| 37 void setArrayBuffer(TestArrayBuffer*); | |
| 38 static ArrayBufferOrArrayBufferViewOrDictionary fromArrayBuffer(TestArrayBuf
fer*); | |
| 39 | |
| 40 bool isArrayBufferView() const { return m_type == SpecificTypeArrayBufferVie
w; } | |
| 41 TestArrayBufferView* getAsArrayBufferView() const; | |
| 42 void setArrayBufferView(TestArrayBufferView*); | |
| 43 static ArrayBufferOrArrayBufferViewOrDictionary fromArrayBufferView(TestArra
yBufferView*); | |
| 44 | |
| 45 bool isDictionary() const { return m_type == SpecificTypeDictionary; } | |
| 46 Dictionary getAsDictionary() const; | |
| 47 void setDictionary(Dictionary); | |
| 48 static ArrayBufferOrArrayBufferViewOrDictionary fromDictionary(Dictionary); | |
| 49 | |
| 50 ArrayBufferOrArrayBufferViewOrDictionary(const ArrayBufferOrArrayBufferViewO
rDictionary&); | |
| 51 ~ArrayBufferOrArrayBufferViewOrDictionary(); | |
| 52 ArrayBufferOrArrayBufferViewOrDictionary& operator=(const ArrayBufferOrArray
BufferViewOrDictionary&); | |
| 53 DECLARE_TRACE(); | |
| 54 | |
| 55 private: | |
| 56 enum SpecificTypes { | |
| 57 SpecificTypeNone, | |
| 58 SpecificTypeArrayBuffer, | |
| 59 SpecificTypeArrayBufferView, | |
| 60 SpecificTypeDictionary, | |
| 61 }; | |
| 62 SpecificTypes m_type; | |
| 63 | |
| 64 Member<TestArrayBuffer> m_arrayBuffer; | |
| 65 Member<TestArrayBufferView> m_arrayBufferView; | |
| 66 Dictionary m_dictionary; | |
| 67 | |
| 68 friend CORE_EXPORT v8::Local<v8::Value> toV8(const ArrayBufferOrArrayBufferV
iewOrDictionary&, v8::Local<v8::Object>, v8::Isolate*); | |
| 69 }; | |
| 70 | |
| 71 class V8ArrayBufferOrArrayBufferViewOrDictionary final { | |
| 72 public: | |
| 73 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, ArrayBuff
erOrArrayBufferViewOrDictionary&, UnionTypeConversionMode, ExceptionState&); | |
| 74 }; | |
| 75 | |
| 76 CORE_EXPORT v8::Local<v8::Value> toV8(const ArrayBufferOrArrayBufferViewOrDictio
nary&, v8::Local<v8::Object>, v8::Isolate*); | |
| 77 | |
| 78 template <class CallbackInfo> | |
| 79 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, ArrayBufferOrArra
yBufferViewOrDictionary& impl) | |
| 80 { | |
| 81 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
| 82 } | |
| 83 | |
| 84 template <> | |
| 85 struct NativeValueTraits<ArrayBufferOrArrayBufferViewOrDictionary> { | |
| 86 CORE_EXPORT static ArrayBufferOrArrayBufferViewOrDictionary nativeValue(v8::
Isolate*, v8::Local<v8::Value>, ExceptionState&); | |
| 87 }; | |
| 88 | |
| 89 class CORE_EXPORT BooleanOrStringOrUnrestrictedDouble final { | |
| 90 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 91 public: | |
| 92 BooleanOrStringOrUnrestrictedDouble(); | |
| 93 bool isNull() const { return m_type == SpecificTypeNone; } | |
| 94 | |
| 95 bool isBoolean() const { return m_type == SpecificTypeBoolean; } | |
| 96 bool getAsBoolean() const; | |
| 97 void setBoolean(bool); | |
| 98 static BooleanOrStringOrUnrestrictedDouble fromBoolean(bool); | |
| 99 | |
| 100 bool isString() const { return m_type == SpecificTypeString; } | |
| 101 String getAsString() const; | |
| 102 void setString(String); | |
| 103 static BooleanOrStringOrUnrestrictedDouble fromString(String); | |
| 104 | |
| 105 bool isUnrestrictedDouble() const { return m_type == SpecificTypeUnrestricte
dDouble; } | |
| 106 double getAsUnrestrictedDouble() const; | |
| 107 void setUnrestrictedDouble(double); | |
| 108 static BooleanOrStringOrUnrestrictedDouble fromUnrestrictedDouble(double); | |
| 109 | |
| 110 BooleanOrStringOrUnrestrictedDouble(const BooleanOrStringOrUnrestrictedDoubl
e&); | |
| 111 ~BooleanOrStringOrUnrestrictedDouble(); | |
| 112 BooleanOrStringOrUnrestrictedDouble& operator=(const BooleanOrStringOrUnrest
rictedDouble&); | |
| 113 DECLARE_TRACE(); | |
| 114 | |
| 115 private: | |
| 116 enum SpecificTypes { | |
| 117 SpecificTypeNone, | |
| 118 SpecificTypeBoolean, | |
| 119 SpecificTypeString, | |
| 120 SpecificTypeUnrestrictedDouble, | |
| 121 }; | |
| 122 SpecificTypes m_type; | |
| 123 | |
| 124 bool m_boolean; | |
| 125 String m_string; | |
| 126 double m_unrestrictedDouble; | |
| 127 | |
| 128 friend CORE_EXPORT v8::Local<v8::Value> toV8(const BooleanOrStringOrUnrestri
ctedDouble&, v8::Local<v8::Object>, v8::Isolate*); | |
| 129 }; | |
| 130 | |
| 131 class V8BooleanOrStringOrUnrestrictedDouble final { | |
| 132 public: | |
| 133 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, BooleanOr
StringOrUnrestrictedDouble&, UnionTypeConversionMode, ExceptionState&); | |
| 134 }; | |
| 135 | |
| 136 CORE_EXPORT v8::Local<v8::Value> toV8(const BooleanOrStringOrUnrestrictedDouble&
, v8::Local<v8::Object>, v8::Isolate*); | |
| 137 | |
| 138 template <class CallbackInfo> | |
| 139 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, BooleanOrStringOr
UnrestrictedDouble& impl) | |
| 140 { | |
| 141 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
| 142 } | |
| 143 | |
| 144 template <> | |
| 145 struct NativeValueTraits<BooleanOrStringOrUnrestrictedDouble> { | |
| 146 CORE_EXPORT static BooleanOrStringOrUnrestrictedDouble nativeValue(v8::Isola
te*, v8::Local<v8::Value>, ExceptionState&); | |
| 147 }; | |
| 148 | |
| 149 class CORE_EXPORT DoubleOrString final { | |
| 150 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 151 public: | |
| 152 DoubleOrString(); | |
| 153 bool isNull() const { return m_type == SpecificTypeNone; } | |
| 154 | |
| 155 bool isDouble() const { return m_type == SpecificTypeDouble; } | |
| 156 double getAsDouble() const; | |
| 157 void setDouble(double); | |
| 158 static DoubleOrString fromDouble(double); | |
| 159 | |
| 160 bool isString() const { return m_type == SpecificTypeString; } | |
| 161 String getAsString() const; | |
| 162 void setString(String); | |
| 163 static DoubleOrString fromString(String); | |
| 164 | |
| 165 DoubleOrString(const DoubleOrString&); | |
| 166 ~DoubleOrString(); | |
| 167 DoubleOrString& operator=(const DoubleOrString&); | |
| 168 DECLARE_TRACE(); | |
| 169 | |
| 170 private: | |
| 171 enum SpecificTypes { | |
| 172 SpecificTypeNone, | |
| 173 SpecificTypeDouble, | |
| 174 SpecificTypeString, | |
| 175 }; | |
| 176 SpecificTypes m_type; | |
| 177 | |
| 178 double m_double; | |
| 179 String m_string; | |
| 180 | |
| 181 friend CORE_EXPORT v8::Local<v8::Value> toV8(const DoubleOrString&, v8::Loca
l<v8::Object>, v8::Isolate*); | |
| 182 }; | |
| 183 | |
| 184 class V8DoubleOrString final { | |
| 185 public: | |
| 186 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, DoubleOrS
tring&, UnionTypeConversionMode, ExceptionState&); | |
| 187 }; | |
| 188 | |
| 189 CORE_EXPORT v8::Local<v8::Value> toV8(const DoubleOrString&, v8::Local<v8::Objec
t>, v8::Isolate*); | |
| 190 | |
| 191 template <class CallbackInfo> | |
| 192 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, DoubleOrString& i
mpl) | |
| 193 { | |
| 194 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
| 195 } | |
| 196 | |
| 197 template <> | |
| 198 struct NativeValueTraits<DoubleOrString> { | |
| 199 CORE_EXPORT static DoubleOrString nativeValue(v8::Isolate*, v8::Local<v8::Va
lue>, ExceptionState&); | |
| 200 }; | |
| 201 | |
| 202 class CORE_EXPORT LongOrTestDictionary final { | |
| 203 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 204 public: | |
| 205 LongOrTestDictionary(); | |
| 206 bool isNull() const { return m_type == SpecificTypeNone; } | |
| 207 | |
| 208 bool isLong() const { return m_type == SpecificTypeLong; } | |
| 209 int getAsLong() const; | |
| 210 void setLong(int); | |
| 211 static LongOrTestDictionary fromLong(int); | |
| 212 | |
| 213 bool isTestDictionary() const { return m_type == SpecificTypeTestDictionary;
} | |
| 214 TestDictionary getAsTestDictionary() const; | |
| 215 void setTestDictionary(TestDictionary); | |
| 216 static LongOrTestDictionary fromTestDictionary(TestDictionary); | |
| 217 | |
| 218 LongOrTestDictionary(const LongOrTestDictionary&); | |
| 219 ~LongOrTestDictionary(); | |
| 220 LongOrTestDictionary& operator=(const LongOrTestDictionary&); | |
| 221 DECLARE_TRACE(); | |
| 222 | |
| 223 private: | |
| 224 enum SpecificTypes { | |
| 225 SpecificTypeNone, | |
| 226 SpecificTypeLong, | |
| 227 SpecificTypeTestDictionary, | |
| 228 }; | |
| 229 SpecificTypes m_type; | |
| 230 | |
| 231 int m_long; | |
| 232 TestDictionary m_testDictionary; | |
| 233 | |
| 234 friend CORE_EXPORT v8::Local<v8::Value> toV8(const LongOrTestDictionary&, v8
::Local<v8::Object>, v8::Isolate*); | |
| 235 }; | |
| 236 | |
| 237 class V8LongOrTestDictionary final { | |
| 238 public: | |
| 239 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, LongOrTes
tDictionary&, UnionTypeConversionMode, ExceptionState&); | |
| 240 }; | |
| 241 | |
| 242 CORE_EXPORT v8::Local<v8::Value> toV8(const LongOrTestDictionary&, v8::Local<v8:
:Object>, v8::Isolate*); | |
| 243 | |
| 244 template <class CallbackInfo> | |
| 245 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, LongOrTestDiction
ary& impl) | |
| 246 { | |
| 247 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
| 248 } | |
| 249 | |
| 250 template <> | |
| 251 struct NativeValueTraits<LongOrTestDictionary> { | |
| 252 CORE_EXPORT static LongOrTestDictionary nativeValue(v8::Isolate*, v8::Local<
v8::Value>, ExceptionState&); | |
| 253 }; | |
| 254 | |
| 255 class CORE_EXPORT NodeOrNodeList final { | |
| 256 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 257 public: | |
| 258 NodeOrNodeList(); | |
| 259 bool isNull() const { return m_type == SpecificTypeNone; } | |
| 260 | |
| 261 bool isNode() const { return m_type == SpecificTypeNode; } | |
| 262 Node* getAsNode() const; | |
| 263 void setNode(Node*); | |
| 264 static NodeOrNodeList fromNode(Node*); | |
| 265 | |
| 266 bool isNodeList() const { return m_type == SpecificTypeNodeList; } | |
| 267 NodeList* getAsNodeList() const; | |
| 268 void setNodeList(NodeList*); | |
| 269 static NodeOrNodeList fromNodeList(NodeList*); | |
| 270 | |
| 271 NodeOrNodeList(const NodeOrNodeList&); | |
| 272 ~NodeOrNodeList(); | |
| 273 NodeOrNodeList& operator=(const NodeOrNodeList&); | |
| 274 DECLARE_TRACE(); | |
| 275 | |
| 276 private: | |
| 277 enum SpecificTypes { | |
| 278 SpecificTypeNone, | |
| 279 SpecificTypeNode, | |
| 280 SpecificTypeNodeList, | |
| 281 }; | |
| 282 SpecificTypes m_type; | |
| 283 | |
| 284 Member<Node> m_node; | |
| 285 Member<NodeList> m_nodeList; | |
| 286 | |
| 287 friend CORE_EXPORT v8::Local<v8::Value> toV8(const NodeOrNodeList&, v8::Loca
l<v8::Object>, v8::Isolate*); | |
| 288 }; | |
| 289 | |
| 290 class V8NodeOrNodeList final { | |
| 291 public: | |
| 292 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, NodeOrNod
eList&, UnionTypeConversionMode, ExceptionState&); | |
| 293 }; | |
| 294 | |
| 295 CORE_EXPORT v8::Local<v8::Value> toV8(const NodeOrNodeList&, v8::Local<v8::Objec
t>, v8::Isolate*); | |
| 296 | |
| 297 template <class CallbackInfo> | |
| 298 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, NodeOrNodeList& i
mpl) | |
| 299 { | |
| 300 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
| 301 } | |
| 302 | |
| 303 template <> | |
| 304 struct NativeValueTraits<NodeOrNodeList> { | |
| 305 CORE_EXPORT static NodeOrNodeList nativeValue(v8::Isolate*, v8::Local<v8::Va
lue>, ExceptionState&); | |
| 306 }; | |
| 307 | |
| 308 class CORE_EXPORT StringOrArrayBufferOrArrayBufferView final { | |
| 309 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 310 public: | |
| 311 StringOrArrayBufferOrArrayBufferView(); | |
| 312 bool isNull() const { return m_type == SpecificTypeNone; } | |
| 313 | |
| 314 bool isString() const { return m_type == SpecificTypeString; } | |
| 315 String getAsString() const; | |
| 316 void setString(String); | |
| 317 static StringOrArrayBufferOrArrayBufferView fromString(String); | |
| 318 | |
| 319 bool isArrayBuffer() const { return m_type == SpecificTypeArrayBuffer; } | |
| 320 TestArrayBuffer* getAsArrayBuffer() const; | |
| 321 void setArrayBuffer(TestArrayBuffer*); | |
| 322 static StringOrArrayBufferOrArrayBufferView fromArrayBuffer(TestArrayBuffer*
); | |
| 323 | |
| 324 bool isArrayBufferView() const { return m_type == SpecificTypeArrayBufferVie
w; } | |
| 325 TestArrayBufferView* getAsArrayBufferView() const; | |
| 326 void setArrayBufferView(TestArrayBufferView*); | |
| 327 static StringOrArrayBufferOrArrayBufferView fromArrayBufferView(TestArrayBuf
ferView*); | |
| 328 | |
| 329 StringOrArrayBufferOrArrayBufferView(const StringOrArrayBufferOrArrayBufferV
iew&); | |
| 330 ~StringOrArrayBufferOrArrayBufferView(); | |
| 331 StringOrArrayBufferOrArrayBufferView& operator=(const StringOrArrayBufferOrA
rrayBufferView&); | |
| 332 DECLARE_TRACE(); | |
| 333 | |
| 334 private: | |
| 335 enum SpecificTypes { | |
| 336 SpecificTypeNone, | |
| 337 SpecificTypeString, | |
| 338 SpecificTypeArrayBuffer, | |
| 339 SpecificTypeArrayBufferView, | |
| 340 }; | |
| 341 SpecificTypes m_type; | |
| 342 | |
| 343 String m_string; | |
| 344 Member<TestArrayBuffer> m_arrayBuffer; | |
| 345 Member<TestArrayBufferView> m_arrayBufferView; | |
| 346 | |
| 347 friend CORE_EXPORT v8::Local<v8::Value> toV8(const StringOrArrayBufferOrArra
yBufferView&, v8::Local<v8::Object>, v8::Isolate*); | |
| 348 }; | |
| 349 | |
| 350 class V8StringOrArrayBufferOrArrayBufferView final { | |
| 351 public: | |
| 352 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, StringOrA
rrayBufferOrArrayBufferView&, UnionTypeConversionMode, ExceptionState&); | |
| 353 }; | |
| 354 | |
| 355 CORE_EXPORT v8::Local<v8::Value> toV8(const StringOrArrayBufferOrArrayBufferView
&, v8::Local<v8::Object>, v8::Isolate*); | |
| 356 | |
| 357 template <class CallbackInfo> | |
| 358 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, StringOrArrayBuff
erOrArrayBufferView& impl) | |
| 359 { | |
| 360 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
| 361 } | |
| 362 | |
| 363 template <> | |
| 364 struct NativeValueTraits<StringOrArrayBufferOrArrayBufferView> { | |
| 365 CORE_EXPORT static StringOrArrayBufferOrArrayBufferView nativeValue(v8::Isol
ate*, v8::Local<v8::Value>, ExceptionState&); | |
| 366 }; | |
| 367 | |
| 368 class CORE_EXPORT StringOrDouble final { | |
| 369 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 370 public: | |
| 371 StringOrDouble(); | |
| 372 bool isNull() const { return m_type == SpecificTypeNone; } | |
| 373 | |
| 374 bool isString() const { return m_type == SpecificTypeString; } | |
| 375 String getAsString() const; | |
| 376 void setString(String); | |
| 377 static StringOrDouble fromString(String); | |
| 378 | |
| 379 bool isDouble() const { return m_type == SpecificTypeDouble; } | |
| 380 double getAsDouble() const; | |
| 381 void setDouble(double); | |
| 382 static StringOrDouble fromDouble(double); | |
| 383 | |
| 384 StringOrDouble(const StringOrDouble&); | |
| 385 ~StringOrDouble(); | |
| 386 StringOrDouble& operator=(const StringOrDouble&); | |
| 387 DECLARE_TRACE(); | |
| 388 | |
| 389 private: | |
| 390 enum SpecificTypes { | |
| 391 SpecificTypeNone, | |
| 392 SpecificTypeString, | |
| 393 SpecificTypeDouble, | |
| 394 }; | |
| 395 SpecificTypes m_type; | |
| 396 | |
| 397 String m_string; | |
| 398 double m_double; | |
| 399 | |
| 400 friend CORE_EXPORT v8::Local<v8::Value> toV8(const StringOrDouble&, v8::Loca
l<v8::Object>, v8::Isolate*); | |
| 401 }; | |
| 402 | |
| 403 class V8StringOrDouble final { | |
| 404 public: | |
| 405 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, StringOrD
ouble&, UnionTypeConversionMode, ExceptionState&); | |
| 406 }; | |
| 407 | |
| 408 CORE_EXPORT v8::Local<v8::Value> toV8(const StringOrDouble&, v8::Local<v8::Objec
t>, v8::Isolate*); | |
| 409 | |
| 410 template <class CallbackInfo> | |
| 411 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, StringOrDouble& i
mpl) | |
| 412 { | |
| 413 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
| 414 } | |
| 415 | |
| 416 template <> | |
| 417 struct NativeValueTraits<StringOrDouble> { | |
| 418 CORE_EXPORT static StringOrDouble nativeValue(v8::Isolate*, v8::Local<v8::Va
lue>, ExceptionState&); | |
| 419 }; | |
| 420 | |
| 421 class CORE_EXPORT StringOrStringSequence final { | |
| 422 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 423 public: | |
| 424 StringOrStringSequence(); | |
| 425 bool isNull() const { return m_type == SpecificTypeNone; } | |
| 426 | |
| 427 bool isString() const { return m_type == SpecificTypeString; } | |
| 428 String getAsString() const; | |
| 429 void setString(String); | |
| 430 static StringOrStringSequence fromString(String); | |
| 431 | |
| 432 bool isStringSequence() const { return m_type == SpecificTypeStringSequence;
} | |
| 433 const Vector<String>& getAsStringSequence() const; | |
| 434 void setStringSequence(const Vector<String>&); | |
| 435 static StringOrStringSequence fromStringSequence(const Vector<String>&); | |
| 436 | |
| 437 StringOrStringSequence(const StringOrStringSequence&); | |
| 438 ~StringOrStringSequence(); | |
| 439 StringOrStringSequence& operator=(const StringOrStringSequence&); | |
| 440 DECLARE_TRACE(); | |
| 441 | |
| 442 private: | |
| 443 enum SpecificTypes { | |
| 444 SpecificTypeNone, | |
| 445 SpecificTypeString, | |
| 446 SpecificTypeStringSequence, | |
| 447 }; | |
| 448 SpecificTypes m_type; | |
| 449 | |
| 450 String m_string; | |
| 451 Vector<String> m_stringSequence; | |
| 452 | |
| 453 friend CORE_EXPORT v8::Local<v8::Value> toV8(const StringOrStringSequence&,
v8::Local<v8::Object>, v8::Isolate*); | |
| 454 }; | |
| 455 | |
| 456 class V8StringOrStringSequence final { | |
| 457 public: | |
| 458 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, StringOrS
tringSequence&, UnionTypeConversionMode, ExceptionState&); | |
| 459 }; | |
| 460 | |
| 461 CORE_EXPORT v8::Local<v8::Value> toV8(const StringOrStringSequence&, v8::Local<v
8::Object>, v8::Isolate*); | |
| 462 | |
| 463 template <class CallbackInfo> | |
| 464 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, StringOrStringSeq
uence& impl) | |
| 465 { | |
| 466 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
| 467 } | |
| 468 | |
| 469 template <> | |
| 470 struct NativeValueTraits<StringOrStringSequence> { | |
| 471 CORE_EXPORT static StringOrStringSequence nativeValue(v8::Isolate*, v8::Loca
l<v8::Value>, ExceptionState&); | |
| 472 }; | |
| 473 | |
| 474 class CORE_EXPORT TestEnumOrDouble final { | |
| 475 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 476 public: | |
| 477 TestEnumOrDouble(); | |
| 478 bool isNull() const { return m_type == SpecificTypeNone; } | |
| 479 | |
| 480 bool isTestEnum() const { return m_type == SpecificTypeTestEnum; } | |
| 481 String getAsTestEnum() const; | |
| 482 void setTestEnum(String); | |
| 483 static TestEnumOrDouble fromTestEnum(String); | |
| 484 | |
| 485 bool isDouble() const { return m_type == SpecificTypeDouble; } | |
| 486 double getAsDouble() const; | |
| 487 void setDouble(double); | |
| 488 static TestEnumOrDouble fromDouble(double); | |
| 489 | |
| 490 TestEnumOrDouble(const TestEnumOrDouble&); | |
| 491 ~TestEnumOrDouble(); | |
| 492 TestEnumOrDouble& operator=(const TestEnumOrDouble&); | |
| 493 DECLARE_TRACE(); | |
| 494 | |
| 495 private: | |
| 496 enum SpecificTypes { | |
| 497 SpecificTypeNone, | |
| 498 SpecificTypeTestEnum, | |
| 499 SpecificTypeDouble, | |
| 500 }; | |
| 501 SpecificTypes m_type; | |
| 502 | |
| 503 String m_testEnum; | |
| 504 double m_double; | |
| 505 | |
| 506 friend CORE_EXPORT v8::Local<v8::Value> toV8(const TestEnumOrDouble&, v8::Lo
cal<v8::Object>, v8::Isolate*); | |
| 507 }; | |
| 508 | |
| 509 class V8TestEnumOrDouble final { | |
| 510 public: | |
| 511 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, TestEnumO
rDouble&, UnionTypeConversionMode, ExceptionState&); | |
| 512 }; | |
| 513 | |
| 514 CORE_EXPORT v8::Local<v8::Value> toV8(const TestEnumOrDouble&, v8::Local<v8::Obj
ect>, v8::Isolate*); | |
| 515 | |
| 516 template <class CallbackInfo> | |
| 517 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, TestEnumOrDouble&
impl) | |
| 518 { | |
| 519 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
| 520 } | |
| 521 | |
| 522 template <> | |
| 523 struct NativeValueTraits<TestEnumOrDouble> { | |
| 524 CORE_EXPORT static TestEnumOrDouble nativeValue(v8::Isolate*, v8::Local<v8::
Value>, ExceptionState&); | |
| 525 }; | |
| 526 | |
| 527 class CORE_EXPORT TestInterface2OrUint8Array final { | |
| 528 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 529 public: | |
| 530 TestInterface2OrUint8Array(); | |
| 531 bool isNull() const { return m_type == SpecificTypeNone; } | |
| 532 | |
| 533 bool isTestInterface2() const { return m_type == SpecificTypeTestInterface2;
} | |
| 534 TestInterface2* getAsTestInterface2() const; | |
| 535 void setTestInterface2(TestInterface2*); | |
| 536 static TestInterface2OrUint8Array fromTestInterface2(TestInterface2*); | |
| 537 | |
| 538 bool isUint8Array() const { return m_type == SpecificTypeUint8Array; } | |
| 539 DOMUint8Array* getAsUint8Array() const; | |
| 540 void setUint8Array(DOMUint8Array*); | |
| 541 static TestInterface2OrUint8Array fromUint8Array(DOMUint8Array*); | |
| 542 | |
| 543 TestInterface2OrUint8Array(const TestInterface2OrUint8Array&); | |
| 544 ~TestInterface2OrUint8Array(); | |
| 545 TestInterface2OrUint8Array& operator=(const TestInterface2OrUint8Array&); | |
| 546 DECLARE_TRACE(); | |
| 547 | |
| 548 private: | |
| 549 enum SpecificTypes { | |
| 550 SpecificTypeNone, | |
| 551 SpecificTypeTestInterface2, | |
| 552 SpecificTypeUint8Array, | |
| 553 }; | |
| 554 SpecificTypes m_type; | |
| 555 | |
| 556 Member<TestInterface2> m_testInterface2; | |
| 557 Member<DOMUint8Array> m_uint8Array; | |
| 558 | |
| 559 friend CORE_EXPORT v8::Local<v8::Value> toV8(const TestInterface2OrUint8Arra
y&, v8::Local<v8::Object>, v8::Isolate*); | |
| 560 }; | |
| 561 | |
| 562 class V8TestInterface2OrUint8Array final { | |
| 563 public: | |
| 564 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, TestInter
face2OrUint8Array&, UnionTypeConversionMode, ExceptionState&); | |
| 565 }; | |
| 566 | |
| 567 CORE_EXPORT v8::Local<v8::Value> toV8(const TestInterface2OrUint8Array&, v8::Loc
al<v8::Object>, v8::Isolate*); | |
| 568 | |
| 569 template <class CallbackInfo> | |
| 570 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, TestInterface2OrU
int8Array& impl) | |
| 571 { | |
| 572 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
| 573 } | |
| 574 | |
| 575 template <> | |
| 576 struct NativeValueTraits<TestInterface2OrUint8Array> { | |
| 577 CORE_EXPORT static TestInterface2OrUint8Array nativeValue(v8::Isolate*, v8::
Local<v8::Value>, ExceptionState&); | |
| 578 }; | |
| 579 | |
| 580 class CORE_EXPORT TestInterfaceGarbageCollectedOrString final { | |
| 581 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 582 public: | |
| 583 TestInterfaceGarbageCollectedOrString(); | |
| 584 bool isNull() const { return m_type == SpecificTypeNone; } | |
| 585 | |
| 586 bool isTestInterfaceGarbageCollected() const { return m_type == SpecificType
TestInterfaceGarbageCollected; } | |
| 587 TestInterfaceGarbageCollected* getAsTestInterfaceGarbageCollected() const; | |
| 588 void setTestInterfaceGarbageCollected(TestInterfaceGarbageCollected*); | |
| 589 static TestInterfaceGarbageCollectedOrString fromTestInterfaceGarbageCollect
ed(TestInterfaceGarbageCollected*); | |
| 590 | |
| 591 bool isString() const { return m_type == SpecificTypeString; } | |
| 592 String getAsString() const; | |
| 593 void setString(String); | |
| 594 static TestInterfaceGarbageCollectedOrString fromString(String); | |
| 595 | |
| 596 TestInterfaceGarbageCollectedOrString(const TestInterfaceGarbageCollectedOrS
tring&); | |
| 597 ~TestInterfaceGarbageCollectedOrString(); | |
| 598 TestInterfaceGarbageCollectedOrString& operator=(const TestInterfaceGarbageC
ollectedOrString&); | |
| 599 DECLARE_TRACE(); | |
| 600 | |
| 601 private: | |
| 602 enum SpecificTypes { | |
| 603 SpecificTypeNone, | |
| 604 SpecificTypeTestInterfaceGarbageCollected, | |
| 605 SpecificTypeString, | |
| 606 }; | |
| 607 SpecificTypes m_type; | |
| 608 | |
| 609 Member<TestInterfaceGarbageCollected> m_testInterfaceGarbageCollected; | |
| 610 String m_string; | |
| 611 | |
| 612 friend CORE_EXPORT v8::Local<v8::Value> toV8(const TestInterfaceGarbageColle
ctedOrString&, v8::Local<v8::Object>, v8::Isolate*); | |
| 613 }; | |
| 614 | |
| 615 class V8TestInterfaceGarbageCollectedOrString final { | |
| 616 public: | |
| 617 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, TestInter
faceGarbageCollectedOrString&, UnionTypeConversionMode, ExceptionState&); | |
| 618 }; | |
| 619 | |
| 620 CORE_EXPORT v8::Local<v8::Value> toV8(const TestInterfaceGarbageCollectedOrStrin
g&, v8::Local<v8::Object>, v8::Isolate*); | |
| 621 | |
| 622 template <class CallbackInfo> | |
| 623 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, TestInterfaceGarb
ageCollectedOrString& impl) | |
| 624 { | |
| 625 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
| 626 } | |
| 627 | |
| 628 template <> | |
| 629 struct NativeValueTraits<TestInterfaceGarbageCollectedOrString> { | |
| 630 CORE_EXPORT static TestInterfaceGarbageCollectedOrString nativeValue(v8::Iso
late*, v8::Local<v8::Value>, ExceptionState&); | |
| 631 }; | |
| 632 | |
| 633 class CORE_EXPORT TestInterfaceOrLong final { | |
| 634 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 635 public: | |
| 636 TestInterfaceOrLong(); | |
| 637 bool isNull() const { return m_type == SpecificTypeNone; } | |
| 638 | |
| 639 bool isTestInterface() const { return m_type == SpecificTypeTestInterface; } | |
| 640 TestInterfaceImplementation* getAsTestInterface() const; | |
| 641 void setTestInterface(TestInterfaceImplementation*); | |
| 642 static TestInterfaceOrLong fromTestInterface(TestInterfaceImplementation*); | |
| 643 | |
| 644 bool isLong() const { return m_type == SpecificTypeLong; } | |
| 645 int getAsLong() const; | |
| 646 void setLong(int); | |
| 647 static TestInterfaceOrLong fromLong(int); | |
| 648 | |
| 649 TestInterfaceOrLong(const TestInterfaceOrLong&); | |
| 650 ~TestInterfaceOrLong(); | |
| 651 TestInterfaceOrLong& operator=(const TestInterfaceOrLong&); | |
| 652 DECLARE_TRACE(); | |
| 653 | |
| 654 private: | |
| 655 enum SpecificTypes { | |
| 656 SpecificTypeNone, | |
| 657 SpecificTypeTestInterface, | |
| 658 SpecificTypeLong, | |
| 659 }; | |
| 660 SpecificTypes m_type; | |
| 661 | |
| 662 Member<TestInterfaceImplementation> m_testInterface; | |
| 663 int m_long; | |
| 664 | |
| 665 friend CORE_EXPORT v8::Local<v8::Value> toV8(const TestInterfaceOrLong&, v8:
:Local<v8::Object>, v8::Isolate*); | |
| 666 }; | |
| 667 | |
| 668 class V8TestInterfaceOrLong final { | |
| 669 public: | |
| 670 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, TestInter
faceOrLong&, UnionTypeConversionMode, ExceptionState&); | |
| 671 }; | |
| 672 | |
| 673 CORE_EXPORT v8::Local<v8::Value> toV8(const TestInterfaceOrLong&, v8::Local<v8::
Object>, v8::Isolate*); | |
| 674 | |
| 675 template <class CallbackInfo> | |
| 676 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, TestInterfaceOrLo
ng& impl) | |
| 677 { | |
| 678 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
| 679 } | |
| 680 | |
| 681 template <> | |
| 682 struct NativeValueTraits<TestInterfaceOrLong> { | |
| 683 CORE_EXPORT static TestInterfaceOrLong nativeValue(v8::Isolate*, v8::Local<v
8::Value>, ExceptionState&); | |
| 684 }; | |
| 685 | |
| 686 class CORE_EXPORT TestInterfaceOrTestInterfaceEmpty final { | |
| 687 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 688 public: | |
| 689 TestInterfaceOrTestInterfaceEmpty(); | |
| 690 bool isNull() const { return m_type == SpecificTypeNone; } | |
| 691 | |
| 692 bool isTestInterface() const { return m_type == SpecificTypeTestInterface; } | |
| 693 TestInterfaceImplementation* getAsTestInterface() const; | |
| 694 void setTestInterface(TestInterfaceImplementation*); | |
| 695 static TestInterfaceOrTestInterfaceEmpty fromTestInterface(TestInterfaceImpl
ementation*); | |
| 696 | |
| 697 bool isTestInterfaceEmpty() const { return m_type == SpecificTypeTestInterfa
ceEmpty; } | |
| 698 TestInterfaceEmpty* getAsTestInterfaceEmpty() const; | |
| 699 void setTestInterfaceEmpty(TestInterfaceEmpty*); | |
| 700 static TestInterfaceOrTestInterfaceEmpty fromTestInterfaceEmpty(TestInterfac
eEmpty*); | |
| 701 | |
| 702 TestInterfaceOrTestInterfaceEmpty(const TestInterfaceOrTestInterfaceEmpty&); | |
| 703 ~TestInterfaceOrTestInterfaceEmpty(); | |
| 704 TestInterfaceOrTestInterfaceEmpty& operator=(const TestInterfaceOrTestInterf
aceEmpty&); | |
| 705 DECLARE_TRACE(); | |
| 706 | |
| 707 private: | |
| 708 enum SpecificTypes { | |
| 709 SpecificTypeNone, | |
| 710 SpecificTypeTestInterface, | |
| 711 SpecificTypeTestInterfaceEmpty, | |
| 712 }; | |
| 713 SpecificTypes m_type; | |
| 714 | |
| 715 Member<TestInterfaceImplementation> m_testInterface; | |
| 716 Member<TestInterfaceEmpty> m_testInterfaceEmpty; | |
| 717 | |
| 718 friend CORE_EXPORT v8::Local<v8::Value> toV8(const TestInterfaceOrTestInterf
aceEmpty&, v8::Local<v8::Object>, v8::Isolate*); | |
| 719 }; | |
| 720 | |
| 721 class V8TestInterfaceOrTestInterfaceEmpty final { | |
| 722 public: | |
| 723 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, TestInter
faceOrTestInterfaceEmpty&, UnionTypeConversionMode, ExceptionState&); | |
| 724 }; | |
| 725 | |
| 726 CORE_EXPORT v8::Local<v8::Value> toV8(const TestInterfaceOrTestInterfaceEmpty&,
v8::Local<v8::Object>, v8::Isolate*); | |
| 727 | |
| 728 template <class CallbackInfo> | |
| 729 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, TestInterfaceOrTe
stInterfaceEmpty& impl) | |
| 730 { | |
| 731 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
| 732 } | |
| 733 | |
| 734 template <> | |
| 735 struct NativeValueTraits<TestInterfaceOrTestInterfaceEmpty> { | |
| 736 CORE_EXPORT static TestInterfaceOrTestInterfaceEmpty nativeValue(v8::Isolate
*, v8::Local<v8::Value>, ExceptionState&); | |
| 737 }; | |
| 738 | |
| 739 class CORE_EXPORT UnrestrictedDoubleOrString final { | |
| 740 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 741 public: | |
| 742 UnrestrictedDoubleOrString(); | |
| 743 bool isNull() const { return m_type == SpecificTypeNone; } | |
| 744 | |
| 745 bool isUnrestrictedDouble() const { return m_type == SpecificTypeUnrestricte
dDouble; } | |
| 746 double getAsUnrestrictedDouble() const; | |
| 747 void setUnrestrictedDouble(double); | |
| 748 static UnrestrictedDoubleOrString fromUnrestrictedDouble(double); | |
| 749 | |
| 750 bool isString() const { return m_type == SpecificTypeString; } | |
| 751 String getAsString() const; | |
| 752 void setString(String); | |
| 753 static UnrestrictedDoubleOrString fromString(String); | |
| 754 | |
| 755 UnrestrictedDoubleOrString(const UnrestrictedDoubleOrString&); | |
| 756 ~UnrestrictedDoubleOrString(); | |
| 757 UnrestrictedDoubleOrString& operator=(const UnrestrictedDoubleOrString&); | |
| 758 DECLARE_TRACE(); | |
| 759 | |
| 760 private: | |
| 761 enum SpecificTypes { | |
| 762 SpecificTypeNone, | |
| 763 SpecificTypeUnrestrictedDouble, | |
| 764 SpecificTypeString, | |
| 765 }; | |
| 766 SpecificTypes m_type; | |
| 767 | |
| 768 double m_unrestrictedDouble; | |
| 769 String m_string; | |
| 770 | |
| 771 friend CORE_EXPORT v8::Local<v8::Value> toV8(const UnrestrictedDoubleOrStrin
g&, v8::Local<v8::Object>, v8::Isolate*); | |
| 772 }; | |
| 773 | |
| 774 class V8UnrestrictedDoubleOrString final { | |
| 775 public: | |
| 776 CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, Unrestric
tedDoubleOrString&, UnionTypeConversionMode, ExceptionState&); | |
| 777 }; | |
| 778 | |
| 779 CORE_EXPORT v8::Local<v8::Value> toV8(const UnrestrictedDoubleOrString&, v8::Loc
al<v8::Object>, v8::Isolate*); | |
| 780 | |
| 781 template <class CallbackInfo> | |
| 782 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, UnrestrictedDoubl
eOrString& impl) | |
| 783 { | |
| 784 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
| 785 } | |
| 786 | |
| 787 template <> | |
| 788 struct NativeValueTraits<UnrestrictedDoubleOrString> { | |
| 789 CORE_EXPORT static UnrestrictedDoubleOrString nativeValue(v8::Isolate*, v8::
Local<v8::Value>, ExceptionState&); | |
| 790 }; | |
| 791 | |
| 792 } // namespace blink | |
| 793 | |
| 794 // We need to set canInitializeWithMemset=true because HeapVector supports | |
| 795 // items that can initialize with memset or have a vtable. It is safe to | |
| 796 // set canInitializeWithMemset=true for a union type object in practice. | |
| 797 // See https://codereview.chromium.org/1118993002/#msg5 for more details. | |
| 798 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::ArrayBufferOrArrayBufferViewOr
Dictionary); | |
| 799 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::BooleanOrStringOrUnrestrictedD
ouble); | |
| 800 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::DoubleOrString); | |
| 801 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::LongOrTestDictionary); | |
| 802 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::NodeOrNodeList); | |
| 803 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::StringOrArrayBufferOrArrayBuff
erView); | |
| 804 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::StringOrDouble); | |
| 805 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::StringOrStringSequence); | |
| 806 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::TestEnumOrDouble); | |
| 807 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::TestInterface2OrUint8Array); | |
| 808 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::TestInterfaceGarbageCollectedO
rString); | |
| 809 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::TestInterfaceOrLong); | |
| 810 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::TestInterfaceOrTestInterfaceEm
pty); | |
| 811 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::UnrestrictedDoubleOrString); | |
| 812 | |
| 813 #endif // UnionTypeCore_h | |
| OLD | NEW |