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

Class PreProcessor

Known Subclasses:
DumbPreProcessor

The main workhorse class for handling C pre-processing.


Method Summary
  __init__(self, current, cpppath, dict, all)
  __call__(self, contents)
Pre-processes a file contents.
  all_include(self, t)
  do_define(self, t)
Default handling of a #define line.
  do_elif(self, t)
Default handling of a #elif line.
  do_else(self, t)
Default handling of a #else line.
  do_endif(self, t)
Default handling of a #endif line.
  do_if(self, t)
Default handling of a #if line.
  do_ifdef(self, t)
Default handling of a #ifdef line.
  do_ifndef(self, t)
Default handling of a #ifndef line.
  do_import(self, t)
Default handling of a #import line.
  do_include(self, t)
Default handling of a #include line.
  do_include_next(self, t)
Default handling of a #include line.
  do_nothing(self, t)
Null method for when we explicitly want the action for a specific preprocessor directive to do nothing.
  do_undef(self, t)
Default handling of a #undef line.
  eval_expression(self, t)
Evaluates a C preprocessor expression.
  find_include_file(self, t)
Finds the #include file for a given preprocessor tuple.
  resolve_include(self, t)
Resolve a tuple-ized #include line.
  restore(self)
Pops the previous dispatch table off the stack and makes it the current one.
  save(self)
Pushes the current dispatch table on the stack and re-initializes the current dispatch table to the default.
  start_handling_includes(self, t)
Causes the PreProcessor object to start processing #import, #include and #include_next lines.
  stop_handling_includes(self, t)
Causes the PreProcessor object to stop processing #import, #include and #include_next lines.
  tupleize(self, contents)
Turns the contents of a file into a list of easily-processed tuples describing the CPP lines in the file.
  _do_if_else_condition(self, condition)
Common logic for evaluating the conditions on #if, #ifdef and #ifndef lines.

Method Details

__call__(self, contents)
(Call operator)

Pre-processes a file contents.

This is the main entry point, which

do_define(self, t)

Default handling of a #define line.

do_elif(self, t)

Default handling of a #elif line.

do_else(self, t)

Default handling of a #else line.

do_endif(self, t)

Default handling of a #endif line.

do_if(self, t)

Default handling of a #if line.

do_ifdef(self, t)

Default handling of a #ifdef line.

do_ifndef(self, t)

Default handling of a #ifndef line.

do_import(self, t)

Default handling of a #import line.

do_include(self, t)

Default handling of a #include line.

do_include_next(self, t)

Default handling of a #include line.

do_nothing(self, t)

Null method for when we explicitly want the action for a specific preprocessor directive to do nothing.

do_undef(self, t)

Default handling of a #undef line.

eval_expression(self, t)

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.

find_include_file(self, t)

Finds the #include file for a given preprocessor tuple.

resolve_include(self, t)

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.

restore(self)

Pops the previous dispatch table off the stack and makes it the current one.

save(self)

Pushes the current dispatch table on the stack and re-initializes the current dispatch table to the default.

start_handling_includes(self, t=None)

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)

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)

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.

_do_if_else_condition(self, condition)

Common logic for evaluating the conditions on #if, #ifdef and #ifndef lines.


Generated by Epydoc 2.1 on Wed Dec 12 09:39:31 2007 http://epydoc.sf.net