MCPcopy Create free account
hub / github.com/crownengine/crown / parse_uniform_decl

Method parse_uniform_decl

src/resource/shader_resource.cpp:2434–2465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2432 }
2433
2434 s32 parse_uniform_decl(UniformMetadata &um, const char *decl, CompileOptions &opts)
2435 {
2436 const char *comment;
2437
2438 um.type = UniformType::COUNT;
2439
2440 if (str_has_prefix(decl, "uniform")) {
2441 const char *type = skip_spaces(decl + 7);
2442 const char *name = type;
2443
2444 while (!isspace(*name)) ++name;
2445 name = skip_spaces(name);
2446
2447 const char *semicol = strchr(name, ';');
2448 if (!semicol)
2449 RETURN_IF_FALSE(SHADER_RESOURCE, false, opts, "Malformed uniform declaration");
2450
2451 const char *name_end = name;
2452 while (name_end != semicol && !isspace(*name_end)) ++name_end;
2453 strncpy(um.name, name, name_end - name);
2454 um.name[name_end - name] = '\0';
2455 }
2456
2457 if ((comment = strstr(decl, "//")) != NULL) {
2458 s32 err = parse_decl_comment(um, comment, opts);
2459 ENSURE_OR_RETURN(SHADER_RESOURCE, err == 0, opts);
2460 } else {
2461 um.type = UniformType::COUNT; // Do not add to metadata.
2462 }
2463
2464 return 0;
2465 }
2466
2467 s32 parse_metadata(Vector<UniformMetadata> &meta, const Buffer &pp_code, CompileOptions &opts)
2468 {

Callers

nothing calls this directly

Calls 4

skip_spacesFunction · 0.85
strchrFunction · 0.85
strncpyFunction · 0.85
strstrFunction · 0.85

Tested by

no test coverage detected