h_name = "newdb.h"
c_name = "newdb.c"
-h_template = """#include <stdio.h>
+h_template = """/* Generated from adventure.yaml - do not hand-hack! */
+#ifndef NEWDB_H
+#define NEWDB_H
+
+#include <stdio.h>
typedef struct {{
const char* inventory;
extern obituary_t obituaries[];
extern hint_t hints[];
-extern size_t CLSSES;
-extern int maximum_deaths;
-extern int turn_threshold_count;
+extern const size_t CLSSES;
+extern const int maximum_deaths;
+extern const int turn_threshold_count;
+#define HINT_COUNT {}
enum arbitrary_messages_refs {{
{}
enum object_descriptions_refs {{
{}
}};
+
+#endif /* end NEWDB_H */
"""
-c_template = """#include "{}"
+c_template = """/* Generated from adventure.yaml - do not hand-hack! */
+
+#include "{}"
const char* arbitrary_messages[] = {{
{}
{}
}};
-size_t CLSSES = {};
-int maximum_deaths = {};
-int turn_threshold_count = {};
+const size_t CLSSES = {};
+const int maximum_deaths = {};
+const int turn_threshold_count = {};
+
+/* end */
"""
def make_c_string(string):
db = yaml.load(f)
h = h_template.format(
+ len(db["hints"]),
get_refs(db["arbitrary_messages"]),
get_refs(db["locations"]),
get_refs(db["object_descriptions"]),
with open(c_name, "w") as cf:
cf.write(c)
+
+# end