(self, routines, f, prefix, header=True, empty=True)
Write a Cython file with python wrappers

           This file contains all the definitions of the routines in c code and
           refers to the header file.

           :Arguments:

           routines
                List of Routine instances
           f
                File-like object to write the file to
           prefix
                The filename prefix, used to refer to the proper header file.
                Only the basename of the prefix is used.
           empty
                Optional. When True, empty lines are included to structure the
                source files. [DEFAULT=True]
Write a Cython file with python wrappers
Write a Cython file with python wrappers
def dump_pyx(self, routines, f, prefix, header=True, empty=True):
        """Write a Cython file with python wrappers

           This file contains all the definitions of the routines in c code and
           refers to the header file.

           :Arguments:

           routines
                List of Routine instances
           f
                File-like object to write the file to
           prefix
                The filename prefix, used to refer to the proper header file.
                Only the basename of the prefix is used.
           empty
                Optional. When True, empty lines are included to structure the
                source files. [DEFAULT=True]
        """
        for routine in routines:
            prototype = self.generator.get_prototype(routine)

            # declare
            print('cdef extern from "%s.h":' % prefix, file=f)
            print('   %s' % prototype, file=f)
            if empty:
                print(file=f)

            # wrap
            ret, args_py = self._split_retvals_inargs(routine.arguments)
            args_c = ", ".join([str(a.name) for a in routine.arguments])
            print("def %s_c(%s):" % (routine.name,
                ", ".join(self._declare_arg(arg) for arg in args_py)), file=f)
            for r in ret:
                if not r in args_py:
                    print("   cdef %s" % self._declare_arg(r), file=f)
            rets = ", ".join([str(r.name) for r in ret])
            if routine.results:
                call = '   return %s(%s)' % (routine.name, args_c)
                if rets:
                    print(call + ', ' + rets, file=f)
                else:
                    print(call, file=f)
            else:
                print('   %s(%s)' % (routine.name, args_c), file=f)
                print('   return %s' % rets, file=f)

            if empty:
                print(file=f)
def dump_pyx ( self , routines , f , prefix , header = True , empty = True ) : for routine in routines : prototype = self . generator . get_prototype ( routine ) # declare print ( 'cdef extern from "%s.h":' % prefix , file = f ) print ( '   %s' % prototype , file = f ) if empty : print ( file = f ) # wrap ret , args_py = self . _split_retvals_inargs ( routine . arguments ) args_c = ", " . join ( [ str ( a . name ) for a in routine . arguments ] ) print ( "def %s_c(%s):" % ( routine . name , ", " . join ( self . _declare_arg ( arg ) for arg in args_py ) ) , file = f ) for r in ret : if not r in args_py : print ( "   cdef %s" % self . _declare_arg ( r ) , file = f ) rets = ", " . join ( [ str ( r . name ) for r in ret ] ) if routine . results : call = '   return %s(%s)' % ( routine . name , args_c ) if rets : print ( call + ', ' + rets , file = f ) else : print ( call , file = f ) else : print ( '   %s(%s)' % ( routine . name , args_c ) , file = f ) print ( '   return %s' % rets , file = f ) if empty : print ( file = f )