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/preprocessor.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source/slang/preprocessor.cpp') diff --git a/source/slang/preprocessor.cpp b/source/slang/preprocessor.cpp index 103db7dcb..bf6f7b7ca 100644 --- a/source/slang/preprocessor.cpp +++ b/source/slang/preprocessor.cpp @@ -564,7 +564,7 @@ static void AddEndOfStreamToken( { Token token = PeekRawToken(preprocessor); token.type = TokenType::EndOfFile; - macro->tokens.mTokens.Add(token); + macro->tokens.mTokens.add(token); } static SimpleTokenInputStream* createSimpleInputStream( @@ -574,13 +574,13 @@ static SimpleTokenInputStream* createSimpleInputStream( SimpleTokenInputStream* inputStream = new SimpleTokenInputStream(); initializeInputStream(preprocessor, inputStream); - inputStream->lexedTokens.mTokens.Add(token); + inputStream->lexedTokens.mTokens.add(token); Token eofToken; eofToken.type = TokenType::EndOfFile; eofToken.loc = token.loc; eofToken.flags = TokenFlag::AfterWhitespace | TokenFlag::AtStartOfLine; - inputStream->lexedTokens.mTokens.Add(eofToken); + inputStream->lexedTokens.mTokens.add(eofToken); inputStream->tokenReader = TokenReader(inputStream->lexedTokens); @@ -659,7 +659,7 @@ static void MaybeBeginMacroExpansion( expansion->environment = &expansion->argumentEnvironment; // Try to read any arguments present. - UInt paramCount = macro->params.Count(); + UInt paramCount = macro->params.getCount(); UInt argIndex = 0; switch (PeekRawTokenType(preprocessor)) @@ -740,7 +740,7 @@ static void MaybeBeginMacroExpansion( } // Add the token and continue parsing. - arg->tokens.mTokens.Add(AdvanceRawToken(preprocessor)); + arg->tokens.mTokens.add(AdvanceRawToken(preprocessor)); } doneWithArgument: {} // We've parsed an argument and should move onto @@ -1586,7 +1586,7 @@ static SlangResult readFile( // auto linkage = context->preprocessor->linkage; auto fileSystemExt = linkage->getFileSystemExt(); - SLANG_RETURN_ON_FAIL(fileSystemExt->loadFile(path.Buffer(), outBlob)); + SLANG_RETURN_ON_FAIL(fileSystemExt->loadFile(path.getBuffer(), outBlob)); // If we are running the preprocessor as part of compiling a // specific module, then we must keep track of the file we've @@ -1732,7 +1732,7 @@ static void HandleDefineDirective(PreprocessorDirectiveContext* context) // are not allowed to be used as macros or parameters). // Add the parameter to the macro being deifned - macro->params.Add(paramToken); + macro->params.add(paramToken); // If we see `)` then we are done with arguments if (PeekRawTokenType(context) == TokenType::RParent) @@ -1755,12 +1755,12 @@ static void HandleDefineDirective(PreprocessorDirectiveContext* context) // Last token on line will be turned into a conceptual end-of-file // token for the sub-stream that the macro expands into. token.type = TokenType::EndOfFile; - macro->tokens.mTokens.Add(token); + macro->tokens.mTokens.add(token); break; } // In the ordinary case, we just add the token to the definition - macro->tokens.mTokens.Add(token); + macro->tokens.mTokens.add(token); } } @@ -1939,7 +1939,7 @@ static const PragmaDirective kUnknownPragmaDirective = { // Look up the `#pragma` directive with the given name. static PragmaDirective const* findPragmaDirective(String const& name) { - char const* nameStr = name.Buffer(); + char const* nameStr = name.getBuffer(); for (int ii = 0; kPragmaDirectives[ii].name; ++ii) { if (strcmp(kPragmaDirectives[ii].name, nameStr) != 0) @@ -2037,7 +2037,7 @@ static const PreprocessorDirective kInvalidDirective = { // Look up the directive with the given name. static PreprocessorDirective const* FindDirective(String const& name) { - char const* nameStr = name.Buffer(); + char const* nameStr = name.getBuffer(); for (int ii = 0; kDirectives[ii].name; ++ii) { if (strcmp(kDirectives[ii].name, nameStr) != 0) @@ -2236,7 +2236,7 @@ static TokenList ReadAllTokens( { Token token = ReadToken(preprocessor); - tokens.mTokens.Add(token); + tokens.mTokens.add(token); // Note: we include the EOF token in the list, // since that is expected by the `TokenList` type. -- cgit v1.2.3