diff --git a/include/hx/Coroutine.h b/include/hx/Coroutine.h new file mode 100644 index 000000000..3f5146387 --- /dev/null +++ b/include/hx/Coroutine.h @@ -0,0 +1,52 @@ +#pragma once + +#include + +namespace hx +{ + struct Coroutine + { + static Dynamic suspend(Dynamic f, Dynamic cont) + { + struct SuspendCaller final : public hx::Object + { + Dynamic f; + Dynamic cont; + + SuspendCaller(Dynamic inF, Dynamic inCont) : f(inF), cont(inCont) + { + HX_OBJ_WB_NEW_MARKED_OBJECT(this); + } + + Dynamic HX_LOCAL_RUN() + { + return f(cont); + } + + Dynamic __run(const Dynamic&, const Dynamic&) override + { + return HX_LOCAL_RUN(); + } + + Dynamic __Run(const Array& args) override + { + return HX_LOCAL_RUN(); + } + + void __Mark(hx::MarkContext* __inCtx) override + { + HX_MARK_MEMBER(__inCtx); + } + +#ifdef HXCPP_VISIT_ALLOCS + void __Visit(hx::VisitContext* __inCtx) override + { + HX_VISIT_MEMBER(__inCtx); + } +#endif + }; + + return new SuspendCaller(f, cont); + } + }; +} \ No newline at end of file diff --git a/include/hxcpp.h b/include/hxcpp.h index 92db51586..81815a470 100755 --- a/include/hxcpp.h +++ b/include/hxcpp.h @@ -383,6 +383,7 @@ typedef bool PropertyAccess; #else #include #endif +#include #endif

AltStyle によって変換されたページ (->オリジナル) /