inline typename boost::enable_if<boost::is_member_function_pointer<TCallback>, TResult >::type
        invoke (const FunctionCallbackInfo<Value> &info)
        {
            typedef typename mpl::begin<TSignature>::type TSeqFirst;
            typedef typename mpl::next< TSeqFirst >::type TSeqInstanceType;
            
            typedef typename boost::remove_const<typename boost::remove_reference<typename TSeqInstanceType::type>::type >::type TInstanceType;
            
            /* Retrieve "this" from V8 */
            Local<Object> _this = info.Holder();
            
            /* Get address by casting the External saved value.
             Note that it was saved in NativeClass<TClass>::ctor */
            TInstanceType *instance = static_cast<TInstanceType *>(_this->GetAlignedPointerFromInternalField(_this->InternalFieldCount() - 2));
            
# if N
#  define BOOST_PP_LOCAL_MACRO(i) V8_BRIDGE_SETUP_ARG(i, TSeqInstanceType)
#  define BOOST_PP_LOCAL_LIMITS (0, N-1)
#  include BOOST_PP_LOCAL_ITERATE()
# endif
            
            return bridge::detail::invoke_native_raw<TResult>(
                                                     this->m_isolationScope
                                                     , detail::invoke_tag<TResult, TPointer>()
                                                     , this->m_callbackPointer
                                                     , instance
                                                     BOOST_PP_ENUM_TRAILING_PARAMS(N, resolvedArg)
                                                     );
        }
static void action_port (Port port, Context context, Descriptor descriptor
                         , Document document
                         BOOST_PP_ENUM_TRAILING_BINARY_PARAMS (BOOST_PP_ITERATION (), A, a))
{
  AbortContextTraits::abort_port(port, context, descriptor, document
                                 BOOST_PP_ENUM_TRAILING_PARAMS (BOOST_PP_ITERATION (), a));
}
        inline typename boost::disable_if<boost::is_member_function_pointer<TCallback>, Handle<Value> >::type
        operator () (const FunctionCallbackInfo<Value> &info)
        {
            typedef typename mpl::begin<TSignature>::type TSeqFirst;
            typedef typename TSeqFirst::type TResult;
            
#if V8BRIDGE_DEBUG /* By default, we're always calling isInvokable before operator(), so we don't need this.
I'm leaving this in operator() too only for debugging preposes. */
            if (!this->isInvokable(info)) {
                return v8::Undefined(this->m_isolationScope);
            }
#endif
            
# if N
#  define BOOST_PP_LOCAL_MACRO(i) V8_BRIDGE_SETUP_ARG(i, TSeqFirst)
#  define BOOST_PP_LOCAL_LIMITS (0, N-1)
#  include BOOST_PP_LOCAL_ITERATE()
# endif
            
            
            Handle<Value> result = bridge::detail::invoke_native(
                                                                 this->m_isolationScope,
                                                                 detail::invoke_tag<TResult, TPointer>()
                                                                 , this->m_callbackPointer
                                                                 BOOST_PP_ENUM_TRAILING_PARAMS(N, resolvedArg)
                                                                 );
            
            
            return result;
        }
void pause
    (Media m, Descriptor d, Document document
     BOOST_PP_ENUM_TRAILING_BINARY_PARAMS (BOOST_PP_ITERATION (), A, a)
    )
{
  media::pause<pause_action_traits>(m, d, document
                                    BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), a));
}
Example #5
0
 >::type const
 operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const &a))
 {
     return result_of::BOOST_PP_CAT(funop, N)<
         expr
       , default_domain BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)
     >::call(*this BOOST_PP_ENUM_TRAILING_PARAMS(N, a));
 }
