Author Topic: vector<int> is OK, but string or wstring no-work.  (Read 91407 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: vector<int> is OK, but string or wstring no-work.
« Reply #60 on: January 14, 2010, 02:37:56 am »
where is the option "parse while typiing"?
Menu->settings->Editor->CodeCompletion.
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: vector<int> is OK, but string or wstring no-work.
« Reply #61 on: January 14, 2010, 03:10:21 am »
hi,I encouter that the parser can not parse in real-time even I enable "parse while typing".

edit:
     update to the latest svn without any change.
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: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: vector<int> is OK, but string or wstring no-work.
« Reply #62 on: January 14, 2010, 03:13:42 am »
hi,I encouter that the parser can not parse in real-time even I enable "parse while typing".

edit:
     update to the latest svn without any change.

Yes, I can confirm this bug.
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: vector<int> is OK, but string or wstring no-work.
« Reply #63 on: January 14, 2010, 03:59:41 am »
the reason is simple.
the variable needParse's scope is function scope.when it (needParse) leave the functioin body.it will be destroyed.so it will be false again when the carect is in different line.
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 Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: vector<int> is OK, but string or wstring no-work.
« Reply #64 on: January 14, 2010, 04:57:58 am »
Oh, look this screenshot.
Code
#include <iostream>
#include <string>

using namespace std;

int main()
{
    basic_string<wchar_t> ws;
    ws.
    return 0;
}
@Loaden
This works fine here, rev 6083.
You can see the screen shot below:

If you drag the scroll bar prompt window, you will find many non-basic_string <T> function, it seems from iostream.


[attachment deleted by admin]

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: vector<int> is OK, but string or wstring no-work.
« Reply #65 on: January 14, 2010, 04:59:04 am »
SVN 6083.


[attachment deleted by admin]

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: vector<int> is OK, but string or wstring no-work.
« Reply #66 on: January 14, 2010, 06:18:32 am »
Quote
If you drag the scroll bar prompt window, you will find many non-basic_string <T> function, it seems from iostream.


you can not use variable name ws here.because it has been defined in istream.tcc which belong to gcc files.


Note:

try another name e.g. wsss,you will get the answer.
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: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: vector<int> is OK, but string or wstring no-work.
« Reply #67 on: January 14, 2010, 06:38:29 am »
Quote
If you drag the scroll bar prompt window, you will find many non-basic_string <T> function, it seems from iostream.


you can not use variable name ws here.because it has been defined in istream.tcc which belong to gcc files.


Note:

try another name e.g. wsss,you will get the answer.

Good! So, this is not a problem. :wink:
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: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: vector<int> is OK, but string or wstring no-work.
« Reply #68 on: January 14, 2010, 06:46:52 am »
Just a reminder:

@morten

This is a big bug, should be fixed soon.

Re: The 12 January 2010 build (6080) is out.
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 Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: vector<int> is OK, but string or wstring no-work.
« Reply #69 on: January 14, 2010, 08:12:53 am »
Quote
If you drag the scroll bar prompt window, you will find many non-basic_string <T> function, it seems from iostream.


you can not use variable name ws here.because it has been defined in istream.tcc which belong to gcc files.


Note:

try another name e.g. wsss,you will get the answer.

Good! So, this is not a problem. :wink:
Confirm it! Thanks!
Below code works fine.
Code
#include <iostream>
#include <string>

int main()
{
    std::wstring ws;
    ws.
    return 0;
}

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: vector<int> is OK, but string or wstring no-work.
« Reply #70 on: January 14, 2010, 11:45:53 am »
the reason is simple.
the variable needParse's scope is function scope.when it (needParse) leave the functioin body.it will be destroyed.so it will be false again when the carect is in different line.
I don't get it. m_NeedReparse was used just there. So what's wrong with this piece of code:
Code
    Parser* parser = m_NativeParser.GetParserPtr();
    bool needReparse = false;
    if (   parser && parser->Options().whileTyping
        && (   (event.GetModificationType() & wxSCI_MOD_INSERTTEXT)
            || (event.GetModificationType() & wxSCI_MOD_DELETETEXT) ) )
    {
        needReparse = true;
    }
    if (control->GetCurrentLine() != m_CurrentLine)
    {
        if (parser && needReparse)
            parser->Reparse(editor->GetFilename());
        else
            FindFunctionAndUpdate(control->GetCurrentLine());
    }
It will trigger the re-parse correctly in the case a parser is present, the option is enabled and a char was inserted/deleted.

So...?! (I am a bit sick, so probably you should explain slowly... ;-)).
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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: vector<int> is OK, but string or wstring no-work.
« Reply #71 on: January 14, 2010, 11:46:49 am »
@morten
This is a big bug, should be fixed soon.
Re: The 12 January 2010 build (6080) is out.
Done in my local copy. Will commit in a while... probably after blueshake answered the other question which may require some modifications, too.
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

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: vector<int> is OK, but string or wstring no-work.
« Reply #72 on: January 14, 2010, 12:32:54 pm »
Quote
I don't get it. m_NeedReparse was used just there. So what's wrong with this piece of code:


