-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjobjectArray.cpp
More file actions
37 lines (34 loc) · 1.23 KB
/
jobjectArray.cpp
File metadata and controls
37 lines (34 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "jobjectArray.hpp"
static jobjectArrayObject* jobjectArray_jobjectArray(PyObject *x) {
if (jobjectArray_CheckExact(x))
INC_RETURN_TYPE(x, jobjectArrayObject*);
else if (jobject_Check(x))
return jobjectArray_FromValue(jobjectArray_Val(x));
_BadArgument("jobjectArray", "argument", "jobject", x);
return NULL;
}
static jobjectArrayObject* jobjectArray_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) {
PyObject *x;
if (!PyArg_UnpackTuple(args, "jobjectArray", 1, 1, &x))
return NULL;
return jobjectArray_jobjectArray(x);
}
PyTypeObject jobjectArray_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "jobjectArray",
.tp_basicsize = sizeof(jobjectArrayObject),
.tp_itemsize = 0,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_doc = "jobjectArray type",
.tp_base = &jarray_Type,
};
jobjectArrayObject* jobjectArray_FromValue(jobjectArray value) {
PyTypeObject *type = &jobjectArray_Type;
jobjectArrayObject *self = (jobjectArrayObject*)type->tp_alloc(type, 0);
if (self != NULL) {
jobject_Val(self) = value;
Py_INCREF(&jobjectArray_Type);
jarray_Type(self) = &jobjectArray_Type;
}
return self;
}