void operator()(jvb::environment e, jvb::Object obj
                BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(BOOST_PP_ITERATION(), A, a)) const
{
  assert(obj.raw() != 0);
  BOOST_MPL_ASSERT((boost::mpl::bool_<(sizeof(void*) <= sizeof(::jlong))>));
  // typename Allocator::template rebind<T>::other allocator;
  std::cout << "constructor wrapper" << std::endl;
  // void* p = allocator.allocate(1, 0);
  // T* object = new (p) T;

  binding::virtual_table<N>const* vtable;
  ::jclass c = obj.class_(e).raw();
  {
    const char* d = "J";
    assert(c != 0);
    jfieldID fid = e.raw()->GetStaticFieldID
      (c, javabind_vtable_field_name, d);
    assert(fid != 0);
    jlong rl = e.raw()->GetStaticLongField(c, fid);
    void* p = 0;
    std::memcpy(&p, &rl, sizeof(void*));
    vtable = static_cast<binding::virtual_table<N>*>(p);
  }
  void* fp = vtable->methods[I].function_object.get();
  assert(fp != 0);
  boost::function<Result(jvb::environment BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), A))>*
    f = static_cast<boost::function<Result(jvb::environment
                                           BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), A))>*>(fp);

  std::auto_ptr<binding::peer_info<T, N> >
    peer_info(new binding::peer_info<T, N>
              (*vtable, (*f)(e BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), a)) ));

  {
    ::jlong rl = 0;
    void* p = peer_info.release();
    std::memcpy(&rl, &p, sizeof(void*));
    const char* d = "J";
    assert(c != 0);
    jfieldID fid = e.raw()->GetFieldID
      (c, binding::javabind_peer_info_field_name, d);
    assert(fid != 0);
    e.raw()->SetLongField(obj.raw(), fid, rl);
  }
}
void stop
  (Media m, Descriptor descriptor, Document document
   BOOST_PP_ENUM_TRAILING_BINARY_PARAMS (BOOST_PP_ITERATION (), A, a)
  )
{
  media::stop<stop_action_traits>
    (m, descriptor, document
     BOOST_PP_ENUM_TRAILING_PARAMS (BOOST_PP_ITERATION (), a));
}
void resume (Context context, Descriptor descriptor, Document document
            BOOST_PP_ENUM_TRAILING_BINARY_PARAMS (BOOST_PP_ITERATION (), A, a))
{
    typedef typename boost::unwrap_reference<Context>::type context_type;
    typedef typename boost::unwrap_reference<Document>::type document_type;
    GNTL_CONCEPT_ASSERT ((concept::structure::Context<context_type>));
    GNTL_CONCEPT_ASSERT ((concept::structure::Document<document_type>));
    algorithm::structure::context::resume<resume_action_traits>
      (context, descriptor, document
       BOOST_PP_ENUM_TRAILING_PARAMS (BOOST_PP_ITERATION (), a));
}
Example #9
0
	int match(
		R(T::*)(BOOST_PP_ENUM_PARAMS(N, A))
	  , lua_State* L
	  , WrappedClass*
	  , Policies const*)
	{
		typedef constructor<
		    T&
		    BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
		> params_t;

		return match_params(
			L, 1, (params_t*)0, (Policies*)0);
	}
Example #10
0
void pause (Port port, Context context, Document document
            BOOST_PP_ENUM_TRAILING_BINARY_PARAMS (BOOST_PP_ITERATION (), A, a))
{
    typedef typename boost::unwrap_reference<Port>::type port_type;
    typedef typename boost::unwrap_reference<Context>::type context_type;
    typedef typename boost::unwrap_reference<Document>::type document_type;

    GNTL_CONCEPT_ASSERT ((concept::parser::Port<port_type>));
    GNTL_CONCEPT_ASSERT ((concept::structure::Context<context_type>));
    GNTL_CONCEPT_ASSERT ((concept::structure::Document<document_type>));
    algorithm::structure::port::pause<pause_action_traits>
        (port, context, document
         BOOST_PP_ENUM_TRAILING_PARAMS (BOOST_PP_ITERATION (), a));
}
Example #11
0
	int match(
		R(T::*)(BOOST_PP_ENUM_PARAMS(N, A))
	  , lua_State* L
	  , WrappedClass*
	  , Policies const*)
	{
		typedef constructor<
			BOOST_DEDUCED_TYPENAME most_derived<T,WrappedClass>::type&
		    BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
		> params_t;

		return match_params(
			L, 1, (params_t*)0, (Policies*)0);
	}
