MCPcopy Create free account
hub / github.com/apache/fory / get_field_meta

Method get_field_meta

compiler/fory_compiler/generators/cpp.py:1554–1586  ·  view source on GitHub ↗

Build FieldMeta expression for a field.

(self, field: Field)

Source from the content-addressed store, hash-verified

1552 return f"({self.get_field_member_name(field)}, {self.get_field_meta(field)})"
1553
1554 def get_field_meta(self, field: Field) -> str:
1555 """Build FieldMeta expression for a field."""
1556 if field.tag_id is not None:
1557 meta = f"fory::F({field.tag_id})"
1558 else:
1559 meta = "fory::F()"
1560 is_any = (
1561 isinstance(field.field_type, PrimitiveType)
1562 and field.field_type.kind == PrimitiveKind.ANY
1563 )
1564 if field.optional or is_any:
1565 meta += ".nullable()"
1566 if field.ref:
1567 meta += ".ref()"
1568 spec = self.get_field_type_spec(field)
1569 if spec:
1570 if field.optional or field.ref:
1571 meta += f".inner({spec})"
1572 elif spec.startswith("fory::T::list("):
1573 meta += f".list({spec[len('fory::T::list(') : -1]})"
1574 elif spec.startswith("fory::T::array("):
1575 meta += f".array({spec[len('fory::T::array(') : -1]})"
1576 elif spec.startswith("fory::T::set("):
1577 meta += f".set({spec[len('fory::T::set(') : -1]})"
1578 elif spec.startswith("fory::T::map("):
1579 meta += f".map({spec[len('fory::T::map(') : -1]})"
1580 elif spec.endswith(".fixed()"):
1581 meta += ".fixed()"
1582 elif spec.endswith(".varint()"):
1583 meta += ".varint()"
1584 elif spec.endswith(".tagged()"):
1585 meta += ".tagged()"
1586 return meta
1587
1588 def get_union_field_meta(self, field: Field) -> str:
1589 """Build FieldMeta expression for a union case."""

Callers 1

get_field_macro_entryMethod · 0.95

Calls 1

get_field_type_specMethod · 0.95

Tested by

no test coverage detected