def __find_out_class_dependencies( self, class_ ):
        full_name = declarations.full_name
        #class depends on it's base classes
        i_depend_on_them = set( [ full_name( base.related_class ) for base in class_.bases ] )
        #class depends on all classes that used in function as argument
        # types and those arguments have default value
        calldefs = filter( lambda decl: isinstance( decl, declarations.calldef_t )
                           , declarations.make_flatten( class_ ))
        for calldef in calldefs:
            for arg in calldef.arguments:
                if declarations.is_enum( arg.type ):
                    top_class_inst = self.__get_top_class_inst( declarations.enum_declaration( arg.type ) )
                    if top_class_inst:
                        i_depend_on_them.add( full_name( top_class_inst ) )
                    continue
                if not arg.default_value:
                    continue
                if declarations.is_pointer( arg.type ) and arg.default_value == 0:
                    continue
                base_type = declarations.base_type( arg.type )
                if not isinstance( base_type, declarations.declarated_t ):
                    continue
                top_class_inst = self.__get_top_class_inst( base_type.declaration )
                if top_class_inst:
                    i_depend_on_them.add( full_name( top_class_inst ) )

        for internal_cls in class_.classes(allow_empty=True):
            internal_cls_dependencies = self.__find_out_class_dependencies( internal_cls )
            i_depend_on_them.update( internal_cls_dependencies )

        i_depend_on_them = list( i_depend_on_them )
        i_depend_on_them.sort()
        return i_depend_on_them
Exemple #2
0
 def __is_unqualified_enum(self, func, arg):
     type_ = declarations.remove_reference(declarations.remove_cv(arg.type))
     if not declarations.is_enum(type_):
         return False
     enum_type = declarations.enum_declaration(type_)
     # GCCXML does not qualify an enum value in the default argument
     # but CastXML does. Split the default value and use only the
     # enum value for fixing it.
     return enum_type.has_value_name(arg.default_value.split('::')[-1])
Exemple #3
0
 def __fix_unqualified_enum(self, func, arg):
     type_ = declarations.remove_reference(declarations.remove_cv(arg.type))
     enum_type = declarations.enum_declaration(type_)
     if self.__cxx_std.is_cxx11_or_greater:
         qualifier_decl_string = enum_type.decl_string
     else:
         qualifier_decl_string = enum_type.parent.decl_string
     return self.__join_names(qualifier_decl_string,
                              arg.default_value.split('::')[-1])
Exemple #4
0
    def __find_out_class_dependencies(self, class_):
        full_name = declarations.full_name
        #class depends on it's base classes
        i_depend_on_them = set(
            [full_name(base.related_class) for base in class_.bases])
        #class depends on all classes that used in function as argument
        # types and those arguments have default value
        calldefs = [
            decl for decl in declarations.make_flatten(class_)
            if isinstance(decl, declarations.calldef_t)
        ]
        for calldef in calldefs:
            for arg in calldef.arguments:
                if declarations.is_enum(arg.type):
                    top_class_inst = self.__get_top_class_inst(
                        declarations.enum_declaration(arg.type))
                    if top_class_inst:
                        i_depend_on_them.add(full_name(top_class_inst))
                    continue
                if not arg.default_value:
                    continue
                if declarations.is_pointer(
                        arg.type) and arg.default_value == 0:
                    continue
                base_type = declarations.base_type(arg.type)
                if not isinstance(base_type, declarations.declarated_t):
                    continue
                top_class_inst = self.__get_top_class_inst(
                    base_type.declaration)
                if top_class_inst:
                    i_depend_on_them.add(full_name(top_class_inst))

        if self.__include_vars:
            vars = [
                decl for decl in declarations.make_flatten(class_)
                if isinstance(decl, declarations.variable_t)
            ]
            for var in vars:
                if declarations.is_pointer(var.type):
                    continue
                base_type = declarations.base_type(var.type)
                if not isinstance(base_type, declarations.declarated_t):
                    continue
                top_class_inst = self.__get_top_class_inst(
                    base_type.declaration)
                if top_class_inst:
                    i_depend_on_them.add(full_name(top_class_inst))

        for internal_cls in class_.classes(allow_empty=True):
            internal_cls_dependencies = self.__find_out_class_dependencies(
                internal_cls)
            i_depend_on_them.update(internal_cls_dependencies)

        i_depend_on_them = list(i_depend_on_them)
        i_depend_on_them.sort()
        return i_depend_on_them
Exemple #5
0
 def __fix_unqualified_enum(self, func, arg):
     type_ = declarations.remove_reference(declarations.remove_cv(arg.type))
     enum_type = declarations.enum_declaration(type_)
     if self.__cxx_std.is_cxx11_or_greater:
         qualifier_decl_string = enum_type.decl_string
     else:
         qualifier_decl_string = enum_type.parent.decl_string
     return self.__join_names(
         qualifier_decl_string,
         arg.default_value.split('::')[-1])
