Update of /cvsroot/pygccxml/source/pyplusplus/code_creators
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32065
Modified Files:
__init__.py code_creator.py compound.py declaration_based.py
module.py
Log Message:
Added more doc strings
Index: compound.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pyplusplus/code_creators/compound.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** compound.py 14 Dec 2005 09:09:52 -0000 1.6
--- compound.py 16 Mar 2006 14:48:45 -0000 1.7
***************
*** 9,12 ****
--- 9,17 ----
class compound_t(code_creator.code_creator_t):
def __init__(self, parent=None):
+ """Constructor.
+
+ @param parent: Parent code creator.
+ @type parent: L{code_creator_t}
+ """
code_creator.code_creator_t.__init__( self, parent )
self._creators = []
***************
*** 14,20 ****
def _get_creators(self):
return self._creators
! creators = property(_get_creators)
def adopt_creator( self, creator, index=None):
creator.parent = self
if index or index == 0:
--- 19,34 ----
def _get_creators(self):
return self._creators
! creators = property(_get_creators,
! doc="""A list of children nodes.
! @type: list of L{code_creator_t}""")
def adopt_creator( self, creator, index=None):
+ """Add a creator to the list of children creators.
+
+ @param creator: Creator object
+ @type creator: L{code_creator_t}
+ @param index: Desired position of the creator or None to append it to the end of the list
+ @type index: int
+ """
creator.parent = self
if index or index == 0:
***************
*** 24,31 ****
def remove_creator( self, creator ):
creator.parent = None
del self._creators[ self._creators.index( creator ) ]
! def create_internal_code( creators ):
internals = map( lambda expr: expr.create(), creators )
internals = filter(None, internals )
--- 38,57 ----
def remove_creator( self, creator ):
+ """Remove a children code creator object.
+
+ @precondition: creator must be a children of self
+ @param creator: The creator node to remove
+ @type creator: L{code_creator_t}
+ """
creator.parent = None
del self._creators[ self._creators.index( creator ) ]
! def create_internal_code( creators ):
! """Concatenate the code from a list of code creators.
!
! @param creators: A list with code creators
! @type creators: list of L{code_creator_t}
! @rtype: str
! """
internals = map( lambda expr: expr.create(), creators )
internals = filter(None, internals )
Index: code_creator.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pyplusplus/code_creators/code_creator.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** code_creator.py 18 Dec 2005 06:36:59 -0000 1.9
--- code_creator.py 16 Mar 2006 14:48:45 -0000 1.10
***************
*** 9,15 ****
class code_creator_t(object):
"""
! code_creator_t is the base class for all code creators.
! This class defines interface that every code creator should implement.
! Also it provides few convinience functions.
"""
PYPLUSPLUS_NS_NAME = 'pyplusplus'
--- 9,22 ----
class code_creator_t(object):
"""
! 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 L{create()}
! method. Derived classes must implement the L{_create_impl()} method
! which is called by the create() method.
"""
PYPLUSPLUS_NS_NAME = 'pyplusplus'
***************
*** 17,20 ****
--- 24,32 ----
LINE_LENGTH = 80
def __init__(self, parent=None):
+ """Constructor.
+
+ @param parent: Parent code creator.
+ @type parent: code_creator_t
+ """
object.__init__(self)
if parent:
***************
*** 30,34 ****
self._parent = new_parent
"""parent - reference to parent code creator"""
! parent = property( _get_parent, _set_parent )
def _get_target_configuration( self ):
--- 42,49 ----
self._parent = new_parent
"""parent - reference to parent code creator"""
! parent = property( _get_parent, _set_parent,
! doc="""Parent code creator or None if this is the root node.
! @type: L{code_creator_t}
! """)
def _get_target_configuration( self ):
***************
*** 37,41 ****
self._target_configuration = config
"""target_configuration - reference to target_configuration_t class instance"""
! target_configuration = property( _get_target_configuration, _set_target_configuration )
def _get_top_parent(self):
--- 52,59 ----
self._target_configuration = config
"""target_configuration - reference to target_configuration_t class instance"""
! target_configuration = property( _get_target_configuration, _set_target_configuration,
! doc="""Target configuration.
! @type: L{target_configuration_t}
! """)
def _get_top_parent(self):
***************
*** 49,53 ****
parent = me.parent
"""top_parent - reference to top parent code creator"""
! top_parent = property( _get_top_parent )
def _create_impl(self):
--- 67,74 ----
parent = me.parent
"""top_parent - reference to top parent code creator"""
! top_parent = property( _get_top_parent,
! doc="""Root of the code creator tree.
! @type: L{code_creator_t}
! """)
def _create_impl(self):
***************
*** 56,59 ****
--- 77,82 ----
actually creates code and returns it. Return value of this function is
string.
+
+ @rtype: str
"""
raise NotImplementedError()
***************
*** 63,66 ****
--- 86,92 ----
this function should be used in order to get code that should be
generated.
+
+ @returns: Returns a text block of C++ source code.
+ @rtype: str
"""
code = self._create_impl()
***************
*** 71,74 ****
--- 97,104 ----
"""
function that returns code without leading and trailing whitespaces.
+
+ @param code: A code block with C++ source code.
+ @type code: str
+ @rtype: str
"""
assert isinstance( code, types.StringTypes )
***************
*** 77,81 ****
def indent( code, size=1 ):
"""
! function that implements code indent algorithm.
"""
assert isinstance( code, types.StringTypes )
--- 107,118 ----
def indent( code, size=1 ):
"""
! function that implements code indent algorithm.
!
! @param code: C++ code block.
! @type code: str
! @param size: The number of indentation levels that the code is shifted
! @type size: int
! @returns: Returns indented source code
! @rtype: str
"""
assert isinstance( code, types.StringTypes )
***************
*** 88,91 ****
--- 125,132 ----
"""
function that implements code unindent algorithm.
+
+ @param code: C++ code block.
+ @type code: str
+ @rtype: str
"""
assert isinstance( code, types.StringTypes )
***************
*** 100,106 ****
function that returns true if content of the line is comment, otherwise
false.
"""
assert isinstance( line, types.StringTypes )
l = line.lstrip()
return l.startswith( '//' ) or l.startswith( '/*' )
! is_comment = staticmethod( is_comment )
\ No newline at end of file
--- 141,151 ----
function that returns true if content of the line is comment, otherwise
false.
+
+ @param line: C++ source code
+ @type line: str
+ @rtype: bool
"""
assert isinstance( line, types.StringTypes )
l = line.lstrip()
return l.startswith( '//' ) or l.startswith( '/*' )
! is_comment = staticmethod( is_comment )
Index: declaration_based.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pyplusplus/code_creators/declaration_based.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** declaration_based.py 28 Feb 2006 07:31:32 -0000 1.10
--- declaration_based.py 16 Mar 2006 14:48:45 -0000 1.11
***************
*** 9,13 ****
--- 9,22 ----
class declaration_based_t(code_creator.code_creator_t):
+ """Code creator that is based on a declaration.
+ """
def __init__(self, declaration, parent=None ):
+ """Constructor.
+
+ @param declaration: Declaration object
+ @type declaration: L{decl_wrapper_t<decl_wrappers.decl_wrapper_t>}
+ @param parent: Parent code creator.
+ @type parent: code_creator_t
+ """
code_creator.code_creator_t.__init__(self, parent)
self._decl = declaration
***************
*** 23,28 ****
def _get_declaration(self):
return self._decl
! declaration = property( _get_declaration )
!
def _get_alias(self):
return self.declaration.alias
--- 32,40 ----
def _get_declaration(self):
return self._decl
! declaration = property( _get_declaration,
! doc="""The declaration this code creator is based on.
! @type: L{decl_wrapper_t<decl_wrappers.decl_wrapper_t>}
! """)
!
def _get_alias(self):
return self.declaration.alias
***************
*** 30,32 ****
def _set_alias(self, alias):
self.declaration.alias = alias
! alias = property( _get_alias, _set_alias )
\ No newline at end of file
--- 42,44 ----
def _set_alias(self, alias):
self.declaration.alias = alias
! alias = property( _get_alias, _set_alias )
Index: __init__.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pyplusplus/code_creators/__init__.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** __init__.py 28 Feb 2006 07:31:32 -0000 1.23
--- __init__.py 16 Mar 2006 14:48:45 -0000 1.24
***************
*** 4,7 ****
--- 4,18 ----
# http://www.boost.org/LICENSE_1_0.txt)
+ """Code creators.
+
+ This sub-package contains the code creator classes which are nodes in
+ the code creator tree. This tree represents the entire source code of
+ the final extension module (even when the source code will later be
+ distributed among several source files) and each individual code
+ creator represents a single block of source code.
+
+ The base class for all code creators is L{code_creator_t}.
+ """
+
from code_creator import code_creator_t
from compound import compound_t
Index: module.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pyplusplus/code_creators/module.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** module.py 14 Dec 2005 09:09:52 -0000 1.12
--- module.py 16 Mar 2006 14:48:45 -0000 1.13
***************
*** 14,18 ****
--- 14,24 ----
class module_t(compound.compound_t):
+ """This class represents the source code for the entire extension module.
+
+ The root of the code creator tree is always a module_t object.
+ """
def __init__(self):
+ """Constructor.
+ """
compound.compound_t.__init__(self, None)
***************
*** 52,56 ****
else:
return found[0]
! body = property( _get_body )
def _get_license( self ):
--- 58,66 ----
else:
return found[0]
! body = property( _get_body,
! doc="""A module_body_t object or None.
! @type: L{module_body_t}
! """
! )
def _get_license( self ):
***************
*** 65,71 ****
self.remove_creator( self.creators[0] )
self.adopt_creator( license_inst, 0 )
! license = property( _get_license, _set_license )
def last_include_index(self):
for i in range( len(self.creators) - 1, -1, -1 ):
if isinstance( self.creators[i], include.include_t ):
--- 75,93 ----
self.remove_creator( self.creators[0] )
self.adopt_creator( license_inst, 0 )
! license = property( _get_license, _set_license,
! doc="""License text.
!
! The license text will always be the first children node.
! @type: str or L{license_t}""")
def last_include_index(self):
+ """Return the children index of the last L{include_t} object.
+
+ An exception is raised when there is no include_t object among
+ the children creators.
+
+ @returns: Children index
+ @rtype: int
+ """
for i in range( len(self.creators) - 1, -1, -1 ):
if isinstance( self.creators[i], include.include_t ):
***************
*** 75,78 ****
--- 97,108 ----
def first_include_index(self):
+ """Return the children index of the first L{include_t} object.
+
+ An exception is raised when there is no include_t object among
+ the children creators.
+
+ @returns: Children index
+ @rtype: int
+ """
first_include_index = 0
for i in range( len(self.creators) ):
***************
*** 84,87 ****
--- 114,124 ----
def adopt_include(self, include_creator):
+ """Insert an L{include_t} object.
+
+ The include creator is inserted right after the last include file.
+
+ @param include_creator: Include creator object
+ @type include_creator: L{include_t}
+ """
self.adopt_creator( include_creator, self.last_include_index() + 1 )
***************
*** 133,135 ****
code = self.unindent(code)
return os.linesep.join( includes ) + 2 * os.linesep + code + os.linesep
!
\ No newline at end of file
--- 170,172 ----
code = self.unindent(code)
return os.linesep.join( includes ) + 2 * os.linesep + code + os.linesep
!
|