-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#pragma once | ||
|
||
#include <hxcpp.h> | ||
|
||
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<Dynamic>& 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); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -383,6 +383,7 @@ typedef bool PropertyAccess; | |
#else | ||
#include <cpp/Int64.h> | ||
#endif | ||
#include <hx/Coroutine.h> | ||
|
||
#endif | ||
|