(s: &[u8])
| 430 | tags: Vec<String>, |
| 431 | } |
| 432 | |
| 433 | fn scan_inline_structs(s: &[u8]) -> InlineScan { |
| 434 | let mut out = InlineScan { ptr: false, types: Vec::new(), tags: Vec::new() }; |
| 435 | let mut last = 0; |
| 436 | loop { |
| 437 | let next_struct = find_word(s, b"struct", last); |
| 438 | let next_union = find_word(s, b"union", last); |
| 439 | let Some((t, keyword_len)) = (match (next_struct, next_union) { |
| 440 | (Some(st), Some(un)) if st < un => Some((st, 6)), |
| 441 | (Some(_), Some(un)) => Some((un, 5)), |
| 442 | (Some(st), None) => Some((st, 6)), |
| 443 | (None, Some(un)) => Some((un, 5)), |
| 444 | (None, None) => None, |
| 445 | }) else { |
| 446 | break; |
| 447 | }; |
| 448 | let after_kw = t + keyword_len; |
| 449 | let ws = skip_jsws(s, after_kw); |
| 450 | if ws == after_kw || !is_word_at(s, ws) { |
| 451 | last = t + 1; |
| 452 | continue; |
| 453 | } |
| 454 | let te = word_end(s, ws); |
| 455 | let open = skip_jsws(s, te); |
| 456 | if s.get(open) != Some(&b'{') { |
| 457 | last = t + 1; |
| 458 | continue; |
| 459 | } |
| 460 | last = open + 1; // lastIndex = end of match (after `{`) |
| 461 | let Some(close) = match_brace(s, open) else { continue }; |
| 462 | // vm: /^\s*(\w+)…/ on the text after `}` — only vm[1] matters here. |
| 463 | let v = skip_jsws(s, close + 1); |
| 464 | if !is_word_at(s, v) { |
| 465 | continue; |
| 466 | } |
| 467 | push_str(&mut out.tags, &s[ws..te]); |
| 468 | for f in parse_struct_fields_raw(&s[open + 1..close]) { |
| 469 | if f.name.is_empty() { |
| 470 | continue; |
| 471 | } |
| 472 | if f.ptr { |
| 473 | out.ptr = true; |
| 474 | } else if !f.ty.is_empty() { |
| 475 | out.types.push(f.ty); |
| 476 | } |
| 477 | } |
| 478 | } |
| 479 | out |
| 480 | } |
| 481 | |
| 482 | /// matchBrace: index of the `}` matching the `{` at `open`, or None. |
no test coverage detected