Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

use_action_iterator Class Reference

This private class parses the use statement after macro expansion This is a finite state machine. More...

Collaboration diagram for use_action_iterator:

Collaboration graph
[legend]
List of all members.

Public Methods

 use_action_iterator ()
void set (const cmt_string& w)
bool ok ()
Useget_use (Use* parent)
 Build or retreive the Use object corresponding to the parsed specification. More...


Private Types

enum  {
  need_package, need_version, need_path, need_version_alias,
  need_path_alias, finished
}
 Warning : this Use had been previously specified as -no_auto_imports Now this new specification tries to turn it to auto_imports. More...


Private Attributes

enum use_action_iterator:: { ... }  state
 Warning : this Use had been previously specified as -no_auto_imports Now this new specification tries to turn it to auto_imports. More...

State auto_imports
cmt_string package
cmt_string version
cmt_string path
cmt_string version_alias
cmt_string path_alias

Detailed Description

This private class parses the use statement after macro expansion This is a finite state machine.

It maintains the results of the parsing in terms of a package name, a version, a path, and state variables (no_auto_imports)

Definition at line 266 of file cmt_use.cxx.


Member Enumeration Documentation

anonymous enum [private]
 

Warning : this Use had been previously specified as -no_auto_imports Now this new specification tries to turn it to auto_imports.

It will be required to propagate the change, according to the specifications:

for all sub_uses: if it is unspecified OR specified as auto_imports: turn it to auto_imports

Enumeration values:
need_package  
need_version  
need_path  
need_version_alias  
need_path_alias  
finished  

Definition at line 492 of file cmt_use.cxx.

00493   {
00494     need_package,
00495     need_version,
00496     need_path,
00497     need_version_alias,
00498     need_path_alias,
00499     finished
00500   }


Constructor & Destructor Documentation

use_action_iterator::use_action_iterator ( ) [inline]
 

Definition at line 270 of file cmt_use.cxx.

00271       {
00272         state = need_package;
00273         auto_imports = Unspecified;
00274       }


Member Function Documentation

Use * use_action_iterator::get_use ( Use * parent ) [inline]
 

Build or retreive the Use object corresponding to the parsed specification.

Definition at line 332 of file cmt_use.cxx.

Referenced by Use::action().

00333       {
00334         static Use::UsePtrVector& Uses = Use::uses ();
00335 
00336         if (version == "") version = "*";
00337 
00338         if (Cmt::get_debug ())
00339           {
00340             int i;
00341 
00342             cout << "use::action1> current=" << parent->package <<
00343                 " package=" << package << " ";
00344 
00345             for (i = 0; i < Uses.size (); i++)
00346               {
00347                 Use* u = Uses[i];
00348                 cout << u->package << " ";
00349               }
00350             cout << endl;
00351           }
00352 
00353         const Use& cu = Use::current ();
00354 
00364         ActionType action = Cmt::get_action ();
00365 
00366         if ((parent != 0) && 
00367             (parent->package != cu.package) &&
00368             (Cmt::get_scope () == ScopePrivate) &&
00369             (action != action_broadcast) &&
00370             (action != action_show_uses))
00371           {
00372             return (0);
00373           }
00374 
00375         // Here the version may contain wild cards
00376 
00377         UseContext save = UseContext::current ();
00378 
00379         if (Cmt::get_debug ())
00380           {
00381             cout << "before adding " << package <<"> auto_imports=" << auto_imports
00382                  << " (current was " << UseContext::get_current_auto_imports () << ")" 
00383                  << " (Cmt::scope=" << Cmt::get_scope () << ")"
00384                  << endl;
00385           }
00386 
00391         switch (auto_imports)
00392           {
00393             case Unspecified:
00394 
00395                 // unspecified => we forward the state saved in the current use context
00396 
00397               UseContext::set_current (UseContext::get_current_auto_imports ());
00398               break;
00399             case Off:
00400 
00401                 // off => the context becomes constrained to be off
00402 
00403               UseContext::set_current (Off);
00404               break;
00405             case On:
00406 
00407                 // on => if current context is off it is kept off
00408                 //       otherwise it is forced to on
00409 
00410               if (UseContext::get_current_auto_imports () != Off)
00411                 {
00412                   UseContext::set_current (On);
00413                 }
00414               break;
00415           }
00416 
00417           //UseContext::set_current (auto_imports);
00418         UseContext::set_current (Cmt::get_scope ());
00419 
00421         Use* new_use = Use::add (path, package, version, 
00422                                  version_alias, path_alias, parent,
00423                                  auto_imports);
00424 
00425         if (new_use != 0)
00426           {
00427             if (Cmt::get_debug ())
00428               {
00429                 cout << "after adding1 " << package << "> auto_imports=" << new_use->auto_imports << endl;
00430               }
00431 
00432             switch (new_use->auto_imports)
00433               {
00434                 case Unspecified:
00435                   new_use->auto_imports = UseContext::get_current_auto_imports ();
00436                   break;
00437                 case On:
00438                   break;
00439                 case Off:
00440                   if (UseContext::get_current_auto_imports () == On)
00441                     {
00453                         //new_use->auto_imports = On;
00454                       new_use->set_auto_imports (On);
00455                     }
00456                   break;
00457               }
00458 
00459 
00460             if (Cmt::get_debug ())
00461               {
00462                 cout << "after adding2 " << package << "> auto_imports=" << new_use->auto_imports << endl;
00463               }
00464 
00465             UseContext& c = UseContext::current ();
00466             c = save;
00467 
00468             Use::reorder (new_use, parent);
00469             
00470             if (Cmt::get_debug ())
00471               {
00472                 int i;
00473                 
00474                 cout << "use::action2> current=" << parent->package
00475                      << " package=" << package << " ";
00476 
00477                 for (i = 0; i < Uses.size (); i++)
00478                   {
00479                     Use* u = Uses[i];
00480                     cout << u->package << " ";
00481                   }
00482 
00483                 cout << endl;
00484               }
00485           }
00486 
00487         return (new_use);
00488       }

