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

Function getctype

numpy/f2py/capi_maps.py:189–239  ·  view source on GitHub ↗

Determines C type

(var)

Source from the content-addressed store, hash-verified

187
188
189def getctype(var):
190 """
191 Determines C type
192 """
193 ctype = 'void'
194 if isfunction(var):
195 if 'result' in var:
196 a = var['result']
197 else:
198 a = var['name']
199 if a in var['vars']:
200 return getctype(var['vars'][a])
201 else:
202 errmess(f'getctype: function {a} has no return value?!\n')
203 elif issubroutine(var):
204 return ctype
205 elif ischaracter_or_characterarray(var):
206 return 'character'
207 elif isstring_or_stringarray(var):
208 return 'string'
209 elif 'typespec' in var and var['typespec'].lower() in f2cmap_all:
210 typespec = var['typespec'].lower()
211 f2cmap = f2cmap_all[typespec]
212 ctype = f2cmap[''] # default type
213 if 'kindselector' in var:
214 if '*' in var['kindselector']:
215 try:
216 ctype = f2cmap[var['kindselector']['*']]
217 except KeyError:
218 raw_typespec = var['typespec']
219 star = var['kindselector']['*']
220 errmess(f'getctype: "{raw_typespec} * {star}" not supported.\n')
221 elif 'kind' in var['kindselector']:
222 if typespec + 'kind' in f2cmap_all:
223 f2cmap = f2cmap_all[typespec + 'kind']
224 try:
225 ctype = f2cmap[var['kindselector']['kind']]
226 except KeyError:
227 if typespec in f2cmap_all:
228 f2cmap = f2cmap_all[typespec]
229 try:
230 ctype = f2cmap[str(var['kindselector']['kind'])]
231 except KeyError:
232 kind = var['kindselector']['kind']
233 errmess(f'getctype: "{typespec}({kind=})" is mapped to C '
234 f'"{ctype}" (to override define {{{typespec!r}: '
235 f'{{{kind!r}: "<C typespec>"}}}} '
236 f'in {os.getcwd()}/.f2py_f2cmap file).\n')
237 elif not isexternal(var):
238 errmess(f'getctype: No C-type found in "{var}", assuming void.\n')
239 return ctype
240
241
242def f2cexpr(expr):

Callers 8

getpydocsignFunction · 0.85
getarrdocsignFunction · 0.85
sign2mapFunction · 0.85
routsign2mapFunction · 0.85
cb_sign2mapFunction · 0.85
cb_routsign2mapFunction · 0.85
common_sign2mapFunction · 0.85
getcallprotoargumentFunction · 0.85

Calls 7

errmessFunction · 0.85
issubroutineFunction · 0.85
isstring_or_stringarrayFunction · 0.85
isexternalFunction · 0.85
lowerMethod · 0.80
isfunctionFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…