result_type operator()(environment e
                       BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(BOOST_PP_ITERATION(), A, a)) const
{
  typedef mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), A)> param_types;
  typedef typename mpl::transform
    <param_types
     , mpl::if_
     <boost::is_same<mpl::_1, const char*>
      , jvb::string
      , mpl::_1> >::type correct_param_types;
  typedef typename boost::function_types::function_type
    <typename mpl::push_front<correct_param_types, result_type>::type>::type
    sig_type;
  Class cls(e, R::name());
  assert(cls.raw() != 0);
  constructors<sig_type> m(e, cls);
  assert(m.raw() != 0);
  detail::new_object_functor<result_type> c;
  return c(e, cls, m.raw() BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), a));
}
        inline typename boost::disable_if<boost::is_member_function_pointer<TCallback>, TResult >::type
        invoke (const FunctionCallbackInfo<Value> &info)
        {
            typedef typename mpl::begin<TSignature>::type TSeqFirst;
            
# if N
#  define BOOST_PP_LOCAL_MACRO(i) V8_BRIDGE_SETUP_ARG(i, TSeqFirst)
#  define BOOST_PP_LOCAL_LIMITS (0, N-1)
#  include BOOST_PP_LOCAL_ITERATE()
# endif
            
            
            return bridge::detail::invoke_native_raw<TResult>(
                                                     this->m_isolationScope,
                                                     detail::invoke_tag<TResult, TPointer>()
                                                     , this->m_callbackPointer
                                                     BOOST_PP_ENUM_TRAILING_PARAMS(N, resolvedArg)
                                                     );
            
            
        }
        inline typename boost::enable_if<boost::is_member_function_pointer<TCallback>, Handle<Value> >::type
        operator () (const FunctionCallbackInfo<Value> &info)
        {
            typedef typename mpl::begin<TSignature>::type TSeqFirst;
            typedef typename TSeqFirst::type TResult;
            typedef typename mpl::next< TSeqFirst >::type TSeqInstanceType;
            
            typedef typename boost::remove_const<typename boost::remove_reference<typename TSeqInstanceType::type>::type >::type TInstanceType;
            
            /* Retrieve "this" from V8 */
            Local<Object> _this = info.Holder();
            
            /* Get address by casting the External saved value.
             Note that it was saved in NativeClass<TClass>::ctor */
            TInstanceType *instance = static_cast<TInstanceType *>(_this->GetAlignedPointerFromInternalField(_this->InternalFieldCount() - 2));
            
#if V8BRIDGE_DEBUG /* By default, we're always calling isInvokable before operator() (see NativeFunction), so we don't need this.
I'm leaving this validation in operator() too only for debugging sake. */
            if (!this->isInvokable(info)) {
                return v8::Undefined(this->m_isolationScope);
            }
#endif
            
# if N
#  define BOOST_PP_LOCAL_MACRO(i) V8_BRIDGE_SETUP_ARG(i, TSeqInstanceType)
#  define BOOST_PP_LOCAL_LIMITS (0, N-1)
#  include BOOST_PP_LOCAL_ITERATE()
# endif
            
            Handle<Value> result = bridge::detail::invoke_native(
                                                                 this->m_isolationScope,
                                                                 detail::invoke_tag<TResult, TPointer>()
                                                                 , this->m_callbackPointer
                                                                 , instance
                                                                 BOOST_PP_ENUM_TRAILING_PARAMS(N, resolvedArg)
                                                                 );
            
            
            return result;
        }
Example #15
0
int
# ifdef LUABIND_INVOKE_MEMBER
invoke_member
# else
invoke_normal
# endif
(
    lua_State* L, F const& f, Signature, Policies const&, mpl::long_<N>
# ifdef LUABIND_INVOKE_VOID
  , mpl::true_
# else
  , mpl::false_
# endif
)
{
    typedef typename mpl::begin<Signature>::type first;
# ifndef LUABIND_INVOKE_VOID
    typedef typename mpl::deref<first>::type result_type;
    typedef typename find_conversion_policy<0, Policies>::type result_policy;
    typename mpl::apply_wrap2<
        result_policy, result_type, cpp_to_lua>::type result_converter;
# endif

# if N > 0
#  define BOOST_PP_LOCAL_MACRO(n) LUABIND_INVOKE_DECLARE_CONVERTER(n)
#  define BOOST_PP_LOCAL_LIMITS (0,N-1)
#  include BOOST_PP_LOCAL_ITERATE()
# endif

    int const arguments = lua_gettop(L);

# ifndef LUABIND_INVOKE_VOID
    result_converter.apply(
        L,
# endif
# ifdef LUABIND_INVOKE_MEMBER
        (c0.apply(L, LUABIND_DECORATE_TYPE(a0), index0).*f)(
            BOOST_PP_ENUM(BOOST_PP_DEC(N), LUABIND_INVOKE_ARG, BOOST_PP_INC)
        )
# else
#  define LUABIND_INVOKE_IDENTITY(x) x
        f(
            BOOST_PP_ENUM(N, LUABIND_INVOKE_ARG, LUABIND_INVOKE_IDENTITY)
        )
#  undef LUABIND_INVOKE_IDENTITY
# endif
# ifndef LUABIND_INVOKE_VOID
    )
# endif
    ;

# if N > 0
#  define BOOST_PP_LOCAL_MACRO(n) LUABIND_INVOKE_CONVERTER_POSTCALL(n)
#  define BOOST_PP_LOCAL_LIMITS (0,N-1)
#  include BOOST_PP_LOCAL_ITERATE()
# endif

    int const results = lua_gettop(L) - arguments;

    int const indices[] = {
        arguments + results BOOST_PP_ENUM_TRAILING_PARAMS(N, index)
    };

    policy_list_postcall<Policies>::apply(L, indices);

    return maybe_yield(L, results, (Policies*)0);
}
Example #16
0
 typename apply_little<Little const BOOST_PP_ENUM_TRAILING(n, PSTADE_const, A)>::type
 operator()(BOOST_PP_ENUM_BINARY_PARAMS(n, A, const &a)) const
 {
     return call_little(m_little BOOST_PP_ENUM_TRAILING_PARAMS(n, a));
 }