Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Unified Diff: Source/bindings/tests/results/core/UnionTypesCore.h

Issue 860353002: IDL: Add toRestricted{Float,Double}() helpers to V8Binding.h (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add FIXME comment Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/tests/results/core/UnionTypesCore.h
diff --git a/Source/bindings/tests/results/core/UnionTypesCore.h b/Source/bindings/tests/results/core/UnionTypesCore.h
index b6d407e95841ae3f126519866dab56b9c8e98c84..85b2dd286c49dc9a9b0d5a1694bff66ad093d609 100644
--- a/Source/bindings/tests/results/core/UnionTypesCore.h
+++ b/Source/bindings/tests/results/core/UnionTypesCore.h
@@ -648,6 +648,52 @@ struct NativeValueTraits<TestInterfaceWillBeGarbageCollectedOrTestDictionary> {
static TestInterfaceWillBeGarbageCollectedOrTestDictionary nativeValue(const v8::Local<v8::Value>&, v8::Isolate*, ExceptionState&);
};
+class UnrestrictedDoubleOrString final {
+ ALLOW_ONLY_INLINE_ALLOCATION();
+public:
+ UnrestrictedDoubleOrString();
+ bool isNull() const { return m_type == SpecificTypeNone; }
+
+ bool isUnrestrictedDouble() const { return m_type == SpecificTypeUnrestrictedDouble; }
+ double getAsUnrestrictedDouble() const;
+ void setUnrestrictedDouble(double);
+
+ bool isString() const { return m_type == SpecificTypeString; }
+ String getAsString() const;
+ void setString(String);
+
+private:
+ enum SpecificTypes {
+ SpecificTypeNone,
+ SpecificTypeUnrestrictedDouble,
+ SpecificTypeString,
+ };
+ SpecificTypes m_type;
+
+ double m_unrestrictedDouble;
+ String m_string;
+
+ friend v8::Local<v8::Value> toV8(const UnrestrictedDoubleOrString&, v8::Local<v8::Object>, v8::Isolate*);
+};
+
+class V8UnrestrictedDoubleOrString final {
+public:
+ static void toImpl(v8::Isolate*, v8::Local<v8::Value>, UnrestrictedDoubleOrString&, ExceptionState&);
+};
+
+v8::Local<v8::Value> toV8(const UnrestrictedDoubleOrString&, v8::Local<v8::Object>, v8::Isolate*);
+
+template <class CallbackInfo>
+inline void v8SetReturnValue(const CallbackInfo& callbackInfo, UnrestrictedDoubleOrString& impl)
+{
+ v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
+}
+
+template <>
+struct NativeValueTraits<UnrestrictedDoubleOrString> {
+ static UnrestrictedDoubleOrString nativeValue(const v8::Local<v8::Value>&, v8::Isolate*, ExceptionState&);
+};
+
class V8DoubleOrStringOrNull final {
public:
static void toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, DoubleOrString& impl, ExceptionState& exceptionState)

Powered by Google App Engine
This is Rietveld 408576698