Author Topic: better handle for pointer  (Read 7122 times)

Offline blueshake

  • Regular
  • ***
  • Posts: 459
better handle for pointer
« on: February 18, 2010, 03:09:46 am »
In current cc,it use a bool variable m_IsPoint to identify pointer.But I don't think it is enough because it can not handle codes below well.
Code
int a = 3;
int* aa = &a;
int** aaa = &aa;-----------not work well for the calltip.
int main()
{
    cout << "Hello world!" << endl;
    return 0;
}

see the screen shot.

patch for it:
Code
Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 6169)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -120,7 +120,7 @@
     m_PreprocessorIfCount(0),
     m_IsBuffer(parserThreadOptions.useBuffer),
     m_Buffer(bufferOrFilename),
-    m_IsPointer(false),
+    m_PointOrRef(wxEmptyString),
     m_TemplateArgument(wxEmptyString)
 {
     m_Tokenizer.SetTokenizerOption(parserThreadOptions.wantPreprocessor);
@@ -454,7 +454,7 @@
         else if (token==ParserConsts::semicolon)
         {
             m_Str.Clear();
-            m_IsPointer = false;
+            m_PointOrRef = wxEmptyString;
             // Notice: clears the queue "m_EncounteredTypeNamespaces"
             while (!m_EncounteredTypeNamespaces.empty())
                 m_EncounteredTypeNamespaces.pop();
@@ -762,7 +762,7 @@
                 }
                 else if (token == _T("*"))
                 {
-                    m_IsPointer = true;
+                    m_PointOrRef << token;
                 }
                 else
                 {
@@ -985,10 +985,10 @@
     if (!(kind & (tkConstructor | tkDestructor)))
     {
         wxString tokenType       = m_Str;
-        if (m_IsPointer)
+        if (!m_PointOrRef.IsEmpty())
         {
-            m_IsPointer = false;
-            tokenType << _T("*");
+            tokenType << m_PointOrRef;
+            m_PointOrRef = wxEmptyString;
         }
         wxString actualTokenType = GetActualTokenType();
         if (actualTokenType.Find(_T(' ')) == wxNOT_FOUND)
@@ -1804,7 +1804,7 @@
         }
         else if (token == _T("*"))
         {
-            m_IsPointer = false;
+            m_PointOrRef << token;
             continue;
         }
         else if (peek == ParserConsts::comma)
@@ -1956,12 +1956,12 @@
             continue;
         else if (token==ParserConsts::semicolon) // end of variable name(s)
         {
-            m_IsPointer = false;
+            m_PointOrRef = wxEmptyString;
             break;
         }
         else if (token == _T("*"))               // variable is a pointer
         {
-            m_IsPointer = true;
+            m_PointOrRef << token;
         }
         else if (   wxIsalpha(token.GetChar(0))
                  || (token.GetChar(0) == '_') )
@@ -1997,12 +1997,12 @@
         else if (token==ParserConsts::semicolon) // end of class name(s)
         {
             m_Tokenizer.UngetToken();
-            m_IsPointer = false;
+            m_PointOrRef = wxEmptyString;
             break;
         }
         else if (token == _T("*"))               // variable is a pointer
         {
-            m_IsPointer = true;
+            m_PointOrRef << token;
         }
         else if (   wxIsalpha(token.GetChar(0))
                  || (token.GetChar(0) == '_') )
Index: src/plugins/codecompletion/parser/parserthread.h
===================================================================
--- src/plugins/codecompletion/parser/parserthread.h (revision 6169)
+++ src/plugins/codecompletion/parser/parserthread.h (working copy)
@@ -315,7 +315,8 @@
         wxString             m_Buffer;
 
         /** a pointer indicator*/
-        bool m_IsPointer;
+        //bool m_IsPointer;
+        wxString m_PointOrRef;
 
         /** holds current template agrument(s) when a template occurs */
         wxString m_TemplateArgument;



[attachment deleted by admin]
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: better handle for pointer
« Reply #1 on: February 18, 2010, 07:56:19 am »
@morten

After a second thought,is it better to replace
Code
m_PointOrRef = wxEmptyString;


with

Code
m_PointOrRef.Clear();


Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?