57{
58 std::set<std::filesystem::path> signature_headers;
59 std::vector<std::string> class_includes { "#pragma once", "" };
60 std::vector<std::string> declarations;
61 std::vector<std::string> definitions;
62
63 for (const SignatureClass& item : classes) {
64 if (item.abstract) {
65 continue;
66 }
67 signature_headers.insert(item.includes.begin(), item.includes.end());
68 class_includes.push_back(include_line(item.entry.header.lexically_relative(source_root)));
69
70 constexpr std::string_view root = "MayaFlux::";
71 const std::string relative = item.entry.type_name.starts_with(root)
72 ? item.entry.type_name.substr(root.size())
73 : item.entry.type_name;
74 const std::string result = "std::shared_ptr<" + relative + ">";
75 for (const ConstructorSignature& constructor : item.constructors) {
76 declarations.push_back(" " + result + " " + item.entry.name + "("
77 + join_parameters(constructor, true) + ");");
78 definitions.push_back(result + " Creator::" + item.entry.name + "(" + join_parameters(constructor, false) + ")");
79 definitions.emplace_back("{");
80 definitions.push_back(" auto obj = std::make_shared<" + item.entry.type_name + ">("
81 + join_arguments(constructor) + ");");
82 definitions.push_back(" MF_LIVE_EXPOSE_NAMED(\"" + item.entry.name + "\", obj);");
83 definitions.emplace_back(" return obj;");
84 definitions.emplace_back("}");
85 definitions.emplace_back("");
86 }
87 }
88
89 std::vector<std::string> includes { "#pragma once", "" };
90 for (const std::filesystem::path& header : signature_headers) {
91 includes.push_back(include_line(header));
92 }
93
95 .includes = joined(includes) + "\n",
96 .classes = joined(class_includes) + "\n",
97 .declarations = joined(declarations) + "\n",
98 .definitions = joined(definitions),
99 };
100}