Get rid of the FFI demo
This commit is contained in:
		
							parent
							
								
									7c528368a4
								
							
						
					
					
						commit
						12be2086b7
					
				
							
								
								
									
										2
									
								
								rust-ffi-demo/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								rust-ffi-demo/.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1,2 +0,0 @@ | |||||||
| demo |  | ||||||
| demo.h |  | ||||||
| @ -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 |  | ||||||
| @ -1,57 +0,0 @@ | |||||||
| #include <stdio.h> |  | ||||||
| #include <stdint.h> |  | ||||||
| 
 |  | ||||||
| #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 <Strength 100+> [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; |  | ||||||
| } |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user