@@ -1760,14 +1760,38 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) {
1760
1760
1761
1761
out << " {nullptr, nullptr, 0, nullptr}\n" << "};\n\n";
1762
1762
1763
+ if (!no_database) {
1764
+ out << "static const InterrogateModuleDef _in_module_def = {\n"
1765
+ << " " << def->file_identifier << ", /* file_identifier */\n"
1766
+ << " \"" << def->library_name << "\", /* library_name */\n"
1767
+ << " \"" << def->library_hash_name << "\", /* library_hash_name */\n"
1768
+ << " \"" << def->module_name << "\", /* module_name */\n";
1769
+ if (def->database_filename != nullptr) {
1770
+ out << " \"" << def->database_filename
1771
+ << "\", /* database_filename */\n";
1772
+ } else {
1773
+ out << " (const char *)0, /* database_filename */\n";
1774
+ }
1775
+
1776
+ out << " nullptr, /* unique_names */\n"
1777
+ << " 0, /* num_unique_names */\n";
1778
+ out << " nullptr, /* fptrs */\n"
1779
+ << " 0, /* num_fptrs */\n";
1780
+ out << " 1, /* first_index */\n"
1781
+ << " " << InterrogateDatabase::get_ptr()->get_next_index()
1782
+ << " /* next_index */\n"
1783
+ << "};\n\n";
1784
+ }
1785
+
1786
+ const char *def_ptr = no_database ? "nullptr" : "&_in_module_def";
1763
1787
if (_external_imports.empty()) {
1764
- out << "extern const struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs, exports, nullptr};\n";
1788
+ out << "extern const struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs, exports, nullptr, " << def_ptr << " };\n";
1765
1789
} else {
1766
1790
out <<
1767
1791
"#ifdef LINK_ALL_STATIC\n"
1768
- "extern const struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs, exports, nullptr};\n"
1792
+ "extern const struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs, exports, nullptr, " << def_ptr << " };\n"
1769
1793
"#else\n"
1770
- "extern const struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs, exports, imports};\n"
1794
+ "extern const struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs, exports, imports, " << def_ptr << " };\n"
1771
1795
"#endif\n";
1772
1796
}
1773
1797
if (out_h != nullptr) {
0 commit comments