aboutsummaryrefslogtreecommitdiff
path: root/samples/bugreport
diff options
context:
space:
mode:
Diffstat (limited to 'samples/bugreport')
4 files changed, 69 insertions, 0 deletions
diff --git a/samples/bugreport/.gitignore b/samples/bugreport/.gitignore
new file mode 100644
index 0000000..378eac2
--- /dev/null
+++ b/samples/bugreport/.gitignore
@@ -0,0 +1 @@
+build
diff --git a/samples/bugreport/build.sh b/samples/bugreport/build.sh
new file mode 100755
index 0000000..2de7528
--- /dev/null
+++ b/samples/bugreport/build.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+cd $(dirname $0)
+
+FLATBUFFERS_DIR=../..
+NAME=myissue
+SCHEMA=eclectic.fbs
+OUT=build
+
+FLATCC_EXE=$FLATBUFFERS_DIR/bin/flatcc
+FLATCC_INCLUDE=$FLATBUFFERS_DIR/include
+FLATCC_LIB=$FLATBUFFERS_DIR/lib
+
+mkdir -p $OUT
+$FLATCC_EXE --outfile $OUT/${NAME}_generated.h -a $SCHEMA || exit 1
+cc -I$FLATCC_INCLUDE -g -o $OUT/$NAME $NAME.c -L$FLATCC_LIB -lflatccrt_d || exit 1
+echo "running $OUT/$NAME"
+if $OUT/$NAME; then
+ echo "success"
+else
+ echo "failed"
+ exit 1
+fi
diff --git a/samples/bugreport/eclectic.fbs b/samples/bugreport/eclectic.fbs
new file mode 100644
index 0000000..ad507e7
--- /dev/null
+++ b/samples/bugreport/eclectic.fbs
@@ -0,0 +1,11 @@
+namespace Eclectic;
+
+enum Fruit : byte { Banana = -1, Orange = 42 }
+table FooBar {
+ meal : Fruit = Banana;
+ density : long (deprecated);
+ say : string;
+ height : short;
+}
+file_identifier "NOOB";
+root_type FooBar;
diff --git a/samples/bugreport/myissue.c b/samples/bugreport/myissue.c
new file mode 100644
index 0000000..0098235
--- /dev/null
+++ b/samples/bugreport/myissue.c
@@ -0,0 +1,35 @@
+/* Minimal test with all headers generated into a single file. */
+#include "build/myissue_generated.h"
+#include "flatcc/support/hexdump.h"
+
+int main(int argc, char *argv[])
+{
+ int ret;
+ void *buf;
+ size_t size;
+ flatcc_builder_t builder, *B;
+
+ (void)argc;
+ (void)argv;
+
+ B = &builder;
+ flatcc_builder_init(B);
+
+ Eclectic_FooBar_start_as_root(B);
+ Eclectic_FooBar_say_create_str(B, "hello");
+ Eclectic_FooBar_meal_add(B, Eclectic_Fruit_Orange);
+ Eclectic_FooBar_height_add(B, -8000);
+ Eclectic_FooBar_end_as_root(B);
+ buf = flatcc_builder_get_direct_buffer(B, &size);
+#if defined(PROVOKE_ERROR) || 0
+ /* Provoke error for testing. */
+ ((char*)buf)[0] = 42;
+#endif
+ ret = Eclectic_FooBar_verify_as_root(buf, size);
+ if (ret) {
+ hexdump("Eclectic.FooBar buffer for myissue", buf, size, stdout);
+ printf("could not verify Electic.FooBar table, got %s\n", flatcc_verify_error_string(ret));
+ }
+ flatcc_builder_clear(B);
+ return ret;
+}