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

Function liveMacro

src/extraction/languages/cpp-macro-methods.ts:362–367  ·  view source on GitHub ↗

* The macro of `name` in effect at `offset`: its last `#define` before it, * unless an `#undef` came between.

(macros: readonly CppMacro[], undefs: ReadonlyArray<{ name: string; at: number }>, name: string, offset: number)

Source from the content-addressed store, hash-verified

360 * unless an `#undef` came between.
361 */
362function liveMacro(macros: readonly CppMacro[], undefs: ReadonlyArray<{ name: string; at: number }>, name: string, offset: number): CppMacro | null {
363 let found: CppMacro | null = null;
364 for (const m of macros) if (m.name === name && m.at < offset && (!found || m.at > found.at)) found = m;
365 if (!found) return null;
366 return undefs.some((u) => u.name === name && u.at > found!.at && u.at < offset) ? null : found;
367}
368
369/** A macro's expansion for the arguments `args` (as written), or null when they don't fit its parameters. */
370function expandCppMacro(macro: CppMacro, args: string[]): string | null {

Callers 1

cppMacroMethodsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected