Example #1
0
				~proxy_functor_caller()
				{
					if (m_called) return;

					m_called = true;
					lua_State* L = m_func->lua_state();

					// get the function
					m_func->pushvalue();

					push_args_from_tuple<1>::apply(L, m_args);
					if (pcall(L, boost::tuples::length<Tuple>::value, 0))
					{ 
#ifndef LUABIND_NO_EXCEPTIONS
						throw luabind::error(L);
#else
						error_callback_fun e = get_error_callback();
						if (e) e(L);
	
						/*assert(0 && "the lua function threw an error and exceptions are disabled."
							"if you want to handle this error use luabind::set_error_callback()");
						std::terminate();*/
#endif
					}
				}
Example #2
0
				~proxy_member_caller()
				{
					if (m_called) return;

					m_called = true;

					// don't count the function and self-reference
					// since those will be popped by pcall
					int top = lua_gettop(L) - 2;

					// pcall will pop the function and self reference
					// and all the parameters

					push_args_from_tuple<1>::apply(L, m_args);
					if (pcall(L, boost::tuples::length<Tuple>::value + 1, 0))
					{
						assert(lua_gettop(L) == top + 1);
#ifndef LUABIND_NO_EXCEPTIONS
						throw luabind::error(L);
#else
						error_callback_fun e = get_error_callback();
						if (e) e(L);
	
						assert(0 && "the lua function threw an error and exceptions are disabled."
								"If you want to handle this error use luabind::set_error_callback()");
						std::terminate();
#endif
					}
					// pops the return values from the function
					stack_pop pop(L, lua_gettop(L) - top);
				}
Example #3
0
    ~proxy_function_caller() noexcept(false)
    {
        if (m_called) return;

        m_called = true;
        lua_State* L = m_state;

        int top = lua_gettop(L);

        push_args_from_tuple<1>::apply(L, m_args);
        if (m_fun(L, boost::tuples::length<Tuple>::value, 0))
        {
            assert(lua_gettop(L) == top - m_params + 1);
#ifndef LUABIND_NO_EXCEPTIONS
            throw luabind::error(L);
#else
            error_callback_fun e = get_error_callback();
            if (e) e(L);

            assert(0 && "the lua function threw an error and exceptions are disabled."
                   " If you want to handle the error you can use luabind::set_error_callback()");
            std::terminate();

#endif
        }

        // pops the return values from the function call
        stack_pop pop(L, lua_gettop(L) - top + m_params);
    }
                void operator[](const Policies& p)
                {
                    m_called = true;

                    // don't count the function and self-reference
                    // since those will be popped by pcall
                    int top = lua_gettop(L) - 2;

                    // pcall will pop the function and self reference
                    // and all the parameters

                    detail::push_args_from_tuple<1>::apply(L, m_args, p);
                    if (pcall(L, boost::tuples::length<Tuple>::value + 1, 0))
                    {
                        assert(lua_gettop(L) == top + 1);
#ifndef LUAPONTE_NO_EXCEPTIONS
                        throw error(L);
#else
                        error_callback_fun e = get_error_callback();
                        if (e) e(L);

                        assert(0 && "the lua function threw an error and exceptions are disabled."
                            "If you want to handle this error use luaponte::set_error_callback()");
                        std::terminate();
#endif
                    }
                    // pops the return values from the function
                    stack_pop pop(L, lua_gettop(L) - top);
                }
Example #5
0
				Ret operator[](const Policies& p)
				{
					typedef typename find_conversion_policy<0, Policies>::type converter_policy;
					typename mpl::apply_wrap2<converter_policy,Ret,lua_to_cpp>::type converter;

					m_called = true;

					// don't count the function and self-reference
					// since those will be popped by pcall
					int top = lua_gettop(L) - 2;

					// pcall will pop the function and self reference
					// and all the parameters

					detail::push_args_from_tuple<1>::apply(L, m_args, p);
# ifdef LUABIND_CPP0x
                    if (pcall(L, std::tuple_size<Tuple>::value + 1, 1))
# else
					if (pcall(L, boost::tuples::length<Tuple>::value + 1, 1))
# endif
					{
						assert(lua_gettop(L) == top + 1);
#ifndef LUABIND_NO_EXCEPTIONS
						throw error(L);
#else
						error_callback_fun e = get_error_callback();
						if (e) e(L);

						assert(0 && "the lua function threw an error and exceptions are disabled."
							"If you want to handle this error use luabind::set_error_callback()");
						std::terminate();
#endif
					}

					// pops the return values from the function
					stack_pop pop(L, lua_gettop(L) - top);

					if (converter.match(L, LUABIND_DECORATE_TYPE(Ret), -1) < 0)
					{
						assert(lua_gettop(L) == top + 1);
#ifndef LUABIND_NO_EXCEPTIONS
						throw cast_failed(L, typeid(Ret));
#else
						cast_failed_callback_fun e = get_cast_failed_callback();
						if (e) e(L, typeid(Ret));

						assert(0 && "the lua function's return value could not be converted."
							"If you want to handle this error use luabind::set_error_callback()");
						std::terminate();
#endif
					}

					return converter.apply(L, LUABIND_DECORATE_TYPE(Ret), -1);
				}
