FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
typesafe_event.h
1 #pragma once
2 #ifndef typesafe_event_h__
3 #define typesafe_event_h__
4 
5 /**********************************************************\
6 Original Author: Richard Bateman (taxilian)
7 
8 Created: Apr 8, 2011
9 License: Dual license model; choose one of two:
10  New BSD License
11  http://www.opensource.org/licenses/bsd-license.php
12  - or -
13  GNU Lesser General Public License, version 2.1
14  http://www.gnu.org/licenses/lgpl-2.1.html
15 
16 Copyright 2009 Richard Bateman, Firebreath development team
17 \**********************************************************/
18 
19 #include <boost/preprocessor/repetition.hpp>
20 #include <boost/preprocessor/cat.hpp>
21 
22 #define __FB_EVTFUNC_NAME(evt) BOOST_PP_CAT(fire_, evt)
23 #define __FB_EVTPARAMMACRO(z, n, args) BOOST_PP_ARRAY_ELEM(n, args) p##n
24 
25 #define __FB_EVTADDTOLIST(z, n, name) name.push_back(p##n);
26 
27 #define FB_JSAPI_EVENT(evt, argCount, argList) \
28  void __FB_EVTFUNC_NAME(evt)( \
29  BOOST_PP_ENUM(argCount, __FB_EVTPARAMMACRO, (argCount, argList)) \
30  ) { \
31  FB::VariantList list; \
32  BOOST_PP_REPEAT(argCount, __FB_EVTADDTOLIST, list) \
33  FireEvent(BOOST_PP_STRINGIZE(BOOST_PP_CAT(on, evt)), list); \
34  }
35 
36 #endif // typesafe_event_h__