Translate wire semantics tests

This commit is contained in:
2026-08-08 18:00:11 +02:00
parent e656a4f6d2
commit de6e611ef0
32 changed files with 3488 additions and 1683 deletions

View File

@@ -72,6 +72,14 @@ WIRE_ROOT_TYPES = {
"T:LibreMetaverse.Tree",
"T:LibreMetaverse.TreeDefinition",
}
COMPOSED_BASE_TYPES = {
"T:LibreMetaverse.Messages.Linden.ChatSessionAcceptInvitation",
"T:LibreMetaverse.Messages.Linden.ChatSessionRequestMuteUpdate",
"T:LibreMetaverse.Messages.Linden.ChatSessionRequestStartConference",
"T:LibreMetaverse.Messages.Linden.MapLayerReplyVariant",
"T:LibreMetaverse.Packets.DirPlacesReplyPacket",
"T:LibreMetaverse.Packets.TestMessagePacket",
}
CORE_NAMESPACES = (
"LibreMetaverse.Http",
"LibreMetaverse.Stats",
@@ -529,6 +537,7 @@ def render_type(item: dict, type_row: dict, member_rows: dict[str, dict[str, str
else:
fields = [member for member in item["members"] if member["kind"] == "field" and not member.get("static")]
private_fields = PRIVATE_LAYOUTS.get(item["doc_id"], [])
base_type = item.get("base_type") if item["doc_id"] in COMPOSED_BASE_TYPES else None
if derives := VALUE_DERIVES.get(item["doc_id"]):
lines.append(f"#[derive({derives})]")
if item["doc_id"] == "T:LibreMetaverse.StructuredData.OSD":
@@ -541,10 +550,15 @@ def render_type(item: dict, type_row: dict, member_rows: dict[str, dict[str, str
" Array(Vec<OSD>), Map(std::collections::HashMap<String, OSD>), LlsdXml(String),",
"}",
]
elif not fields and not names and not private_fields:
elif not fields and not names and not private_fields and not base_type:
lines.append(f"pub struct {rust_name};")
else:
lines.append(f"pub struct {rust_name}{suffix} {{")
if base_type:
lines += [
f" /// Rust composition for C# base type `{base_type}`.",
f" pub base: {mapper.type(base_type, None, set(names))},",
]
for field in fields:
field_signature = member_rows[field["doc_id"]]["rust_signature"]
field_name_match = re.fullmatch(r"pub ([^:]+): (.+)", field_signature)