Report imported explicit class template instantiation definitions in the
metadata.
This will be useful for instantiating C++ class template specializations from
Rust. Actually linking requests from `cc_template!` macro to imported
specializations will come in a followup.
PiperOrigin-RevId: 473224390
diff --git a/rs_bindings_from_cc/generate_bindings_and_metadata.cc b/rs_bindings_from_cc/generate_bindings_and_metadata.cc
index cb99248..6d8ff0c 100644
--- a/rs_bindings_from_cc/generate_bindings_and_metadata.cc
+++ b/rs_bindings_from_cc/generate_bindings_and_metadata.cc
@@ -39,13 +39,21 @@
cmdline.rustfmt_exe_path(),
cmdline.rustfmt_config_path()));
+ absl::flat_hash_map<std::string, std::string> instantiations;
+ for (const auto* record : ir.get_items_if<Record>()) {
+ if (record->is_explicit_class_template_instantiation_definition) {
+ instantiations.insert({record->cc_name, record->rs_name});
+ }
+ }
+
auto top_level_namespaces = crubit::CollectNamespaces(ir);
return BindingsAndMetadata{
.ir = ir,
.rs_api = bindings.rs_api,
.rs_api_impl = bindings.rs_api_impl,
- .namespaces = top_level_namespaces,
+ .namespaces = std::move(top_level_namespaces),
+ .instantiations = std::move(instantiations),
};
}