def AutoExclude( mb ):
    """ Automaticaly exclude a range of things that don't convert well from C++ to Python
    """
    global_ns = mb.global_ns
    for ns in NAMESPACES:
        main_ns = global_ns.namespace( ns )
    
        # vars that are static consts but have their values set in the header file are bad
        Remove_Static_Consts ( main_ns )
        
        ## Exclude protected and private that are not pure virtual
        query = declarations.access_type_matcher_t( 'private' ) \
                & ~declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL )
        try:
            non_public_non_pure_virtual = main_ns.calldefs( query )
            non_public_non_pure_virtual.exclude()
        except:
            pass
    
        #Virtual functions that return reference could not be overriden from Python
        query = declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.VIRTUAL ) \
                & declarations.custom_matcher_t( lambda decl: declarations.is_reference( decl.return_type ) )
        try:
            main_ns.calldefs( query ).virtuality = declarations.VIRTUALITY_TYPES.NOT_VIRTUAL
        except:
            pass
Exemple #2
0
def excludeAllPrivate(cls):
    cls.decls(declarations.matchers.access_type_matcher_t("private")).exclude()

    # include back pure virtual private functions
    query = declarations.matchers.access_type_matcher_t("private") \
            & declarations.virtuality_type_matcher_t(declarations.VIRTUALITY_TYPES.PURE_VIRTUAL)

    cls.mem_funs(query, allow_empty = True).include()
Exemple #3
0
def excludeAllPrivate(cls):
    cls.decls(declarations.matchers.access_type_matcher_t("private")).exclude()
    
    # include back pure virtual private functions
    query = declarations.matchers.access_type_matcher_t("private") \
            & declarations.virtuality_type_matcher_t(declarations.VIRTUALITY_TYPES.PURE_VIRTUAL)
    
    cls.mem_funs(query, allow_empty = True).include()
def filter_declarations( mb ):
    global_ns = mb.global_ns
    global_ns.exclude()
    ogrerefapp_ns = global_ns.namespace( 'OgreRefApp' )
    ogrerefapp_ns.include()
    
 
    ## Exclude protected and private that are not pure virtual
    query = ~declarations.access_type_matcher_t( 'public' ) \
            & ~declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL )
    non_public_non_pure_virtual = ogrerefapp_ns.calldefs( query )
    non_public_non_pure_virtual.exclude()
def AutoExclude( mb ):
    """ Automaticaly exclude a range of things that don't convert well from C++ to Python
    """
    global_ns = mb.global_ns
    main_ns = global_ns   # No namespaces in NxPhysics


    #Virtual functions that return reference could not be overriden from Python
    query = declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.VIRTUAL ) \
            & declarations.custom_matcher_t( lambda decl: declarations.is_reference( decl.return_type ) )
    try:
        main_ns.calldefs( query ).virtuality = declarations.VIRTUALITY_TYPES.NOT_VIRTUAL
    except:
        pass
def filter_declarations( mb ):	
    """ filter class declarations
    """
    global_ns = mb.global_ns
    global_ns.exclude()
    #global_ns.namespace('std').class_('pair<float, float>').include()
    
    MyGUI_ns = global_ns.namespace( 'MyGUI' )
    MyGUI_ns.include()
    
    global_ns.namespace( 'Ogre' ).class_('SharedPtr<Ogre::Resource>').include(already_exposed=True)
    global_ns.namespace( 'Ogre' ).class_('HardwarePixelBufferSharedPtr').include(already_exposed=True)
    
    global_ns.namespace( 'OIS' ).class_('KeyEvent').include(already_exposed=True)
    global_ns.namespace( 'OIS' ).class_('MouseEvent').include(already_exposed=True)	
	
    # Exclude protected and private that are not pure virtual
    query = declarations.access_type_matcher_t( 'private' ) \
            & ~declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL )
    MyGUI_ns.calldefs( query, allow_empty=True ).exclude()
