loci: rewrite class_is_u16_len
Now inspects memebrs instead of hardcoding class names.
diff --git a/c_gen/loxi_utils_legacy.py b/c_gen/loxi_utils_legacy.py
index 5f3214a..0399638 100644
--- a/c_gen/loxi_utils_legacy.py
+++ b/c_gen/loxi_utils_legacy.py
@@ -127,11 +127,23 @@
"""
Return True if cls_name is an object which uses initial uint16 length
"""
- return cls in ["of_group_desc_stats_entry", "of_group_stats_entry",
- "of_flow_stats_entry", "of_bucket", "of_table_features",
- "of_bsn_port_counter_stats_entry", "of_bsn_vlan_counter_stats_entry",
- "of_bsn_gentable_entry_desc_stats_entry", "of_bsn_gentable_entry_stats_entry",
- "of_bsn_gentable_desc_stats_entry", "of_bsn_vrf_counter_stats_entry"]
+
+ ofclass = loxi_globals.unified.class_by_name(cls)
+ if not ofclass:
+ return False
+
+ if len(ofclass.members) < 1:
+ return False
+
+ m = ofclass.members[0]
+
+ if not isinstance(m, ir.OFLengthMember):
+ return False
+
+ if m.oftype != "uint16_t":
+ return False
+
+ return True
def class_is_list(cls):
"""