Exemple #6
0
 def __is_unqualified_enum(self, func, arg):
     type_ = declarations.remove_reference(declarations.remove_cv(arg.type))
     if not declarations.is_enum(type_):
         return False
     enum_type = declarations.enum_declaration(type_)
     # GCCXML does not qualify an enum value in the default argument
     # but CastXML does. Split the default value and use only the
     # enum value for fixing it.
     return enum_type.has_value_name(
         arg.default_value.split('::')[-1])
Exemple #7
0
def customize_module( mb ):   
    extmodule = mb.code_creator
    extmodule.license = customization_data.license

    # Insert a custom init call
    extmodule.adopt_creator( code_creators.custom_text_t('extern void InitialiseTnFOXPython();\n\n'), len(extmodule.creators)-1)
    extmodule.body.adopt_creator( code_creators.custom_text_t('    InitialiseTnFOXPython();\n\n'), 0)

    # Remove all standard headers in favour of precompiled header
    includes = filter( lambda creator: isinstance( creator, code_creators.include_t )
                        , extmodule.creators )
    map( lambda creator: extmodule.remove_creator( creator ), includes )
    position = extmodule.last_include_index() + 1
    extmodule.adopt_creator( code_creators.namespace_using_t('::FX'), position )
    extmodule.user_defined_directories.append( settings.generated_files_dir )
    extmodule.adopt_include( code_creators.include_t( header='../common.h' ) )    
    extmodule.precompiled_header = '../common.h'
    extmodule.adopt_include( code_creators.include_t( header='../patches.cpp.h' ) )    

    # Fix bug in gccxml where default args with function as value gain an extra ()
    try:
        constr = mb.constructor( 'FXPrimaryButton', arg_types=[None]*15 )
        constr.arguments[10].default_value = '(FX::FXWindow::defaultPadding() * 4)'
        constr.arguments[11].default_value = '(FX::FXWindow::defaultPadding() * 4)'
    except: pass

    # Patch default args with enums to be number (to avoid undeclared enum problem)
    def args_declaration_wa( self ):
        args = []
        for index, arg in enumerate( self.declaration.arguments ):
            result = arg.type.decl_string + ' ' + self.argument_name(index)
            if arg.default_value:
                result += '=%s' % arg.wrapper_default_value
            args.append( result )
        if len( args ) == 1:
            return args[ 0 ]
        return ', '.join( args )

    code_creators.calldef.calldef_wrapper_t.args_declaration = args_declaration_wa 

    allfuncs = mb.calldefs()
    for func in allfuncs:
        #print type(func), type(func.parent), func
        for arg in func.arguments:
            if not arg.default_value:
                continue
            arg.wrapper_default_value = arg.default_value
            if not declarations.is_enum( arg.type ):
                continue
            enum_ = declarations.enum_declaration( arg.type )
            if isinstance( enum_.parent, declarations.namespace_t ):
                continue #global enum
            # Be lazy, and just lookup the last part
            value = arg.default_value[ arg.default_value.rfind('::')+2: ]
            arg.default_value = arg.type.declaration.values[ value ] + '/*' + arg.default_value + '*/'
Exemple #8
0
 def __should_use_enum_wa(self, arg):
     global use_enum_workaround
     if not declarations.is_enum(arg.type):
         return False
     if use_enum_workaround:
         return True
     #enum belongs to the class we are working on
     if self.__decl.parent is declarations.enum_declaration( arg.type ).parent \
        and isinstance( self.__decl, declarations.constructor_t ):
         return True
     return False
Exemple #9
0
 def __should_use_enum_wa( self, arg ):
     global use_enum_workaround
     if not declarations.is_enum( arg.type ):
         return False
     if use_enum_workaround:
         return True
     #enum belongs to the class we are working on
     if self.__decl.parent is declarations.enum_declaration( arg.type ).parent \
        and isinstance( self.__decl, declarations.constructor_t ):
         return True
     return False
Exemple #10
0
 def __fix_unqualified_enum( self, func, arg):
     type_ = declarations.remove_reference( declarations.remove_cv( arg.type ) )
     enum_type = declarations.enum_declaration( type_ )
     return self.__join_names( enum_type.parent.decl_string, arg.default_value )
Exemple #11
0
 def __is_unqualified_enum(self, func, arg):
     type_ = declarations.remove_reference( declarations.remove_cv( arg.type ) )
     if not declarations.is_enum( type_ ):
         return False
     enum_type = declarations.enum_declaration( type_ )
     return enum_type.has_value_name( arg.default_value )
Exemple #12
0
 def __fix_unqualified_enum( self, func, arg):
     type_ = declarations.remove_reference( declarations.remove_cv( arg.type ) )
     enum_type = declarations.enum_declaration( type_ )
     return self.__join_names( enum_type.parent.decl_string, arg.default_value )
Exemple #13
0
 def __is_unqualified_enum(self, func, arg):
     type_ = declarations.remove_reference( declarations.remove_cv( arg.type ) )        
     if not declarations.is_enum( type_ ):
         return False
     enum_type = declarations.enum_declaration( type_ )
     return enum_type.has_value_name( arg.default_value )