Exemple #7
0
    def redefined_funcs( self ):
        """
        returns list of member functions that should be defined in the class wrapper

        It comes useful in 3 tier hierarchy:

        .. code-block:: c++

           struct base{
               virtual void do_nothing() = 0;
           };

           struct derived{
               virtual void do_something() = 0;
           };

           struct concrete{
               virtual void do_nothing(){}
               virtual void do_something(){}
           };

        The wrapper for class `derived`, should define `do_nothing` function,
        otherwise the generated code will not compile
        """

        if isinstance( self._redefined_funcs, list ):
            return self._redefined_funcs

        all_included = declarations.custom_matcher_t( lambda decl: decl.ignore == False and decl.exportable )
        all_protected = declarations.access_type_matcher_t( 'protected' ) & all_included
        all_pure_virtual = declarations.virtuality_type_matcher_t( VIRTUALITY_TYPES.PURE_VIRTUAL )
        all_virtual = declarations.virtuality_type_matcher_t( VIRTUALITY_TYPES.VIRTUAL ) \
                      & ( declarations.access_type_matcher_t( 'public' ) \
                          | declarations.access_type_matcher_t( 'protected' ))
        all_not_pure_virtual = ~all_pure_virtual

        query = all_protected | all_pure_virtual
        mf_query = query | all_virtual
        relevant_opers = declarations.custom_matcher_t( lambda decl: decl.symbol in ('()', '[]') )
        funcs = []
        defined_funcs = []

        for base in self.recursive_bases:
            if base.access == ACCESS_TYPES.PRIVATE:
                continue
            base_cls = base.related_class

            funcs.extend( base_cls.member_functions( mf_query, recursive=False, allow_empty=True ) )
            funcs.extend( base_cls.member_operators( relevant_opers & query, recursive=False, allow_empty=True ) )

            defined_funcs.extend( base_cls.member_functions( all_not_pure_virtual, recursive=False, allow_empty=True ) )
            defined_funcs.extend( base_cls.member_operators( all_not_pure_virtual & relevant_opers, recursive=False, allow_empty=True ) )

        not_reimplemented_funcs = set()
        is_same_function = declarations.is_same_function
        for f in funcs:
            cls_fs = self.calldefs( name=f.name, recursive=False, allow_empty=True )
            for cls_f in cls_fs:
                if is_same_function( f, cls_f ):
                    break
            else:
                #should test whether this function has been added or not
                for f_impl in not_reimplemented_funcs:
                    if is_same_function( f, f_impl ):
                        if declarations.is_base_and_derived( f_impl.parent, f.parent ):
                            #add function from the most derived class
                            not_reimplemented_funcs.remove( f_impl )
                            not_reimplemented_funcs.add( f )
                        break
                else:
                    #should test whether this function is implemented in base class
                    if f.virtuality != VIRTUALITY_TYPES.PURE_VIRTUAL:
                        not_reimplemented_funcs.add( f )
                    else:
                        for f_defined in defined_funcs:
                            if is_same_function( f, f_defined ):
                                break
                        else:
                            not_reimplemented_funcs.add( f )
        functions = [f for f in list( not_reimplemented_funcs ) if ( False == f.ignore and True == f.exportable )
                                      or all_pure_virtual( f )]


        #Boost.Python is not able to call for non-virtual function, from the base
        #class if there is a virtual function with the same within base class
        #See override_bug tester for more information

        def buggy_bpl_filter( f ):
            if f.parent is self:
                return False
            if f.access_type != ACCESS_TYPES.PUBLIC:
                return False
            if f.virtuality != VIRTUALITY_TYPES.NOT_VIRTUAL:
                return False
            #we need to check that we don't have "same" function in this class
            this_funs = self.decls( name=f.name
                                    , decl_type=declarations.calldef_t
                                    , recursive=False
                                    , allow_empty=True )
            for this_f in this_funs:
                if is_same_function( this_f, f ):
                    #there is already the function in the class, so no need to redefined it
                    return False
            else:
                return True

        tmp = {} # id : f
        for redefined_f in functions:
            #redefined is virtual, I am not interested in virtual functions
            for rfo in redefined_f.overloads:
                if id(rfo) in tmp:
                    continue
                if buggy_bpl_filter( rfo ):
                    tmp[ id(rfo) ] = rfo
        functions.extend( list(tmp.values()) )

        functions.sort( key=lambda f: ( f.name, f.location.as_tuple() ) )

        self._redefined_funcs = functions
        return self._redefined_funcs
    def redefined_funcs( self ):
        """returns list of member functions that should be defined in class wrapper

        It comes useful in 3 tier hierarchy:
        struct base{
            virtual void do_nothing() = 0;
        };

        struct derived{
            virtual void do_something() = 0;
        };

        struct concrete{
            virtual void do_nothing(){}
            virtual void do_something(){}
        };

        derived_wrapper should define do_nothing function, otherwise the generated
        code will not compile
        """

        if isinstance( self._redefined_funcs, list ):
            return self._redefined_funcs

        all_included = declarations.custom_matcher_t( lambda decl: decl.ignore == False and decl.exportable )
        all_protected = declarations.access_type_matcher_t( 'protected' ) & all_included
        all_pure_virtual = declarations.virtuality_type_matcher_t( VIRTUALITY_TYPES.PURE_VIRTUAL )
        all_not_pure_virtual = ~all_pure_virtual

        query = all_protected | all_pure_virtual
        relevant_opers = declarations.custom_matcher_t( lambda decl: decl.symbol in ('()', '[]') )
        funcs = set()
        defined_funcs = set()

        for base in self.recursive_bases:
            if base.access == ACCESS_TYPES.PRIVATE:
                continue
            base_cls = base.related_class
            funcs.update( base_cls.member_functions( query, recursive=False, allow_empty=True ) )
            funcs.update( base_cls.member_operators( relevant_opers & query, recursive=False, allow_empty=True ) )

            defined_funcs.update( base_cls.member_functions( all_not_pure_virtual, recursive=False, allow_empty=True ) )
            defined_funcs.update( base_cls.member_operators( all_not_pure_virtual & relevant_opers, recursive=False, allow_empty=True ) )

        not_reimplemented_funcs = set()
        is_same_function = declarations.is_same_function
        for f in funcs:
            cls_fs = self.calldefs( name=f.name, recursive=False, allow_empty=True )
            for cls_f in cls_fs:
                if is_same_function( f, cls_f ):
                    break
            else:
                #should test whether this function has been added or not
                for f_impl in not_reimplemented_funcs:
                    if is_same_function( f, f_impl ):
                        if declarations.is_base_and_derived( f_impl.parent, f.parent ):
                            #add function from the most derived class
                            not_reimplemented_funcs.remove( f_impl )
                            not_reimplemented_funcs.add( f )                       
                        break
                else:
                    #should test whether this function is implemented in base class
                    if f.virtuality != VIRTUALITY_TYPES.PURE_VIRTUAL:
                        not_reimplemented_funcs.add( f )
                    else:
                        for f_defined in defined_funcs:
                            if is_same_function( f, f_defined ):
                                break
                        else:
                            not_reimplemented_funcs.add( f )
        functions = list( not_reimplemented_funcs )
        functions.sort( cmp=lambda f1, f2: cmp( ( f1.name, f1.location.as_tuple() )
                                                , ( f2.name, f2.location.as_tuple() ) ) )
        self._redefined_funcs = functions
        return self._redefined_funcs
