]> git.tdb.fi Git - libs/game.git/blobdiff - tools/setupgen/setupgen.cpp
Support API decorations for setups
[libs/game.git] / tools / setupgen / setupgen.cpp
index efb93fb81c32e80f0093a5fbd92396996ea0678a..204045fbd364a90c5da1199cdb10176e07de633e 100644 (file)
@@ -106,6 +106,8 @@ void SetupGen::collect_headers(const Module &mod)
 {
        headers.insert("msp/datafile/objectloader.h");
        headers.insert("msp/strings/lexicalcast.h");
+       if(!mod.api_header.empty())
+               headers.insert(mod.api_header);
        for(const unique_ptr<Struct> &s: mod.structs)
                for(const Struct::Field &f: s->get_fields())
                        if(const string &h = f.type->get_header(); !h.empty())
@@ -131,6 +133,8 @@ void SetupGen::generate_header(const Module &mod, IO::Base &out) const
                        IO::print(out, "#include <%s>\n", h);
        }
 
+       IO::print(out, "\n#define API %s\n", mod.api);
+
        if(!mod.name_space.empty())
                IO::print(out, "\nnamespace %s {\n", mod.name_space);
 
@@ -196,6 +200,8 @@ SetupGen::Loader::Loader(SetupGen &s, Module &m):
 
 void SetupGen::Loader::init_actions()
 {
+       add("api", &Loader::api);
+       add("api", &Loader::api_with_header);
        add("component", &Loader::struct_def, Struct::COMPONENT);
        add("entity", &Loader::struct_def, Struct::ENTITY);
        add("enum", &Loader::enum_def);
@@ -203,6 +209,17 @@ void SetupGen::Loader::init_actions()
        add("namespace", &Loader::name_space);
 }
 
+void SetupGen::Loader::api(const string &a)
+{
+       api_with_header(a, string());
+}
+
+void SetupGen::Loader::api_with_header(const string &a, const string &h)
+{
+       mod.api = a;
+       mod.api_header = h;
+}
+
 void SetupGen::Loader::enum_def(const DataFile::Symbol &n)
 {
        Enum en(n.name);