diff options
| author | physick <mynameisgennadiy@vk.com> | 2026-07-15 17:46:13 +0500 |
|---|---|---|
| committer | physick <mynameisgennadiy@vk.com> | 2026-07-15 17:46:13 +0500 |
| commit | 8b79b8149d1e23d90b5871f980aec65d8aa7ae23 (patch) | |
| tree | 88a8788b75270dba53a15cbc2b6e0916f05301c6 /src/puzzles/puzzle.h | |
| parent | f314b56da42e1ead200e2373e9b214f77290d03b (diff) | |
Puzzle infrastructure pt 1.
Diffstat (limited to 'src/puzzles/puzzle.h')
| -rw-r--r-- | src/puzzles/puzzle.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/puzzles/puzzle.h b/src/puzzles/puzzle.h index d530a89..6c72a18 100644 --- a/src/puzzles/puzzle.h +++ b/src/puzzles/puzzle.h @@ -3,6 +3,16 @@ #ifndef PUZZLE_H +enum PUZZLE_TEST_RESULT : char { + RESULT_OK = 0, + RESULT_COMPTIME_NO_ENTRY, + RESULT_COMPTIME_ERR, + RESULT_RUNTIME_ERR, + // TODO: add async evaluation to prevent `while (true)` situation + RESULT_TIMEOUT, + RESULT_INIT_ERROR, +}; + // This is a param that would be placed in a slot // https://wren.io/embedding/slots-and-handles.html#writing-slots typedef struct { @@ -13,22 +23,32 @@ typedef struct { } PuzzleIO; typedef struct { + // https://wren.io/embedding/calling-wren-from-c.html#setting-up-a-receiver + char *RecieverName; // https://wren.io/embedding/calling-wren-from-c.html#getting-a-method-handle char *MainMethodSignature; size_t argc; PuzzleIO *argv; + PuzzleIO ExpectedResult; } Test; + +/// The user submitted code should be evaluated by this point. +/// The entry point should be registered and the absence of the +/// Main method signatire will be concidered an error +enum PUZZLE_TEST_RESULT RunTest(Test *test, WrenVM *vm); + typedef struct { char *Name; char *Description; + char *InitialCode; /// The tests that are accessible for an end user size_t TestC; Test *Tests; } Puzzle; - + // TODO void ReadPuzzleFromFile(const char *path); @@ -36,5 +56,15 @@ void FreePuzzle(Puzzle *self); /// A prebuilt puzzle. Used for debuging Puzzle *GetTestPuzzle(); +typedef struct { + char *stdout; + enum PUZZLE_TEST_RESULT result; +} SubmitionResult; + +// Don't put anything in out_res, it will be overriten. +// The stdout of the VM will be there +SubmitionResult *SubmitSolution(Puzzle *self, char *script); +void FreeSunmitionResult(SubmitionResult *res); + #define PUZZLE_H #endif // PUZZLE_H |
