|
91 | 91 | } |
92 | 92 |
|
93 | 93 |
|
94 | | -#: Extra wire spellings the C++ client accepts for an enum (C++ enum name -> {spelling: member |
95 | | -#: NAME}). Only spellings peers really send, which the hand-written client always accepted: |
96 | | -#: vgi-go, vgi-rust and vgi-java send ``function_type`` / ``macro_type`` in lower case, and |
97 | | -#: ``table_in_out`` is the legacy name of TABLE. Encoding always writes the canonical name. |
98 | | -ENUM_WIRE_ALIASES: dict[str, dict[str, str]] = { |
99 | | - "FunctionType": { |
100 | | - "scalar": "SCALAR", |
101 | | - "table": "TABLE", |
102 | | - "table_in_out": "TABLE", |
103 | | - "table_buffering": "TABLE_BUFFERING", |
104 | | - "aggregate": "AGGREGATE", |
105 | | - }, |
106 | | - # vgi-go, vgi-rust and vgi-java send macro_type in lower case too. |
107 | | - "MacroType": {"scalar": "SCALAR", "table": "TABLE"}, |
108 | | -} |
109 | | - |
110 | | - |
111 | 94 | def cpp_name(py_name: str) -> str: |
112 | 95 | """The C++ type name for a protocol type's Python name.""" |
113 | 96 | return CPP_NAMES.get(py_name) or cs.csharp_name(py_name) |
@@ -504,16 +487,6 @@ def _render_source(model: _Model, namespace: list[str]) -> str: |
504 | 487 | out.write(f"std::optional<{e.name}> {e.name}FromWire(const std::string &wire) {{\n") |
505 | 488 | out.write(f"\tfor (int16_t i = 0; i < k{e.name}Count; i++) {{\n") |
506 | 489 | out.write(f"\t\tif (wire == k{e.name}Wire[i]) {{\n\t\t\treturn static_cast<{e.name}>(i);\n\t\t}}\n\t}}\n") |
507 | | - aliases = ENUM_WIRE_ALIASES.get(e.name, {}) |
508 | | - if aliases: |
509 | | - member_ident = {m.wire_name: m.ident for m in e.members} |
510 | | - out.write( |
511 | | - "\t// Accepted spellings beyond the canonical names (vgi.codegen.cpp_records.ENUM_WIRE_ALIASES).\n" |
512 | | - ) |
513 | | - for alias, member in sorted(aliases.items()): |
514 | | - if member not in member_ident: |
515 | | - raise GeneratorError(f"{e.name}: alias {alias!r} names unknown member {member!r}") |
516 | | - out.write(f'\tif (wire == "{alias}") {{\n\t\treturn {e.name}::{member_ident[member]};\n\t}}\n') |
517 | 490 | out.write("\treturn std::nullopt;\n}\n\n") |
518 | 491 | out.write(f"void ReadValue(const arrow::Array &array, int64_t i, {e.name} &out, const wire::Ctx &ctx) {{\n") |
519 | 492 | out.write("\tstd::string s;\n\twire::ReadValue(array, i, s, ctx);\n") |
|
0 commit comments