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

Unified Diff: Source/wtf/UnionType.h

Issue 15076011: Support union return type for anonymous named/indexed getter (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: update Created 7 years, 7 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/wtf/UnionType.h
diff --git a/Source/wtf/text/StringStatics.h b/Source/wtf/UnionType.h
similarity index 64%
copy from Source/wtf/text/StringStatics.h
copy to Source/wtf/UnionType.h
index 73097bc5cdbaf2e17318bd93cdcb1c445f676b27..23597ca6e3149486641e9332921304c8eeb90269 100644
--- a/Source/wtf/text/StringStatics.h
+++ b/Source/wtf/UnionType.h
@@ -28,19 +28,50 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef StringStatics_h
-#define StringStatics_h
+#ifndef UnionType_h
+#define UnionType_h
namespace WTF {
-class StringStatics {
+// UnionTypeN holds multiple types of objects.
+//
+// WebIDL(UnionType):
+// http://www.w3.org/TR/WebIDL/#prod-UnionType
+//
+// Example IDL:
+// http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#htmlformcontrolscollection
+template<typename Type1, typename Type2>
+class UnionType2 {
public:
- static void init();
-
+ UnionType2()
+ {
+ }
+ explicit UnionType2(PassRefPtr<Type1> value)
+ {
+ m_value1 = value;
+ }
+ explicit UnionType2(PassRefPtr<Type2> value)
+ {
+ m_value2 = value;
+ }
+ bool isNull() const
+ {
+ return !m_value1 && !m_value2;
+ }
+ PassRefPtr<Type1> member1() const
+ {
+ return m_value1;
+ }
+ PassRefPtr<Type2> member2() const
+ {
+ return m_value2;
+ }
private:
- StringStatics();
+ RefPtr<Type1> m_value1;
+ RefPtr<Type2> m_value2;
haraken 2013/05/16 05:38:05 Nit: m_value1 => m_member1
};
-}
-#endif
+} // namespace WTF
+
+#endif // UnionType_h
« Source/bindings/scripts/IDLParser.pm ('K') | « Source/core/html/HTMLFormControlsCollection.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698