def __test_ref_x__to__y(self, source, target): if not is_reference( source ): return False if is_fundamental( source.base ) and is_fundamental( target ): return True if is_convertible( source.base, cpptypes.int_t() ) and is_enum( target ): return True if isinstance( target, cpptypes.declarated_t ): assert isinstance( target.declaration, class_declaration.class_t ) if has_copy_constructor( target.declaration ): return True #we have copy constructor return False
def is_integral( type ): """returns True, if type represents C++ integral type, False otherwise""" integral_def = create_cv_types( cpptypes.char_t() ) \ + create_cv_types( cpptypes.unsigned_char_t() ) \ + create_cv_types( cpptypes.signed_char_t() ) \ + create_cv_types( cpptypes.wchar_t() ) \ + create_cv_types( cpptypes.short_int_t() ) \ + create_cv_types( cpptypes.short_unsigned_int_t() ) \ + create_cv_types( cpptypes.bool_t() ) \ + create_cv_types( cpptypes.int_t() ) \ + create_cv_types( cpptypes.unsigned_int_t() ) \ + create_cv_types( cpptypes.long_int_t() ) \ + create_cv_types( cpptypes.long_unsigned_int_t() ) \ + create_cv_types( cpptypes.long_long_int_t() ) \ + create_cv_types( cpptypes.long_long_unsigned_int_t() ) return remove_alias( type ) in integral_def
def is_integral(type): """returns True, if type represents C++ integral type, False otherwise""" integral_def = create_cv_types( cpptypes.char_t() ) \ + create_cv_types( cpptypes.unsigned_char_t() ) \ + create_cv_types( cpptypes.signed_char_t() ) \ + create_cv_types( cpptypes.wchar_t() ) \ + create_cv_types( cpptypes.short_int_t() ) \ + create_cv_types( cpptypes.short_unsigned_int_t() ) \ + create_cv_types( cpptypes.bool_t() ) \ + create_cv_types( cpptypes.int_t() ) \ + create_cv_types( cpptypes.unsigned_int_t() ) \ + create_cv_types( cpptypes.long_int_t() ) \ + create_cv_types( cpptypes.long_unsigned_int_t() ) \ + create_cv_types( cpptypes.long_long_int_t() ) \ + create_cv_types( cpptypes.long_long_unsigned_int_t() ) return remove_alias(type) in integral_def