|
20 | 20 | 'double *' : "numpy.double", |
21 | 21 | 'int' : "numpy.intc", |
22 | 22 | 'int *' : "numpy.intc", |
23 | | - 'int[4]' : "numpy.dtype([('', 'i', (4,))])", |
24 | | - 'double[2]' : "numpy.dtype([('', 'd', (2,))])", |
25 | | - 'double[3]' : "numpy.dtype([('p', 'd', (3,))])", |
26 | | - 'double[2][3]' : "numpy.dtype([('pv', 'd', (2,3))])", |
27 | | - 'double[3][3]' : "numpy.dtype([('r', 'd', (3,3))])", |
| 23 | + 'int[4]' : "numpy.dtype([('fi0', 'i', (4,))])", |
| 24 | + 'double[2]' : "numpy.dtype([('fi0', 'd', (2,))])", |
| 25 | + 'double[3]' : "numpy.dtype([('fi0', 'd', (3,))])", |
| 26 | + 'double[2][3]' : "numpy.dtype([('fi0', 'd', (2,3))])", |
| 27 | + 'double[3][3]' : "numpy.dtype([('fi0', 'd', (3,3))])", |
28 | 28 | 'eraASTROM *' : "dt_eraASTROM", |
29 | | - 'char *' : "numpy.dtype('S1')", |
| 29 | + 'eraLDBODY[]' : "dt_eraLDBODY", |
| 30 | + 'char *' : "numpy.dtype('S16')", |
| 31 | + 'const char *' : "numpy.dtype('S16')", |
30 | 32 | } |
31 | 33 |
|
32 | 34 |
|
| 35 | +NDIMS_REX = re.compile(re.escape("numpy.dtype([('fi0', '.*', <(.*)>)])").replace(r'\.\*','.*').replace(r'\<', '(').replace(r'\>',')')) |
| 36 | + |
| 37 | + |
33 | 38 | class FunctionDoc(object): |
34 | 39 |
|
35 | 40 | def __init__(self, doc): |
@@ -159,6 +164,21 @@ def ctype_ptr(self): |
159 | 164 | def dtype(self): |
160 | 165 | return ctype_to_dtype[self.ctype] |
161 | 166 |
|
| 167 | + @property |
| 168 | + def ndims(self): |
| 169 | + """ |
| 170 | + This is an argument that has a multi-dimensional output, like |
| 171 | + double[3][3] |
| 172 | + """ |
| 173 | + if self.dtype.startswith('numpy.dtype'): |
| 174 | + mtch = NDIMS_REX.match(self.dtype) |
| 175 | + if mtch: |
| 176 | + return len(eval(mtch.group(1))) |
| 177 | + else: |
| 178 | + return 0 |
| 179 | + else: |
| 180 | + return 0 |
| 181 | + |
162 | 182 | def __repr__(self): |
163 | 183 | return "Argument('{0}', name='{1}', ctype='{2}', inout_state='{3}')".format(self.definition, self.name, self.ctype, self.inout_state) |
164 | 184 |
|
@@ -209,6 +229,14 @@ def __repr__(self): |
209 | 229 | def dtype(self): |
210 | 230 | return ctype_to_dtype[self.ctype] |
211 | 231 |
|
| 232 | + @property |
| 233 | + def nd_dtype(self): |
| 234 | + """ |
| 235 | + This if the return type has a multi-dimensional output, like |
| 236 | + double[3][3] |
| 237 | + """ |
| 238 | + return "'fi0'" in self.dtype |
| 239 | + |
212 | 240 | @property |
213 | 241 | def doc_info(self): |
214 | 242 | return self.doc.ret_info |
@@ -365,6 +393,7 @@ def surround(a_list, pre, post): |
365 | 393 | "found in the string that " |
366 | 394 | "spawned it. This should be " |
367 | 395 | "impossible!") |
| 396 | + |
368 | 397 | print("Rendering template") |
369 | 398 | erfa_pyx = erfa_pyx_in.render(funcs=funcs) |
370 | 399 |
|
|
0 commit comments