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

Function buildhooks

numpy/f2py/common_rules.py:40–145  ·  view source on GitHub ↗
(m)

Source from the content-addressed store, hash-verified

38
39
40def buildhooks(m):
41 ret = {'commonhooks': [], 'initcommonhooks': [],
42 'docs': ['"COMMON blocks:\\n"']}
43 fwrap = ['']
44
45 def fadd(line, s=fwrap):
46 s[0] = f'{s[0]}\n {line}'
47 chooks = ['']
48
49 def cadd(line, s=chooks):
50 s[0] = f'{s[0]}\n{line}'
51 ihooks = ['']
52
53 def iadd(line, s=ihooks):
54 s[0] = f'{s[0]}\n{line}'
55 doc = ['']
56
57 def dadd(line, s=doc):
58 s[0] = f'{s[0]}\n{line}'
59 for (name, vnames, vars) in findcommonblocks(m):
60 lower_name = name.lower()
61 hnames, inames = [], []
62 for n in vnames:
63 if isintent_hide(vars[n]):
64 hnames.append(n)
65 else:
66 inames.append(n)
67 hnames_str = ','.join(hnames)
68 inames_str = ','.join(inames)
69 if hnames:
70 outmess(f'\t\tConstructing COMMON block support for "{name}"...\n\t\t '
71 f'{inames_str}\n\t\t Hidden: {hnames_str}\n')
72 else:
73 outmess(f'\t\tConstructing COMMON block support for "{name}"...\n\t\t '
74 f'{inames_str}\n')
75 fadd(f'subroutine f2pyinit{name}(setupfunc)')
76 for usename in getuseblocks(m):
77 fadd(f'use {usename}')
78 fadd('external setupfunc')
79 for n in vnames:
80 fadd(func2subr.var2fixfortran(vars, n))
81 if name == '_BLNK_':
82 fadd(f"common {','.join(vnames)}")
83 else:
84 fadd(f"common /{name}/ {','.join(vnames)}")
85 fadd(f"call setupfunc({','.join(inames)})")
86 fadd('end\n')
87 cadd(f'static FortranDataDef f2py_{name}_def[] = {{')
88 idims = []
89 for n in inames:
90 ct = capi_maps.getctype(vars[n])
91 elsize = capi_maps.get_elsize(vars[n])
92 at = capi_maps.c2capi_map[ct]
93 dm = capi_maps.getarrdims(n, vars[n])
94 if dm['dims']:
95 idims.append(f"({dm['dims']})")
96 else:
97 idims.append('')

Callers

nothing calls this directly

Calls 15

findcommonblocksFunction · 0.85
isintent_hideFunction · 0.85
getuseblocksFunction · 0.85
rmbadnameFunction · 0.85
hasnoteFunction · 0.85
lowerMethod · 0.80
joinMethod · 0.80
stripMethod · 0.80
upperMethod · 0.80
replaceMethod · 0.80
outmessFunction · 0.70
faddFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…