SCons :: cpp :: PreProcessor :: Class PreProcessor
[hide private]
[frames] | no frames]

Class PreProcessor

source code

object --+
         |
        PreProcessor
Known Subclasses:

The main workhorse class for handling C pre-processing.
Instance Methods [hide private]
 
__call__(self, file)
Pre-processes a file.
source code
 
__init__(self, current='.', cpppath=(), dict={}, all=0)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
_do_if_else_condition(self, condition)
Common logic for evaluating the conditions on #if, #ifdef and #ifndef lines.
source code
 
all_include(self, t) source code
 
do_define(self, t)
Default handling of a #define line.
source code
 
do_elif(self, t)
Default handling of a #elif line.
source code
 
do_else(self, t)
Default handling of a #else line.
source code
 
do_endif(self, t)
Default handling of a #endif line.
source code
 
do_if(self, t)
Default handling of a #if line.
source code
 
do_ifdef(self, t)
Default handling of a #ifdef line.
source code
 
do_ifndef(self, t)
Default handling of a #ifndef line.
source code
 
do_import(self, t)
Default handling of a #import line.
source code
 
do_include(self, t)
Default handling of a #include line.
source code
 
do_include_next(self, t)
Default handling of a #include line.
source code
 
do_nothing(self, t)
Null method for when we explicitly want the action for a specific preprocessor directive to do nothing.
source code
 
do_undef(self, t)
Default handling of a #undef line.
source code
 
eval_expression(self, t)
Evaluates a C preprocessor expression.
source code
 
finalize_result(self, fname) source code
 
find_include_file(self, t)
Finds the #include file for a given preprocessor tuple.
source code
 
initialize_result(self, fname) source code
 
process_contents(self, contents, fname=None)
Pre-processes a file contents.
source code
 
read_file(self, file) source code
 
resolve_include(self, t)
Resolve a tuple-ized #include line.
source code
 
restore(self)
Pops the previous dispatch table off the stack and makes it the current one.
source code
 
save(self)
Pushes the current dispatch table on the stack and re-initializes the current dispatch table to the default.
source code
 
scons_current_file(self, t) source code
 
start_handling_includes(self, t=None)
Causes the PreProcessor object to start processing #import, #include and #include_next lines.
source code
 
stop_handling_includes(self, t=None)
Causes the PreProcessor object to stop processing #import, #include and #include_next lines.
source code
 
tupleize(self, contents)
Turns the contents of a file into a list of easily-processed tuples describing the CPP lines in the file.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__call__(self, file)
(Call operator)

source code 

Pre-processes a file.

This is the main public entry point.

__init__(self, current='.', cpppath=(), dict={}, all=0)
(Constructor)

source code 
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: object.__init__
(inherited documentation)

eval_expression(self, t)

source code 

Evaluates a C preprocessor expression.

This is done by converting it to a Python equivalent and eval()ing it in the C preprocessor namespace we use to track #define values.

process_contents(self, contents, fname=None)

source code 

Pre-processes a file contents.

This is the main internal entry point.

resolve_include(self, t)

source code 
Resolve a tuple-ized #include line.

This handles recursive expansion of values without "" or <>
surrounding the name until an initial " or < is found, to handle
        #include FILE
where FILE is a #define somewhere else.

start_handling_includes(self, t=None)

source code 

Causes the PreProcessor object to start processing #import, #include and #include_next lines.

This method will be called when a #if, #ifdef, #ifndef or #elif evaluates True, or when we reach the #else in a #if, #ifdef, #ifndef or #elif block where a condition already evaluated False.

stop_handling_includes(self, t=None)

source code 

Causes the PreProcessor object to stop processing #import, #include and #include_next lines.

This method will be called when a #if, #ifdef, #ifndef or #elif evaluates False, or when we reach the #else in a #if, #ifdef, #ifndef or #elif block where a condition already evaluated True.

tupleize(self, contents)

source code 

Turns the contents of a file into a list of easily-processed tuples describing the CPP lines in the file.

The first element of each tuple is the line's preprocessor directive (#if, #include, #define, etc., minus the initial '#'). The remaining elements are specific to the type of directive, as pulled apart by the regular expression.