Skip to content

Commit

Permalink
Clean class detection
Browse files Browse the repository at this point in the history
  • Loading branch information
krystophny committed Nov 28, 2024
1 parent dc5d68a commit b823762
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion f90wrap/f90wrapgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,11 @@ def write_class_lines(self, cname, recursive=False):
self.write_type_lines(cname, recursive, f"{cname}_wrapper_type")

def is_class(self, tname):
return "class(%(classname)s)" % {"classname": tname} in self.types
if not tname in self.types:
return False
if "used_as_class" in self.types[tname].attributes:
return True
return False

def write_type_or_class_lines(self, tname, recursive=False):
if self.is_class(tname):
Expand Down
4 changes: 3 additions & 1 deletion f90wrap/fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ def find_types(tree, skipped_types=None):
node.uses = set([(mod.name, (node.name,))])
types[node.name] = node
types['type(%s)' % node.name] = node
types['class(%s)' % node.name] = node
else:
log.info('Skipping type %s defined in module %s' % (node.name, mod.name))

Expand All @@ -614,7 +615,8 @@ def find_types(tree, skipped_types=None):
continue
if node.type.startswith('class('):
class_name = derived_typename(node.type)
types['class(%s)' % class_name] = types[class_name]
if 'used_as_class' not in types[class_name].attributes:
types[class_name].attributes.append('used_as_class')

return types

Expand Down

0 comments on commit b823762

Please sign in to comment.