How to use the f90wrap.fortran.Interface function in f90wrap

To help you get started, we’ve selected a few f90wrap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jameskermode / f90wrap / f90wrap / transform.py View on Github external
def visit_Type(self, node):
            logging.debug('visiting %r' % node)
            interfaces = []
            procedures = []
            for child in ft.iter_child_nodes(node):
                if isinstance(child, ft.Interface):
                    interfaces.append(child)
                elif isinstance(child, ft.Procedure):
                    procedures.append(child)
                else:
                    # other child nodes should be left where they are
                    pass

            node.interfaces = interfaces
            node.procedures = procedures
            return self.generic_visit(node)
github jameskermode / f90wrap / f90wrap / pywrapgen.py View on Github external
doc.append("\t%s" % d)
                doc.append("")

        if isinstance(node, ft.Function):
            for i, arg in enumerate(node.ret_val):
                pytype = ft.f2py_type(arg.type, arg.attributes)
                if i == 0:
                    doc.append("")
                    doc.append("Returns")
                    doc.append("-------")
                doc.append("%s : %s" % (arg.name, pytype))
                if arg.doc:
                    for d in arg.doc:
                        doc.append("\t%s" % d)
                    doc.append("")
    elif isinstance(node, ft.Interface):
        # for interfaces, list the components
        doc.append('')
        doc.append('Overloaded interface containing the following procedures:')
        for proc in node.procedures:
            doc.append('  %s' % (hasattr(proc, 'method_name')
                                 and proc.method_name or proc.name))

    doc += [''] + node.doc[:]  # incoming docstring from Fortran source

    return '\n'.join(['"""'] + doc + ['"""'])
github jameskermode / f90wrap / f90wrap / transform.py View on Github external
# just a regular method - move into typ.procedures
                typ.procedures.append(node)
                logging.info('added method %s to type %s' %
                              (node.method_name, typ.name))
            else:
                # this method was originally inside an interface,
                # so we need to replicate Interface inside the Type
                for intf in typ.interfaces:
                    if intf.name == interface.name:
                        intf.procedures.append(node)
                        logging.info('added method %s to interface %s in type %s module %r' %
                                      (node.method_name, intf.name, typ.name, node.mod_name))
                        break
                else:
                    intf = ft.Interface(interface.name,
                                        interface.filename,
                                        interface.doc,
                                        interface.lineno,
                                        [node],
                                        mod_name=node.mod_name,
                                        type_name=typ.name)
                    typ.interfaces.append(intf)
                    logging.info('added method %s to new interface %s in type %s module %r' %
                                  (node.method_name, intf.name, typ.name, node.mod_name))

            # remove method from parent since we've added it to Type
            return None
        else:
            return node