MCPcopy Create free account
hub / github.com/numpy/numpy / getctype

Function getctype

numpy/f2py/capi_maps.py:187–235  ·  view source on GitHub ↗

Determines C type

(var)

Source from the content-addressed store, hash-verified

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

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

Tested by

no test coverage detected