diff --git a/.github/actions/deploy-ubuntu/action.yml b/.github/actions/deploy-ubuntu/action.yml index 97307bcf597..ebbd1dccfc1 100644 --- a/.github/actions/deploy-ubuntu/action.yml +++ b/.github/actions/deploy-ubuntu/action.yml @@ -64,11 +64,6 @@ runs: export CODENAME=$UBUNTU_CODENAME if [[ ! "$ARCH" == "amd64" ]]; then - # https://github.com/actions/runner-images/issues/4589 - $SUDO apt-add-repository -y ppa:ondrej/php - $SUDO apt-get -y install ppa-purge - $SUDO ppa-purge -y ppa:ondrej/php - # https://github.com/actions/runner-images/issues/675 $SUDO gem install apt-spy2 $SUDO apt-spy2 check @@ -76,6 +71,11 @@ runs: $SUDO sed -i 's/azure\.//' /etc/apt/apt-mirrors.txt /etc/apt/sources.list $SUDO cat /etc/apt/apt-mirrors.txt /etc/apt/sources.list $SUDO apt-get update + + # https://github.com/actions/runner-images/issues/4589 + $SUDO apt-add-repository -y ppa:ondrej/php + $SUDO apt-get -y install ppa-purge + $SUDO ppa-purge -y ppa:ondrej/php fi if [[ "$ARCH" == "i386" ]]; then diff --git a/CHANGELOG.md b/CHANGELOG.md index b77f472e04f..16341d341f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ * Refactor and improve presets for PyTorch ([pull #1360](https://github.com/bytedeco/javacpp-presets/pull/1360)) * Include `mkl_lapack.h` header file in presets for MKL ([issue #1388](https://github.com/bytedeco/javacpp-presets/issues/1388)) * Map new higher-level C++ API of Triton Inference Server ([pull #1361](https://github.com/bytedeco/javacpp-presets/pull/1361)) - * Upgrade presets for OpenCV 4.8.1, DNNL 3.3, OpenBLAS 0.3.24, CPython 3.11.5, NumPy 1.25.2, SciPy 1.11.2, LLVM 17.0.1, Leptonica 1.83.1, Tesseract 5.3.3, TensorFlow Lite 2.14.0, Triton Inference Server 2.38.0, ONNX 1.14.1, ONNX Runtime 1.16.1, TVM 0.13.0, and their dependencies + * Upgrade presets for OpenCV 4.8.1, DNNL 3.3, OpenBLAS 0.3.24, CPython 3.12.0, NumPy 1.26.1, SciPy 1.11.3, LLVM 17.0.1, Leptonica 1.83.1, Tesseract 5.3.3, TensorFlow Lite 2.14.0, Triton Inference Server 2.38.0, ONNX 1.14.1, ONNX Runtime 1.16.1, TVM 0.13.0, and their dependencies ### June 6, 2023 version 1.5.9 * Virtualize `nvinfer1::IGpuAllocator` from TensorRT to allow customization ([pull #1367](https://github.com/bytedeco/javacpp-presets/pull/1367)) diff --git a/README.md b/README.md index 673ad7e553e..7d28d7f48b8 100644 --- a/README.md +++ b/README.md @@ -204,8 +204,8 @@ Each child module in turn relies by default on the included [`cppbuild.sh` scrip * CMINPACK 1.3.8 https://github.com/devernay/cminpack * FFTW 3.3.10 http://www.fftw.org/download.html * GSL 2.7 http://www.gnu.org/software/gsl/#downloading - * CPython 3.11.x https://www.python.org/downloads/ - * NumPy 1.25.x https://github.com/numpy/numpy + * CPython 3.12.x https://www.python.org/downloads/ + * NumPy 1.26.x https://github.com/numpy/numpy * SciPy 1.11.x https://github.com/scipy/scipy * Gym 0.26.x https://github.com/openai/gym * LLVM 17.0.x http://llvm.org/releases/download.html diff --git a/cpython/README.md b/cpython/README.md index 4566ed93962..880cc054ebe 100644 --- a/cpython/README.md +++ b/cpython/README.md @@ -14,7 +14,7 @@ Introduction ------------ This directory contains the JavaCPP Presets module for: - * CPython 3.11.5 https://www.python.org/ + * CPython 3.12.0 https://www.python.org/ Please refer to the parent README.md file for more detailed information about the JavaCPP Presets. @@ -54,7 +54,7 @@ We can use [Maven 3](http://maven.apache.org/) to download and install automatic org.bytedeco cpython-platform - 3.11.5-1.5.10-SNAPSHOT + 3.12.0-1.5.10-SNAPSHOT diff --git a/cpython/cppbuild.sh b/cpython/cppbuild.sh index c7715a1d320..65c30c7a456 100755 --- a/cpython/cppbuild.sh +++ b/cpython/cppbuild.sh @@ -8,7 +8,7 @@ if [[ -z "$PLATFORM" ]]; then fi OPENSSL=openssl-3.1.3 -CPYTHON_VERSION=3.11.5 +CPYTHON_VERSION=3.12.0 download https://www.openssl.org/source/$OPENSSL.tar.gz $OPENSSL.tar.gz download https://www.python.org/ftp/python/$CPYTHON_VERSION/Python-$CPYTHON_VERSION.tgz Python-$CPYTHON_VERSION.tgz @@ -148,7 +148,7 @@ case $PLATFORM in cp -r Lib/* ../lib/ cp -r Include/* PC/pyconfig.h ../include/ unzip -o ../lib/ensurepip/_bundled/pip* -d ../lib/ - unzip -o ../lib/ensurepip/_bundled/setuptools* -d ../lib/ + # unzip -o ../lib/ensurepip/_bundled/setuptools* -d ../lib/ ;; windows-x86_64) mkdir -p ../include ../lib ../libs ../bin @@ -161,7 +161,7 @@ case $PLATFORM in cp -r Lib/* ../lib/ cp -r Include/* PC/pyconfig.h ../include/ unzip -o ../lib/ensurepip/_bundled/pip* -d ../lib/ - unzip -o ../lib/ensurepip/_bundled/setuptools* -d ../lib/ + # unzip -o ../lib/ensurepip/_bundled/setuptools* -d ../lib/ ;; *) echo "Error: Platform \"$PLATFORM\" is not supported" diff --git a/cpython/platform/pom.xml b/cpython/platform/pom.xml index 2b79a761736..d3860adac81 100644 --- a/cpython/platform/pom.xml +++ b/cpython/platform/pom.xml @@ -12,7 +12,7 @@ org.bytedeco cpython-platform - 3.11.5-${project.parent.version} + 3.12.0-${project.parent.version} JavaCPP Presets Platform for CPython diff --git a/cpython/pom.xml b/cpython/pom.xml index db168a95d16..d61d1b62b04 100644 --- a/cpython/pom.xml +++ b/cpython/pom.xml @@ -11,7 +11,7 @@ org.bytedeco cpython - 3.11.5-${project.parent.version} + 3.12.0-${project.parent.version} JavaCPP Presets for CPython @@ -35,7 +35,7 @@ ${basedir}/cppbuild/${javacpp.platform}/include/ - ${basedir}/cppbuild/${javacpp.platform}/include/python3.11/ + ${basedir}/cppbuild/${javacpp.platform}/include/python3.12/ ${basedir}/cppbuild/${javacpp.platform}/lib/ diff --git a/cpython/samples/pom.xml b/cpython/samples/pom.xml index b83e7dc9abe..dec0e715040 100644 --- a/cpython/samples/pom.xml +++ b/cpython/samples/pom.xml @@ -12,7 +12,7 @@ org.bytedeco cpython-platform - 3.11.5-1.5.10-SNAPSHOT + 3.12.0-1.5.10-SNAPSHOT diff --git a/cpython/src/gen/java/org/bytedeco/cpython/Int_PyOS_InputHook.java b/cpython/src/gen/java/org/bytedeco/cpython/Int_PyOS_InputHook.java index 6d2504a2abb..da24038938d 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/Int_PyOS_InputHook.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/Int_PyOS_InputHook.java @@ -10,6 +10,7 @@ import static org.bytedeco.cpython.global.python.*; +// #endif /* Stuff with no proper home (yet) */ diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PerfMapState.java b/cpython/src/gen/java/org/bytedeco/cpython/PerfMapState.java new file mode 100644 index 00000000000..b0a61059401 --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/PerfMapState.java @@ -0,0 +1,35 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +// #if !defined(Py_LIMITED_API) +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class PerfMapState extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public PerfMapState() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public PerfMapState(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public PerfMapState(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public PerfMapState position(long position) { + return (PerfMapState)super.position(position); + } + @Override public PerfMapState getPointer(long i) { + return new PerfMapState((Pointer)this).offsetAddress(i); + } + + public native @Cast("FILE*") Pointer perf_map(); public native PerfMapState perf_map(Pointer setter); + public native PyThread_type_lock map_lock(); public native PerfMapState map_lock(PyThread_type_lock setter); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyASCIIObject.java b/cpython/src/gen/java/org/bytedeco/cpython/PyASCIIObject.java index 075fc017bfa..6c1b711db98 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyASCIIObject.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyASCIIObject.java @@ -15,7 +15,7 @@ /* ASCII-only strings created through PyUnicode_New use the PyASCIIObject structure. state.ascii and state.compact are set, and the data - immediately follow the structure. utf8_length and wstr_length can be found + immediately follow the structure. utf8_length can be found in the length field; the utf8 pointer is equal to the data pointer. */ @Properties(inherit = org.bytedeco.cpython.presets.python.class) public class PyASCIIObject extends Pointer { @@ -44,8 +44,7 @@ public class PyASCIIObject extends Pointer { * kind = PyUnicode_1BYTE_KIND * compact = 1 * ascii = 1 - * ready = 1 - * (length is the length of the utf8 and wstr strings) + * (length is the length of the utf8) * (data starts just after the structure) * (since ASCII is decoded from UTF-8, the utf8 string are the data) @@ -56,77 +55,45 @@ public class PyASCIIObject extends Pointer { * kind = PyUnicode_1BYTE_KIND, PyUnicode_2BYTE_KIND or PyUnicode_4BYTE_KIND * compact = 1 - * ready = 1 * ascii = 0 * utf8 is not shared with data * utf8_length = 0 if utf8 is NULL - * wstr is shared with data and wstr_length=length - if kind=PyUnicode_2BYTE_KIND and sizeof(wchar_t)=2 - or if kind=PyUnicode_4BYTE_KIND and sizeof(wchar_t)=4 - * wstr_length = 0 if wstr is NULL * (data starts just after the structure) - - legacy string, not ready: - - * structure = PyUnicodeObject - * test: kind == PyUnicode_WCHAR_KIND - * length = 0 (use wstr_length) - * hash = -1 - * kind = PyUnicode_WCHAR_KIND - * compact = 0 - * ascii = 0 - * ready = 0 - * interned = SSTATE_NOT_INTERNED - * wstr is not NULL - * data.any is NULL - * utf8 is NULL - * utf8_length = 0 - - - legacy string, ready: + - legacy string: * structure = PyUnicodeObject structure - * test: !PyUnicode_IS_COMPACT(op) && kind != PyUnicode_WCHAR_KIND + * test: !PyUnicode_IS_COMPACT(op) * kind = PyUnicode_1BYTE_KIND, PyUnicode_2BYTE_KIND or PyUnicode_4BYTE_KIND * compact = 0 - * ready = 1 * data.any is not NULL * utf8 is shared and utf8_length = length with data.any if ascii = 1 * utf8_length = 0 if utf8 is NULL - * wstr is shared with data.any and wstr_length = length - if kind=PyUnicode_2BYTE_KIND and sizeof(wchar_t)=2 - or if kind=PyUnicode_4BYTE_KIND and sizeof(wchar_4)=4 - * wstr_length = 0 if wstr is NULL Compact strings use only one memory block (structure + characters), whereas legacy strings use one block for the structure and one block for characters. - Legacy strings are created by PyUnicode_FromUnicode() and - PyUnicode_FromStringAndSize(NULL, size) functions. They become ready - when PyUnicode_READY() is called. + Legacy strings are created by subclasses of Unicode. See also _PyUnicode_CheckConsistency(). */ public native @ByRef PyObject ob_base(); public native PyASCIIObject ob_base(PyObject setter); public native @Cast("Py_ssize_t") long length(); public native PyASCIIObject length(long setter); /* Number of code points in the string */ public native @Cast("Py_hash_t") long hash(); public native PyASCIIObject hash(long setter); /* Hash value; -1 if not set */ - /* - SSTATE_NOT_INTERNED (0) - SSTATE_INTERNED_MORTAL (1) - SSTATE_INTERNED_IMMORTAL (2) - - If interned != SSTATE_NOT_INTERNED, the two references from the + /* If interned is non-zero, the two references from the dictionary to this object are *not* counted in ob_refcnt. - */ + The possible values here are: + 0: Not Interned + 1: Interned + 2: Interned and Immortal + 3: Interned, Immortal, and Static + This categorization allows the runtime to determine the right + cleanup mechanism at runtime shutdown. */ @Name("state.interned") public native @Cast("unsigned int") @NoOffset int state_interned(); public native PyASCIIObject state_interned(int setter); /* Character size: - - PyUnicode_WCHAR_KIND (0): - - * character type = wchar_t (16 or 32 bits, depending on the - platform) - - PyUnicode_1BYTE_KIND (1): * character type = Py_UCS1 (8 bits, unsigned) @@ -157,13 +124,7 @@ See also _PyUnicode_CheckConsistency(). and the kind is PyUnicode_1BYTE_KIND. If ascii is set and compact is set, use the PyASCIIObject structure. */ @Name("state.ascii") public native @Cast("unsigned int") @NoOffset int state_ascii(); public native PyASCIIObject state_ascii(int setter); - /* The ready flag indicates whether the object layout is initialized - completely. This means that this is either a compact object, or - the data pointer is filled out. The bit is redundant, and helps - to minimize the test in PyUnicode_IS_READY(). */ - @Name("state.ready") public native @Cast("unsigned int") @NoOffset int state_ready(); public native PyASCIIObject state_ready(int setter); /* Padding to ensure that PyUnicode_DATA() is always aligned to 4 bytes (see issue #19537 on m68k). */ - public native @Cast("wchar_t*") Pointer wstr(); public native PyASCIIObject wstr(Pointer setter); /* wchar_t representation (null-terminated) */ } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyAsyncGenObject.java b/cpython/src/gen/java/org/bytedeco/cpython/PyAsyncGenObject.java index 9c67eb1eef6..b975393699b 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyAsyncGenObject.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyAsyncGenObject.java @@ -33,8 +33,6 @@ public class PyAsyncGenObject extends Pointer { } public native @ByRef PyObject ob_base(); public native PyAsyncGenObject ob_base(PyObject setter); - /* The code object backing the generator */ - public native PyCodeObject ag_code(); public native PyAsyncGenObject ag_code(PyCodeObject setter); /* List of weak reference. */ public native PyObject ag_weakreflist(); public native PyAsyncGenObject ag_weakreflist(PyObject setter); /* Name of the generator. */ @@ -50,4 +48,5 @@ public class PyAsyncGenObject extends Pointer { public native byte ag_frame_state(); public native PyAsyncGenObject ag_frame_state(byte setter); public native PyObject ag_iframe(int i); public native PyAsyncGenObject ag_iframe(int i, PyObject setter); @MemberGetter public native @Cast("PyObject**") PointerPointer ag_iframe(); + } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyCodeObject.java b/cpython/src/gen/java/org/bytedeco/cpython/PyCodeObject.java index 47d4817d86e..acd6ee4f646 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyCodeObject.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyCodeObject.java @@ -58,8 +58,6 @@ public class PyCodeObject extends Pointer { public native PyObject co_exceptiontable(); public native PyCodeObject co_exceptiontable(PyObject setter); /* Byte string encoding exception handling \ table */ public native int co_flags(); public native PyCodeObject co_flags(int setter); /* CO_..., see below */ - public native short co_warmup(); public native PyCodeObject co_warmup(short setter); /* Warmup counter for quickening */ - public native short _co_linearray_entry_size(); public native PyCodeObject _co_linearray_entry_size(short setter); /* Size of each entry in _co_linearray */ /* The rest are not so impactful on performance. */ public native int co_argcount(); public native PyCodeObject co_argcount(int setter); /* #arguments, except *args */ @@ -70,12 +68,12 @@ public class PyCodeObject extends Pointer { /* redundant values (derived from co_localsplusnames and \ co_localspluskinds) */ - public native int co_nlocalsplus(); public native PyCodeObject co_nlocalsplus(int setter); /* number of local + cell + free variables \ - */ + public native int co_nlocalsplus(); public native PyCodeObject co_nlocalsplus(int setter); /* number of local + cell + free variables */ + public native int co_framesize(); public native PyCodeObject co_framesize(int setter); /* Size of frame in words */ public native int co_nlocals(); public native PyCodeObject co_nlocals(int setter); /* number of local variables */ - public native int co_nplaincellvars(); public native PyCodeObject co_nplaincellvars(int setter); /* number of non-arg cell variables */ public native int co_ncellvars(); public native PyCodeObject co_ncellvars(int setter); /* total number of cell variables */ public native int co_nfreevars(); public native PyCodeObject co_nfreevars(int setter); /* number of free variables */ + public native @Cast("uint32_t") int co_version(); public native PyCodeObject co_version(int setter); /* version number */ public native PyObject co_localsplusnames(); public native PyCodeObject co_localsplusnames(PyObject setter); /* tuple mapping offsets to names */ public native PyObject co_localspluskinds(); public native PyCodeObject co_localspluskinds(PyObject setter); /* Bytes mapping to local kinds (one byte \ @@ -85,8 +83,9 @@ public class PyCodeObject extends Pointer { public native PyObject co_qualname(); public native PyCodeObject co_qualname(PyObject setter); /* unicode (qualname, for reference) */ public native PyObject co_linetable(); public native PyCodeObject co_linetable(PyObject setter); /* bytes object that holds location info */ public native PyObject co_weakreflist(); public native PyCodeObject co_weakreflist(PyObject setter); /* to support weakrefs to code objects */ - public native PyObject _co_code(); public native PyCodeObject _co_code(PyObject setter); /* cached co_code object/attribute */ - public native @Cast("char*") BytePointer _co_linearray(); public native PyCodeObject _co_linearray(BytePointer setter); /* array of line offsets */ + public native _PyCoCached _co_cached(); public native PyCodeObject _co_cached(_PyCoCached setter); /* cached co_* attributes */ + public native @Cast("uint64_t") long _co_instrumentation_version(); public native PyCodeObject _co_instrumentation_version(long setter); /* current instrumentation version */ + public native _PyCoMonitoringData _co_monitoring(); public native PyCodeObject _co_monitoring(_PyCoMonitoringData setter); /* Monitoring data */ public native int _co_firsttraceable(); public native PyCodeObject _co_firsttraceable(int setter); /* index of first traceable instruction */ /* Scratch space for extra data relating to the code object. \ Type is a void* to keep the format private in codeobject.c to force \ diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyCode_WatchCallback.java b/cpython/src/gen/java/org/bytedeco/cpython/PyCode_WatchCallback.java new file mode 100644 index 00000000000..9e180c57e42 --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyCode_WatchCallback.java @@ -0,0 +1,34 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + + +/* + * A callback that is invoked for different events in a code object's lifecycle. + * + * The callback is invoked with a borrowed reference to co, after it is + * created and before it is destroyed. + * + * If the callback sets an exception, it must return -1. Otherwise + * it should return 0. + */ +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class PyCode_WatchCallback extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public PyCode_WatchCallback(Pointer p) { super(p); } + protected PyCode_WatchCallback() { allocate(); } + private native void allocate(); + public native int call( + @Cast("PyCodeEvent") int event, + PyCodeObject co); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyCompactUnicodeObject.java b/cpython/src/gen/java/org/bytedeco/cpython/PyCompactUnicodeObject.java index 4bd81403c09..99d73cef749 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyCompactUnicodeObject.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyCompactUnicodeObject.java @@ -36,6 +36,4 @@ public class PyCompactUnicodeObject extends Pointer { public native @Cast("Py_ssize_t") long utf8_length(); public native PyCompactUnicodeObject utf8_length(long setter); /* Number of bytes in utf8, excluding the * terminating \0. */ public native @Cast("char*") BytePointer utf8(); public native PyCompactUnicodeObject utf8(BytePointer setter); /* UTF-8 representation (null-terminated) */ - public native @Cast("Py_ssize_t") long wstr_length(); public native PyCompactUnicodeObject wstr_length(long setter); /* Number of code points in wstr, possible - * surrogates count as two code points. */ } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyConfig.java b/cpython/src/gen/java/org/bytedeco/cpython/PyConfig.java index 8a488ed670c..1ab0cff802f 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyConfig.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyConfig.java @@ -43,6 +43,7 @@ public class PyConfig extends Pointer { public native @Cast("unsigned long") long hash_seed(); public native PyConfig hash_seed(long setter); public native int faulthandler(); public native PyConfig faulthandler(int setter); public native int tracemalloc(); public native PyConfig tracemalloc(int setter); + public native int perf_profiling(); public native PyConfig perf_profiling(int setter); public native int import_time(); public native PyConfig import_time(int setter); public native int code_debug_ranges(); public native PyConfig code_debug_ranges(int setter); public native int show_ref_count(); public native PyConfig show_ref_count(int setter); @@ -77,6 +78,7 @@ public class PyConfig extends Pointer { public native @Cast("wchar_t*") Pointer check_hash_pycs_mode(); public native PyConfig check_hash_pycs_mode(Pointer setter); public native int use_frozen_modules(); public native PyConfig use_frozen_modules(int setter); public native int safe_path(); public native PyConfig safe_path(int setter); + public native int int_max_str_digits(); public native PyConfig int_max_str_digits(int setter); /* --- Path configuration inputs ------------ */ public native int pathconfig_warnings(); public native PyConfig pathconfig_warnings(int setter); @@ -111,10 +113,6 @@ public class PyConfig extends Pointer { // If equal to 0, stop Python initialization before the "main" phase. public native int _init_main(); public native PyConfig _init_main(int setter); - // If non-zero, disallow threads, subprocesses, and fork. - // Default: 0. - public native int _isolated_interpreter(); public native PyConfig _isolated_interpreter(int setter); - // If non-zero, we believe we're running from a source tree. public native int _is_python_build(); public native PyConfig _is_python_build(int setter); } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyCoroObject.java b/cpython/src/gen/java/org/bytedeco/cpython/PyCoroObject.java index 8403142d9ea..26310c5ebe2 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyCoroObject.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyCoroObject.java @@ -33,8 +33,6 @@ public class PyCoroObject extends Pointer { } public native @ByRef PyObject ob_base(); public native PyCoroObject ob_base(PyObject setter); - /* The code object backing the generator */ - public native PyCodeObject cr_code(); public native PyCoroObject cr_code(PyCodeObject setter); /* List of weak reference. */ public native PyObject cr_weakreflist(); public native PyCoroObject cr_weakreflist(PyObject setter); /* Name of the generator. */ @@ -50,4 +48,5 @@ public class PyCoroObject extends Pointer { public native byte cr_frame_state(); public native PyCoroObject cr_frame_state(byte setter); public native PyObject cr_iframe(int i); public native PyCoroObject cr_iframe(int i, PyObject setter); @MemberGetter public native @Cast("PyObject**") PointerPointer cr_iframe(); + } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyDictObject.java b/cpython/src/gen/java/org/bytedeco/cpython/PyDictObject.java index aa04e5274b6..34f0a3f47aa 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyDictObject.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyDictObject.java @@ -39,7 +39,10 @@ public class PyDictObject extends Pointer { /* Dictionary version: globally unique, value change each time the dictionary is modified */ - public native @Cast("uint64_t") long ma_version_tag(); public native PyDictObject ma_version_tag(long setter); +// #ifdef Py_BUILD_CORE +// #else + public native @Cast("uint64_t") @Deprecated long ma_version_tag(); public native PyDictObject ma_version_tag(long setter); +// #endif public native PyDictKeysObject ma_keys(); public native PyDictObject ma_keys(PyDictKeysObject setter); diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyDict_WatchCallback.java b/cpython/src/gen/java/org/bytedeco/cpython/PyDict_WatchCallback.java new file mode 100644 index 00000000000..2904f1c2dec --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyDict_WatchCallback.java @@ -0,0 +1,25 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +// Callback to be invoked when a watched dict is cleared, dealloced, or modified. +// In clear/dealloc case, key and new_value will be NULL. Otherwise, new_value will be the +// new value for key, NULL if key is being deleted. +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class PyDict_WatchCallback extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public PyDict_WatchCallback(Pointer p) { super(p); } + protected PyDict_WatchCallback() { allocate(); } + private native void allocate(); + public native int call(@Cast("PyDict_WatchEvent") int event, PyObject dict, PyObject key, PyObject new_value); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyFunctionObject.java b/cpython/src/gen/java/org/bytedeco/cpython/PyFunctionObject.java index adcbef8a849..3f42ed99155 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyFunctionObject.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyFunctionObject.java @@ -54,6 +54,7 @@ public class PyFunctionObject extends Pointer { public native PyObject func_weakreflist(); public native PyFunctionObject func_weakreflist(PyObject setter); /* List of weak references */ public native PyObject func_module(); public native PyFunctionObject func_module(PyObject setter); /* The __module__ attribute, can be anything */ public native PyObject func_annotations(); public native PyFunctionObject func_annotations(PyObject setter); /* Annotations, a dict or NULL */ + public native PyObject func_typeparams(); public native PyFunctionObject func_typeparams(PyObject setter); /* Tuple of active type variables or NULL */ public native vectorcallfunc vectorcall(); public native PyFunctionObject vectorcall(vectorcallfunc setter); /* Version number for use by specializer. * Can set to non-zero when we want to specialize. @@ -61,7 +62,8 @@ public class PyFunctionObject extends Pointer { * defaults * kwdefaults (only if the object changes, not the contents of the dict) * code - * annotations */ + * annotations + * vectorcall function pointer */ public native @Cast("uint32_t") int func_version(); public native PyFunctionObject func_version(int setter); /* Invariant: diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyFunction_WatchCallback.java b/cpython/src/gen/java/org/bytedeco/cpython/PyFunction_WatchCallback.java new file mode 100644 index 00000000000..681d61768f0 --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyFunction_WatchCallback.java @@ -0,0 +1,40 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +/* + * A callback that is invoked for different events in a function's lifecycle. + * + * The callback is invoked with a borrowed reference to func, after it is + * created and before it is modified or destroyed. The callback should not + * modify func. + * + * When a function's code object, defaults, or kwdefaults are modified the + * callback will be invoked with the respective event and new_value will + * contain a borrowed reference to the new value that is about to be stored in + * the function. Otherwise the third argument is NULL. + * + * If the callback returns with an exception set, it must return -1. Otherwise + * it should return 0. + */ +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class PyFunction_WatchCallback extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public PyFunction_WatchCallback(Pointer p) { super(p); } + protected PyFunction_WatchCallback() { allocate(); } + private native void allocate(); + public native int call( + @Cast("PyFunction_WatchEvent") int event, + PyFunctionObject func, + PyObject new_value); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyFutureFeatures.java b/cpython/src/gen/java/org/bytedeco/cpython/PyFutureFeatures.java index 5c9dfd0d6dd..9e432f8342c 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyFutureFeatures.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyFutureFeatures.java @@ -31,6 +31,6 @@ public class PyFutureFeatures extends Pointer { return new PyFutureFeatures((Pointer)this).offsetAddress(i); } - public native int ff_features(); public native PyFutureFeatures ff_features(int setter); /* flags set by future statements */ - public native int ff_lineno(); public native PyFutureFeatures ff_lineno(int setter); /* line number of last future statement */ + public native int ff_features(); public native PyFutureFeatures ff_features(int setter); /* flags set by future statements */ + public native @ByRef _PyCompilerSrcLocation ff_location(); public native PyFutureFeatures ff_location(_PyCompilerSrcLocation setter); /* location of last future statement */ } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyGenObject.java b/cpython/src/gen/java/org/bytedeco/cpython/PyGenObject.java index a43bd8fc708..0cf2745b9a5 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyGenObject.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyGenObject.java @@ -9,7 +9,7 @@ import static org.bytedeco.javacpp.presets.javacpp.*; import static org.bytedeco.cpython.global.python.*; - + @Properties(inherit = org.bytedeco.cpython.presets.python.class) public class PyGenObject extends Pointer { @@ -31,8 +31,6 @@ public class PyGenObject extends Pointer { /* The gi_ prefix is intended to remind of generator-iterator. */ public native @ByRef PyObject ob_base(); public native PyGenObject ob_base(PyObject setter); - /* The code object backing the generator */ - public native PyCodeObject gi_code(); public native PyGenObject gi_code(PyCodeObject setter); /* List of weak reference. */ public native PyObject gi_weakreflist(); public native PyGenObject gi_weakreflist(PyObject setter); /* Name of the generator. */ @@ -48,4 +46,5 @@ public class PyGenObject extends Pointer { public native byte gi_frame_state(); public native PyGenObject gi_frame_state(byte setter); public native PyObject gi_iframe(int i); public native PyGenObject gi_iframe(int i, PyObject setter); @MemberGetter public native @Cast("PyObject**") PointerPointer gi_iframe(); + } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyImportErrorObject.java b/cpython/src/gen/java/org/bytedeco/cpython/PyImportErrorObject.java index 2576b62642f..74283f3e28f 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyImportErrorObject.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyImportErrorObject.java @@ -36,4 +36,5 @@ public class PyImportErrorObject extends Pointer { public native PyObject msg(); public native PyImportErrorObject msg(PyObject setter); public native PyObject name(); public native PyImportErrorObject name(PyObject setter); public native PyObject path(); public native PyImportErrorObject path(PyObject setter); + public native PyObject name_from(); public native PyImportErrorObject name_from(PyObject setter); } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyInterpreterConfig.java b/cpython/src/gen/java/org/bytedeco/cpython/PyInterpreterConfig.java new file mode 100644 index 00000000000..f708134e113 --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyInterpreterConfig.java @@ -0,0 +1,40 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class PyInterpreterConfig extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public PyInterpreterConfig() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public PyInterpreterConfig(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public PyInterpreterConfig(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public PyInterpreterConfig position(long position) { + return (PyInterpreterConfig)super.position(position); + } + @Override public PyInterpreterConfig getPointer(long i) { + return new PyInterpreterConfig((Pointer)this).offsetAddress(i); + } + + // XXX "allow_object_sharing"? "own_objects"? + public native int use_main_obmalloc(); public native PyInterpreterConfig use_main_obmalloc(int setter); + public native int allow_fork(); public native PyInterpreterConfig allow_fork(int setter); + public native int allow_exec(); public native PyInterpreterConfig allow_exec(int setter); + public native int allow_threads(); public native PyInterpreterConfig allow_threads(int setter); + public native int allow_daemon_threads(); public native PyInterpreterConfig allow_daemon_threads(int setter); + public native int check_multi_interp_extensions(); public native PyInterpreterConfig check_multi_interp_extensions(int setter); + public native int gil(); public native PyInterpreterConfig gil(int setter); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyMemberDef.java b/cpython/src/gen/java/org/bytedeco/cpython/PyMemberDef.java index d75d4a62798..7feb72345e6 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyMemberDef.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyMemberDef.java @@ -9,14 +9,14 @@ import static org.bytedeco.javacpp.presets.javacpp.*; import static org.bytedeco.cpython.global.python.*; - /* For offsetof */ + + /* An array of PyMemberDef structures defines the name, type and offset of selected members of a C structure. These can be read by PyMember_GetOne() and set by PyMember_SetOne() (except if their READONLY flag is set). The array must be terminated with an entry whose name pointer is NULL. */ - @Properties(inherit = org.bytedeco.cpython.presets.python.class) public class PyMemberDef extends Pointer { static { Loader.load(); } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyMemoryViewObject.java b/cpython/src/gen/java/org/bytedeco/cpython/PyMemoryViewObject.java deleted file mode 100644 index 94dfc69feda..00000000000 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyMemoryViewObject.java +++ /dev/null @@ -1,41 +0,0 @@ -// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE - -package org.bytedeco.cpython; - -import java.nio.*; -import org.bytedeco.javacpp.*; -import org.bytedeco.javacpp.annotation.*; - -import static org.bytedeco.javacpp.presets.javacpp.*; - -import static org.bytedeco.cpython.global.python.*; - /* PIL-style layout */ - -@Properties(inherit = org.bytedeco.cpython.presets.python.class) -public class PyMemoryViewObject extends Pointer { - static { Loader.load(); } - /** Default native constructor. */ - public PyMemoryViewObject() { super((Pointer)null); allocate(); } - /** Native array allocator. Access with {@link Pointer#position(long)}. */ - public PyMemoryViewObject(long size) { super((Pointer)null); allocateArray(size); } - /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public PyMemoryViewObject(Pointer p) { super(p); } - private native void allocate(); - private native void allocateArray(long size); - @Override public PyMemoryViewObject position(long position) { - return (PyMemoryViewObject)super.position(position); - } - @Override public PyMemoryViewObject getPointer(long i) { - return new PyMemoryViewObject((Pointer)this).offsetAddress(i); - } - - public native @ByRef PyVarObject ob_base(); public native PyMemoryViewObject ob_base(PyVarObject setter); - public native _PyManagedBufferObject mbuf(); public native PyMemoryViewObject mbuf(_PyManagedBufferObject setter); /* managed buffer */ - public native @Cast("Py_hash_t") long hash(); public native PyMemoryViewObject hash(long setter); /* hash value for read-only views */ - public native int flags(); public native PyMemoryViewObject flags(int setter); /* state flags */ - public native @Cast("Py_ssize_t") long exports(); public native PyMemoryViewObject exports(long setter); /* number of buffer re-exports */ - public native @ByRef Py_buffer view(); public native PyMemoryViewObject view(Py_buffer setter); /* private copy of the exporter's view */ - public native PyObject weakreflist(); public native PyMemoryViewObject weakreflist(PyObject setter); - public native @Cast("Py_ssize_t") long ob_array(int i); public native PyMemoryViewObject ob_array(int i, long setter); - @MemberGetter public native @Cast("Py_ssize_t*") SizeTPointer ob_array(); /* shape, strides, suboffsets */ -} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyModuleDef.java b/cpython/src/gen/java/org/bytedeco/cpython/PyModuleDef.java index e8c9e79dc78..821d180e783 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyModuleDef.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyModuleDef.java @@ -10,7 +10,6 @@ import static org.bytedeco.cpython.global.python.*; -// #endif // #endif /* New in 3.5 */ diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyModuleDef_Base.java b/cpython/src/gen/java/org/bytedeco/cpython/PyModuleDef_Base.java index 1737122ddf5..0584329fc23 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyModuleDef_Base.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyModuleDef_Base.java @@ -31,6 +31,12 @@ public class PyModuleDef_Base extends Pointer { } public native @ByRef PyObject ob_base(); public native PyModuleDef_Base ob_base(PyObject setter); + /* The function used to re-initialize the module. + This is only set for legacy (single-phase init) extension modules + and only used for those that support multiple initializations + (m_size >= 0). + It is set by _PyImport_LoadDynamicModuleWithSpec() + and _imp.create_builtin(). */ public static class PyObject_M_init extends FunctionPointer { static { Loader.load(); } /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ @@ -40,6 +46,14 @@ public static class PyObject_M_init extends FunctionPointer { public native PyObject call(); } public native PyObject_M_init m_init(); public native PyModuleDef_Base m_init(PyObject_M_init setter); + /* The module's index into its interpreter's modules_by_index cache. + This is set for all extension modules but only used for legacy ones. + (See PyInterpreterState.modules_by_index for more info.) + It is set by PyModuleDef_Init(). */ public native @Cast("Py_ssize_t") long m_index(); public native PyModuleDef_Base m_index(long setter); + /* A copy of the module's __dict__ after the first time it was loaded. + This is only set/used for legacy modules that do not support + multiple initializations. + It is set by _PyImport_FixupExtensionObject(). */ public native PyObject m_copy(); public native PyModuleDef_Base m_copy(PyObject setter); } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyNumberMethods.java b/cpython/src/gen/java/org/bytedeco/cpython/PyNumberMethods.java index dea39037bec..f58520d2b0b 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyNumberMethods.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyNumberMethods.java @@ -11,6 +11,7 @@ import static org.bytedeco.cpython.global.python.*; +// #endif /* !Py_BUILD_CORE */ @Properties(inherit = org.bytedeco.cpython.presets.python.class) public class PyNumberMethods extends Pointer { diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyThreadState.java b/cpython/src/gen/java/org/bytedeco/cpython/PyThreadState.java index c7591cd8392..feb4959cd78 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyThreadState.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyThreadState.java @@ -35,24 +35,40 @@ public class PyThreadState extends Pointer { public native PyThreadState next(); public native PyThreadState next(PyThreadState setter); public native PyInterpreterState interp(); public native PyThreadState interp(PyInterpreterState setter); - /* Has been initialized to a safe state. + /* Has been initialized to a safe state. - In order to be effective, this must be set to 0 during or right - after allocation. */ - public native int _initialized(); public native PyThreadState _initialized(int setter); + In order to be effective, this must be set to 0 during or right + after allocation. */ + @Name("_status.initialized") public native @Cast("unsigned int") @NoOffset int _status_initialized(); public native PyThreadState _status_initialized(int setter); - /* Was this thread state statically allocated? */ - public native int _static(); public native PyThreadState _static(int setter); + /* Has been bound to an OS thread. */ + @Name("_status.bound") public native @Cast("unsigned int") @NoOffset int _status_bound(); public native PyThreadState _status_bound(int setter); + /* Has been unbound from its OS thread. */ + @Name("_status.unbound") public native @Cast("unsigned int") @NoOffset int _status_unbound(); public native PyThreadState _status_unbound(int setter); + /* Has been bound aa current for the GILState API. */ + @Name("_status.bound_gilstate") public native @Cast("unsigned int") @NoOffset int _status_bound_gilstate(); public native PyThreadState _status_bound_gilstate(int setter); + /* Currently in use (maybe holds the GIL). */ + @Name("_status.active") public native @Cast("unsigned int") @NoOffset int _status_active(); public native PyThreadState _status_active(int setter); - public native int recursion_remaining(); public native PyThreadState recursion_remaining(int setter); - public native int recursion_limit(); public native PyThreadState recursion_limit(int setter); + /* various stages of finalization */ + @Name("_status.finalizing") public native @Cast("unsigned int") @NoOffset int _status_finalizing(); public native PyThreadState _status_finalizing(int setter); + @Name("_status.cleared") public native @Cast("unsigned int") @NoOffset int _status_cleared(); public native PyThreadState _status_cleared(int setter); + @Name("_status.finalized") public native @Cast("unsigned int") @NoOffset int _status_finalized(); public native PyThreadState _status_finalized(int setter); + + /* padding to align to 4 bytes */ + + + public native int py_recursion_remaining(); public native PyThreadState py_recursion_remaining(int setter); + public native int py_recursion_limit(); public native PyThreadState py_recursion_limit(int setter); + + public native int c_recursion_remaining(); public native PyThreadState c_recursion_remaining(int setter); public native int recursion_headroom(); public native PyThreadState recursion_headroom(int setter); /* Allow 50 more calls to handle any errors. */ /* 'tracing' keeps track of the execution depth when tracing/profiling. This is to prevent the actual trace/profile code from being recorded in the trace/profile. */ public native int tracing(); public native PyThreadState tracing(int setter); - public native int tracing_what(); public native PyThreadState tracing_what(int setter); /* The event currently being traced, if any. */ + public native int what_event(); public native PyThreadState what_event(int setter); /* The event currently being monitored, if any. */ /* Pointer to current _PyCFrame in the C stack frame of the currently, * or most recently, executing _PyEval_EvalFrameDefault. */ @@ -64,9 +80,7 @@ public class PyThreadState extends Pointer { public native PyObject c_traceobj(); public native PyThreadState c_traceobj(PyObject setter); /* The exception currently being raised */ - public native PyObject curexc_type(); public native PyThreadState curexc_type(PyObject setter); - public native PyObject curexc_value(); public native PyThreadState curexc_value(PyObject setter); - public native PyObject curexc_traceback(); public native PyThreadState curexc_traceback(PyObject setter); + public native PyObject current_exception(); public native PyThreadState current_exception(PyObject setter); /* Pointer to the top of the exception stack for the exceptions * we may be currently handling. (See _PyErr_StackItem above.) @@ -86,8 +100,7 @@ public class PyThreadState extends Pointer { */ public native @Cast("unsigned long") long native_thread_id(); public native PyThreadState native_thread_id(long setter); - public native int trash_delete_nesting(); public native PyThreadState trash_delete_nesting(int setter); - public native PyObject trash_delete_later(); public native PyThreadState trash_delete_later(PyObject setter); + public native @ByRef _py_trashcan trash(); public native PyThreadState trash(_py_trashcan setter); /* Called when a thread state is deleted normally, but not when it * is destroyed after fork(). @@ -134,8 +147,6 @@ public static class On_delete_Pointer extends FunctionPointer { /* Unique thread state id. */ public native @Cast("uint64_t") long id(); public native PyThreadState id(long setter); - public native @ByRef PyTraceInfo trace_info(); public native PyThreadState trace_info(PyTraceInfo setter); - public native _PyStackChunk datastack_chunk(); public native PyThreadState datastack_chunk(_PyStackChunk setter); public native PyObject datastack_top(int i); public native PyThreadState datastack_top(int i, PyObject setter); public native @Cast("PyObject**") PointerPointer datastack_top(); public native PyThreadState datastack_top(PointerPointer setter); diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyTraceInfo.java b/cpython/src/gen/java/org/bytedeco/cpython/PyTraceInfo.java deleted file mode 100644 index 14a43497b7e..00000000000 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyTraceInfo.java +++ /dev/null @@ -1,35 +0,0 @@ -// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE - -package org.bytedeco.cpython; - -import java.nio.*; -import org.bytedeco.javacpp.*; -import org.bytedeco.javacpp.annotation.*; - -import static org.bytedeco.javacpp.presets.javacpp.*; - -import static org.bytedeco.cpython.global.python.*; - - - -@Properties(inherit = org.bytedeco.cpython.presets.python.class) -public class PyTraceInfo extends Pointer { - static { Loader.load(); } - /** Default native constructor. */ - public PyTraceInfo() { super((Pointer)null); allocate(); } - /** Native array allocator. Access with {@link Pointer#position(long)}. */ - public PyTraceInfo(long size) { super((Pointer)null); allocateArray(size); } - /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public PyTraceInfo(Pointer p) { super(p); } - private native void allocate(); - private native void allocateArray(long size); - @Override public PyTraceInfo position(long position) { - return (PyTraceInfo)super.position(position); - } - @Override public PyTraceInfo getPointer(long i) { - return new PyTraceInfo((Pointer)this).offsetAddress(i); - } - - public native PyCodeObject code(); public native PyTraceInfo code(PyCodeObject setter); // The code object for the bounds. May be NULL. - public native @ByRef PyCodeAddressRange bounds(); public native PyTraceInfo bounds(PyCodeAddressRange setter); // Only valid if code != NULL. -} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyTypeObject.java b/cpython/src/gen/java/org/bytedeco/cpython/PyTypeObject.java index 340032c4ea1..de928b9195c 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyTypeObject.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyTypeObject.java @@ -103,9 +103,9 @@ or tp_reserved (Python 3) */ public native inquiry tp_is_gc(); public native PyTypeObject tp_is_gc(inquiry setter); /* For PyObject_IS_GC */ public native PyObject tp_bases(); public native PyTypeObject tp_bases(PyObject setter); public native PyObject tp_mro(); public native PyTypeObject tp_mro(PyObject setter); /* method resolution order */ - public native PyObject tp_cache(); public native PyTypeObject tp_cache(PyObject setter); - public native PyObject tp_subclasses(); public native PyTypeObject tp_subclasses(PyObject setter); - public native PyObject tp_weaklist(); public native PyTypeObject tp_weaklist(PyObject setter); + public native PyObject tp_cache(); public native PyTypeObject tp_cache(PyObject setter); /* no longer used */ + public native Pointer tp_subclasses(); public native PyTypeObject tp_subclasses(Pointer setter); /* for static builtin types this is an index */ + public native PyObject tp_weaklist(); public native PyTypeObject tp_weaklist(PyObject setter); /* not used for static builtin types */ public native destructor tp_del(); public native PyTypeObject tp_del(destructor setter); /* Type attribute cache version tag. Added in version 2.6 */ @@ -113,4 +113,7 @@ or tp_reserved (Python 3) */ public native destructor tp_finalize(); public native PyTypeObject tp_finalize(destructor setter); public native vectorcallfunc tp_vectorcall(); public native PyTypeObject tp_vectorcall(vectorcallfunc setter); + + /* bitset of which type-watchers care about this type */ + public native @Cast("unsigned char") byte tp_watched(); public native PyTypeObject tp_watched(byte setter); } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyType_Slot.java b/cpython/src/gen/java/org/bytedeco/cpython/PyType_Slot.java index 074a276d065..04f0ef0c896 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyType_Slot.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyType_Slot.java @@ -10,6 +10,7 @@ import static org.bytedeco.cpython.global.python.*; +// #endif @Properties(inherit = org.bytedeco.cpython.presets.python.class) public class PyType_Slot extends Pointer { diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyType_WatchCallback.java b/cpython/src/gen/java/org/bytedeco/cpython/PyType_WatchCallback.java new file mode 100644 index 00000000000..ccbdba86264 --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyType_WatchCallback.java @@ -0,0 +1,22 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class PyType_WatchCallback extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public PyType_WatchCallback(Pointer p) { super(p); } + protected PyType_WatchCallback() { allocate(); } + private native void allocate(); + public native int call(PyTypeObject arg0); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/PyUnicodeObject.java b/cpython/src/gen/java/org/bytedeco/cpython/PyUnicodeObject.java index 24a92df912c..a6b8acd1d93 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/PyUnicodeObject.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/PyUnicodeObject.java @@ -11,9 +11,7 @@ import static org.bytedeco.cpython.global.python.*; -/* Strings allocated through PyUnicode_FromUnicode(NULL, len) use the - PyUnicodeObject structure. The actual string data is initially in the wstr - block, and copied into the data block using _PyUnicode_Ready. */ +/* Object format for Unicode subclasses. */ @Properties(inherit = org.bytedeco.cpython.presets.python.class) public class PyUnicodeObject extends Pointer { static { Loader.load(); } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/Py_tracefunc.java b/cpython/src/gen/java/org/bytedeco/cpython/Py_tracefunc.java index f699cb531c5..282ccee6e2c 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/Py_tracefunc.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/Py_tracefunc.java @@ -11,6 +11,7 @@ import static org.bytedeco.cpython.global.python.*; + /* State unique per thread */ /* Py_tracefunc return -1 when raising an exception, or 0 for success. */ diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_PyCFrame.java b/cpython/src/gen/java/org/bytedeco/cpython/_PyCFrame.java index 5dd57de8e1a..51ef44f9453 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/_PyCFrame.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/_PyCFrame.java @@ -41,7 +41,6 @@ public class _PyCFrame extends Pointer { * discipline and make sure that instances of this struct cannot * accessed outside of their lifetime. */ - public native @Cast("uint8_t") byte use_tracing(); public native _PyCFrame use_tracing(byte setter); // 0 or 255 (or'ed into opcode, hence 8-bit type) /* Pointer to the currently executing frame (it can be NULL) */ public native @Cast("_PyInterpreterFrame*") Pointer current_frame(); public native _PyCFrame current_frame(Pointer setter); public native _PyCFrame previous(); public native _PyCFrame previous(_PyCFrame setter); diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_PyCoCached.java b/cpython/src/gen/java/org/bytedeco/cpython/_PyCoCached.java new file mode 100644 index 00000000000..bd6202c2db0 --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/_PyCoCached.java @@ -0,0 +1,37 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + + +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class _PyCoCached extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public _PyCoCached() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public _PyCoCached(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public _PyCoCached(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public _PyCoCached position(long position) { + return (_PyCoCached)super.position(position); + } + @Override public _PyCoCached getPointer(long i) { + return new _PyCoCached((Pointer)this).offsetAddress(i); + } + + public native PyObject _co_code(); public native _PyCoCached _co_code(PyObject setter); + public native PyObject _co_varnames(); public native _PyCoCached _co_varnames(PyObject setter); + public native PyObject _co_cellvars(); public native _PyCoCached _co_cellvars(PyObject setter); + public native PyObject _co_freevars(); public native _PyCoCached _co_freevars(PyObject setter); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_PyCoLineInstrumentationData.java b/cpython/src/gen/java/org/bytedeco/cpython/_PyCoLineInstrumentationData.java new file mode 100644 index 00000000000..e11f2cda972 --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/_PyCoLineInstrumentationData.java @@ -0,0 +1,37 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +/* Ancilliary data structure used for instrumentation. + Line instrumentation creates an array of + these. One entry per code unit.*/ +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class _PyCoLineInstrumentationData extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public _PyCoLineInstrumentationData() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public _PyCoLineInstrumentationData(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public _PyCoLineInstrumentationData(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public _PyCoLineInstrumentationData position(long position) { + return (_PyCoLineInstrumentationData)super.position(position); + } + @Override public _PyCoLineInstrumentationData getPointer(long i) { + return new _PyCoLineInstrumentationData((Pointer)this).offsetAddress(i); + } + + public native @Cast("uint8_t") byte original_opcode(); public native _PyCoLineInstrumentationData original_opcode(byte setter); + public native byte line_delta(); public native _PyCoLineInstrumentationData line_delta(byte setter); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_PyCoMonitoringData.java b/cpython/src/gen/java/org/bytedeco/cpython/_PyCoMonitoringData.java new file mode 100644 index 00000000000..e64b6d63ec3 --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/_PyCoMonitoringData.java @@ -0,0 +1,50 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +/* Main data structure used for instrumentation. + * This is allocated when needed for instrumentation + */ +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class _PyCoMonitoringData extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public _PyCoMonitoringData() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public _PyCoMonitoringData(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public _PyCoMonitoringData(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public _PyCoMonitoringData position(long position) { + return (_PyCoMonitoringData)super.position(position); + } + @Override public _PyCoMonitoringData getPointer(long i) { + return new _PyCoMonitoringData((Pointer)this).offsetAddress(i); + } + + /* Monitoring specific to this code object */ + public native @ByRef _Py_LocalMonitors local_monitors(); public native _PyCoMonitoringData local_monitors(_Py_LocalMonitors setter); + /* Monitoring that is active on this code object */ + public native @ByRef _Py_LocalMonitors active_monitors(); public native _PyCoMonitoringData active_monitors(_Py_LocalMonitors setter); + /* The tools that are to be notified for events for the matching code unit */ + public native @Cast("uint8_t*") BytePointer tools(); public native _PyCoMonitoringData tools(BytePointer setter); + /* Information to support line events */ + public native _PyCoLineInstrumentationData lines(); public native _PyCoMonitoringData lines(_PyCoLineInstrumentationData setter); + /* The tools that are to be notified for line events for the matching code unit */ + public native @Cast("uint8_t*") BytePointer line_tools(); public native _PyCoMonitoringData line_tools(BytePointer setter); + /* Information to support instruction events */ + /* The underlying instructions, which can themselves be instrumented */ + public native @Cast("uint8_t*") BytePointer per_instruction_opcodes(); public native _PyCoMonitoringData per_instruction_opcodes(BytePointer setter); + /* The tools that are to be notified for instruction events for the matching code unit */ + public native @Cast("uint8_t*") BytePointer per_instruction_tools(); public native _PyCoMonitoringData per_instruction_tools(BytePointer setter); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_PyCompilerSrcLocation.java b/cpython/src/gen/java/org/bytedeco/cpython/_PyCompilerSrcLocation.java new file mode 100644 index 00000000000..08e2f7b39bf --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/_PyCompilerSrcLocation.java @@ -0,0 +1,37 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +/* source location information */ +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class _PyCompilerSrcLocation extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public _PyCompilerSrcLocation() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public _PyCompilerSrcLocation(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public _PyCompilerSrcLocation(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public _PyCompilerSrcLocation position(long position) { + return (_PyCompilerSrcLocation)super.position(position); + } + @Override public _PyCompilerSrcLocation getPointer(long i) { + return new _PyCompilerSrcLocation((Pointer)this).offsetAddress(i); + } + + public native int lineno(); public native _PyCompilerSrcLocation lineno(int setter); + public native int end_lineno(); public native _PyCompilerSrcLocation end_lineno(int setter); + public native int col_offset(); public native _PyCompilerSrcLocation col_offset(int setter); + public native int end_col_offset(); public native _PyCompilerSrcLocation end_col_offset(int setter); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_PyLongValue.java b/cpython/src/gen/java/org/bytedeco/cpython/_PyLongValue.java new file mode 100644 index 00000000000..f37f6780e66 --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/_PyLongValue.java @@ -0,0 +1,53 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +/* Long integer representation. + The absolute value of a number is equal to + SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i) + Negative numbers are represented with ob_size < 0; + zero is represented by ob_size == 0. + In a normalized number, ob_digit[abs(ob_size)-1] (the most significant + digit) is never zero. Also, in all cases, for all valid i, + 0 <= ob_digit[i] <= MASK. + The allocation function takes care of allocating extra memory + so that ob_digit[0] ... ob_digit[abs(ob_size)-1] are actually available. + We always allocate memory for at least one digit, so accessing ob_digit[0] + is always safe. However, in the case ob_size == 0, the contents of + ob_digit[0] may be undefined. + + CAUTION: Generic code manipulating subtypes of PyVarObject has to + aware that ints abuse ob_size's sign bit. +*/ + +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class _PyLongValue extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public _PyLongValue() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public _PyLongValue(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public _PyLongValue(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public _PyLongValue position(long position) { + return (_PyLongValue)super.position(position); + } + @Override public _PyLongValue getPointer(long i) { + return new _PyLongValue((Pointer)this).offsetAddress(i); + } + + public native @Cast("uintptr_t") long lv_tag(); public native _PyLongValue lv_tag(long setter); /* Number of digits, sign and flags */ + public native @Cast("digit") int ob_digit(int i); public native _PyLongValue ob_digit(int i, int setter); + @MemberGetter public native @Cast("digit*") IntPointer ob_digit(); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_PyManagedBufferObject.java b/cpython/src/gen/java/org/bytedeco/cpython/_PyManagedBufferObject.java deleted file mode 100644 index 9acaf8c1ec7..00000000000 --- a/cpython/src/gen/java/org/bytedeco/cpython/_PyManagedBufferObject.java +++ /dev/null @@ -1,35 +0,0 @@ -// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE - -package org.bytedeco.cpython; - -import java.nio.*; -import org.bytedeco.javacpp.*; -import org.bytedeco.javacpp.annotation.*; - -import static org.bytedeco.javacpp.presets.javacpp.*; - -import static org.bytedeco.cpython.global.python.*; - /* free format */ -@Properties(inherit = org.bytedeco.cpython.presets.python.class) -public class _PyManagedBufferObject extends Pointer { - static { Loader.load(); } - /** Default native constructor. */ - public _PyManagedBufferObject() { super((Pointer)null); allocate(); } - /** Native array allocator. Access with {@link Pointer#position(long)}. */ - public _PyManagedBufferObject(long size) { super((Pointer)null); allocateArray(size); } - /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public _PyManagedBufferObject(Pointer p) { super(p); } - private native void allocate(); - private native void allocateArray(long size); - @Override public _PyManagedBufferObject position(long position) { - return (_PyManagedBufferObject)super.position(position); - } - @Override public _PyManagedBufferObject getPointer(long i) { - return new _PyManagedBufferObject((Pointer)this).offsetAddress(i); - } - - public native @ByRef PyObject ob_base(); public native _PyManagedBufferObject ob_base(PyObject setter); - public native int flags(); public native _PyManagedBufferObject flags(int setter); /* state flags */ - public native @Cast("Py_ssize_t") long exports(); public native _PyManagedBufferObject exports(long setter); /* number of direct memoryview exports */ - public native @ByRef Py_buffer master(); public native _PyManagedBufferObject master(Py_buffer setter); /* snapshot buffer obtained from the original exporter */ -} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_PyUnicodeWriter.java b/cpython/src/gen/java/org/bytedeco/cpython/_PyUnicodeWriter.java index 2d1d531c9c0..58932d55d59 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/_PyUnicodeWriter.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/_PyUnicodeWriter.java @@ -10,9 +10,6 @@ import static org.bytedeco.cpython.global.python.*; -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif - /* --- _PyUnicodeWriter API ----------------------------------------------- */ @@ -36,7 +33,7 @@ public class _PyUnicodeWriter extends Pointer { public native PyObject buffer(); public native _PyUnicodeWriter buffer(PyObject setter); public native Pointer data(); public native _PyUnicodeWriter data(Pointer setter); - public native @Cast("PyUnicode_Kind") int kind(); public native _PyUnicodeWriter kind(int setter); + public native int kind(); public native _PyUnicodeWriter kind(int setter); public native @Cast("Py_UCS4") int maxchar(); public native _PyUnicodeWriter maxchar(int setter); public native @Cast("Py_ssize_t") long size(); public native _PyUnicodeWriter size(long setter); public native @Cast("Py_ssize_t") long pos(); public native _PyUnicodeWriter pos(long setter); diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_Py_CODEUNIT.java b/cpython/src/gen/java/org/bytedeco/cpython/_Py_CODEUNIT.java new file mode 100644 index 00000000000..21e53ee263a --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/_Py_CODEUNIT.java @@ -0,0 +1,44 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +/* Each instruction in a code object is a fixed-width value, + * currently 2 bytes: 1-byte opcode + 1-byte oparg. The EXTENDED_ARG + * opcode allows for larger values but the current limit is 3 uses + * of EXTENDED_ARG (see Python/compile.c), for a maximum + * 32-bit value. This aligns with the note in Python/compile.c + * (compiler_addop_i_line) indicating that the max oparg value is + * 2**32 - 1, rather than INT_MAX. + */ + +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class _Py_CODEUNIT extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public _Py_CODEUNIT() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public _Py_CODEUNIT(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public _Py_CODEUNIT(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public _Py_CODEUNIT position(long position) { + return (_Py_CODEUNIT)super.position(position); + } + @Override public _Py_CODEUNIT getPointer(long i) { + return new _Py_CODEUNIT((Pointer)this).offsetAddress(i); + } + + public native @Cast("uint16_t") short cache(); public native _Py_CODEUNIT cache(short setter); + @Name("op.code") public native @Cast("uint8_t") byte op_code(); public native _Py_CODEUNIT op_code(byte setter); + @Name("op.arg") public native @Cast("uint8_t") byte op_arg(); public native _Py_CODEUNIT op_arg(byte setter); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_Py_GlobalMonitors.java b/cpython/src/gen/java/org/bytedeco/cpython/_Py_GlobalMonitors.java new file mode 100644 index 00000000000..57d375394d3 --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/_Py_GlobalMonitors.java @@ -0,0 +1,34 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class _Py_GlobalMonitors extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public _Py_GlobalMonitors() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public _Py_GlobalMonitors(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public _Py_GlobalMonitors(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public _Py_GlobalMonitors position(long position) { + return (_Py_GlobalMonitors)super.position(position); + } + @Override public _Py_GlobalMonitors getPointer(long i) { + return new _Py_GlobalMonitors((Pointer)this).offsetAddress(i); + } + + public native @Cast("uint8_t") byte tools(int i); public native _Py_GlobalMonitors tools(int i, byte setter); + @MemberGetter public native @Cast("uint8_t*") BytePointer tools(); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_Py_LocalMonitors.java b/cpython/src/gen/java/org/bytedeco/cpython/_Py_LocalMonitors.java new file mode 100644 index 00000000000..dbb1eb26149 --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/_Py_LocalMonitors.java @@ -0,0 +1,37 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +/* Tables of which tools are active for each monitored event. */ +/* For 3.12 ABI compatibility this is over sized */ +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class _Py_LocalMonitors extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public _Py_LocalMonitors() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public _Py_LocalMonitors(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public _Py_LocalMonitors(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public _Py_LocalMonitors position(long position) { + return (_Py_LocalMonitors)super.position(position); + } + @Override public _Py_LocalMonitors getPointer(long i) { + return new _Py_LocalMonitors((Pointer)this).offsetAddress(i); + } + + /* Only _PY_MONITORING_LOCAL_EVENTS of these are used */ + public native @Cast("uint8_t") byte tools(int i); public native _Py_LocalMonitors tools(int i, byte setter); + @MemberGetter public native @Cast("uint8_t*") BytePointer tools(); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_longobject.java b/cpython/src/gen/java/org/bytedeco/cpython/_longobject.java index 9615e80657f..ea9b16f2a1f 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/_longobject.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/_longobject.java @@ -11,24 +11,6 @@ import static org.bytedeco.cpython.global.python.*; -/* Long integer representation. - The absolute value of a number is equal to - SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i) - Negative numbers are represented with ob_size < 0; - zero is represented by ob_size == 0. - In a normalized number, ob_digit[abs(ob_size)-1] (the most significant - digit) is never zero. Also, in all cases, for all valid i, - 0 <= ob_digit[i] <= MASK. - The allocation function takes care of allocating extra memory - so that ob_digit[0] ... ob_digit[abs(ob_size)-1] are actually available. - We always allocate memory for at least one digit, so accessing ob_digit[0] - is always safe. However, in the case ob_size == 0, the contents of - ob_digit[0] may be undefined. - - CAUTION: Generic code manipulating subtypes of PyVarObject has to - aware that ints abuse ob_size's sign bit. -*/ - @Properties(inherit = org.bytedeco.cpython.presets.python.class) public class _longobject extends Pointer { static { Loader.load(); } @@ -47,7 +29,6 @@ public class _longobject extends Pointer { return new _longobject((Pointer)this).offsetAddress(i); } - public native @ByRef PyVarObject ob_base(); public native _longobject ob_base(PyVarObject setter); - public native @Cast("digit") int ob_digit(int i); public native _longobject ob_digit(int i, int setter); - @MemberGetter public native @Cast("digit*") IntPointer ob_digit(); + public native @ByRef PyObject ob_base(); public native _longobject ob_base(PyObject setter); + public native @ByRef _PyLongValue long_value(); public native _longobject long_value(_PyLongValue setter); } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_object.java b/cpython/src/gen/java/org/bytedeco/cpython/_object.java index 5670bf28c3e..f7ee7deefb9 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/_object.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/_object.java @@ -34,6 +34,19 @@ public class _object extends Pointer { return new _object((Pointer)this).offsetAddress(i); } - public native @Cast("Py_ssize_t") long ob_refcnt(); public native _object ob_refcnt(long setter); +// #if (defined(__GNUC__) || defined(__clang__)) +// && !(defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) + // On C99 and older, anonymous union is a GCC and clang extension +// #endif +// #ifdef _MSC_VER + // Ignore MSC warning C4201: "nonstandard extension used: + // nameless struct/union" +// #endif + public native @Cast("Py_ssize_t") long ob_refcnt(); public native _object ob_refcnt(long setter); +// #if SIZEOF_VOID_P > 4 + public native @Cast("uint32_t") int ob_refcnt_split(int i); public native _object ob_refcnt_split(int i, int setter); + @MemberGetter public native @Cast("uint32_t*") IntPointer ob_refcnt_split(); +// #endif +// #ifdef _MSC_VER public native PyTypeObject ob_type(); public native _object ob_type(PyTypeObject setter); } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_py_trashcan.java b/cpython/src/gen/java/org/bytedeco/cpython/_py_trashcan.java new file mode 100644 index 00000000000..d4173c78ad9 --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/_py_trashcan.java @@ -0,0 +1,34 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class _py_trashcan extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public _py_trashcan() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public _py_trashcan(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public _py_trashcan(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public _py_trashcan position(long position) { + return (_py_trashcan)super.position(position); + } + @Override public _py_trashcan getPointer(long i) { + return new _py_trashcan((Pointer)this).offsetAddress(i); + } + + public native int delete_nesting(); public native _py_trashcan delete_nesting(int setter); + public native PyObject delete_later(); public native _py_trashcan delete_later(PyObject setter); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_specialization_cache.java b/cpython/src/gen/java/org/bytedeco/cpython/_specialization_cache.java index d0c41bdfa79..8c4d7213fc6 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/_specialization_cache.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/_specialization_cache.java @@ -32,5 +32,16 @@ public class _specialization_cache extends Pointer { return new _specialization_cache((Pointer)this).offsetAddress(i); } + // In order to avoid bloating the bytecode with lots of inline caches, the + // members of this structure have a somewhat unique contract. They are set + // by the specialization machinery, and are invalidated by PyType_Modified. + // The rules for using them are as follows: + // - If getitem is non-NULL, then it is the same Python function that + // PyType_Lookup(cls, "__getitem__") would return. + // - If getitem is NULL, then getitem_version is meaningless. + // - If getitem->func_version == getitem_version, then getitem can be called + // with two positional arguments and no keyword arguments, and has neither + // *args nor **kwargs (as required by BINARY_SUBSCR_GETITEM): public native PyObject getitem(); public native _specialization_cache getitem(PyObject setter); + public native @Cast("uint32_t") int getitem_version(); public native _specialization_cache getitem_version(int setter); } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/_xid.java b/cpython/src/gen/java/org/bytedeco/cpython/_xid.java index d131f64a057..e2685fd1a0f 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/_xid.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/_xid.java @@ -54,15 +54,7 @@ public class _xid extends Pointer { // interpreter given the data. The resulting object (a new // reference) will be equivalent to the original object. This field // is required. - public static class New_object__PyCrossInterpreterData extends FunctionPointer { - static { Loader.load(); } - /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public New_object__PyCrossInterpreterData(Pointer p) { super(p); } - protected New_object__PyCrossInterpreterData() { allocate(); } - private native void allocate(); - public native PyObject call(_PyCrossInterpreterData arg0); - } - public native New_object__PyCrossInterpreterData new_object(); public native _xid new_object(New_object__PyCrossInterpreterData setter); + public native xid_newobjectfunc new_object(); public native _xid new_object(xid_newobjectfunc setter); // free is called when the data is released. If it is NULL then // nothing will be done to free the data. For some types this is // okay (e.g. bytes) and for those types this field should be set @@ -72,13 +64,5 @@ public static class New_object__PyCrossInterpreterData extends FunctionPointer { // leak. In that case, at the very least this field should be set // to PyMem_RawFree (the default if not explicitly set to NULL). // The call will happen with the original interpreter activated. - public static class Free_Pointer extends FunctionPointer { - static { Loader.load(); } - /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public Free_Pointer(Pointer p) { super(p); } - protected Free_Pointer() { allocate(); } - private native void allocate(); - public native void call(Pointer arg0); - } - public native @Name("free") Free_Pointer _free(); public native _xid _free(Free_Pointer setter); + public native @Name("free") xid_freefunc _free(); public native _xid _free(xid_freefunc setter); } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/atexit_datacallbackfunc.java b/cpython/src/gen/java/org/bytedeco/cpython/atexit_datacallbackfunc.java new file mode 100644 index 00000000000..d6a02c7c916 --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/atexit_datacallbackfunc.java @@ -0,0 +1,22 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class atexit_datacallbackfunc extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public atexit_datacallbackfunc(Pointer p) { super(p); } + protected atexit_datacallbackfunc() { allocate(); } + private native void allocate(); + public native void call(Pointer arg0); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/crossinterpdatafunc.java b/cpython/src/gen/java/org/bytedeco/cpython/crossinterpdatafunc.java index f398303f9ae..7f7a1b74006 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/crossinterpdatafunc.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/crossinterpdatafunc.java @@ -20,5 +20,6 @@ public class crossinterpdatafunc extends FunctionPointer { public crossinterpdatafunc(Pointer p) { super(p); } protected crossinterpdatafunc() { allocate(); } private native void allocate(); - public native int call(PyObject arg0, _PyCrossInterpreterData arg1); + public native int call(PyThreadState tstate, PyObject arg1, + _PyCrossInterpreterData arg2); } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/gcvisitobjects_t.java b/cpython/src/gen/java/org/bytedeco/cpython/gcvisitobjects_t.java new file mode 100644 index 00000000000..baa22132538 --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/gcvisitobjects_t.java @@ -0,0 +1,37 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + + +// #if !defined(Py_LIMITED_API) +/* Visit all live GC-capable objects, similar to gc.get_objects(None). The + * supplied callback is called on every such object with the void* arg set + * to the supplied arg. Returning 0 from the callback ends iteration, returning + * 1 allows iteration to continue. Returning any other value may result in + * undefined behaviour. + * + * If new objects are (de)allocated by the callback it is undefined if they + * will be visited. + + * Garbage collection is disabled during operation. Explicitly running a + * collection in the callback may lead to undefined behaviour e.g. visiting the + * same objects multiple times or not at all. + */ +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class gcvisitobjects_t extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public gcvisitobjects_t(Pointer p) { super(p); } + protected gcvisitobjects_t() { allocate(); } + private native void allocate(); + public native int call(PyObject arg0, Pointer arg1); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/getbufferproc.java b/cpython/src/gen/java/org/bytedeco/cpython/getbufferproc.java index 654a27f722b..7d7aeb07e33 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/getbufferproc.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/getbufferproc.java @@ -11,8 +11,6 @@ import static org.bytedeco.cpython.global.python.*; -// #endif /* NEEDS_PY_IDENTIFIER */ - @Properties(inherit = org.bytedeco.cpython.presets.python.class) public class getbufferproc extends FunctionPointer { static { Loader.load(); } diff --git a/cpython/src/gen/java/org/bytedeco/cpython/global/python.java b/cpython/src/gen/java/org/bytedeco/cpython/global/python.java index 779cd000c83..d1058ef733d 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/global/python.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/global/python.java @@ -143,13 +143,13 @@ There is also (independent) API version information in modsupport.h. /* Version parsed out into numeric values */ /*--start constants--*/ public static final int PY_MAJOR_VERSION = 3; -public static final int PY_MINOR_VERSION = 11; -public static final int PY_MICRO_VERSION = 5; +public static final int PY_MINOR_VERSION = 12; +public static final int PY_MICRO_VERSION = 0; public static final int PY_RELEASE_LEVEL = PY_RELEASE_LEVEL_FINAL; public static final int PY_RELEASE_SERIAL = 0; /* Version as a string */ -public static final String PY_VERSION = "3.11.5"; +public static final String PY_VERSION = "3.12.0"; /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. @@ -185,6 +185,9 @@ There is also (independent) API version information in modsupport.h. /* The normal alignment of `long', in bytes. */ public static final int ALIGNOF_LONG = 8; +/* The normal alignment of `max_align_t', in bytes. */ +public static final int ALIGNOF_MAX_ALIGN_T = 16; + /* The normal alignment of `size_t', in bytes. */ public static final int ALIGNOF_SIZE_T = 8; @@ -468,6 +471,9 @@ There is also (independent) API version information in modsupport.h. /* Defined when any dynamic module loading is enabled. */ public static final int HAVE_DYNAMIC_LOADING = 1; +/* Define to 1 if you have the header file. */ +/* #undef HAVE_EDITLINE_READLINE_H */ + /* Define to 1 if you have the header file. */ public static final int HAVE_ENDIAN_H = 1; @@ -534,6 +540,15 @@ There is also (independent) API version information in modsupport.h. /* Define to 1 if you have the `fexecve' function. */ public static final int HAVE_FEXECVE = 1; +/* Define if you have the 'ffi_closure_alloc' function. */ +public static final int HAVE_FFI_CLOSURE_ALLOC = 1; + +/* Define if you have the 'ffi_prep_cif_var' function. */ +public static final int HAVE_FFI_PREP_CIF_VAR = 1; + +/* Define if you have the 'ffi_prep_closure_loc' function. */ +public static final int HAVE_FFI_PREP_CLOSURE_LOC = 1; + /* Define to 1 if you have the `flock' function. */ public static final int HAVE_FLOCK = 1; @@ -830,21 +845,12 @@ There is also (independent) API version information in modsupport.h. /* Define to 1 if you have the `dld' library (-ldld). */ /* #undef HAVE_LIBDLD */ -/* Define to 1 if you have the `gdbm_compat' library (-lgdbm_compat). */ -public static final int HAVE_LIBGDBM_COMPAT = 1; - /* Define to 1 if you have the `ieee' library (-lieee). */ /* #undef HAVE_LIBIEEE */ /* Define to 1 if you have the header file. */ public static final int HAVE_LIBINTL_H = 1; -/* Define to 1 if you have the `ndbm' library (-lndbm). */ -/* #undef HAVE_LIBNDBM */ - -/* Define to build the readline module. */ -/* #undef HAVE_LIBREADLINE */ - /* Define to 1 if you have the `resolv' library (-lresolv). */ /* #undef HAVE_LIBRESOLV */ @@ -884,6 +890,9 @@ There is also (independent) API version information in modsupport.h. /* Define if compiling using Linux 4.1 or later. */ public static final int HAVE_LINUX_CAN_RAW_JOIN_FILTERS = 1; +/* Define to 1 if you have the header file. */ +public static final int HAVE_LINUX_FS_H = 1; + /* Define to 1 if you have the header file. */ public static final int HAVE_LINUX_LIMITS_H = 1; @@ -950,12 +959,12 @@ There is also (independent) API version information in modsupport.h. /* Define if you have the 'memfd_create' function. */ public static final int HAVE_MEMFD_CREATE = 1; -/* Define to 1 if you have the header file. */ -public static final int HAVE_MEMORY_H = 1; - /* Define to 1 if you have the `memrchr' function. */ public static final int HAVE_MEMRCHR = 1; +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MINIX_CONFIG_H */ + /* Define to 1 if you have the `mkdirat' function. */ public static final int HAVE_MKDIRAT = 1; @@ -983,6 +992,9 @@ There is also (independent) API version information in modsupport.h. /* Define to 1 if you have the `nanosleep' function. */ public static final int HAVE_NANOSLEEP = 1; +/* Define to 1 if you have the `ncursesw' library. */ +/* #undef HAVE_NCURSESW */ + /* Define to 1 if you have the header file. */ /* #undef HAVE_NCURSES_H */ @@ -1004,6 +1016,9 @@ There is also (independent) API version information in modsupport.h. /* Define to 1 if you have the header file. */ public static final int HAVE_NETPACKET_PACKET_H = 1; +/* Define to 1 if you have the header file. */ +public static final int HAVE_NET_ETHERNET_H = 1; + /* Define to 1 if you have the header file. */ public static final int HAVE_NET_IF_H = 1; @@ -1023,6 +1038,9 @@ There is also (independent) API version information in modsupport.h. /* Define to 1 if you have the `openpty' function. */ public static final int HAVE_OPENPTY = 1; +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PANEL_H */ + /* Define to 1 if you have the `pathconf' function. */ public static final int HAVE_PATHCONF = 1; @@ -1110,6 +1128,9 @@ There is also (independent) API version information in modsupport.h. /* Define to 1 if you have the `pwritev2' function. */ public static final int HAVE_PWRITEV2 = 1; +/* Define to 1 if you have the header file. */ +/* #undef HAVE_READLINE_READLINE_H */ + /* Define to 1 if you have the `readlink' function. */ public static final int HAVE_READLINK = 1; @@ -1221,6 +1242,9 @@ There is also (independent) API version information in modsupport.h. /* Define to 1 if you have the `setlocale' function. */ public static final int HAVE_SETLOCALE = 1; +/* Define to 1 if you have the `setns' function. */ +public static final int HAVE_SETNS = 1; + /* Define to 1 if you have the `setpgid' function. */ public static final int HAVE_SETPGID = 1; @@ -1335,13 +1359,12 @@ There is also (independent) API version information in modsupport.h. /* Define if you have struct stat.st_mtimensec */ /* #undef HAVE_STAT_TV_NSEC2 */ -/* Define if your compiler supports variable length function prototypes (e.g. - void fprintf(FILE *, char *, ...);) *and* */ -public static final int HAVE_STDARG_PROTOTYPES = 1; - /* Define to 1 if you have the header file. */ public static final int HAVE_STDINT_H = 1; +/* Define to 1 if you have the header file. */ +public static final int HAVE_STDIO_H = 1; + /* Define to 1 if you have the header file. */ public static final int HAVE_STDLIB_H = 1; @@ -1595,6 +1618,9 @@ There is also (independent) API version information in modsupport.h. /* Define to 1 if you have the `unlinkat' function. */ public static final int HAVE_UNLINKAT = 1; +/* Define to 1 if you have the `unshare' function. */ +public static final int HAVE_UNSHARE = 1; + /* Define if you have a useable wchar_t type defined in wchar.h; useable means wchar_t must be an unsigned type with at least 16 bits. (see Include/unicodeobject.h). */ @@ -1721,13 +1747,13 @@ There is also (independent) API version information in modsupport.h. /* #undef PYLONG_BITS_IN_DIGIT */ /* enabled builtin hash modules */ -public static final String PY_BUILTIN_HASHLIB_HASHES = "md5,sha1,sha256,sha512,sha3,blake2"; +public static final String PY_BUILTIN_HASHLIB_HASHES = "md5,sha1,sha2,sha3,blake2"; /* Define if you want to coerce the C locale to a UTF-8 based locale */ public static final int PY_COERCE_C_LOCALE = 1; -/* Define to printf format modifier for Py_ssize_t */ -// #define PY_FORMAT_SIZE_T "z" +/* Define to 1 if you have the perf trampoline. */ +public static final int PY_HAVE_PERF_TRAMPOLINE = 1; /* Define to 1 to build the sqlite module with loadable extensions support. */ /* #undef PY_SQLITE_ENABLE_LOAD_EXTENSION */ @@ -1837,9 +1863,6 @@ There is also (independent) API version information in modsupport.h. /* Library needed by timemodule.c: librt may be needed for clock_gettime() */ /* #undef TIMEMODULE_LIB */ -/* Define to 1 if you can safely include both and . */ -public static final int TIME_WITH_SYS_TIME = 1; - /* Define to 1 if your declares `struct tm'. */ /* #undef TM_IN_SYS_TIME */ @@ -1850,21 +1873,87 @@ There is also (independent) API version information in modsupport.h. // #ifndef _ALL_SOURCE public static final int _ALL_SOURCE = 1; // #endif +/* Enable general extensions on macOS. */ +// #ifndef _DARWIN_C_SOURCE +public static final int _DARWIN_C_SOURCE = 1; +// #endif +/* Enable general extensions on Solaris. */ +// #ifndef __EXTENSIONS__ +public static final int __EXTENSIONS__ = 1; +// #endif /* Enable GNU extensions on systems that have them. */ // #ifndef _GNU_SOURCE public static final int _GNU_SOURCE = 1; // #endif -/* Enable threading extensions on Solaris. */ +/* Enable X/Open compliant socket functions that do not require linking + with -lxnet on HP-UX 11.11. */ +// #ifndef _HPUX_ALT_XOPEN_SOCKET_API +public static final int _HPUX_ALT_XOPEN_SOCKET_API = 1; +// #endif +/* Identify the host operating system as Minix. + This macro does not affect the system headers' behavior. + A future release of Autoconf may stop defining this macro. */ +// #ifndef _MINIX +/* # undef _MINIX */ +// #endif +/* Enable general extensions on NetBSD. + Enable NetBSD compatibility extensions on Minix. */ +// #ifndef _NETBSD_SOURCE +public static final int _NETBSD_SOURCE = 1; +// #endif +/* Enable OpenBSD compatibility extensions on NetBSD. + Oddly enough, this does nothing on OpenBSD. */ +// #ifndef _OPENBSD_SOURCE +public static final int _OPENBSD_SOURCE = 1; +// #endif +/* Define to 1 if needed for POSIX-compatible behavior. */ +// #ifndef _POSIX_SOURCE +/* # undef _POSIX_SOURCE */ +// #endif +/* Define to 2 if needed for POSIX-compatible behavior. */ +// #ifndef _POSIX_1_SOURCE +/* # undef _POSIX_1_SOURCE */ +// #endif +/* Enable POSIX-compatible threading on Solaris. */ // #ifndef _POSIX_PTHREAD_SEMANTICS public static final int _POSIX_PTHREAD_SEMANTICS = 1; // #endif +/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ +// #ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +public static final int __STDC_WANT_IEC_60559_ATTRIBS_EXT__ = 1; +// #endif +/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ +// #ifndef __STDC_WANT_IEC_60559_BFP_EXT__ +public static final int __STDC_WANT_IEC_60559_BFP_EXT__ = 1; +// #endif +/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ +// #ifndef __STDC_WANT_IEC_60559_DFP_EXT__ +public static final int __STDC_WANT_IEC_60559_DFP_EXT__ = 1; +// #endif +/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ +// #ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ +public static final int __STDC_WANT_IEC_60559_FUNCS_EXT__ = 1; +// #endif +/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */ +// #ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ +public static final int __STDC_WANT_IEC_60559_TYPES_EXT__ = 1; +// #endif +/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ +// #ifndef __STDC_WANT_LIB_EXT2__ +public static final int __STDC_WANT_LIB_EXT2__ = 1; +// #endif +/* Enable extensions specified by ISO/IEC 24747:2009. */ +// #ifndef __STDC_WANT_MATH_SPEC_FUNCS__ +public static final int __STDC_WANT_MATH_SPEC_FUNCS__ = 1; +// #endif /* Enable extensions on HP NonStop. */ // #ifndef _TANDEM_SOURCE public static final int _TANDEM_SOURCE = 1; // #endif -/* Enable general extensions on Solaris. */ -// #ifndef __EXTENSIONS__ -public static final int __EXTENSIONS__ = 1; +/* Enable X/Open extensions. Define to 500 only if necessary + to make mbstate_t available. */ +// #ifndef _XOPEN_SOURCE +public static final int _XOPEN_SOURCE = 700; // #endif @@ -1886,7 +1975,7 @@ There is also (independent) API version information in modsupport.h. Dyld is necessary to support frameworks. */ /* #undef WITH_DYLD */ -/* Define to build the readline module against Editline. */ +/* Define to build the readline module against libedit. */ /* #undef WITH_EDITLINE */ /* Define if you want to compile in object freelists optimization */ @@ -1923,7 +2012,6 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ /* #undef _BSD_SOURCE */ /* Define on Darwin to activate all library features */ -public static final int _DARWIN_C_SOURCE = 1; /* This must be set to 64 on some systems to enable large file support. */ public static final int _FILE_OFFSET_BITS = 64; @@ -1937,22 +2025,11 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ /* This must be defined on AIX systems to enable large file support. */ /* #undef _LARGE_FILES */ -/* Define to 1 if on MINIX. */ -/* #undef _MINIX */ - /* Define on NetBSD to activate all library features */ -public static final int _NETBSD_SOURCE = 1; - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -/* #undef _POSIX_1_SOURCE */ /* Define to activate features from IEEE Stds 1003.1-2008 */ public static final long _POSIX_C_SOURCE = 200809L; -/* Define to 1 if you need to in order for `stat' and other things to work. */ -/* #undef _POSIX_SOURCE */ - /* Define if you have POSIX threads, and your system does not define that. */ /* #undef _POSIX_THREADS */ @@ -1972,7 +2049,6 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ /* #undef _WASI_EMULATED_SIGNAL */ /* Define to the level of X/Open that your system supports */ -public static final int _XOPEN_SOURCE = 700; /* Define to activate Unix95-and-earlier features */ public static final int _XOPEN_SOURCE_EXTENDED = 1; @@ -1995,7 +2071,7 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ /* Define to `long int' if does not define. */ /* #undef off_t */ -/* Define to `int' if does not define. */ +/* Define as a signed integer type capable of holding a process identifier. */ /* #undef pid_t */ /* Define to empty if the keyword does not work. */ @@ -2089,18 +2165,6 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ // # define HAVE_GCC_ASM_FOR_X87 // #endif - /* - * The definition in pyconfig.h is only valid on the OS release - * where configure ran on and not necessarily for all systems where - * the executable can be used on. - * - * Specifically: OSX 10.4 has limited supported for '%zd', while - * 10.5 has full support for '%zd'. A binary built on 10.5 won't - * work properly on 10.4 unless we suppress the definition - * of PY_FORMAT_SIZE_T - */ -// #undef PY_FORMAT_SIZE_T - // #endif /* defined(_APPLE__) */ @@ -2263,32 +2327,10 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ /* Largest possible value of size_t. */ // #define PY_SIZE_MAX SIZE_MAX -/* Macro kept for backward compatibility: use "z" in new code. - * - * PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf - * format to convert an argument with the width of a size_t or Py_ssize_t. - * C99 introduced "z" for this purpose, but old MSVCs had not supported it. - * Since MSVC supports "z" since (at least) 2015, we can just use "z" - * for new code. - * - * These "high level" Python format functions interpret "z" correctly on - * all platforms (Python interprets the format string itself, and does whatever - * the platform C requires to convert a size_t/Py_ssize_t argument): - * - * PyBytes_FromFormat - * PyErr_Format - * PyBytes_FromFormatV - * PyUnicode_FromFormatV +/* Macro kept for backward compatibility: use directly "z" in new code. * - * Lower-level uses require that you interpolate the correct format modifier - * yourself (e.g., calling printf, fprintf, sprintf, PyOS_snprintf); for - * example, - * - * Py_ssize_t index; - * fprintf(stderr, "index %" PY_FORMAT_SIZE_T "d sucks\n", index); - * - * That will expand to %zd or to something else correct for a Py_ssize_t on - * the platform. + * PY_FORMAT_SIZE_T is a modifier for use in a printf format to convert an + * argument with the width of a size_t or Py_ssize_t: "z" (C99). */ // #ifndef PY_FORMAT_SIZE_T // # define PY_FORMAT_SIZE_T "z" @@ -2316,7 +2358,6 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ // # define Py_LOCAL_INLINE(type) static inline type // #endif -// bpo-28126: Py_MEMCPY is kept for backwards compatibility, // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 // #endif @@ -2377,6 +2418,10 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ // #define S_ISCHR(x) (((x) & S_IFMT) == S_IFCHR) // #endif +// #ifndef S_ISLNK +// #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK) +// #endif + // #ifdef __cplusplus /* Move this down here since some C++ #include's don't like to be included inside an extern "C" */ @@ -2445,6 +2490,14 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ // #define Py_DEPRECATED(VERSION_UNUSED) // #endif +// _Py_DEPRECATED_EXTERNALLY(version) +// Deprecated outside CPython core. +// #ifdef Py_BUILD_CORE +// #else +// #define _Py_DEPRECATED_EXTERNALLY(version) Py_DEPRECATED(version) +// #endif + + // #if defined(__clang__) // #define _Py_COMP_DIAG_PUSH _Pragma("clang diagnostic push") // #define _Py_COMP_DIAG_IGNORE_DEPR_DECLS @@ -2543,9 +2596,6 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ in platform-specific #ifdefs. **************************************************************************/ -// #ifdef SOLARIS -// #endif - // #ifdef HAVE__GETPTY // #endif @@ -2745,6 +2795,11 @@ linkage handling and it uses __declspec(). // #ifndef WITH_THREAD // #endif +// #ifdef WITH_THREAD +// # ifdef Py_BUILD_CORE +// # endif +// #endif + /* Check that ALT_SOABI is consistent with Py_TRACE_REFS: ./configure --with-trace-refs should must be used to define Py_TRACE_REFS */ // #if defined(ALT_SOABI) && defined(Py_TRACE_REFS) @@ -2793,6 +2848,15 @@ linkage handling and it uses __declspec(). // # define _Py__has_builtin(x) 0 // #endif +// _Py_TYPEOF(expr) gets the type of an expression. +// +// Example: _Py_TYPEOF(x) x_copy = (x); +// +// The macro is only defined if GCC or clang compiler is used. +// #if defined(__GNUC__) || defined(__clang__) +// # define _Py_TYPEOF(expr) __typeof__(expr) +// #endif + /* A convenient way for code to know if sanitizers are enabled. */ // #if defined(__has_feature) @@ -2812,6 +2876,22 @@ linkage handling and it uses __declspec(). // # endif // #endif + +/* AIX has __bool__ redefined in it's system header file. */ +// #if defined(_AIX) && defined(__bool__) +// #undef __bool__ +// #endif + +// Make sure we have maximum alignment, even if the current compiler +// does not support max_align_t. Note that: +// - Autoconf reports alignment of unknown types to 0. +// - 'long double' has maximum alignment on *most* platforms, +// looks like the best we can do for pre-C11 compilers. +// - The value is tested, see test_alignof_max_align_t +// #if !defined(ALIGNOF_MAX_ALIGN_T) || ALIGNOF_MAX_ALIGN_T == 0 +// # undef ALIGNOF_MAX_ALIGN_T +// #endif + // #endif /* Py_PYPORT_H */ @@ -2973,6 +3053,11 @@ For example Py_STRINGIFY(__LINE__) is replaced by the line number, not // For example, "int x; _Py_RVALUE(x) = 1;" fails with a compiler error. // #define _Py_RVALUE(EXPR) ((void)0, (EXPR)) +// Return non-zero if the type is signed, return zero if it's unsigned. +// Use "<= 0" rather than "< 0" to prevent the compiler warning: +// "comparison of unsigned expression in '< 0' is always false". +// #define _Py_IS_TYPE_SIGNED(type) ((type)(-1) <= 0) + // #endif /* Py_PYMACRO_H */ @@ -3019,27 +3104,25 @@ For example Py_STRINGIFY(__LINE__) is replaced by the line number, not // Return 1 if float or double arg is neither infinite nor NAN, else 0. // #define Py_IS_FINITE(X) isfinite(X) -/* HUGE_VAL is supposed to expand to a positive double infinity. Python - * uses Py_HUGE_VAL instead because some platforms are broken in this - * respect. We used to embed code in pyport.h to try to worm around that, - * but different platforms are broken in conflicting ways. If you're on - * a platform where HUGE_VAL is defined incorrectly, fiddle your Python - * config to #define Py_HUGE_VAL to something that works on your platform. +// Py_INFINITY: Value that evaluates to a positive double infinity. +// #ifndef Py_INFINITY +public static native @MemberGetter double Py_INFINITY(); +public static final double Py_INFINITY = Py_INFINITY(); +// #endif + +/* Py_HUGE_VAL should always be the same as Py_INFINITY. But historically + * this was not reliable and Python did not require IEEE floats and C99 + * conformity. Prefer Py_INFINITY for new code. */ // #ifndef Py_HUGE_VAL // # define Py_HUGE_VAL HUGE_VAL // #endif -// Py_NAN: Value that evaluates to a quiet Not-a-Number (NaN). +/* Py_NAN: Value that evaluates to a quiet Not-a-Number (NaN). The sign is + * undefined and normally not relevant, but e.g. fixed for float("nan"). + */ // #if !defined(Py_NAN) -// # if _Py__has_builtin(__builtin_nan) - // Built-in implementation of the ISO C99 function nan(): quiet NaN. -// # define Py_NAN (__builtin_nan("")) -// #else - // Use C99 NAN constant: quiet Not-A-Number. - // NAN is a float, Py_NAN is a double: cast to double. // # define Py_NAN ((double)NAN) -// # endif // #endif // #endif /* Py_PYMATH_H */ @@ -3101,6 +3184,9 @@ For example Py_STRINGIFY(__LINE__) is replaced by the line number, not // #ifdef __cplusplus // #endif +// #ifdef __clang__ +// #endif + /* _PyTime_t: Python timestamp with subsecond precision. It can be used to store a duration, and so indirectly a date (related to another date, like UNIX epoch). */ @@ -3177,6 +3263,10 @@ Only use the macro for small values, prefer _PyTime_FromSeconds(). */ /* Create a timestamp from a number of nanoseconds. */ @NoException public static native @Cast("_PyTime_t") long _PyTime_FromNanoseconds(@Cast("_PyTime_t") long ns); +/* Create a timestamp from a number of microseconds. + * Clamp to [_PyTime_MIN; _PyTime_MAX] on overflow. */ +@NoException public static native @Cast("_PyTime_t") long _PyTime_FromMicrosecondsClamp(@Cast("_PyTime_t") long us); + /* Create a timestamp from nanoseconds (Python int). */ @NoException public static native int _PyTime_FromNanosecondsObject(@Cast("_PyTime_t*") LongPointer t, PyObject obj); @@ -3478,13 +3568,13 @@ performed on failure (no exception is set, no warning is printed, etc). // Deprecated aliases only kept for backward compatibility. // PyMem_Del and PyMem_DEL are defined with no parameter to be able to use // them as function pointers (ex: dealloc = PyMem_Del). -// #define PyMem_MALLOC(n) PyMem_Malloc(n) -// #define PyMem_NEW(type, n) PyMem_New(type, n) -// #define PyMem_REALLOC(p, n) PyMem_Realloc(p, n) -// #define PyMem_RESIZE(p, type, n) PyMem_Resize(p, type, n) -// #define PyMem_FREE(p) PyMem_Free(p) -// #define PyMem_Del PyMem_Free -// #define PyMem_DEL PyMem_Free +// #define PyMem_MALLOC(n) PyMem_Malloc((n)) +// #define PyMem_NEW(type, n) PyMem_New(type, (n)) +// #define PyMem_REALLOC(p, n) PyMem_Realloc((p), (n)) +// #define PyMem_RESIZE(p, type, n) PyMem_Resize((p), type, (n)) +// #define PyMem_FREE(p) PyMem_Free((p)) +// #define PyMem_Del(p) PyMem_Free((p)) +// #define PyMem_DEL(p) PyMem_Free((p)) // #ifndef Py_LIMITED_API @@ -3537,6 +3627,12 @@ performed on failure (no exception is set, no warning is printed, etc). // Targeting ../Py_buffer.java +// Targeting ../getbufferproc.java + + +// Targeting ../releasebufferproc.java + + /* Return 1 if the getbuffer function is available, otherwise return 0. */ @NoException public static native int PyObject_CheckBuffer(PyObject obj); @@ -3607,7 +3703,7 @@ performed on failure (no exception is set, no warning is printed, etc). /* Maximum number of dimensions */ public static final int PyBUF_MAX_NDIM = 64; -/* Flags for getting buffers */ +/* Flags for getting buffers. Keep these in sync with inspect.BufferFlags. */ public static final int PyBUF_SIMPLE = 0; public static final int PyBUF_WRITABLE = 0x0001; @@ -3790,6 +3886,8 @@ used for this (to accommodate for future changes). The implementation whose size is determined when the object is allocated. */ +// #include "pystats.h" + /* Py_DEBUG implies Py_REF_DEBUG. */ // #if defined(Py_DEBUG) && !defined(Py_REF_DEBUG) // # define Py_REF_DEBUG @@ -3809,12 +3907,70 @@ used for this (to accommodate for future changes). The implementation /* PyObject_HEAD defines the initial segment of every PyObject. */ // #define PyObject_HEAD PyObject ob_base; +/* +Immortalization: + +The following indicates the immortalization strategy depending on the amount +of available bits in the reference count field. All strategies are backwards +compatible but the specific reference count value or immortalization check +might change depending on the specializations for the underlying system. + +Proper deallocation of immortal instances requires distinguishing between +statically allocated immortal instances vs those promoted by the runtime to be +immortal. The latter should be the only instances that require +cleanup during runtime finalization. +*/ + +// #if SIZEOF_VOID_P > 4 +/* +In 64+ bit systems, an object will be marked as immortal by setting all of the +lower 32 bits of the reference count field, which is equal to: 0xFFFFFFFF + +Using the lower 32 bits makes the value backwards compatible by allowing +C-Extensions without the updated checks in Py_INCREF and Py_DECREF to safely +increase and decrease the objects reference count. The object would lose its +immortality, but the execution would still be correct. + +Reference count increases will use saturated arithmetic, taking advantage of +having all the lower 32 bits set, which will avoid the reference count to go +beyond the refcount limit. Immortality checks for reference count decreases will +be done by checking the bit sign flag in the lower 32 bits. +*/ +public static native @MemberGetter long _Py_IMMORTAL_REFCNT(); +public static final long _Py_IMMORTAL_REFCNT = _Py_IMMORTAL_REFCNT(); + +// #else +/* +In 32 bit systems, an object will be marked as immortal by setting all of the +lower 30 bits of the reference count field, which is equal to: 0x3FFFFFFF + +Using the lower 30 bits makes the value backwards compatible by allowing +C-Extensions without the updated checks in Py_INCREF and Py_DECREF to safely +increase and decrease the objects reference count. The object would lose its +immortality, but the execution would still be correct. + +Reference count increases and decreases will first go through an immortality +check by comparing the reference count field to the immortality reference count. +*/ +// #endif + +// Make all internal uses of PyObject_HEAD_INIT immortal while preserving the +// C-API expectation that the refcnt will be set to 1. +// #ifdef Py_BUILD_CORE +// #else // #define PyObject_HEAD_INIT(type) -// { _PyObject_EXTRA_INIT -// 1, type }, +// { +// _PyObject_EXTRA_INIT +// { 1 }, +// (type) +// }, +// #endif /* Py_BUILD_CORE */ // #define PyVarObject_HEAD_INIT(type, size) -// { PyObject_HEAD_INIT(type) size }, +// { +// PyObject_HEAD_INIT(type) +// (size) +// }, /* PyObject_VAR_HEAD defines the initial segment of all variable-size * container objects. These end with a declaration of an array with 1 @@ -3853,11 +4009,16 @@ used for this (to accommodate for future changes). The implementation // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 // #endif +public static native @ByRef PyTypeObject PyLong_Type(); public static native void PyLong_Type(PyTypeObject setter); +public static native @ByRef PyTypeObject PyBool_Type(); public static native void PyBool_Type(PyTypeObject setter); + // bpo-39573: The Py_SET_SIZE() function must be used to set an object size. @NoException public static native @Cast("Py_ssize_t") long Py_SIZE(PyObject ob); // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 // #endif +@NoException public static native int _Py_IsImmortal(PyObject op); +// #define _Py_IsImmortal(op) _Py_IsImmortal(_PyObject_CAST(op)) @NoException public static native int Py_IS_TYPE(PyObject ob, PyTypeObject type); // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 @@ -3873,7 +4034,6 @@ used for this (to accommodate for future changes). The implementation // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 // #endif - @NoException public static native void Py_SET_SIZE(PyVarObject ob, @Cast("Py_ssize_t") long size); // Targeting ../unaryfunc.java @@ -3962,6 +4122,9 @@ used for this (to accommodate for future changes). The implementation // Targeting ../allocfunc.java +// Targeting ../vectorcallfunc.java + + // Targeting ../PyType_Slot.java @@ -3985,6 +4148,11 @@ used for this (to accommodate for future changes). The implementation @NoException public static native PyObject PyType_GetName(PyTypeObject arg0); @NoException public static native PyObject PyType_GetQualName(PyTypeObject arg0); // #endif +// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000 +@NoException public static native PyObject PyType_FromMetaclass(PyTypeObject arg0, PyObject arg1, PyType_Spec arg2, PyObject arg3); +@NoException public static native Pointer PyObject_GetTypeData(PyObject obj, PyTypeObject cls); +@NoException public static native @Cast("Py_ssize_t") long PyType_GetTypeDataSize(PyTypeObject cls); +// #endif /* Generic type check */ @NoException public static native int PyType_IsSubtype(PyTypeObject arg0, PyTypeObject arg1); @@ -4077,12 +4245,21 @@ Code can use PyType_HasFeature(type_ob, flag_value) to test whether the // #ifndef Py_LIMITED_API +/* Track types initialized using _PyStaticType_InitBuiltin(). */ +public static final int _Py_TPFLAGS_STATIC_BUILTIN = (1 << 1); + +/* Placement of weakref pointers are managed by the VM, not by the type. + * The VM will automatically set tp_weaklistoffset. + */ +public static final int Py_TPFLAGS_MANAGED_WEAKREF = (1 << 3); + /* Placement of dict (and values) pointers are managed by the VM, not by the type. - * The VM will automatically set tp_dictoffset. Should not be used for variable sized - * classes, such as classes that extend tuple. + * The VM will automatically set tp_dictoffset. */ public static final int Py_TPFLAGS_MANAGED_DICT = (1 << 4); +public static final int Py_TPFLAGS_PREHEADER = (Py_TPFLAGS_MANAGED_WEAKREF | Py_TPFLAGS_MANAGED_DICT); + /* Set if instances of the type object are treated as sequences for pattern matching */ public static final int Py_TPFLAGS_SEQUENCE = (1 << 5); /* Set if instances of the type object are treated as mappings for pattern matching */ @@ -4103,11 +4280,13 @@ Code can use PyType_HasFeature(type_ob, flag_value) to test whether the public static final long Py_TPFLAGS_BASETYPE = (1L << 10); /* Set if the type implements the vectorcall protocol (PEP 590) */ -// #ifndef Py_LIMITED_API +// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000 public static final long Py_TPFLAGS_HAVE_VECTORCALL = (1L << 11); +// #ifndef Py_LIMITED_API // Backwards compatibility alias for API that was provisional in Python 3.8 public static final long _Py_TPFLAGS_HAVE_VECTORCALL = Py_TPFLAGS_HAVE_VECTORCALL; // #endif +// #endif /* Set if the type is 'ready' -- fully initialized */ public static final long Py_TPFLAGS_READY = (1L << 12); @@ -4138,6 +4317,9 @@ Code can use PyType_HasFeature(type_ob, flag_value) to test whether the // subject itself (rather than a mapped attribute on it): public static final long _Py_TPFLAGS_MATCH_SELF = (1L << 22); +/* Items (ob_size*tp_itemsize) are found at the end of an instance's memory */ +public static final long Py_TPFLAGS_ITEMS_AT_END = (1L << 23); + /* These flags are used to determine if a type is a subclass. */ public static final long Py_TPFLAGS_LONG_SUBCLASS = (1L << 24); public static final long Py_TPFLAGS_LIST_SUBCLASS = (1L << 25); @@ -4197,8 +4379,8 @@ in special builds (Py_REF_DEBUG, Py_TRACE_REFS) performs additional you can count such references to the type object.) */ -// #ifdef Py_REF_DEBUG -// #endif /* Py_REF_DEBUG */ +// #if defined(Py_REF_DEBUG) && !defined(Py_LIMITED_API) +// #endif // Py_REF_DEBUG && !Py_LIMITED_API @NoException public static native void _Py_Dealloc(PyObject arg0); @@ -4218,8 +4400,7 @@ in special builds (Py_REF_DEBUG, Py_TRACE_REFS) performs additional // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 // #endif - -// #if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030A0000 +// #if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG)) // #elif defined(Py_REF_DEBUG) @@ -4262,15 +4443,35 @@ in special builds (Py_REF_DEBUG, Py_TRACE_REFS) performs additional * one of those can't cause problems -- but in part that relies on that * Python integers aren't currently weakly referencable. Best practice is * to use Py_CLEAR() even if you can't think of a reason for why you need to. + * + * gh-98724: Use a temporary variable to only evaluate the macro argument once, + * to avoid the duplication of side effects if the argument has side effects. + * + * gh-99701: If the PyObject* type is used with casting arguments to PyObject*, + * the code can be miscompiled with strict aliasing because of type punning. + * With strict aliasing, a compiler considers that two pointers of different + * types cannot read or write the same memory which enables optimization + * opportunities. + * + * If available, use _Py_TYPEOF() to use the 'op' type for temporary variables, + * and so avoid type punning. Otherwise, use memcpy() which causes type erasure + * and so prevents the compiler to reuse an old cached 'op' value after + * Py_CLEAR(). */ +// #ifdef _Py_TYPEOF +// #else // #define Py_CLEAR(op) // do { -// PyObject *_py_tmp = _PyObject_CAST(op); -// if (_py_tmp != NULL) { -// (op) = NULL; -// Py_DECREF(_py_tmp); +// PyObject **_tmp_op_ptr = _Py_CAST(PyObject**, &(op)); +// PyObject *_tmp_old_op = (*_tmp_op_ptr); +// if (_tmp_old_op != NULL) { +// PyObject *_null_ptr = _Py_NULL; +// memcpy(_tmp_op_ptr, &_null_ptr, sizeof(PyObject*)); +// Py_DECREF(_tmp_old_op); // } // } while (0) +// #endif + /* Function to use in case the object pointer can be NULL: */ @NoException public static native void Py_XINCREF(PyObject op); @@ -4316,7 +4517,7 @@ where NULL (nil) is not suitable (since NULL often means 'error'). // #define Py_IsNone(x) Py_Is((x), Py_None) /* Macro for returning Py_None from a function */ -// #define Py_RETURN_NONE return Py_NewRef(Py_None) +// #define Py_RETURN_NONE return Py_None /* Py_NotImplemented is a singleton used to signal that an operation is @@ -4326,7 +4527,7 @@ where NULL (nil) is not suitable (since NULL often means 'error'). // #define Py_NotImplemented (&_Py_NotImplementedStruct) /* Macro for returning Py_NotImplemented from a function */ -// #define Py_RETURN_NOTIMPLEMENTED return Py_NewRef(Py_NotImplemented) +// #define Py_RETURN_NOTIMPLEMENTED return Py_NotImplemented /* Rich comparison opcodes */ public static final int Py_LT = 0; @@ -4426,7 +4627,7 @@ it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at @NoException public static native int PyType_HasFeature(PyTypeObject type, @Cast("unsigned long") long feature); -// #define PyType_FastSubclass(type, flag) PyType_HasFeature(type, flag) +// #define PyType_FastSubclass(type, flag) PyType_HasFeature((type), (flag)) @NoException public static native int PyType_Check(PyObject op); // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 @@ -4451,26 +4652,18 @@ it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at // #endif @NoException public static native void _Py_NewReference(PyObject op); +@NoException public static native void _Py_NewReferenceNoTotal(PyObject op); // Targeting ../_Py_Identifier.java -// #if defined(NEEDS_PY_IDENTIFIER) || !defined(Py_BUILD_CORE) +// #ifndef Py_BUILD_CORE // For now we are keeping _Py_IDENTIFIER for continued use // in non-builtin extensions (and naughty PyPI modules). -// #define _Py_static_string_init(value) { .string = value, .index = -1 } +// #define _Py_static_string_init(value) { .string = (value), .index = -1 } // #define _Py_static_string(varname, value) static _Py_Identifier varname = _Py_static_string_init(value) // #define _Py_IDENTIFIER(varname) _Py_static_string(PyId_##varname, #varname) -// Targeting ../getbufferproc.java - - -// Targeting ../releasebufferproc.java - - -// Targeting ../vectorcallfunc.java - - // Targeting ../PyNumberMethods.java @@ -4517,6 +4710,7 @@ it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at @NoException public static native PyObject _PyType_GetTextSignatureFromInternalDoc(@Cast("const char*") BytePointer arg0, @Cast("const char*") BytePointer arg1); @NoException public static native PyObject _PyType_GetTextSignatureFromInternalDoc(String arg0, String arg1); @NoException public static native PyObject PyType_GetModuleByDef(PyTypeObject arg0, PyModuleDef arg1); +@NoException public static native PyObject PyType_GetDict(PyTypeObject arg0); @NoException public static native int PyObject_Print(PyObject arg0, @Cast("FILE*") Pointer arg1, int arg2); @NoException public static native void _Py_BreakPoint(); @@ -4556,38 +4750,55 @@ it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at @NoException public static native PyObject _PyObject_FunctionStr(PyObject arg0); -/* Safely decref `op` and set `op` to `op2`. +/* Safely decref `dst` and set `dst` to `src`. * * As in case of Py_CLEAR "the obvious" code can be deadly: * - * Py_DECREF(op); - * op = op2; + * Py_DECREF(dst); + * dst = src; * * The safe way is: * - * Py_SETREF(op, op2); + * Py_SETREF(dst, src); * - * That arranges to set `op` to `op2` _before_ decref'ing, so that any code - * triggered as a side-effect of `op` getting torn down no longer believes - * `op` points to a valid object. + * That arranges to set `dst` to `src` _before_ decref'ing, so that any code + * triggered as a side-effect of `dst` getting torn down no longer believes + * `dst` points to a valid object. * - * Py_XSETREF is a variant of Py_SETREF that uses Py_XDECREF instead of - * Py_DECREF. + * Temporary variables are used to only evalutate macro arguments once and so + * avoid the duplication of side effects. _Py_TYPEOF() or memcpy() is used to + * avoid a miscompilation caused by type punning. See Py_CLEAR() comment for + * implementation details about type punning. + * + * The memcpy() implementation does not emit a compiler warning if 'src' has + * not the same type than 'src': any pointer type is accepted for 'src'. */ - -// #define Py_SETREF(op, op2) +// #ifdef _Py_TYPEOF +// #else +// #define Py_SETREF(dst, src) // do { -// PyObject *_py_tmp = _PyObject_CAST(op); -// (op) = (op2); -// Py_DECREF(_py_tmp); +// PyObject **_tmp_dst_ptr = _Py_CAST(PyObject**, &(dst)); +// PyObject *_tmp_old_dst = (*_tmp_dst_ptr); +// PyObject *_tmp_src = _PyObject_CAST(src); +// memcpy(_tmp_dst_ptr, &_tmp_src, sizeof(PyObject*)); +// Py_DECREF(_tmp_old_dst); // } while (0) +// #endif -// #define Py_XSETREF(op, op2) +/* Py_XSETREF() is a variant of Py_SETREF() that uses Py_XDECREF() instead of + * Py_DECREF(). + */ +// #ifdef _Py_TYPEOF +// #else +// #define Py_XSETREF(dst, src) // do { -// PyObject *_py_tmp = _PyObject_CAST(op); -// (op) = (op2); -// Py_XDECREF(_py_tmp); +// PyObject **_tmp_dst_ptr = _Py_CAST(PyObject**, &(dst)); +// PyObject *_tmp_old_dst = (*_tmp_dst_ptr); +// PyObject *_tmp_src = _PyObject_CAST(src); +// memcpy(_tmp_dst_ptr, &_tmp_src, sizeof(PyObject*)); +// Py_XDECREF(_tmp_old_dst); // } while (0) +// #endif public static native @ByRef PyTypeObject _PyNone_Type(); public static native void _PyNone_Type(PyTypeObject setter); @@ -4633,9 +4844,9 @@ particular object is corrupt (e.g. buggy a tp_visit method in an extension // #endif // #define _PyObject_ASSERT_WITH_MSG(obj, expr, msg) -// _PyObject_ASSERT_FROM(obj, expr, msg, __FILE__, __LINE__, __func__) +// _PyObject_ASSERT_FROM((obj), expr, (msg), __FILE__, __LINE__, __func__) // #define _PyObject_ASSERT(obj, expr) -// _PyObject_ASSERT_WITH_MSG(obj, expr, NULL) +// _PyObject_ASSERT_WITH_MSG((obj), expr, NULL) // #define _PyObject_ASSERT_FAILED_MSG(obj, msg) // _PyObject_AssertFailed((obj), NULL, (msg), __FILE__, __LINE__, __func__) @@ -4735,7 +4946,7 @@ passed as second argument to Py_TRASHCAN_BEGIN(). // /* If "cond" is false, then _tstate remains NULL and the deallocator \ // * is run normally without involving the trashcan */ // if (cond) { -// _tstate = PyThreadState_Get(); +// _tstate = _PyThreadState_UncheckedGet(); // if (_PyTrash_begin(_tstate, _PyObject_CAST(op))) { // break; // } @@ -4748,8 +4959,8 @@ passed as second argument to Py_TRASHCAN_BEGIN(). // } while (0); // #define Py_TRASHCAN_BEGIN(op, dealloc) -// Py_TRASHCAN_BEGIN_CONDITION(op, -// _PyTrash_cond(_PyObject_CAST(op), (destructor)dealloc)) +// Py_TRASHCAN_BEGIN_CONDITION((op), +// _PyTrash_cond(_PyObject_CAST(op), (destructor)(dealloc))) /* The following two macros, Py_TRASHCAN_SAFE_BEGIN and * Py_TRASHCAN_SAFE_END, are deprecated since version 3.11 and @@ -4759,11 +4970,32 @@ passed as second argument to Py_TRASHCAN_BEGIN(). // #define Py_TRASHCAN_SAFE_BEGIN(op) // do { // UsingDeprecatedTrashcanMacro cond=1; -// Py_TRASHCAN_BEGIN_CONDITION(op, cond); +// Py_TRASHCAN_BEGIN_CONDITION((op), cond); // #define Py_TRASHCAN_SAFE_END(op) // Py_TRASHCAN_END; // } while(0); +@NoException public static native Pointer PyObject_GetItemData(PyObject obj); + +@NoException public static native int _PyObject_VisitManagedDict(PyObject obj, visitproc visit, Pointer arg); +@NoException public static native void _PyObject_ClearManagedDict(PyObject obj); + +public static final int TYPE_MAX_WATCHERS = 8; +// Targeting ../PyType_WatchCallback.java + + +@NoException public static native int PyType_AddWatcher(PyType_WatchCallback callback); +@NoException public static native int PyType_ClearWatcher(int watcher_id); +@NoException public static native int PyType_Watch(int watcher_id, PyObject type); +@NoException public static native int PyType_Unwatch(int watcher_id, PyObject type); + +/* Attempt to assign a version tag to the given type. + * + * Returns 1 if the type already had a valid version tag or a new one was + * assigned, or 0 if a new tag could not be assigned. + */ +@NoException public static native int PyUnstable_Type_AssignVersionTag(PyTypeObject type); + // Parsed from objimpl.h @@ -4903,14 +5135,14 @@ performed on failure other than to return NULL (no warning it printed, no // Alias to PyObject_New(). In Python 3.8, PyObject_NEW() called directly // PyObject_MALLOC() with _PyObject_SIZE(). -// #define PyObject_NEW(type, typeobj) PyObject_New(type, typeobj) +// #define PyObject_NEW(type, typeobj) PyObject_New(type, (typeobj)) // #define PyObject_NewVar(type, typeobj, n) // ( (type *) _PyObject_NewVar((typeobj), (n)) ) // Alias to PyObject_NewVar(). In Python 3.8, PyObject_NEW_VAR() called // directly PyObject_MALLOC() with _PyObject_VAR_SIZE(). -// #define PyObject_NEW_VAR(type, typeobj, n) PyObject_NewVar(type, typeobj, n) +// #define PyObject_NEW_VAR(type, typeobj, n) PyObject_NewVar(type, (typeobj), (n)) /* @@ -4924,6 +5156,11 @@ performed on failure other than to return NULL (no warning it printed, no @NoException public static native int PyGC_Enable(); @NoException public static native int PyGC_Disable(); @NoException public static native int PyGC_IsEnabled(); +// Targeting ../gcvisitobjects_t.java + + +@NoException public static native void PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, Pointer arg); +// #endif /* Test if a type has a GC head */ // #define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC) @@ -4988,7 +5225,7 @@ performed on failure other than to return NULL (no warning it printed, no // # error "this header file must not be included directly" // #endif -// #define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize ) +@NoException public static native @Cast("size_t") long _PyObject_SIZE(PyTypeObject type); /* _PyObject_VAR_SIZE returns the number of bytes (as size_t) allocated for a vrbl-size object with nitems items, exclusive of gc overhead (if any). The @@ -5004,10 +5241,7 @@ value is rounded up to the closest multiple of sizeof(void *), in order to // # error "_PyObject_VAR_SIZE requires SIZEOF_VOID_P be a power of 2" // #endif -// #define _PyObject_VAR_SIZE(typeobj, nitems) -// _Py_SIZE_ROUND_UP((typeobj)->tp_basicsize + -// (nitems)*(typeobj)->tp_itemsize, -// SIZEOF_VOID_P) +@NoException public static native @Cast("size_t") long _PyObject_VAR_SIZE(PyTypeObject type, @Cast("Py_ssize_t") long nitems); // Targeting ../PyObjectArenaAllocator.java @@ -5036,6 +5270,9 @@ defines a different _PyGC_FINALIZED() macro. */ @NoException public static native @Cast("PyObject**") PointerPointer PyObject_GET_WEAKREFS_LISTPTR(PyObject op); +@NoException public static native PyObject PyUnstable_Object_GC_NewWithExtraData(PyTypeObject arg0, + @Cast("size_t") long arg1); + // Parsed from typeslots.h @@ -5229,21 +5466,21 @@ defines a different _PyGC_FINALIZED() macro. */ // #ifdef __cplusplus // #endif -public static native int Py_DebugFlag(); public static native void Py_DebugFlag(int setter); -public static native int Py_VerboseFlag(); public static native void Py_VerboseFlag(int setter); -public static native int Py_QuietFlag(); public static native void Py_QuietFlag(int setter); -public static native int Py_InteractiveFlag(); public static native void Py_InteractiveFlag(int setter); -public static native int Py_InspectFlag(); public static native void Py_InspectFlag(int setter); -public static native int Py_OptimizeFlag(); public static native void Py_OptimizeFlag(int setter); -public static native int Py_NoSiteFlag(); public static native void Py_NoSiteFlag(int setter); -public static native int Py_BytesWarningFlag(); public static native void Py_BytesWarningFlag(int setter); -public static native int Py_FrozenFlag(); public static native void Py_FrozenFlag(int setter); -public static native int Py_IgnoreEnvironmentFlag(); public static native void Py_IgnoreEnvironmentFlag(int setter); -public static native int Py_DontWriteBytecodeFlag(); public static native void Py_DontWriteBytecodeFlag(int setter); -public static native int Py_NoUserSiteDirectory(); public static native void Py_NoUserSiteDirectory(int setter); -public static native int Py_UnbufferedStdioFlag(); public static native void Py_UnbufferedStdioFlag(int setter); -public static native int Py_HashRandomizationFlag(); public static native void Py_HashRandomizationFlag(int setter); -public static native int Py_IsolatedFlag(); public static native void Py_IsolatedFlag(int setter); +public static native @Deprecated int Py_DebugFlag(); public static native void Py_DebugFlag(int setter); +public static native @Deprecated int Py_VerboseFlag(); public static native void Py_VerboseFlag(int setter); +public static native @Deprecated int Py_QuietFlag(); public static native void Py_QuietFlag(int setter); +public static native @Deprecated int Py_InteractiveFlag(); public static native void Py_InteractiveFlag(int setter); +public static native @Deprecated int Py_InspectFlag(); public static native void Py_InspectFlag(int setter); +public static native @Deprecated int Py_OptimizeFlag(); public static native void Py_OptimizeFlag(int setter); +public static native @Deprecated int Py_NoSiteFlag(); public static native void Py_NoSiteFlag(int setter); +public static native @Deprecated int Py_BytesWarningFlag(); public static native void Py_BytesWarningFlag(int setter); +public static native @Deprecated int Py_FrozenFlag(); public static native void Py_FrozenFlag(int setter); +public static native @Deprecated int Py_IgnoreEnvironmentFlag(); public static native void Py_IgnoreEnvironmentFlag(int setter); +public static native @Deprecated int Py_DontWriteBytecodeFlag(); public static native void Py_DontWriteBytecodeFlag(int setter); +public static native @Deprecated int Py_NoUserSiteDirectory(); public static native void Py_NoUserSiteDirectory(int setter); +public static native @Deprecated int Py_UnbufferedStdioFlag(); public static native void Py_UnbufferedStdioFlag(int setter); +public static native @Deprecated int Py_HashRandomizationFlag(); public static native void Py_HashRandomizationFlag(int setter); +public static native @Deprecated int Py_IsolatedFlag(); public static native void Py_IsolatedFlag(int setter); // #ifdef MS_WINDOWS // #endif @@ -5291,6 +5528,54 @@ defines a different _PyGC_FINALIZED() macro. */ @NoException public static native PyObject PyDictProxy_New(PyObject arg0); @NoException public static native PyObject PyWrapper_New(PyObject arg0, PyObject arg1); +// Targeting ../PyMemberDef.java + + + +// These constants used to be in structmember.h, not prefixed by Py_. +// (structmember.h now has aliases to the new names.) + +/* Types */ +public static final int Py_T_SHORT = 0; +public static final int Py_T_INT = 1; +public static final int Py_T_LONG = 2; +public static final int Py_T_FLOAT = 3; +public static final int Py_T_DOUBLE = 4; +public static final int Py_T_STRING = 5; +public static final int _Py_T_OBJECT = 6; // Deprecated, use Py_T_OBJECT_EX instead +/* the ordering here is weird for binary compatibility */ +public static final int Py_T_CHAR = 7; /* 1-character string */ +public static final int Py_T_BYTE = 8; /* 8-bit signed int */ +/* unsigned variants: */ +public static final int Py_T_UBYTE = 9; +public static final int Py_T_USHORT = 10; +public static final int Py_T_UINT = 11; +public static final int Py_T_ULONG = 12; + +/* Added by Jack: strings contained in the structure */ +public static final int Py_T_STRING_INPLACE = 13; + +/* Added by Lillo: bools contained in the structure (assumed char) */ +public static final int Py_T_BOOL = 14; + +public static final int Py_T_OBJECT_EX = 16; +public static final int Py_T_LONGLONG = 17; +public static final int Py_T_ULONGLONG = 18; + +public static final int Py_T_PYSSIZET = 19; /* Py_ssize_t */ +public static final int _Py_T_NONE = 20; // Deprecated. Value is always None. + +/* Flags */ +public static final int Py_READONLY = 1; +public static final int Py_AUDIT_READ = 2; // Added in 3.10, harmless no-op before that +public static final int _Py_WRITE_RESTRICTED = 4; // Deprecated, no-op. Do not reuse the value. +public static final int Py_RELATIVE_OFFSET = 8; + +@NoException public static native PyObject PyMember_GetOne(@Cast("const char*") BytePointer arg0, PyMemberDef arg1); +@NoException public static native PyObject PyMember_GetOne(String arg0, PyMemberDef arg1); +@NoException public static native int PyMember_SetOne(@Cast("char*") BytePointer arg0, PyMemberDef arg1, PyObject arg2); +@NoException public static native int PyMember_SetOne(@Cast("char*") ByteBuffer arg0, PyMemberDef arg1, PyObject arg2); +@NoException public static native int PyMember_SetOne(@Cast("char*") byte[] arg0, PyMemberDef arg1, PyObject arg2); // #ifndef Py_LIMITED_API // # define Py_CPYTHON_DESCROBJECT_H @@ -5327,8 +5612,8 @@ defines a different _PyGC_FINALIZED() macro. */ public static native @ByRef PyTypeObject PyByteArrayIter_Type(); public static native void PyByteArrayIter_Type(PyTypeObject setter); /* Type check macros */ -// #define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type) -// #define PyByteArray_CheckExact(self) Py_IS_TYPE(self, &PyByteArray_Type) +// #define PyByteArray_Check(self) PyObject_TypeCheck((self), &PyByteArray_Type) +// #define PyByteArray_CheckExact(self) Py_IS_TYPE((self), &PyByteArray_Type) /* Direct API functions */ @NoException public static native PyObject PyByteArray_FromObject(PyObject arg0); @@ -5366,12 +5651,10 @@ defines a different _PyGC_FINALIZED() macro. */ // (assert(PyByteArray_Check(op)), _Py_CAST(PyByteArrayObject*, op)) @NoException public static native @Cast("char*") BytePointer PyByteArray_AS_STRING(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyByteArray_AS_STRING(self) PyByteArray_AS_STRING(_PyObject_CAST(self)) @NoException public static native @Cast("Py_ssize_t") long PyByteArray_GET_SIZE(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyByteArray_GET_SIZE(self) PyByteArray_GET_SIZE(_PyObject_CAST(self)) // Parsed from bytesobject.h @@ -5406,7 +5689,7 @@ defines a different _PyGC_FINALIZED() macro. */ // #define PyBytes_Check(op) // PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS) -// #define PyBytes_CheckExact(op) Py_IS_TYPE(op, &PyBytes_Type) +// #define PyBytes_CheckExact(op) Py_IS_TYPE((op), &PyBytes_Type) @NoException public static native PyObject PyBytes_FromStringAndSize(@Cast("const char*") BytePointer arg0, @Cast("Py_ssize_t") long arg1); @NoException public static native PyObject PyBytes_FromStringAndSize(String arg0, @Cast("Py_ssize_t") long arg1); @@ -5512,12 +5795,10 @@ defines a different _PyGC_FINALIZED() macro. */ // (assert(PyBytes_Check(op)), _Py_CAST(PyBytesObject*, op)) @NoException public static native @Cast("char*") BytePointer PyBytes_AS_STRING(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyBytes_AS_STRING(op) PyBytes_AS_STRING(_PyObject_CAST(op)) @NoException public static native @Cast("Py_ssize_t") long PyBytes_GET_SIZE(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyBytes_GET_SIZE(self) PyBytes_GET_SIZE(_PyObject_CAST(self)) /* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*, x must be an iterable object. */ @@ -5692,7 +5973,7 @@ through the interface functions PyUnicode_FromWideChar(), // #define PyUnicode_Check(op) // PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS) -// #define PyUnicode_CheckExact(op) Py_IS_TYPE(op, &PyUnicode_Type) +// #define PyUnicode_CheckExact(op) Py_IS_TYPE((op), &PyUnicode_Type) /* --- Constants ---------------------------------------------------------- */ @@ -5767,13 +6048,6 @@ buflen is the length of the buffer in (Py_UCS4) characters. */ ); // #endif -/* Get the number of Py_UNICODE units in the - string representation. */ - -@NoException public static native @Cast("Py_ssize_t") @Deprecated long PyUnicode_GetSize( - PyObject unicode - ); - // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 /* Read a character from the string. */ @@ -5794,9 +6068,7 @@ buflen is the length of the buffer in (Py_UCS4) characters. */ ); // #endif -/* Resize a Unicode object. The length is the number of characters, except - if the kind of the string is PyUnicode_WCHAR_KIND: in this case, the length - is the number of Py_UNICODE characters. +/* Resize a Unicode object. The length is the number of codepoints. *unicode is modified to point to the new (resized) object and 0 returned on success. @@ -5880,11 +6152,6 @@ necessary. If obj is already a true Unicode object (not a subtype), return String u ); -// PyUnicode_InternImmortal() is deprecated since Python 3.10 -// and will be removed in Python 3.12. Use PyUnicode_InternInPlace() instead. -@NoException public static native @Deprecated void PyUnicode_InternImmortal(@Cast("PyObject**") PointerPointer arg0); -@NoException public static native @Deprecated void PyUnicode_InternImmortal(@ByPtrPtr PyObject arg0); - /* --- wchar_t support for platforms which support it --------------------- */ // #ifdef HAVE_WCHAR_H @@ -6445,7 +6712,7 @@ Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is /* --- ASCII Codecs ------------------------------------------------------- - Only 7-bit ASCII data is excepted. All other codes generate errors. + Only 7-bit ASCII data is expected. All other codes generate errors. */ @@ -6562,15 +6829,10 @@ length using strlen(). */ @NoException public static native int PyUnicode_FSDecoder(PyObject arg0, Pointer arg1); -/* Decode a null-terminated string using Py_FileSystemDefaultEncoding - and the "surrogateescape" error handler. - - If Py_FileSystemDefaultEncoding is not set, fall back to the locale - encoding. - - Use PyUnicode_DecodeFSDefaultAndSize() if the string length is known. -*/ +/* Decode a null-terminated string from the Python filesystem encoding + and error handler. + If the string length is known, use PyUnicode_DecodeFSDefaultAndSize(). */ @NoException public static native PyObject PyUnicode_DecodeFSDefault( @Cast("const char*") BytePointer s ); @@ -6578,13 +6840,7 @@ Use PyUnicode_DecodeFSDefaultAndSize() if the string length is known. String s ); -/* Decode a string using Py_FileSystemDefaultEncoding - and the "surrogateescape" error handler. - - If Py_FileSystemDefaultEncoding is not set, fall back to the locale - encoding. -*/ - +/* Decode a string from the Python filesystem encoding and error handler. */ @NoException public static native PyObject PyUnicode_DecodeFSDefaultAndSize( @Cast("const char*") BytePointer s, @Cast("Py_ssize_t") long size @@ -6594,13 +6850,8 @@ Use PyUnicode_DecodeFSDefaultAndSize() if the string length is known. @Cast("Py_ssize_t") long size ); -/* Encode a Unicode object to Py_FileSystemDefaultEncoding with the - "surrogateescape" error handler, and return bytes. - - If Py_FileSystemDefaultEncoding is not set, fall back to the locale - encoding. -*/ - +/* Encode a Unicode object to the Python filesystem encoding and error handler. + Return bytes. */ @NoException public static native PyObject PyUnicode_EncodeFSDefault( PyObject unicode ); @@ -6880,57 +7131,21 @@ Unicode ordinal integers or None (causing deletion of the character). /* --- Internal Unicode Operations ---------------------------------------- */ -// #ifndef USE_UNICODE_WCHAR_CACHE -public static final int USE_UNICODE_WCHAR_CACHE = 1; -// #endif /* USE_UNICODE_WCHAR_CACHE */ - -/* Since splitting on whitespace is an important use case, and - whitespace in most situations is solely ASCII whitespace, we - optimize for the common case by using a quick look-up table - _Py_ascii_whitespace (see below) with an inlined check. - - */ -// #define Py_UNICODE_ISSPACE(ch) -// ((Py_UCS4)(ch) < 128 ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch)) - -// #define Py_UNICODE_ISLOWER(ch) _PyUnicode_IsLowercase(ch) -// #define Py_UNICODE_ISUPPER(ch) _PyUnicode_IsUppercase(ch) -// #define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) -// #define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) - -// #define Py_UNICODE_TOLOWER(ch) _PyUnicode_ToLowercase(ch) -// #define Py_UNICODE_TOUPPER(ch) _PyUnicode_ToUppercase(ch) -// #define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) - -// #define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) -// #define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) -// #define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) -// #define Py_UNICODE_ISPRINTABLE(ch) _PyUnicode_IsPrintable(ch) +// Static inline functions to work with surrogates +@NoException public static native int Py_UNICODE_IS_SURROGATE(@Cast("Py_UCS4") int ch); +@NoException public static native int Py_UNICODE_IS_HIGH_SURROGATE(@Cast("Py_UCS4") int ch); +@NoException public static native int Py_UNICODE_IS_LOW_SURROGATE(@Cast("Py_UCS4") int ch); -// #define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) -// #define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) -// #define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) +// Join two surrogate characters and return a single Py_UCS4 value. +@NoException public static native @Cast("Py_UCS4") int Py_UNICODE_JOIN_SURROGATES(@Cast("Py_UCS4") int high, @Cast("Py_UCS4") int low); -// #define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch) +// High surrogate = top 10 bits added to 0xD800. +// The character must be in the range [U+10000; U+10ffff]. +@NoException public static native @Cast("Py_UCS4") int Py_UNICODE_HIGH_SURROGATE(@Cast("Py_UCS4") int ch); -// #define Py_UNICODE_ISALNUM(ch) -// (Py_UNICODE_ISALPHA(ch) || -// Py_UNICODE_ISDECIMAL(ch) || -// Py_UNICODE_ISDIGIT(ch) || -// Py_UNICODE_ISNUMERIC(ch)) - -/* macros to work with surrogates */ -// #define Py_UNICODE_IS_SURROGATE(ch) (0xD800 <= (ch) && (ch) <= 0xDFFF) -// #define Py_UNICODE_IS_HIGH_SURROGATE(ch) (0xD800 <= (ch) && (ch) <= 0xDBFF) -// #define Py_UNICODE_IS_LOW_SURROGATE(ch) (0xDC00 <= (ch) && (ch) <= 0xDFFF) -/* Join two surrogate characters and return a single Py_UCS4 value. */ -// #define Py_UNICODE_JOIN_SURROGATES(high, low) -// (((((Py_UCS4)(high) & 0x03FF) << 10) | -// ((Py_UCS4)(low) & 0x03FF)) + 0x10000) -/* high surrogate = top 10 bits added to D800 */ -// #define Py_UNICODE_HIGH_SURROGATE(ch) (0xD800 - (0x10000 >> 10) + ((ch) >> 10)) -/* low surrogate = bottom 10 bits added to DC00 */ -// #define Py_UNICODE_LOW_SURROGATE(ch) (0xDC00 + ((ch) & 0x3FF)) +// Low surrogate = bottom 10 bits added to 0xDC00. +// The character must be in the range [U+10000; U+10ffff]. +@NoException public static native @Cast("Py_UCS4") int Py_UNICODE_LOW_SURROGATE(@Cast("Py_UCS4") int ch); // Targeting ../PyASCIIObject.java @@ -6965,52 +7180,46 @@ Unicode ordinal integers or None (causing deletion of the character). public static final int SSTATE_NOT_INTERNED = 0; public static final int SSTATE_INTERNED_MORTAL = 1; public static final int SSTATE_INTERNED_IMMORTAL = 2; +public static final int SSTATE_INTERNED_IMMORTAL_STATIC = 3; /* Use only if you know it's a string */ @NoException public static native @Cast("unsigned int") int PyUnicode_CHECK_INTERNED(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyUnicode_CHECK_INTERNED(op) PyUnicode_CHECK_INTERNED(_PyObject_CAST(op)) -/* Fast check to determine whether an object is ready. Equivalent to: - PyUnicode_IS_COMPACT(op) || _PyUnicodeObject_CAST(op)->data.any */ -@NoException public static native @Cast("unsigned int") int PyUnicode_IS_READY(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +/* For backward compatibility */ + +// #define PyUnicode_IS_READY(op) PyUnicode_IS_READY(_PyObject_CAST(op)) /* Return true if the string contains only ASCII characters, or 0 if not. The string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be ready. */ @NoException public static native @Cast("unsigned int") int PyUnicode_IS_ASCII(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyUnicode_IS_ASCII(op) PyUnicode_IS_ASCII(_PyObject_CAST(op)) /* Return true if the string is compact or 0 if not. No type checks or Ready calls are performed. */ @NoException public static native @Cast("unsigned int") int PyUnicode_IS_COMPACT(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyUnicode_IS_COMPACT(op) PyUnicode_IS_COMPACT(_PyObject_CAST(op)) /* Return true if the string is a compact ASCII string (use PyASCIIObject structure), or 0 if not. No type checks or Ready calls are performed. */ @NoException public static native int PyUnicode_IS_COMPACT_ASCII(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyUnicode_IS_COMPACT_ASCII(op) PyUnicode_IS_COMPACT_ASCII(_PyObject_CAST(op)) /** enum PyUnicode_Kind */ public static final int -/* String contains only wstr byte characters. This is only possible - when the string was created with a legacy API and _PyUnicode_Ready() - has not been called yet. */ - PyUnicode_WCHAR_KIND = 0, /* Return values of the PyUnicode_KIND() function: */ PyUnicode_1BYTE_KIND = 1, PyUnicode_2BYTE_KIND = 2, PyUnicode_4BYTE_KIND = 4; -/* Return one of the PyUnicode_*_KIND values defined above. */ -// #define PyUnicode_KIND(op) -// (assert(PyUnicode_IS_READY(op)), -// _PyASCIIObject_CAST(op)->state.kind) +// PyUnicode_KIND(): Return one of the PyUnicode_*_KIND values defined above. +// +// gh-89653: Converting this macro to a static inline function would introduce +// new compiler warnings on "kind < PyUnicode_KIND(str)" (compare signed and +// unsigned numbers) where kind type is an int or on +// "unsigned int kind = PyUnicode_KIND(str)" (cast signed to unsigned). +// #define PyUnicode_KIND(op) _Py_RVALUE(_PyASCIIObject_CAST(op)->state.kind) /* Return a void pointer to the raw unicode buffer. */ @NoException public static native Pointer _PyUnicode_COMPACT_DATA(PyObject op); @@ -7018,8 +7227,7 @@ when the string was created with a legacy API and _PyUnicode_Ready() @NoException public static native Pointer _PyUnicode_NONCOMPACT_DATA(PyObject op); @NoException public static native Pointer PyUnicode_DATA(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyUnicode_DATA(op) PyUnicode_DATA(_PyObject_CAST(op)) /* Return pointers to the canonical representation cast to unsigned char, Py_UCS2, or Py_UCS4 for direct character access. @@ -7030,12 +7238,9 @@ No checks are performed, use PyUnicode_KIND() before to ensure // #define PyUnicode_2BYTE_DATA(op) _Py_STATIC_CAST(Py_UCS2*, PyUnicode_DATA(op)) // #define PyUnicode_4BYTE_DATA(op) _Py_STATIC_CAST(Py_UCS4*, PyUnicode_DATA(op)) -/* Returns the length of the unicode string. The caller has to make sure that - the string has it's canonical representation set before calling - this function. Call PyUnicode_(FAST_)Ready to ensure that. */ +/* Returns the length of the unicode string. */ @NoException public static native @Cast("Py_ssize_t") long PyUnicode_GET_LENGTH(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyUnicode_GET_LENGTH(op) PyUnicode_GET_LENGTH(_PyObject_CAST(op)) /* Write into the canonical representation, this function does not do any sanity checks and is intended for usage in loops. The caller should cache the @@ -7044,30 +7249,33 @@ index is the index in the string (starts at 0) and value is the new code point value which should be written to that location. */ @NoException public static native void PyUnicode_WRITE(int kind, Pointer data, @Cast("Py_ssize_t") long index, @Cast("Py_UCS4") int value); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyUnicode_WRITE(kind, data, index, value) +// PyUnicode_WRITE(_Py_STATIC_CAST(int, kind), _Py_CAST(void*, data), +// (index), _Py_STATIC_CAST(Py_UCS4, value)) /* Read a code point from the string's canonical representation. No checks or ready calls are performed. */ @NoException public static native @Cast("Py_UCS4") int PyUnicode_READ(int kind, @Const Pointer data, @Cast("Py_ssize_t") long index); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyUnicode_READ(kind, data, index) +// PyUnicode_READ(_Py_STATIC_CAST(int, kind), +// _Py_STATIC_CAST(const void*, data), +// (index)) /* PyUnicode_READ_CHAR() is less efficient than PyUnicode_READ() because it calls PyUnicode_KIND() and might call it twice. For single reads, use PyUnicode_READ_CHAR, for multiple consecutive reads callers should cache kind and use PyUnicode_READ instead. */ @NoException public static native @Cast("Py_UCS4") int PyUnicode_READ_CHAR(PyObject unicode, @Cast("Py_ssize_t") long index); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyUnicode_READ_CHAR(unicode, index) +// PyUnicode_READ_CHAR(_PyObject_CAST(unicode), (index)) /* Return a maximum character value which is suitable for creating another string based on op. This is always an approximation but more efficient than iterating over the string. */ @NoException public static native @Cast("Py_UCS4") int PyUnicode_MAX_CHAR_VALUE(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyUnicode_MAX_CHAR_VALUE(op) +// PyUnicode_MAX_CHAR_VALUE(_PyObject_CAST(op)) /* === Public API ========================================================= */ @@ -7081,24 +7289,9 @@ calls PyUnicode_KIND() and might call it twice. For single reads, use @Cast("Py_UCS4") int maxchar ); -/* Initializes the canonical string representation from the deprecated - wstr/Py_UNICODE representation. This function is used to convert Unicode - objects which were created using the old API to the new flexible format - introduced with PEP 393. +/* For backward compatibility */ - Don't call this function directly, use the public PyUnicode_READY() function - instead. */ -@NoException public static native int _PyUnicode_Ready( - PyObject unicode - ); - -/* PyUnicode_READY() does less work than _PyUnicode_Ready() in the best - case. If the canonical representation is not yet set, it will still call - _PyUnicode_Ready(). - Returns 0 on success and -1 on errors. */ -@NoException public static native int PyUnicode_READY(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyUnicode_READY(op) PyUnicode_READY(_PyObject_CAST(op)) /* Get a copy of a Unicode string. */ @NoException public static native PyObject _PyUnicode_Copy( @@ -7188,77 +7381,6 @@ may crash if parameters are invalid (e.g. if the output string PyObject unicode, @Cast("Py_ssize_t") long start, @Cast("Py_ssize_t") long end); - -/* --- Legacy deprecated API ---------------------------------------------- */ - -/* Create a Unicode Object from the Py_UNICODE buffer u of the given - size. - - u may be NULL which causes the contents to be undefined. It is the - user's responsibility to fill in the needed data afterwards. Note - that modifying the Unicode object contents after construction is - only allowed if u was set to NULL. - - The buffer is copied into the new object. */ -@NoException public static native @Deprecated PyObject PyUnicode_FromUnicode( - @Cast("const Py_UNICODE*") Pointer u, - @Cast("Py_ssize_t") long size - ); - -/* Return a read-only pointer to the Unicode object's internal - Py_UNICODE buffer. - If the wchar_t/Py_UNICODE representation is not yet available, this - function will calculate it. */ -@NoException public static native @Cast("Py_UNICODE*") @Deprecated Pointer PyUnicode_AsUnicode( - PyObject unicode - ); - -/* Similar to PyUnicode_AsUnicode(), but raises a ValueError if the string - contains null characters. */ -@NoException public static native @Cast("const Py_UNICODE*") Pointer _PyUnicode_AsUnicode( - PyObject unicode - ); - -/* Return a read-only pointer to the Unicode object's internal - Py_UNICODE buffer and save the length at size. - If the wchar_t/Py_UNICODE representation is not yet available, this - function will calculate it. */ - -@NoException public static native @Cast("Py_UNICODE*") @Deprecated Pointer PyUnicode_AsUnicodeAndSize( - PyObject unicode, - @Cast("Py_ssize_t*") SizeTPointer size - ); - - -/* Fast access macros */ - -@NoException public static native @Cast("Py_ssize_t") @Deprecated long PyUnicode_WSTR_LENGTH(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif - -/* Returns the deprecated Py_UNICODE representation's size in code units - (this includes surrogate pairs as 2 units). - If the Py_UNICODE representation is not available, it will be computed - on request. Use PyUnicode_GET_LENGTH() for the length in code points. */ - -@NoException public static native @Cast("Py_ssize_t") @Deprecated long PyUnicode_GET_SIZE(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif - -@NoException public static native @Cast("Py_ssize_t") @Deprecated long PyUnicode_GET_DATA_SIZE(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif - -/* Alias for PyUnicode_AsUnicode(). This will create a wchar_t/Py_UNICODE - representation on demand. Using this macro is very inefficient now, - try to port your code to use the new PyUnicode_*BYTE_DATA() macros or - use PyUnicode_WRITE() and PyUnicode_READ(). */ - -@NoException public static native @Cast("Py_UNICODE*") @Deprecated Pointer PyUnicode_AS_UNICODE(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif - -@NoException public static native @Deprecated @Cast("const char*") BytePointer PyUnicode_AS_DATA(PyObject op); // Targeting ../_PyUnicodeWriter.java @@ -7293,15 +7415,14 @@ use PyUnicode_WRITE() and PyUnicode_READ(). */ Return 0 on success, raise an exception and return -1 on error. */ // #define _PyUnicodeWriter_PrepareKind(WRITER, KIND) -// (assert((KIND) != PyUnicode_WCHAR_KIND), -// (KIND) <= (WRITER)->kind +// ((KIND) <= (WRITER)->kind // ? 0 // : _PyUnicodeWriter_PrepareKindInternal((WRITER), (KIND))) /* Don't call this function directly, use the _PyUnicodeWriter_PrepareKind() macro instead. */ @NoException public static native int _PyUnicodeWriter_PrepareKindInternal(_PyUnicodeWriter writer, - @Cast("PyUnicode_Kind") int kind); + int kind); /* Append a Unicode character. Return 0 on success, raise an exception and return -1 on error. */ @@ -7689,11 +7810,6 @@ Unicode ordinal integers or None (causing deletion of the character). /* === Characters Type APIs =============================================== */ -/* Helper array used by Py_UNICODE_ISSPACE(). */ - -@MemberGetter public static native @Cast("const unsigned char") byte _Py_ascii_whitespace(int i); -@MemberGetter public static native @Cast("const unsigned char*") BytePointer _Py_ascii_whitespace(); - /* These should not be used directly. Use the Py_UNICODE_IS* and Py_UNICODE_TO* macros instead. @@ -7833,6 +7949,41 @@ Unicode ordinal integers or None (causing deletion of the character). @Cast("Py_UCS4") int ch ); +// Helper array used by Py_UNICODE_ISSPACE(). +@MemberGetter public static native @Cast("const unsigned char") byte _Py_ascii_whitespace(int i); +@MemberGetter public static native @Cast("const unsigned char*") BytePointer _Py_ascii_whitespace(); + +// Since splitting on whitespace is an important use case, and +// whitespace in most situations is solely ASCII whitespace, we +// optimize for the common case by using a quick look-up table +// _Py_ascii_whitespace (see below) with an inlined check. +@NoException public static native int Py_UNICODE_ISSPACE(@Cast("Py_UCS4") int ch); + +// #define Py_UNICODE_ISLOWER(ch) _PyUnicode_IsLowercase(ch) +// #define Py_UNICODE_ISUPPER(ch) _PyUnicode_IsUppercase(ch) +// #define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) +// #define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) + +// #define Py_UNICODE_TOLOWER(ch) _PyUnicode_ToLowercase(ch) +// #define Py_UNICODE_TOUPPER(ch) _PyUnicode_ToUppercase(ch) +// #define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) + +// #define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) +// #define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) +// #define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) +// #define Py_UNICODE_ISPRINTABLE(ch) _PyUnicode_IsPrintable(ch) + +// #define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) +// #define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) +// #define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) + +// #define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch) + +@NoException public static native int Py_UNICODE_ISALNUM(@Cast("Py_UCS4") int ch); + + +/* === Misc functions ===================================================== */ + @NoException public static native PyObject _PyUnicode_FormatLong(PyObject arg0, int arg1, int arg2, int arg3); /* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/ @@ -7842,7 +7993,7 @@ Unicode ordinal integers or None (causing deletion of the character). and where the hash values are equal (i.e. a very probable match) */ @NoException public static native int _PyUnicode_EQ(PyObject arg0, PyObject arg1); -/* Equality check. Returns -1 on failure. */ +/* Equality check. */ @NoException public static native int _PyUnicode_Equal(PyObject arg0, PyObject arg1); @NoException public static native int _PyUnicode_WideCharString_Converter(PyObject arg0, Pointer arg1); @@ -7861,11 +8012,9 @@ and where the hash values are equal (i.e. a very probable match) */ /* Long (arbitrary precision) integer object interface */ -public static native @ByRef PyTypeObject PyLong_Type(); public static native void PyLong_Type(PyTypeObject setter); - // #define PyLong_Check(op) // PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS) -// #define PyLong_CheckExact(op) Py_IS_TYPE(op, &PyLong_Type) +// #define PyLong_CheckExact(op) Py_IS_TYPE((op), &PyLong_Type) @NoException public static native PyObject PyLong_FromLong(long arg0); @NoException public static native PyObject PyLong_FromUnsignedLong(@Cast("unsigned long") long arg0); @@ -8014,6 +8163,9 @@ and where the hash values are equal (i.e. a very probable match) */ public static final long PyLong_BASE = PyLong_BASE(); public static native @MemberGetter long PyLong_MASK(); public static final long PyLong_MASK = PyLong_MASK(); +// Targeting ../_PyLongValue.java + + // Targeting ../_longobject.java @@ -8023,6 +8175,27 @@ and where the hash values are equal (i.e. a very probable match) */ /* Return a copy of src. */ @NoException public static native PyObject _PyLong_Copy(PyLongObject src); +@NoException public static native PyLongObject _PyLong_FromDigits(int negative, @Cast("Py_ssize_t") long digit_count, @Cast("digit*") IntPointer digits); +@NoException public static native PyLongObject _PyLong_FromDigits(int negative, @Cast("Py_ssize_t") long digit_count, @Cast("digit*") IntBuffer digits); +@NoException public static native PyLongObject _PyLong_FromDigits(int negative, @Cast("Py_ssize_t") long digit_count, @Cast("digit*") int[] digits); + + +/* Inline some internals for speed. These should be in pycore_long.h + * if user code didn't need them inlined. */ + +public static final int _PyLong_SIGN_MASK = 3; +public static final int _PyLong_NON_SIZE_BITS = 3; + + +@NoException public static native int _PyLong_IsCompact(@Const PyLongObject op); + +// #define PyUnstable_Long_IsCompact _PyLong_IsCompact + +@NoException public static native @Cast("Py_ssize_t") long _PyLong_CompactValue(@Const PyLongObject op); + +// #define PyUnstable_Long_CompactValue _PyLong_CompactValue + + // #ifdef __cplusplus // #endif // #endif /* !Py_LONGINTREPR_H */ @@ -8038,21 +8211,17 @@ and where the hash values are equal (i.e. a very probable match) */ // #ifdef __cplusplus // #endif +// #define PyBool_Check(x) Py_IS_TYPE((x), &PyBool_Type) -public static native @ByRef PyTypeObject PyBool_Type(); public static native void PyBool_Type(PyTypeObject setter); - -// #define PyBool_Check(x) Py_IS_TYPE(x, &PyBool_Type) - -/* Py_False and Py_True are the only two bools in existence. -Don't forget to apply Py_INCREF() when returning either!!! */ +/* Py_False and Py_True are the only two bools in existence. */ /* Don't use these directly */ public static native @ByRef PyLongObject _Py_FalseStruct(); public static native void _Py_FalseStruct(PyLongObject setter); public static native @ByRef PyLongObject _Py_TrueStruct(); public static native void _Py_TrueStruct(PyLongObject setter); /* Use these macros */ -// #define Py_False ((PyObject *) &_Py_FalseStruct) -// #define Py_True ((PyObject *) &_Py_TrueStruct) +// #define Py_False _PyObject_CAST(&_Py_FalseStruct) +// #define Py_True _PyObject_CAST(&_Py_TrueStruct) // Test if an object is the True singleton, the same as "x is True" in Python. @NoException public static native int Py_IsTrue(PyObject x); @@ -8063,8 +8232,8 @@ and where the hash values are equal (i.e. a very probable match) */ // #define Py_IsFalse(x) Py_Is((x), Py_False) /* Macros for returning Py_True or Py_False, respectively */ -// #define Py_RETURN_TRUE return Py_NewRef(Py_True) -// #define Py_RETURN_FALSE return Py_NewRef(Py_False) +// #define Py_RETURN_TRUE return Py_True +// #define Py_RETURN_FALSE return Py_False /* Function to return a bool from a C long */ @NoException public static native PyObject PyBool_FromLong(long arg0); @@ -8091,7 +8260,7 @@ PyFloatObject represents a (double precision) floating point number. public static native @ByRef PyTypeObject PyFloat_Type(); public static native void PyFloat_Type(PyTypeObject setter); // #define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type) -// #define PyFloat_CheckExact(op) Py_IS_TYPE(op, &PyFloat_Type) +// #define PyFloat_CheckExact(op) Py_IS_TYPE((op), &PyFloat_Type) // #define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN) @@ -8143,8 +8312,8 @@ PyFloatObject represents a (double precision) floating point number. public static native @ByRef PyTypeObject PyComplex_Type(); public static native void PyComplex_Type(PyTypeObject setter); -// #define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type) -// #define PyComplex_CheckExact(op) Py_IS_TYPE(op, &PyComplex_Type) +// #define PyComplex_Check(op) PyObject_TypeCheck((op), &PyComplex_Type) +// #define PyComplex_CheckExact(op) Py_IS_TYPE((op), &PyComplex_Type) @NoException public static native PyObject PyComplex_FromDoubles(double real, double imag); @@ -8184,7 +8353,7 @@ PyFloatObject represents a (double precision) floating point number. public static native @ByRef PyTypeObject PyRangeIter_Type(); public static native void PyRangeIter_Type(PyTypeObject setter); public static native @ByRef PyTypeObject PyLongRangeIter_Type(); public static native void PyLongRangeIter_Type(PyTypeObject setter); -// #define PyRange_Check(op) Py_IS_TYPE(op, &PyRange_Type) +// #define PyRange_Check(op) Py_IS_TYPE((op), &PyRange_Type) // #ifdef __cplusplus // #endif @@ -8200,19 +8369,9 @@ PyFloatObject represents a (double precision) floating point number. // #ifdef __cplusplus // #endif -// #ifndef Py_LIMITED_API -public static native @ByRef PyTypeObject _PyManagedBuffer_Type(); public static native void _PyManagedBuffer_Type(PyTypeObject setter); -// #endif public static native @ByRef PyTypeObject PyMemoryView_Type(); public static native void PyMemoryView_Type(PyTypeObject setter); -// #define PyMemoryView_Check(op) Py_IS_TYPE(op, &PyMemoryView_Type) - -// #ifndef Py_LIMITED_API -/* Get a pointer to the memoryview's private copy of the exporter's buffer. */ -// #define PyMemoryView_GET_BUFFER(op) (&((PyMemoryViewObject *)(op))->view) -/* Get a pointer to the exporting object (this may be NULL!). */ -// #define PyMemoryView_GET_BASE(op) (((PyMemoryViewObject *)(op))->view.obj) -// #endif +// #define PyMemoryView_Check(op) Py_IS_TYPE((op), &PyMemoryView_Type) @NoException public static native PyObject PyMemoryView_FromObject(PyObject base); // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 @@ -8230,27 +8389,10 @@ PyFloatObject represents a (double precision) floating point number. int buffertype, @Cast("char") byte order); - -/* The structs are declared here so that macros can work, but they shouldn't - be considered public. Don't access their fields directly, use the macros - and functions instead! */ // #ifndef Py_LIMITED_API -public static final int _Py_MANAGED_BUFFER_RELEASED = 0x001; /* access to exporter blocked */ -public static final int _Py_MANAGED_BUFFER_FREE_FORMAT = 0x002; -// Targeting ../_PyManagedBufferObject.java - - - - -/* memoryview state flags */ -public static final int _Py_MEMORYVIEW_RELEASED = 0x001; /* access to master buffer blocked */ -public static final int _Py_MEMORYVIEW_C = 0x002; /* C-contiguous layout */ -public static final int _Py_MEMORYVIEW_FORTRAN = 0x004; /* Fortran contiguous layout */ -public static final int _Py_MEMORYVIEW_SCALAR = 0x008; /* scalar: ndim = 0 */ -public static final int _Py_MEMORYVIEW_PIL = 0x010; -// Targeting ../PyMemoryViewObject.java - - +// # define Py_CPYTHON_MEMORYOBJECT_H +// # include "cpython/memoryobject.h" +// # undef Py_CPYTHON_MEMORYOBJECT_H // #endif // #ifdef __cplusplus @@ -8286,7 +8428,7 @@ PyFloatObject represents a (double precision) floating point number. // #define PyTuple_Check(op) // PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS) -// #define PyTuple_CheckExact(op) Py_IS_TYPE(op, &PyTuple_Type) +// #define PyTuple_CheckExact(op) Py_IS_TYPE((op), &PyTuple_Type) @NoException public static native PyObject PyTuple_New(@Cast("Py_ssize_t") long size); @NoException public static native @Cast("Py_ssize_t") long PyTuple_Size(PyObject arg0); @@ -8325,15 +8467,14 @@ PyFloatObject represents a (double precision) floating point number. // Macros and static inline functions, trading safety for speed @NoException public static native @Cast("Py_ssize_t") long PyTuple_GET_SIZE(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyTuple_GET_SIZE(op) PyTuple_GET_SIZE(_PyObject_CAST(op)) -// #define PyTuple_GET_ITEM(op, index) (_PyTuple_CAST(op)->ob_item[index]) +// #define PyTuple_GET_ITEM(op, index) (_PyTuple_CAST(op)->ob_item[(index)]) /* Function *only* to be used to fill in brand new tuples */ @NoException public static native void PyTuple_SET_ITEM(PyObject op, @Cast("Py_ssize_t") long index, PyObject value); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyTuple_SET_ITEM(op, index, value) +// PyTuple_SET_ITEM(_PyObject_CAST(op), (index), _PyObject_CAST(value)) @NoException public static native void _PyTuple_DebugMallocStats(@Cast("FILE*") Pointer out); @@ -8364,7 +8505,7 @@ PyFloatObject represents a (double precision) floating point number. // #define PyList_Check(op) // PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS) -// #define PyList_CheckExact(op) Py_IS_TYPE(op, &PyList_Type) +// #define PyList_CheckExact(op) Py_IS_TYPE((op), &PyList_Type) @NoException public static native PyObject PyList_New(@Cast("Py_ssize_t") long size); @NoException public static native @Cast("Py_ssize_t") long PyList_Size(PyObject arg0); @@ -8410,14 +8551,13 @@ PyFloatObject represents a (double precision) floating point number. // Macros and static inline functions, trading safety for speed @NoException public static native @Cast("Py_ssize_t") long PyList_GET_SIZE(PyObject op); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyList_GET_SIZE(op) PyList_GET_SIZE(_PyObject_CAST(op)) -// #define PyList_GET_ITEM(op, index) (_PyList_CAST(op)->ob_item[index]) +// #define PyList_GET_ITEM(op, index) (_PyList_CAST(op)->ob_item[(index)]) @NoException public static native void PyList_SET_ITEM(PyObject op, @Cast("Py_ssize_t") long index, PyObject value); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyList_SET_ITEM(op, index, value) +// PyList_SET_ITEM(_PyObject_CAST(op), (index), _PyObject_CAST(value)) // Parsed from dictobject.h @@ -8439,7 +8579,7 @@ PyFloatObject represents a (double precision) floating point number. // #define PyDict_Check(op) // PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS) -// #define PyDict_CheckExact(op) Py_IS_TYPE(op, &PyDict_Type) +// #define PyDict_CheckExact(op) Py_IS_TYPE((op), &PyDict_Type) @NoException public static native PyObject PyDict_New(); @NoException public static native PyObject PyDict_GetItem(PyObject mp, PyObject key); @@ -8495,9 +8635,9 @@ of a key wins, else the first. The Python dict constructor dict(seq2) public static native @ByRef PyTypeObject PyDictValues_Type(); public static native void PyDictValues_Type(PyTypeObject setter); public static native @ByRef PyTypeObject PyDictItems_Type(); public static native void PyDictItems_Type(PyTypeObject setter); -// #define PyDictKeys_Check(op) PyObject_TypeCheck(op, &PyDictKeys_Type) -// #define PyDictValues_Check(op) PyObject_TypeCheck(op, &PyDictValues_Type) -// #define PyDictItems_Check(op) PyObject_TypeCheck(op, &PyDictItems_Type) +// #define PyDictKeys_Check(op) PyObject_TypeCheck((op), &PyDictKeys_Type) +// #define PyDictValues_Check(op) PyObject_TypeCheck((op), &PyDictValues_Type) +// #define PyDictItems_Check(op) PyObject_TypeCheck((op), &PyDictItems_Type) /* This excludes Values, since they are not sets. */ // # define PyDictViewSet_Check(op) // (PyDictKeys_Check(op) || PyDictItems_Check(op)) @@ -8562,7 +8702,9 @@ of a key wins, else the first. The Python dict constructor dict(seq2) PyObject mp, @Cast("Py_ssize_t*") SizeTPointer pos, @ByPtrPtr PyObject key, @ByPtrPtr PyObject value, @Cast("Py_hash_t*") SizeTPointer hash); /* Get the number of items of a dictionary. */ -// #define PyDict_GET_SIZE(mp) (assert(PyDict_Check(mp)),((PyDictObject *)mp)->ma_used) +@NoException public static native @Cast("Py_ssize_t") long PyDict_GET_SIZE(PyObject op); +// #define PyDict_GET_SIZE(op) PyDict_GET_SIZE(_PyObject_CAST(op)) + @NoException public static native int _PyDict_Contains_KnownHash(PyObject arg0, PyObject arg1, @Cast("Py_hash_t") long arg2); @NoException public static native int _PyDict_ContainsId(PyObject arg0, _Py_Identifier arg1); @NoException public static native PyObject _PyDict_NewPresized(@Cast("Py_ssize_t") long minused); @@ -8589,70 +8731,92 @@ of a key wins, else the first. The Python dict constructor dict(seq2) @NoException public static native PyObject _PyDictView_Intersect(PyObject self, PyObject other); +/* Dictionary watchers */ -// Parsed from structmember.h +// #define PY_FOREACH_DICT_EVENT(V) +// V(ADDED) +// V(MODIFIED) +// V(DELETED) +// V(CLONED) +// V(CLEARED) +// V(DEALLOCATED) -// #ifndef Py_STRUCTMEMBER_H -// #define Py_STRUCTMEMBER_H -// #ifdef __cplusplus -// #endif +/** enum PyDict_WatchEvent */ +// #define PY_DEF_EVENT(EVENT) PyDict_EVENT_##EVENT, +public static final int + PyDict_EVENT_ADDED = 0, + PyDict_EVENT_MODIFIED = 1, + PyDict_EVENT_DELETED = 2, + PyDict_EVENT_CLONED = 3, + PyDict_EVENT_CLEARED = 4, + PyDict_EVENT_DEALLOCATED = 5; +// #undef PY_DEF_EVENT +// Targeting ../PyDict_WatchCallback.java -/* Interface to map C struct members to Python object attributes */ -// #include -// Targeting ../PyMemberDef.java +// Register/unregister a dict-watcher callback +@NoException public static native int PyDict_AddWatcher(PyDict_WatchCallback callback); +@NoException public static native int PyDict_ClearWatcher(int watcher_id); +// Mark given dictionary as "watched" (callback will be called if it is modified) +@NoException public static native int PyDict_Watch(int watcher_id, PyObject dict); +@NoException public static native int PyDict_Unwatch(int watcher_id, PyObject dict); -/* Types */ -public static final int T_SHORT = 0; -public static final int T_INT = 1; -public static final int T_LONG = 2; -public static final int T_FLOAT = 3; -public static final int T_DOUBLE = 4; -public static final int T_STRING = 5; -public static final int T_OBJECT = 6; -/* XXX the ordering here is weird for binary compatibility */ -public static final int T_CHAR = 7; /* 1-character string */ -public static final int T_BYTE = 8; /* 8-bit signed int */ -/* unsigned variants: */ -public static final int T_UBYTE = 9; -public static final int T_USHORT = 10; -public static final int T_UINT = 11; -public static final int T_ULONG = 12; -/* Added by Jack: strings contained in the structure */ -public static final int T_STRING_INPLACE = 13; +// Parsed from structmember.h -/* Added by Lillo: bools contained in the structure (assumed char) */ -public static final int T_BOOL = 14; +// #ifndef Py_STRUCTMEMBER_H +// #define Py_STRUCTMEMBER_H +// #ifdef __cplusplus +// #endif -public static final int T_OBJECT_EX = 16; /* Like T_OBJECT, but raises AttributeError - when the value is NULL, instead of - converting to None. */ -public static final int T_LONGLONG = 17; -public static final int T_ULONGLONG = 18; -public static final int T_PYSSIZET = 19; /* Py_ssize_t */ -public static final int T_NONE = 20; /* Value is always None */ +/* Interface to map C struct members to Python object attributes + * + * This header is deprecated: new code should not use stuff from here. + * New definitions are in descrobject.h. + * + * However, there's nothing wrong with old code continuing to use it, + * and there's not much mainenance overhead in maintaining a few aliases. + * So, don't be too eager to convert old code. + * + * It uses names not prefixed with Py_. + * It is also *not* included from Python.h and must be included individually. + */ + +// #include /* For offsetof (not always provided by Python.h) */ +/* Types */ +public static final int T_SHORT = Py_T_SHORT; +public static final int T_INT = Py_T_INT; +public static final int T_LONG = Py_T_LONG; +public static final int T_FLOAT = Py_T_FLOAT; +public static final int T_DOUBLE = Py_T_DOUBLE; +public static final int T_STRING = Py_T_STRING; +public static final int T_OBJECT = _Py_T_OBJECT; +public static final int T_CHAR = Py_T_CHAR; +public static final int T_BYTE = Py_T_BYTE; +public static final int T_UBYTE = Py_T_UBYTE; +public static final int T_USHORT = Py_T_USHORT; +public static final int T_UINT = Py_T_UINT; +public static final int T_ULONG = Py_T_ULONG; +public static final int T_STRING_INPLACE = Py_T_STRING_INPLACE; +public static final int T_BOOL = Py_T_BOOL; +public static final int T_OBJECT_EX = Py_T_OBJECT_EX; +public static final int T_LONGLONG = Py_T_LONGLONG; +public static final int T_ULONGLONG = Py_T_ULONGLONG; +public static final int T_PYSSIZET = Py_T_PYSSIZET; +public static final int T_NONE = _Py_T_NONE; /* Flags */ -public static final int READONLY = 1; -public static final int READ_RESTRICTED = 2; -public static final int PY_WRITE_RESTRICTED = 4; +public static final int READONLY = Py_READONLY; +public static final int PY_AUDIT_READ = Py_AUDIT_READ; +public static final int READ_RESTRICTED = Py_AUDIT_READ; +public static final int PY_WRITE_RESTRICTED = _Py_WRITE_RESTRICTED; public static final int RESTRICTED = (READ_RESTRICTED | PY_WRITE_RESTRICTED); -public static final int PY_AUDIT_READ = READ_RESTRICTED; - -/* Current API, use this */ -@NoException public static native PyObject PyMember_GetOne(@Cast("const char*") BytePointer arg0, PyMemberDef arg1); -@NoException public static native PyObject PyMember_GetOne(String arg0, PyMemberDef arg1); -@NoException public static native int PyMember_SetOne(@Cast("char*") BytePointer arg0, PyMemberDef arg1, PyObject arg2); -@NoException public static native int PyMember_SetOne(@Cast("char*") ByteBuffer arg0, PyMemberDef arg1, PyObject arg2); -@NoException public static native int PyMember_SetOne(@Cast("char*") byte[] arg0, PyMemberDef arg1, PyObject arg2); - // #ifdef __cplusplus // #endif @@ -8674,8 +8838,8 @@ of a key wins, else the first. The Python dict constructor dict(seq2) public static native @ByRef PyTypeObject PyODictItems_Type(); public static native void PyODictItems_Type(PyTypeObject setter); public static native @ByRef PyTypeObject PyODictValues_Type(); public static native void PyODictValues_Type(PyTypeObject setter); -// #define PyODict_Check(op) PyObject_TypeCheck(op, &PyODict_Type) -// #define PyODict_CheckExact(op) Py_IS_TYPE(op, &PyODict_Type) +// #define PyODict_Check(op) PyObject_TypeCheck((op), &PyODict_Type) +// #define PyODict_CheckExact(op) Py_IS_TYPE((op), &PyODict_Type) // #define PyODict_SIZE(op) PyDict_GET_SIZE((op)) @NoException public static native PyObject PyODict_New(); @@ -8683,13 +8847,13 @@ of a key wins, else the first. The Python dict constructor dict(seq2) @NoException public static native int PyODict_DelItem(PyObject od, PyObject key); /* wrappers around PyDict* functions */ -// #define PyODict_GetItem(od, key) PyDict_GetItem(_PyObject_CAST(od), key) +// #define PyODict_GetItem(od, key) PyDict_GetItem(_PyObject_CAST(od), (key)) // #define PyODict_GetItemWithError(od, key) -// PyDict_GetItemWithError(_PyObject_CAST(od), key) -// #define PyODict_Contains(od, key) PyDict_Contains(_PyObject_CAST(od), key) +// PyDict_GetItemWithError(_PyObject_CAST(od), (key)) +// #define PyODict_Contains(od, key) PyDict_Contains(_PyObject_CAST(od), (key)) // #define PyODict_Size(od) PyDict_Size(_PyObject_CAST(od)) // #define PyODict_GetItemString(od, key) -// PyDict_GetItemString(_PyObject_CAST(od), key) +// PyDict_GetItemString(_PyObject_CAST(od), (key)) // #endif @@ -8740,21 +8904,21 @@ of a key wins, else the first. The Python dict constructor dict(seq2) @NoException public static native PyObject PySet_Pop(PyObject set); @NoException public static native @Cast("Py_ssize_t") long PySet_Size(PyObject anyset); -// #define PyFrozenSet_CheckExact(ob) Py_IS_TYPE(ob, &PyFrozenSet_Type) +// #define PyFrozenSet_CheckExact(ob) Py_IS_TYPE((ob), &PyFrozenSet_Type) // #define PyFrozenSet_Check(ob) -// (Py_IS_TYPE(ob, &PyFrozenSet_Type) || +// (Py_IS_TYPE((ob), &PyFrozenSet_Type) || // PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) // #define PyAnySet_CheckExact(ob) -// (Py_IS_TYPE(ob, &PySet_Type) || Py_IS_TYPE(ob, &PyFrozenSet_Type)) +// (Py_IS_TYPE((ob), &PySet_Type) || Py_IS_TYPE((ob), &PyFrozenSet_Type)) // #define PyAnySet_Check(ob) -// (Py_IS_TYPE(ob, &PySet_Type) || Py_IS_TYPE(ob, &PyFrozenSet_Type) || +// (Py_IS_TYPE((ob), &PySet_Type) || Py_IS_TYPE((ob), &PyFrozenSet_Type) || // PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || // PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) // #define PySet_CheckExact(op) Py_IS_TYPE(op, &PySet_Type) // #define PySet_Check(ob) -// (Py_IS_TYPE(ob, &PySet_Type) || +// (Py_IS_TYPE((ob), &PySet_Type) || // PyType_IsSubtype(Py_TYPE(ob), &PySet_Type)) // #ifndef Py_LIMITED_API @@ -8784,8 +8948,8 @@ of a key wins, else the first. The Python dict constructor dict(seq2) public static native @ByRef PyTypeObject PyCFunction_Type(); public static native void PyCFunction_Type(PyTypeObject setter); -// #define PyCFunction_CheckExact(op) Py_IS_TYPE(op, &PyCFunction_Type) -// #define PyCFunction_Check(op) PyObject_TypeCheck(op, &PyCFunction_Type) +// #define PyCFunction_CheckExact(op) Py_IS_TYPE((op), &PyCFunction_Type) +// #define PyCFunction_Check(op) PyObject_TypeCheck((op), &PyCFunction_Type) // Targeting ../PyCFunction.java @@ -8922,27 +9086,23 @@ of a key wins, else the first. The Python dict constructor dict(seq2) public static native @ByRef PyTypeObject PyCMethod_Type(); public static native void PyCMethod_Type(PyTypeObject setter); -// #define PyCMethod_CheckExact(op) Py_IS_TYPE(op, &PyCMethod_Type) -// #define PyCMethod_Check(op) PyObject_TypeCheck(op, &PyCMethod_Type) +// #define PyCMethod_CheckExact(op) Py_IS_TYPE((op), &PyCMethod_Type) +// #define PyCMethod_Check(op) PyObject_TypeCheck((op), &PyCMethod_Type) /* Static inline functions for direct access to these values. Type checks are *not* done, so use with care. */ @NoException public static native PyCFunction PyCFunction_GET_FUNCTION(PyObject func); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(_PyObject_CAST(func)) @NoException public static native PyObject PyCFunction_GET_SELF(PyObject func_obj); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyCFunction_GET_SELF(func) PyCFunction_GET_SELF(_PyObject_CAST(func)) @NoException public static native int PyCFunction_GET_FLAGS(PyObject func); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyCFunction_GET_FLAGS(func) PyCFunction_GET_FLAGS(_PyObject_CAST(func)) @NoException public static native PyTypeObject PyCFunction_GET_CLASS(PyObject func_obj); -// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -// #endif +// #define PyCFunction_GET_CLASS(func) PyCFunction_GET_CLASS(_PyObject_CAST(func)) // Parsed from moduleobject.h @@ -8957,8 +9117,8 @@ of a key wins, else the first. The Python dict constructor dict(seq2) public static native @ByRef PyTypeObject PyModule_Type(); public static native void PyModule_Type(PyTypeObject setter); -// #define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type) -// #define PyModule_CheckExact(op) Py_IS_TYPE(op, &PyModule_Type) +// #define PyModule_Check(op) PyObject_TypeCheck((op), &PyModule_Type) +// #define PyModule_CheckExact(op) Py_IS_TYPE((op), &PyModule_Type) // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 @NoException public static native PyObject PyModule_NewObject( @@ -9006,9 +9166,19 @@ of a key wins, else the first. The Python dict constructor dict(seq2) public static final int Py_mod_create = 1; public static final int Py_mod_exec = 2; +public static final int Py_mod_multiple_interpreters = 3; // #ifndef Py_LIMITED_API -public static final int _Py_mod_LAST_SLOT = 2; +public static final int _Py_mod_LAST_SLOT = 3; +// #endif + +/* for Py_mod_multiple_interpreters: */ +public static native @MemberGetter Pointer Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED(); +public static final Pointer Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED = Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED(); +public static native @MemberGetter Pointer Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED(); +public static final Pointer Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED = Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED(); +public static native @MemberGetter Pointer Py_MOD_PER_INTERPRETER_GIL_SUPPORTED(); +public static final Pointer Py_MOD_PER_INTERPRETER_GIL_SUPPORTED = Py_MOD_PER_INTERPRETER_GIL_SUPPORTED(); // Targeting ../PyModuleDef.java @@ -9052,7 +9222,7 @@ of a key wins, else the first. The Python dict constructor dict(seq2) public static native @ByRef PyTypeObject PyFunction_Type(); public static native void PyFunction_Type(PyTypeObject setter); -// #define PyFunction_Check(op) Py_IS_TYPE(op, &PyFunction_Type) +// #define PyFunction_Check(op) Py_IS_TYPE((op), &PyFunction_Type) @NoException public static native PyObject PyFunction_New(PyObject arg0, PyObject arg1); @NoException public static native PyObject PyFunction_NewWithQualName(PyObject arg0, PyObject arg1, PyObject arg2); @@ -9061,6 +9231,7 @@ of a key wins, else the first. The Python dict constructor dict(seq2) @NoException public static native PyObject PyFunction_GetModule(PyObject arg0); @NoException public static native PyObject PyFunction_GetDefaults(PyObject arg0); @NoException public static native int PyFunction_SetDefaults(PyObject arg0, PyObject arg1); +@NoException public static native void PyFunction_SetVectorcall(PyFunctionObject arg0, vectorcallfunc arg1); @NoException public static native PyObject PyFunction_GetKwDefaults(PyObject arg0); @NoException public static native int PyFunction_SetKwDefaults(PyObject arg0, PyObject arg1); @NoException public static native PyObject PyFunction_GetClosure(PyObject arg0); @@ -9079,22 +9250,31 @@ of a key wins, else the first. The Python dict constructor dict(seq2) @Cast("size_t") long nargsf, PyObject kwnames); -/* Macros for direct access to these values. Type checks are *not* - done, so use with care. */ -// #define PyFunction_GET_CODE(func) -// (((PyFunctionObject *)func) -> func_code) -// #define PyFunction_GET_GLOBALS(func) -// (((PyFunctionObject *)func) -> func_globals) -// #define PyFunction_GET_MODULE(func) -// (((PyFunctionObject *)func) -> func_module) -// #define PyFunction_GET_DEFAULTS(func) -// (((PyFunctionObject *)func) -> func_defaults) -// #define PyFunction_GET_KW_DEFAULTS(func) -// (((PyFunctionObject *)func) -> func_kwdefaults) -// #define PyFunction_GET_CLOSURE(func) -// (((PyFunctionObject *)func) -> func_closure) -// #define PyFunction_GET_ANNOTATIONS(func) -// (((PyFunctionObject *)func) -> func_annotations) +// #define _PyFunction_CAST(func) +// (assert(PyFunction_Check(func)), _Py_CAST(PyFunctionObject*, func)) + +/* Static inline functions for direct access to these values. + Type checks are *not* done, so use with care. */ +@NoException public static native PyObject PyFunction_GET_CODE(PyObject func); +// #define PyFunction_GET_CODE(func) PyFunction_GET_CODE(_PyObject_CAST(func)) + +@NoException public static native PyObject PyFunction_GET_GLOBALS(PyObject func); +// #define PyFunction_GET_GLOBALS(func) PyFunction_GET_GLOBALS(_PyObject_CAST(func)) + +@NoException public static native PyObject PyFunction_GET_MODULE(PyObject func); +// #define PyFunction_GET_MODULE(func) PyFunction_GET_MODULE(_PyObject_CAST(func)) + +@NoException public static native PyObject PyFunction_GET_DEFAULTS(PyObject func); +// #define PyFunction_GET_DEFAULTS(func) PyFunction_GET_DEFAULTS(_PyObject_CAST(func)) + +@NoException public static native PyObject PyFunction_GET_KW_DEFAULTS(PyObject func); +// #define PyFunction_GET_KW_DEFAULTS(func) PyFunction_GET_KW_DEFAULTS(_PyObject_CAST(func)) + +@NoException public static native PyObject PyFunction_GET_CLOSURE(PyObject func); +// #define PyFunction_GET_CLOSURE(func) PyFunction_GET_CLOSURE(_PyObject_CAST(func)) + +@NoException public static native PyObject PyFunction_GET_ANNOTATIONS(PyObject func); +// #define PyFunction_GET_ANNOTATIONS(func) PyFunction_GET_ANNOTATIONS(_PyObject_CAST(func)) /* The classmethod and staticmethod types lives here, too */ public static native @ByRef PyTypeObject PyClassMethod_Type(); public static native void PyClassMethod_Type(PyTypeObject setter); @@ -9103,6 +9283,43 @@ of a key wins, else the first. The Python dict constructor dict(seq2) @NoException public static native PyObject PyClassMethod_New(PyObject arg0); @NoException public static native PyObject PyStaticMethod_New(PyObject arg0); +// #define PY_FOREACH_FUNC_EVENT(V) +// V(CREATE) +// V(DESTROY) +// V(MODIFY_CODE) +// V(MODIFY_DEFAULTS) +// V(MODIFY_KWDEFAULTS) + +/** enum PyFunction_WatchEvent */ + +// #define PY_DEF_EVENT(EVENT) PyFunction_EVENT_##EVENT, +public static final int + PyFunction_EVENT_CREATE = 0, + PyFunction_EVENT_DESTROY = 1, + PyFunction_EVENT_MODIFY_CODE = 2, + PyFunction_EVENT_MODIFY_DEFAULTS = 3, + PyFunction_EVENT_MODIFY_KWDEFAULTS = 4; +// #undef PY_DEF_EVENT +// Targeting ../PyFunction_WatchCallback.java + + + +/* + * Register a per-interpreter callback that will be invoked for function lifecycle + * events. + * + * Returns a handle that may be passed to PyFunction_ClearWatcher on success, + * or -1 and sets an error if no more handles are available. + */ +@NoException public static native int PyFunction_AddWatcher(PyFunction_WatchCallback callback); + +/* + * Clear the watcher associated with the watcher_id handle. + * + * Returns 0 on success or -1 if no watcher exists for the supplied id. + */ +@NoException public static native int PyFunction_ClearWatcher(int watcher_id); + // #ifdef __cplusplus // #endif // #endif /* !Py_FUNCOBJECT_H */ @@ -9125,34 +9342,42 @@ of a key wins, else the first. The Python dict constructor dict(seq2) public static native @ByRef PyTypeObject PyMethod_Type(); public static native void PyMethod_Type(PyTypeObject setter); -// #define PyMethod_Check(op) Py_IS_TYPE(op, &PyMethod_Type) +// #define PyMethod_Check(op) Py_IS_TYPE((op), &PyMethod_Type) @NoException public static native PyObject PyMethod_New(PyObject arg0, PyObject arg1); @NoException public static native PyObject PyMethod_Function(PyObject arg0); @NoException public static native PyObject PyMethod_Self(PyObject arg0); -/* Macros for direct access to these values. Type checks are *not* - done, so use with care. */ -// #define PyMethod_GET_FUNCTION(meth) -// (((PyMethodObject *)meth) -> im_func) -// #define PyMethod_GET_SELF(meth) -// (((PyMethodObject *)meth) -> im_self) +// #define _PyMethod_CAST(meth) +// (assert(PyMethod_Check(meth)), _Py_CAST(PyMethodObject*, meth)) + +/* Static inline functions for direct access to these values. + Type checks are *not* done, so use with care. */ +@NoException public static native PyObject PyMethod_GET_FUNCTION(PyObject meth); +// #define PyMethod_GET_FUNCTION(meth) PyMethod_GET_FUNCTION(_PyObject_CAST(meth)) + +@NoException public static native PyObject PyMethod_GET_SELF(PyObject meth); +// #define PyMethod_GET_SELF(meth) PyMethod_GET_SELF(_PyObject_CAST(meth)) // Targeting ../PyInstanceMethodObject.java public static native @ByRef PyTypeObject PyInstanceMethod_Type(); public static native void PyInstanceMethod_Type(PyTypeObject setter); -// #define PyInstanceMethod_Check(op) Py_IS_TYPE(op, &PyInstanceMethod_Type) +// #define PyInstanceMethod_Check(op) Py_IS_TYPE((op), &PyInstanceMethod_Type) @NoException public static native PyObject PyInstanceMethod_New(PyObject arg0); @NoException public static native PyObject PyInstanceMethod_Function(PyObject arg0); -/* Macros for direct access to these values. Type checks are *not* - done, so use with care. */ -// #define PyInstanceMethod_GET_FUNCTION(meth) -// (((PyInstanceMethodObject *)meth) -> func) +// #define _PyInstanceMethod_CAST(meth) +// (assert(PyInstanceMethod_Check(meth)), +// _Py_CAST(PyInstanceMethodObject*, meth)) + +/* Static inline function for direct access to these values. + Type checks are *not* done, so use with care. */ +@NoException public static native PyObject PyInstanceMethod_GET_FUNCTION(PyObject meth); +// #define PyInstanceMethod_GET_FUNCTION(meth) PyInstanceMethod_GET_FUNCTION(_PyObject_CAST(meth)) // #ifdef __cplusplus // #endif @@ -9186,14 +9411,14 @@ of a key wins, else the first. The Python dict constructor dict(seq2) /* The default encoding used by the platform file system APIs If non-NULL, this is different than the default encoding for strings */ -public static native @Cast("const char*") BytePointer Py_FileSystemDefaultEncoding(); public static native void Py_FileSystemDefaultEncoding(BytePointer setter); +public static native @Deprecated @Cast("const char*") BytePointer Py_FileSystemDefaultEncoding(); public static native void Py_FileSystemDefaultEncoding(BytePointer setter); // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000 -public static native @Cast("const char*") BytePointer Py_FileSystemDefaultEncodeErrors(); public static native void Py_FileSystemDefaultEncodeErrors(BytePointer setter); +public static native @Deprecated @Cast("const char*") BytePointer Py_FileSystemDefaultEncodeErrors(); public static native void Py_FileSystemDefaultEncodeErrors(BytePointer setter); // #endif -public static native int Py_HasFileSystemDefaultEncoding(); public static native void Py_HasFileSystemDefaultEncoding(int setter); +public static native @Deprecated int Py_HasFileSystemDefaultEncoding(); public static native void Py_HasFileSystemDefaultEncoding(int setter); // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000 -public static native int Py_UTF8Mode(); public static native void Py_UTF8Mode(int setter); +public static native @Deprecated int Py_UTF8Mode(); public static native void Py_UTF8Mode(int setter); // #endif /* A routine to check if a file descriptor can be select()-ed. */ @@ -9325,7 +9550,7 @@ of a key wins, else the first. The Python dict constructor dict(seq2) -// #define PyCapsule_CheckExact(op) Py_IS_TYPE(op, &PyCapsule_Type) +// #define PyCapsule_CheckExact(op) Py_IS_TYPE((op), &PyCapsule_Type) @NoException public static native PyObject PyCapsule_New( @@ -9413,7 +9638,7 @@ of a key wins, else the first. The Python dict constructor dict(seq2) /* Reveal traceback type so we can typecheck traceback objects */ public static native @ByRef PyTypeObject PyTraceBack_Type(); public static native void PyTraceBack_Type(PyTypeObject setter); -// #define PyTraceBack_Check(v) Py_IS_TYPE(v, &PyTraceBack_Type) +// #define PyTraceBack_Check(v) Py_IS_TYPE((v), &PyTraceBack_Type) // #ifndef Py_LIMITED_API @@ -9463,7 +9688,7 @@ of a key wins, else the first. The Python dict constructor dict(seq2) public static native @ByRef PyTypeObject PySlice_Type(); public static native void PySlice_Type(PyTypeObject setter); public static native @ByRef PyTypeObject PyEllipsis_Type(); public static native void PyEllipsis_Type(PyTypeObject setter); -// #define PySlice_Check(op) Py_IS_TYPE(op, &PySlice_Type) +// #define PySlice_Check(op) Py_IS_TYPE((op), &PySlice_Type) @NoException public static native PyObject PySlice_New(PyObject start, PyObject stop, PyObject step); @@ -9515,14 +9740,17 @@ of a key wins, else the first. The Python dict constructor dict(seq2) public static native @ByRef PyTypeObject PyCell_Type(); public static native void PyCell_Type(PyTypeObject setter); -// #define PyCell_Check(op) Py_IS_TYPE(op, &PyCell_Type) +// #define PyCell_Check(op) Py_IS_TYPE((op), &PyCell_Type) @NoException public static native PyObject PyCell_New(PyObject arg0); @NoException public static native PyObject PyCell_Get(PyObject arg0); @NoException public static native int PyCell_Set(PyObject arg0, PyObject arg1); -// #define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref) -// #define PyCell_SET(op, v) _Py_RVALUE(((PyCellObject *)(op))->ob_ref = (v)) +@NoException public static native PyObject PyCell_GET(PyObject op); +// #define PyCell_GET(op) PyCell_GET(_PyObject_CAST(op)) + +@NoException public static native void PyCell_SET(PyObject op, PyObject value); +// #define PyCell_SET(op, value) PyCell_SET(_PyObject_CAST(op), (value)) // #ifdef __cplusplus // #endif @@ -9543,12 +9771,12 @@ of a key wins, else the first. The Python dict constructor dict(seq2) // #ifdef Py_BUILD_CORE // #endif -// #define PySeqIter_Check(op) Py_IS_TYPE(op, &PySeqIter_Type) +// #define PySeqIter_Check(op) Py_IS_TYPE((op), &PySeqIter_Type) @NoException public static native PyObject PySeqIter_New(PyObject arg0); -// #define PyCallIter_Check(op) Py_IS_TYPE(op, &PyCallIter_Type) +// #define PyCallIter_Check(op) Py_IS_TYPE((op), &PyCallIter_Type) @NoException public static native PyObject PyCallIter_New(PyObject arg0, PyObject arg1); @@ -9574,8 +9802,6 @@ of a key wins, else the first. The Python dict constructor dict(seq2) and coroutine objects. */ // #define _PyGenObject_HEAD(prefix) // PyObject_HEAD -// /* The code object backing the generator */ -// PyCodeObject *prefix##_code; // /* List of weak reference. */ // PyObject *prefix##_weakreflist; // /* Name of the generator. */ @@ -9596,8 +9822,8 @@ of a key wins, else the first. The Python dict constructor dict(seq2) public static native @ByRef PyTypeObject PyGen_Type(); public static native void PyGen_Type(PyTypeObject setter); -// #define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type) -// #define PyGen_CheckExact(op) Py_IS_TYPE(op, &PyGen_Type) +// #define PyGen_Check(op) PyObject_TypeCheck((op), &PyGen_Type) +// #define PyGen_CheckExact(op) Py_IS_TYPE((op), &PyGen_Type) @NoException public static native PyObject PyGen_New(PyFrameObject arg0); @NoException public static native PyObject PyGen_NewWithQualName(PyFrameObject arg0, @@ -9606,6 +9832,7 @@ of a key wins, else the first. The Python dict constructor dict(seq2) @NoException public static native int _PyGen_FetchStopIterationValue(@Cast("PyObject**") PointerPointer arg0); @NoException public static native int _PyGen_FetchStopIterationValue(@ByPtrPtr PyObject arg0); @NoException public static native void _PyGen_Finalize(PyObject self); +@NoException public static native PyCodeObject PyGen_GetCode(PyGenObject gen); // Targeting ../PyCoroObject.java @@ -9613,7 +9840,7 @@ of a key wins, else the first. The Python dict constructor dict(seq2) public static native @ByRef PyTypeObject PyCoro_Type(); public static native void PyCoro_Type(PyTypeObject setter); public static native @ByRef PyTypeObject _PyCoroWrapper_Type(); public static native void _PyCoroWrapper_Type(PyTypeObject setter); -// #define PyCoro_CheckExact(op) Py_IS_TYPE(op, &PyCoro_Type) +// #define PyCoro_CheckExact(op) Py_IS_TYPE((op), &PyCoro_Type) @NoException public static native PyObject PyCoro_New(PyFrameObject arg0, PyObject name, PyObject qualname); // Targeting ../PyAsyncGenObject.java @@ -9628,7 +9855,9 @@ of a key wins, else the first. The Python dict constructor dict(seq2) @NoException public static native PyObject PyAsyncGen_New(PyFrameObject arg0, PyObject name, PyObject qualname); -// #define PyAsyncGen_CheckExact(op) Py_IS_TYPE(op, &PyAsyncGen_Type) +// #define PyAsyncGen_CheckExact(op) Py_IS_TYPE((op), &PyAsyncGen_Type) + +// #define PyAsyncGenASend_CheckExact(op) Py_IS_TYPE((op), &_PyAsyncGenASend_Type) // #undef _PyGenObject_HEAD @@ -9734,12 +9963,12 @@ of a key wins, else the first. The Python dict constructor dict(seq2) public static native @ByRef PyTypeObject _PyWeakref_ProxyType(); public static native void _PyWeakref_ProxyType(PyTypeObject setter); public static native @ByRef PyTypeObject _PyWeakref_CallableProxyType(); public static native void _PyWeakref_CallableProxyType(PyTypeObject setter); -// #define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType) +// #define PyWeakref_CheckRef(op) PyObject_TypeCheck((op), &_PyWeakref_RefType) // #define PyWeakref_CheckRefExact(op) -// Py_IS_TYPE(op, &_PyWeakref_RefType) +// Py_IS_TYPE((op), &_PyWeakref_RefType) // #define PyWeakref_CheckProxy(op) -// (Py_IS_TYPE(op, &_PyWeakref_ProxyType) || -// Py_IS_TYPE(op, &_PyWeakref_CallableProxyType)) +// (Py_IS_TYPE((op), &_PyWeakref_ProxyType) +// || Py_IS_TYPE((op), &_PyWeakref_CallableProxyType)) // #define PyWeakref_Check(op) // (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op)) @@ -9793,9 +10022,9 @@ of a key wins, else the first. The Python dict constructor dict(seq2) // #ifndef Py_LIMITED_API /* Macro, *only* to be used to fill in brand new objects */ -// #define PyStructSequence_SET_ITEM(op, i, v) PyTuple_SET_ITEM(op, i, v) +// #define PyStructSequence_SET_ITEM(op, i, v) PyTuple_SET_ITEM((op), (i), (v)) -// #define PyStructSequence_GET_ITEM(op, i) PyTuple_GET_ITEM(op, i) +// #define PyStructSequence_GET_ITEM(op, i) PyTuple_GET_ITEM((op), (i)) // #endif @NoException public static native void PyStructSequence_SetItem(PyObject arg0, @Cast("Py_ssize_t") long arg1, PyObject arg2); @@ -9821,7 +10050,7 @@ of a key wins, else the first. The Python dict constructor dict(seq2) public static native @ByRef PyTypeObject PyPickleBuffer_Type(); public static native void PyPickleBuffer_Type(PyTypeObject setter); -// #define PyPickleBuffer_Check(op) Py_IS_TYPE(op, &PyPickleBuffer_Type) +// #define PyPickleBuffer_Check(op) Py_IS_TYPE((op), &PyPickleBuffer_Type) /* Create a PickleBuffer redirecting to the given buffer-enabled object */ @NoException public static native PyObject PyPickleBuffer_FromObject(PyObject arg0); @@ -10177,6 +10406,8 @@ based on _PyCodec_Lookup(). The same comments w/r to the encoding @NoException public static native void PyErr_Fetch(@Cast("PyObject**") PointerPointer arg0, @Cast("PyObject**") PointerPointer arg1, @Cast("PyObject**") PointerPointer arg2); @NoException public static native void PyErr_Fetch(@ByPtrPtr PyObject arg0, @ByPtrPtr PyObject arg1, @ByPtrPtr PyObject arg2); @NoException public static native void PyErr_Restore(PyObject arg0, PyObject arg1, PyObject arg2); +@NoException public static native PyObject PyErr_GetRaisedException(); +@NoException public static native void PyErr_SetRaisedException(PyObject arg0); // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030b0000 @NoException public static native PyObject PyErr_GetHandledException(); @NoException public static native void PyErr_SetHandledException(PyObject arg0); @@ -10213,6 +10444,10 @@ The Py_FatalError() function is replaced with a macro which logs @NoException public static native PyObject PyException_GetContext(PyObject arg0); @NoException public static native void PyException_SetContext(PyObject arg0, PyObject arg1); + +@NoException public static native PyObject PyException_GetArgs(PyObject arg0); +@NoException public static native void PyException_SetArgs(PyObject arg0, PyObject arg1); + /* */ // #define PyExceptionClass_Check(x) @@ -10224,10 +10459,10 @@ The Py_FatalError() function is replaced with a macro which logs @NoException public static native @Cast("const char*") BytePointer PyExceptionClass_Name(PyObject arg0); -// #define PyExceptionInstance_Class(x) ((PyObject*)Py_TYPE(x)) +// #define PyExceptionInstance_Class(x) _PyObject_CAST(Py_TYPE(x)) // #define _PyBaseExceptionGroup_Check(x) -// PyObject_TypeCheck(x, (PyTypeObject *)PyExc_BaseExceptionGroup) +// PyObject_TypeCheck((x), (PyTypeObject *)PyExc_BaseExceptionGroup) /* Predefined exceptions */ @@ -10587,7 +10822,8 @@ The Py_FatalError() function is replaced with a macro which logs /* Context manipulation (PEP 3134) */ -@NoException public static native void _PyErr_ChainExceptions(PyObject arg0, PyObject arg1, PyObject arg2); +@NoException public static native @Deprecated void _PyErr_ChainExceptions(PyObject arg0, PyObject arg1, PyObject arg2); +@NoException public static native void _PyErr_ChainExceptions1(PyObject arg0); /* Like PyErr_Format(), but saves current exception as __context__ and __cause__. @@ -10603,25 +10839,13 @@ The Py_FatalError() function is replaced with a macro which logs /* In exceptions.c */ -/* Helper that attempts to replace the current exception with one of the - * same type but with a prefix added to the exception text. The resulting - * exception description looks like: - * - * prefix (exc_type: original_exc_str) - * - * Only some exceptions can be safely replaced. If the function determines - * it isn't safe to perform the replacement, it will leave the original - * unmodified exception in place. - * - * Returns a borrowed reference to the new exception (if any), NULL if the - * existing exception was left in place. - */ -@NoException public static native PyObject _PyErr_TrySetFromCause( - @Cast("const char*") BytePointer prefix_format - ); -@NoException public static native PyObject _PyErr_TrySetFromCause( - String prefix_format - ); +@NoException public static native int _PyException_AddNote( + PyObject exc, + PyObject note); + +@NoException public static native PyObject PyUnstable_Exc_PrepReraiseStar( + PyObject orig, + PyObject excs); /* In signalmodule.c */ @@ -10689,7 +10913,14 @@ The Py_FatalError() function is replaced with a macro which logs String func, String format); -// #define Py_FatalError(message) _Py_FatalErrorFunc(__func__, message) +@NoException public static native PyObject _PyErr_SetImportErrorWithNameFrom( + PyObject arg0, + PyObject arg1, + PyObject arg2, + PyObject arg3); + + +// #define Py_FatalError(message) _Py_FatalErrorFunc(__func__, (message)) // Parsed from pythread.h @@ -10719,7 +10950,9 @@ The Py_FatalError() function is replaced with a macro which logs @NoException public static native void PyThread_exit_thread(); @NoException public static native @Cast("unsigned long") long PyThread_get_thread_ident(); -// #if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(_WIN32) || defined(_AIX) +// #if (defined(__APPLE__) || defined(__linux__) || defined(_WIN32) +// || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) +// || defined(__DragonFly__) || defined(_AIX)) // #define PY_HAVE_THREAD_NATIVE_ID @NoException public static native @Cast("unsigned long") long PyThread_get_thread_native_id(); // #endif @@ -10982,9 +11215,9 @@ be used between _Ensure() and _Release() calls, so long as the -// #define PyContext_CheckExact(o) Py_IS_TYPE(o, &PyContext_Type) -// #define PyContextVar_CheckExact(o) Py_IS_TYPE(o, &PyContextVar_Type) -// #define PyContextToken_CheckExact(o) Py_IS_TYPE(o, &PyContextToken_Type) +// #define PyContext_CheckExact(o) Py_IS_TYPE((o), &PyContext_Type) +// #define PyContextVar_CheckExact(o) Py_IS_TYPE((o), &PyContextVar_Type) +// #define PyContextToken_CheckExact(o) Py_IS_TYPE((o), &PyContextToken_Type) @NoException public static native PyObject PyContext_New(); @@ -11066,6 +11299,7 @@ be used between _Ensure() and _Release() calls, so long as the @NoException public static native int PyStatus_IsError(@ByVal PyStatus err); @NoException public static native int PyStatus_IsExit(@ByVal PyStatus err); @NoException public static native int PyStatus_Exception(@ByVal PyStatus err); +@NoException public static native PyObject _PyErr_SetFromPyStatus(@ByVal PyStatus status); // Targeting ../PyWideStringList.java @@ -11161,6 +11395,40 @@ be used between _Ensure() and _Release() calls, so long as the // #endif +/* +Runtime Feature Flags + +Each flag indicate whether or not a specific runtime feature +is available in a given context. For example, forking the process +might not be allowed in the current interpreter (i.e. os.fork() would fail). +*/ + +/* Set if the interpreter share obmalloc runtime state + with the main interpreter. */ +public static final long Py_RTFLAGS_USE_MAIN_OBMALLOC = (1L << 5); + +/* Set if import should check a module for subinterpreter support. */ +public static final long Py_RTFLAGS_MULTI_INTERP_EXTENSIONS = (1L << 8); + +/* Set if threads are allowed. */ +public static final long Py_RTFLAGS_THREADS = (1L << 10); + +/* Set if daemon threads are allowed. */ +public static final long Py_RTFLAGS_DAEMON_THREADS = (1L << 11); + +/* Set if os.fork() is allowed. */ +public static final long Py_RTFLAGS_FORK = (1L << 15); + +/* Set if os.exec*() is allowed. */ +public static final long Py_RTFLAGS_EXEC = (1L << 16); + + +@NoException public static native int _PyInterpreterState_HasFeature(PyInterpreterState interp, + @Cast("unsigned long") long feature); + + +/* private interpreter helpers */ + @NoException public static native int _PyInterpreterState_RequiresIDRef(PyInterpreterState arg0); @NoException public static native void _PyInterpreterState_RequireIDRef(PyInterpreterState arg0, int arg1); @@ -11182,9 +11450,6 @@ be used between _Ensure() and _Release() calls, so long as the public static final int PyTrace_C_EXCEPTION = 5; public static final int PyTrace_C_RETURN = 6; public static final int PyTrace_OPCODE = 7; -// Targeting ../PyTraceInfo.java - - // Targeting ../_PyCFrame.java @@ -11194,16 +11459,31 @@ be used between _Ensure() and _Release() calls, so long as the // Targeting ../_PyStackChunk.java +// Targeting ../_py_trashcan.java + + // Targeting ../PyThreadState.java +/* WASI has limited call stack. Python's recursion limit depends on code + layout, optimization, and WASI runtime. Wasmtime can handle about 700 + recursions, sometimes less. 500 is a more conservative limit. */ +// #ifndef C_RECURSION_LIMIT +// # ifdef __wasi__ +public static final int C_RECURSION_LIMIT = 500; +// # else + // This value is duplicated in Lib/test/support/__init__.py +// # endif +// #endif /* other API */ // Alias for backward compatibility with Python 3.8 // #define _PyInterpreterState_Get PyInterpreterState_Get +/* An alias for the internal _PyThreadState_New(), + kept for stable ABI compatibility. */ @NoException public static native PyThreadState _PyThreadState_Prealloc(PyInterpreterState arg0); /* Similar to PyThreadState_Get(), but don't issue a fatal error @@ -11274,7 +11554,10 @@ See also _PyInterpreterState_Get() and _PyInterpreterState_GET(). */ for example. Python must be preinitialized to call this method. - The caller must hold the GIL. */ + The caller must hold the GIL. + + Once done with the configuration, PyConfig_Clear() must be called to clear + it. */ @NoException public static native int _PyInterpreterState_GetConfigCopy( PyConfig config); @@ -11302,13 +11585,30 @@ The configuration should come from _PyInterpreterState_GetConfigCopy(). */ // Targeting ../_PyCrossInterpreterData.java +// Targeting ../xid_newobjectfunc.java + + +// Targeting ../xid_freefunc.java + + // Targeting ../_xid.java +@NoException public static native void _PyCrossInterpreterData_Init( + _PyCrossInterpreterData data, + PyInterpreterState interp, Pointer shared, PyObject obj, + xid_newobjectfunc new_object); +@NoException public static native int _PyCrossInterpreterData_InitWithSize( + _PyCrossInterpreterData arg0, + PyInterpreterState interp, @Cast("const size_t") long arg2, PyObject arg3, + xid_newobjectfunc arg4); +@NoException public static native void _PyCrossInterpreterData_Clear( + PyInterpreterState arg0, _PyCrossInterpreterData arg1); + @NoException public static native int _PyObject_GetCrossInterpreterData(PyObject arg0, _PyCrossInterpreterData arg1); @NoException public static native PyObject _PyCrossInterpreterData_NewObject(_PyCrossInterpreterData arg0); -@NoException public static native void _PyCrossInterpreterData_Release(_PyCrossInterpreterData arg0); +@NoException public static native int _PyCrossInterpreterData_Release(_PyCrossInterpreterData arg0); @NoException public static native int _PyObject_CheckCrossInterpreterData(PyObject arg0); // Targeting ../crossinterpdatafunc.java @@ -11316,6 +11616,7 @@ The configuration should come from _PyInterpreterState_GetConfigCopy(). */ @NoException public static native int _PyCrossInterpreterData_RegisterClass(PyTypeObject arg0, crossinterpdatafunc arg1); +@NoException public static native int _PyCrossInterpreterData_UnregisterClass(PyTypeObject arg0); @NoException public static native crossinterpdatafunc _PyCrossInterpreterData_Lookup(PyObject arg0); @@ -11404,8 +11705,6 @@ public static native int PyArg_ParseTupleAndKeywords(PyObject arg0, PyObject arg @NoException public static native PyObject _Py_BuildValue_SizeT(String arg0); -// #define ANY_VARARGS(n) (n == PY_SSIZE_T_MAX) - @NoException public static native PyObject Py_VaBuildValue(@Cast("const char*") BytePointer arg0, @ByVal @Cast("va_list*") Pointer arg1); @NoException public static native PyObject Py_VaBuildValue(String arg0, @ByVal @Cast("va_list*") Pointer arg1); @@ -11432,8 +11731,8 @@ public static native int PyArg_ParseTupleAndKeywords(PyObject arg0, PyObject arg @NoException public static native int PyModule_AddType(PyObject module, PyTypeObject type); // #endif /* Py_LIMITED_API */ -// #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c) -// #define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c) +// #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant((m), #c, (c)) +// #define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant((m), #c, (c)) // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 /* New in 3.5 */ @@ -11504,10 +11803,10 @@ the module is still loaded (because the mismatch can only be tested // #ifdef Py_LIMITED_API // #define PyModule_Create(module) -// PyModule_Create2(module, PYTHON_ABI_VERSION) +// PyModule_Create2((module), PYTHON_ABI_VERSION) // #else // #define PyModule_Create(module) -// PyModule_Create2(module, PYTHON_API_VERSION) +// PyModule_Create2((module), PYTHON_API_VERSION) // #endif // #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 @@ -11518,10 +11817,10 @@ the module is still loaded (because the mismatch can only be tested // #ifdef Py_LIMITED_API // #define PyModule_FromDefAndSpec(module, spec) -// PyModule_FromDefAndSpec2(module, spec, PYTHON_ABI_VERSION) +// PyModule_FromDefAndSpec2((module), (spec), PYTHON_ABI_VERSION) // #else // #define PyModule_FromDefAndSpec(module, spec) -// PyModule_FromDefAndSpec2(module, spec, PYTHON_API_VERSION) +// PyModule_FromDefAndSpec2((module), (spec), PYTHON_API_VERSION) // #endif /* Py_LIMITED_API */ // #endif /* New in 3.5 */ @@ -11578,7 +11877,7 @@ the module is still loaded (because the mismatch can only be tested /* Deprecated since PyEval_CallObjectWithKeywords is deprecated */ // #define PyEval_CallObject(callable, arg) -// PyEval_CallObjectWithKeywords(callable, arg, (PyObject *)NULL) +// PyEval_CallObjectWithKeywords((callable), (arg), _PyObject_CAST(_Py_NULL)) @NoException public static native @Deprecated PyObject PyEval_CallFunction( PyObject callable, @Cast("const char*") BytePointer format); @@ -11728,8 +12027,10 @@ To leave the block in the middle (e.g., with return), you must insert // #endif @NoException public static native void PyEval_SetProfile(Py_tracefunc arg0, PyObject arg1); +@NoException public static native void PyEval_SetProfileAllThreads(Py_tracefunc arg0, PyObject arg1); @NoException public static native int _PyEval_SetProfile(PyThreadState tstate, Py_tracefunc func, PyObject arg); @NoException public static native void PyEval_SetTrace(Py_tracefunc arg0, PyObject arg1); +@NoException public static native void PyEval_SetTraceAllThreads(Py_tracefunc arg0, PyObject arg1); @NoException public static native int _PyEval_SetTrace(PyThreadState tstate, Py_tracefunc func, PyObject arg); /* Helper to look up a builtin object */ @@ -11745,7 +12046,11 @@ To leave the block in the middle (e.g., with return), you must insert @NoException public static native void _PyEval_SetSwitchInterval(@Cast("unsigned long") long microseconds); @NoException public static native @Cast("unsigned long") long _PyEval_GetSwitchInterval(); -@NoException public static native @Cast("Py_ssize_t") long _PyEval_RequestCodeExtraIndex(freefunc arg0); +@NoException public static native int _PyEval_MakePendingCalls(PyThreadState arg0); + +@NoException public static native @Cast("Py_ssize_t") long PyUnstable_Eval_RequestCodeExtraIndex(freefunc arg0); +// Old name -- remove when this API changes: +@NoException public static native @Cast("Py_ssize_t") @Deprecated long _PyEval_RequestCodeExtraIndex(freefunc f); @NoException public static native int _PyEval_SliceIndex(PyObject arg0, @Cast("Py_ssize_t*") SizeTPointer arg1); @NoException public static native int _PyEval_SliceIndexNotNone(PyObject arg0, @Cast("Py_ssize_t*") SizeTPointer arg1); @@ -11788,6 +12093,17 @@ To leave the block in the middle (e.g., with return), you must insert @NoException public static native @Deprecated void PySys_AddXOption(@Cast("const wchar_t*") Pointer arg0); @NoException public static native PyObject PySys_GetXOptions(); +// Targeting ../PerfMapState.java + + + +@NoException public static native int PyUnstable_PerfMapState_Init(); + +@NoException public static native int PyUnstable_WritePerfMapEntry(@Const Pointer code_addr, @Cast("unsigned int") int code_size, @Cast("const char*") BytePointer entry_name); +@NoException public static native int PyUnstable_WritePerfMapEntry(@Const Pointer code_addr, @Cast("unsigned int") int code_size, String entry_name); + +@NoException public static native void PyUnstable_PerfMapState_Fini(); +// #endif // #ifndef Py_LIMITED_API // # define Py_CPYTHON_SYSMODULE_H @@ -11968,7 +12284,7 @@ To leave the block in the middle (e.g., with return), you must insert // #endif // #define PyImport_ImportModuleEx(n, g, l, f) -// PyImport_ImportModuleLevel(n, g, l, f, 0) +// PyImport_ImportModuleLevel((n), (g), (l), (f), 0) @NoException public static native PyObject PyImport_GetImporter(PyObject path); @NoException public static native PyObject PyImport_Import(PyObject name); @@ -12022,8 +12338,8 @@ To leave the block in the middle (e.g., with return), you must insert @NoException public static native int _PyImport_SetModuleString(@Cast("const char*") BytePointer name, PyObject module); @NoException public static native int _PyImport_SetModuleString(String name, PyObject module); -@NoException public static native void _PyImport_AcquireLock(); -@NoException public static native int _PyImport_ReleaseLock(); +@NoException public static native void _PyImport_AcquireLock(PyInterpreterState interp); +@NoException public static native int _PyImport_ReleaseLock(PyInterpreterState interp); @NoException public static native int _PyImport_FixupBuiltin( PyObject mod, @@ -12040,6 +12356,7 @@ To leave the block in the middle (e.g., with return), you must insert // Targeting ../_inittab.java +// This is not used after Py_Initialize() is called. public static native _inittab PyImport_Inittab(); public static native void PyImport_Inittab(_inittab setter); @NoException public static native int PyImport_ExtendInittab(_inittab newtab); // Targeting ../_frozen.java @@ -12073,9 +12390,9 @@ To leave the block in the middle (e.g., with return), you must insert Print an object 'o' on file 'fp'. Returns -1 on error. The flags argument is used to enable certain printing options. The only option currently - supported is Py_Print_RAW. - - (What should be said about Py_Print_RAW?). */ + supported is Py_PRINT_RAW. By default (flags=0), PyObject_Print() formats + the object by calling PyObject_Repr(). If flags equals to Py_PRINT_RAW, it + formats the object by calling PyObject_Str(). */ /* Implemented elsewhere: @@ -12147,7 +12464,7 @@ To leave the block in the middle (e.g., with return), you must insert -1 on failure. This is the equivalent of the Python statement: del o.attr_name. */ -// #define PyObject_DelAttrString(O,A) PyObject_SetAttrString((O),(A), NULL) +// #define PyObject_DelAttrString(O, A) PyObject_SetAttrString((O), (A), NULL) /* Implemented as a macro: @@ -12157,7 +12474,7 @@ To leave the block in the middle (e.g., with return), you must insert Delete attribute named attr_name, for object o. Returns -1 on failure. This is the equivalent of the Python statement: del o.attr_name. */ -// #define PyObject_DelAttr(O,A) PyObject_SetAttr((O),(A), NULL) +// #define PyObject_DelAttr(O, A) PyObject_SetAttr((O), (A), NULL) /* Implemented elsewhere: @@ -12291,6 +12608,40 @@ Called by the str() and print() built-in functions. */ PyObject obj, PyObject name); +/* Given a vectorcall nargsf argument, return the actual number of arguments. + * (For use outside the limited API, this is re-defined as a static inline + * function in cpython/abstract.h) + */ +@NoException public static native @Cast("Py_ssize_t") long PyVectorcall_NARGS(@Cast("size_t") long nargsf); + +/* Call "callable" (which must support vectorcall) with positional arguments + "tuple" and keyword arguments "dict". "dict" may also be NULL */ +@NoException public static native PyObject PyVectorcall_Call(PyObject callable, PyObject tuple, PyObject dict); + +// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000 +public static native @MemberGetter long PY_VECTORCALL_ARGUMENTS_OFFSET(); +public static final long PY_VECTORCALL_ARGUMENTS_OFFSET = PY_VECTORCALL_ARGUMENTS_OFFSET(); + +/* Perform a PEP 590-style vector call on 'callable' */ +@NoException public static native PyObject PyObject_Vectorcall( + PyObject callable, + @Cast("PyObject*const*") PointerPointer args, + @Cast("size_t") long nargsf, + PyObject kwnames); +@NoException public static native PyObject PyObject_Vectorcall( + PyObject callable, + @ByPtrPtr PyObject args, + @Cast("size_t") long nargsf, + PyObject kwnames); + +/* Call the method 'name' on args[0] with arguments in args[1..nargsf-1]. */ +@NoException public static native PyObject PyObject_VectorcallMethod( + PyObject name, @Cast("PyObject*const*") PointerPointer args, + @Cast("size_t") long nargsf, PyObject kwnames); +@NoException public static native PyObject PyObject_VectorcallMethod( + PyObject name, @ByPtrPtr PyObject args, + @Cast("size_t") long nargsf, PyObject kwnames); +// #endif /* Implemented elsewhere: @@ -12798,7 +13149,7 @@ buffer interface and returns a pointer to a writable memory location in /* Return the 'i'-th element of the sequence 'o', assuming that o was returned by PySequence_Fast, and that i is within bounds. */ // #define PySequence_Fast_GET_ITEM(o, i) -// (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i)) +// (PyList_Check(o) ? PyList_GET_ITEM((o), (i)) : PyTuple_GET_ITEM((o), (i))) /* Return a pointer to the underlying item array for an object returned by PySequence_Fast */ @@ -12876,7 +13227,7 @@ Use __contains__ if possible, else _PySequence_IterSearch(). */ failure. This is equivalent to the Python statement: del o[key]. */ -// #define PyMapping_DelItemString(O,K) PyObject_DelItemString((O),(K)) +// #define PyMapping_DelItemString(O, K) PyObject_DelItemString((O), (K)) /* Implemented as a macro: @@ -12886,7 +13237,7 @@ Use __contains__ if possible, else _PySequence_IterSearch(). */ Returns -1 on failure. This is equivalent to the Python statement: del o[key]. */ -// #define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K)) +// #define PyMapping_DelItem(O, K) PyObject_DelItem((O), (K)) /* On success, return 1 if the mapping object 'o' has the key 'key', and 0 otherwise. @@ -13017,24 +13368,14 @@ or PyObject_FastCallDict() (both forms are supported), @ByPtrPtr PyObject args, @Cast("Py_ssize_t") long nargs, PyObject keywords); -public static native @MemberGetter int PY_VECTORCALL_ARGUMENTS_OFFSET(); -public static final int PY_VECTORCALL_ARGUMENTS_OFFSET = PY_VECTORCALL_ARGUMENTS_OFFSET(); - -@NoException public static native @Cast("Py_ssize_t") long PyVectorcall_NARGS(@Cast("size_t") long n); +// PyVectorcall_NARGS() is exported as a function for the stable ABI. +// Here (when we are not using the stable ABI), the name is overridden to +// call a static inline function for best performance. +// #define PyVectorcall_NARGS(n) _PyVectorcall_NARGS(n) +@NoException public static native @Cast("Py_ssize_t") long _PyVectorcall_NARGS(@Cast("size_t") long n); @NoException public static native vectorcallfunc PyVectorcall_Function(PyObject callable); -@NoException public static native PyObject PyObject_Vectorcall( - PyObject callable, - @Cast("PyObject*const*") PointerPointer args, - @Cast("size_t") long nargsf, - PyObject kwnames); -@NoException public static native PyObject PyObject_Vectorcall( - PyObject callable, - @ByPtrPtr PyObject args, - @Cast("size_t") long nargsf, - PyObject kwnames); - // Backwards compatibility aliases for API that was provisional in Python 3.8 // #define _PyObject_Vectorcall PyObject_Vectorcall // #define _PyObject_VectorcallMethod PyObject_VectorcallMethod @@ -13057,10 +13398,6 @@ or PyObject_FastCallDict() (both forms are supported), @Cast("size_t") long nargsf, PyObject kwargs); -/* Call "callable" (which must support vectorcall) with positional arguments - "tuple" and keyword arguments "dict". "dict" may also be NULL */ -@NoException public static native PyObject PyVectorcall_Call(PyObject callable, PyObject tuple, PyObject dict); - // Same as PyObject_Vectorcall(), except without keyword arguments @NoException public static native PyObject _PyObject_FastCall( PyObject func, @@ -13073,13 +13410,6 @@ or PyObject_FastCallDict() (both forms are supported), @NoException public static native PyObject PyObject_CallOneArg(PyObject func, PyObject arg); -@NoException public static native PyObject PyObject_VectorcallMethod( - PyObject name, @Cast("PyObject*const*") PointerPointer args, - @Cast("size_t") long nargsf, PyObject kwnames); -@NoException public static native PyObject PyObject_VectorcallMethod( - PyObject name, @ByPtrPtr PyObject args, - @Cast("size_t") long nargsf, PyObject kwnames); - @NoException public static native PyObject PyObject_CallMethodNoArgs(PyObject self, PyObject name); @NoException public static native PyObject PyObject_CallMethodOneArg(PyObject self, PyObject name, PyObject arg); @@ -13134,7 +13464,7 @@ or PyObject_FastCallDict() (both forms are supported), /* Assume tp_as_sequence and sq_item exist and that 'i' does not need to be corrected for a negative index. */ // #define PySequence_ITEM(o, i) -// ( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) ) +// ( Py_TYPE(o)->tp_as_sequence->sq_item((o), (i)) ) public static final int PY_ITERSEARCH_COUNT = 1; public static final int PY_ITERSEARCH_INDEX = 2; @@ -13203,27 +13533,46 @@ or PyObject_FastCallDict() (both forms are supported), // #ifndef Py_LIMITED_API // #ifndef Py_CODE_H // #define Py_CODE_H + // #ifdef __cplusplus // #endif -/* Each instruction in a code object is a fixed-width value, - * currently 2 bytes: 1-byte opcode + 1-byte oparg. The EXTENDED_ARG - * opcode allows for larger values but the current limit is 3 uses - * of EXTENDED_ARG (see Python/compile.c), for a maximum - * 32-bit value. This aligns with the note in Python/compile.c - * (compiler_addop_i_line) indicating that the max oparg value is - * 2**32 - 1, rather than INT_MAX. - */ +/* Count of all local monitoring events */ +public static final int _PY_MONITORING_LOCAL_EVENTS = 10; +/* Count of all "real" monitoring events (not derived from other events) */ +public static final int _PY_MONITORING_UNGROUPED_EVENTS = 15; +/* Count of all monitoring events */ +public static final int _PY_MONITORING_EVENTS = 17; +// Targeting ../_Py_LocalMonitors.java + + +// Targeting ../_Py_GlobalMonitors.java + + +// Targeting ../_Py_CODEUNIT.java + + + + +/* These macros only remain defined for compatibility. */ +// #define _Py_OPCODE(word) ((word).op.code) +// #define _Py_OPARG(word) ((word).op.arg) + +@NoException public static native @ByVal _Py_CODEUNIT _py_make_codeunit(@Cast("uint8_t") byte opcode, @Cast("uint8_t") byte oparg); + +@NoException public static native void _py_set_opcode(_Py_CODEUNIT word, @Cast("uint8_t") byte opcode); + +// #define _Py_MAKE_CODEUNIT(opcode, oparg) _py_make_codeunit((opcode), (oparg)) +// #define _Py_SET_OPCODE(word, opcode) _py_set_opcode(&(word), (opcode)) +// Targeting ../_PyCoCached.java + + +// Targeting ../_PyCoLineInstrumentationData.java + + +// Targeting ../_PyCoMonitoringData.java -// #ifdef WORDS_BIGENDIAN -// # define _Py_OPCODE(word) ((word) >> 8) -// # define _Py_OPARG(word) ((word) & 255) -// # define _Py_MAKECODEUNIT(opcode, oparg) (((opcode)<<8)|(oparg)) -// #else -// #endif -// Use "unsigned char" instead of "uint8_t" here to avoid illegal aliasing: -// #define _Py_SET_OPCODE(word, opcode) (((unsigned char *)&(word))[0] = (opcode)) // To avoid repeating ourselves in deepfreeze.py, all PyCodeObject members are // defined in this macro: @@ -13256,8 +13605,6 @@ or PyObject_FastCallDict() (both forms are supported), // PyObject *co_exceptiontable; /* Byte string encoding exception handling \ // table */ // int co_flags; /* CO_..., see below */ -// short co_warmup; /* Warmup counter for quickening */ -// short _co_linearray_entry_size; /* Size of each entry in _co_linearray */ // // /* The rest are not so impactful on performance. */ // int co_argcount; /* #arguments, except *args */ @@ -13268,12 +13615,12 @@ or PyObject_FastCallDict() (both forms are supported), // // /* redundant values (derived from co_localsplusnames and \ // co_localspluskinds) */ -// int co_nlocalsplus; /* number of local + cell + free variables \ -// */ +// int co_nlocalsplus; /* number of local + cell + free variables */ +// int co_framesize; /* Size of frame in words */ // int co_nlocals; /* number of local variables */ -// int co_nplaincellvars; /* number of non-arg cell variables */ // int co_ncellvars; /* total number of cell variables */ // int co_nfreevars; /* number of free variables */ +// uint32_t co_version; /* version number */ // // PyObject *co_localsplusnames; /* tuple mapping offsets to names */ // PyObject *co_localspluskinds; /* Bytes mapping to local kinds (one byte \ @@ -13283,8 +13630,9 @@ or PyObject_FastCallDict() (both forms are supported), // PyObject *co_qualname; /* unicode (qualname, for reference) */ // PyObject *co_linetable; /* bytes object that holds location info */ // PyObject *co_weakreflist; /* to support weakrefs to code objects */ -// PyObject *_co_code; /* cached co_code object/attribute */ -// char *_co_linearray; /* array of line offsets */ +// _PyCoCached *_co_cached; /* cached co_* attributes */ +// uint64_t _co_instrumentation_version; /* current instrumentation version */ +// _PyCoMonitoringData *_co_monitoring; /* Monitoring data */ // int _co_firsttraceable; /* index of first traceable instruction */ // /* Scratch space for extra data relating to the code object. \ // Type is a void* to keep the format private in codeobject.c to force \ @@ -13333,24 +13681,39 @@ or PyObject_FastCallDict() (both forms are supported), public static native @ByRef PyTypeObject PyCode_Type(); public static native void PyCode_Type(PyTypeObject setter); -// #define PyCode_Check(op) Py_IS_TYPE(op, &PyCode_Type) -// #define PyCode_GetNumFree(op) ((op)->co_nfreevars) -// #define _PyCode_CODE(CO) ((_Py_CODEUNIT *)(CO)->co_code_adaptive) +// #define PyCode_Check(op) Py_IS_TYPE((op), &PyCode_Type) + +@NoException public static native @Cast("Py_ssize_t") long PyCode_GetNumFree(PyCodeObject op); + +@NoException public static native int PyCode_GetFirstFree(PyCodeObject op); + +// #define _PyCode_CODE(CO) _Py_RVALUE((_Py_CODEUNIT *)(CO)->co_code_adaptive) // #define _PyCode_NBYTES(CO) (Py_SIZE(CO) * (Py_ssize_t)sizeof(_Py_CODEUNIT)) -/* Public interface */ -@NoException public static native PyCodeObject PyCode_New( +/* Unstable public interface */ +@NoException public static native PyCodeObject PyUnstable_Code_New( int arg0, int arg1, int arg2, int arg3, int arg4, PyObject arg5, PyObject arg6, PyObject arg7, PyObject arg8, PyObject arg9, PyObject arg10, PyObject arg11, PyObject arg12, PyObject arg13, int arg14, PyObject arg15, PyObject arg16); -@NoException public static native PyCodeObject PyCode_NewWithPosOnlyArgs( +@NoException public static native PyCodeObject PyUnstable_Code_NewWithPosOnlyArgs( int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, PyObject arg6, PyObject arg7, PyObject arg8, PyObject arg9, PyObject arg10, PyObject arg11, PyObject arg12, PyObject arg13, PyObject arg14, int arg15, PyObject arg16, PyObject arg17); /* same as struct above */ +// Old names -- remove when this API changes: +@NoException public static native @Deprecated PyCodeObject PyCode_New( + int a, int b, int c, int d, int e, PyObject f, PyObject g, + PyObject h, PyObject i, PyObject j, PyObject k, + PyObject l, PyObject m, PyObject n, int o, PyObject p, + PyObject q); +@NoException public static native @Deprecated PyCodeObject PyCode_NewWithPosOnlyArgs( + int a, int poac, int b, int c, int d, int e, PyObject f, PyObject g, + PyObject h, PyObject i, PyObject j, PyObject k, + PyObject l, PyObject m, PyObject n, int o, PyObject p, + PyObject q); /* Creates a new empty code object with the specified source location. */ @NoException public static native PyCodeObject PyCode_NewEmpty(@Cast("const char*") BytePointer filename, @Cast("const char*") BytePointer funcname, int firstlineno); @@ -13364,6 +13727,37 @@ use PyFrame_GetLineNumber() instead. */ @NoException public static native int PyCode_Addr2Location(PyCodeObject arg0, int arg1, IntPointer arg2, IntPointer arg3, IntPointer arg4, IntPointer arg5); @NoException public static native int PyCode_Addr2Location(PyCodeObject arg0, int arg1, IntBuffer arg2, IntBuffer arg3, IntBuffer arg4, IntBuffer arg5); @NoException public static native int PyCode_Addr2Location(PyCodeObject arg0, int arg1, int[] arg2, int[] arg3, int[] arg4, int[] arg5); + +// #define PY_FOREACH_CODE_EVENT(V) +// V(CREATE) +// V(DESTROY) + +/** enum PyCodeEvent */ + +// #define PY_DEF_EVENT(op) PY_CODE_EVENT_##op, +public static final int + PY_CODE_EVENT_CREATE = 0, + PY_CODE_EVENT_DESTROY = 1; +// #undef PY_DEF_EVENT +// Targeting ../PyCode_WatchCallback.java + + + +/* + * Register a per-interpreter callback that will be invoked for code object + * lifecycle events. + * + * Returns a handle that may be passed to PyCode_ClearWatcher on success, + * or -1 and sets an error if no more handles are available. + */ +@NoException public static native int PyCode_AddWatcher(PyCode_WatchCallback callback); + +/* + * Clear the watcher associated with the watcher_id handle. + * + * Returns 0 on success or -1 if no watcher exists for the provided id. + */ +@NoException public static native int PyCode_ClearWatcher(int watcher_id); // Targeting ../_opaque.java @@ -13388,13 +13782,16 @@ use PyFrame_GetLineNumber() instead. */ @NoException public static native PyObject PyCode_Optimize(PyObject code, PyObject consts, PyObject names, PyObject lnotab); - -@NoException public static native int _PyCode_GetExtra(PyObject code, @Cast("Py_ssize_t") long index, - @Cast("void**") PointerPointer extra); -@NoException public static native int _PyCode_GetExtra(PyObject code, @Cast("Py_ssize_t") long index, - @Cast("void**") @ByPtrPtr Pointer extra); -@NoException public static native int _PyCode_SetExtra(PyObject code, @Cast("Py_ssize_t") long index, - Pointer extra); +@NoException public static native int PyUnstable_Code_GetExtra( + PyObject code, @Cast("Py_ssize_t") long index, @Cast("void**") PointerPointer extra); +@NoException public static native int PyUnstable_Code_GetExtra( + PyObject code, @Cast("Py_ssize_t") long index, @Cast("void**") @ByPtrPtr Pointer extra); +@NoException public static native int PyUnstable_Code_SetExtra( + PyObject code, @Cast("Py_ssize_t") long index, Pointer extra); +// Old names -- remove when this API changes: +@NoException public static native @Deprecated int _PyCode_GetExtra(PyObject code, @Cast("Py_ssize_t") long index, @Cast("void**") PointerPointer extra); +@NoException public static native @Deprecated int _PyCode_GetExtra(PyObject code, @Cast("Py_ssize_t") long index, @Cast("void**") @ByPtrPtr Pointer extra); +@NoException public static native @Deprecated int _PyCode_SetExtra(PyObject code, @Cast("Py_ssize_t") long index, Pointer extra); /* Equivalent to getattr(code, 'co_code') in Python. Returns a strong reference to a bytes object. */ @@ -13484,6 +13881,16 @@ use PyFrame_GetLineNumber() instead. */ // #define _PyCompilerFlags_INIT // (PyCompilerFlags){.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION} +// Targeting ../_PyCompilerSrcLocation.java + + + +// #define SRC_LOCATION_FROM_AST(n) +// (_PyCompilerSrcLocation){ +// .ineno = (n)->lineno, +// .end_lineno = (n)->end_lineno, +// .col_offset = (n)->col_offset, +// .end_col_offset = (n)->end_col_offset } // Targeting ../PyFutureFeatures.java @@ -13520,6 +13927,9 @@ use PyFrame_GetLineNumber() instead. */ @NoException public static native void PyErr_Print(); @NoException public static native void PyErr_PrintEx(int arg0); @NoException public static native void PyErr_Display(PyObject arg0, PyObject arg1, PyObject arg2); + +// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000 +@NoException public static native void PyErr_DisplayException(PyObject arg0); // Targeting ../Int_PyOS_InputHook.java @@ -13660,8 +14070,8 @@ use PyFrame_GetLineNumber() instead. */ PyCompilerFlags flags, int optimize); -// #define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1) -// #define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1) +// #define Py_CompileString(str, p, s) Py_CompileStringExFlags((str), (p), (s), NULL, -1) +// #define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags((str), (p), (s), (f), -1) @NoException public static native @Cast("const char*") BytePointer _Py_SourceAsString( @@ -13714,23 +14124,23 @@ macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to @NoException public static native PyObject PyRun_FileFlags(@Cast("FILE*") Pointer fp, String p, int s, PyObject g, PyObject l, PyCompilerFlags flags); /* Use macros for a bunch of old variants */ -// #define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL) -// #define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL) +// #define PyRun_String(str, s, g, l) PyRun_StringFlags((str), (s), (g), (l), NULL) +// #define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags((fp), (name), 0, NULL) // #define PyRun_AnyFileEx(fp, name, closeit) -// PyRun_AnyFileExFlags(fp, name, closeit, NULL) +// PyRun_AnyFileExFlags((fp), (name), (closeit), NULL) // #define PyRun_AnyFileFlags(fp, name, flags) -// PyRun_AnyFileExFlags(fp, name, 0, flags) -// #define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL) -// #define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL) -// #define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL) -// #define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL) -// #define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL) +// PyRun_AnyFileExFlags((fp), (name), 0, (flags)) +// #define PyRun_SimpleString(s) PyRun_SimpleStringFlags((s), NULL) +// #define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags((f), (p), 0, NULL) +// #define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags((f), (p), (c), NULL) +// #define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags((f), (p), NULL) +// #define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags((f), (p), NULL) // #define PyRun_File(fp, p, s, g, l) -// PyRun_FileExFlags(fp, p, s, g, l, 0, NULL) +// PyRun_FileExFlags((fp), (p), (s), (g), (l), 0, NULL) // #define PyRun_FileEx(fp, p, s, g, l, c) -// PyRun_FileExFlags(fp, p, s, g, l, c, NULL) +// PyRun_FileExFlags((fp), (p), (s), (g), (l), (c), NULL) // #define PyRun_FileFlags(fp, p, s, g, l, flags) -// PyRun_FileExFlags(fp, p, s, g, l, 0, flags) +// PyRun_FileExFlags((fp), (p), (s), (g), (l), 0, (flags)) /* Stuff with no proper home (yet) */ @@ -13899,6 +14309,7 @@ macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to @NoException public static native @Cast("const char*") BytePointer _Py_gitversion(); @NoException public static native int _Py_IsFinalizing(); +@NoException public static native int _Py_IsInterpreterFinalizing(PyInterpreterState interp); /* Random */ @NoException public static native int _PyOS_URandom(Pointer buffer, @Cast("Py_ssize_t") long size); @@ -13909,7 +14320,48 @@ macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to @NoException public static native int _Py_LegacyLocaleDetected(int warn); @NoException public static native @Cast("char*") BytePointer _Py_SetLocaleFromEnv(int category); -@NoException public static native PyThreadState _Py_NewInterpreter(int isolated_subinterpreter); +/* --- PyInterpreterConfig ------------------------------------ */ + +public static final int PyInterpreterConfig_DEFAULT_GIL = (0); +public static final int PyInterpreterConfig_SHARED_GIL = (1); +public static final int PyInterpreterConfig_OWN_GIL = (2); +// Targeting ../PyInterpreterConfig.java + + + +// #define _PyInterpreterConfig_INIT +// { +// .se_main_obmalloc = 0, +// .aow_fork = 0, +// .aow_exec = 0, +// .aow_threads = 1, +// .aow_daemon_threads = 0, +// .check_multi_interp_extensions = 1, +// .gil = PyInterpreterConfig_OWN_GIL, +// } + +// #define _PyInterpreterConfig_LEGACY_INIT +// { +// .se_main_obmalloc = 1, +// .aow_fork = 1, +// .aow_exec = 1, +// .aow_threads = 1, +// .aow_daemon_threads = 1, +// .check_multi_interp_extensions = 0, +// .gil = PyInterpreterConfig_SHARED_GIL, +// } + +@NoException public static native @ByVal PyStatus Py_NewInterpreterFromConfig( + @Cast("PyThreadState**") PointerPointer tstate_p, + @Const PyInterpreterConfig config); +@NoException public static native @ByVal PyStatus Py_NewInterpreterFromConfig( + @ByPtrPtr PyThreadState tstate_p, + @Const PyInterpreterConfig config); +// Targeting ../atexit_datacallbackfunc.java + + +@NoException public static native int _Py_AtExit( + PyInterpreterState arg0, atexit_datacallbackfunc arg1, Pointer arg2); // Parsed from cpython/pyctype.h @@ -14172,6 +14624,40 @@ Return a tuple of (filename: str, lineno: int) tuples. @NoException public static native PyObject _PyTraceMalloc_GetTraceback( @Cast("unsigned int") int domain, @Cast("uintptr_t") long ptr); + +/* Return non-zero if tracemalloc is tracing */ +@NoException public static native int _PyTraceMalloc_IsTracing(); + +/* Clear the tracemalloc traces */ +@NoException public static native void _PyTraceMalloc_ClearTraces(); + +/* Clear the tracemalloc traces */ +@NoException public static native PyObject _PyTraceMalloc_GetTraces(); + +/* Clear tracemalloc traceback for an object */ +@NoException public static native PyObject _PyTraceMalloc_GetObjectTraceback(PyObject obj); + +/* Initialize tracemalloc */ +@NoException public static native int _PyTraceMalloc_Init(); + +/* Start tracemalloc */ +@NoException public static native int _PyTraceMalloc_Start(int max_nframe); + +/* Stop tracemalloc */ +@NoException public static native void _PyTraceMalloc_Stop(); + +/* Get the tracemalloc traceback limit */ +@NoException public static native int _PyTraceMalloc_GetTracebackLimit(); + +/* Get the memory usage of tracemalloc in bytes */ +@NoException public static native @Cast("size_t") long _PyTraceMalloc_GetMemory(); + +/* Get the current size and peak size of traced memory blocks as a 2-tuple */ +@NoException public static native PyObject _PyTraceMalloc_GetTracedMemory(); + +/* Set the peak size of traced memory blocks to the current size */ +@NoException public static native void _PyTraceMalloc_ResetPeak(); + // #endif // #endif /* !Py_TRACEMALLOC_H */ @@ -14263,39 +14749,39 @@ Return a tuple of (filename: str, lineno: int) tuples. // o is a pointer to a time or a datetime object. // #define _PyDateTime_HAS_TZINFO(o) (((_PyDateTime_BaseTZInfo *)(o))->hastzinfo) -// #define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)o)->data[0] << 8) | -// ((PyDateTime_Date*)o)->data[1]) -// #define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)o)->data[2]) -// #define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)o)->data[3]) +// #define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)(o))->data[0] << 8) | +// ((PyDateTime_Date*)(o))->data[1]) +// #define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)(o))->data[2]) +// #define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)(o))->data[3]) -// #define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)o)->data[4]) -// #define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)o)->data[5]) -// #define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)o)->data[6]) +// #define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)(o))->data[4]) +// #define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)(o))->data[5]) +// #define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)(o))->data[6]) // #define PyDateTime_DATE_GET_MICROSECOND(o) -// ((((PyDateTime_DateTime*)o)->data[7] << 16) | -// (((PyDateTime_DateTime*)o)->data[8] << 8) | -// ((PyDateTime_DateTime*)o)->data[9]) -// #define PyDateTime_DATE_GET_FOLD(o) (((PyDateTime_DateTime*)o)->fold) -// #define PyDateTime_DATE_GET_TZINFO(o) (_PyDateTime_HAS_TZINFO(o) ? +// ((((PyDateTime_DateTime*)(o))->data[7] << 16) | +// (((PyDateTime_DateTime*)(o))->data[8] << 8) | +// ((PyDateTime_DateTime*)(o))->data[9]) +// #define PyDateTime_DATE_GET_FOLD(o) (((PyDateTime_DateTime*)(o))->fold) +// #define PyDateTime_DATE_GET_TZINFO(o) (_PyDateTime_HAS_TZINFO((o)) ? // ((PyDateTime_DateTime *)(o))->tzinfo : Py_None) /* Apply for time instances. */ -// #define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)o)->data[0]) -// #define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)o)->data[1]) -// #define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)o)->data[2]) +// #define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)(o))->data[0]) +// #define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)(o))->data[1]) +// #define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)(o))->data[2]) // #define PyDateTime_TIME_GET_MICROSECOND(o) -// ((((PyDateTime_Time*)o)->data[3] << 16) | -// (((PyDateTime_Time*)o)->data[4] << 8) | -// ((PyDateTime_Time*)o)->data[5]) -// #define PyDateTime_TIME_GET_FOLD(o) (((PyDateTime_Time*)o)->fold) +// ((((PyDateTime_Time*)(o))->data[3] << 16) | +// (((PyDateTime_Time*)(o))->data[4] << 8) | +// ((PyDateTime_Time*)(o))->data[5]) +// #define PyDateTime_TIME_GET_FOLD(o) (((PyDateTime_Time*)(o))->fold) // #define PyDateTime_TIME_GET_TZINFO(o) (_PyDateTime_HAS_TZINFO(o) ? // ((PyDateTime_Time *)(o))->tzinfo : Py_None) /* Apply for time delta instances */ -// #define PyDateTime_DELTA_GET_DAYS(o) (((PyDateTime_Delta*)o)->days) -// #define PyDateTime_DELTA_GET_SECONDS(o) (((PyDateTime_Delta*)o)->seconds) +// #define PyDateTime_DELTA_GET_DAYS(o) (((PyDateTime_Delta*)(o))->days) +// #define PyDateTime_DELTA_GET_SECONDS(o) (((PyDateTime_Delta*)(o))->seconds) // #define PyDateTime_DELTA_GET_MICROSECONDS(o) -// (((PyDateTime_Delta*)o)->microseconds) +// (((PyDateTime_Delta*)(o))->microseconds) // Targeting ../PyDateTime_CAPI.java @@ -14318,60 +14804,60 @@ Return a tuple of (filename: str, lineno: int) tuples. // #define PyDateTime_TimeZone_UTC PyDateTimeAPI->TimeZone_UTC /* Macros for type checking when not building the Python core. */ -// #define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType) -// #define PyDate_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->DateType) +// #define PyDate_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->DateType) +// #define PyDate_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->DateType) -// #define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType) -// #define PyDateTime_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->DateTimeType) +// #define PyDateTime_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->DateTimeType) +// #define PyDateTime_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->DateTimeType) -// #define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType) -// #define PyTime_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->TimeType) +// #define PyTime_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->TimeType) +// #define PyTime_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->TimeType) -// #define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType) -// #define PyDelta_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->DeltaType) +// #define PyDelta_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->DeltaType) +// #define PyDelta_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->DeltaType) -// #define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType) -// #define PyTZInfo_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->TZInfoType) +// #define PyTZInfo_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->TZInfoType) +// #define PyTZInfo_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->TZInfoType) /* Macros for accessing constructors in a simplified fashion. */ // #define PyDate_FromDate(year, month, day) -// PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType) +// PyDateTimeAPI->Date_FromDate((year), (month), (day), PyDateTimeAPI->DateType) // #define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) -// PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, -// min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType) +// PyDateTimeAPI->DateTime_FromDateAndTime((year), (month), (day), (hour), +// (min), (sec), (usec), Py_None, PyDateTimeAPI->DateTimeType) // #define PyDateTime_FromDateAndTimeAndFold(year, month, day, hour, min, sec, usec, fold) -// PyDateTimeAPI->DateTime_FromDateAndTimeAndFold(year, month, day, hour, -// min, sec, usec, Py_None, fold, PyDateTimeAPI->DateTimeType) +// PyDateTimeAPI->DateTime_FromDateAndTimeAndFold((year), (month), (day), (hour), +// (min), (sec), (usec), Py_None, (fold), PyDateTimeAPI->DateTimeType) // #define PyTime_FromTime(hour, minute, second, usecond) -// PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, +// PyDateTimeAPI->Time_FromTime((hour), (minute), (second), (usecond), // Py_None, PyDateTimeAPI->TimeType) // #define PyTime_FromTimeAndFold(hour, minute, second, usecond, fold) -// PyDateTimeAPI->Time_FromTimeAndFold(hour, minute, second, usecond, -// Py_None, fold, PyDateTimeAPI->TimeType) +// PyDateTimeAPI->Time_FromTimeAndFold((hour), (minute), (second), (usecond), +// Py_None, (fold), PyDateTimeAPI->TimeType) // #define PyDelta_FromDSU(days, seconds, useconds) -// PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, +// PyDateTimeAPI->Delta_FromDelta((days), (seconds), (useconds), 1, // PyDateTimeAPI->DeltaType) // #define PyTimeZone_FromOffset(offset) -// PyDateTimeAPI->TimeZone_FromTimeZone(offset, NULL) +// PyDateTimeAPI->TimeZone_FromTimeZone((offset), NULL) // #define PyTimeZone_FromOffsetAndName(offset, name) -// PyDateTimeAPI->TimeZone_FromTimeZone(offset, name) +// PyDateTimeAPI->TimeZone_FromTimeZone((offset), (name)) /* Macros supporting the DB API. */ // #define PyDateTime_FromTimestamp(args) // PyDateTimeAPI->DateTime_FromTimestamp( -// (PyObject*) (PyDateTimeAPI->DateTimeType), args, NULL) +// (PyObject*) (PyDateTimeAPI->DateTimeType), (args), NULL) // #define PyDate_FromTimestamp(args) // PyDateTimeAPI->Date_FromTimestamp( -// (PyObject*) (PyDateTimeAPI->DateType), args) +// (PyObject*) (PyDateTimeAPI->DateType), (args)) // #endif /* !defined(_PY_DATETIME_IMPL) */ diff --git a/cpython/src/gen/java/org/bytedeco/cpython/vectorcallfunc.java b/cpython/src/gen/java/org/bytedeco/cpython/vectorcallfunc.java index f15cca12419..930bbbb4754 100644 --- a/cpython/src/gen/java/org/bytedeco/cpython/vectorcallfunc.java +++ b/cpython/src/gen/java/org/bytedeco/cpython/vectorcallfunc.java @@ -11,6 +11,7 @@ import static org.bytedeco.cpython.global.python.*; +// #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000 // 3.12 public class vectorcallfunc extends FunctionPointer { static { Loader.load(); } /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ diff --git a/cpython/src/gen/java/org/bytedeco/cpython/xid_freefunc.java b/cpython/src/gen/java/org/bytedeco/cpython/xid_freefunc.java new file mode 100644 index 00000000000..19761b2f4da --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/xid_freefunc.java @@ -0,0 +1,21 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class xid_freefunc extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public xid_freefunc(Pointer p) { super(p); } + protected xid_freefunc() { allocate(); } + private native void allocate(); + public native void call(Pointer arg0); +} diff --git a/cpython/src/gen/java/org/bytedeco/cpython/xid_newobjectfunc.java b/cpython/src/gen/java/org/bytedeco/cpython/xid_newobjectfunc.java new file mode 100644 index 00000000000..8a5e383640b --- /dev/null +++ b/cpython/src/gen/java/org/bytedeco/cpython/xid_newobjectfunc.java @@ -0,0 +1,22 @@ +// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.cpython; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.javacpp.presets.javacpp.*; + +import static org.bytedeco.cpython.global.python.*; + + +@Properties(inherit = org.bytedeco.cpython.presets.python.class) +public class xid_newobjectfunc extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public xid_newobjectfunc(Pointer p) { super(p); } + protected xid_newobjectfunc() { allocate(); } + private native void allocate(); + public native PyObject call(_PyCrossInterpreterData arg0); +} diff --git a/cpython/src/main/java/org/bytedeco/cpython/presets/python.java b/cpython/src/main/java/org/bytedeco/cpython/presets/python.java index 717523eaa16..1850d05e68b 100644 --- a/cpython/src/main/java/org/bytedeco/cpython/presets/python.java +++ b/cpython/src/main/java/org/bytedeco/cpython/presets/python.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022 Samuel Audet + * Copyright (C) 2018-2023 Samuel Audet * * Licensed either under the Apache License, Version 2.0, or (at your option) * under the terms of the GNU General Public License as published by @@ -193,7 +193,7 @@ "cpython/pylifecycle.h", "cpython/fileutils.h", }, - link = "python3.11@.1.0!", + link = "python3.12@.1.0!", preload = {"ffi@.6", "ffi@.5", "libcrypto-1_1", "libssl-1_1"/*, "sqlite3", "tcl86t", "tk86t"*/}, resource = {"include", "lib", "libs", "bin", "share"} ), @@ -203,8 +203,8 @@ @Platform(value = "linux-x86", preloadpath = {"/usr/lib32/", "/usr/lib/"}), @Platform(value = "linux-x86_64", preloadpath = {"/usr/lib64/", "/usr/lib/"}), @Platform(value = "linux-ppc64", preloadpath = {"/usr/lib/powerpc64-linux-gnu/", "/usr/lib/powerpc64le-linux-gnu/"}), - @Platform(value = "macosx", link = "python3.11!"), - @Platform(value = "windows", link = "python311"), + @Platform(value = "macosx", link = "python3.12!"), + @Platform(value = "windows", link = "python312"), }, target = "org.bytedeco.cpython", global = "org.bytedeco.cpython.global.python", @@ -222,7 +222,7 @@ public static synchronized File cachePackage() throws IOException { return packageFile; } File pythonFile = Loader.cacheResource("/org/bytedeco/cpython/" + Loader.getPlatform()); - File configDir = new File(pythonFile, "lib/python3.11/"); + File configDir = new File(pythonFile, "lib/python3.12/"); if (configDir.exists()) { String pythonPath = pythonFile.getAbsolutePath(); Pattern pattern = Pattern.compile("'prefix': '(.*)'"); @@ -261,10 +261,10 @@ public static synchronized File cachePackage() throws IOException { return pythonFile; } - /** Returns {@code {f, new File(f, "site-packages"), new File(f, "python3.11"), new File(f, "python3.11/lib-dynload"), new File(f, "python3.11/site-packages")}} where {@code File f = new File(cachePackage(), "lib")}. */ + /** Returns {@code {f, new File(f, "site-packages"), new File(f, "python3.12"), new File(f, "python3.12/lib-dynload"), new File(f, "python3.12/site-packages")}} where {@code File f = new File(cachePackage(), "lib")}. */ public static File[] cachePackages() throws IOException { File f = new File(cachePackage(), "lib"); - return new File[] {f, new File(f, "site-packages"), new File(f, "python3.11"), new File(f, "python3.11/lib-dynload"), new File(f, "python3.11/site-packages")}; + return new File[] {f, new File(f, "site-packages"), new File(f, "python3.12"), new File(f, "python3.12/lib-dynload"), new File(f, "python3.12/site-packages")}; } public void map(InfoMap infoMap) { @@ -272,7 +272,7 @@ public void map(InfoMap infoMap) { "int PyAST_Check.*").skip()) .put(new Info("COMPILER", "TIMEMODULE_LIB", "NTDDI_VERSION", "Py_NTDDI", "Py_IS_NAN", - "copysign", "hypot", "timezone", "daylight", "tzname", + "copysign", "hypot", "timezone", "daylight", "tzname", "__extension__", "__pragma", "RETSIGTYPE", "_Py_COUNT_ALLOCS_COMMA", "Py_None", "Py_NotImplemented", "_Py_NULL", "Py_NO_INLINE", "PY_LONG_LONG", "PY_UINT32_T", "PY_UINT64_T", "PY_INT32_T", "PY_INT64_T", "PY_SIZE_MAX", "PY_FORMAT_SIZE_T", "Py_MEMCPY", "_Py_HOT_FUNCTION", "_Py_NO_INLINE", "PyMODINIT_FUNC", "Py_VA_COPY", @@ -318,7 +318,9 @@ public void map(InfoMap infoMap) { "defined(MS_WIN32) && !defined(HAVE_SNPRINTF)", "defined(MS_WINDOWS) && !defined(Py_LIMITED_API)", "!defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000", + "defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))", "defined(Py_REF_DEBUG)", + "defined(Py_REF_DEBUG) && !defined(Py_LIMITED_API)", "defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030A0000", "defined(Py_REF_DEBUG) && !(defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030A0000)", "PY_SSIZE_T_CLEAN").cppTypes().define(false)) @@ -327,7 +329,14 @@ public void map(InfoMap infoMap) { .put(new Info("COMPILER", "PY_LLONG_MIN", "PY_LLONG_MAX", "PY_ULLONG_MAX", "PY_TIMEOUT_MAX", "SIZEOF_PY_HASH_T", "SIZEOF_PY_UHASH_T", "PY_SSIZE_T_MAX", "PY_SSIZE_T_MIN", - "LONG_BIT", "PyLong_BASE", "PyLong_MASK", "Py_UNICODE_SIZE").cppTypes("long long").translate(false)) + "LONG_BIT", "PyLong_BASE", "PyLong_MASK", "Py_UNICODE_SIZE", + "PY_VECTORCALL_ARGUMENTS_OFFSET", "_Py_IMMORTAL_REFCNT").cppTypes("long long").translate(false)) + + .put(new Info("Py_INFINITY").cppTypes("double").translate(false)) + + .put(new Info("Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED", + "Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED", + "Py_MOD_PER_INTERPRETER_GIL_SUPPORTED").cppTypes("void*").translate(false)) .put(new Info("PyHash_FuncDef").purify()) @@ -351,7 +360,7 @@ public void map(InfoMap infoMap) { .put(new Info("_Py_memory_order", "PyThreadState::_preserve_36_ABI_1", "PyThreadState::_preserve_36_ABI_2", "_PyGC_generation0", "_PyBytes_InsertThousandsGroupingLocale", "_PyBytes_InsertThousandsGrouping", "_PyUnicode_DecodeUnicodeInternal", - "_PyFloat_Repr", "_PyFloat_Digits", "_PyFloat_DigitsInit", + "_PyFloat_Repr", "_PyFloat_Digits", "_PyFloat_DigitsInit", "_PyErr_SetImportErrorWithNameFrom", "PySortWrapper_Type", "PyCmpWrapper_Type", "_PyGen_yf", "_PyAIterWrapper_New", "_PyTime_FromTimeval", "_PyAIterWrapper_Type", "_PyErr_WarnUnawaitedCoroutine", "_PyErr_GetTopmostException", "PyInit__imp", "_PyCoro_GetAwaitableIter", "_PyAsyncGenValueWrapperNew", "PyAsyncGen_ClearFreeLists", @@ -363,7 +372,8 @@ public void map(InfoMap infoMap) { "_Py_asdl_seq_new", "_Py_asdl_int_seq_new", "_Py_isabs", "_PyTime_MIN", "_PyTime_MAX", "_Py_InitializeFromWideArgs", "_Py_InitializeFromArgs", "_PyNode_FinalizeEndPos", "_PyCodec_Forget", "_PyCode_InitAddressRange", "_PyDict_GetItemHint", "PyLineTable_InitAddressRange", - "PyLineTable_NextAddressRange", "PyLineTable_PreviousAddressRange").skip()) + "PyLineTable_NextAddressRange", "PyLineTable_PreviousAddressRange", "PyUnicode_READY", "PyUnicode_IS_READY", + "PyUnstable_Long_IsCompact", "PyUnstable_Long_CompactValue", "_PyInterpreterConfig_INIT", "_PyInterpreterConfig_LEGACY_INIT").skip()) .put(new Info("mod_ty").valueTypes("_mod").pointerTypes("@ByPtrPtr _mod")) .put(new Info("stmt_ty").valueTypes("_stmt").pointerTypes("@ByPtrPtr _stmt")) diff --git a/cpython/src/main/java/org/bytedeco/cpython/python.java b/cpython/src/main/java/org/bytedeco/cpython/python.java index 20b04d780ac..c54ed582c1d 100644 --- a/cpython/src/main/java/org/bytedeco/cpython/python.java +++ b/cpython/src/main/java/org/bytedeco/cpython/python.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2022 Samuel Audet + * Copyright (C) 2019-2023 Samuel Audet * * Licensed either under the Apache License, Version 2.0, or (at your option) * under the terms of the GNU General Public License as published by @@ -41,11 +41,11 @@ inherit = org.bytedeco.cpython.presets.python.class, value = { @Platform( - executable = "python3.11" + executable = "python3.12" ), @Platform( value = "macosx", - executable = "python3.11" + executable = "python3.12" ), @Platform( value = "windows", diff --git a/numpy/README.md b/numpy/README.md index 3c8dbce0ed4..436fce6e0c9 100644 --- a/numpy/README.md +++ b/numpy/README.md @@ -9,7 +9,7 @@ Introduction ------------ This directory contains the JavaCPP Presets module for: - * NumPy 1.25.2 http://www.numpy.org/ + * NumPy 1.26.1 http://www.numpy.org/ Please refer to the parent README.md file for more detailed information about the JavaCPP Presets. @@ -48,7 +48,7 @@ We can use [Maven 3](http://maven.apache.org/) to download and install automatic org.bytedeco numpy-platform - 1.25.2-1.5.10-SNAPSHOT + 1.26.1-1.5.10-SNAPSHOT diff --git a/numpy/cppbuild.sh b/numpy/cppbuild.sh index dd072958d1a..de1cfc03cc8 100755 --- a/numpy/cppbuild.sh +++ b/numpy/cppbuild.sh @@ -7,7 +7,7 @@ if [[ -z "$PLATFORM" ]]; then exit fi -NUMPY_VERSION=1.25.2 +NUMPY_VERSION=1.26.1 download https://github.com/numpy/numpy/releases/download/v$NUMPY_VERSION/numpy-$NUMPY_VERSION.tar.gz numpy-$NUMPY_VERSION.tar.gz mkdir -p $PLATFORM @@ -44,21 +44,20 @@ echo "Decompressing archives..." tar --totals -xzf ../numpy-$NUMPY_VERSION.tar.gz cd numpy-$NUMPY_VERSION -# work around issues with the INCLUDE environment variable and distutils on Windows -if [[ -n ${INCLUDE:-} ]]; then - PREVIFS="$IFS" - IFS="$BUILD_PATH_SEPARATOR" - rm -f include - for P in $INCLUDE; do - echo '"/I'$P'"' >> include - done - export INCLUDE= - export CL="@include -std:c++17" - export DISTUTILS_USE_SDK=1 - export MSSdk=1 - IFS="$PREVIFS" - sedinplace '/include/d' numpy/distutils/msvccompiler.py -fi +sedinplace "/blas = dependency(.*)/c\\ +includes = include_directories('$OPENBLAS_PATH/include/')\\ +blas = declare_dependency(dependencies : cc.find_library('openblas', dirs: '$OPENBLAS_PATH/lib/'), include_directories : includes)\\ +" numpy/meson.build + +sedinplace "/name: 'CBLAS'/a\\ +include_directories : includes\\ +" numpy/meson.build + +sedinplace "/lapack_dep = dependency(.*)/c\\ +lapack_dep = blas\\ +" numpy/meson.build + +sedinplace '/_distributor_init_local/d' numpy/meson.build # https://github.com/scipy/scipy/issues/13072 sedinplace 's/for lib in libraries:/for lib in libraries[:]:/g' ./numpy/distutils/command/build_ext.py @@ -75,15 +74,15 @@ echo "libraries = openblas" >> site.cfg echo "library_dirs = $OPENBLAS_PATH/lib/" >> site.cfg echo "include_dirs = $OPENBLAS_PATH/include/" >> site.cfg -if [[ -f "$CPYTHON_PATH/include/python3.11/Python.h" ]]; then +if [[ -f "$CPYTHON_PATH/include/python3.12/Python.h" ]]; then # setup.py won't pick up the right libgfortran.so without this export LD_LIBRARY_PATH="$OPENBLAS_PATH/lib/:$CPYTHON_PATH/lib/" - export PATH="$CPYTHON_PATH/lib/python3.11/bin/:$PATH" - export PYTHON_BIN_PATH="$CPYTHON_PATH/bin/python3.11" - export PYTHON_INCLUDE_PATH="$CPYTHON_PATH/include/python3.11/" - export PYTHON_LIB_PATH="$CPYTHON_PATH/lib/python3.11/" - export PYTHON_INSTALL_PATH="$INSTALL_PATH/lib/python3.11/site-packages/" - export SSL_CERT_FILE="$CPYTHON_PATH/lib/python3.11/site-packages/pip/_vendor/certifi/cacert.pem" + export PATH="$CPYTHON_PATH/lib/python3.12/bin/:$PATH" + export PYTHON_BIN_PATH="$CPYTHON_PATH/bin/python3.12" + export PYTHON_INCLUDE_PATH="$CPYTHON_PATH/include/python3.12/" + export PYTHON_LIB_PATH="$CPYTHON_PATH/lib/python3.12/" + export PYTHON_INSTALL_PATH="$INSTALL_PATH/lib/python3.12/site-packages/" + export SSL_CERT_FILE="$CPYTHON_PATH/lib/python3.12/site-packages/pip/_vendor/certifi/cacert.pem" chmod +x "$PYTHON_BIN_PATH" elif [[ -f "$CPYTHON_PATH/include/Python.h" ]]; then CPYTHON_PATH=$(cygpath $CPYTHON_PATH) @@ -98,62 +97,56 @@ fi export PYTHONPATH="$PYTHON_INSTALL_PATH" mkdir -p "$PYTHON_INSTALL_PATH" -TOOLS="setuptools==59.1.0 cython==0.29.35" +TOOLS="setuptools==67.6.1 cython==0.29.35" if ! $PYTHON_BIN_PATH -m pip install --target=$PYTHON_LIB_PATH $TOOLS; then echo "extra_link_args = -lgfortran" >> site.cfg - chmod +x "$CPYTHON_HOST_PATH/bin/python3.11" + chmod +x "$CPYTHON_HOST_PATH/bin/python3.12" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CPYTHON_HOST_PATH/lib/:$CPYTHON_HOST_PATH" - "$CPYTHON_HOST_PATH/bin/python3.11" -m pip install --target="$CPYTHON_HOST_PATH/lib/python3.11/" crossenv==1.0 $TOOLS - "$CPYTHON_HOST_PATH/bin/python3.11" -m crossenv "$PYTHON_BIN_PATH" crossenv + "$CPYTHON_HOST_PATH/bin/python3.12" -m pip install --target="$CPYTHON_HOST_PATH/lib/python3.12/" crossenv==1.0 $TOOLS + "$CPYTHON_HOST_PATH/bin/python3.12" -m crossenv "$PYTHON_BIN_PATH" crossenv source crossenv/bin/activate cross-expose cython - chmod +x $CPYTHON_HOST_PATH/lib/python3.11/bin/* - export PATH="$CPYTHON_HOST_PATH/lib/python3.11/bin/:$PATH" + chmod +x $CPYTHON_HOST_PATH/lib/python3.12/bin/* + export PATH="$CPYTHON_HOST_PATH/lib/python3.12/bin/:$PATH" export PYTHON_BIN_PATH="python" fi case $PLATFORM in linux-armhf) - ATLAS=None CC="arm-linux-gnueabihf-gcc -std=c99" "$PYTHON_BIN_PATH" setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -L$CPYTHON_PATH/lib/ install --prefix $INSTALL_PATH + ATLAS=None CC="arm-linux-gnueabihf-gcc -std=c99" "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH arm-linux-gnueabihf-strip $(find ../ -iname *.so) ;; linux-arm64) - ATLAS=None CC="aarch64-linux-gnu-gcc -mabi=lp64" CFLAGS="-O2" "$PYTHON_BIN_PATH" setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -L$CPYTHON_PATH/lib/ install --prefix $INSTALL_PATH + ATLAS=None CC="aarch64-linux-gnu-gcc -mabi=lp64" CFLAGS="-O2" "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH aarch64-linux-gnu-strip $(find ../ -iname *.so) ;; linux-ppc64le) - ATLAS=None CC="powerpc64le-linux-gnu-gcc -m64" "$PYTHON_BIN_PATH" setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -L$CPYTHON_PATH/lib/ install --prefix $INSTALL_PATH + ATLAS=None CC="powerpc64le-linux-gnu-gcc -m64" "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH powerpc64le-linux-gnu-strip $(find ../ -iname *.so) ;; linux-x86) # https://github.com/numpy/numpy/pull/20695 sedinplace -i 's/machine = platform.machine()/return False/g' numpy/core/setup.py - ATLAS=None CC="gcc -m32" "$PYTHON_BIN_PATH" setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -L$CPYTHON_PATH/lib/ install --prefix $INSTALL_PATH + ATLAS=None CC="gcc -m32" "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH strip $(find ../ -iname *.so) ;; linux-x86_64) - ATLAS=None CC="gcc -m64" "$PYTHON_BIN_PATH" setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -L$CPYTHON_PATH/lib/ install --prefix $INSTALL_PATH + ATLAS=None CC="gcc -m64" "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH strip $(find ../ -iname *.so) ;; macosx-*) sedinplace 's/-std=c99/-w/g' numpy/distutils/ccompiler.py - ATLAS=None "$PYTHON_BIN_PATH" setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -L$CPYTHON_PATH/lib/ install --prefix $INSTALL_PATH + ATLAS=None "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH # need to add RPATH so it can find MKL in cache for f in $(find ../ -iname *.so); do install_name_tool -add_rpath @loader_path/../../../ $f; done ;; windows-x86) sedinplace '/ccompiler._default_compilers = /,+2d' numpy/distutils/ccompiler.py # don't try to use GCC sedinplace 's/ltype = long_double_representation(pyod("_configtest"))/ltype = "IEEE_DOUBLE_LE"/g' numpy/core/setup_common.py - # the build sometimes fails with multiple jobs - MAKEJ=1 - # setup.py install doesn't accept absolute paths on Windows - ATLAS=None "$PYTHON_BIN_PATH" setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -L$CPYTHON_PATH/lib/ -L$CPYTHON_PATH/libs/ install --prefix .. + ATLAS=None "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH ;; windows-x86_64) - # the build sometimes fails with multiple jobs - MAKEJ=1 - # setup.py install doesn't accept absolute paths on Windows - ATLAS=None "$PYTHON_BIN_PATH" setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -L$CPYTHON_PATH/lib/ -L$CPYTHON_PATH/libs/ install --prefix .. + ATLAS=None "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH ;; *) echo "Error: Platform \"$PLATFORM\" is not supported" diff --git a/numpy/platform/pom.xml b/numpy/platform/pom.xml index 09ad4812e28..67c3e835021 100644 --- a/numpy/platform/pom.xml +++ b/numpy/platform/pom.xml @@ -12,7 +12,7 @@ org.bytedeco numpy-platform - 1.25.2-${project.parent.version} + 1.26.1-${project.parent.version} JavaCPP Presets Platform for NumPy @@ -28,7 +28,7 @@ org.bytedeco cpython-platform - 3.11.5-${project.parent.version} + 3.12.0-${project.parent.version} ${project.groupId} diff --git a/numpy/pom.xml b/numpy/pom.xml index 15f0cb6a67b..8259ca503d0 100644 --- a/numpy/pom.xml +++ b/numpy/pom.xml @@ -11,7 +11,7 @@ org.bytedeco numpy - 1.25.2-${project.parent.version} + 1.26.1-${project.parent.version} JavaCPP Presets for NumPy @@ -23,7 +23,7 @@ org.bytedeco cpython - 3.11.5-${project.parent.version} + 3.12.0-${project.parent.version} org.bytedeco @@ -51,7 +51,7 @@ org.bytedeco cpython - 3.11.5-${project.parent.version} + 3.12.0-${project.parent.version} org.bytedeco @@ -62,7 +62,7 @@ org.bytedeco cpython - 3.11.5-${project.parent.version} + 3.12.0-${project.parent.version} ${javacpp.platform} @@ -80,7 +80,7 @@ ${basedir}/../cpython/src/main/resources/org/bytedeco/cpython/include/ ${basedir}/../cpython/target/classes/org/bytedeco/cpython/include/ ${basedir}/../cpython/cppbuild/${javacpp.platform}/include/ - ${basedir}/../cpython/cppbuild/${javacpp.platform}/include/python3.11/ + ${basedir}/../cpython/cppbuild/${javacpp.platform}/include/python3.12/ ${basedir}/cppbuild/${javacpp.platform}/python/numpy/core/include/ ${basedir}/cppbuild/${javacpp.platform}/python/numpy/core/include/numpy/ @@ -107,7 +107,7 @@ /org/bytedeco/openblas/${javacpp.platform}/include/ /org/bytedeco/cpython/include/ /org/bytedeco/cpython/${javacpp.platform}/include/ - /org/bytedeco/cpython/${javacpp.platform}/include/python3.11/ + /org/bytedeco/cpython/${javacpp.platform}/include/python3.12/ /${javacpp.platform.library.path}/ @@ -171,7 +171,7 @@ org.bytedeco cpython - 3.11.5-${project.parent.version} + 3.12.0-${project.parent.version} ${os.name}-${os.arch} diff --git a/numpy/samples/pom.xml b/numpy/samples/pom.xml index 2353249336d..6c8f22d1efd 100644 --- a/numpy/samples/pom.xml +++ b/numpy/samples/pom.xml @@ -12,7 +12,7 @@ org.bytedeco numpy-platform - 1.25.2-1.5.10-SNAPSHOT + 1.26.1-1.5.10-SNAPSHOT diff --git a/numpy/src/gen/java/org/bytedeco/numpy/global/numpy.java b/numpy/src/gen/java/org/bytedeco/numpy/global/numpy.java index 5fd2ec26689..a211ef6010a 100644 --- a/numpy/src/gen/java/org/bytedeco/numpy/global/numpy.java +++ b/numpy/src/gen/java/org/bytedeco/numpy/global/numpy.java @@ -20,6 +20,7 @@ public class numpy extends org.bytedeco.numpy.presets.numpy { // Parsed from _numpyconfig.h public static final int NPY_HAVE_ENDIAN_H = 1; + public static native @MemberGetter int NPY_SIZEOF_SHORT(); public static final int NPY_SIZEOF_SHORT = NPY_SIZEOF_SHORT(); public static native @MemberGetter int NPY_SIZEOF_INT(); @@ -36,12 +37,16 @@ public class numpy extends org.bytedeco.numpy.presets.numpy { public static final int NPY_SIZEOF_OFF_T = 8; public static final int NPY_SIZEOF_PY_LONG_LONG = 8; public static final int NPY_SIZEOF_LONGLONG = 8; -public static final int NPY_NO_SMP = 0; + public static final int NPY_USE_C99_COMPLEX = 1; public static final int NPY_HAVE_COMPLEX_DOUBLE = 1; public static final int NPY_HAVE_COMPLEX_FLOAT = 1; public static final int NPY_HAVE_COMPLEX_LONG_DOUBLE = 1; public static final int NPY_USE_C99_FORMATS = 1; + +/* #undef NPY_NO_SIGNAL */ +public static final int NPY_NO_SMP = 0; + // #define NPY_VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) public static final int NPY_ABI_VERSION = 0x01000009; public static final int NPY_API_VERSION = 0x00000011; @@ -940,12 +945,18 @@ It also looks like Python itself uses sizeof(char) quite a // #define NPY_OS_SOLARIS // #elif defined(__CYGWIN__) // #define NPY_OS_CYGWIN -// #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -// #define NPY_OS_WIN32 -// #elif defined(_WIN64) || defined(__WIN64__) || defined(WIN64) -// #define NPY_OS_WIN64 -// #elif defined(__MINGW32__) || defined(__MINGW64__) +/* We are on Windows.*/ +// #elif defined(_WIN32) + /* We are using MinGW (64-bit or 32-bit)*/ +// #if defined(__MINGW32__) || defined(__MINGW64__) // #define NPY_OS_MINGW + /* Otherwise, if _WIN64 is defined, we are targeting 64-bit Windows*/ +// #elif defined(_WIN64) +// #define NPY_OS_WIN64 + /* Otherwise assume we are targeting 32-bit Windows*/ +// #else +// #define NPY_OS_WIN32 +// #endif // #elif defined(__APPLE__) // #define NPY_OS_DARWIN // #elif defined(__HAIKU__) diff --git a/onnx/cppbuild.sh b/onnx/cppbuild.sh index 5947b627c40..991a90e1135 100755 --- a/onnx/cppbuild.sh +++ b/onnx/cppbuild.sh @@ -13,8 +13,8 @@ export CMAKE_BUILD_DIR=.setuptools-cmake-build/ export MAX_JOBS=$MAKEJ export ONNX=1.14.1 -export PROTO=3.17.3 -export PYBIND=2.10.1 +export PROTO=3.20.3 +export PYBIND=2.11.0 download https://github.com/onnx/onnx/archive/v$ONNX.tar.gz onnx-$ONNX.tar.gz download https://github.com/google/protobuf/releases/download/v$PROTO/protobuf-cpp-$PROTO.tar.gz protobuf-$PROTO.tar.gz @@ -53,13 +53,13 @@ fi CPYTHON_PATH="${CPYTHON_PATH//\\//}" -if [[ -f "$CPYTHON_PATH/include/python3.11/Python.h" ]]; then +if [[ -f "$CPYTHON_PATH/include/python3.12/Python.h" ]]; then export LD_LIBRARY_PATH="$CPYTHON_PATH/lib/" - export PYTHON_BIN_PATH="$CPYTHON_PATH/bin/python3.11" - export PYTHON_INCLUDE_PATH="$CPYTHON_PATH/include/python3.11/" - export PYTHON_LIB_PATH="$CPYTHON_PATH/lib/python3.11/" - export PYTHON_INSTALL_PATH="$INSTALL_PATH/lib/python3.11/site-packages/" - export SSL_CERT_FILE="$CPYTHON_PATH/lib/python3.11/site-packages/pip/_vendor/certifi/cacert.pem" + export PYTHON_BIN_PATH="$CPYTHON_PATH/bin/python3.12" + export PYTHON_INCLUDE_PATH="$CPYTHON_PATH/include/python3.12/" + export PYTHON_LIB_PATH="$CPYTHON_PATH/lib/python3.12/" + export PYTHON_INSTALL_PATH="$INSTALL_PATH/lib/python3.12/site-packages/" + export SSL_CERT_FILE="$CPYTHON_PATH/lib/python3.12/site-packages/pip/_vendor/certifi/cacert.pem" chmod +x "$PYTHON_BIN_PATH" elif [[ -f "$CPYTHON_PATH/include/Python.h" ]]; then CPYTHON_PATH=$(cygpath $CPYTHON_PATH) @@ -108,7 +108,8 @@ sedinplace 's/if WINDOWS:/if False:/g' setup.py sedinplace '/if platform.architecture/{N;N;N;d;}' setup.py sedinplace "/setup_requires.append('pytest-runner')/d" setup.py export CMAKE_ARGS="-DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DProtobuf_USE_STATIC_LIBS=ON -DONNX_USE_LITE_PROTO=ON" -"$PYTHON_BIN_PATH" setup.py --quiet build +$PYTHON_BIN_PATH -m pip install --target=$PYTHON_LIB_PATH setuptools==67.6.1 protobuf==$PROTO +$PYTHON_BIN_PATH -m pip install -e . mkdir -p ../include/onnx ../include/onnx/common ../include/onnx/defs ../include/onnx/optimizer/ ../include/onnx/optimizer/passes ../include/onnx/version_converter ../include/onnx/version_converter/adapters ../include/onnx/shape_inference diff --git a/onnx/platform/pom.xml b/onnx/platform/pom.xml index 79cf3dd279c..20cc580b6ca 100644 --- a/onnx/platform/pom.xml +++ b/onnx/platform/pom.xml @@ -28,7 +28,7 @@ org.bytedeco cpython-platform - 3.11.5-${project.parent.version} + 3.12.0-${project.parent.version} true diff --git a/onnx/pom.xml b/onnx/pom.xml index 4875e9bfd99..ac964f2fcc6 100644 --- a/onnx/pom.xml +++ b/onnx/pom.xml @@ -22,7 +22,7 @@ org.bytedeco cpython - 3.11.5-${project.parent.version} + 3.12.0-${project.parent.version} true @@ -42,7 +42,7 @@ org.bytedeco cpython-platform - 3.11.5-${project.parent.version} + 3.12.0-${project.parent.version} diff --git a/onnx/src/main/java/org/bytedeco/onnx/presets/onnx.java b/onnx/src/main/java/org/bytedeco/onnx/presets/onnx.java index 839e1e5e75c..0976014b97c 100644 --- a/onnx/src/main/java/org/bytedeco/onnx/presets/onnx.java +++ b/onnx/src/main/java/org/bytedeco/onnx/presets/onnx.java @@ -81,7 +81,8 @@ public class onnx implements InfoMapper { public void map(InfoMap infoMap) { infoMap.put(new Info("ONNX_NAMESPACE").cppText("#define ONNX_NAMESPACE onnx")) - .put(new Info("alignas", "PROTOC_EXPORT", "LIBPROTOBUF_EXPORT", "PROTOBUF_EXPORT", "PROTOBUF_CONSTEXPR", "PROTOBUF_FINAL", + .put(new Info("alignas", "PROTOC_EXPORT", "LIBPROTOBUF_EXPORT", "PROTOBUF_EXPORT", "PROTOBUF_CONSTEXPR", "PROTOBUF_FINAL", "PROTOBUF_NODISCARD", + "PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG", "PROTOBUF_ATTRIBUTE_INIT_PRIORITY1", "PROTOBUF_ATTRIBUTE_INIT_PRIORITY2", "PROTOBUF_TC_PARAM_DECL", "PROTOBUF_MUSTTAIL", "PROTOBUF_TAILCALL", "PROTOBUF_NO_THREAD_SAFETY_ANALYSIS", "PROTOBUF_COLD", "PROTOBUF_THREAD_LOCAL", "PROTOBUF_CONSTINIT", "PROTOBUF_ATTRIBUTE_NO_DESTROY", "PROTOBUF_ATTRIBUTE_INIT_PRIORITY", "PROTOBUF_PRAGMA_INIT_SEG", "PROTOBUF_ATTRIBUTE_WEAK", "PROTOBUF_ATTRIBUTE_REINITIALIZES", "PROTOBUF_ALWAYS_INLINE", "PROTOBUF_NOINLINE", "PROTOBUF_NDEBUG_INLINE", "PROTOBUF_RETURNS_NONNULL", @@ -89,7 +90,7 @@ public void map(InfoMap infoMap) { "PROTOBUF_EXPORT_TEMPLATE_DEFINE", "GOOGLE_ATTRIBUTE_ALWAYS_INLINE", "GOOGLE_ATTRIBUTE_FUNC_ALIGN", "GOOGLE_ATTRIBUTE_NOINLINE", "GOOGLE_PREDICT_TRUE", "GOOGLE_PREDICT_FALSE", "GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE", "GOOGLE_PROTOBUF_ATTRIBUTE_RETURNS_NONNULL", "ONNX_UNUSED", "ONNX_API", "ONNXIFI_ABI", "ONNXIFI_CHECK_RESULT", "ONNXIFI_PUBLIC", "ONNX_IMPORT", "ONNX_EXPORT").cppTypes().annotations()) - .put(new Info("GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER", "defined(_MSC_VER) && (_MSC_VER < 1600)").define(false)) + .put(new Info("PROTOBUF_FORCE_COPY_IN_SWAP", "GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER", "defined(_MSC_VER) && (_MSC_VER < 1600)").define(false)) .put(new Info("PROTOBUF_DEPRECATED").cppText("#define PROTOBUF_DEPRECATED DEPRECATED").cppTypes()) .put(new Info("PROTOBUF_DEPRECATED_ENUM").cppText("#define PROTOBUF_DEPRECATED_ENUM DEPRECATED").cppTypes()) @@ -139,6 +140,7 @@ public void map(InfoMap infoMap) { .put(new Info("google::protobuf::Any", "google::protobuf::Descriptor", "google::protobuf::Metadata").cast().pointerTypes("Pointer")) .put(new Info("google::protobuf::FindAllExtensions", "google::protobuf::Map", "google::protobuf::RepeatedField", "google::protobuf::RepeatedPtrField", "google::protobuf::arena_metrics::EnableArenaMetrics", "google::protobuf::io::EpsCopyOutputStream", "google::protobuf::internal::DescriptorTable", + "google::protobuf::internal::ExplicitlyConstructedArenaString", "google::protobuf::internal::ExplicitlyConstructed", "google::protobuf::internal::MapEntry", "google::protobuf::internal::MapField", "google::protobuf::internal::AuxillaryParseTableField", "google::protobuf::internal::ParseTableField", "google::protobuf::internal::ParseTable", "google::protobuf::internal::FieldMetadata", "google::protobuf::internal::SerializationTable", "google::protobuf::internal::proto3_preserve_unknown_", diff --git a/opencv/README.md b/opencv/README.md index 066c43063de..8e783fa06d2 100644 --- a/opencv/README.md +++ b/opencv/README.md @@ -77,7 +77,7 @@ We can use [Maven 3](http://maven.apache.org/) to download and install automatic org.bytedeco numpy-platform - 1.25.2-1.5.10-SNAPSHOT + 1.26.1-1.5.10-SNAPSHOT diff --git a/opencv/cppbuild.sh b/opencv/cppbuild.sh index a577c12d1df..7b16bbd1408 100755 --- a/opencv/cppbuild.sh +++ b/opencv/cppbuild.sh @@ -45,13 +45,13 @@ export PYTHON3_EXECUTABLE= export PYTHON3_INCLUDE_DIR= export PYTHON3_LIBRARY= export PYTHON3_PACKAGES_PATH= -if [[ -f "$CPYTHON_PATH/include/python3.11/Python.h" ]]; then +if [[ -f "$CPYTHON_PATH/include/python3.12/Python.h" ]]; then export LD_LIBRARY_PATH="$OPENBLAS_PATH/lib/:$CPYTHON_PATH/lib/:$NUMPY_PATH/lib/:${LD_LIBRARY_PATH:-}" - export PYTHON3_EXECUTABLE="$CPYTHON_PATH/bin/python3.11" - export PYTHON3_INCLUDE_DIR="$CPYTHON_PATH/include/python3.11/" - export PYTHON3_LIBRARY="$CPYTHON_PATH/lib/python3.11/" - export PYTHON3_PACKAGES_PATH="$INSTALL_PATH/lib/python3.11/site-packages/" - export SSL_CERT_FILE="$CPYTHON_PATH/lib/python3.11/site-packages/pip/_vendor/certifi/cacert.pem" + export PYTHON3_EXECUTABLE="$CPYTHON_PATH/bin/python3.12" + export PYTHON3_INCLUDE_DIR="$CPYTHON_PATH/include/python3.12/" + export PYTHON3_LIBRARY="$CPYTHON_PATH/lib/python3.12/" + export PYTHON3_PACKAGES_PATH="$INSTALL_PATH/lib/python3.12/site-packages/" + export SSL_CERT_FILE="$CPYTHON_PATH/lib/python3.12/site-packages/pip/_vendor/certifi/cacert.pem" chmod +x "$PYTHON3_EXECUTABLE" elif [[ -f "$CPYTHON_PATH/include/Python.h" ]]; then CPYTHON_PATH=$(cygpath $CPYTHON_PATH) @@ -60,7 +60,7 @@ elif [[ -f "$CPYTHON_PATH/include/Python.h" ]]; then export PATH="$OPENBLAS_PATH:$CPYTHON_PATH:$NUMPY_PATH:$PATH" export PYTHON3_EXECUTABLE="$CPYTHON_PATH/bin/python.exe" export PYTHON3_INCLUDE_DIR="$CPYTHON_PATH/include/" - export PYTHON3_LIBRARY="$CPYTHON_PATH/libs/python311.lib" + export PYTHON3_LIBRARY="$CPYTHON_PATH/libs/python312.lib" export PYTHON3_PACKAGES_PATH="$INSTALL_PATH/lib/site-packages/" export SSL_CERT_FILE="$CPYTHON_PATH/lib/pip/_vendor/certifi/cacert.pem" fi @@ -110,9 +110,9 @@ sedinplace 's/PythonInterp "${min_version}"/PythonInterp/g' cmake/OpenCVDetectPy sedinplace 's/PythonLibs "${_version_major_minor}.${_version_patch}" EXACT/PythonLibs/g' cmake/OpenCVDetectPython.cmake sedinplace '/if(PYTHONINTERP_FOUND)/a\ if(" ${_python_version_major}" STREQUAL " 3")\ - set(PYTHON_VERSION_STRING "3.11")\ + set(PYTHON_VERSION_STRING "3.12")\ set(PYTHON_VERSION_MAJOR "3")\ - set(PYTHON_VERSION_MINOR "11")\ + set(PYTHON_VERSION_MINOR "12")\ endif()\ ' cmake/OpenCVDetectPython.cmake sedinplace '/execute_process/{N;N;N;d;}' cmake/OpenCVDetectPython.cmake diff --git a/opencv/pom.xml b/opencv/pom.xml index 2c1ad828638..ef3af6eafa9 100644 --- a/opencv/pom.xml +++ b/opencv/pom.xml @@ -23,7 +23,7 @@ org.bytedeco numpy - 1.25.2-${project.parent.version} + 1.26.1-${project.parent.version} true @@ -67,7 +67,7 @@ org.bytedeco numpy-platform - 1.25.2-${project.parent.version} + 1.26.1-${project.parent.version} diff --git a/opencv/samples/pom.xml b/opencv/samples/pom.xml index 965e513d3f6..feff9093ce8 100644 --- a/opencv/samples/pom.xml +++ b/opencv/samples/pom.xml @@ -40,7 +40,7 @@ org.bytedeco numpy-platform - 1.25.2-1.5.10-SNAPSHOT + 1.26.1-1.5.10-SNAPSHOT diff --git a/platform/pom.xml b/platform/pom.xml index 92e43ca0549..9a871bc8e8f 100644 --- a/platform/pom.xml +++ b/platform/pom.xml @@ -212,17 +212,17 @@ org.bytedeco cpython-platform - 3.11.5-${project.version} + 3.12.0-${project.version} org.bytedeco numpy-platform - 1.25.2-${project.version} + 1.26.1-${project.version} org.bytedeco scipy-platform - 1.11.2-${project.version} + 1.11.3-${project.version} diff --git a/pytorch/cppbuild.sh b/pytorch/cppbuild.sh index 75697c364c8..aebc073401d 100755 --- a/pytorch/cppbuild.sh +++ b/pytorch/cppbuild.sh @@ -76,14 +76,14 @@ CPYTHON_PATH="${CPYTHON_PATH//\\//}" OPENBLAS_PATH="${OPENBLAS_PATH//\\//}" NUMPY_PATH="${NUMPY_PATH//\\//}" -if [[ -f "$CPYTHON_PATH/include/python3.11/Python.h" ]]; then +if [[ -f "$CPYTHON_PATH/include/python3.12/Python.h" ]]; then # setup.py won't pick up the right libgfortran.so without this export LD_LIBRARY_PATH="$OPENBLAS_PATH/lib/:$CPYTHON_PATH/lib/:$NUMPY_PATH/lib/" - export PYTHON_BIN_PATH="$CPYTHON_PATH/bin/python3.11" - export PYTHON_INCLUDE_PATH="$CPYTHON_PATH/include/python3.11/" - export PYTHON_LIB_PATH="$CPYTHON_PATH/lib/python3.11/" - export PYTHON_INSTALL_PATH="$INSTALL_PATH/lib/python3.11/site-packages/" - export SSL_CERT_FILE="$CPYTHON_PATH/lib/python3.11/site-packages/pip/_vendor/certifi/cacert.pem" + export PYTHON_BIN_PATH="$CPYTHON_PATH/bin/python3.12" + export PYTHON_INCLUDE_PATH="$CPYTHON_PATH/include/python3.12/" + export PYTHON_LIB_PATH="$CPYTHON_PATH/lib/python3.12/" + export PYTHON_INSTALL_PATH="$INSTALL_PATH/lib/python3.12/site-packages/" + export SSL_CERT_FILE="$CPYTHON_PATH/lib/python3.12/site-packages/pip/_vendor/certifi/cacert.pem" chmod +x "$PYTHON_BIN_PATH" elif [[ -f "$CPYTHON_PATH/include/Python.h" ]]; then CPYTHON_PATH=$(cygpath $CPYTHON_PATH) @@ -101,7 +101,7 @@ mkdir -p "$PYTHON_INSTALL_PATH" export CFLAGS="-I$CPYTHON_PATH/include/ -I$PYTHON_LIB_PATH/include/python/ -L$CPYTHON_PATH/lib/ -L$CPYTHON_PATH/libs/" export PYTHONNOUSERSITE=1 -$PYTHON_BIN_PATH -m pip install --target=$PYTHON_LIB_PATH setuptools==59.1.0 pyyaml==6.0 typing_extensions==4.0.0 +$PYTHON_BIN_PATH -m pip install --target=$PYTHON_LIB_PATH setuptools==67.6.1 pyyaml==6.0.1 typing_extensions==4.8.0 case $PLATFORM in linux-x86) @@ -178,7 +178,7 @@ TORCH_API std::ostream& operator<<(std::ostream& stream, const nn::Module& modul ' torch/csrc/api/include/torch/nn/module.h sedinplace 's/char(\(.*\))/\1/g' torch/csrc/jit/serialization/pickler.h -#USE_GLOO=0 USE_MKLDNN=0 \ +#USE_FBGEMM=0 USE_KINETO=0 USE_GLOO=0 USE_MKLDNN=0 \ "$PYTHON_BIN_PATH" setup.py build rm -Rf ../lib diff --git a/pytorch/platform/gpu/pom.xml b/pytorch/platform/gpu/pom.xml index 6747350ad93..6ae56e0ee59 100644 --- a/pytorch/platform/gpu/pom.xml +++ b/pytorch/platform/gpu/pom.xml @@ -34,7 +34,7 @@ org.bytedeco numpy-platform - 1.25.2-${project.parent.version} + 1.26.1-${project.parent.version} true diff --git a/pytorch/platform/pom.xml b/pytorch/platform/pom.xml index 3df21ed15eb..8df62d99c80 100644 --- a/pytorch/platform/pom.xml +++ b/pytorch/platform/pom.xml @@ -33,7 +33,7 @@ org.bytedeco numpy-platform - 1.25.2-${project.parent.version} + 1.26.1-${project.parent.version} true diff --git a/pytorch/pom.xml b/pytorch/pom.xml index 144ae0686c8..4acbcd7fc5d 100644 --- a/pytorch/pom.xml +++ b/pytorch/pom.xml @@ -27,7 +27,7 @@ org.bytedeco numpy - 1.25.2-${project.parent.version} + 1.26.1-${project.parent.version} true @@ -52,7 +52,7 @@ org.bytedeco numpy-platform - 1.25.2-${project.parent.version} + 1.26.1-${project.parent.version} diff --git a/scipy/README.md b/scipy/README.md index bc7d83775bb..80686eef893 100644 --- a/scipy/README.md +++ b/scipy/README.md @@ -9,7 +9,7 @@ Introduction ------------ This directory contains the JavaCPP Presets module for: - * SciPy 1.11.2 https://www.scipy.org/ + * SciPy 1.11.3 https://www.scipy.org/ Please refer to the parent README.md file for more detailed information about the JavaCPP Presets. @@ -48,7 +48,7 @@ We can use [Maven 3](http://maven.apache.org/) to download and install automatic org.bytedeco scipy-platform - 1.11.2-1.5.10-SNAPSHOT + 1.11.3-1.5.10-SNAPSHOT diff --git a/scipy/cppbuild.sh b/scipy/cppbuild.sh index f37a3587cc2..bc6f968f1be 100755 --- a/scipy/cppbuild.sh +++ b/scipy/cppbuild.sh @@ -8,11 +8,11 @@ if [[ -z "$PLATFORM" ]]; then fi BOOST=1_75_0 -SCIPY_VERSION=1.11.2 +SCIPY_VERSION=1.11.3 download http://downloads.sourceforge.net/project/boost/boost/${BOOST//_/.}/boost_$BOOST.tar.gz boost_$BOOST.tar.gz -download https://github.com/scipy/HiGHS/archive/refs/heads/main.tar.gz HiGHS-main.tar.gz -download https://github.com/scipy/unuran/archive/refs/heads/main.tar.gz unuran-main.tar.gz -download https://github.com/scipy/PROPACK/archive/refs/heads/main.tar.gz PROPACK-main.tar.gz +download https://github.com/scipy/HiGHS/archive/4a12295.tar.gz HiGHS-4a12295.tar.gz +download https://github.com/scipy/unuran/archive/81a1fd1.tar.gz unuran-81a1fd1.tar.gz +download https://github.com/scipy/PROPACK/archive/96f6800.tar.gz PROPACK-96f6800.tar.gz download https://github.com/scipy/scipy/archive/v$SCIPY_VERSION.tar.gz scipy-$SCIPY_VERSION.tar.gz mkdir -p $PLATFORM @@ -51,16 +51,25 @@ NUMPY_PATH="${NUMPY_PATH//\\//}" echo "Decompressing archives..." tar --totals -xzf ../boost_$BOOST.tar.gz -tar --totals -xzf ../HiGHS-main.tar.gz -tar --totals -xzf ../unuran-main.tar.gz -tar --totals -xzf ../PROPACK-main.tar.gz +tar --totals -xzf ../HiGHS-*.tar.gz +tar --totals -xzf ../unuran-*.tar.gz +tar --totals -xzf ../PROPACK-*.tar.gz tar --totals -xzf ../scipy-$SCIPY_VERSION.tar.gz cp -a boost_$BOOST/* scipy-$SCIPY_VERSION/scipy/_lib/boost_math/ -cp -a HiGHS-main/* scipy-$SCIPY_VERSION/scipy/_lib/highs/ -cp -a unuran-main/* scipy-$SCIPY_VERSION/scipy/_lib/unuran/ -cp -a PROPACK-main/* scipy-$SCIPY_VERSION/scipy/sparse/linalg/_propack/PROPACK/ +cp -a HiGHS-*/* scipy-$SCIPY_VERSION/scipy/_lib/highs/ +cp -a unuran-*/* scipy-$SCIPY_VERSION/scipy/_lib/unuran/ +cp -a PROPACK-*/* scipy-$SCIPY_VERSION/scipy/sparse/linalg/_propack/PROPACK/ cd scipy-$SCIPY_VERSION +sedinplace "/blas = dependency(\['openblas', 'OpenBLAS'\])/c\\ +includes = include_directories('$OPENBLAS_PATH/include/')\\ +blas = declare_dependency(dependencies : cc.find_library('openblas', dirs: '$OPENBLAS_PATH/lib/'), include_directories : includes)\\ +" scipy/meson.build + +sedinplace "/lapack = dependency(\['openblas', 'OpenBLAS'\])/c\\ +lapack = blas\\ +" scipy/meson.build + mkdir -p scipy/_lib/boost_math/include cp -a scipy/_lib/boost_math/boost scipy/_lib/boost_math/include mv _setup.py setup.py @@ -74,15 +83,15 @@ echo "libraries = openblas" >> site.cfg echo "library_dirs = $OPENBLAS_PATH/lib/" >> site.cfg echo "include_dirs = $OPENBLAS_PATH/include/" >> site.cfg -if [[ -f "$CPYTHON_PATH/include/python3.11/Python.h" ]]; then +if [[ -f "$CPYTHON_PATH/include/python3.12/Python.h" ]]; then # setup.py won't pick up the right libgfortran.so without this export LD_LIBRARY_PATH="$OPENBLAS_PATH/lib/:$CPYTHON_PATH/lib/:$NUMPY_PATH/lib/" - export PATH="$CPYTHON_PATH/lib/python3.11/bin/:$PATH" - export PYTHON_BIN_PATH="$CPYTHON_PATH/bin/python3.11" - export PYTHON_INCLUDE_PATH="$CPYTHON_PATH/include/python3.11/" - export PYTHON_LIB_PATH="$CPYTHON_PATH/lib/python3.11/" - export PYTHON_INSTALL_PATH="$INSTALL_PATH/lib/python3.11/site-packages/" - export SSL_CERT_FILE="$CPYTHON_PATH/lib/python3.11/site-packages/pip/_vendor/certifi/cacert.pem" + export PATH="$CPYTHON_PATH/lib/python3.12/bin/:$PATH" + export PYTHON_BIN_PATH="$CPYTHON_PATH/bin/python3.12" + export PYTHON_INCLUDE_PATH="$CPYTHON_PATH/include/python3.12/" + export PYTHON_LIB_PATH="$CPYTHON_PATH/lib/python3.12/" + export PYTHON_INSTALL_PATH="$INSTALL_PATH/lib/python3.12/site-packages/" + export SSL_CERT_FILE="$CPYTHON_PATH/lib/python3.12/site-packages/pip/_vendor/certifi/cacert.pem" chmod +x "$PYTHON_BIN_PATH" elif [[ -f "$CPYTHON_PATH/include/Python.h" ]]; then CPYTHON_PATH=$(cygpath $CPYTHON_PATH) @@ -101,95 +110,73 @@ mkdir -p "$PYTHON_INSTALL_PATH" # https://github.com/scipy/scipy/issues/15281 export SCIPY_USE_PYTHRAN=0 -TOOLS="setuptools==59.1.0 cython==0.29.35 pybind11==2.10.1 pythran==0.10.0 decorator==5.1.0 six==1.16.0 networkx==2.6.3 ply==3.11 beniget==0.4.0 gast==0.5.0" +TOOLS="setuptools==67.6.1 cython==0.29.35" if ! $PYTHON_BIN_PATH -m pip install --no-deps --target=$PYTHON_LIB_PATH $TOOLS; then echo "extra_link_args = -lgfortran" >> site.cfg - chmod +x "$CPYTHON_HOST_PATH/bin/python3.11" + chmod +x "$CPYTHON_HOST_PATH/bin/python3.12" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CPYTHON_HOST_PATH/lib/:$CPYTHON_HOST_PATH" - "$CPYTHON_HOST_PATH/bin/python3.11" -m pip install --no-deps --target="$CPYTHON_HOST_PATH/lib/python3.11/" crossenv==1.4 numpy==1.25.2 $TOOLS - "$CPYTHON_HOST_PATH/bin/python3.11" -m crossenv "$PYTHON_BIN_PATH" crossenv - cp -a "$NUMPY_PATH/python/numpy" "$CPYTHON_HOST_PATH/lib/python3.11/" -# cp -a "$CPYTHON_HOST_PATH/lib/python3.11/include" "$PYTHON_LIB_PATH" + "$CPYTHON_HOST_PATH/bin/python3.12" -m pip install --no-deps --target="$CPYTHON_HOST_PATH/lib/python3.12/" crossenv==1.4 numpy==1.26.1 $TOOLS + "$CPYTHON_HOST_PATH/bin/python3.12" -m crossenv "$PYTHON_BIN_PATH" crossenv + cp -a "$NUMPY_PATH/python/numpy" "$CPYTHON_HOST_PATH/lib/python3.12/" +# cp -a "$CPYTHON_HOST_PATH/lib/python3.12/include" "$PYTHON_LIB_PATH" source crossenv/bin/activate cross-expose cython numpy pybind11 pythran - chmod +x $CPYTHON_HOST_PATH/lib/python3.11/bin/* - export PATH="$CPYTHON_HOST_PATH/lib/python3.11/bin/:$PATH" + chmod +x $CPYTHON_HOST_PATH/lib/python3.12/bin/* + export PATH="$CPYTHON_HOST_PATH/lib/python3.12/bin/:$PATH" export PYTHON_BIN_PATH="python" export NUMPY_MADVISE_HUGEPAGE=1 # For some reason, setup.py fails on Linux if the Python installation is not at its original prefix - PREFIX_HOST_PATH=$(sed -n 's/^prefix="\(.*\)"/\1/p' $CPYTHON_HOST_PATH/bin/python3.11-config) + PREFIX_HOST_PATH=$(sed -n 's/^prefix="\(.*\)"/\1/p' $CPYTHON_HOST_PATH/bin/python3.12-config) mkdir -p $PREFIX_HOST_PATH cp -a $CPYTHON_HOST_PATH/* $PREFIX_HOST_PATH fi if [[ $PLATFORM == linux* ]]; then # For some reason, setup.py fails on Linux if the Python installation is not at its original prefix - PREFIX_PATH=$(sed -n 's/^prefix="\(.*\)"/\1/p' $CPYTHON_PATH/bin/python3.11-config) + PREFIX_PATH=$(sed -n 's/^prefix="\(.*\)"/\1/p' $CPYTHON_PATH/bin/python3.12-config) mkdir -p $PREFIX_PATH cp -a $CPYTHON_PATH/* $PREFIX_PATH fi case $PLATFORM in linux-armhf) - ATLAS=None CC="arm-linux-gnueabihf-gcc -std=c99" F77="arm-linux-gnueabihf-gfortran" F90="$F77" FFLAGS="-fPIC" LDFLAGS="-shared" "$PYTHON_BIN_PATH" setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -I$PYTHON_LIB_PATH/include/python/ -L$CPYTHON_PATH/lib/ -L$OPENBLAS_PATH/lib/ -lopenblas -lpthread -lgfortran install --prefix $INSTALL_PATH + ATLAS=None CC="arm-linux-gnueabihf-gcc -std=c99" F77="arm-linux-gnueabihf-gfortran" F90="$F77" FFLAGS="-fPIC" "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH arm-linux-gnueabihf-strip $(find ../ -iname *.so) ;; linux-arm64) - ATLAS=None CC="aarch64-linux-gnu-gcc -mabi=lp64" F77="aarch64-linux-gnu-gfortran" F90="$F77" FFLAGS="-mabi=lp64 -fPIC" LDFLAGS="-mabi=lp64 -shared" "$PYTHON_BIN_PATH" setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -I$PYTHON_LIB_PATH/include/python/ -L$CPYTHON_PATH/lib/ -L$OPENBLAS_PATH/lib/ -lopenblas -lpthread -lgfortran install --prefix $INSTALL_PATH + ATLAS=None CC="aarch64-linux-gnu-gcc -mabi=lp64" F77="aarch64-linux-gnu-gfortran" F90="$F77" FFLAGS="-mabi=lp64 -fPIC" "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH aarch64-linux-gnu-strip $(find ../ -iname *.so) ;; linux-ppc64le) - ATLAS=None CC="powerpc64le-linux-gnu-gcc -m64" F77="powerpc64le-linux-gnu-gfortran" F90="$F77" FFLAGS="-m64 -fPIC" LDFLAGS="-m64 -shared" "$PYTHON_BIN_PATH" setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -I$PYTHON_LIB_PATH/include/python/ -L$CPYTHON_PATH/lib/ -L$OPENBLAS_PATH/lib/ -lopenblas -lpthread -lgfortran install --prefix $INSTALL_PATH + ATLAS=None CC="powerpc64le-linux-gnu-gcc -m64" F77="powerpc64le-linux-gnu-gfortran" F90="$F77" FFLAGS="-m64 -fPIC" "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH powerpc64le-linux-gnu-strip $(find ../ -iname *.so) ;; linux-x86) - ATLAS=None CC="gcc -m32 -D__STDC_NO_THREADS__" FFLAGS="-m32 -fPIC" LDFLAGS="-m32 -shared" "$PYTHON_BIN_PATH" setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -I$PYTHON_LIB_PATH/include/python/ -L$CPYTHON_PATH/lib/ -L$OPENBLAS_PATH/lib/ -lopenblas -lpthread -lgfortran install --prefix $INSTALL_PATH + ATLAS=None CC="gcc -m32 -D__STDC_NO_THREADS__" FFLAGS="-m32 -fPIC" "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH strip $(find ../ -iname *.so) ;; linux-x86_64) - ATLAS=None CC="gcc -m64 -D__STDC_NO_THREADS__" FFLAGS="-m64 -fPIC" LDFLAGS="-m64 -shared" "$PYTHON_BIN_PATH" setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -I$PYTHON_LIB_PATH/include/python/ -L$CPYTHON_PATH/lib/ -L$OPENBLAS_PATH/lib/ -lopenblas -lpthread -lgfortran install --prefix $INSTALL_PATH + ATLAS=None CC="gcc -m64 -D__STDC_NO_THREADS__" FFLAGS="-m64 -fPIC" "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH strip $(find ../ -iname *.so) ;; macosx-*) export F77="$(ls -1 /usr/local/bin/gfortran-* | head -n 1)" export F90="$F77" export LDFLAGS="-L/usr/lib/" - ATLAS=None "$PYTHON_BIN_PATH" setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -I$PYTHON_LIB_PATH/include/python/ -L$CPYTHON_PATH/lib/ -L$OPENBLAS_PATH/lib/ -lopenblas -lpthread -lgfortran install --prefix $INSTALL_PATH + ATLAS=None FC="$F77" "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH # need to add RPATH so it can find MKL in cache for f in $(find ../ -iname *.so); do install_name_tool -add_rpath @loader_path/../../../ -add_rpath @loader_path/../../../../ $f || true; done ;; windows-x86) # parameters required by clang-cl export CL="-m32" - # the build sometimes fails with multiple jobs - export MAKEJ=1 - # SciPy can only be built from very short paths on Windows - cmd.exe //c "mklink /j \\scipy ." - export CPYTHON_PATH=$(cygpath -w $CPYTHON_PATH) - export PYTHON_BIN_PATH=$(cygpath -w $PYTHON_BIN_PATH) - export PYTHON_LIB_PATH=$(cygpath -w $PYTHON_LIB_PATH) - export OPENBLAS_PATH=$(cygpath -w $OPENBLAS_PATH) - export INSTALL_PATH=$(cygpath -w $INSTALL_PATH) - export ATLAS=None - cmd.exe //c "cd \\scipy & $PYTHON_BIN_PATH setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -I$PYTHON_LIB_PATH/include/python/ -L$CPYTHON_PATH/lib/ -L$CPYTHON_PATH/libs/ -L$OPENBLAS_PATH/lib/ -lopenblas install --prefix $INSTALL_PATH" - cmd.exe //c "rmdir \\scipy" + ATLAS=None CC="gcc -m32" CXX="g++ -m32" "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH ;; windows-x86_64) # parameters required by clang-cl export CL="-m64" - # the build sometimes fails with multiple jobs - export MAKEJ=1 - # SciPy can only be built from very short paths on Windows - cmd.exe //c "mklink /j \\scipy ." - export CPYTHON_PATH=$(cygpath -w $CPYTHON_PATH) - export PYTHON_BIN_PATH=$(cygpath -w $PYTHON_BIN_PATH) - export PYTHON_LIB_PATH=$(cygpath -w $PYTHON_LIB_PATH) - export OPENBLAS_PATH=$(cygpath -w $OPENBLAS_PATH) - export INSTALL_PATH=$(cygpath -w $INSTALL_PATH) - export ATLAS=None - cmd.exe //c "cd \\scipy & $PYTHON_BIN_PATH setup.py --quiet build -j $MAKEJ build_ext -I$CPYTHON_PATH/include/ -I$PYTHON_LIB_PATH/include/python/ -L$CPYTHON_PATH/lib/ -L$CPYTHON_PATH/libs/ -L$OPENBLAS_PATH/lib/ -lopenblas install --prefix $INSTALL_PATH" - cmd.exe //c "rmdir \\scipy" + ATLAS=None CC="gcc -m64" CXX="g++ -m64" "$PYTHON_BIN_PATH" -m pip install . --prefix $INSTALL_PATH ;; *) echo "Error: Platform \"$PLATFORM\" is not supported" diff --git a/scipy/platform/pom.xml b/scipy/platform/pom.xml index 1803f8ceaae..8007e7af77c 100644 --- a/scipy/platform/pom.xml +++ b/scipy/platform/pom.xml @@ -12,7 +12,7 @@ org.bytedeco scipy-platform - 1.11.2-${project.parent.version} + 1.11.3-${project.parent.version} JavaCPP Presets Platform for SciPy @@ -23,7 +23,7 @@ org.bytedeco numpy-platform - 1.25.2-${project.parent.version} + 1.26.1-${project.parent.version} ${project.groupId} diff --git a/scipy/pom.xml b/scipy/pom.xml index 55a0277c19f..c9dcd37c780 100644 --- a/scipy/pom.xml +++ b/scipy/pom.xml @@ -11,14 +11,14 @@ org.bytedeco scipy - 1.11.2-${project.parent.version} + 1.11.3-${project.parent.version} JavaCPP Presets for SciPy org.bytedeco numpy - 1.25.2-${project.parent.version} + 1.26.1-${project.parent.version} org.bytedeco @@ -41,7 +41,7 @@ org.bytedeco numpy - 1.25.2-${project.parent.version} + 1.26.1-${project.parent.version} org.bytedeco @@ -52,13 +52,13 @@ org.bytedeco cpython - 3.11.5-${project.parent.version} + 3.12.0-${project.parent.version} ${javacpp.platform} org.bytedeco numpy - 1.25.2-${project.parent.version} + 1.26.1-${project.parent.version} ${javacpp.platform} @@ -77,7 +77,7 @@ ${basedir}/../cpython/src/main/resources/org/bytedeco/cpython/include/ ${basedir}/../cpython/target/classes/org/bytedeco/cpython/include/ ${basedir}/../cpython/cppbuild/${javacpp.platform}/include/ - ${basedir}/../cpython/cppbuild/${javacpp.platform}/include/python3.11/ + ${basedir}/../cpython/cppbuild/${javacpp.platform}/include/python3.12/ ${basedir}/../numpy/src/main/resources/org/bytedeco/numpy/include/ ${basedir}/../numpy/target/classes/org/bytedeco/numpy/include/ ${basedir}/../numpy/cppbuild/${javacpp.platform}/python/numpy/core/include/ @@ -108,7 +108,7 @@ /org/bytedeco/openblas/${javacpp.platform}/include/ /org/bytedeco/cpython/include/ /org/bytedeco/cpython/${javacpp.platform}/include/ - /org/bytedeco/cpython/${javacpp.platform}/include/python3.11/ + /org/bytedeco/cpython/${javacpp.platform}/include/python3.12/ /org/bytedeco/numpy/include/ /org/bytedeco/numpy/${javacpp.platform}/python/numpy/core/include/ /org/bytedeco/numpy/${javacpp.platform}/python/numpy/core/include/numpy/ @@ -177,7 +177,7 @@ org.bytedeco cpython - 3.11.5-${project.parent.version} + 3.12.0-${project.parent.version} ${os.name}-${os.arch} diff --git a/scipy/samples/pom.xml b/scipy/samples/pom.xml index 7d44ccb35dc..0c24e55e552 100644 --- a/scipy/samples/pom.xml +++ b/scipy/samples/pom.xml @@ -12,7 +12,7 @@ org.bytedeco scipy-platform - 1.11.2-1.5.10-SNAPSHOT + 1.11.3-1.5.10-SNAPSHOT diff --git a/tvm/cppbuild.sh b/tvm/cppbuild.sh index 76fa1e076e1..7076871a227 100755 --- a/tvm/cppbuild.sh +++ b/tvm/cppbuild.sh @@ -104,6 +104,8 @@ sedinplace 's/find_opencl(${USE_OPENCL})/find_package(OpenCL REQUIRED)/g' cmake/ # https://github.com/apache/tvm/pull/6752 #patch -Np1 < ../../../tvm.patch +patch -Np1 < ../../../tvm-python.patch + # Work around issues with llvm-config f=($LLVM_PATH/llvm-config*) if [[ -f $f ]]; then @@ -118,15 +120,15 @@ if [[ -f "$LLVM_PATH/lib/LTO.lib" ]]; then ln -sf LTO.lib $LLVM_PATH/lib/LLVM.lib fi -if [[ -f "$CPYTHON_PATH/include/python3.11/Python.h" ]]; then +if [[ -f "$CPYTHON_PATH/include/python3.12/Python.h" ]]; then # setup.py won't pick up the right libgfortran.so without this export LD_LIBRARY_PATH="$OPENBLAS_PATH/lib/:$CPYTHON_PATH/lib/:$NUMPY_PATH/lib/:$SCIPY_PATH/lib/" - export PATH="$CPYTHON_PATH/lib/python3.11/bin/:$PATH" - export PYTHON_BIN_PATH="$CPYTHON_PATH/bin/python3.11" - export PYTHON_INCLUDE_PATH="$CPYTHON_PATH/include/python3.11/" - export PYTHON_LIB_PATH="$CPYTHON_PATH/lib/python3.11/" - export PYTHON_INSTALL_PATH="$INSTALL_PATH/lib/python3.11/site-packages/" - export SSL_CERT_FILE="$CPYTHON_PATH/lib/python3.11/site-packages/pip/_vendor/certifi/cacert.pem" + export PATH="$CPYTHON_PATH/lib/python3.12/bin/:$PATH" + export PYTHON_BIN_PATH="$CPYTHON_PATH/bin/python3.12" + export PYTHON_INCLUDE_PATH="$CPYTHON_PATH/include/python3.12/" + export PYTHON_LIB_PATH="$CPYTHON_PATH/lib/python3.12/" + export PYTHON_INSTALL_PATH="$INSTALL_PATH/lib/python3.12/site-packages/" + export SSL_CERT_FILE="$CPYTHON_PATH/lib/python3.12/site-packages/pip/_vendor/certifi/cacert.pem" chmod +x "$PYTHON_BIN_PATH" elif [[ -f "$CPYTHON_PATH/include/Python.h" ]]; then CPYTHON_PATH=$(cygpath $CPYTHON_PATH) @@ -145,7 +147,7 @@ mkdir -p "$PYTHON_INSTALL_PATH" export CFLAGS="-I$CPYTHON_PATH/include/ -I$PYTHON_LIB_PATH/include/python/ -L$CPYTHON_PATH/lib/ -L$CPYTHON_PATH/libs/" export PYTHONNOUSERSITE=1 -$PYTHON_BIN_PATH -m pip install --target=$PYTHON_LIB_PATH setuptools==59.1.0 +$PYTHON_BIN_PATH -m pip install --target=$PYTHON_LIB_PATH setuptools==67.6.1 case $PLATFORM in linux-x86_64) diff --git a/tvm/platform/gpu/pom.xml b/tvm/platform/gpu/pom.xml index f40d2661d24..073bbe8dbd6 100644 --- a/tvm/platform/gpu/pom.xml +++ b/tvm/platform/gpu/pom.xml @@ -39,7 +39,7 @@ org.bytedeco scipy-platform - 1.11.2-${project.parent.version} + 1.11.3-${project.parent.version} org.bytedeco diff --git a/tvm/platform/pom.xml b/tvm/platform/pom.xml index e85900db169..f19274514b0 100644 --- a/tvm/platform/pom.xml +++ b/tvm/platform/pom.xml @@ -38,7 +38,7 @@ org.bytedeco scipy-platform - 1.11.2-${project.parent.version} + 1.11.3-${project.parent.version} org.bytedeco diff --git a/tvm/pom.xml b/tvm/pom.xml index 49fa631ec1f..d9f4b9c2fee 100644 --- a/tvm/pom.xml +++ b/tvm/pom.xml @@ -33,7 +33,7 @@ org.bytedeco scipy - 1.11.2-${project.parent.version} + 1.11.3-${project.parent.version} org.bytedeco @@ -76,7 +76,7 @@ org.bytedeco scipy-platform - 1.11.2-${project.parent.version} + 1.11.3-${project.parent.version} @@ -110,7 +110,7 @@ ${basedir}/../cpython/src/main/resources/org/bytedeco/cpython/include/ ${basedir}/../cpython/target/classes/org/bytedeco/cpython/include/ ${basedir}/../cpython/cppbuild/${javacpp.platform}/include/ - ${basedir}/../cpython/cppbuild/${javacpp.platform}/include/python3.11/ + ${basedir}/../cpython/cppbuild/${javacpp.platform}/include/python3.12/ ${basedir}/../numpy/src/main/resources/org/bytedeco/numpy/include/ ${basedir}/../numpy/target/classes/org/bytedeco/numpy/include/ ${basedir}/../numpy/cppbuild/${javacpp.platform}/python/numpy/core/include/ @@ -163,7 +163,7 @@ /org/bytedeco/openblas/${javacpp.platform}/include/ /org/bytedeco/cpython/include/ /org/bytedeco/cpython/${javacpp.platform}/include/ - /org/bytedeco/cpython/${javacpp.platform}/include/python3.11/ + /org/bytedeco/cpython/${javacpp.platform}/include/python3.12/ /org/bytedeco/numpy/include/ /org/bytedeco/numpy/${javacpp.platform}/python/numpy/core/include/ /org/bytedeco/numpy/${javacpp.platform}/python/numpy/core/include/numpy/ diff --git a/tvm/samples/DeployBERT.java b/tvm/samples/DeployBERT.java index d43dbe43ed7..1b88df4218b 100644 --- a/tvm/samples/DeployBERT.java +++ b/tvm/samples/DeployBERT.java @@ -176,18 +176,18 @@ public static void DeployBERTRuntime() { System.out.println("Running BERT runtime..."); // load in the library DLDevice ctx = new DLDevice().device_type(kDLCPU).device_id(0); - Module mod_factory = Module.LoadFromFile("lib/libbert.so"); + Module mod_factory = Module.LoadFromFile(new TVMString("lib/libbert.so")); // create the BERT runtime module TVMValue values = new TVMValue(2); IntPointer codes = new IntPointer(2); TVMArgsSetter setter = new TVMArgsSetter(values, codes); setter.apply(0, ctx); TVMRetValue rv = new TVMRetValue(); - mod_factory.GetFunction("default").CallPacked(new TVMArgs(values, codes, 1), rv); + mod_factory.GetFunction(new TVMString("default")).CallPacked(new TVMArgs(values, codes, 1), rv); Module gmod = rv.asModule(); - PackedFunc set_input = gmod.GetFunction("set_input"); - PackedFunc get_output = gmod.GetFunction("get_output"); - PackedFunc run = gmod.GetFunction("run"); + PackedFunc set_input = gmod.GetFunction(new TVMString("set_input")); + PackedFunc get_output = gmod.GetFunction(new TVMString("get_output")); + PackedFunc run = gmod.GetFunction(new TVMString("run")); // Use the C++ API to create some random sequence int batch = 1, seq_length = 128; diff --git a/tvm/samples/HowtoDeploy.java b/tvm/samples/HowtoDeploy.java index 51e1c5937f1..9df8abe6cf5 100644 --- a/tvm/samples/HowtoDeploy.java +++ b/tvm/samples/HowtoDeploy.java @@ -97,7 +97,7 @@ static void PrepareTestLibs() throws Exception { static void Verify(Module mod, String fname) { // Get the function from the module. - PackedFunc f = mod.GetFunction(fname); + PackedFunc f = mod.GetFunction(new TVMString(fname)); assert f != null; // Allocate the DLPack data structures. // @@ -149,14 +149,14 @@ static void Verify(Module mod, String fname) { static void DeploySingleOp() { // Normally we can directly - Module mod_dylib = Module.LoadFromFile("lib/test_addone_dll.so"); + Module mod_dylib = Module.LoadFromFile(new TVMString("lib/test_addone_dll.so")); System.out.println("Verify dynamic loading from test_addone_dll.so"); Verify(mod_dylib, "addone"); // For libraries that are directly packed as system lib and linked together with the app // We can directly use GetSystemLib to get the system wide library. System.out.println("Verify load function from system lib"); TVMRetValue rv = new TVMRetValue(); - Registry.Get("runtime.SystemLib").CallPacked(new TVMArgs((TVMValue)null, (IntPointer)null, 0), rv); + Registry.Get(new TVMString("runtime.SystemLib")).CallPacked(new TVMArgs((TVMValue)null, (IntPointer)null, 0), rv); Module mod_syslib = rv.asModule(); // Verify(mod_syslib, "addonesys"); } @@ -165,18 +165,18 @@ static void DeployGraphExecutor() { System.out.println("Running graph executor..."); // load in the library DLDevice dev = new DLDevice().device_type(kDLCPU).device_id(0); - Module mod_factory = Module.LoadFromFile("lib/test_relay_add.so"); + Module mod_factory = Module.LoadFromFile(new TVMString("lib/test_relay_add.so")); // create the graph executor module TVMValue values = new TVMValue(2); IntPointer codes = new IntPointer(2); TVMArgsSetter setter = new TVMArgsSetter(values, codes); setter.apply(0, dev); TVMRetValue rv = new TVMRetValue(); - mod_factory.GetFunction("default").CallPacked(new TVMArgs(values, codes, 1), rv); + mod_factory.GetFunction(new TVMString("default")).CallPacked(new TVMArgs(values, codes, 1), rv); Module gmod = rv.asModule(); - PackedFunc set_input = gmod.GetFunction("set_input"); - PackedFunc get_output = gmod.GetFunction("get_output"); - PackedFunc run = gmod.GetFunction("run"); + PackedFunc set_input = gmod.GetFunction(new TVMString("set_input")); + PackedFunc get_output = gmod.GetFunction(new TVMString("get_output")); + PackedFunc run = gmod.GetFunction(new TVMString("run")); // Use the C++ API NDArray x = NDArray.Empty(new ShapeTuple(2, 2), new DLDataType().code((byte)kDLFloat).bits((byte)32).lanes((short)1), dev); diff --git a/tvm/tvm-python.patch b/tvm/tvm-python.patch new file mode 100644 index 00000000000..f9c05230262 --- /dev/null +++ b/tvm/tvm-python.patch @@ -0,0 +1,90 @@ +diff --git a/python/tvm/relay/frontend/pytorch_utils.py b/python/tvm/relay/frontend/pytorch_utils.py +index 7de1248bd..b83e6c632 100644 +--- a/python/tvm/relay/frontend/pytorch_utils.py ++++ b/python/tvm/relay/frontend/pytorch_utils.py +@@ -36,7 +36,6 @@ def is_version_greater_than(ver): + than the one given as an argument. + """ + import torch +- from distutils.version import LooseVersion + + torch_ver = torch.__version__ + # PT version numbers can include +cu[cuda version code] +@@ -44,7 +43,7 @@ def is_version_greater_than(ver): + if "+cu" in torch_ver: + torch_ver = torch_ver.split("+cu")[0] + +- return LooseVersion(torch_ver) > ver ++ return True + + + def getattr_attr_name(node): +diff --git a/python/tvm/relay/op/contrib/ethosn.py b/python/tvm/relay/op/contrib/ethosn.py +index 81534d48a..c5a9b6d58 100644 +--- a/python/tvm/relay/op/contrib/ethosn.py ++++ b/python/tvm/relay/op/contrib/ethosn.py +@@ -17,7 +17,6 @@ + # pylint: disable=invalid-name, unused-argument + """Arm(R) Ethos(TM)-N NPU supported operators.""" + from enum import Enum +-from distutils.version import LooseVersion + + import tvm.ir + from tvm.relay import transform +@@ -118,11 +117,6 @@ def partition_for_ethosn(mod, params=None, **opts): + """ + api_version = ethosn_api_version() + supported_api_versions = ["3.2.0"] +- if all(api_version != LooseVersion(exp_ver) for exp_ver in supported_api_versions): +- raise ValueError( +- f"Driver stack version {api_version} is unsupported. " +- f"Please use version in {supported_api_versions}." +- ) + + if params: + mod["main"] = bind_params_by_name(mod["main"], params) +@@ -433,8 +427,6 @@ def split(expr): + """Check if a split is supported by Ethos-N.""" + if not ethosn_available(): + return False +- if ethosn_api_version() == LooseVersion("3.0.1"): +- return False + if not _ethosn.split(expr): + return False + +diff --git a/python/tvm/relay/testing/tflite.py b/python/tvm/relay/testing/tflite.py +index df9c0bcad..f95fc3c37 100644 +--- a/python/tvm/relay/testing/tflite.py ++++ b/python/tvm/relay/testing/tflite.py +@@ -15,7 +15,6 @@ + # specific language governing permissions and limitations + # under the License. + """Common utilities for creating TFLite models""" +-from distutils.version import LooseVersion + import numpy as np + import pytest + import tflite.Model # pylint: disable=wrong-import-position +@@ -133,17 +132,12 @@ class TFLiteModel: + """ + assert self.serial_model is not None, "TFLite model was not created." + +- output_tolerance = None +- if tf.__version__ < LooseVersion("2.5.0"): +- output_tolerance = 1 +- interpreter = tf.lite.Interpreter(model_content=self.serial_model) +- else: +- output_tolerance = 0 +- interpreter = tf.lite.Interpreter( +- model_content=self.serial_model, +- experimental_op_resolver_type=tf.lite.experimental.OpResolverType.BUILTIN_REF, +- experimental_preserve_all_tensors=False, +- ) ++ output_tolerance = 0 ++ interpreter = tf.lite.Interpreter( ++ model_content=self.serial_model, ++ experimental_op_resolver_type=tf.lite.experimental.OpResolverType.BUILTIN_REF, ++ experimental_preserve_all_tensors=False, ++ ) + + interpreter.allocate_tensors() + input_details = interpreter.get_input_details()