Exemple #9
0
    def filter_declarations(self, mb):
        mb.global_ns.exclude()
        mb.global_ns.namespace('pyplusplus', recursive=False).include()
        boost_ns = mb.global_ns.namespace('boost', recursive=False)
        boost_ns.namespace('posix_time', recursive=False).include()
        boost_ns.namespace('date_time', recursive=False).include()
        boost_ns.namespace('gregorian', recursive=False).include()
        boost_ns.namespace('local_time', recursive=False).include()
        boost_ns.classes(
            lambda decl: decl.name.startswith('constrained_value<')).include()
        ## Exclude protected and private that are not pure virtual
        query = ~declarations.access_type_matcher_t( 'public' ) \
            & ~declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL )
        non_public_non_pure_virtual = boost_ns.calldefs(query)
        non_public_non_pure_virtual.exclude()

        for name in ['month_str_to_ushort', 'from_stream_type', 'parse_date']:
            boost_ns.calldefs(
                lambda decl: decl.name.startswith(name)).exclude()

        to_be_removed = [
            'c_time',
            'duration_traits_long',
            'duration_traits_adapted',
            'posix_time_system_config'  #TODO find out link bug
            ,
            'millisec_posix_time_system_config'
        ]
        boost_ns.classes(lambda decl: decl.name in to_be_removed).exclude()

        starts_with = [
            'time_resolution_traits<', 'counted_time_rep<', 'date_facet<',
            'period_formatter<', 'date_generator_formatter<',
            'special_values_formatter<'
        ]
        for name in starts_with:
            boost_ns.classes(lambda decl: decl.name.startswith(name)).exclude()

        ends_with = ['_impl', '_config']
        for name in ends_with:
            boost_ns.classes(lambda decl: decl.name.endswith(name)).exclude()

        boost_ns.classes(
            lambda decl: decl.alias.endswith('formatter')).exclude()

        #boost.date_time has problem to create local_[micro]sec_clock
        #variable, it has nothing to do with Py++
        empty_classes = ['local_microsec_clock', 'local_sec_clock']
        for alias in empty_classes:
            class_ = boost_ns.class_(lambda decl: decl.alias == alias)
            class_.exclude()
            class_.ignore = False

        for alias in ['microsec_clock', 'second_clock']:
            class_ = boost_ns.class_(lambda decl: decl.alias == alias)
            class_.calldefs().create_with_signature = True

        tdi = mb.class_(lambda decl: decl.alias == 'time_duration_impl')
        tdi_init = tdi.constructor(arg_types=[None, None, None, None],
                                   recursive=False)
        tdi_init.ignore = True
        #next declarations are not exported, but Py++ writes warnings about them:
        boost_ns.operators('<<').exclude()
        boost_ns.operators('>>').exclude()
        boost_ns.operators('=').exclude()
        #next function uses non public class in its definition.
        microsec_clocks = boost_ns.classes(
            lambda decl: decl.name.startswith('microsec_clock<'))
        for mc in microsec_clocks:
            mc.member_functions('create_time').exclude()

        #TODO: add FT
        #next function takes reference to int. This function could not be called
        #from Python. Function transformation feature solves this problem
        tz_db_base = boost_ns.class_(
            lambda decl: decl.name.startswith('tz_db_base<'))
        tz_db_base.member_functions('split_rule_spec').exclude()
    def redefined_funcs(self):
        """
        returns list of member functions that should be defined in the class wrapper

        It comes useful in 3 tier hierarchy:

        .. code-block:: c++

           struct base{
               virtual void do_nothing() = 0;
           };

           struct derived{
               virtual void do_something() = 0;
           };

           struct concrete{
               virtual void do_nothing(){}
               virtual void do_something(){}
           };

        The wrapper for class `derived`, should define `do_nothing` function,
        otherwise the generated code will not compile
        """

        if isinstance(self._redefined_funcs, list):
            return self._redefined_funcs

        all_included = declarations.custom_matcher_t(
            lambda decl: decl.ignore == False and decl.exportable)
        all_protected = declarations.access_type_matcher_t(
            'protected') & all_included
        all_pure_virtual = declarations.virtuality_type_matcher_t(
            VIRTUALITY_TYPES.PURE_VIRTUAL)
        all_virtual = declarations.virtuality_type_matcher_t( VIRTUALITY_TYPES.VIRTUAL ) \
                      & ( declarations.access_type_matcher_t( 'public' ) \
                          | declarations.access_type_matcher_t( 'protected' ))
        all_not_pure_virtual = ~all_pure_virtual

        query = all_protected | all_pure_virtual
        mf_query = query | all_virtual
        relevant_opers = declarations.custom_matcher_t(
            lambda decl: decl.symbol in ('()', '[]'))
        funcs = []
        defined_funcs = []

        for base in self.recursive_bases:
            if base.access == ACCESS_TYPES.PRIVATE:
                continue
            base_cls = base.related_class

            funcs.extend(
                base_cls.member_functions(mf_query,
                                          recursive=False,
                                          allow_empty=True))
            funcs.extend(
                base_cls.member_operators(relevant_opers & query,
                                          recursive=False,
                                          allow_empty=True))

            defined_funcs.extend(
                base_cls.member_functions(all_not_pure_virtual,
                                          recursive=False,
                                          allow_empty=True))
            defined_funcs.extend(
                base_cls.member_operators(all_not_pure_virtual
                                          & relevant_opers,
                                          recursive=False,
                                          allow_empty=True))

        not_reimplemented_funcs = set()
        is_same_function = declarations.is_same_function
        for f in funcs:
            cls_fs = self.calldefs(name=f.name,
                                   recursive=False,
                                   allow_empty=True)
            for cls_f in cls_fs:
                if is_same_function(f, cls_f):
                    break
            else:
                #should test whether this function has been added or not
                for f_impl in not_reimplemented_funcs:
                    if is_same_function(f, f_impl):
                        if declarations.is_base_and_derived(
                                f_impl.parent, f.parent):
                            #add function from the most derived class
                            not_reimplemented_funcs.remove(f_impl)
                            not_reimplemented_funcs.add(f)
                        break
                else:
                    #should test whether this function is implemented in base class
                    if f.virtuality != VIRTUALITY_TYPES.PURE_VIRTUAL:
                        not_reimplemented_funcs.add(f)
                    else:
                        for f_defined in defined_funcs:
                            if is_same_function(f, f_defined):
                                break
                        else:
                            not_reimplemented_funcs.add(f)
        functions = filter(
            lambda f: (False == f.ignore and True == f.exportable) or
            all_pure_virtual(f), list(not_reimplemented_funcs))

        #Boost.Python is not able to call for non-virtual function, from the base
        #class if there is a virtual function with the same within base class
        #See override_bug tester for more information

        def buggy_bpl_filter(f):
            if f.parent is self:
                return False
            if f.access_type != ACCESS_TYPES.PUBLIC:
                return False
            if f.virtuality != VIRTUALITY_TYPES.NOT_VIRTUAL:
                return False
            #we need to check that we don't have "same" function in this class
            this_funs = self.decls(name=f.name,
                                   decl_type=declarations.calldef_t,
                                   recursive=False,
                                   allow_empty=True)
            for this_f in this_funs:
                if is_same_function(this_f, f):
                    #there is already the function in the class, so no need to redefined it
                    return False
            else:
                return True

        tmp = {}  # id : f
        for redefined_f in functions:
            #redefined is virtual, I am not interested in virtual functions
            for rfo in redefined_f.overloads:
                if id(rfo) in tmp:
                    continue
                if buggy_bpl_filter(rfo):
                    tmp[id(rfo)] = rfo
        functions.extend(tmp.values())

        functions.sort(cmp=lambda f1, f2: cmp((f1.name, f1.location.as_tuple(
        )), (f2.name, f2.location.as_tuple())))

        self._redefined_funcs = functions
        return self._redefined_funcs
