Translate types and utilities tests
Some checks failed
Rust API gates / api-gates (push) Has been cancelled
Some checks failed
Rust API gates / api-gates (push) Has been cancelled
This commit is contained in:
@@ -170,6 +170,12 @@ SUPPORT_TYPES = {
|
||||
MEMBER_RETURN_OVERRIDES = {
|
||||
"M:LibreMetaverse.Caps.Capabilities": "Vec<String>",
|
||||
}
|
||||
TYPE_USAGE_OVERRIDES = {
|
||||
"LibreMetaverse.DictionaryChangeCallback": (
|
||||
"std::sync::Arc<dyn Fn(libremetaverse::DictionaryEventAction, "
|
||||
"libremetaverse_types::compat::DictionaryEntry) + Send + Sync>"
|
||||
),
|
||||
}
|
||||
TYPE_NAME_OVERRIDES = {
|
||||
"T:LibreMetaverse.LslTools.Error": "LslError",
|
||||
}
|
||||
@@ -419,7 +425,13 @@ def function_bodies(text: str) -> list[str]:
|
||||
def validate_generated_shims() -> None:
|
||||
for path in sorted((ROOT / "crates").glob("*/src/generated*.rs")):
|
||||
text = path.read_text()
|
||||
if re.search(r"#\[derive\([^]]*\bDefault\b", text):
|
||||
default_types = set(
|
||||
re.findall(
|
||||
r"#\[derive\([^]]*\bDefault\b[^]]*\)\]\s*pub struct ([A-Za-z_][A-Za-z0-9_]*)",
|
||||
text,
|
||||
)
|
||||
)
|
||||
if default_types - {"UUID"}:
|
||||
raise ValueError(f"generated shim derives a plausible Default: {path.relative_to(ROOT)}")
|
||||
for body in function_bodies(text):
|
||||
if FAKE_BODY.search(body):
|
||||
@@ -514,7 +526,7 @@ class Mapper:
|
||||
if base in generics or ("." not in base and base.startswith("T")):
|
||||
target = base
|
||||
elif target is None:
|
||||
target = self.resolved.get(base)
|
||||
target = TYPE_USAGE_OVERRIDES.get(base, self.resolved.get(base))
|
||||
if target is None:
|
||||
raise ValueError(f"unresolved referenced type: {value} (base {base})")
|
||||
if mapped_arguments and base not in {
|
||||
|
||||
Reference in New Issue
Block a user