From e24c5a6cb9c3347477b83abe084a09ae8f9fde0a Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 7 Jan 2021 16:01:48 -0800 Subject: Fill in some missing bits of capability API (#1652) * Fill in some missing bits of capability API * Make invalid/unknown capability have a zero value (this aligns it better with the public API for `SlangProfileID`, so that the two can be merged down the line) * Actually provide an implementation of `spFindCapability()` public API * fixup: bug fixes for renumbering invalid capability atom --- source/slang/slang-capability.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'source/slang/slang-capability.cpp') diff --git a/source/slang/slang-capability.cpp b/source/slang/slang-capability.cpp index a75f6131c..5de05a5a4 100644 --- a/source/slang/slang-capability.cpp +++ b/source/slang/slang-capability.cpp @@ -97,11 +97,7 @@ struct CapabilityAtomInfo CapabilityAtom bases[kCapabilityAtom_MaxBases]; }; // -// The array is going to be sized to include an entry for `CapabilityAtom::Invalid` -// which as a value of -1, so we need to size the array one larger than the `Count` -// value. -// -static const CapabilityAtomInfo kCapabilityAtoms[Int(CapabilityAtom::Count) + 1] = +static const CapabilityAtomInfo kCapabilityAtoms[Int(CapabilityAtom::Count)] = { { "invalid", CapabilityAtomFlavor::Concrete, CapabilityAtomConflictMask::None, 0, { CapabilityAtom::Invalid, CapabilityAtom::Invalid, CapabilityAtom::Invalid, CapabilityAtom::Invalid } }, @@ -114,7 +110,7 @@ static const CapabilityAtomInfo kCapabilityAtoms[Int(CapabilityAtom::Count) + 1] static CapabilityAtomInfo const& _getInfo(CapabilityAtom atom) { SLANG_ASSERT(Int(atom) < Int(CapabilityAtom::Count)); - return kCapabilityAtoms[Int(atom) + 1]; + return kCapabilityAtoms[Int(atom)]; } CapabilityAtom findCapabilityAtom(UnownedStringSlice const& name) @@ -124,11 +120,6 @@ CapabilityAtom findCapabilityAtom(UnownedStringSlice const& name) // for( Index i = 0; i < Index(CapabilityAtom::Count); ++i ) { - // Note: using `_getInfo` here instead of accessing - // the `kCapabilityAtoms` array directly lets us - // avoid dealing with the offset-by-one indexing - // choice. - // auto& capInfo = _getInfo(CapabilityAtom(i)); if(name == UnownedTerminatedStringSlice(capInfo.name)) return CapabilityAtom(i); -- cgit v1.2.3