diff options
-rw-r--r-- | libstorycode/narrative.c | 24 | ||||
-rw-r--r-- | libstorycode/narrative.h | 5 | ||||
-rw-r--r-- | libstorycode/presentation.c | 60 | ||||
-rw-r--r-- | libstorycode/presentation.h | 36 | ||||
-rw-r--r-- | libstorycode/slide.c | 54 | ||||
-rw-r--r-- | libstorycode/slide.h | 36 | ||||
-rw-r--r-- | libstorycode/storycode.c | 44 | ||||
-rw-r--r-- | libstorycode/storycode.h | 35 | ||||
-rw-r--r-- | libstorycode/storycode.l | 2 | ||||
-rw-r--r-- | libstorycode/stylesheet.c | 51 | ||||
-rw-r--r-- | libstorycode/stylesheet.h | 36 | ||||
-rw-r--r-- | meson.build | 25 | ||||
-rw-r--r-- | src/sc2_test.c | 12 |
13 files changed, 400 insertions, 20 deletions
diff --git a/libstorycode/narrative.c b/libstorycode/narrative.c index 971af82..c2e0d27 100644 --- a/libstorycode/narrative.c +++ b/libstorycode/narrative.c @@ -28,3 +28,27 @@ #include <stdlib.h> #include <string.h> +#include "narrative.h" + +struct _narrative +{ + int n_items; + struct narrative_item *items; +}; + + +Narrative *narrative_new() +{ + Narrative *n; + n = malloc(sizeof(*n)); + if ( n == NULL ) return NULL; + n->n_items = 0; + n->items = NULL; + return n; +} + +void narrative_free(Narrative *n) +{ + free(n->items); + free(n); +} diff --git a/libstorycode/narrative.h b/libstorycode/narrative.h index 096ace5..b9a9f7c 100644 --- a/libstorycode/narrative.h +++ b/libstorycode/narrative.h @@ -27,5 +27,10 @@ #include <config.h> #endif +typedef struct _narrative Narrative; + +extern Narrative *narrative_new(void); +extern void narrative_free(Narrative *n); + #endif /* NARRATIVE_H */ diff --git a/libstorycode/presentation.c b/libstorycode/presentation.c new file mode 100644 index 0000000..2ac751f --- /dev/null +++ b/libstorycode/presentation.c @@ -0,0 +1,60 @@ +/* + * presentation.c + * + * Copyright © 2019 Thomas White <taw@bitwiz.org.uk> + * + * This file is part of Colloquium. + * + * Colloquium is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdlib.h> +#include <string.h> + +#include "presentation.h" +#include "stylesheet.h" +#include "slide.h" +#include "narrative.h" + +struct _presentation +{ + Stylesheet *stylesheet; + Narrative *narrative; + int n_slides; + Slide **slides; +}; + + +Presentation *presentation_new() +{ + Presentation *p; + p = malloc(sizeof(*p)); + if ( p == NULL ) return NULL; + p->stylesheet = NULL; + p->narrative = NULL; + p->slides = NULL; + p->n_slides = 0; + return p; +} + +void presentation_free(Presentation *p) +{ + free(p); +} diff --git a/libstorycode/presentation.h b/libstorycode/presentation.h new file mode 100644 index 0000000..7f4b144 --- /dev/null +++ b/libstorycode/presentation.h @@ -0,0 +1,36 @@ +/* + * presentation.h + * + * Copyright © 2019 Thomas White <taw@bitwiz.org.uk> + * + * This file is part of Colloquium. + * + * Colloquium is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef PRESENTATION_H +#define PRESENTATION_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +typedef struct _presentation Presentation; + +extern Presentation *presentation_new(void); +extern void presentation_free(Presentation *p); + + +#endif /* PRESENTATION_H */ diff --git a/libstorycode/slide.c b/libstorycode/slide.c new file mode 100644 index 0000000..28a4ee3 --- /dev/null +++ b/libstorycode/slide.c @@ -0,0 +1,54 @@ +/* + * slide.c + * + * Copyright © 2019 Thomas White <taw@bitwiz.org.uk> + * + * This file is part of Colloquium. + * + * Colloquium is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdlib.h> +#include <string.h> + +#include "slide.h" + +struct _slide +{ + int n_items; + struct slide_item *items; +}; + + +Slide *slide_new() +{ + Slide *s; + s = malloc(sizeof(*s)); + if ( s == NULL ) return NULL; + s->n_items = 0; + s->items = NULL; + return s; +} + +void slide_free(Slide *s) +{ + free(s->items); + free(s); +} diff --git a/libstorycode/slide.h b/libstorycode/slide.h new file mode 100644 index 0000000..be9b08c --- /dev/null +++ b/libstorycode/slide.h @@ -0,0 +1,36 @@ +/* + * slide.h + * + * Copyright © 2019 Thomas White <taw@bitwiz.org.uk> + * + * This file is part of Colloquium. + * + * Colloquium is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef SLIDE_H +#define SLIDE_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +typedef struct _slide Slide; + +extern Slide *slide_new(void); +extern void slide_free(Slide *n); + + +#endif /* SLIDE_H */ diff --git a/libstorycode/storycode.c b/libstorycode/storycode.c new file mode 100644 index 0000000..e9eb505 --- /dev/null +++ b/libstorycode/storycode.c @@ -0,0 +1,44 @@ +/* + * storycode.c + * + * Copyright © 2019 Thomas White <taw@bitwiz.org.uk> + * + * This file is part of Colloquium. + * + * Colloquium is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdlib.h> +#include <string.h> + +#include "presentation.h" + +#include "storycode_parse.h" +#include "storycode_lex.h" + +Presentation *storycode_parse_presentation(const char *sc) +{ + YY_BUFFER_STATE b; + + b = sc_scan_string(sc); + scparse(); + sc_delete_buffer(b); + return NULL; +} diff --git a/libstorycode/storycode.h b/libstorycode/storycode.h new file mode 100644 index 0000000..476941e --- /dev/null +++ b/libstorycode/storycode.h @@ -0,0 +1,35 @@ +/* + * storycode.h + * + * Copyright © 2019 Thomas White <taw@bitwiz.org.uk> + * + * This file is part of Colloquium. + * + * Colloquium is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef STORYCODE_H +#define STORYCODE_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "presentation.h" + +extern Presentation *storycode_parse_presentation(const char *sc); + + +#endif /* STORYCODE_H */ diff --git a/libstorycode/storycode.l b/libstorycode/storycode.l index a64fbec..e8fd70a 100644 --- a/libstorycode/storycode.l +++ b/libstorycode/storycode.l @@ -22,7 +22,7 @@ %{ #define YYDEBUG 1 - #include "storycode.tab.h" + #include "storycode_parse.h" %} %option noyywrap nounput noinput diff --git a/libstorycode/stylesheet.c b/libstorycode/stylesheet.c new file mode 100644 index 0000000..00210ec --- /dev/null +++ b/libstorycode/stylesheet.c @@ -0,0 +1,51 @@ +/* + * stylesheet.c + * + * Copyright © 2019 Thomas White <taw@bitwiz.org.uk> + * + * This file is part of Colloquium. + * + * Colloquium is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdlib.h> +#include <string.h> + +#include "stylesheet.h" + +struct _stylesheet +{ + int n_items; +}; + + +Stylesheet *stylesheet_new() +{ + Stylesheet *s; + s = malloc(sizeof(*s)); + if ( s == NULL ) return NULL; + s->n_items = 0; + return s; +} + +void stylesheet_free(Stylesheet *s) +{ + free(s); +} diff --git a/libstorycode/stylesheet.h b/libstorycode/stylesheet.h new file mode 100644 index 0000000..f7af223 --- /dev/null +++ b/libstorycode/stylesheet.h @@ -0,0 +1,36 @@ +/* + * stylesheet.h + * + * Copyright © 2019 Thomas White <taw@bitwiz.org.uk> + * + * This file is part of Colloquium. + * + * Colloquium is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef STYLESHEET_H +#define STYLESHEET_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +typedef struct _stylesheet Stylesheet; + +extern Stylesheet *stylesheet_new(void); +extern void stylesheet_free(Stylesheet *s); + + +#endif /* STYLESHEET_H */ diff --git a/meson.build b/meson.build index 7e6ac83..6a03731 100644 --- a/meson.build +++ b/meson.build @@ -34,9 +34,9 @@ libstorycode_includes = include_directories('libstorycode') flex = find_program('flex') bison = find_program('bison') -storycode_tab_ch = custom_target('storycode.tab.c', - output : ['storycode.tab.c', - 'storycode.tab.h'], +storycode_parse_ch = custom_target('storycode_parse.c', + output : ['storycode_parse.c', + 'storycode_parse.h'], input : 'libstorycode/storycode.y', command : [bison, '--defines=@OUTPUT1@', '-p', 'sc', @@ -44,16 +44,21 @@ storycode_tab_ch = custom_target('storycode.tab.c', '--output=@OUTPUT0@', '@INPUT@']) -storycode_c = custom_target('storycode.c', - output : ['storycode.c', 'storycode.h'], - input : ['libstorycode/storycode.l', storycode_tab_ch], +storycode_lex_c = custom_target('storycode_lex.c', + output : ['storycode_lex.c', 'storycode_lex.h'], + input : ['libstorycode/storycode.l', storycode_parse_ch], command : [flex, '--outfile=@OUTPUT0@', '--header-file=@OUTPUT1@', '-P', 'sc', '@INPUT@']) + libstorycode = library('storycode', ['libstorycode/narrative.c', - storycode_c, + 'libstorycode/slide.c', + 'libstorycode/presentation.c', + 'libstorycode/stylesheet.c', + 'libstorycode/storycode.c', + storycode_lex_c, ], include_directories : libstorycode_includes, install : true) @@ -64,9 +69,9 @@ libstorycode_dep = declare_dependency(include_directories : libstorycode_include executable('sc2_test', ['src/sc2_test.c', - ], - gresources, - dependencies : [gtkdep, libstorycode_dep]) + ], + gresources, + dependencies : [gtkdep, libstorycode_dep]) # Main program executable('colloquium', diff --git a/src/sc2_test.c b/src/sc2_test.c index 3279887..1dc4099 100644 --- a/src/sc2_test.c +++ b/src/sc2_test.c @@ -27,29 +27,23 @@ #include <glib/gstdio.h> #include <gio/gio.h> -#include "storycode.tab.h" #include "storycode.h" +#include "presentation.h" //int scdebug = 1; int main(int argc, char *argv[]) { - YY_BUFFER_STATE b; GFile *file; GBytes *bytes; const char *text; size_t len; + Presentation *p; file = g_file_new_for_uri("resource:///uk/me/bitwiz/Colloquium/demo.sc"); bytes = g_file_load_bytes(file, NULL, NULL, NULL); text = g_bytes_get_data(bytes, &len); - - printf("Here goes...\n"); - b = sc_scan_string(text); - scparse(); - sc_delete_buffer(b); - printf("Done.\n"); - + p = storycode_parse_presentation(text); g_bytes_unref(bytes); return 0; |