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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // class has a corresponding .idl file. | 225 // class has a corresponding .idl file. |
226 #define DEFINE_WRAPPERTYPEINFO() \ | 226 #define DEFINE_WRAPPERTYPEINFO() \ |
227 public: \ | 227 public: \ |
228 const WrapperTypeInfo* wrapperTypeInfo() const override \ | 228 const WrapperTypeInfo* wrapperTypeInfo() const override \ |
229 { \ | 229 { \ |
230 return &s_wrapperTypeInfo; \ | 230 return &s_wrapperTypeInfo; \ |
231 } \ | 231 } \ |
232 private: \ | 232 private: \ |
233 static const WrapperTypeInfo& s_wrapperTypeInfo | 233 static const WrapperTypeInfo& s_wrapperTypeInfo |
234 | 234 |
235 // Defines 'wrapperTypeInfo' virtual method, which should never be called. | |
236 // | |
237 // This macro is used when there exists a class hierarchy with a root class | |
238 // and most of the subclasses are script-wrappable but not all of them. | |
239 // In that case, the root class can inherit from ScriptWrappable and use | |
240 // this macro, and let subclasses have a choice whether or not use | |
241 // DEFINE_WRAPPERTYPEINFO macro. The script-wrappable subclasses which have | |
242 // corresponding IDL file must call DEFINE_WRAPPERTYPEINFO, and the others | |
243 // must not. | |
244 #define DEFINE_WRAPPERTYPEINFO_NOT_REACHED() \ | |
245 public: \ | |
246 const WrapperTypeInfo* wrapperTypeInfo() const override \ | |
247 { \ | |
248 ASSERT_NOT_REACHED(); \ | |
249 return 0; \ | |
250 } \ | |
251 private: \ | |
252 typedef void end_of_define_wrappertypeinfo_not_reached_t | |
253 | |
254 | |
255 // Declares 'wrapperTypeInfo' method without definition. | 235 // Declares 'wrapperTypeInfo' method without definition. |
256 // | 236 // |
257 // This macro is used for template classes. e.g. DOMTypedArray<>. | 237 // This macro is used for template classes. e.g. DOMTypedArray<>. |
258 // To export such a template class X, we need to instantiate X with EXPORT_API, | 238 // To export such a template class X, we need to instantiate X with EXPORT_API, |
259 // i.e. "extern template class EXPORT_API X;" | 239 // i.e. "extern template class EXPORT_API X;" |
260 // However, once we instantiate X, we cannot specialize X after | 240 // However, once we instantiate X, we cannot specialize X after |
261 // the instantiation. i.e. we will see "error: explicit specialization of ... | 241 // the instantiation. i.e. we will see "error: explicit specialization of ... |
262 // after instantiation". So we cannot define X's s_wrapperTypeInfo in generated | 242 // after instantiation". So we cannot define X's s_wrapperTypeInfo in generated |
263 // code by using specialization. Instead, we need to implement wrapperTypeInfo | 243 // code by using specialization. Instead, we need to implement wrapperTypeInfo |
264 // in X's cpp code, and instantiate X, i.e. "template class X;". | 244 // in X's cpp code, and instantiate X, i.e. "template class X;". |
265 #define DECLARE_WRAPPERTYPEINFO() \ | 245 #define DECLARE_WRAPPERTYPEINFO() \ |
266 public: \ | 246 public: \ |
267 const WrapperTypeInfo* wrapperTypeInfo() const override; \ | 247 const WrapperTypeInfo* wrapperTypeInfo() const override; \ |
268 private: \ | 248 private: \ |
269 typedef void end_of_define_wrappertypeinfo_not_reached_t | 249 typedef void end_of_define_wrappertypeinfo_not_reached_t |
270 | 250 |
271 } // namespace blink | 251 } // namespace blink |
272 | 252 |
273 #endif // ScriptWrappable_h | 253 #endif // ScriptWrappable_h |
OLD | NEW |