MCPcopy Index your code
hub / github.com/numpy/numpy / buildhooks

Function buildhooks

numpy/f2py/f90mod_rules.py:82–281  ·  view source on GitHub ↗
(pymod)

Source from the content-addressed store, hash-verified

80
81
82def buildhooks(pymod):
83 from . import rules
84 ret = {'f90modhooks': [], 'initf90modhooks': [], 'body': [],
85 'need': ['F_FUNC', 'arrayobject.h'],
86 'separatorsfor': {'includes0': '\n', 'includes': '\n'},
87 'docs': ['"Fortran 90/95 modules:\\n"'],
88 'latexdoc': []}
89 fhooks = ['']
90
91 def fadd(line, s=fhooks):
92 s[0] = f'{s[0]}\n {line}'
93 doc = ['']
94
95 def dadd(line, s=doc):
96 s[0] = f'{s[0]}\n{line}'
97
98 usenames = getuseblocks(pymod)
99 for m in findf90modules(pymod):
100 sargs, fargs, efargs, modobjs, notvars, onlyvars = [], [], [], [], [
101 m['name']], []
102 sargsp = []
103 ifargs = []
104 mfargs = []
105 if hasbody(m):
106 for b in m['body']:
107 notvars.append(b['name'])
108 for n in m['vars'].keys():
109 var = m['vars'][n]
110
111 if (n not in notvars and isvariable(var)) and (not l_or(isintent_hide, isprivate)(var)):
112 onlyvars.append(n)
113 mfargs.append(n)
114 outmess(f"\t\tConstructing F90 module support for \"{m['name']}\"...\n")
115 if len(onlyvars) == 0 and len(notvars) == 1 and m['name'] in notvars:
116 outmess(f"\t\t\tSkipping {m['name']} since there are no public vars/func in this module...\n")
117 continue
118
119 # gh-25186
120 if m['name'] in usenames and containscommon(m):
121 outmess(f"\t\t\tSkipping {m['name']} since it is in 'use' and contains a common block...\n")
122 continue
123 # skip modules with derived types
124 if m['name'] in usenames and containsderivedtypes(m):
125 outmess(f"\t\t\tSkipping {m['name']} since it is in 'use' and contains a derived type...\n")
126 continue
127 if onlyvars:
128 outmess(f"\t\t Variables: {' '.join(onlyvars)}\n")
129 chooks = ['']
130
131 def cadd(line, s=chooks):
132 s[0] = f'{s[0]}\n{line}'
133 ihooks = ['']
134
135 def iadd(line, s=ihooks):
136 s[0] = f'{s[0]}\n{line}'
137
138 vrd = capi_maps.modsign2map(m)
139 cadd(f"static FortranDataDef f2py_{m['name']}_def[] = {{")

Callers

nothing calls this directly

Calls 15

getuseblocksFunction · 0.85
findf90modulesFunction · 0.85
hasbodyFunction · 0.85
isvariableFunction · 0.85
l_orFunction · 0.85
containscommonFunction · 0.85
containsderivedtypesFunction · 0.85
hasnoteFunction · 0.85
undo_rmbadname1Function · 0.85
isallocatableFunction · 0.85
isroutineFunction · 0.85
applyrulesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…