Example #1
0
		inline void typeMismatchError(lua_State *state, const std::string& message)
		{
			ErrorHandler::instance().handle(message.c_str(), state);
#if !KAGUYA_ERROR_NO_THROW
			throw LuaTypeMismatch(message);
#endif
		}
typename traits::enable_if<traits::is_object<MemType>::value, int>::type
call(lua_State *state, MemType T::*mptr) {
  T *this_ = lua_type_traits<T *>::get(state, 1);
  if (lua_gettop(state) == 1) {
    if (!this_) {
      const T &this_ = lua_type_traits<const T &>::get(state, 1);
      if (is_usertype<MemType>::value && !traits::is_pointer<MemType>::value) {
        return util::push_args(
            state, standard::reference_wrapper<const MemType>(this_.*mptr));
      } else {
        return util::push_args(state, this_.*mptr);
      }
    } else {
      if (is_usertype<MemType>::value && !traits::is_pointer<MemType>::value) {
        return util::push_args(
            state, standard::reference_wrapper<MemType>(this_->*mptr));
      } else {
        return util::push_args(state, this_->*mptr);
      }
    }
  } else {
    if (!this_) {
      throw LuaTypeMismatch();
    }
    this_->*mptr = lua_type_traits<MemType>::get(state, 2);
    return 0;
  }
}
Example #3
0
			Res invoke(Res(ThisType::*f)(FArgs...)const, const ThisType* this_, Args&&... args)
			{
				if (!this_)
				{
					throw LuaTypeMismatch("type mismatch!!");
				}
				return (this_->*f)(std::forward<Args>(args)...);
			}
Example #4
0
			void invoke(void (ThisType::*f)(FArgs...), ThisType* this_, Args&&... args)
			{
				if (!this_)
				{
					throw LuaTypeMismatch("type mismatch!!");
				}
				(this_->*f)(std::forward<Args>(args)...);
			}
Example #5
0
typename lua_type_traits<T, Enable>::get_type
lua_type_traits<T, Enable>::get(lua_State *l, int index) {
  const typename traits::remove_reference<T>::type *pointer = get_const_pointer(
      l, index, types::typetag<typename traits::remove_reference<T>::type>());
  if (!pointer) {
    throw LuaTypeMismatch();
  }
  return *pointer;
}
Example #6
0
			int _call_apply(lua_State* state, MemType T::* m, unusedindex, MemType T::*)
			{
				T* this_ = lua_type_traits<T*>::get(state, 1);
				if (!this_)
				{
					throw LuaTypeMismatch("type mismatch!!");
				}
				if (lua_gettop(state) == 1)
				{
					return lua_type_traits<MemType>::push(state, this_->*m);
				}
				else
				{
					this_->*m = lua_type_traits<MemType>::get(state, 2);
					return 0;
				}
			}