def filter_declarations( mb ):
    global_ns = mb.global_ns
    global_ns.exclude()
    
    ogrenewt_ns = global_ns.namespace( 'BasicJoints' )
    ogrenewt_ns.include()
    ogrenewt_ns = global_ns.namespace( 'PrebuiltCustomJoints' )
    ogrenewt_ns.include()
    ogrenewt_ns = global_ns.namespace( 'CollisionPrimitives' )
    ogrenewt_ns.include()
    
    temp_ns = global_ns.namespace( 'Converters' )
    temp_ns.include()
    temp_ns = global_ns.namespace( 'CollisionTools' )
    temp_ns.include()
    temp_ns = global_ns.namespace( 'MomentOfInertia' )
    temp_ns.include()
    
    
    ogrenewt_ns = global_ns.namespace( 'OgreNewt' )
    ogrenewt_ns.include()
    
    ## these need to be excluded due to callback functions - Have been wrapped 
    ogrenewt_ns.class_( "World" ).member_functions("setLeaveWorldCallback").exclude()
    
    
    ogrenewt_ns.class_( "Body" ).member_functions("addBouyancyForce").exclude()
    
    ogrenewt_ns.class_( "Body" ).member_functions("setAutoactiveCallback").exclude()
    ogrenewt_ns.class_( "Body" ).member_functions("setCustomForceAndTorqueCallback").exclude()
    ogrenewt_ns.class_( "Body" ).member_functions("setCustomTransformCallback").exclude()

    ogrenewt_ns.class_( "BodyIterator" ).member_functions("go").exclude()
    global_ns.namespace( 'BasicJoints' ).class_( "Hinge" ).member_functions("setCallback").exclude()
    global_ns.namespace( 'BasicJoints' ).class_( "Slider" ).member_functions("setCallback").exclude()
    global_ns.namespace( 'BasicJoints' ).class_( "Universal" ).member_functions("setCallback").exclude()
    
        
    ## Replaced these with 'useful' functions in the handwrappers - take and return python objects
    ogrenewt_ns.class_( "Body" ).member_functions("setUserData").exclude()
    ogrenewt_ns.class_( "Joint" ).member_functions("setUserData").exclude()
    ogrenewt_ns.class_( "Body" ).member_functions("getUserData").exclude()
    ogrenewt_ns.class_( "Joint" ).member_functions("getUserData").exclude()
    
    ## This one needs a list of vertices given to it
    ogrenewt_ns.class_( "TreeCollision" ).member_functions("addPoly").exclude()
    
     
    # ConvexHull has an overloaded constructor that takes 5 args, one is a pointer to a list of vectors which we can't
    # handle, so we created a helper function caller createConvexHull that takes a python list instead.
    mb.global_ns.namespace ('OgreNewt').class_('ConvexHull').constructor(arg_types=[None,None,None,None,None]).exclude()
       
    ### and we need the free functions 
    for func in ogrenewt_ns.free_functions ():
        ## print "FREE Func:", func.name
        func.include()
            
    ## Exclude protected and private that are not pure virtual
    query = declarations.access_type_matcher_t( 'private' ) \
            & ~declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL )
    ogrenewt_ns.calldefs( query, allow_empty=True ).exclude()
    
    
    
    ## Some varibles that we really do need and aren't exposed by default..    
    cls = ogrenewt_ns.class_("ContactCallback")
    cls.variable('m_body0').include()
    cls.variable('m_body1').include()
    cls.variable('m_contact').include()
    cls.variable('m_material').include()
    
    global_ns.namespace( 'Ogre' ).class_('AxisAlignedBox').include(already_exposed=True)
    global_ns.namespace( 'Ogre' ).class_('Radian').include(already_exposed=True)
    global_ns.namespace( 'Ogre' ).class_('SceneNode').include(already_exposed=True)
    global_ns.namespace( 'Ogre' ).class_('IndexData').include(already_exposed=True)
    global_ns.namespace( 'Ogre' ).class_('SceneManager').include(already_exposed=True)
    global_ns.namespace( 'Ogre' ).class_('Vector3').include(already_exposed=True)
    global_ns.namespace( 'Ogre' ).class_('Matrix4').include(already_exposed=True)
    global_ns.namespace( 'Ogre' ).class_('Degree').include(already_exposed=True)
    global_ns.namespace( 'Ogre' ).class_('Quaternion').include(already_exposed=True)
    global_ns.namespace( 'Ogre' ).class_('Node').include(already_exposed=True)
    global_ns.namespace( 'Ogre' ).class_('Serializer').include(already_exposed=True)
