Unverified Commit 6011f63c authored by Mark Hammond's avatar Mark Hammond Committed by GitHub
Browse files

Stop carrying the namespace around in ExternalFfiMetadata and Type. (#2379)

This is needed only by bindings and can be determined as they are generated.
parent 06abb714
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -295,7 +295,7 @@ impl<'a> KotlinWrapper<'a> {
        })
    }

    pub fn initialization_fns(&self) -> Vec<String> {
    pub fn initialization_fns(&self, ci: &ComponentInterface) -> Vec<String> {
        let init_fns = self
            .ci
            .iter_types()
@@ -314,11 +314,7 @@ impl<'a> KotlinWrapper<'a> {
                if module_path == self.ci.crate_name() {
                    return None;
                }
                let namespace = if let Type::External { namespace, .. } = ty {
                    Some(namespace.as_str())
                } else {
                    None
                };
                let namespace = Some(ci.namespace_for_module_path(module_path).unwrap());
                Some((module_path, namespace))
            })
            .map(|(module_path, namespace)| {
+1 −0
Original line number Diff line number Diff line
{%- let namespace = ci.namespace_for_module_path(module_path)? %}
{%- let package_name=self.external_type_package_name(module_path, namespace) %}
{%- let fully_qualified_type_name = "{}.{}"|format(package_name, name|class_name(ci)) %}
{%- let fully_qualified_ffi_converter_name = "{}.FfiConverterType{}"|format(package_name, name) %}
+1 −1
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ internal interface UniffiLib : Library {
            val lib = loadIndirect<UniffiLib>(componentName)
            // No need to check the contract version and checksums, since 
            // we already did that with `IntegrityCheckingUniffiLib` above.
            {% for fn in self.initialization_fns() -%}
            {% for fn in self.initialization_fns(ci) -%}
            {{ fn }}
            {% endfor -%}
            // Loading of library with integrity check done.
+1 −1
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ object NoPointer
{%- when Type::Custom { module_path, name, builtin } %}
{% include "CustomTypeTemplate.kt" %}

{%- when Type::External { module_path, name, namespace, .. } %}
{%- when Type::External { module_path, name, .. } %}
{% include "ExternalTypeTemplate.kt" %}

{%- else %}
+2 −1
Original line number Diff line number Diff line
{%- let namespace = ci.namespace_for_type(type_)? %}
{%- let module = python_config.module_for_namespace(namespace) -%}

# External type {{name}} is in namespace "{{namespace}}", crate {{module_path}}
# External type {{ name }}: `from {{ module }} import {{ name }}`
{%- let ffi_converter_name = "_UniffiConverterType{}"|format(name) %}
{{ self.add_import_of(module, ffi_converter_name) }}
{{ self.add_import_of(module, name) }} {#- import the type alias itself -#}
Loading