see the codes below,in the new codes,it declare a new variable needReparse ,not m_NeedReparse.
    Parser* parser = m_NativeParser.GetParserPtr();
    bool needReparse = false;
    if (   parser && parser->Options().whileTyping
        && (   (event.GetModificationType() & wxSCI_MOD_INSERTTEXT)
            || (event.GetModificationType() & wxSCI_MOD_DELETETEXT) ) )
    {
        needReparse = true;
    }
    if (control->GetCurrentLine() != m_CurrentLine)
    {
        if (parser && needReparse)
            parser->Reparse(editor->GetFilename());
        else
            FindFunctionAndUpdate(control->GetCurrentLine());
    }
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: vector<int> is OK, but string or wstring no-work.
« Reply #73 on: January 14, 2010, 12:35:06 pm »
maybe this will help a little.
Code
Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp (revision 6083)
+++ src/plugins/codecompletion/codecompletion.cpp (working copy)
@@ -2085,17 +2085,24 @@
     }
 
     Parser* parser = m_NativeParser.GetParserPtr();
-    bool needReparse = false;
+    //bool needReparse = false;
     if (   parser && parser->Options().whileTyping
         && (   (event.GetModificationType() & wxSCI_MOD_INSERTTEXT)
             || (event.GetModificationType() & wxSCI_MOD_DELETETEXT) ) )
     {
-        needReparse = true;
+        //needReparse = true;
+        m_NeedReparse = true;
     }
     if (control->GetCurrentLine() != m_CurrentLine)
     {
-        if (parser && needReparse)
-            parser->Reparse(editor->GetFilename());
+
+        if (parser && m_NeedReparse)
+           {
+               m_NeedReparse = false;
+               parser->Reparse(editor->GetFilename());
+           }
         else
             FindFunctionAndUpdate(control->GetCurrentLine());
     }
Index: src/plugins/codecompletion/codecompletion.h
===================================================================
--- src/plugins/codecompletion/codecompletion.h (revision 6083)
+++ src/plugins/codecompletion/codecompletion.h (working copy)
@@ -135,7 +135,7 @@
         int                                m_ActiveCalltipsNest;
 
         bool                               m_IsAutoPopup;
-
+        bool                                m_NeedReparse;
         wxChoice*                          m_Function;
         wxChoice*                          m_Scope;
         FunctionsScopeVec                  m_FunctionsScope;


NOTE:

the patch is used to show what changed(or explain what I try to say.please do not apply it)
:wink:
« Last Edit: January 14, 2010, 12:37:07 pm by blueshake »
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 Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: vector<int> is OK, but string or wstring no-work.
« Reply #74 on: January 14, 2010, 02:27:28 pm »
To make it clear, why the current code does not work:

needReparse is set to true whenever text is inserted or deleted, but the reparsing is only triggered if we leave the current line.
This does normally (never ?) happen inside the same event, so we have to remember whether a reparse is needed, either with a member-variable or a static local variable.