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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 // Defines 'wrapperTypeInfo' virtual method which returns the WrapperTypeInfo of | 190 // Defines 'wrapperTypeInfo' virtual method which returns the WrapperTypeInfo of |
191 // the instance. Also declares a static member of type WrapperTypeInfo, of which | 191 // the instance. Also declares a static member of type WrapperTypeInfo, of which |
192 // the definition is given by the IDL code generator. | 192 // the definition is given by the IDL code generator. |
193 // | 193 // |
194 // All the derived classes of ScriptWrappable, regardless of directly or | 194 // All the derived classes of ScriptWrappable, regardless of directly or |
195 // indirectly, must write this macro in the class definition as long as the | 195 // indirectly, must write this macro in the class definition as long as the |
196 // class has a corresponding .idl file. | 196 // class has a corresponding .idl file. |
197 #define DEFINE_WRAPPERTYPEINFO() \ | 197 #define DEFINE_WRAPPERTYPEINFO() \ |
198 public: \ | 198 public: \ |
199 virtual const WrapperTypeInfo* wrapperTypeInfo() const override \ | 199 const WrapperTypeInfo* wrapperTypeInfo() const override \ |
200 { \ | 200 { \ |
201 return &s_wrapperTypeInfo; \ | 201 return &s_wrapperTypeInfo; \ |
202 } \ | 202 } \ |
203 private: \ | 203 private: \ |
204 static const WrapperTypeInfo& s_wrapperTypeInfo | 204 static const WrapperTypeInfo& s_wrapperTypeInfo |
205 | 205 |
206 // Defines 'wrapperTypeInfo' virtual method, which should never be called. | 206 // Defines 'wrapperTypeInfo' virtual method, which should never be called. |
207 // | 207 // |
208 // This macro is used when there exists a class hierarchy with a root class | 208 // This macro is used when there exists a class hierarchy with a root class |
209 // and most of the subclasses are script-wrappable but not all of them. | 209 // and most of the subclasses are script-wrappable but not all of them. |
210 // In that case, the root class can inherit from ScriptWrappable and use | 210 // In that case, the root class can inherit from ScriptWrappable and use |
211 // this macro, and let subclasses have a choice whether or not use | 211 // this macro, and let subclasses have a choice whether or not use |
212 // DEFINE_WRAPPERTYPEINFO macro. The script-wrappable subclasses which have | 212 // DEFINE_WRAPPERTYPEINFO macro. The script-wrappable subclasses which have |
213 // corresponding IDL file must call DEFINE_WRAPPERTYPEINFO, and the others | 213 // corresponding IDL file must call DEFINE_WRAPPERTYPEINFO, and the others |
214 // must not. | 214 // must not. |
215 #define DEFINE_WRAPPERTYPEINFO_NOT_REACHED() \ | 215 #define DEFINE_WRAPPERTYPEINFO_NOT_REACHED() \ |
216 public: \ | 216 public: \ |
217 virtual const WrapperTypeInfo* wrapperTypeInfo() const override \ | 217 const WrapperTypeInfo* wrapperTypeInfo() const override \ |
218 { \ | 218 { \ |
219 ASSERT_NOT_REACHED(); \ | 219 ASSERT_NOT_REACHED(); \ |
220 return 0; \ | 220 return 0; \ |
221 } \ | 221 } \ |
222 private: \ | 222 private: \ |
223 typedef void end_of_define_wrappertypeinfo_not_reached_t | 223 typedef void end_of_define_wrappertypeinfo_not_reached_t |
224 | 224 |
225 | 225 |
226 // Declares 'wrapperTypeInfo' method without definition. | 226 // Declares 'wrapperTypeInfo' method without definition. |
227 // | 227 // |
228 // This macro is used for template classes. e.g. DOMTypedArray<>. | 228 // This macro is used for template classes. e.g. DOMTypedArray<>. |
229 // To export such a template class X, we need to instantiate X with EXPORT_API, | 229 // To export such a template class X, we need to instantiate X with EXPORT_API, |
230 // i.e. "extern template class EXPORT_API X;" | 230 // i.e. "extern template class EXPORT_API X;" |
231 // However, once we instantiate X, we cannot specialize X after | 231 // However, once we instantiate X, we cannot specialize X after |
232 // the instantiation. i.e. we will see "error: explicit specialization of ... | 232 // the instantiation. i.e. we will see "error: explicit specialization of ... |
233 // after instantiation". So we cannot define X's s_wrapperTypeInfo in generated | 233 // after instantiation". So we cannot define X's s_wrapperTypeInfo in generated |
234 // code by using specialization. Instead, we need to implement wrapperTypeInfo | 234 // code by using specialization. Instead, we need to implement wrapperTypeInfo |
235 // in X's cpp code, and instantiate X, i.e. "template class X;". | 235 // in X's cpp code, and instantiate X, i.e. "template class X;". |
236 #define DECLARE_WRAPPERTYPEINFO() \ | 236 #define DECLARE_WRAPPERTYPEINFO() \ |
237 public: \ | 237 public: \ |
238 virtual const WrapperTypeInfo* wrapperTypeInfo() const override; \ | 238 const WrapperTypeInfo* wrapperTypeInfo() const override; \ |
239 private: \ | 239 private: \ |
240 typedef void end_of_define_wrappertypeinfo_not_reached_t | 240 typedef void end_of_define_wrappertypeinfo_not_reached_t |
241 | 241 |
242 } // namespace blink | 242 } // namespace blink |
243 | 243 |
244 #endif // ScriptWrappable_h | 244 #endif // ScriptWrappable_h |
OLD | NEW |