Package pyplusplus :: Package code_creators :: Module code_creator :: Class code_creator_t

type code_creator_t

source code

object --+
         |
        code_creator_t
Known Subclasses:

code_creator_t is the base class for all code creators.

This class defines the interface that every code creator should implement. Also it provides few convenience functions.

The purpose of a code creator is the generation of a block of C++ source code as it will appear in the final source code for the extension module. The source code is obtained by calling the create() method. Derived classes must implement the _create_impl() method which is called by the create() method.

Instance Methods
 
__init__(self)
Constructor.
source code
str
create(self)
this function should be used in order to get code that should be generated.
source code
 
get_system_headers(self, recursive=False, unique=False) source code
str
beautify(self, code)
function that returns code without leading and trailing whitespaces.
source code
Static Methods
 
unique_headers(headers) source code
str
indent(code, size=1)
function that implements code indent algorithm.
source code
str
unindent(code)
function that implements code unindent algorithm.
source code
bool
is_comment(line)
function that returns true if content of the line is comment, otherwise false.
source code
Class Variables
  PYPLUSPLUS_NS_NAME = 'pyplusplus'
  LINE_LENGTH = 80
  PARAM_SEPARATOR = ', '
Properties
  works_on_instance
code_creator_t parent
Parent code creator or None if this is the root node.
target_configuration_t target_configuration
Target configuration.
code_creator_t top_parent
Root of the code creator tree.
Method Details

__init__(self)
(Constructor)

source code 

Constructor.

Parameters:
  • parent (code_creator_t) - Parent code creator.
Overrides: object.__init__

create(self)

source code 

this function should be used in order to get code that should be generated.

Returns: str
Returns a text block of C++ source code.

beautify(self, code)

source code 

function that returns code without leading and trailing whitespaces.

Parameters:
  • code (str) - A code block with C++ source code.
Returns: str

indent(code, size=1)
Static Method

source code 

function that implements code indent algorithm.

Parameters:
  • code (str) - C++ code block.
  • size (int) - The number of indentation levels that the code is shifted
Returns: str
Returns indented source code

unindent(code)
Static Method

source code 

function that implements code unindent algorithm.

Parameters:
  • code (str) - C++ code block.
Returns: str

is_comment(line)
Static Method

source code 

function that returns true if content of the line is comment, otherwise false.

Parameters:
  • line (str) - C++ source code
Returns: bool

Property Details

works_on_instance

Get Method:
_get_works_on_instance(self)
Set Method:
_set_works_on_instance(self, works_on_instance)

parent

Parent code creator or None if this is the root node.

Get Method:
_get_parent(self)
Set Method:
_set_parent(self, new_parent)
Type:
code_creator_t

target_configuration

Target configuration.

Get Method:
_get_target_configuration(self)
Set Method:
_set_target_configuration(self, config)
Type:
target_configuration_t

top_parent

Root of the code creator tree.

Get Method:
_get_top_parent(self)
Type:
code_creator_t