This is a large diff, but most of the work is mechanical.
Allow the test-runner to initialize more than one C++ file.
Adding a lookup for External types so the templates have more detail about what the External (imported) types actually are.
Adding a ext-types fixture.
The most interesting of these is the second:
Before rendering any files, a pass is taken of all ComponentInterfaces.
Each type is collected, and added to a type map, keyed by module-path and name.
When an external type is encountered later, the type map is consulted, and the actual type
is used.
This is to remove a deficiency in Type::External: the ExternalKind enum did not map completely onto a Type:
before this change, it wasn't clear what sort of type was being imported, and so it was difficult/impossible
to work out how to import (import { X } vs import { type X }), or what to import: X vs XInterface.
This meant changing the type_name, ffi_converter_name and some other filter methods, necessitating many template files. These changes can be largely skimmed over.
The test also caught a runtime bug, which is also fixed in this PR: when a Rust trait is implemented by Rust, but exposed (as a typescript interface), this was erroring at runtime with a UniffiStaleHandleError. This is now fixed.
According to The Big O of Code Reviews, this is a O(n) change.
This is a large diff, but most of the work is mechanical.
External
types so the templates have more detail about what theExternal
(imported) types actually are.ext-types
fixture.The most interesting of these is the second:
Before rendering any files, a pass is taken of all
ComponentInterface
s.Each type is collected, and added to a type map, keyed by module-path and name.
When an external type is encountered later, the type map is consulted, and the actual type is used.
This is to remove a deficiency in
Type::External
: theExternalKind
enum did not map completely onto aType
: before this change, it wasn't clear what sort of type was being imported, and so it was difficult/impossible to work out how to import (import { X }
vsimport { type X }
), or what to import:X
vsXInterface
.This meant changing the
type_name
,ffi_converter_name
and some other filter methods, necessitating many template files. These changes can be largely skimmed over.The test also caught a runtime bug, which is also fixed in this PR: when a Rust trait is implemented by Rust, but exposed (as a typescript
interface
), this was erroring at runtime with aUniffiStaleHandleError
. This is now fixed.