MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / GetExtensionFromString

Function GetExtensionFromString

source/table2.cpp:354–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352}
353
354bool GetExtensionFromString(const char* name, Extension* extension) {
355 // The comparison function knows to use 'name' string to compare against
356 // when the value is kSentinel.
357 const auto kSentinel = uint32_t(-1);
358 const NameValue needle{{}, kSentinel};
359 auto less = [&](const NameValue& lhs, const NameValue& rhs) {
360 const char* lhs_chars = lhs.value == kSentinel ? name : getChars(lhs.name);
361 const char* rhs_chars = rhs.value == kSentinel ? name : getChars(rhs.name);
362 return std::strcmp(lhs_chars, rhs_chars) < 0;
363 };
364
365 auto where = std::lower_bound(kExtensionNames.begin(), kExtensionNames.end(),
366 needle, less);
367 if (where != kExtensionNames.end() &&
368 std::strcmp(getChars(where->name), name) == 0) {
369 *extension = static_cast<Extension>(where->value);
370 return true;
371 }
372 return false;
373}
374
375// This is dirty copy of the spirv.hpp11 function
376// TODO - Use a generated version of this function

Callers 4

CheckIfKnownExtensionFunction · 0.85
RegisterExtensionFunction · 0.85
AddExtensionMethod · 0.85
TEST_PFunction · 0.85

Calls 3

getCharsFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by 1

TEST_PFunction · 0.68