MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / parse_struct_fields_raw

Function parse_struct_fields_raw

codegraph-kernel/src/cfnptr.rs:1091–1142  ·  view source on GitHub ↗

Port of `parseStructFieldsRaw` — structure only, classification TS-side.

(inner: &[u8])

Source from the content-addressed store, hash-verified

1089}
1090
1091/// Port of `parseStructFieldsRaw` — structure only, classification TS-side.
1092pub fn parse_struct_fields_raw(inner: &[u8]) -> Vec<RawField> {
1093 let mut fields = Vec::new();
1094 let mut idx: u32 = 0;
1095 for (ds, de) in split_top_level(inner, b';') {
1096 let (ds, de) = jsws_trim(inner, ds, de);
1097 if ds >= de {
1098 continue;
1099 }
1100 let decl = &inner[ds..de];
1101 let parts = split_top_level(decl, b',');
1102 let ft = first_typed(&decl[parts[0].0..parts[0].1]);
1103 let shared_type: &[u8] = match &ft {
1104 Some(((ts, te), _)) => &decl[parts[0].0 + ts..parts[0].0 + te],
1105 None => b"",
1106 };
1107 for (pi, &(ps, pe)) in parts.iter().enumerate() {
1108 let (ps2, pe2) = jsws_trim(decl, ps, pe);
1109 let p = &decl[ps2..pe2];
1110 let mut name: &[u8] = b"";
1111 let mut ty: &[u8] = b"";
1112 let mut ptr = false;
1113 if let Some((ns, ne)) = fnptr_decl(p) {
1114 name = &p[ns..ne];
1115 ptr = true;
1116 } else if pi == 0 {
1117 if let Some((_, (ns, ne))) = &ft {
1118 name = &decl[parts[0].0 + ns..parts[0].0 + ne];
1119 ty = shared_type;
1120 }
1121 } else {
1122 // /^\**\s*(\w+)/
1123 let mut q = 0usize;
1124 while q < p.len() && p[q] == b'*' {
1125 q += 1;
1126 }
1127 let q = skip_jsws(p, q);
1128 if is_word_at(p, q) {
1129 name = &p[q..word_end(p, q)];
1130 ty = shared_type;
1131 }
1132 }
1133 fields.push(RawField {
1134 name: bytes_to_string(name),
1135 index: idx,
1136 ptr,
1137 ty: bytes_to_string(ty),
1138 });
1139 idx += 1;
1140 }
1141 }
1142 fields
1143}
1144
1145// ---------- per-file entry ----------

Callers 2

scan_inline_structsFunction · 0.85
scan_fileFunction · 0.85

Calls 10

split_top_levelFunction · 0.85
jsws_trimFunction · 0.85
first_typedFunction · 0.85
fnptr_declFunction · 0.85
skip_jswsFunction · 0.85
is_word_atFunction · 0.85
bytes_to_stringFunction · 0.85
lenMethod · 0.80
pushMethod · 0.80
word_endFunction · 0.70

Tested by

no test coverage detected