From 4880789e3003441732cca4471091563f36531635 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 29 Apr 2019 17:03:46 -0400 Subject: String/List closer to conventions, and use Index type (#959) * List made members m_ Tweaked types to closer match conventions. * Use asserts for checking conditions on List. Other small improvements. * List.Count() -> getSize() * List Add -> add First -> getFirst Last -> getLast RemoveLast -> removeLast ReleaseBuffer -> detachBuffer GetArrayView -> getArrayView * List:: AddRange -> addRange Capacity -> getCapacity Insert -> insert InsertRange -> insertRange AddRange -> addRange RemoveRange -> removeRange RemoveAt -> removeAt Remove -> remove Reverse -> reverse FastRemove -> fastRemove FastRemoveAt -> fastRemoveAt Clear -> clear * List FreeBuffer -> _deallocateBuffer Free -> clearAndDeallocate SwapWith -> swapWith * List SetSize -> setSize Reserve -> reserve GrowToSize growToSize * UnsafeShrinkToSize -> unsafeShrinkToSize Compress -> compress FindLast -> findLastIndex FindLast -> findLastIndex Simplify Contains * List Removed m_allocator (wasn't used) Swap -> swapElements Sort -> sort Contains -> contains ForEach -> forEach QuickSort -> quickSort InsertionSort -> insertionSort BinarySearch -> binarySearch Max -> calcMax Min -> calcMin * Initializer::Initialize -> initialize List:: Allocate -> _allocate Init -> _init IndexOf -> indexOf * * Put #include in common.h, and remove unneeded inclusions * Small refactor of ArrayView - remove stride as not used * getSize -> getCount setSize -> setCount unsafeShrinkToSize->unsafeShrinkToCount growToSize -> growToCount m_size -> m_count * Some tidy up around Allocator. * Use Index type on List. * Refactor of IntSet. First tentative look at using Index. * Made Index an Int Did preliminary fixes. Made String use Index. * Partial refactor of String. * String::Buffer -> getBuffer ToWString -> toWString * Small improvements to String. String:: Buffer() -> getBuffer() Equals() -> equals * Try to use Index where appropriate. * Fix warnings on windows x86 builds. --- source/slang/parameter-binding.cpp | 58 +++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'source/slang/parameter-binding.cpp') diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp index 293a24338..bdb76a005 100644 --- a/source/slang/parameter-binding.cpp +++ b/source/slang/parameter-binding.cpp @@ -99,7 +99,7 @@ struct UsedRanges // using indices, because we may actually modify // the array as we go. // - Int rangeCount = ranges.Count(); + Int rangeCount = ranges.getCount(); for(Int rr = 0; rr < rangeCount; ++rr) { auto existingRange = ranges[rr]; @@ -161,7 +161,7 @@ struct UsedRanges prefix.begin = range.begin; prefix.end = existingRange.begin; prefix.parameter = range.parameter; - ranges.Add(prefix); + ranges.add(prefix); } // // Now we know that the interval `[range.begin, existingRange.begin)` @@ -195,14 +195,14 @@ struct UsedRanges // if(range.begin < range.end) { - ranges.Add(range); + ranges.add(range); } // Any ranges that got added along the way might not // be in the proper sorted order, so we'll need to // sort the array to restore our global invariant. // - ranges.Sort(); + ranges.sort(); // We end by returning an overlapping parameter that // we found along the way, if any. @@ -250,7 +250,7 @@ struct UsedRanges { UInt begin = 0; - UInt rangeCount = ranges.Count(); + UInt rangeCount = ranges.getCount(); for (UInt rr = 0; rr < rangeCount; ++rr) { // try to fit in before this range... @@ -584,7 +584,7 @@ static bool findLayoutArg( { if( modifier ) { - *outVal = (UInt) strtoull(String(modifier->valToken.Content).Buffer(), nullptr, 10); + *outVal = (UInt) strtoull(String(modifier->valToken.Content).getBuffer(), nullptr, 10); return true; } } @@ -671,8 +671,8 @@ static void collectGlobalGenericParameter( { RefPtr layout = new GenericParamLayout(); layout->decl = paramDecl; - layout->index = (int)context->shared->programLayout->globalGenericParams.Count(); - context->shared->programLayout->globalGenericParams.Add(layout); + layout->index = (int)context->shared->programLayout->globalGenericParams.getCount(); + context->shared->programLayout->globalGenericParams.add(layout); context->shared->programLayout->globalGenericParamsMap[layout->decl->getName()->text] = layout.Ptr(); } @@ -716,10 +716,10 @@ static void collectGlobalScopeParameter( // TODO: `ParameterInfo` should probably become `LayoutParamInfo`. // ParameterInfo* parameterInfo = new ParameterInfo(); - context->shared->parameters.Add(parameterInfo); + context->shared->parameters.add(parameterInfo); // Add the first variable declaration to the list of declarations for the parameter - parameterInfo->varLayouts.Add(varLayout); + parameterInfo->varLayouts.add(varLayout); // Add any additional variables to the list of declarations for( auto additionalVarDeclRef : shaderParamInfo.additionalParamDeclRefs ) @@ -739,7 +739,7 @@ static void collectGlobalScopeParameter( additionalVarLayout->typeLayout = typeLayout; additionalVarLayout->varDecl = additionalVarDeclRef; - parameterInfo->varLayouts.Add(additionalVarLayout); + parameterInfo->varLayouts.add(additionalVarLayout); } } @@ -1002,7 +1002,7 @@ void generateParameterBindings( RefPtr parameterInfo) { // There must be at least one declaration for the parameter. - SLANG_RELEASE_ASSERT(parameterInfo->varLayouts.Count() != 0); + SLANG_RELEASE_ASSERT(parameterInfo->varLayouts.getCount() != 0); // Iterate over all declarations looking for explicit binding information. for( auto& varLayout : parameterInfo->varLayouts ) @@ -1246,8 +1246,8 @@ static void completeBindingsForParameter( // that earlier code has validated that the declarations // "match". - SLANG_RELEASE_ASSERT(parameterInfo->varLayouts.Count() != 0); - auto firstVarLayout = parameterInfo->varLayouts.First(); + SLANG_RELEASE_ASSERT(parameterInfo->varLayouts.getCount() != 0); + auto firstVarLayout = parameterInfo->varLayouts.getFirst(); completeBindingsForParameterImpl( context, @@ -1342,7 +1342,7 @@ SimpleSemanticInfo decomposeSimpleSemantic( // The name is everything before the digits String stringComposedName(composedName); - info.name = stringComposedName.SubString(0, indexLoc); + info.name = stringComposedName.subString(0, indexLoc); info.index = strtol(stringComposedName.begin() + indexLoc, nullptr, 10); } return info; @@ -1362,11 +1362,11 @@ static RefPtr processSimpleEntryPointParameter( auto semanticIndex = *state.ioSemanticIndex; String semanticName = optSemanticName ? *optSemanticName : ""; - String sn = semanticName.ToLower(); + String sn = semanticName.toLower(); RefPtr typeLayout; - if (sn.StartsWith("sv_") - || sn.StartsWith("nv_")) + if (sn.startsWith("sv_") + || sn.startsWith("nv_")) { // System-value semantic. @@ -1626,7 +1626,7 @@ static RefPtr processEntryPointVaryingParameter( // supposed to be case-insensitive and // upper-case is the dominant convention. String semanticName = *optSemanticName; - String sn = semanticName.ToUpper(); + String sn = semanticName.toUpper(); auto semanticIndex = *state.ioSemanticIndex; @@ -1720,7 +1720,7 @@ static RefPtr processEntryPointVaryingParameter( } } - structLayout->fields.Add(fieldVarLayout); + structLayout->fields.add(fieldVarLayout); structLayout->mapVarToLayout.Add(field.getDecl(), fieldVarLayout); } @@ -1883,7 +1883,7 @@ struct ScopeLayoutBuilder } } - m_structLayout->fields.Add(firstVarLayout); + m_structLayout->fields.add(firstVarLayout); if( parameterInfo ) { @@ -1934,8 +1934,8 @@ struct ScopeLayoutBuilder void addParameter( ParameterInfo* parameterInfo) { - SLANG_RELEASE_ASSERT(parameterInfo->varLayouts.Count() != 0); - auto firstVarLayout = parameterInfo->varLayouts.First(); + SLANG_RELEASE_ASSERT(parameterInfo->varLayouts.getCount() != 0); + auto firstVarLayout = parameterInfo->varLayouts.getFirst(); _addParameter(firstVarLayout, parameterInfo); } @@ -2024,7 +2024,7 @@ static void collectEntryPointParameters( // The entry point layout must be added to the output // program layout so that it can be accessed by reflection. // - context->shared->programLayout->entryPoints.Add(entryPointLayout); + context->shared->programLayout->entryPoints.add(entryPointLayout); // For the duration of our parameter collection work we will // establish this entry point as the current one in the context. @@ -2041,7 +2041,7 @@ static void collectEntryPointParameters( SLANG_ASSERT(taggedUnionType); auto substType = taggedUnionType->Substitute(typeSubst).as(); auto typeLayout = createTypeLayout(context->layoutContext, substType); - entryPointLayout->taggedUnionTypeLayouts.Add(typeLayout); + entryPointLayout->taggedUnionTypeLayouts.add(typeLayout); } // We are going to iterate over the entry-point parameters, @@ -2337,8 +2337,8 @@ RefPtr generateParameterBindings( bool needDefaultConstantBuffer = false; for( auto& parameterInfo : sharedContext.parameters ) { - SLANG_RELEASE_ASSERT(parameterInfo->varLayouts.Count() != 0); - auto firstVarLayout = parameterInfo->varLayouts.First(); + SLANG_RELEASE_ASSERT(parameterInfo->varLayouts.getCount() != 0); + auto firstVarLayout = parameterInfo->varLayouts.getFirst(); // Does the field have any uniform data? if( firstVarLayout->typeLayout->FindResourceInfo(LayoutResourceKind::Uniform) ) @@ -2366,8 +2366,8 @@ RefPtr generateParameterBindings( // for (auto& parameterInfo : sharedContext.parameters) { - SLANG_RELEASE_ASSERT(parameterInfo->varLayouts.Count() != 0); - auto firstVarLayout = parameterInfo->varLayouts.First(); + SLANG_RELEASE_ASSERT(parameterInfo->varLayouts.getCount() != 0); + auto firstVarLayout = parameterInfo->varLayouts.getFirst(); // For each parameter, we will look at each resource it consumes. // -- cgit v1.2.3