Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ EXAMPLES = \
issue306_allocatable_realloc \
issue307_logical_array \
issue32 \
issue353_selected_kind \
issue41_abstract_classes \
keep_single_interface \
keyword_renaming_issue160 \
Expand Down
13 changes: 13 additions & 0 deletions examples/issue353_selected_kind/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include ../make.inc

.PHONY: all test clean

all:
f90wrap test_selected_kind.f90 -v

test: all
$(PYTHON) run.py

clean:
rm -f f90wrap*.f90 .f2py_f2cmap mod.py
rm -rf __pycache__/ build/ _build_dir/
7 changes: 7 additions & 0 deletions examples/issue353_selected_kind/Makefile.meson
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include ../make.meson.inc

NAME := test_selected_kind
LIBSRC_WRAP_FPP_FILES := test_selected_kind.f90

test: extension
$(PYTHON) run.py
25 changes: 25 additions & 0 deletions examples/issue353_selected_kind/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from pathlib import Path
import glob

wrapper_files = glob.glob("f90wrap_*.f90")
if not wrapper_files:
raise SystemExit("No f90wrap_*.f90 files found")

wrapper = ""
for f in wrapper_files:
wrapper += Path(f).read_text(encoding="utf-8")

expected = [
"integer(selected_int_kind(9)), intent(out) :: i",
"real(selected_real_kind(13,300)), intent(out) :: a",
]

missing = [line for line in expected if line not in wrapper]
if missing:
raise SystemExit(
"Missing expected wrapper lines:\n"
+ "\n".join(missing)
+ "\n\nGenerated wrapper:\n"
+ wrapper
)

6 changes: 6 additions & 0 deletions examples/issue353_selected_kind/test_selected_kind.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
subroutine test_selected_kind(i, a)
implicit none
integer(kind=selected_int_kind(9)), intent(out) :: i
real(kind=selected_real_kind(13,300)), intent(out) :: a
end subroutine test_selected_kind

31 changes: 25 additions & 6 deletions f90wrap/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,17 @@ def check_decl(cl, file):
filename = file.filename
lineno = file.lineno

tp = re.match(types_re, cl).group()
tp_match = re.match(types_re, cl)
tp = tp_match.group()
tp_end = tp_match.end()
while tp.count('(') > tp.count(')') and tp_end < len(cl):
while tp_end < len(cl) and cl[tp_end].isspace():
tp_end += 1
if tp_end < len(cl) and cl[tp_end] == ')':
tp += ')'
tp_end += 1
else:
break
atr = re.search(attr_re, cl)
if atr != None:
atrl = s_attrib_re.findall(atr.group())
Expand All @@ -1493,7 +1503,7 @@ def check_decl(cl, file):
if m is not None:
names = cl[m.end():]
else:
names = types_re.sub('', cl)
names = cl[tp_end:]

# old line - doesn't handle array constants
# nl=re.split(r'\s*,\s*',names)
Expand Down Expand Up @@ -1575,15 +1585,24 @@ def check_arg(cl, file):
filename = file.filename
lineno = file.lineno

tp = re.match(types_re, cl).group()
tp_match = re.match(types_re, cl)
tp = tp_match.group()
tp_end = tp_match.end()
while tp.count('(') > tp.count(')') and tp_end < len(cl):
while tp_end < len(cl) and cl[tp_end].isspace():
tp_end += 1
if tp_end < len(cl) and cl[tp_end] == ')':
tp += ')'
tp_end += 1
else:
break
m = re.search(d_colon, cl)
if m is not None:
atr_temp = cl[re.match(types_re, cl).end():m.start()]
atr_temp = cl[tp_end:m.start()]
names = cl[m.end():]
else:
atr_temp = ''
# Need to remove ONLY THE FIRST type string (the name may have the type in it)
names = types_re.sub('', cl, 1)
names = cl[tp_end:]

atrl = split_attribs(atr_temp)

Expand Down
Loading