Exemple #12
0
    def filter_declarations(self, mb):
        mb.global_ns.exclude()
        mb.global_ns.namespace("pyplusplus", recursive=False).include()
        boost_ns = mb.global_ns.namespace("boost", recursive=False)
        boost_ns.namespace("posix_time", recursive=False).include()
        boost_ns.namespace("date_time", recursive=False).include()
        boost_ns.namespace("gregorian", recursive=False).include()
        boost_ns.namespace("local_time", recursive=False).include()
        boost_ns.classes(lambda decl: decl.name.startswith("constrained_value<")).include()
        ## Exclude protected and private that are not pure virtual
        query = ~declarations.access_type_matcher_t("public") & ~declarations.virtuality_type_matcher_t(
            declarations.VIRTUALITY_TYPES.PURE_VIRTUAL
        )
        non_public_non_pure_virtual = boost_ns.calldefs(query)
        non_public_non_pure_virtual.exclude()

        for name in ["month_str_to_ushort", "from_stream_type", "parse_date"]:
            boost_ns.calldefs(lambda decl: decl.name.startswith(name)).exclude()

        to_be_removed = [
            "c_time",
            "duration_traits_long",
            "duration_traits_adapted",
            "posix_time_system_config",  # TODO find out link bug
            "millisec_posix_time_system_config",
        ]
        boost_ns.classes(lambda decl: decl.name in to_be_removed).exclude()

        starts_with = [
            "time_resolution_traits<",
            "counted_time_rep<",
            "date_facet<",
            "period_formatter<",
            "date_generator_formatter<",
            "special_values_formatter<",
        ]
        for name in starts_with:
            boost_ns.classes(lambda decl: decl.name.startswith(name)).exclude()

        ends_with = ["_impl", "_config"]
        for name in ends_with:
            boost_ns.classes(lambda decl: decl.name.endswith(name)).exclude()

        boost_ns.classes(lambda decl: decl.alias.endswith("formatter")).exclude()

        # boost.date_time has problem to create local_[micro]sec_clock
        # variable, it has nothing to do with Py++
        empty_classes = ["local_microsec_clock", "local_sec_clock"]
        for alias in empty_classes:
            class_ = boost_ns.class_(lambda decl: decl.alias == alias)
            class_.exclude()
            class_.ignore = False

        for alias in ["microsec_clock", "second_clock"]:
            class_ = boost_ns.class_(lambda decl: decl.alias == alias)
            class_.calldefs().create_with_signature = True

        tdi = mb.class_(lambda decl: decl.alias == "time_duration_impl")
        tdi_init = tdi.constructor(arg_types=[None, None, None, None], recursive=False)
        tdi_init.ignore = True
        # next declarations are not exported, but Py++ writes warnings about them:
        boost_ns.operators("<<").exclude()
        boost_ns.operators(">>").exclude()
        boost_ns.operators("=").exclude()
        # next function uses non public class in its definition.
        microsec_clocks = boost_ns.classes(lambda decl: decl.name.startswith("microsec_clock<"))
        for mc in microsec_clocks:
            mc.member_functions("create_time").exclude()

        # TODO: add FT
        # next function takes reference to int. This function could not be called
        # from Python. Function transformation feature solves this problem
        tz_db_base = boost_ns.class_(lambda decl: decl.name.startswith("tz_db_base<"))
        tz_db_base.member_functions("split_rule_spec").exclude()