bool use_action_iterator::ok ( ) [inline]
 

Definition at line 318 of file cmt_use.cxx.

Referenced by Use::action().

00319       {
00320         if (package == "") return (false);
00321         if (CmtSystem::is_home_package (package, version)) return (false);
00322         if (CmtSystem::is_user_context_package (package, version)) return (false);
00323 
00324         return (true);
00325       }

void use_action_iterator::set ( const cmt_string & w ) [inline]
 

Definition at line 276 of file cmt_use.cxx.

Referenced by Use::action().

00277       {
00278         if (w == "-auto_imports")
00279           {
00280             auto_imports = On;
00281           }
00282         else if (w == "-no_auto_imports")
00283           {
00284             auto_imports = Off;
00285           }
00286         else if (w == "|")
00287           {
00288             state = need_version_alias;
00289           }
00290         else
00291           {
00292             switch (state)
00293               {
00294                 case need_package:
00295                   package = w;
00296                   state = need_version;
00297                   break;
00298                 case need_version:
00299                   version = w;
00300                   state = need_path;
00301                   break;
00302                 case need_path:
00303                   path = w;
00304                   state = finished;
00305                   break;
00306                 case need_version_alias:
00307                   version_alias = w;
00308                   state = need_path_alias;
00309                   break;
00310                 case need_path_alias:
00311                   path_alias = w;
00312                   state = finished;
00313                   break;
00314               }
00315           }
00316       }


Member Data Documentation

State use_action_iterator::auto_imports [private]
 

Definition at line 502 of file cmt_use.cxx.

cmt_string use_action_iterator::package [private]
 

Definition at line 504 of file cmt_use.cxx.

cmt_string use_action_iterator::path [private]
 

Definition at line 506 of file cmt_use.cxx.

cmt_string use_action_iterator::path_alias [private]
 

Definition at line 508 of file cmt_use.cxx.

enum { ... } use_action_iterator::state [private]
 

Warning : this Use had been previously specified as -no_auto_imports Now this new specification tries to turn it to auto_imports.

It will be required to propagate the change, according to the specifications:

for all sub_uses: if it is unspecified OR specified as auto_imports: turn it to auto_imports

cmt_string use_action_iterator::version [private]
 

Definition at line 505 of file cmt_use.cxx.

cmt_string use_action_iterator::version_alias [private]
 

Definition at line 507 of file cmt_use.cxx.


The documentation for this class was generated from the following file:
Generated at Thu May 16 16:28:02 2002 for CMT by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000