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

Function liveMacro

src/extraction/languages/cpp-macro-methods.ts:361–366  ·  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

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

Callers 1

cppMacroMethodsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected