forked from ninia/jep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyjobject.h
67 lines (50 loc) · 2.16 KB
/
pyjobject.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
jep - Java Embedded Python
Copyright (c) 2004-2021 JEP AUTHORS.
This file is licensed under the the zlib/libpng License.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "jep_platform.h"
#ifndef _Included_pyjobject
#define _Included_pyjobject
extern PyTypeObject PyJObject_Type;
/*
* The common fields for PyJObject. The usage of this macro is similar to
* PyObject_HEAD. Any type which extends PyJObject and requires additional
* fields must start the struct definition with PyObject_HEAD followed
* immediatly by PyJObject_FIELDS and then any custom fields for the subtype.
*
* These fields are the JNI objects for the Java object and the Class of that
* object. As well as a Python dict for the attributes and a Python string
* containing the fully qualified java class name.
*/
#define PyJObject_FIELDS \
jobject object; \
jclass clazz; \
PyObject *javaClassName;
typedef struct {
PyObject_HEAD
PyJObject_FIELDS
} PyJObject;
/*
* Create a new instance of PyJObject or one of it's subtypes that wraps
* the object provided. If the class of the object is known it can be passed
* in, or the final argument can be NULL and this function will figure it out.
*/
PyObject* PyJObject_New(JNIEnv*, PyTypeObject*, jobject, jclass);
#define PyJObject_Check(pyobj) \
PyObject_TypeCheck(pyobj, &PyJObject_Type)
#endif // ndef pyjobject