From 12be2086b790df95fc243116e2d3b319baa46e03 Mon Sep 17 00:00:00 2001 From: Dane Johnson Date: Mon, 24 Jan 2022 11:39:44 -0600 Subject: [PATCH] Get rid of the FFI demo --- rust-ffi-demo/.gitignore | 2 -- rust-ffi-demo/Makefile | 9 ------- rust-ffi-demo/demo.c | 57 ---------------------------------------- 3 files changed, 68 deletions(-) delete mode 100644 rust-ffi-demo/.gitignore delete mode 100644 rust-ffi-demo/Makefile delete mode 100644 rust-ffi-demo/demo.c diff --git a/rust-ffi-demo/.gitignore b/rust-ffi-demo/.gitignore deleted file mode 100644 index 3ced3e3..0000000 --- a/rust-ffi-demo/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -demo -demo.h \ No newline at end of file diff --git a/rust-ffi-demo/Makefile b/rust-ffi-demo/Makefile deleted file mode 100644 index fcbb712..0000000 --- a/rust-ffi-demo/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LDFLAGS := -L../src/rust-base/target/debug -lstorybook -Wl,--gc-sections -lpthread -ldl -.PHONY: all clean -all: demo -demo: demo.h demo.c - $(CC) -g $^ $(LDFLAGS) -o $@ -demo.h: - cbindgen -c ../src/rust-base/cbindgen.toml --crate storybook --lang c -o demo.h ../src/rust-base -clean: - rm -f demo demo.h diff --git a/rust-ffi-demo/demo.c b/rust-ffi-demo/demo.c deleted file mode 100644 index da80835..0000000 --- a/rust-ffi-demo/demo.c +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include - -#include "demo.h" - -const char* story = "START\n" - "One day, Dane took a really big shit!\n" - "GOTO DIALOG\n" - "DIALOG\n" - "\"Wow, that was a really big shit!\"\n" - "1) Die [DIE]\n" - "2) Don't die [DONT_DIE] (-1 Honor)\n" - "DONT_DIE\n" - "But he died anyways.\n" - "GOTO DIE\n" - "DIE\n" - "Then he died. Fuck you, Dane!\n" - "THE END\n"; - -int main() { - Book *book = storybook_make_book(story); - - while(!storybook_is_ended(book)) { - char* s = storybook_get_body(book); - printf("%s\n", s); - storybook_free_string(s); - - enum footer footer = storybook_get_footer(book); - switch (footer) { - case (FOOTER_ENDING): - printf("The End\n"); - storybook_advance_nooption(book); - break; - case (FOOTER_GOTO): - storybook_advance_nooption(book); - break; - case (FOOTER_CHOICES): - ChoiceList *list = storybook_get_choices(book); - for (ChoiceList *curr = list; curr; curr = curr->next) { - const StatCheck *sk = curr->choice.statcheck; - if (sk) { - printf("\e[0;31m"); - } - printf("%d) %s", curr->choice.option, curr->choice.flavor); - printf("\n\e[0m"); - } - storybook_free_choices(list); - uint32_t option; - printf("Make a choice: "); - scanf("%d", &option); - storybook_advance_option(book, option); - } - } - - storybook_free_book(book); - return 0; -}