def filter_declarations( mb ):
    global_ns = mb.global_ns
    global_ns.exclude()
    
  
    ode_ns = global_ns  ##  Ode doesn't have it's own namespace..  .namespace( 'ode' )
    for cls in ode_ns.classes():
# #         print "Checking ", cls.decl_string
        try:
            if  cls.decl_string[2]=='d' and cls.decl_string[3].isupper():
# #                 print "Including Class:", cls.name
                cls.include()
        except:
            pass
    ## and the dxXXclasses        
    for cls in ode_ns.classes():
# #         print "Checking ", cls.decl_string
        if  cls.decl_string[2:4]=='dx' and cls.decl_string[4].isupper():
# #             print "Including dxClass:", cls.name
            cls.include()
     ## and we'll need the free functions as well
    for funcs in ode_ns.free_functions ():
# #         print "FREE Func:", funcs.name
        if funcs.name[0]=='d' and funcs.name[1].isupper():
# #             print "Including Function", funcs.name
            funcs.include()
            
    for var in ode_ns.variables ():
# #         print "Checking Variable:", var.name
        if len(var.name) > 2:
            if var.name[0]=='d' and var.name[1].isupper():
# #                 print "Including variable", var.name
                var.include()
    for var in ode_ns.typedefs ():
# #         print "Checking typedef:", var.name
        if len(var.name) > 2:
            if var.name[0]=='d' and var.name[1].isupper():
# #                 print "Including typedef", var.name
                var.include()                
#         print "Member Func:", funcs.name
#         if funcs.name[0]=='d':
#             print "Including Member Function", funcs.name
#             funcs.include()

