|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Test-access surface for reflow_tokenize.c internal helpers. More...
#include <stddef.h>#include <stdint.h>#include "ra8_attributes.h"#include "ra8_err.h"#include "reflow.h"Go to the source code of this file.
Enumerations | |
| enum | priv_tok_consts_t : uint32_t { k_priv_max_depth = 64U , k_priv_tag_name_cap = 16U , k_priv_entity_window = 12U , k_priv_entity_min = 4U , k_priv_uc_2byte = 0x80U , k_priv_uc_3byte = 0x800U , k_priv_uc_4byte = 0x10000U , k_priv_uc_max = 0x10FFFFU , k_priv_utf8_lead2 = 0xC0U , k_priv_utf8_lead3 = 0xE0U , k_priv_utf8_lead4 = 0xF0U , k_priv_utf8_cont = 0x80U , k_priv_utf8_mask = 0x3FU , k_priv_utf8_sh6 = 6U , k_priv_utf8_sh12 = 12U , k_priv_utf8_sh18 = 18U , k_priv_base_dec = 10U , k_priv_base_hex = 16U , k_priv_hex_offset = 10U , k_priv_style_mask } |
| Tokenizer bounds and UTF-8 / numeric-entity encoding constants. More... | |
Functions | |
| bool | priv_reflow_tok_is_xml_whitespace (char c) |
| True for the ASCII characters XHTML treats as whitespace. | |
| reflow_html_tag_t | priv_reflow_tok_classify (const char *name, size_t len) |
| Map a (possibly namespace-prefixed) tag name to its enum. | |
| bool | priv_reflow_tok_decode_entity (const char *src, size_t avail, uint32_t *out_cp, size_t *out_used) |
| Decode one XML entity reference beginning at &. | |
| size_t | priv_reflow_tok_utf8_encode (uint32_t cp, uint8_t *dst) |
| UTF-8 encode a code point into dst (up to 4 bytes). | |
| bool | priv_reflow_tok_is_block (reflow_html_tag_t tag) |
| Test whether a tag is a block-flow container in the v1 subset. | |
| uint8_t | priv_reflow_tok_style_for (reflow_html_tag_t tag) |
| Return the style bit an inline tag contributes to its subtree. | |
| bool | priv_reflow_tok_emit (reflow_t *engine, reflow_token_kind_t kind, reflow_html_tag_t tag, uint8_t style, uint32_t off, uint32_t len) |
| Append one token to the engine's token pool. | |
| bool | priv_reflow_tok_feed (reflow_t *engine, char ch, bool *last_ws) |
| Write one byte through the whitespace-collapse state machine. | |
| bool | priv_reflow_tok_stash_run (reflow_t *engine, const uint8_t *buf, size_t start, size_t end, uint32_t *out_off, uint32_t *out_len) |
| Entity-decode and whitespace-collapse a text run into the pool. | |
| bool | priv_reflow_tok_starts_with (const uint8_t *buf, size_t i, size_t len, const char *lit) |
| Test whether buf at i begins with the literal lit. | |
| size_t | priv_reflow_tok_skip_past (const uint8_t *buf, size_t i, size_t len, const char *lit) |
| Return the index just past the first occurrence of lit. | |
| size_t | priv_reflow_tok_find_lit (const uint8_t *buf, size_t i, size_t len, const char *lit) |
| Return the index of the first occurrence of lit (its start), or len. | |
| bool | priv_reflow_tok_find_attr (const uint8_t *tag, size_t tag_len, const char *name, size_t name_len, size_t *out_voff, size_t *out_vlen) |
| Locate a named attribute's quoted value span within a tag (no copy). | |
| void | priv_reflow_tok_capture_attr (reflow_t *engine, const uint8_t *tag, size_t tag_len, const char *name, size_t name_len, uint32_t *out_off, uint32_t *out_len) |
| Copy a named attribute's quoted value from a tag span into the pool. | |
| ra8_css_element_t | priv_reflow_tok_css_element (reflow_html_tag_t kind, const uint8_t *tag, size_t span) |
| Build a CSS element identity from a just-opened tag's attributes. | |
| ra8_css_style_t | priv_reflow_tok_css_inline (const uint8_t *tag, size_t span) |
| Parse a just-opened tag's inline style="..." into a CSS declaration. | |
| uint8_t | priv_reflow_tok_intern_link (reflow_t *engine, uint32_t href_off, uint32_t href_len) |
| Intern an <a> href slice into the link-target table. | |
| bool | priv_reflow_tok_rel_is_stylesheet (const uint8_t *rel, size_t len) |
| True if a rel attribute value contains the stylesheet token. | |
| uint8_t | priv_reflow_tok_resolve_face_slot (const reflow_t *engine, const ra8_css_style_t *comp) |
| Map a cascaded run's (font-family + emphasis) to an embedded face slot. | |
| ra8_err_t | priv_reflow_xml_walk (reflow_t *engine, const uint8_t *xhtml_buf, size_t xhtml_len) |
| Tokenize the XHTML buffer and populate engine->tokens[]. | |
Test-access surface for reflow_tokenize.c internal helpers.
Exposes the small, individually-MC/DC-able helpers of the no-heap XHTML tokenizer so tests/src/test_reflow_tokenize.c can drive both arms of each decision directly (the tokenizer's main loop is otherwise reached only through priv_reflow_xml_walk). Not part of the public API.
[Ring 4 / Reflow] {World: NS}
Definition in file reflow_tokenize_internal.h.
| enum priv_tok_consts_t : uint32_t |
Tokenizer bounds and UTF-8 / numeric-entity encoding constants.
Shared across the tokenizer translation units (reflow_tokenize.c, reflow_tokenize_lex.c): the lexical primitives use the UTF-8 / numeric-entity / tag-name constants while the markup engine uses the nesting-depth bound and the run-style mask. Kept here so a single definition is visible to every TU.
Definition at line 42 of file reflow_tokenize_internal.h.
| void priv_reflow_tok_capture_attr | ( | reflow_t * | engine, |
| const uint8_t * | tag, | ||
| size_t | tag_len, | ||
| const char * | name, | ||
| size_t | name_len, | ||
| uint32_t * | out_off, | ||
| uint32_t * | out_len ) |
Copy a named attribute's quoted value from a tag span into the pool.
Scans the raw <...> span for attribute name and copies its quoted value verbatim into the engine text pool. On no match / malformed attribute / empty value / full pool the outputs are zeroed. Defined in reflow_tokenize_attr.c.
| [in,out] | engine | Engine whose text pool receives the value bytes. |
| [in] | tag | Raw tag span starting at '<'. |
| [in] | tag_len | Length of tag, bytes. |
| [in] | name | Lower-case attribute name to find. |
| [in] | name_len | Length of name, bytes. |
| [out] | out_off | Receives the text-pool offset of the value (0 if none). |
| [out] | out_len | Receives the value byte length (0 if none). |
name value was stored in the pool. Copy a named attribute's quoted value from a tag span into the pool.
Scans the raw <...> span for attribute name (case-insensitive, not preceded by another name character) and copies its quoted value verbatim into the engine text pool. Used for <img src> / <a href> / element id. On no match, a malformed attribute, an empty value, or a full pool the outputs are zeroed, which callers treat as "attribute absent".
| [in,out] | engine | Engine whose text pool receives the value bytes. |
| [in] | tag | Raw tag span starting at '<'. |
| [in] | tag_len | Length of tag, bytes. |
| [in] | name | Lower-case attribute name to find. |
| [in] | name_len | Length of name, bytes. |
| [out] | out_off | Receives the text-pool offset of the value (0 if none). |
| [out] | out_len | Receives the value byte length (0 if none). |
name value was stored in the pool. Definition at line 196 of file reflow_tokenize_attr.c.
References k_reflow_text_pool_bytes, memcpy(), priv_reflow_tok_find_attr(), reflow_t::text_pool, and reflow_t::text_pool_used.
Referenced by internal_handle_void(), and internal_open_attrs().
| reflow_html_tag_t priv_reflow_tok_classify | ( | const char * | name, |
| size_t | len ) |
Map a (possibly namespace-prefixed) tag name to its enum.
Strips any prefix: namespace, lower-cases the local name, and matches it against the v1 subset's tag table.
| [in] | name | NUL-terminated local-or-prefixed tag name. |
| [in] | len | Length of name in bytes (excluding any NUL). |
| k_reflow_tag_unknown | Name is null or unrecognised. |
< Word.
< Tag.
Definition at line 118 of file reflow_tokenize_lex.c.
References internal_local_lower(), k_priv_tag_name_cap, k_reflow_tag_a, k_reflow_tag_b, k_reflow_tag_blockquote, k_reflow_tag_br, k_reflow_tag_em, k_reflow_tag_h1, k_reflow_tag_h2, k_reflow_tag_h3, k_reflow_tag_h4, k_reflow_tag_h5, k_reflow_tag_h6, k_reflow_tag_hr, k_reflow_tag_i, k_reflow_tag_img, k_reflow_tag_li, k_reflow_tag_link, k_reflow_tag_ol, k_reflow_tag_p, k_reflow_tag_strong, k_reflow_tag_table, k_reflow_tag_td, k_reflow_tag_th, k_reflow_tag_tr, k_reflow_tag_ul, k_reflow_tag_unknown, and strcmp().
Referenced by internal_parse_sel_type(), and internal_parse_start().
| ra8_css_element_t priv_reflow_tok_css_element | ( | reflow_html_tag_t | kind, |
| const uint8_t * | tag, | ||
| size_t | span ) |
Build a CSS element identity from a just-opened tag's attributes.
Locates the id and class attribute value spans in place (no copy) so the cascade can match #id / .class selectors; the returned pointers alias tag. Defined in reflow_tokenize_attr.c.
| [in] | kind | Classified tag. |
| [in] | tag | Raw tag span starting at '<'. |
| [in] | span | Length of tag, bytes. |
| ra8_css_element_t | Populated struct; absent attributes have NULL pointer and zero length. |
span bytes. tag. tag. Locates the id and class attribute value spans in place (no copy) so the cascade can match #id / .class selectors; the returned pointers alias tag. A missing attribute leaves its pointer NULL and its length zero. The element's tag enum is stored so type selectors also work.
| [in] | kind | Classified tag. |
| [in] | tag | Raw tag span starting at '<'. |
| [in] | span | Length of tag, bytes. |
| ra8_css_element_t | Fully populated struct; absent attributes have NULL pointer and zero length. |
span bytes. tag. tag. Definition at line 243 of file reflow_tokenize_attr.c.
References ra8_css_element_t::class_len, ra8_css_element_t::class_str, ra8_css_element_t::id, ra8_css_element_t::id_len, priv_reflow_tok_find_attr(), and ra8_css_element_t::tag.
Referenced by internal_handle_start().
| ra8_css_style_t priv_reflow_tok_css_inline | ( | const uint8_t * | tag, |
| size_t | span ) |
Parse a just-opened tag's inline style="..." into a CSS declaration.
Locates the style attribute and delegates to ra8_css_parse_inline(). The returned struct has set == 0 when no inline declarations override the cascade. Defined in reflow_tokenize_attr.c.
| [in] | tag | Raw tag span starting at '<'. |
| [in] | span | Length of tag, bytes. |
| ra8_css_style_t | Struct with set == 0 if no style attribute is present. |
span bytes. tag. Locates the style attribute within the raw tag span and delegates to ra8_css_parse_inline() to parse its value into a declaration struct. When the attribute is absent or the parser fails the returned struct has set == 0, indicating no inline declarations override the cascade.
| [in] | tag | Raw tag span starting at '<'. |
| [in] | span | Length of tag, bytes. |
| ra8_css_style_t | Struct with set == 0 if no style attribute is present. |
span bytes. tag. Definition at line 279 of file reflow_tokenize_attr.c.
References priv_reflow_tok_find_attr(), and ra8_css_parse_inline().
Referenced by internal_open_styled().
| bool priv_reflow_tok_decode_entity | ( | const char * | src, |
| size_t | avail, | ||
| uint32_t * | out_cp, | ||
| size_t * | out_used ) |
Decode one XML entity reference beginning at &.
Recognises the named entities amp/lt/gt/quot/apos and numeric &#dec; / &#xhex; references. Unrecognised sequences are reported as "not an entity" so the caller emits the literal &.
| [in] | src | Buffer positioned so src[0] == '&'. |
| [in] | avail | Bytes available from src (>= 1). |
| [out] | out_cp | Decoded Unicode code point on success. |
| [out] | out_used | Bytes consumed from src on success. |
| false | Not a recognised/complete entity (caller emits '&'). |
< Word.
< Cp.
Definition at line 220 of file reflow_tokenize_lex.c.
References internal_decode_numeric(), k_priv_entity_min, k_priv_entity_window, strlen(), and strncmp().
Referenced by internal_stash_one().
| bool priv_reflow_tok_emit | ( | reflow_t * | engine, |
| reflow_token_kind_t | kind, | ||
| reflow_html_tag_t | tag, | ||
| uint8_t | style, | ||
| uint32_t | off, | ||
| uint32_t | len ) |
Append one token to the engine's token pool.
Fills the next reflow_token_t and advances token_count, or fails if the fixed pool is full. Defined in reflow_tokenize_lex.c.
| [in,out] | engine | Engine whose token pool is appended to. |
| [in] | kind | Token kind. |
| [in] | tag | Associated tag (or k_reflow_tag_unknown). |
| [in] | style | Inline-style bits for the token. |
| [in] | off | Text-pool offset (text tokens only). |
| [in] | len | Text-pool length (text tokens only). |
| false | The token pool is full. |
Fills the next reflow_token_t and advances token_count, or fails if the fixed pool is full.
| [in,out] | engine | Engine whose token pool is appended to. |
| [in] | kind | Token kind. |
| [in] | tag | Associated tag (or k_reflow_tag_unknown). |
| [in] | style | Inline-style bits for the token. |
| [in] | off | Text-pool offset (text tokens only). |
| [in] | len | Text-pool length (text tokens only). |
| false | The token pool is full. |
Definition at line 358 of file reflow_tokenize_lex.c.
References reflow_token_t::color, reflow_token_t::css_font_px, k_reflow_color_inherit, k_reflow_max_tokens, reflow_token_t::kind, reflow_token_t::reserved, reflow_token_t::reserved16, reflow_token_t::style, reflow_token_t::tag, reflow_token_t::text_len, reflow_token_t::text_off, reflow_t::token_count, and reflow_t::tokens.
Referenced by internal_emit_text_run(), internal_handle_cdata(), internal_handle_end(), internal_handle_start(), internal_handle_void(), and internal_open_attrs().
| bool priv_reflow_tok_feed | ( | reflow_t * | engine, |
| char | ch, | ||
| bool * | last_ws ) |
Write one byte through the whitespace-collapse state machine.
Runs of ASCII whitespace collapse to a single space; a run that begins with *last_ws true (start of node) drops its leading whitespace. Defined in reflow_tokenize_lex.c.
| [in,out] | engine | Engine whose text pool is appended to. |
| [in] | ch | Byte to write. |
| [in,out] | last_ws | Collapse state (true if the prior byte was space). |
| false | The text pool is full. |
Runs of ASCII whitespace collapse to a single space; a run that begins with *last_ws true (start of node) drops its leading whitespace.
| [in,out] | engine | Engine whose text pool is appended to. |
| [in] | ch | Byte to write. |
| [in,out] | last_ws | Collapse state (true if the prior byte was space). |
| false | The text pool is full. |
Definition at line 400 of file reflow_tokenize_lex.c.
References k_reflow_text_pool_bytes, priv_reflow_tok_is_xml_whitespace(), reflow_t::text_pool, and reflow_t::text_pool_used.
Referenced by internal_feed_utf8(), internal_handle_cdata(), and internal_stash_one().
| bool priv_reflow_tok_find_attr | ( | const uint8_t * | tag, |
| size_t | tag_len, | ||
| const char * | name, | ||
| size_t | name_len, | ||
| size_t * | out_voff, | ||
| size_t * | out_vlen ) |
Locate a named attribute's quoted value span within a tag (no copy).
Returns the value's offset + length within tag so callers can copy it to the pool or scan it in place. Defined in reflow_tokenize_attr.c.
| [in] | tag | Raw tag span starting at '<'. |
| [in] | tag_len | Length of tag, bytes. |
| [in] | name | Lower-case attribute name to find. |
| [in] | name_len | Length of name, bytes. |
| [out] | out_voff | Receives the value offset within tag. |
| [out] | out_vlen | Receives the value length, bytes. |
name value was found. | true | *out_voff / *out_vlen describe the value within tag. |
| false | Attribute absent or malformed. |
tag. The non-copying core of priv_reflow_tok_capture_attr(): returns the value's offset + length *within tag* so callers can either copy it to the pool or scan it in place (e.g. an inline style).
| [in] | tag | Raw tag span starting at '<'. |
| [in] | tag_len | Length of tag, bytes. |
| [in] | name | Lower-case attribute name to find. |
| [in] | name_len | Length of name, bytes. |
| [out] | out_voff | Receives the value offset within tag. |
| [out] | out_vlen | Receives the value length, bytes. |
name value was found. | true | *out_voff / *out_vlen describe the value within tag. |
| false | Attribute absent or malformed. |
tag. Definition at line 153 of file reflow_tokenize_attr.c.
References internal_attr_name_at(), and internal_attr_quoted_value().
Referenced by internal_handle_link(), priv_reflow_tok_capture_attr(), priv_reflow_tok_css_element(), and priv_reflow_tok_css_inline().
| size_t priv_reflow_tok_find_lit | ( | const uint8_t * | buf, |
| size_t | i, | ||
| size_t | len, | ||
| const char * | lit ) |
Return the index of the first occurrence of lit (its start), or len.
Like priv_reflow_tok_skip_past but returns the literal's START offset. Defined in reflow_tokenize_lex.c.
| [in] | buf | Source buffer. |
| [in] | i | Offset to search from. |
| [in] | len | Total buffer length. |
| [in] | lit | NUL-terminated literal to find. |
| len | The literal does not occur in [i, len). |
Like priv_reflow_tok_skip_past but returns the literal's START offset, so the caller can both bound the preceding content and resume past the literal.
| [in] | buf | Source buffer. |
| [in] | i | Offset to search from. |
| [in] | len | Total buffer length. |
| [in] | lit | NUL-terminated literal to find. |
| len | The literal does not occur in [i, len). |
Definition at line 623 of file reflow_tokenize_lex.c.
References internal_bytes_equal(), and strlen().
Referenced by internal_handle_raw_text().
| uint8_t priv_reflow_tok_intern_link | ( | reflow_t * | engine, |
| uint32_t | href_off, | ||
| uint32_t | href_len ) |
Intern an <a> href slice into the link-target table.
Appends a {href_off, href_len} entry and returns its 1-based id. An empty href or a full table returns 0. Defined in reflow_tokenize_attr.c.
| [in,out] | engine | Engine whose link-target table grows. |
| [in] | href_off | Href text-pool offset. |
| [in] | href_len | Href byte length. |
| 0 | Empty href or the table is full. |
| 1..k_reflow_max_links | The newly assigned 1-based link id. |
Appends a {href_off, href_len} entry and returns its 1-based id (stored in subsequent text tokens' reserved byte). An empty href or a full table returns 0 (the run renders as plain underlined text – not tappable).
| [in,out] | engine | Engine whose link-target table grows. |
| [in] | href_off | Href text-pool offset. |
| [in] | href_len | Href byte length. |
| 0 | Empty href or the table is full. |
| 1..k_reflow_max_links | The newly assigned 1-based link id. |
Definition at line 315 of file reflow_tokenize_attr.c.
References reflow_link_target_t::href_len, reflow_link_target_t::href_off, k_reflow_max_links, reflow_t::link_target_count, and reflow_t::link_targets.
Referenced by internal_open_attrs().
| bool priv_reflow_tok_is_block | ( | reflow_html_tag_t | tag | ) |
Test whether a tag is a block-flow container in the v1 subset.
Block tags emit block-start / block-end tokens; all others do not introduce a block box. Defined in reflow_tokenize_lex.c.
| [in] | tag | Classified tag. |
| false | Any inline, void, or unknown tag. |
Block tags emit block-start / block-end tokens; all others do not introduce a block box.
| [in] | tag | Classified tag. |
| false | Any inline, void, or unknown tag. |
Definition at line 276 of file reflow_tokenize_lex.c.
References k_reflow_tag_blockquote, k_reflow_tag_h1, k_reflow_tag_h2, k_reflow_tag_h3, k_reflow_tag_h4, k_reflow_tag_h5, k_reflow_tag_h6, k_reflow_tag_li, k_reflow_tag_ol, k_reflow_tag_p, k_reflow_tag_table, k_reflow_tag_td, k_reflow_tag_th, k_reflow_tag_tr, and k_reflow_tag_ul.
Referenced by internal_handle_end(), and internal_handle_start().
| bool priv_reflow_tok_is_xml_whitespace | ( | char | c | ) |
True for the ASCII characters XHTML treats as whitespace.
Matches space, tab, newline, carriage-return, form-feed and vertical-tab – the set collapsed by the tokenizer's text handling.
| [in] | c | Byte to classify. |
| false | c is any non-whitespace byte. |
Definition at line 41 of file reflow_tokenize_lex.c.
Referenced by internal_attr_quoted_value(), internal_parse_start(), internal_tag_is(), and priv_reflow_tok_feed().
| bool priv_reflow_tok_rel_is_stylesheet | ( | const uint8_t * | rel, |
| size_t | len ) |
True if a rel attribute value contains the stylesheet token.
Case-sensitive substring scan, bounded by len. Defined in reflow_tokenize_attr.c.
| [in] | rel | Attribute-value bytes (not NUL-terminated). |
| [in] | len | Length of rel, bytes. |
rel. | true | The substring "stylesheet" was found in rel. |
| false | The substring is absent or len is too short. |
rel addresses len readable bytes. rel is non-null. Case-sensitive substring scan (EPUB <link> rels are authored lowercase; this also accepts the alternate stylesheet form). Bounded by the value length. The inner loop iterates at most len times so the scan is O(len) with no dynamic allocation.
| [in] | rel | Attribute-value bytes (not NUL-terminated). |
| [in] | len | Length of rel, bytes. |
rel. | true | The substring "stylesheet" was found in rel. |
| false | The substring is absent or len is too short to contain it. |
rel addresses len readable bytes. rel is non-null (a zero len is a valid empty-value case). Definition at line 347 of file reflow_tokenize_attr.c.
Referenced by internal_handle_link().
| uint8_t priv_reflow_tok_resolve_face_slot | ( | const reflow_t * | engine, |
| const ra8_css_style_t * | comp ) |
Map a cascaded run's (font-family + emphasis) to an embedded face slot.
Returns 0 (the engine's default bound face) when no embedded face matches, else 1 + the registry index. Defined in reflow_tokenize_attr.c.
| [in] | engine | Engine whose face registry + parsed sheet are consulted. |
| [in] | comp | The element's cascaded style (family + emphasis bits). |
| 0 | No registered face matches the cascaded family + emphasis combination. |
engine and comp are non-null. Returns 0 (the engine's default bound face) when no embedded face is registered, the run has no resolved font-family, no @font-face matches, or the matched @font-face was never registered (its src had no manifest font). Otherwise returns 1 + the registry index, which the render pass uses to pick the matching stbtt_fontinfo.
| [in] | engine | Engine whose face registry + parsed sheet are consulted. |
| [in] | comp | The element's cascaded style (family + emphasis bits). |
| 0 | No registered face matches the cascaded family + emphasis combination. |
engine and comp are non-null. Definition at line 382 of file reflow_tokenize_attr.c.
References reflow_t::css, reflow_face_t::css_face_idx, reflow_t::face_count, reflow_t::faces, ra8_css_style_t::family_len, ra8_css_style_t::family_off, k_ra8_css_set_family, k_reflow_style_bold, k_reflow_style_italic, ra8_css_sheet_t::names, ra8_css_match_face(), ra8_css_style_t::set, and ra8_css_style_t::style.
Referenced by internal_open_styled().
| size_t priv_reflow_tok_skip_past | ( | const uint8_t * | buf, |
| size_t | i, | ||
| size_t | len, | ||
| const char * | lit ) |
Return the index just past the first occurrence of lit.
Linear bounded scan; used to skip comments / PIs / declarations. Defined in reflow_tokenize_lex.c.
| [in] | buf | Source buffer. |
| [in] | i | Offset to search from. |
| [in] | len | Total buffer length. |
| [in] | lit | NUL-terminated literal to find. |
| len | The literal does not occur in [i, len). |
Linear bounded scan; used to skip comments / PIs / declarations.
| [in] | buf | Source buffer. |
| [in] | i | Offset to search from. |
| [in] | len | Total buffer length. |
| [in] | lit | NUL-terminated literal to find. |
| len | The literal does not occur in [i, len). |
Definition at line 591 of file reflow_tokenize_lex.c.
References internal_bytes_equal(), and strlen().
Referenced by internal_handle_lt(), and internal_handle_raw_text().
| bool priv_reflow_tok_starts_with | ( | const uint8_t * | buf, |
| size_t | i, | ||
| size_t | len, | ||
| const char * | lit ) |
Test whether buf at i begins with the literal lit.
Bounds-checks that lit fits within [i, len) before comparing. Defined in reflow_tokenize_lex.c.
| [in] | buf | Source buffer. |
| [in] | i | Offset to test from. |
| [in] | len | Total buffer length. |
| [in] | lit | NUL-terminated literal to match. |
| false | Out of range or mismatch. |
Definition at line 564 of file reflow_tokenize_lex.c.
References internal_bytes_equal(), and strlen().
Referenced by internal_handle_lt(), and internal_tag_is().
| bool priv_reflow_tok_stash_run | ( | reflow_t * | engine, |
| const uint8_t * | buf, | ||
| size_t | start, | ||
| size_t | end, | ||
| uint32_t * | out_off, | ||
| uint32_t * | out_len ) |
Entity-decode and whitespace-collapse a text run into the pool.
Walks the run one source position at a time, decoding a recognised entity to UTF-8 (else passing '&' through) and collapsing whitespace. Defined in reflow_tokenize_lex.c.
| [in,out] | engine | Engine whose text pool is appended to. |
| [in] | buf | Source buffer. |
| [in] | start | Start offset of the run (inclusive). |
| [in] | end | End offset of the run (exclusive). |
| [out] | out_off | Text-pool offset of the stored run. |
| [out] | out_len | Number of bytes stored. |
| false | The text pool is full. |
Walks the run one source position at a time via internal_stash_one(), which decodes a recognised entity to UTF-8 (else passes '&' through) and collapses whitespace.
| [in,out] | engine | Engine whose text pool is appended to. |
| [in] | buf | Source buffer. |
| [in] | start | Start offset of the run (inclusive). |
| [in] | end | End offset of the run (exclusive). |
| [out] | out_off | Text-pool offset of the stored run. |
| [out] | out_len | Number of bytes stored. |
| false | The text pool is full. |
Definition at line 514 of file reflow_tokenize_lex.c.
References internal_stash_one(), and reflow_t::text_pool_used.
Referenced by internal_emit_text_run().
| uint8_t priv_reflow_tok_style_for | ( | reflow_html_tag_t | tag | ) |
Return the style bit an inline tag contributes to its subtree.
b/strong add bold, i/em add italic, a adds underline; every other tag contributes nothing. Defined in reflow_tokenize_lex.c.
| [in] | tag | Classified tag. |
| 0 | The tag carries no inline style. |
b/strong add bold, i/em add italic, a adds underline; every other tag contributes nothing.
| [in] | tag | Classified tag. |
| 0 | The tag carries no inline style. |
Definition at line 316 of file reflow_tokenize_lex.c.
References k_reflow_style_bold, k_reflow_style_italic, k_reflow_style_underline, k_reflow_tag_a, k_reflow_tag_b, k_reflow_tag_em, k_reflow_tag_i, and k_reflow_tag_strong.
Referenced by internal_open_styled().
| size_t priv_reflow_tok_utf8_encode | ( | uint32_t | cp, |
| uint8_t * | dst ) |
UTF-8 encode a code point into dst (up to 4 bytes).
Selects the 1/2/3/4-byte form by code-point range; values above U+10FFFF are clamped to the maximum valid code point.
| [in] | cp | Unicode code point (clamped to the valid range). |
| [out] | dst | Destination of at least 4 bytes. |
| 1 | ASCII code point. |
Definition at line 46 of file reflow_tokenize_lex.c.
References k_priv_uc_2byte, k_priv_uc_3byte, k_priv_uc_4byte, k_priv_uc_max, k_priv_utf8_cont, k_priv_utf8_lead2, k_priv_utf8_lead3, k_priv_utf8_lead4, k_priv_utf8_mask, k_priv_utf8_sh12, k_priv_utf8_sh18, and k_priv_utf8_sh6.
Referenced by internal_feed_utf8().
Tokenize the XHTML buffer and populate engine->tokens[].
The tokenizer entry point. A single forward pass over the XHTML source with no heap and no DOM. Defined in reflow_tokenize.c and consumed by the layout driver in reflow_parse.c; the per-decision helpers above are the individually-MC/DC-able primitives it drives.
| [in,out] | engine | Engine whose token / text pools are populated. |
| [in] | xhtml_buf | XHTML source bytes. |
| [in] | xhtml_len | Length of xhtml_buf, in bytes. |
| k_ra8_ok | Tokenization succeeded. |
| k_ra8_err_null_ptr | engine or xhtml_buf is null. |
| k_ra8_err_invalid_size | xhtml_len is zero. |
engine and xhtml_buf are non-null. xhtml_len is non-zero. Definition at line 827 of file reflow_tokenize.c.
References tok_ctx_t::color, reflow_t::css, tok_ctx_t::engine, internal_emit_text_run(), internal_handle_lt(), k_ra8_err_invalid_size, k_ra8_err_no_mem, k_ra8_err_null_ptr, k_ra8_err_validation_failed, k_ra8_ok, k_reflow_color_inherit, k_reflow_style_normal, ra8_css_sheet_reset(), tok_ctx_t::saw_element, tok_ctx_t::sp, and tok_ctx_t::style.
Referenced by reflow_parse_xhtml().