MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / c1_enumerator_at

Function c1_enumerator_at

tests/test_extraction.c:8395–8413  ·  view source on GitHub ↗

Is ` [. ]. ` the ONE Variable def of that name, with parent_class * ` . ` (NULL: no parent_class)? */

Source from the content-addressed store, hash-verified

8393/* Is `<module>[.<scope>].<name>` the ONE Variable def of that name, with parent_class
8394 * `<module>.<parent_tail>` (NULL: no parent_class)? */
8395static bool c1_enumerator_at(CBMFileResult *r, const char *scope, const char *name,
8396 const char *parent_tail) {
8397 char qn[256];
8398 snprintf(qn, sizeof(qn), "%s%s%s.%s", r->module_qn, scope[0] ? "." : "", scope, name);
8399 const CBMDefinition *d = c1_def_qn(r, qn);
8400 if (!d || !d->label || strcmp(d->label, "Variable") != 0 ||
8401 count_defs_named(r, "Variable", name) != 1) {
8402 const CBMDefinition *other = c1_def(r, "Variable", name);
8403 fprintf(stderr, " [c1] want the one Variable %s, the Variable of that name is %s\n", qn,
8404 other ? other->qualified_name : "(none)");
8405 return false;
8406 }
8407 if (!parent_tail) {
8408 return d->parent_class == NULL;
8409 }
8410 char parent[256];
8411 snprintf(parent, sizeof(parent), "%s.%s", r->module_qn, parent_tail);
8412 return d->parent_class && strcmp(d->parent_class, parent) == 0;
8413}
8414
8415/* C has no struct scope for ordinary identifiers: an enum declared inside a struct or
8416 * union puts its enumerators in the scope around it, and the code names them

Callers 1

test_extraction.cFile · 0.85

Calls 3

c1_def_qnFunction · 0.85
c1_defFunction · 0.85
count_defs_namedFunction · 0.70

Tested by

no test coverage detected