## these either don't exist in the source or have strange arguments
    ignore=(  "dGeomGetBodyNext", "dGeomMoved", "dPrintMatrix",
        "dWorldGetAutoDisableAngularAverageThreshold",
        "dWorldGetAutoDisableLinearAverageThreshold", 
        "dWorldSetAutoDisableAngularAverageThreshold",
        "dWorldSetAutoDisableLinearAverageThreshold" ,
        "dJointAddPUTorque",
        "dGeomTriMeshGetTriangle"
        )
    for cls in ignore:
        try:
            ode_ns.free_function(cls).exclude()
        except:
            pass
       
    # #     
    # in hand wrappers to handle pyobjects...
    ode_ns.class_( "dGeom" ).member_functions( "getData").exclude()
    ode_ns.class_( "dGeom" ).member_functions( "setData").exclude()
    ode_ns.class_( "dBody" ).member_functions( "setData").exclude()
    ode_ns.class_( "dBody" ).member_functions( "getData").exclude()
    
    ode_ns.class_( "dSpace" ).member_functions( "collide").exclude()
    ode_ns.class_( "dFixedJoint" ).member_functions( "create").exclude()

    ## Exclude protected and private that are not pure virtual
    ### need to be careful here as it removes free functions
    query = ( declarations.access_type_matcher_t( 'private' ) | declarations.access_type_matcher_t( 'protected' ) )\
            & ~declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL )
    non_public_non_pure_virtual = ode_ns.calldefs( query )
# #     print "TO EXCLUDE:", non_public_non_pure_virtual
    non_public_non_pure_virtual.exclude()
    
    #For some reason Py++ does not honor call policies in this case.
    #You will have to expose them by hand
    dContactGeom = ode_ns.class_( 'dContactGeom' )
    g12 = dContactGeom.variables( lambda d: d.name in ('g1', 'g2' ) )
    g12.exclude()
    #g12.getter_call_policies = call_policies.return_value_policy( call_policies.return_opaque_pointer )

    ode_ns.class_( 'dBox' ).noncopyable = True
    ode_ns.class_( 'dCapsule' ).noncopyable = True
    ode_ns.class_( 'dGeom' ).noncopyable = True
    ode_ns.class_( 'dGeomTransform' ).noncopyable = True
    ode_ns.class_( 'dPlane' ).noncopyable = True
    ode_ns.class_( 'dQuadTreeSpace' ).noncopyable = True
    ode_ns.class_( 'dRay' ).noncopyable = True
    ode_ns.class_( 'dSphere' ).noncopyable = True
def filter_declarations( mb ):
    global_ns = mb.global_ns
    global_ns.exclude()
    global_ns.namespace('std').class_('pair<float, float>').include()
    
    CEGUI_ns = global_ns.namespace( 'CEGUI' )
    CEGUI_ns.include()
    
    ## not available at link time.. 
    CEGUI_ns.free_functions("lbi_greater").exclude()
    CEGUI_ns.free_functions("lbi_less").exclude()
    
    ## Dumb fix to remove all Properties classes -  unfortunately the properties in these classes are indicated as public
    ## however within their 'parent' class they are defined as private..
    ## see MultiLineEditboxProperties
    ##
    for cls in mb.global_ns.namespace ('CEGUI').classes():
        if "Properties" in cls.decl_string:
            print "Excluding:", cls.name
            cls.exclude()
          
                   
    ## EventNamespace causes failure when loading the python module
    ## possibly because of the ugly Properties fix above :) 
    for cls in mb.global_ns.namespace ('CEGUI').classes():
        try:
            cls.variable('EventNamespace').exclude()
        except:
            pass
    ## turns out that in SOME classes this also fails registration (Combodroplist for example)
    for cls in mb.global_ns.namespace ('CEGUI').classes():
        try:
            cls.variable('WidgetTypeName').exclude()
        except:
            pass
    ## fix due to new gccxml        
    try:
        global_ns.member_function('::CEGUI::ListboxItem::setSelectionColours', arg_types=['__restrict__ ::CEGUI::colour &']).exclude()
        global_ns.member_function('::CEGUI::ListboxTextItem::setTextColours', arg_types=['__restrict__ ::CEGUI::colour &']).exclude()
    except:
        pass       

    ## Exclude protected and private that are not pure virtual
    query = declarations.access_type_matcher_t( 'private' ) \
            & ~declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL )
    CEGUI_ns.calldefs( query, allow_empty=True ).exclude()
    
    ## lets work around a bug in GCCXMl - http://language-binding.net/pygccxml/design.html#patchers
    draws = mb.member_functions( 'draw' )   # find all the draw functions
    for draw in draws:
        for arg in draw.arguments:  
            if arg.default_value == '0ffffffff':
                arg.default_value = '0xffffffff'

         
    ## class to exclude
    excludes=['::CEGUI::FactoryModule',
            '::CEGUI::ScriptFunctor',
            '::CEGUI::CEGUIRQListener',
            '::CEGUI::RefCounted< CEGUI::FormattedRenderedString >' # not in the debug version
            ]
    for e in excludes:
        try:
            CEGUI_ns.class_( e ).exclude()     
        except:
            print "FAILED to exclude:", e
    ## now have functions in String that return uint arrays a need to be wrapped
    sc = CEGUI_ns.class_( "String" )
    sc.member_functions('data').exclude()
    sc.member_functions('ptr').exclude()
    
    ## and only remove the at functions that are not returning constants
    ## the const version returns by value which is good, the non const returns a reference which doesn't compile
    sc.member_function( 'at', lambda decl: decl.has_const == False ).exclude()
    
    ## CEGUI::WindowManager::loadWindowLayout can take a function pointer as an agrument whcih isn't supported yet
    ## so lets remove the versions that expose the pointer 
    lo = CEGUI_ns.class_( 'WindowManager' ).member_function( 'loadWindowLayout', arg_types=[None, None, None, None, None] )
    lo.arguments[3].type = lo.arguments[4].type     #AJM Not sure how args work so setting the func pointer to a void pointer
    
    ## OgreCEGUIRenderer.h has an assumed namespace in one of the default agrs that we need to fix
    try:
        orRe = CEGUI_ns.constructor('OgreCEGUIRenderer', arg_types=[None, None, None, None] )
        pos = orRe.arguments[1].default_value.index("RENDER_QUEUE_OVERLAY")
        tempstring = orRe.arguments[1].default_value[:pos]+"::Ogre::"+orRe.arguments[1].default_value[pos:]
        orRe.arguments[1].default_value = tempstring
    except:
        pass
    # try to force this one..
    ## a string one that stops pydoc working against CEGUI
    CEGUI_ns.class_('ListHeader').variable('SegmentNameSuffix').exclude()
    #Exclude non default constructors of iterator classes. 
    for cls in CEGUI_ns.classes():
       if not declarations.templates.is_instantiation( cls.name ):
           continue
       name = declarations.templates.name( cls.name )
       if not name.endswith( 'Iterator' ):
           continue
       #default constructor does not have arguments
       constructors = cls.constructors( lambda decl: bool( decl.arguments )
                                                      , allow_empty=True
                                                      , recursive=False )
       constructors.exclude()

