Author Topic: VC STL fix patch, Only three changes after a long period test  (Read 8601 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
This patch comes from ollydbg, I've only done testing, and ultimately the creation of patches.
Very much hope that this patch can be applied before the 10.4 version, so that will benefit the majority of CB + VC users.
When the application of this patch, VC STL code completion will become perfect!

Before applying patches, this code is no code completion tips.
Code
#include <iostream>
#include <string>

using namespace std;

int main()
{
    std::string s;
    s.   
    return 0;
}

However, after applying this patch, VC STL code completion tips and the GCC as perfect!
Thanks!

Code
Index: src/plugins/codecompletion/codecompletion.cpp

===================================================================

--- src/plugins/codecompletion/codecompletion.cpp (revision 6193)

+++ src/plugins/codecompletion/codecompletion.cpp (working copy)

@@ -205,6 +205,10 @@

 
         Tokenizer::SetReplacementString(_T("_GLIBCXX_END_NAMESPACE_TR1"),      _T("}"));
         Tokenizer::SetReplacementString(_T("_GLIBCXX_BEGIN_NAMESPACE_TR1"),    _T("-namespace tr1 {"));
+       
+        // for VC
+        Tokenizer::SetReplacementString(_T("_STD_BEGIN"),                       _T("-namespace std {"));
+        Tokenizer::SetReplacementString(_T("_STD_END"),                         _T("}"));
     }
     else
         cfg->Read(_T("token_replacements"), &repl);
Index: src/plugins/codecompletion/parser/tokenizer.cpp

===================================================================

--- src/plugins/codecompletion/parser/tokenizer.cpp (revision 6193)

+++ src/plugins/codecompletion/parser/tokenizer.cpp (working copy)

@@ -292,7 +292,7 @@

 }
 
 // expect we are not in a C-string.
-bool Tokenizer::SkipToOneOfChars(const wxChar* chars, bool supportNesting, bool skipPreprocessor)
+bool Tokenizer::SkipToOneOfChars(const wxChar* chars, bool supportNesting, bool skipPreprocessor, bool skipAnglebrace)
 {
     while (NotEOF() && !CharInString(CurrentChar(), chars))
     {
@@ -320,11 +320,15 @@

                 case '(': SkipBlock('('); break;
                 case '[': SkipBlock('['); break;
                 case '<': // don't skip if << operator
-                    if (NextChar() == '<')
-                        MoveToNextChar(2); // skip it and also the next '<' or the next '<' leads to a SkipBlock('<');
-                    else
-                        SkipBlock('<');
-                    break;
+                    if (skipAnglebrace)
+                    {
+                        if (NextChar() == '<')
+                            MoveToNextChar(2); // skip it and also the next '<' or the next '<' leads to a SkipBlock('<');
+                        else
+                            SkipBlock('<');
+                        break;
+                    }
+
                 default: done = true; break;
             }
         }
@@ -503,7 +507,7 @@

     {
         if (c == _T('='))
         {
-            if (!SkipToOneOfChars(_T(",;}"), true, true))
+            if (!SkipToOneOfChars(_T(",;}"), true, true, false))
                 return false;
         }
     }
Index: src/plugins/codecompletion/parser/tokenizer.h

===================================================================

--- src/plugins/codecompletion/parser/tokenizer.h (revision 6193)

+++ src/plugins/codecompletion/parser/tokenizer.h (working copy)

@@ -134,7 +134,7 @@

     bool SkipWhiteSpace();
     bool IsEscapedChar();
     bool SkipToChar(const wxChar& ch);
-    bool SkipToOneOfChars(const wxChar* chars, bool supportNesting = false, bool skipPreprocessor = false);
+    bool SkipToOneOfChars(const wxChar* chars, bool supportNesting = false, bool skipPreprocessor = false, bool skipAnglebrace = true);
     bool SkipBlock(const wxChar& ch);
     bool SkipUnwanted(); // skips comments, assignments, preprocessor etc.
     bool SkipComment(bool skipWhiteAtEnd = true);

[attachment deleted by admin]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: VC STL fix patch, Only three changes after a long period test
« Reply #1 on: March 21, 2010, 08:42:00 pm »
Very much hope that this patch can be applied before the 10.4 version, so that will benefit the majority of CB + VC users.
I'll give it a try... (and apply it if it's OK).

Please keep in mind that I very well followed the recent CC suggestions, but I don't want to touch this component before the release. This here might be the only exception.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