Beispiel #1
0
 def keep_cls(self, c):
     """ 
        The filter to keep a class/struct or an enum : 
         if we a namespace list, it must be in it. 
         if we have an explicit self.classes : c must be into it
         if target_file_only it has to be in the file given to c++2py
     """
     if CL.is_template(c) or ("ignore_in_python" in CL.get_annotations(c)): return False
     if self.namespaces:
         qualified_ns = CL.get_namespace(c)
         if not any((x in qualified_ns) for x in self.namespaces) : return False
     if self.classes: 
         return c.spelling in self.classes or CL.fully_qualified(c) in self.classes
     return (c.location.file.name == self.filename) if self.target_file_only else True
Beispiel #2
0
    def get_public_methods(self, c):
        """
        Parameters
        -----------

        c:  AST node
            a cursor to a class
        
        Returns
        --------
        A list of cursors to the methods
        return : a tuple (proplist, methodlist) where proplist : a list of property_  and methodlist : the others methods
        """
        keep = lambda m : CL.is_public(m) and not CL.is_template(m) and not ("ignore_in_python" in CL.get_annotations(m)) and not m.spelling.startswith('operator')
        return CL.get_methods(c, True, keep)
Beispiel #3
0
 def keep_cls(self, c):
     """ 
        The filter to keep a class/struct or an enum : 
         if we a namespace list, it must be in it. 
         if we have an explicit self.classes : c must be into it
         else it has to be in the file given to c++2py 
     """
     if CL.is_template(c) or ("ignore_in_python" in CL.get_annotations(c)):
         return False
     if self.namespaces:
         ns = CL.get_namespace(c)
         if not any((x in ns) for x in self.namespaces): return False
     if self.classes:
         return c.spelling in self.classes or CL.fully_qualified(
             c) in self.classes
     return c.location.file.name == self.filename
Beispiel #4
0
    def get_public_methods(self, c):
        """
        Parameters
        -----------

        c:  AST node
            a cursor to a class
        
        Returns
        --------
        A list of cursors to the methods
        return : a tuple (proplist, methodlist) where proplist : a list of property_  and methodlist : the others methods
        """
        keep = lambda m: CL.is_public(m) and not CL.is_template(
            m) and not ("ignore_in_python" in CL.get_annotations(m)
                        ) and not m.spelling.startswith('operator')
        return CL.get_methods(c, True, keep)
Beispiel #5
0
    def get_all_params_ret_type(self, param_cls_list):
        """Yields every parameters and return type of every methods and functions"""
       
        for f in self.all_functions_gen():
            yield getattr(f, 'result_type', None)
            for p in CL.get_params(f) : 
                yield p.type

        for x in itertools.chain(param_cls_list, self.all_classes_gen()): 
            for m in CL.get_members(x, False): # False : no inherited
                yield m.type
            for m in itertools.chain(CL.get_constructors(x), CL.get_methods(x)):
                # A minimal filter, do not reuse self.keep_fnt here, because the namespace is N1::N2:...::ClassName
                if CL.is_template(m) or ("ignore_in_python" in CL.get_annotations(m)): continue
                yield getattr(m, 'result_type', None)
                for p in CL.get_params(m) : 
                    yield p.type
Beispiel #6
0
    def get_all_params_ret_type(self, param_cls_list):
        """Yields every parameters and return type of every methods and functions"""

        for f in self.all_functions_gen():
            yield getattr(f, 'result_type', None)
            for p in CL.get_params(f):
                yield p.type

        for x in itertools.chain(param_cls_list, self.all_classes_gen()):
            for m in CL.get_members(x, False):  # False : no inherited
                yield m.type
            for m in itertools.chain(CL.get_constructors(x),
                                     CL.get_methods(x)):
                # A minimal filter, do not reuse self.keep_fnt here, because the namespace is N1::N2:...::ClassName
                if CL.is_template(m) or ("ignore_in_python"
                                         in CL.get_annotations(m)):
                    continue
                yield getattr(m, 'result_type', None)
                for p in CL.get_params(m):
                    yield p.type