MCPcopy
hub / github.com/numpy/numpy / createfuncwrapper

Function createfuncwrapper

numpy/f2py/func2subr.py:86–206  ·  view source on GitHub ↗
(rout, signature=0)

Source from the content-addressed store, hash-verified

84 return useisoc
85
86def createfuncwrapper(rout, signature=0):
87 assert isfunction(rout)
88
89 extra_args = []
90 vars = rout['vars']
91 for a in rout['args']:
92 v = rout['vars'][a]
93 for i, d in enumerate(v.get('dimension', [])):
94 if d == ':':
95 dn = f'f2py_{a}_d{i}'
96 dv = {'typespec': 'integer', 'intent': ['hide']}
97 dv['='] = f'shape({a}, {i})'
98 extra_args.append(dn)
99 vars[dn] = dv
100 v['dimension'][i] = dn
101 rout['args'].extend(extra_args)
102 need_interface = bool(extra_args)
103
104 ret = ['']
105
106 def add(line, ret=ret):
107 ret[0] = f'{ret[0]}\n {line}'
108 name = rout['name']
109 fortranname = getfortranname(rout)
110 f90mode = ismoduleroutine(rout)
111 newname = f'{name}f2pywrap'
112
113 if newname not in vars:
114 vars[newname] = vars[name]
115 args = [newname] + rout['args'][1:]
116 else:
117 args = [newname] + rout['args']
118
119 l_tmpl = var2fixfortran(vars, name, '@@@NAME@@@', f90mode)
120 if l_tmpl[:13] == 'character*(*)':
121 if f90mode:
122 l_tmpl = 'character(len=10)' + l_tmpl[13:]
123 else:
124 l_tmpl = 'character*10' + l_tmpl[13:]
125 charselect = vars[name]['charselector']
126 if charselect.get('*', '') == '(*)':
127 charselect['*'] = '10'
128
129 l1 = l_tmpl.replace('@@@NAME@@@', newname)
130 rl = None
131
132 useisoc = useiso_c_binding(rout)
133 sargs = ', '.join(args)
134 if f90mode:
135 # gh-23598 fix warning
136 # Essentially, this gets called again with modules where the name of the
137 # function is added to the arguments, which is not required, and removed
138 sargs = sargs.replace(f"{name}, ", '')
139 args = [arg for arg in args if arg != name]
140 rout['args'] = args
141 add(f"subroutine f2pywrap_{rout['modulename']}_{name} ({sargs})")
142 if not signature:
143 add(f"use {rout['modulename']}, only : {fortranname}")

Callers 1

assubrFunction · 0.85

Calls 15

getfortrannameFunction · 0.85
ismoduleroutineFunction · 0.85
var2fixfortranFunction · 0.85
useiso_c_bindingFunction · 0.85
addFunction · 0.85
isexternalFunction · 0.85
isintent_inFunction · 0.85
islogicalfunctionFunction · 0.85
replaceMethod · 0.80
joinMethod · 0.80
splitMethod · 0.80
startswithMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…