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

Function parse_struct_fields_raw

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

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

(inner: &[u8])

Source from the content-addressed store, hash-verified

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

Callers 2

scan_inline_structsFunction · 0.85
scan_fileFunction · 0.85

Calls 9

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
word_endFunction · 0.85
bytes_to_stringFunction · 0.85
lenMethod · 0.80

Tested by

no test coverage detected