Package pyplusplus :: Package module_creator :: Module creators_wizard

# Source Code for Module pyplusplus.module_creator.creators_wizard

     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  """this module defines few function that will guess what creator(s) should be
     7  created for exposing a declaration
     8  """
     9
    10  from pygccxml import declarations
    11  from pyplusplus import code_creators
    12
    13
    14  ACCESS_TYPES = declarations.ACCESS_TYPES
    15  VIRTUALITY_TYPES = declarations.VIRTUALITY_TYPES
    16
    17
    18 -def find_out_mem_fun_creator_classes( decl ):
    19      """return tuple of ( registration, declaration ) code creator classes"""
    20      maker_cls = None
    21      fwrapper_cls = None
    22      access_level = decl.parent.find_out_member_access_type( decl )
    23      if len( decl.transformations ) not in ( 0, 1 ):
    24          raise RuntimeError( "Right now Py++ does not support multiple transformation applied on a single function." )
    25      if access_level == ACCESS_TYPES.PUBLIC:
    26          if decl.virtuality == VIRTUALITY_TYPES.NOT_VIRTUAL:
    27              if decl.transformations:
    28                  maker_cls = code_creators.mem_fun_transformed_t
    29                  fwrapper_cls = code_creators.mem_fun_transformed_wrapper_t
    30              else:
    31                  maker_cls = code_creators.mem_fun_t
    32          elif decl.virtuality == VIRTUALITY_TYPES.PURE_VIRTUAL:
    33              fwrapper_cls = code_creators.mem_fun_pv_wrapper_t
    34              maker_cls = code_creators.mem_fun_pv_t
    35          else:
    36              if decl.transformations:
    37                  fwrapper_cls = code_creators.mem_fun_v_transformed_wrapper_t
    38                  maker_cls = code_creators.mem_fun_v_transformed_t
    39              else:
    40                  if decl.overridable:
    41                      fwrapper_cls = code_creators.mem_fun_v_wrapper_t
    42                  maker_cls = code_creators.mem_fun_v_t
    43      elif access_level == ACCESS_TYPES.PROTECTED:
    44          if decl.virtuality == VIRTUALITY_TYPES.NOT_VIRTUAL:
    45              if decl.has_static:
    46                  fwrapper_cls = code_creators.mem_fun_protected_s_wrapper_t
    47                  maker_cls = code_creators.mem_fun_protected_s_t
    48              else:
    49                  fwrapper_cls = code_creators.mem_fun_protected_wrapper_t
    50                  maker_cls = code_creators.mem_fun_protected_t
    51          elif decl.virtuality == VIRTUALITY_TYPES.VIRTUAL:
    52              if decl.overridable:
    53                  fwrapper_cls = code_creators.mem_fun_protected_v_wrapper_t
    54                  maker_cls = code_creators.mem_fun_protected_v_t
    55          else:
    56              fwrapper_cls = code_creators.mem_fun_protected_pv_wrapper_t
    57              maker_cls = code_creators.mem_fun_protected_pv_t
    58      else: #private
    59          if decl.virtuality == VIRTUALITY_TYPES.NOT_VIRTUAL:
    60              pass#in general we should not come here
    61          elif decl.virtuality == VIRTUALITY_TYPES.PURE_VIRTUAL:
    62              fwrapper_cls = code_creators.mem_fun_private_pv_wrapper_t
    63          else:
    64              if decl.overridable:
    65                  fwrapper_cls = code_creators.mem_fun_v_wrapper_t
    66                  maker_cls = code_creators.mem_fun_v_t
    67      return ( maker_cls, fwrapper_cls )
    68