Example #6
0
		inline void call_error(lua_State* L)
		{
#ifndef LUABIND_NO_EXCEPTIONS
			throw luabind::error(L);
#else
			error_callback_fun e = get_error_callback();
			if (e) e(L);

			assert(0 && "the lua function threw an error and exceptions are disabled."
				" If you want to handle the error you can use luabind::set_error_callback()");
			std::terminate();
#endif
		}
Example #7
0
				void operator[](const Policies& p)
				{
					m_called = true;
					lua_State* L = m_func->lua_state();
#ifndef LUABIND_NO_ERROR_CHECKING
					if (L == 0)
					{
	#ifndef LUABIND_NO_EXCEPTIONS
						throw error(L); 
	#else
						error_callback_fun e = get_error_callback();
						if (e) e(L);
	
						/*assert(0 && "tried to call uninitialized functor object."
							"if you want to handle this error use luabind::set_error_callback()");
						std::terminate();*/
	#endif
					}
#endif


					// get the function
					m_func->pushvalue();

					detail::push_args_from_tuple<1>::apply(L, m_args, p);
					if (pcall(L, boost::tuples::length<Tuple>::value, 0))
					{ 
#ifndef LUABIND_NO_EXCEPTIONS
						throw error(L); 
#else
						error_callback_fun e = get_error_callback();
						if (e) e(L);
	
						assert(0 && "the lua function threw an error and exceptions are disabled."
							"if you want to handle this error use luabind::set_error_callback()");
						std::terminate();
#endif
					}
				}
Example #8
0
    Ret operator[](const Policies& p)
    {
        typedef typename detail::find_conversion_policy<0, Policies>::type converter_policy;
        typename mpl::apply_wrap2<converter_policy,Ret,lua_to_cpp>::type converter;

        m_called = true;
        lua_State* L = m_state;

        int top = lua_gettop(L);

        detail::push_args_from_tuple<1>::apply(L, m_args, p);
        if (m_fun(L, boost::tuples::length<Tuple>::value, 1))
        {
            assert(lua_gettop(L) == top - m_params + 1);
#ifndef LUABIND_NO_EXCEPTIONS
            throw error(L);
#else
            error_callback_fun e = get_error_callback();
            if (e) e(L);

            assert(0 && "the lua function threw an error and exceptions are disabled."
                   " If you want to handle the error you can use luabind::set_error_callback()");
            std::terminate();
#endif
        }

        // pops the return values from the function call
        stack_pop pop(L, lua_gettop(L) - top + m_params);

        if (converter.match(L, LUABIND_DECORATE_TYPE(Ret), -1) < 0)
        {
#ifndef LUABIND_NO_EXCEPTIONS
            throw cast_failed(L, typeid(Ret));
#else
            cast_failed_callback_fun e = get_cast_failed_callback();
            if (e) e(L, typeid(Ret));

            assert(0 && "the lua function's return value could not be converted."
                   " If you want to handle the error you can use luabind::set_error_callback()");
            std::terminate();

#endif
        }

        return converter.apply(L, LUABIND_DECORATE_TYPE(Ret), -1);
    }
Example #9
0
				Ret operator[](const Policies& p)
				{
					typedef typename detail::find_conversion_policy<0, Policies>::type converter_policy;
					typename converter_policy::template generate_converter<Ret, lua_to_cpp>::type converter;

					m_called = true;
					lua_State* L = m_func->lua_state();
#ifndef LUABIND_NO_ERROR_CHECKING
					if (L == 0)
					{
	#ifndef LUABIND_NO_EXCEPTIONS
						throw error(L); 
	#else
						error_callback_fun e = get_error_callback();
						if (e) e(L);
	
						/*assert(0 && "tried to call uninitialized functor object."
							"if you want to handle this error use luabind::set_error_callback()");
						std::terminate();*/
	#endif
					}
#endif

					detail::stack_pop popper(L, 1); // pop the return value

					// get the function
					m_func->pushvalue();

					detail::push_args_from_tuple<1>::apply(L, m_args, p);
					if (pcall(L, boost::tuples::length<Tuple>::value, 1))
					{ 
#ifndef LUABIND_NO_EXCEPTIONS
						throw error(L);
#else
						error_callback_fun e = get_error_callback();
						if (e) e(L);
	
						/*assert(0 && "the lua function threw an error and exceptions are disabled."
							"if you want to handle this error use luabind::set_error_callback()");
						std::terminate();*/
#endif
					}

#ifndef LUABIND_NO_ERROR_CHECKING

					if (converter.match(L, LUABIND_DECORATE_TYPE(Ret), -1) < 0)
					{
#ifndef LUABIND_NO_EXCEPTIONS
						throw cast_failed(L, LUABIND_TYPEID(Ret));
#else
						cast_failed_callback_fun e = get_cast_failed_callback();
						if (e) e(L, LUABIND_TYPEID(Ret));

						/*assert(0 && "the lua function's return value could not be converted."
							"if you want to handle this error use luabind::set_error_callback()");
						std::terminate();*/
#endif
					}
#endif
					return converter.apply(L, LUABIND_DECORATE_TYPE(Ret), -1);
				}