43 static char const* kwlist[] = {
"property",
"jg", NULL};
44 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"O|i", (
char**)&kwlist,
47 comin_descrdata_property_t* prop =
48 (comin_descrdata_property_t*)PyCapsule_GetPointer(prop_cap,
49 "descrdata_property");
53 if (std::string(prop->datatype) ==
56 }
else if (prop->ndims == 0) {
57 if (std::string(prop->datatype) ==
"int") {
60 val = ((int (*)(int))prop->get_function)(
jg);
62 val = ((int (*)())prop->get_function)();
63 return PyLong_FromLong(val);
65 if (std::string(prop->datatype) ==
"double") {
68 val = ((double (*)(int))prop->get_function)(
jg);
70 val = ((double (*)())prop->get_function)();
71 return PyFloat_FromDouble(val);
73 if (std::string(prop->datatype) ==
"bool") {
76 val = ((bool (*)(int))prop->get_function)(
jg);
78 val = ((bool (*)())prop->get_function)();
84 return PyErr_Format(PyExc_RuntimeError,
85 "datatype %s for scalar value %s not implemented",
86 prop->datatype, prop->name);
88 std::vector<int> arr_size(prop->ndims);
90 ((void (*)(int,
void**,
int*))prop->get_function)(
jg, &dataptr,
93 ((
void (*)(
void**,
int*))prop->get_function)(&dataptr, arr_size.data());
95 return PyErr_Format(PyExc_RuntimeError,
"%s get function returned NULL",
97 if (prop->ndims == 0) {
100 if (std::string(prop->datatype) ==
"char" && prop->ndims == 1)
101 return Py_BuildValue(
"s#", dataptr, (Py_ssize_t)arr_size[0]);
104 if (std::string(prop->datatype) ==
"double") {
106 }
else if (std::string(prop->datatype) ==
"int") {
108 }
else if (std::string(prop->datatype) ==
"int8_t") {
111 return PyErr_Format(PyExc_RuntimeError,
112 "datatype %s for property %s not implemented",
113 prop->datatype, prop->name);
115 return PyMemoryView_FromBuffer(&
buffer);