Package pyplusplus :: Package code_creators :: Module namespace |

# Source Code for Module pyplusplus.code_creators.namespace

     1  # Copyright 2004-2008 Roman Yakovenko.
     2  # Distributed under the Boost Software License, Version 1.0. (See
     3  # accompanying file LICENSE_1_0.txt or copy at
     4  # http://www.boost.org/LICENSE_1_0.txt)
     5
     6  import code_creator
     7
     8 -class namespace_alias_t(code_creator.code_creator_t):
     9 -    def __init__( self, alias, full_namespace_name ):
    10          code_creator.code_creator_t.__init__( self )
    11          self._alias = alias
    12          self._full_namespace_name = full_namespace_name
    13          self.__created_code = None
    14
    15 -    def _get_alias( self ):
    16          return self._alias
    17 -    def _set_alias( self, new_alias ):
    18          self._alias = new_alias
    19      alias = property( _get_alias, _set_alias )
    20
    21 -    def _get_full_namespace_name( self ):
    22          return self._full_namespace_name.lstrip( '::' )
    23 -    def _set_full_namespace_name( self, new_full_namespace_name ):
    24          self._full_namespace_name = new_full_namespace_name
    25      full_namespace_name = property( _get_full_namespace_name, _set_full_namespace_name )
    26
    27 -    def _create_impl(self):
    28          if self.__created_code:
    29              return self.__created_code
    30          else:
    31              self.__created_code = 'namespace %s = %s;' % ( self.alias, self.full_namespace_name )
    32              return self.__created_code
    33
    34 -    def _get_system_headers_impl( self ):
    35          return []
    36
    37 -class namespace_using_t(code_creator.code_creator_t):
    38 -    def __init__( self, namespace_name ):
    39          code_creator.code_creator_t.__init__(self )
    40          self._namespace_name = namespace_name
    41          self.__created_code = None
    42
    43 -    def _get_namespace_name( self ):
    44          return self._namespace_name.lstrip( '::' )
    45 -    def _set_namespace_name( self, new_namespace_name ):
    46          self._namespace_name = new_namespace_name
    47      namespace_name = property( _get_namespace_name, _set_namespace_name )
    48
    49 -    def _create_impl(self):
    50          if self.__created_code:
    51              return self.__created_code
    52          else:
    53              self.__created_code = 'using namespace %s;' % self.namespace_name
    54              return self.__created_code
    55
    56 -    def _get_system_headers_impl( self ):
    57          return []
    58