42 static char const* kwlist[] = {
"property",
"jg", NULL};
43 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"O|i", (
char**)&kwlist,
46 comin_descrdata_property_t* prop =
47 (comin_descrdata_property_t*)PyCapsule_GetPointer(prop_cap,
48 "descrdata_property");
52 if (std::string(prop->datatype) ==
55 }
else if (prop->ndims == 0) {
56 if (std::string(prop->datatype) ==
"int") {
59 val = ((int (*)(int))prop->get_function)(
jg);
61 val = ((int (*)())prop->get_function)();
62 return PyLong_FromLong(val);
64 if (std::string(prop->datatype) ==
"double") {
67 val = ((double (*)(int))prop->get_function)(
jg);
69 val = ((double (*)())prop->get_function)();
70 return PyFloat_FromDouble(val);
72 if (std::string(prop->datatype) ==
"bool") {
75 val = ((bool (*)(int))prop->get_function)(
jg);
77 val = ((bool (*)())prop->get_function)();
83 return PyErr_Format(PyExc_RuntimeError,
84 "datatype %s for scalar value %s not implemented",
85 prop->datatype, prop->name);
87 std::vector<int> arr_size(prop->ndims);
89 ((void (*)(int,
void**,
int*))prop->get_function)(
jg, &dataptr,
92 ((
void (*)(
void**,
int*))prop->get_function)(&dataptr, arr_size.data());
94 return PyErr_Format(PyExc_RuntimeError,
"%s get function returned NULL",
96 if (prop->ndims == 0) {
99 if (std::string(prop->datatype) ==
"char" && prop->ndims == 1)
100 return Py_BuildValue(
"s#", dataptr, (Py_ssize_t)arr_size[0]);
103 if (std::string(prop->datatype) ==
"double") {
105 }
else if (std::string(prop->datatype) ==
"int") {
107 }
else if (std::string(prop->datatype) ==
"int8_t") {
110 return PyErr_Format(PyExc_RuntimeError,
111 "datatype %s for property %s not implemented",
112 prop->datatype, prop->name);
114 return PyMemoryView_FromBuffer(&
buffer);