INNER CODE UNIT · Python

function_body

toyota-connected/ivi-homescreen · scripts/gen_config_reference.py:237

def function_body(text, name, path):
    # The body of a function: from its opening brace to the next brace at column
    # 0. Same refusal to yield nothing as the ParseOutputMatch scrape above -- a
    # definition that moved must fail loudly, or the table silently drops out of
    # the reference and out of the "every key needs META" check with it.
    #
    # The brace is found by scanning forward rather than required on the
    # signature line: these signatures wrap across several lines, and anchoring
    # on a same-line brace is what the ParseOutputMatch pattern gets away with
    # only because that one signature happens to fit. A declaration is skipped
    # by requiring the brace to arrive before any semicolon, so a forward
    # declaration cannot capture the following function's body.
    for m in re.finditer(rf"^\w[^\n]*\b{name}\s*\(", text, re.M):
        brace = text.find("{", m.end())
        semi = text.find(";", m.end())
        if brace < 0 or (semi >= 0 and semi < brace):
            continue  # a declaration, not the definition
        body = text[brace + 1:]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…