Author Topic: New code completion remarks/issues  (Read 142169 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5230
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New code completion remarks/issues
« Reply #165 on: October 09, 2009, 08:02:02 am »
I'm sorry, I find the bug, it's here

line 766-787 of nativeparser.cpp.

Code: [Select]
            if (!token->m_Args.IsEmpty() && !token->m_Args.Matches(_T("()")))
            {
                wxString buffer = token->m_Args;
                buffer.Remove(0, 1); // remove (
                buffer.RemoveLast(); // remove )
                buffer.Replace(_T(","), _T(";")); // replace commas with semi-colons
                buffer << _T(';'); // aid parser ;)
                buffer.Trim();

                if (s_DebugSmartSense)
                {
                #if wxCHECK_VERSION(2, 9, 0)
                    Manager::Get()->GetLogManager()->DebugLog(F(_T("Parsing arguments: \"%s\""), buffer.wx_str()));
                #else
                    Manager::Get()->GetLogManager()->DebugLog(F(_T("Parsing arguments: \"%s\""), buffer.c_str()));
                #endif
                    if (!buffer.IsEmpty() && !parser->ParseBuffer(buffer, false, false, true))
                    {
                        Manager::Get()->GetLogManager()->DebugLog(_T("ERROR parsing arguments"));
                    }
                }
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: New code completion remarks/issues
« Reply #166 on: October 09, 2009, 08:05:53 am »
I'm sorry, I find the bug, it's here
line 766-787 of nativeparser.cpp.
...so?! What exactly is wrong with that portion?
...besides: it works fine here (trunk)...?!
« Last Edit: October 09, 2009, 08:09:09 am by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5230
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New code completion remarks/issues
« Reply #167 on: October 09, 2009, 08:09:33 am »
I'm sorry, I find the bug, it's here
line 766-787 of nativeparser.cpp.
...so?! What exactly is wrong with that portion?

The code is wrapped in the if (s_DebugSmartSense )from rev 5840 to 5845 of the nativeparser.cpp.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: New code completion remarks/issues
« Reply #168 on: October 09, 2009, 08:14:11 am »
The code is wrapped in the if (s_DebugSmartSense )from rev 5840 to 5845 of the nativeparser.cpp.
Argh! Good one. Nevermind... my mistake. :oops: I was always using it *with* DebugSmartSense enabled, so that's why it worked here... Will commit the fix soon...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5230
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New code completion remarks/issues
« Reply #169 on: October 09, 2009, 08:19:09 am »
The code is wrapped in the if (s_DebugSmartSense )from rev 5840 to 5845 of the nativeparser.cpp.
Argh! Good one. Nevermind... my mistake. :oops: I was always using it *with* DebugSmartSense enabled, so that's why it worked here... Will commit the fix soon...

haha, I think one reason of the mistake:  #if wxCHECK_VERSION(2, 9, 0)  preprocessor guard is a little annoying. :D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: New code completion remarks/issues
« Reply #170 on: October 09, 2009, 08:19:36 am »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline mmkider

  • Almost regular
  • **
  • Posts: 150
Re: New code completion remarks/issues
« Reply #171 on: October 09, 2009, 08:36:18 am »
« Last Edit: October 09, 2009, 08:37:55 am by mmkider »

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: New code completion remarks/issues
« Reply #172 on: October 09, 2009, 08:36:55 am »
Will commit the fix soon...
...done.
:lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol:
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: New code completion remarks/issues
« Reply #173 on: October 09, 2009, 08:38:48 am »
Dear ollydbg:
had you tried on reply #155?
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 daniloz

  • Regular
  • ***
  • Posts: 268
Re: New code completion remarks/issues
« Reply #174 on: October 09, 2009, 08:49:56 am »
Quick question... in the structs_typedefs.cpp (from the tests - thx Morten):
Code: [Select]
struct _s
{
  int   x;
  float y;
};
typedef struct _s t_s;

typedef struct _s_inner
{
int z_inner;
} t_s_inner;

C::B shows "t_s" as a typedef, BUT "t_s_inner" as a class. Is this a bug or a feature? :D

Btw, I was expecting to see "t_s_inner" as a typedef... ;)

daniloz

PS: why are structs treated as class by the CC?

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: New code completion remarks/issues
« Reply #175 on: October 09, 2009, 10:11:58 am »
Quick question... in the structs_typedefs.cpp (from the tests - thx Morten):
Code: [Select]
struct _s
{
  int   x;
  float y;
};
typedef struct _s t_s;

typedef struct _s_inner
{
int z_inner;
} t_s_inner;

C::B shows "t_s" as a typedef, BUT "t_s_inner" as a class. Is this a bug or a feature? :D

Btw, I was expecting to see "t_s_inner" as a typedef... ;)

daniloz

PS: why are structs treated as class by the CC?



