Author Topic: some advice to CodeCompletion Plugin  (Read 3352 times)

Offline zyjjingle

  • Multiple posting newcomer
  • *
  • Posts: 11
some advice to CodeCompletion Plugin
« on: September 23, 2009, 05:08:56 pm »
in gcc compiler tool chain include files, always use this way
   //#define _EXFUN(name, proto) name proto
   //#define _EXPARAM(name, proto) (name) proto
   //#define _DEFUN(name,arglist,args) name(args)
   //#define _DEFUN_VOID(name) name(void)

for example:
char    *_EXFUN(strcat,(char *, const char *));
char    *_EXFUN(strchr,(const char *, int));
int    _EXFUN(strcmp,(const char *, const char *));

If CodeCompletion add some codes, it is easy to extend functions defined in this way.

//this is a referrence
int TokensTree::AddToken(Token* newToken,int forceidx)
{
    if(!newToken)
        return -1;

   //linux include convert
   //#define _EXFUN(name, proto) name proto
   //#define _EXPARAM(name, proto) (name) proto
   //#define _DEFUN(name,arglist,args) name(args)
   //#define _DEFUN_VOID(name) name(void)
   {
      //wxString file = GetFilename(newToken->m_File);
      //if( (file.Find("GNUARM")>=0 || file.Find( "MinGW" ) >=0 ) )
      {
         if( newToken->m_Name == "_DEFUN_VOID" )
         {
            wxString name = newToken->m_Args;
            name = name.AfterFirst( '(' );
            name = name.BeforeLast( ')' );
            newToken->m_Name = name ;
            newToken->m_Args = "(void)";
         }
         else if( newToken->m_Name=="_EXFUN" )
         {
            wxString name = newToken->m_Args;
            LPCTSTR p = (LPCTSTR)name;
            name.Replace( "\t", " " );
            name = name.AfterFirst( '(' );
            name = name.BeforeLast( ')' );
            name.Trim().Trim(false);
            
            wxString type = newToken->m_ActualType;
            bool flag = false;
            while( name[0]=='*' || name[0]=='&' )
            {
               type += name[0];
               name.Remove(0,1);
               flag = true;
            }
            if( flag )
            {
               newToken->m_ActualType = type;
               name.Trim(false);
            }
            
            newToken->m_Name = name.BeforeFirst(',');
            newToken->m_Args = name.AfterFirst(',');
         }
      }
   }
« Last Edit: September 23, 2009, 05:32:02 pm by zyjjingle »