Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

std::endl : wrong completion

<< < (2/4) > >>

ollydbg:

--- Quote from: Loaden on August 27, 2010, 05:57:10 am ---But in:ostream.tcc (LINE: 361 or 384)

--- Quote ---#if _GLIBCXX_EXTERN_TEMPLATE
  extern template class basic_ostream<char>;
 extern template ostream& endl(ostream&);
  extern template ostream& ends(ostream&);

--- End quote ---
Here is a variable.


--- End quote ---
our parser just recognize this "endl" as a function, because it has some grammar mode:

--- Code: ---AAAA BBBB();

--- End code ---

Loaden:

--- Quote from: ollydbg on August 27, 2010, 06:55:04 am ---
--- Quote from: Loaden on August 27, 2010, 05:57:10 am ---But in:ostream.tcc (LINE: 361 or 384)

--- Quote ---#if _GLIBCXX_EXTERN_TEMPLATE
  extern template class basic_ostream<char>;
 extern template ostream& endl(ostream&);
  extern template ostream& ends(ostream&);

--- End quote ---
Here is a variable.


--- End quote ---
our parser just recognize this "endl" as a function, because it has some grammar mode:

--- Code: ---AAAA BBBB();

--- End code ---

--- End quote ---

Looks can only judge of the special?

--- Quote ---Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp   (revision 6543)
+++ src/plugins/codecompletion/codecompletion.cpp   (working copy)
@@ -790,7 +790,8 @@
                 items.Add(tmp);
                 if (autoAddParentheses && token->m_TokenKind == tkFunction)
                 {
-                    m_SearchItem[token->m_Name] = token->m_Args.size() - 2;
+                    if (token->m_Name != _T("endl"))
+                        m_SearchItem[token->m_Name] = token->m_Args.size() - 2;
                 }
                 if (token->m_TokenKind == tkNamespace && token->m_Aliases.size())
                 {

--- End quote ---

[attachment deleted by admin]

eranif:
std::endl *is* a function.

When people are typing std::endl they are actually passing the pointer of the function to the 'operator <<' of class basic_ostream


--- Code: ---__ostream_type&
      operator<<(__ostream_type& (*__pf)(__ostream_type&))
--- End code ---

The same is true for all other similar methods, like std::hex, std::oct, std::dec etc
So if you are going to special handle the 'endl' case, make sure you handle the other methods as well (hex, dec, oct etc.)

Eran

ollydbg:

--- Quote from: eranif on August 27, 2010, 07:55:16 am ---std::endl *is* a function.

When people are typing std::endl they are actually passing the pointer of the function to the 'operator <<' of class basic_ostream


--- Code: ---__ostream_type&
      operator<<(__ostream_type& (*__pf)(__ostream_type&))
--- End code ---

The same is true for all other similar methods, like std::hex, std::oct, std::dec etc
So if you are going to special handle the 'endl' case, make sure you handle the other methods as well (hex, dec, oct etc.)

Eran


--- End quote ---

Thanks eran for your help.
So, my personal question is: how does Codelite deal with this kind of problem??
thanks.

eranif:

--- Quote ---So, my personal question is: how does Codelite deal with this kind of problem??
--- End quote ---
I am not :D

The same as codeblocks:
when user types std::endl -> codelite adds the () and shows the function tip. I never find it a problem since in codelite if I delete the open brace, the closing brace is also deleted

Eran

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version