pyplusplus.code_creators.include

Package pyplusplus :: Package code_creators :: Module include |

# Source Code for Module pyplusplus.code_creators.include

     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  import include_directories
     8
     9 -class include_t(code_creator.code_creator_t):
    10      """
    11      Creates C++ code for include directive
    12      """
    13 -    def __init__( self, header, user_defined=False, system=False ):
    14          code_creator.code_creator_t.__init__(self)
    15          self._header = include_directories.include_directories_t.normalize( header )
    16          self._include_dirs_optimization = None #This parameter will be set from module_t.create function
    17          self._user_defined = user_defined
    18          self._system = system
    19          self.__created_code = None
    20
    21      @property
    22 -    def is_user_defined(self):
    23          return self._user_defined
    24
    25      @property
    26 -    def is_system(self):
    27          """Return True if header file is system( Boost.Python or Py++ ) header file"""
    28          return self._system
    29
    30 -    def _get_header(self):
    31          return self._header
    32 -    def _set_header(self, header):
    33          self._header = include_directories.include_directories_t.normalize( header )
    34      header = property( _get_header, _set_header )
    35
    36 -    def _get_include_dirs_optimization(self):
    37          return self._include_dirs_optimization
    38 -    def _set_include_dirs_optimization(self, include_dirs):
    39          self._include_dirs_optimization = include_dirs
    40      include_dirs_optimization = property( _get_include_dirs_optimization, _set_include_dirs_optimization )
    41
    42 -    def _create_include_directive_code(self):
    43          header = self.header.strip()
    44          if header.startswith( '"' ) or header.startswith( '<' ):
    45              return '#include %s' % self.header
    46
    47          if not self.include_dirs_optimization:
    48              return '#include "%s"' % self.header
    49          else:
    50              normalize_header = self.include_dirs_optimization.normalize_header( self.header )
    51              if self.include_dirs_optimization.is_std(self.header):
    52                  return '#include <%s>' % normalize_header
    53              else:
    54                  return '#include "%s"' % normalize_header
    55
    56 -    def _create_impl(self):
    57          if not self.__created_code:
    58              self.__created_code = self._create_include_directive_code()
    59          return self.__created_code
    60
    61 -    def _get_system_headers_impl( self ):
    62          return []
    63