1 #ifndef SG_NASAL_GHOST_HXX_
2 # error Nasal cppbind - do not include this file!
5 #define n BOOST_PP_ITERATION()
7 #define SG_GHOST_FUNC_TYPE\
8 boost::function<Ret (raw_type& BOOST_PP_COMMA_IF(n)BOOST_PP_ENUM_PARAMS(n,A))>
11 * Bind any callable entity accepting an instance of raw_type and an arbitrary
12 * number of arguments as method.
17 BOOST_PP_ENUM_PARAMS(n, class A)
19 Ghost& method(const std::string& name, const SG_GHOST_FUNC_TYPE& func)
21 #if defined(GCC_VERSION) && GCC_VERSION < 40407
22 // The old version of g++ used on Jenkins (16.11.2012) only compiles this
24 # define SG_GHOST_REQUIRE_ARG(z, n, dummy)\
25 boost::bind(&arg_from_nasal<A##n>, _2, n)
27 // VS (2008, 2010, ... ?) only allow this version.
28 # define SG_GHOST_REQUIRE_ARG(z, n, dummy)\
29 boost::bind(&Ghost::arg_from_nasal<A##n>, _2, n)
35 typename boost::function<Ret (raw_type&, const CallContext&)>
40 BOOST_PP_ENUM(n, SG_GHOST_REQUIRE_ARG,)
44 #undef SG_GHOST_REQUIRE_ARG
47 #define SG_GHOST_MEM_FN(cv)\
49 * Bind a member function with an arbitrary number of arguments as method.\
54 BOOST_PP_ENUM_PARAMS(n, class A)\
58 const std::string& name,\
59 Ret (raw_type::*fn)(BOOST_PP_ENUM_PARAMS(n,A)) cv\
65 BOOST_PP_ENUM_PARAMS(n,A)\
66 >(name, SG_GHOST_FUNC_TYPE(fn));\
71 SG_GHOST_MEM_FN(const)
73 #undef SG_GHOST_MEM_FN
76 * Bind free function accepting an instance of raw_type and an arbitrary
77 * number of arguments as method.
83 BOOST_PP_ENUM_PARAMS(n, class A)
87 const std::string& name,
88 Ret (*fn)(Type BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n,A))
92 (( boost::is_convertible<raw_type&, Type>::value
93 //|| boost::is_convertible<raw_type*, Type>::value
94 // TODO check how to do it with pointer...
96 return method<Ret>(name, SG_GHOST_FUNC_TYPE(fn));
100 #undef SG_GHOST_TYPEDEF_FUNC_TYPE