[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdevelop/languages/cpp/parser/rpp
From:       David Nolden <david.nolden.kde () art-master ! de>
Date:       2007-09-11 20:27:30
Message-ID: 1189542450.447979.32091.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 711230 by zwabel:

Always create undef-macros instead of removing macros from the environment. This is \
needed for correct environment-management.

 M  +13 -2     pp-engine.cpp  
 M  +13 -4     pp-environment.cpp  
 M  +2 -3      pp-macro-expander.cpp  


--- trunk/KDE/kdevelop/languages/cpp/parser/rpp/pp-engine.cpp #711229:711230
@@ -565,7 +565,10 @@
         break;
       }
 
-      result.set_long(m_environment->retrieveMacro(token_text) ? 1 : 0);
+      {
+        pp_macro* m = m_environment->retrieveMacro(token_text);
+        result.set_long( (m && !m->isUndef()) ? 1 : 0);
+      }
 
       token = next_token(input); // skip '('
 
@@ -1024,7 +1027,15 @@
   QString macro_name = skip_identifier(input);
   RETURN_ON_FAIL(!macro_name.isEmpty());
 
-  m_environment->clearMacro(macro_name);
+  pp_macro* macro = new pp_macro();
+  macro->file = m_files.top();
+  macro->name = macro_name;
+
+  macro->defined = false;
+
+  m_environment->setMacro(macro);
+  
+  //m_environment->clearMacro(macro_name);
 }
 
 int pp::next_token (Stream& input)
--- trunk/KDE/kdevelop/languages/cpp/parser/rpp/pp-environment.cpp #711229:711230
@@ -157,14 +157,23 @@
 
 void Environment::clearMacro(const KDevelop::HashedString& name)
 {
-  if (!m_replaying) {
+//   pp_macro* undef = new pp_macro();
+//   undef->name = name;
+//   undef->defined = false;
+//   if(!m_replaying)
+//     m_blocks.top()->macros.append(undef);
+// 
+//   setMacro(undef); //Before, m_environment.remove(..) was called
+
+ if(!m_replaying) {
     pp_macro* undef = new pp_macro();
     undef->name = name;
     undef->defined = false;
-
     m_blocks.top()->macros.append(undef);
   }
 
+  ///@todo Think about how this plays together with environment-management
+  ///We need undef-macros to be put into the definedMacros etc. lists
   m_environment.remove(name);
 }
 
@@ -173,9 +182,9 @@
   if (!m_replaying && !m_blocks.isEmpty())
     m_blocks.top()->macros.append(macro);
 
-  if( !macro->defined )
+/*  if( !macro->defined )
     clearMacro(macro->name);
-  else
+  else*/
     m_environment.insert(macro->name, macro);
 }
 
--- trunk/KDE/kdevelop/languages/cpp/parser/rpp/pp-macro-expander.cpp #711229:711230
@@ -185,7 +185,7 @@
         // TODO handle inbuilt "defined" etc functions
 
         pp_macro* macro = m_engine->environment()->retrieveMacro(name);
-        if (!macro || macro->hidden || m_engine->hideNextMacro())
+        if (!macro || !macro->defined || macro->hidden || m_engine->hideNextMacro())
         {
           m_engine->setHideNextMacro(name == "defined");
 
@@ -225,9 +225,8 @@
               QString identifier = skip_identifier(es);
 
               pp_macro* m2 = 0;
-              if (es.atEnd() && (m2 = \
m_engine->environment()->retrieveMacro(identifier))) { +              if (es.atEnd() \
&& (m2 = m_engine->environment()->retrieveMacro(identifier)) && m2->defined) {  m = \
                m2;
-
               } else {
                 output << expanded;
               }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic