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

Function fortran_doc

numpy/f2py/src/fortranobject.c:258–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256}
257
258static PyObject *
259fortran_doc(FortranDataDef def)
260{
261 char *buf, *p;
262 PyObject *s = NULL;
263 Py_ssize_t n, origsize, size = 100;
264
265 if (def.doc != NULL) {
266 size += strlen(def.doc);
267 }
268 origsize = size;
269 buf = p = (char *)PyMem_Malloc(size);
270 if (buf == NULL) {
271 return PyErr_NoMemory();
272 }
273
274 if (def.rank == -1) {
275 if (def.doc) {
276 n = strlen(def.doc);
277 if (n > size) {
278 goto fail;
279 }
280 memcpy(p, def.doc, n);
281 p += n;
282 size -= n;
283 }
284 else {
285 n = PyOS_snprintf(p, size, "%s - no docs available", def.name);
286 if (n < 0 || n >= size) {
287 goto fail;
288 }
289 p += n;
290 size -= n;
291 }
292 }
293 else {
294 PyArray_Descr *d = PyArray_DescrFromType(def.type);
295 n = PyOS_snprintf(p, size, "%s : '%c'-", def.name, d->type);
296 Py_DECREF(d);
297 if (n < 0 || n >= size) {
298 goto fail;
299 }
300 p += n;
301 size -= n;
302
303 if (def.data == NULL) {
304 n = format_def(p, size, def);
305 if (n < 0) {
306 goto fail;
307 }
308 p += n;
309 size -= n;
310 }
311 else if (def.rank > 0) {
312 n = format_def(p, size, def);
313 if (n < 0) {
314 goto fail;
315 }

Callers 1

fortran_getattrFunction · 0.85

Calls 1

format_defFunction · 0.85

Tested by

no test coverage detected