How to use the f90wrap.fortran.iter_child_nodes 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 / transform.py View on Github external
def add_missing_constructors(tree):
    for node in ft.walk(tree):
        if not isinstance(node, ft.Type):
            continue
        for child in ft.iter_child_nodes(node):
            if isinstance(child, ft.Procedure):
                if 'constructor' in child.attributes:
                    logging.info('found constructor %s' % child.name)
                    break
        else:

            logging.info('adding missing constructor for %s' % node.name)
            new_node = ft.Subroutine('%s_initialise' % node.name,
                                     node.filename,
                                     ['Automatically generated constructor for %s' % node.name],
                                     node.lineno,
                                     [ft.Argument(name='this',  # self.prefix + 'this' would probably be safer
                                                  filename=node.filename,
                                                  doc=['Object to be constructed'],
                                                  lineno=node.lineno,
                                                  attributes=['intent(out)'],
github jameskermode / f90wrap / f90wrap / transform.py View on Github external
def add_missing_destructors(tree):
    for node in ft.walk(tree):
        if not isinstance(node, ft.Type):
            continue
        for child in ft.iter_child_nodes(node):
            if isinstance(child, ft.Procedure):
                if 'destructor' in child.attributes:
                    logging.info('found destructor %s' % child.name)
                    break
        else:

            logging.info('adding missing destructor for %s' % node.name)
            new_node = ft.Subroutine('%s_finalise' % node.name,
                                     node.filename,
                                     ['Automatically generated destructor for %s' % node.name],
                                     node.lineno,
                                     [ft.Argument(name='this',  # self.prefix + 'this' would probably be safer
                                                  filename=node.filename,
                                                  doc=['Object to be destructed'],
                                                  lineno=node.lineno,
                                                  attributes=['intent(inout)'],