{
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())
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);
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);
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);
struct Module
{
std::string name_space;
+ std::string api;
+ std::string api_header;
std::vector<std::unique_ptr<Enum>> enums;
std::vector<std::unique_ptr<Struct>> structs;
};
private:
void init_actions() override;
+ void api(const std::string &);
+ void api_with_header(const std::string &, const std::string &);
void enum_def(const Msp::DataFile::Symbol &);
void import(const std::string &);
void name_space(const std::string &);
void Struct::define_type(IO::Base &out) const
{
- IO::print(out, "struct %s\n{\n", name);
+ IO::print(out, "struct API %s\n{\n", name);
IO::print(out, "\tclass Loader;\n\n");
for(const Field &f: fields)
void Struct::define_loader(IO::Base &out) const
{
- IO::print(out, "class %s::Loader: public Msp::DataFile::ObjectLoader<%s>\n{\n", name, name);
+ IO::print(out, "class API %s::Loader: public Msp::DataFile::ObjectLoader<%s>\n{\n", name, name);
IO::print(out, "public:\n");
IO::print(out, "\tLoader(%s &);\n", name);
IO::print(out, "\nprivate:\n");