#     ## I'm going to exclude all iterators as there is a problem with CEGUIIteratorBase.h
    for cls in CEGUI_ns.classes():
# #         print "checking", cls.name
        if 'iterator' in cls.name.lower() :
            cls.exclude()
            print "Excluding Iterator", cls.name
            
    try:  # this is in the newer version of cegui so I'm OK if it fails     
        CEGUI_ns.class_('OgreCEGUIResourceProvider').exclude() # it's _ogrePrivate..
    except:
        pass
    ## Replaced these with 'useful' functions in the handwrappers - take and return python objects
    CEGUI_ns.class_( "Window" ).member_functions("setUserData").exclude()
    CEGUI_ns.class_( "Window" ).member_functions("getUserData").exclude()

    # Py++ doesn't know that this should be noncopyable so we set it here  
    nocopy=['EventSet','GlobalEventSet','MouseCursor','OgreCEGUIRenderer','CEGUIOgreRenderer',
            ]
    for c in nocopy:
        try:
            CEGUI_ns.class_(c).noncopyable = True
        except:
            pass
    for c in CEGUI_ns.classes():
        if c.name.endswith ("Exception"):
            c.noncopyable=True
    # changes to latest py++ can gccxml etc June 15 2008
    excludes = ['::CEGUI::ItemListBase::getSortCallback',
                '::CEGUI::OgreRenderer::createOgreImageCodec',
                '::CEGUI::RefCounted<CEGUI::FormattedRenderedString>::isValid']
    for f in excludes:
        try:
            CEGUI_ns.member_function(f).exclude()
        except:
            print "Couldn't exclude :",f
        
    CEGUI_ns.class_('RawDataContainer').exclude() # has pointers that need to be handled -- hopefully not needed    
    
    CEGUI_ns.member_function("::CEGUI::WindowManager::loadWindowLayout", arg_types=[None,None,None,None,None]).exclude()   
    
    
    
    global_ns.namespace( 'Ogre' ).class_('SceneManager').include(already_exposed=True)
    global_ns.namespace( 'Ogre' ).class_('RenderWindow').include(already_exposed=True)
    global_ns.namespace( 'Ogre' ).class_('TexturePtr').include(already_exposed=True)

    if environment.isLinux():
        for c in CEGUI_ns.classes():
            if c.name.endswith ('Exception') and c.name != 'Exception' :
                c.exclude()
                print "Excluded:", c

        e = ['::CEGUI::OgreRenderer::destroyOgreImageCodec',
        #     '::CEGUI::FileIOException',
            ]
        for c in e:
            global_ns.member_functions(c).exclude()
            
    cls = CEGUI_ns.class_('::CEGUI::RefCounted< CEGUI::BoundSlot >')
    cls.operator('==').exclude() # not in debug build