Complete StructuredData parity and parser hardening (#37)

This commit is contained in:
2026-08-09 01:51:29 +00:00
parent 6d02db8a9a
commit d980692933
18 changed files with 438 additions and 7 deletions

View File

@@ -78,6 +78,13 @@ NATIVE_TYPES = {
"T:LibreMetaverse.Utils": "crate::utils::Utils",
}
# Native declarations whose cataloged method implementations are still emitted
# below. This is used for static namespace types such as OSDParser: the type is
# hand-written, while its fixed public methods remain generator-audited.
NATIVE_DECLARATIONS = {
"T:LibreMetaverse.StructuredData.OSDParser": "crate::model::OSDParser",
}
NATIVE_MEMBER_BODIES = {
"M:LibreMetaverse.StructuredData.OSDParser.BufferCharactersEqual(System.IO.StringReader,System.Char[],System.Int32)":
"crate::notation::buffer_characters_equal(reader, buffer, offset)",
@@ -762,9 +769,14 @@ def render_type(item: dict, type_row: dict, member_rows: dict[str, dict[str, str
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"]):
native_declaration = NATIVE_DECLARATIONS.get(item["doc_id"])
if native_declaration:
lines.append(f"pub use {native_declaration} as {rust_name};")
elif derives := VALUE_DERIVES.get(item["doc_id"]):
lines.append(f"#[derive({derives})]")
if item["doc_id"] == "T:LibreMetaverse.StructuredData.OSD":
if native_declaration:
pass
elif item["doc_id"] == "T:LibreMetaverse.StructuredData.OSD":
lines += [
"#[non_exhaustive]",
"pub enum OSD {",
@@ -990,7 +1002,7 @@ def coverage_report(catalog: dict, coverage: dict[str, tuple[int, int, bool]]) -
native_type_ids = {
item["doc_id"]
for item in assembly["types"]
if item["doc_id"] in NATIVE_TYPES
if item["doc_id"] in NATIVE_TYPES or item["doc_id"] in NATIVE_DECLARATIONS
or (name == "LibreMetaverse.Types" and item["kind"] == "enum")
}
native_member_ids = {