Commit Graph

3293 Commits

Author SHA1 Message Date
rdb 535105c373 build: Update to interrogate 0.6.0
Fixes #1743
2025-07-28 15:18:03 +02:00
Olivier Roussel cbb313d732
Use Win32 native calls for atomic also with clang-cl (#1746) 2025-05-11 09:15:12 +02:00
rdb 6452907b64 Improvements for env handling with node.js and emscripten
- Initializes the environment so that getenv et al works properly
- No longer calls JS functions at static init time; the JS preamble will
  pass the right env vars to ExecutionEnvironment
- Sets the binary name to the path of the .js file
2025-02-03 18:06:30 +01:00
rdb 79d6727077 Move MAIN_DIR initialization code from interrogate to panda3d
Using the new -init flag, see panda3d/interrogate#3
2025-02-02 20:11:32 +01:00
rdb fa25c51d30 notify: Fix compile error on Android 2024-11-26 16:40:18 +01:00
rdb f5433fa5d7 CMake/makewheel: properly determine and pass platform tag
One part of #1663
2024-11-07 12:49:11 +01:00
rdb b51dd4d7bc Merge branch 'release/1.10.x' 2024-11-06 22:52:54 +01:00
rdb a076dd4704 CMake: Fix issues locating Python in thirdparty on Windows
Fixes #1472
2024-11-06 15:48:45 +01:00
rdb 4da5158b05 CMake: change how thirdparty directory is detected 2024-11-06 12:57:51 +01:00
rdb cdebca4703 CMake: Only pass -fno-rtti and -frtti for C++ targets 2024-11-06 11:28:33 +01:00
rdb 72b9dd9a70 parser-inc: add emscripten/heap.h to squelch interrogate warning 2024-11-04 18:40:33 +01:00
rdb 7c74060035 dtoolutil: Read environment variables in emscripten under node.js 2024-11-04 18:40:26 +01:00
rdb 94c63fe9da dtoolutil: Remove silly unused variable 2024-11-04 13:25:22 +01:00
rdb 50b984cffd dtoolbase: Fix test failure on 32-bit Windows with pftoa 2024-10-31 23:50:27 +01:00
rdb ff91f127bf py_compat: Fix Python 2.7 compilation error
This code never actually gets compiled in Python 3

[skip ci]
2024-10-30 21:52:23 +01:00
rdb 6d54aee0c7 Remove runtime dependency on interrogatedb 2024-10-30 17:46:26 +01:00
rdb 0c1a0799b1 Fix faulty auto-merge 2024-10-30 14:41:06 +01:00
rdb e58449cde7 dtoolutil: Let Python do Filename conversion to UTF-8 2024-10-30 13:42:33 +01:00
rdb 7560a1edd1 Merge branch 'release/1.10.x' 2024-10-30 13:42:21 +01:00
rdb f47b34d2a1 Fix remaining uses of ._PyType member in extension code
This should be replaced with Dtool_GetPyTypeObject, hiding the implementation details a bit so that we can more easily change the underlying structure if we need later

Also adds Py_NewRef to py_compat.h, backporting from master
2024-10-30 13:26:34 +01:00
rdb 0ba2aadcd6 Introduce Py_IS_TYPE, use for Py_TYPE comparisons 2024-10-30 13:17:11 +01:00
rdb 64454b1c9f Replace direct uses of ob_type, which gives problems in nogil build 2024-10-30 13:17:11 +01:00
rdb 6885edc811 build: Update interrogate to 0.3.0 to support 3.13t build 2024-10-29 16:10:39 +01:00
rdb f50fef3744 Switch over to C++14, drop support for MSVC 2015
The main reason is that the current development version of Eigen requires C++14 to be enabled, so otherwise we can't compile with the latest Eigen.

If really needed, we can keep support for MSVC 2015 (please make your voice heard) but that would lock us out of a few features of C++14.
2024-10-19 13:16:36 +02:00
rdb beff684af3 Further thread safety changes for Python 3.13 free threading
See #1683
2024-09-19 20:43:06 +02:00
rdb 4b2fa45578 Make use of PyImport_GetModule function 2024-09-19 20:42:31 +02:00
rdb 5106fc879f Changes for compatibility with Python 3.13
Includes some preliminary work to make free-threading safe, see also #1683
2024-09-19 16:01:10 +02:00
rdb b32459ffa1 Merge branch 'release/1.10.x' 2024-09-19 15:51:25 +02:00
rdb cdafd81764 Fix compilation issues with Python 3.13 2024-09-19 15:47:50 +02:00
rdb f5401b19fa Merge branch 'release/1.10.x' 2024-09-16 13:54:22 +02:00
rdb 78ace53dbe dtoolutil: Fix typo in pfstream causing compiler warning 2024-08-14 19:08:49 +02:00
rdb ddaeb05367 Fix compilation when building without bison 2024-08-14 19:08:16 +02:00
rdb 8d2407d553 Delete cppparser and interrogate from tree
These tools now live in https://github.com/panda3d/interrogate/

See also #1074
2024-08-10 16:55:03 +02:00
rdb c9cddb8d92 CMake: Stop building interrogate from tree
Instead, either build it externally (BUILD_INTERROGATE) or accept INTERROGATE_EXECUTABLE / INTERROGATE_MODULE_EXECUTABLE settings
2024-08-10 16:54:12 +02:00
rdb fc1d95ae1d dtoolbase: Add missing includes to pstrtod.cxx 2024-08-08 21:36:21 +02:00
rdb abf0b38705 dtoolutil: Use string compare instead of strcmp in filename.I 2024-08-08 21:36:00 +02:00
rdb ad57762e9f Merge branch 'release/1.10.x' 2024-08-07 22:34:08 +02:00
rdb 8c8cbeea98 linmath: For repr, use as much precision as needed for roundtrip
Will use as few digits as is necessary to ensure that round-tripping the same number with pstrtod will result in the same vector.  This prevents eg. 3.3 formatting as 3.29999995 while still ensuring that two floats that are not equal (other than nan) are guaranteed to have a different string representation.

Uses a hacky pftoa function that can be abandoned as soon as we adopt C++17, which has to_chars that does what we need

Fixes #1671
2024-08-07 17:24:11 +02:00
rdb ca7ba4eab3 py_panda: Add Dtool_GetPyTypeObject macro
This is a cleaner, future-proof way of accessing a Panda type as PyTypeObject pointer
2024-08-07 15:53:27 +02:00
rdb 1cc0676e41 dtoolutil: Fix misnamed include guard 2024-08-04 17:08:45 +02:00
rdb 58ea174eb2 interrogate: Use the limited Python API for simple Python back-end 2024-08-03 21:50:19 +02:00
rdb 0215b02985 interrogate: Replace a use of std::cerr with nout 2024-08-03 16:36:55 +02:00
rdb ae04533527 dtoolutil: Fix typo in error message 2024-08-03 16:36:37 +02:00
rdb 7a13d86d93 CMake: remove vestigial HAVE_ROCKET_PYTHON macro 2024-08-03 15:00:44 +02:00
rdb 105f938d68 interrogate: Fix non-deterministic order of external import types
Fixes #1651
2024-05-28 11:11:21 +02:00
rdb 0df17a00ca Merge branch 'bugfix/interrogate-gc-exception' of github.com:johnnyapol/panda3d 2024-05-14 22:46:53 +02:00
John C. Allwein 8cc62c9706 interrogate: avoid GC exceptions processing objects mid-construction
After 38692dd525, GC pauses occuring before
the __init__ function of the C++ backed object is called in a inheritance chain will
cause an exception during garbage collection and cause the python runtime to exit.

This can be observed by say, forcing a GC-pause in MetaInterval.__init__ before it calls CMetaInterval::__init__.
2024-05-14 09:48:55 -06:00
rdb 5cad92cd56 interrogate: Fix missing header to fix non-unity build 2024-03-29 20:57:12 +01:00
rdb 38692dd525 interrogate: Support subclassing C++ objects from Python
This change enables persistent Python wrapper objects for Python subclasses of typed, reference counted C++ objects.  That means that these objects will store a reference to `self` on the C++ object, and interrogate will always return that instead of making a new Python wrapper every time it is returned from C++.

Practically, this means that you could subclass eg. PandaNode, Event, Fog, what have you, and store these in the scene graph - the Python data in the subclass will be retained and Panda will return your subclass when you ask for the object back rather than creating a new wrapper object without your original data.

To do this, Interrogate generates a proxy class inheriting from the C++ type with additional room to store a `self` pointer and a TypeHandle (which is returned by an overridden `get_type()`).  This TypeHandle is automatically created by registering the Python subclass with the typing system.  The proxy class is only used when the constructor detects that it's constructing for a subtype, so that regular uses of the C++ type are not affected by this mechanism.

(The registration with the typing system could use some improvement.  There's no regard for namespacing right now, in particular.  Furthermore, we could move the registration to an `__init_subclass__()` method, with parameters to specify an existing TypeHandle or to customize the type name.)

This creates a reference cycle, which must be cleared somehow.  One way this happens is by overriding `unref()` in the proxy, which checks that if the Python and C++ reference counts are both 1, this must be the circular reference, and then it breaks the cycle.  Note that this will _only_ work if all other Python references have been cleared before the last C++ reference goes away.  For the other case, we need to rely on Python's garbage collector, so these classes also implement tp_traverse and tp_clear.

This commit also therefore re-enables Python garbage collector support (ie. defining `__traverse__()`), which was previously disabled due to the problems caused by multiple Python wrappers referring to the same C++ object.  To avoid these problems, Panda will only cooperate with Python's GC if the C++ reference count is 1, in which case we can trivially prove that the last reference must be from the Python wrapper.  Note that this explains why we need persistent wrappers for traversal to work--if there are multiple Python wrappers pointing to the C++ object, and they are all participating in a reference cycle, the reference count cannot be 1, and cycle detection does not work.  By default, the GC is only enabled for Python subclasses, but a class may define `__traverse__()` in order to opt-in, keeping the previous limitation in mind.

There is a second mechanism introduced by this commit: classes may define a public `__self__` member of type `PyObject *` if they want to use persistent objects even if they aren't being subclassed.  This allows these classes to participate in Python's GC and avoid the situation above.

The cycle detection is implemented for PandaNode's Python tags, but this is very incomplete, since the traversal doesn't recurse into children and it won't work if there is more than one wrapper object that is part of a cycle, since PandaNode by default doesn't use persistent wrappers.  This problem may need more attention later.

Fixes #1410
2024-03-29 20:51:34 +01:00
rdb 61665dc8ba cppparser: Remove unused `<list>` include 2024-03-29 16:12:01 +01:00