Debian Codegraph @

doc/modify.rst

raw
1 #############
2 How to Modify
3 #############
4
5 ===============
6 Rebuild Process
7 ===============
8
9 jpy's source distribution directory layout uses the `Maven common directory structure <http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html>`_.
10
11 * ``setup.py`` - Python build/installation script, will compile Python and Java sources, install the libraries and run all unit-level tests.
12 * ``pom.xml`` - Maven project file to build the Java sources. Called by ``setup.py``.
13 * ``src/main/c`` - C source files for the jpy Python API
14 * ``src/test/python`` - Python API test cases
15 * ``src/main/java`` - Java source files for the jpy Java API
16 * ``src/test/java`` - Java API test cases
17
18
19 After changing any source code just run setup again as indicated in the :ref:`build` process.
20
21
22 After changing signatures of native methods in ``src/main/java/org/jpy/PyLib.java``, you need to compile the Java classes
23 and regenerate the C headers for the ``PyLib`` class using Maven::
24
25 mvn compile
26 javah -d src/main/c/jni -v -classpath target/classes org.jpy.PyLib
27
28 Then always adapt changes ``org_jpy_PyLib.c`` according to newly generated ``org_jpy_PyLib.h`` and ``org_jpy_PyLib_Diag.h``.
29 Files are found in ``src/main/c/jni/``. Then run setup again as indicated above.
30
31 =======================
32 C Programming Guideline
33 =======================
34
35 * Follow style used in Python itself
36 * Python type global variable names: `J<type>_Type`
37 * Python type instance structs: `JPy_J<type>`
38 * Python function decl for a type: `J<type>_<FunctionName>(JNIEnv* jenv, JPy_J<type>* <type>, ...)`
39 * The pointer is always the first parameter, only type slots obtain their `jenv` from `JPy_GetJEnv()`
40 * Python slots function for a type: `J<type>_<slot_name>(JNIEnv* jenv, JPy_J<type>* self, ...)`
41 * Usually functions shall indicate errors by returning NULL or -1 on error.
42 Callers can expect that the PyErr_SetError has been set correctly and thus simply
43 return NULL or -1 again.
44 Exception: very simple functions, e.g. `JObj_Check()`, can go without error status indication.
45 * Naming conventions:
46
47 * jpy_jtype.h/c - The Java Meta-Type
48 * JPy_JType type
49 * JType_xxx() functions
50 * jpy_jobj.h/c - The Java Object Wrapper
51 * JPy_JObj type
52 * JObj_xxx() functions
53 * jpy_jmethod.h/c - The Java Method Wrapper
54 * JPy_JMethod type
55 * JPy_JOverloadedMethod type
56 * JMethod_xxx() functions
57 * JOverloadedMethod_xxx() functions
58 * jpy_jfield.h/c - The Java Field Wrapper
59 * JPy_JField type
60 * JField_xxx() functions
61 * jpy_conv.h/c - Conversion of Python objects from/to Java values
62 * JPy_From<JType> functions / JPy_FROM_<JTYPE> macros create Python objects (new references!) from Java types
63 * JPy_As<JType> functions / JPy_AS_<JTYPE> macros convert from Python objects to Java types
64 * jpy_diag.h/c - Control of outputting diagnostic info
65 * JPy_Diag type
66 * JPy_DIAG_F_<name> macros
67 * JPy_DIAG_PRINT(flags, format, ...) macros
68 * jpy_module.h/c - The 'jpy' module definition
69 * JPy_xxx() functions
70 * jni/org_jpy_PyLib.h - generated by javah from PyLib.java
71 * jni/org_jpy_PyLib_Diag.h - generated by javah from PyLib.java
72 * jni/org_jpy_PyLib.c - native implementations from PyLib.java
73