OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // Sets properties using default attributes. | 69 // Sets properties using default attributes. |
70 bool set(const String&, const v8::Handle<v8::Value>&); | 70 bool set(const String&, const v8::Handle<v8::Value>&); |
71 bool set(const String&, const String&); | 71 bool set(const String&, const String&); |
72 bool set(const String&, unsigned); | 72 bool set(const String&, unsigned); |
73 bool set(const String&, const Dictionary&); | 73 bool set(const String&, const Dictionary&); |
74 | 74 |
75 v8::Handle<v8::Value> v8Value() const { return m_options; } | 75 v8::Handle<v8::Value> v8Value() const { return m_options; } |
76 | 76 |
77 class ConversionContext { | 77 class ConversionContext { |
78 public: | 78 public: |
79 ConversionContext(const String& interfaceName, const String& methodName,
ExceptionState& exceptionState) | 79 explicit ConversionContext(ExceptionState& exceptionState) |
80 : m_interfaceName(interfaceName) | 80 : m_exceptionState(exceptionState) |
81 , m_methodName(methodName) | |
82 , m_exceptionState(exceptionState) | |
83 , m_dirty(true) | 81 , m_dirty(true) |
84 { | 82 { |
85 resetPerPropertyContext(); | 83 resetPerPropertyContext(); |
86 } | 84 } |
87 | 85 |
88 const String& interfaceName() const { return m_interfaceName; } | |
89 const String& methodName() const { return m_methodName; } | |
90 bool forConstructor() const { return m_methodName.isEmpty(); } | |
91 ExceptionState& exceptionState() const { return m_exceptionState; } | 86 ExceptionState& exceptionState() const { return m_exceptionState; } |
92 | 87 |
93 bool isNullable() const { return m_isNullable; } | 88 bool isNullable() const { return m_isNullable; } |
94 String typeName() const { return m_propertyTypeName; } | 89 String typeName() const { return m_propertyTypeName; } |
95 | 90 |
96 ConversionContext& setConversionType(const String&, bool); | 91 ConversionContext& setConversionType(const String&, bool); |
97 | 92 |
98 void throwTypeError(const String& detail); | 93 void throwTypeError(const String& detail); |
99 | 94 |
100 void resetPerPropertyContext(); | 95 void resetPerPropertyContext(); |
101 | 96 |
102 private: | 97 private: |
103 const String m_interfaceName; | |
104 const String m_methodName; | |
105 ExceptionState& m_exceptionState; | 98 ExceptionState& m_exceptionState; |
106 bool m_dirty; | 99 bool m_dirty; |
107 | 100 |
108 bool m_isNullable; | 101 bool m_isNullable; |
109 String m_propertyTypeName; | 102 String m_propertyTypeName; |
110 }; | 103 }; |
111 | 104 |
112 class ConversionContextScope { | 105 class ConversionContextScope { |
113 public: | 106 public: |
114 ConversionContextScope(ConversionContext& context) | 107 explicit ConversionContextScope(ConversionContext& context) |
115 : m_context(context) { } | 108 : m_context(context) { } |
116 ~ConversionContextScope() | 109 ~ConversionContextScope() |
117 { | 110 { |
118 m_context.resetPerPropertyContext(); | 111 m_context.resetPerPropertyContext(); |
119 } | 112 } |
120 private: | 113 private: |
121 ConversionContext& m_context; | 114 ConversionContext& m_context; |
122 }; | 115 }; |
123 | 116 |
124 bool convert(ConversionContext&, const String&, Dictionary&) const; | 117 bool convert(ConversionContext&, const String&, Dictionary&) const; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, T& value); | 161 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, T& value); |
169 template <typename T> | 162 template <typename T> |
170 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, Nullable<T>& value); | 163 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, Nullable<T>& value); |
171 template <template <typename> class PointerType, typename T> | 164 template <template <typename> class PointerType, typename T> |
172 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, PointerType<T>& value); | 165 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, PointerType<T>& value); |
173 }; | 166 }; |
174 | 167 |
175 } | 168 } |
176 | 169 |
177 #endif // Dictionary_h | 170 #endif // Dictionary_h |
OLD | NEW |