not a bug,I do this.read the codes about void ParserThread::ReadClsNames(wxString& ancestor)
as I kown ,there is a bug in typedef handle .so......
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: New code completion remarks/issues
« Reply #176 on: October 09, 2009, 03:31:57 pm »
Quick question... in the structs_typedefs.cpp (from the tests - thx Morten):
Code: [Select]
struct _s
{
  int   x;
  float y;
};
typedef struct _s t_s;

typedef struct _s_inner
{
int z_inner;
} t_s_inner;

C::B shows "t_s" as a typedef, BUT "t_s_inner" as a class. Is this a bug or a feature? :D

Btw, I was expecting to see "t_s_inner" as a typedef... ;)

daniloz

PS: why are structs treated as class by the CC?



fixed.


and fixed the typedef issue.
test codes:
Code: [Select]
struct _s
{
  int   x;
  float y;
};
typedef struct _s t_s;
typedef t_s ssss;

ssss.
patch:
Code: [Select]
Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 5859)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -1795,13 +1795,15 @@
                   current.c_str(),
                   m_Str.c_str(),
                   (m_pLastParent ? m_pLastParent->m_Name.c_str():_T("<no-parent>")));
-            Token* newToken = DoAddToken(tkClass, current, m_Tokenizer.GetLineNumber());
+            Token* newToken = DoAddToken(tkTypedef, current, m_Tokenizer.GetLineNumber());
             if (!newToken)
                 break;
             else
             {
                 wxString tempAncestor = ancestor;
                 newToken->m_AncestorsString = tempAncestor;
+                newToken->m_ActualType = tempAncestor;
+                newToken->m_Type = tempAncestor;
             }
         }
         else // unexpected
Index: src/plugins/codecompletion/parser/token.cpp
===================================================================
--- src/plugins/codecompletion/parser/token.cpp (revision 5859)
+++ src/plugins/codecompletion/parser/token.cpp (working copy)
@@ -865,7 +865,7 @@
                 {
                     Token* ancestorToken = at(*it);
                     // only classes take part in inheritance
-                    if (ancestorToken && ancestorToken != token && (ancestorToken->m_TokenKind == tkClass || ancestorToken->m_TokenKind == tkEnum))// && !ancestorToken->m_IsTypedef)
+                    if (ancestorToken && ancestorToken != token && (ancestorToken->m_TokenKind == tkClass || ancestorToken->m_TokenKind == tkEnum || ancestorToken->m_TokenKind == tkTypedef))// && !ancestorToken->m_IsTypedef)
                     {
                         token->m_Ancestors.insert(*it);
                         ancestorToken->m_Descendants.insert(i);
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5230
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New code completion remarks/issues
« Reply #177 on: October 10, 2009, 07:42:47 am »
Here is the patch to add TRACE to the token.cpp.

Also, this patch contains the previous post's patch by blueshake.

Currently, If you test the structs_typedefs.cbp.

Only these statements below failed.

Code: [Select]
//    t_ptr.
//    t_ptr(3,3).

PS: Is it a typo? the original code is:

Code: [Select]
//    t_ptr_s(
//    t_ptr_s(3,3).



[attachment deleted by admin]
« Last Edit: October 10, 2009, 05:31:04 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5230
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New code completion remarks/issues
« Reply #178 on: October 11, 2009, 01:13:13 pm »
This is the testing patch for parsing the Macros for GCC 4.x

See the screenshot.



You should also change these section in your default.conf file. Just search by "TOKEN_REPLACEMENTS"



Code: [Select]
<TOKEN_REPLACEMENTS>
<ssmap>
<_GLIBCXX_BEGIN_NAMESPACE>
<![CDATA[+namespace]]>
</_GLIBCXX_BEGIN_NAMESPACE>
<_GLIBCXX_BEGIN_NAMESPACE_TR1>
<![CDATA[-namespace tr1 {]]>
</_GLIBCXX_BEGIN_NAMESPACE_TR1>
<_GLIBCXX_BEGIN_NESTED_NAMESPACE>
<![CDATA[+namespace]]>
</_GLIBCXX_BEGIN_NESTED_NAMESPACE>
<_GLIBCXX_END_NAMESPACE>
<![CDATA[}]]>
</_GLIBCXX_END_NAMESPACE>
<_GLIBCXX_END_NAMESPACE_TR1>
<![CDATA[}]]>
</_GLIBCXX_END_NAMESPACE_TR1>
<_GLIBCXX_END_NESTED_NAMESPACE>
<![CDATA[}]]>
</_GLIBCXX_END_NESTED_NAMESPACE>
<_GLIBCXX_STD>
<![CDATA[std]]>
</_GLIBCXX_STD>
</ssmap>
</TOKEN_REPLACEMENTS>


I'm still testing... :D

Edit

it seems works OK!



[attachment deleted by admin]
« Last Edit: October 11, 2009, 03:10:31 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: New code completion remarks/issues
« Reply #179 on: October 11, 2009, 02:40:12 pm »
What I want to know is if doing this wil slow down the parse process?
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?