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

Function parse_struct_fields_raw

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

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

(inner: &[u8])

Source from the content-addressed store, hash-verified

1061}
1062
1063/// Port of `parseStructFieldsRaw` — structure only, classification TS-side.
1064pub fn parse_struct_fields_raw(inner: &[u8]) -> Vec<RawField> {
1065 let mut fields = Vec::new();
1066 let mut idx: u32 = 0;
1067 for (ds, de) in split_top_level(inner, b';') {
1068 let (ds, de) = jsws_trim(inner, ds, de);
1069 if ds >= de {
1070 continue;
1071 }
1072 let decl = &inner[ds..de];
1073 let parts = split_top_level(decl, b',');
1074 let ft = first_typed(&decl[parts[0].0..parts[0].1]);
1075 let shared_type: &[u8] = match &ft {
1076 Some(((ts, te), _)) => &decl[parts[0].0 + ts..parts[0].0 + te],
1077 None => b"",
1078 };
1079 for (pi, &(ps, pe)) in parts.iter().enumerate() {
1080 let (ps2, pe2) = jsws_trim(decl, ps, pe);
1081 let p = &decl[ps2..pe2];
1082 let mut name: &[u8] = b"";
1083 let mut ty: &[u8] = b"";
1084 let mut ptr = false;
1085 if let Some((ns, ne)) = fnptr_decl(p) {
1086 name = &p[ns..ne];
1087 ptr = true;
1088 } else if pi == 0 {
1089 if let Some((_, (ns, ne))) = &ft {
1090 name = &decl[parts[0].0 + ns..parts[0].0 + ne];
1091 ty = shared_type;
1092 }
1093 } else {
1094 // /^\**\s*(\w+)/
1095 let mut q = 0usize;
1096 while q < p.len() && p[q] == b'*' {
1097 q += 1;
1098 }
1099 let q = skip_jsws(p, q);
1100 if is_word_at(p, q) {
1101 name = &p[q..word_end(p, q)];
1102 ty = shared_type;
1103 }
1104 }
1105 fields.push(RawField {
1106 name: bytes_to_string(name),
1107 index: idx,
1108 ptr,
1109 ty: bytes_to_string(ty),
1110 });
1111 idx += 1;
1112 }
1113 }
1114 fields
1115}
1116
1117// ---------- 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