VRM_CORE_ALWAYS_INLINE constexpr static void exec( TF&& f, Ts&&... xs) // . noexcept(noexcept( (void)(std::initializer_list<int>{(f(FWD(xs)), 0)...}))) { using swallow = std::initializer_list<int>; return (void)(swallow{(f(FWD(xs)), 0)...}); }
VRM_CORE_ALWAYS_INLINE decltype(auto) apply_helper( TF&& f, TT&& t, std::index_sequence<TIs...>) // . noexcept(noexcept(FWD(f)(std::get<TIs>(FWD(t))...))) { // The `apply_helper` function calls `f` once, expanding the // contents of the `t` tuple as the function parameters. return FWD(f)(std::get<TIs>(FWD(t))...); }
void for_tuple(TF&& f, TTuple&& t) { auto adapted = [f = FWD(f)](auto&&... xs) { for_args(f, FWD(xs)...); }; std::experimental::apply(adapted, FWD(t)); }
void serialize(PcktBuf& p, Ts&&... xs) { ssvu::forArgs( [&p](auto&& x) { p << FWD(x); }, FWD(xs)...); // ::serialize(p, FWD(xs)...); }
auto static_for(TFBody&& body) { auto step = [body = FWD(body)]( auto self, auto state, auto&& x, auto&&... xs) { auto next_state = body(state, x); constexpr auto last_iteration = bool_v<(sizeof...(xs) == 0)>; constexpr auto must_break = bool_v<( // . std::is_same< // . decltype(next_state.next_action()), // . impl::action::a_break // . >{} // . )>; return static_if(bool_v<(must_break || last_iteration)>) .then([next_state](auto&&) { return next_state.accumulator(); }) .else_([next_state, state, &xs...](auto&& xself) { // vvvvv return xself(next_state, xs...); })(self); }; return [step = std::move(step)](auto accumulator) { return [step, accumulator](auto&&... xs) { return static_if(bool_v<(sizeof...(xs) == 0)>) .then([accumulator](auto&&) { return accumulator; }) .else_([accumulator](auto&& xstep, auto&&... ys) { auto initial_state = impl::make_state( // . sz_v<0>, // . accumulator, // . impl::action::a_continue{} // . ); // vvvvvvvvvvvvvvvvvvv return y_combinator(xstep)( // . initial_state, FWD(ys)...); })(step, FWD(xs)...); }; }; }
inline NodePtr createNode(TArgs&&... mArgs) { SSVU_ASSERT_STATIC( ssvu::isBaseOf<GraphNode<TGraph>, NodeDerived>(), "TNode must be derived from Graph::Node"); return &ssvu::getEmplaceUPtr<NodeDerived>(nodes, FWD(mArgs)...); }
auto then(FThen&& f_then) { return ::node{[parent = std::move(*this), f_then = FWD(f_then)]() mutable { return f_then(static_cast<F&>(parent)()); }}; }
kern_return_t catch_exception_raise( mach_port_t exception_port,mach_port_t thread,mach_port_t task, exception_type_t exception,exception_data_t code, mach_msg_type_number_t code_count ) { kern_return_t r; char *addr; #ifdef __POWERPC__ thread_state_flavor_t flavor = PPC_EXCEPTION_STATE; mach_msg_type_number_t exc_state_count = PPC_EXCEPTION_STATE_COUNT; ppc_exception_state_t exc_state; #else # error FIXME for non-ppc darwin #endif /* we should never get anything that isn't EXC_BAD_ACCESS, but just in case */ if(exception != EXC_BAD_ACCESS) { /* We aren't interested, pass it on to the old handler */ fprintf(stderr,"Exception: 0x%x Code: 0x%x 0x%x in catch....\n", exception, code_count > 0 ? code[0] : -1, code_count > 1 ? code[1] : -1); return FWD(); } r = thread_get_state(thread,flavor, (natural_t*)&exc_state,&exc_state_count); if(r != KERN_SUCCESS) DIE("thread_get_state"); /* This is the address that caused the fault */ addr = (char*) exc_state.dar; #ifdef TEST if(!my_handle_exn(addr, code[0])) return FWD(); #else segv_generic(addr, code[0]); #endif return KERN_SUCCESS; }
inline Pckt(nl::init_fields, Ts&&... mX) : fields(FWD(mX)...) { }
inline void linkTo(const NodePtr& mNode, TArgs&&... mArgs) { SSVU_ASSERT(TGraph::isNodeValid(mNode)); TGraph::StorageNodeBase::emplaceLink(mNode, FWD(mArgs)...); }
inline void emplaceLink(TArgs&&... mArgs) { links.emplace_back(FWD(mArgs)...); }
inline NodePtr createNode(TArgs&&... mArgs) { auto result(storage.createNode(FWD(mArgs)...)); nodes.emplace_back(result); return result; }
inline void linkToSelf(TArgs&&... mArgs) { TGraph::StorageNodeBase::emplaceLink( TGraph::StorageNodeBase::getNodePtr(this), FWD(mArgs)...); }
#define VRM_CORE_IMPL_DEFINE_ARGS_SLICE_WRAPPER_SN(fn) \ VRM_CORE_IMPL_DEFINE_ARGS_SLICE_WRAPPER(VRM_PP_CAT(fn, _wrapper), fn) VRM_CORE_NAMESPACE { namespace impl { /// @brief Defines a wrapper that, after slicing a variadic argument /// pack, applies the resulting `ref_tuple` to the function `f`. /// @details The used slicing function is passed in as `TFArgGetter`, /// under the form of a `constexpr`-friendly wrapper. template <typename TFArgGetter, typename TF, typename... Ts> VRM_CORE_ALWAYS_INLINE constexpr decltype(auto) // . args_call_wrapper(TFArgGetter, TF&& f, Ts&&... xs) // . VRM_CORE_IMPL_NOEXCEPT_AND_RETURN_BODY_VA( // . apply(f, TFArgGetter{}(FWD(xs)...)) // . ) } namespace impl { // Call the macros to define all wrappers. VRM_CORE_IMPL_DEFINE_ARGS_SLICE_WRAPPER_SN(first_n_args) VRM_CORE_IMPL_DEFINE_ARGS_SLICE_WRAPPER_SN(last_n_args) VRM_CORE_IMPL_DEFINE_ARGS_SLICE_WRAPPER_SN(all_args_from) VRM_CORE_IMPL_DEFINE_ARGS_SLICE_WRAPPER_SN(all_args_after) VRM_CORE_IMPL_DEFINE_ARGS_SLICE_WRAPPER_SN(all_args_until) VRM_CORE_IMPL_DEFINE_ARGS_SLICE_WRAPPER_SN(all_args_before) } } VRM_CORE_NAMESPACE_END
UDPSckt(Ts&&... xs) : sckt{FWD(xs)...} { sckt.setBlocking(false); }
/* - step - map set of states reachable before char to set reachable after == static states step(struct re_guts *g, sopno start, sopno stop, \ == states bef, int ch, states aft); == #define BOL (OUT-1) == #define EOL (BOL-1) == #define BOLEOL (BOL-2) == #define NOTHING (BOL-3) == #define BOW (BOL-4) == #define EOW (BOL-5) == #define BADCHAR (BOL-6) == #define NONCHAR(c) ((c) <= OUT) */ static states step(struct re_guts *g, sopno start, /* start state within strip */ sopno stop, /* state after stop state within strip */ states bef, /* states reachable before */ wint_t ch, /* character or NONCHAR code */ states aft) /* states already known reachable after */ { cset *cs; sop s; sopno pc; onestate here; /* note, macros know this name */ sopno look; int i; for (pc = start, INIT(here, pc); pc != stop; pc++, INC(here)) { s = g->strip[pc]; switch (OP(s)) { case OEND: assert(pc == stop-1); break; case OCHAR: /* only characters can match */ assert(!NONCHAR(ch) || ch != OPND(s)); if (ch == OPND(s)) FWD(aft, bef, 1); break; case OBOL: if (ch == BOL || ch == BOLEOL) FWD(aft, bef, 1); break; case OEOL: if (ch == EOL || ch == BOLEOL) FWD(aft, bef, 1); break; case OBOW: if (ch == BOW) FWD(aft, bef, 1); break; case OEOW: if (ch == EOW) FWD(aft, bef, 1); break; case OANY: if (!NONCHAR(ch)) FWD(aft, bef, 1); break; case OANYOF: cs = &g->sets[OPND(s)]; if (!NONCHAR(ch) && CHIN(cs, ch)) FWD(aft, bef, 1); break; case OBACK_: /* ignored here */ case O_BACK: FWD(aft, aft, 1); break; case OPLUS_: /* forward, this is just an empty */ FWD(aft, aft, 1); break; case O_PLUS: /* both forward and back */ FWD(aft, aft, 1); i = ISSETBACK(aft, OPND(s)); BACK(aft, aft, OPND(s)); if (!i && ISSETBACK(aft, OPND(s))) { /* oho, must reconsider loop body */ pc -= OPND(s) + 1; INIT(here, pc); } break; case OQUEST_: /* two branches, both forward */ FWD(aft, aft, 1); FWD(aft, aft, OPND(s)); break; case O_QUEST: /* just an empty */ FWD(aft, aft, 1); break; case OLPAREN: /* not significant here */ case ORPAREN: FWD(aft, aft, 1); break; case OCH_: /* mark the first two branches */ FWD(aft, aft, 1); assert(OP(g->strip[pc+OPND(s)]) == OOR2); FWD(aft, aft, OPND(s)); break; case OOR1: /* done a branch, find the O_CH */ if (ISSTATEIN(aft, here)) { for (look = 1; OP(s = g->strip[pc+look]) != O_CH; look += OPND(s)) assert(OP(s) == OOR2); FWD(aft, aft, look); } break; case OOR2: /* propagate OCH_'s marking */ FWD(aft, aft, 1); if (OP(g->strip[pc+OPND(s)]) != O_CH) { assert(OP(g->strip[pc+OPND(s)]) == OOR2); FWD(aft, aft, OPND(s)); } break; case O_CH: /* just empty */ FWD(aft, aft, 1); break; default: /* ooooops... */ assert(nope); break; } } return(aft); }
vnum_wrapper(Ts&&... xs) : _data{FWD(xs)...} { }
inline void emplace(TArgs&&... mArgs) { particles.emplace_back(FWD(mArgs)...); }
inline auto& appendToImpl(std::string& mStr, T&& mA, TArgs&&... mArgs) { mStr += FWD(mA); return appendToImpl(mStr, FWD(mArgs)...); }
inline T& create(const std::string& mName, TArgs&&... mArgs) { return ssvu::getEmplaceUPtr<T>( items, menu, *this, mName, FWD(mArgs)...); }
auto make_pckt(Ts&&... fields) { T res(nl::init_fields{}, FWD(fields)...); return res; }
inline static auto& mk(BTRChunk& mC, TArgs&&... mArgs) { return mC.mkEffect<T>(FWD(mArgs)...); }
node(FFwd&& f) : F{FWD(f)} { }
constexpr auto y_combinator(TF&& f) noexcept { return impl::y_combinator_result<std::decay_t<TF>>(FWD(f)); }
constexpr decltype(auto) operator()(Ts&&... xs) { return _f(std::ref(*this), FWD(xs)...); }
unmanaged(Ts&&... xs) noexcept : _handle{FWD(xs)...} { }
auto ECST_PURE_FN make_multi(TInstance& inst, TContext& ctx, Ts&&... xs) { return multi<TSystemSignature, TContext, TInstance>( inst, ctx, FWD(xs)...); }
inline void setTimer(TArgs&&... mArgs) { gameEngine->setTimer<T, TArgs...>(FWD(mArgs)...); }
inline auto& appendTo(std::string& mStr, TArgs&&... mArgs) { return Impl::appendToImpl(mStr, FWD(mArgs)...); }
constexpr explicit y_combinator_result(T&& f) noexcept // . : _f(FWD(f)) { }