diff --git a/.cargo/config b/.cargo/config.toml similarity index 100% rename from .cargo/config rename to .cargo/config.toml diff --git a/.gitignore b/.gitignore index 073aaab..2da30fd 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ RustCHOP.xcodeproj/project.xcworkspace/xcuserdata *.xcodeproj/ cmake-build* output.plist + +venv/ diff --git a/Cargo.lock b/Cargo.lock index f4f3dd0..219e6de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,12 +20,6 @@ dependencies = [ "gimli 0.31.1", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "adler2" version = "2.0.0" @@ -66,9 +60,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" [[package]] name = "android-tzdata" @@ -96,9 +90,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.91" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "aquamarine" @@ -115,9 +109,9 @@ dependencies = [ [[package]] name = "arbitrary" -version = "1.3.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" [[package]] name = "async-trait" @@ -127,7 +121,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -180,7 +174,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -191,7 +185,7 @@ dependencies = [ "autocxx-engine 0.27.0 (git+https://github.com/tychedelia/autocxx.git?branch=main)", "env_logger 0.9.3", "indexmap 1.9.3", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -202,7 +196,7 @@ dependencies = [ "autocxx-engine 0.27.0 (git+https://github.com/tychedelia/autocxx.git)", "env_logger 0.9.3", "indexmap 1.9.3", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -216,7 +210,7 @@ dependencies = [ "cc", "cxx-gen", "indexmap 1.9.3", - "indoc", + "indoc 1.0.9", "itertools 0.10.5", "log", "miette", @@ -227,7 +221,7 @@ dependencies = [ "regex", "rustversion", "serde_json", - "syn 2.0.85", + "syn 2.0.87", "tempfile", "thiserror", "version_check", @@ -244,7 +238,7 @@ dependencies = [ "cc", "cxx-gen", "indexmap 1.9.3", - "indoc", + "indoc 1.0.9", "itertools 0.10.5", "log", "miette", @@ -255,7 +249,7 @@ dependencies = [ "regex", "rustversion", "serde_json", - "syn 2.0.85", + "syn 2.0.87", "tempfile", "thiserror", "version_check", @@ -270,7 +264,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -286,7 +280,7 @@ dependencies = [ "quote", "serde", "serde_json", - "syn 2.0.85", + "syn 2.0.87", "thiserror", ] @@ -303,7 +297,7 @@ dependencies = [ "quote", "serde", "serde_json", - "syn 2.0.85", + "syn 2.0.87", "thiserror", ] @@ -316,7 +310,7 @@ dependencies = [ "addr2line 0.24.2", "cfg-if 1.0.0", "libc", - "miniz_oxide 0.8.0", + "miniz_oxide", "object 0.36.5", "rustc-demangle", "windows-targets 0.52.6", @@ -489,7 +483,7 @@ dependencies = [ "derive-new", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -550,7 +544,7 @@ checksum = "f92da000e738bcf20ec873d63c3b46ed4e0afa10fb14ea3133874886c0fb591f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -636,9 +630,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.31" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "jobserver", "libc", @@ -716,7 +710,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ "termcolor", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -776,9 +770,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" dependencies = [ "libc", ] @@ -1022,9 +1016,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" +checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf" dependencies = [ "csv-core", "itoa", @@ -1043,9 +1037,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.129" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdc8cca144dce1c4981b5c9ab748761619979e515c3d53b5df385c677d1d007" +checksum = "23c042a0ba58aaff55299632834d1ea53ceff73d62373f62c9ae60890ad1b942" dependencies = [ "cc", "cxxbridge-flags", @@ -1055,46 +1049,46 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.129" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5764c3142ab44fcf857101d12c0ddf09c34499900557c764f5ad0597159d1fc" +checksum = "45dc1c88d0fdac57518a9b1f6c4f4fb2aca8f3c30c0d03d7d8518b47ca0bcea6" dependencies = [ "cc", "codespan-reporting", - "once_cell", "proc-macro2", "quote", "scratch", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] name = "cxx-gen" -version = "0.7.129" +version = "0.7.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efca6ed5e98eb15f076dde7604398cda57c6d3ede0e13b4185aa2d212e1e528e" +checksum = "1a3af2d30806a271901b8a325941592ce250629472ff589cdd8734ef06952222" dependencies = [ "codespan-reporting", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] name = "cxxbridge-flags" -version = "1.0.129" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d422aff542b4fa28c2ce8e5cc202d42dbf24702345c1fba3087b2d3f8a1b90ff" +checksum = "aa7ed7d30b289e2592cc55bc2ccd89803a63c913e008e6eb59f06cddf45bb52f" [[package]] name = "cxxbridge-macro" -version = "1.0.129" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1719100f31492cd6adeeab9a0f46cdbc846e615fdb66d7b398aa46ec7fdd06f" +checksum = "0b8c465d22de46b851c04630a5fc749a26005b263632ed2e0d9cc81518ead78d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "rustversion", + "syn 2.0.87", ] [[package]] @@ -1144,7 +1138,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", "unicode-xid", ] @@ -1201,6 +1195,17 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "either" version = "1.13.0" @@ -1268,15 +1273,14 @@ dependencies = [ [[package]] name = "exr" -version = "1.72.0" +version = "1.73.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "887d93f60543e9a9362ef8a21beedd0a833c5d9610e18c67abe15a5963dcb1a4" +checksum = "f83197f59927b46c04a183a619b7c29df34e63e63c7869320862268c0ef687e0" dependencies = [ "bit_field", - "flume", "half", "lebe", - "miniz_oxide 0.7.4", + "miniz_oxide", "rayon-core", "smallvec 1.13.2", "zune-inflate", @@ -1290,9 +1294,9 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fastrand" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "fdeflate" @@ -1331,21 +1335,12 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", - "miniz_oxide 0.8.0", -] - -[[package]] -name = "flume" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" -dependencies = [ - "spin", + "miniz_oxide", ] [[package]] @@ -1447,7 +1442,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -1589,7 +1584,7 @@ dependencies = [ "http", "indexmap 2.6.0", "slab", - "tokio 1.41.0", + "tokio 1.41.1", "tokio-util", "tracing", ] @@ -1634,9 +1629,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" [[package]] name = "heck" @@ -1644,6 +1639,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -1746,7 +1747,7 @@ dependencies = [ "itoa", "pin-project-lite", "socket2", - "tokio 1.41.0", + "tokio 1.41.1", "tower-service", "tracing", "want", @@ -1775,6 +1776,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec 1.13.2", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "id-arena" version = "2.2.1" @@ -1783,12 +1902,23 @@ checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec 1.13.2", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] @@ -1827,7 +1957,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.1", ] [[package]] @@ -1836,6 +1966,12 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" +[[package]] +name = "indoc" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" + [[package]] name = "inout" version = "0.1.3" @@ -2007,9 +2143,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "libc" -version = "0.2.161" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] name = "libloading" @@ -2058,6 +2194,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lock_api" version = "0.3.4" @@ -2150,7 +2292,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.38", + "rustix 0.38.40", ] [[package]] @@ -2180,6 +2322,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + [[package]] name = "miette" version = "5.10.0" @@ -2198,7 +2349,7 @@ dependencies = [ "terminal_size", "textwrap", "thiserror", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -2209,7 +2360,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -2224,15 +2375,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.8.0" @@ -2593,9 +2735,15 @@ dependencies = [ "crc32fast", "fdeflate", "flate2", - "miniz_oxide 0.8.0", + "miniz_oxide", ] +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + [[package]] name = "powerfmt" version = "0.2.0" @@ -2618,7 +2766,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -2662,9 +2810,9 @@ checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" [[package]] name = "psm" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205" +checksum = "200b9ff220857e53e184257720a14553b2f4aa02577d2ed9842d45d4b9654810" dependencies = [ "cc", ] @@ -2680,11 +2828,27 @@ dependencies = [ "unicase", ] +[[package]] +name = "pyo3" +version = "0.23.0-dev" +source = "git+https://github.com/tychedelia/pyo3?branch=td-rs#b4352f0f55ba950f8be1901f5284710bf754a95e" +dependencies = [ + "cfg-if 1.0.0", + "indoc 2.0.5", + "libc", + "memoffset 0.9.1", + "once_cell", + "portable-atomic", + "pyo3-build-config", + "pyo3-ffi", + "pyo3-macros", + "unindent", +] + [[package]] name = "pyo3-build-config" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc38c5feeb496c8321091edf3d63e9a6829eab4b863b4a6a65f26f3e9cc6b179" +version = "0.23.0-dev" +source = "git+https://github.com/tychedelia/pyo3?branch=td-rs#b4352f0f55ba950f8be1901f5284710bf754a95e" dependencies = [ "once_cell", "target-lexicon", @@ -2692,18 +2856,41 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94845622d88ae274d2729fcefc850e63d7a3ddff5e3ce11bd88486db9f1d357d" +version = "0.23.0-dev" +source = "git+https://github.com/tychedelia/pyo3?branch=td-rs#b4352f0f55ba950f8be1901f5284710bf754a95e" dependencies = [ "libc", "pyo3-build-config", ] +[[package]] +name = "pyo3-macros" +version = "0.23.0-dev" +source = "git+https://github.com/tychedelia/pyo3?branch=td-rs#b4352f0f55ba950f8be1901f5284710bf754a95e" +dependencies = [ + "proc-macro2", + "pyo3-macros-backend", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "pyo3-macros-backend" +version = "0.23.0-dev" +source = "git+https://github.com/tychedelia/pyo3?branch=td-rs#b4352f0f55ba950f8be1901f5284710bf754a95e" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "pyo3-build-config", + "quote", + "syn 2.0.87", +] + [[package]] name = "python-chop" version = "0.1.0" dependencies = [ + "pyo3", "pyo3-ffi", "td-rs-chop", "td-rs-derive", @@ -2828,7 +3015,7 @@ checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -2852,7 +3039,7 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr 2.7.4", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "regex-syntax 0.8.5", ] @@ -2867,9 +3054,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr 2.7.4", @@ -2915,7 +3102,7 @@ dependencies = [ "serde_urlencoded", "sync_wrapper", "system-configuration", - "tokio 1.41.0", + "tokio 1.41.1", "tower-service", "url", "wasm-bindgen", @@ -3045,9 +3232,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.38" +version = "0.38.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" +checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" dependencies = [ "bitflags 2.6.0", "errno", @@ -3058,9 +3245,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.16" +version = "0.23.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +checksum = "7f1a745511c54ba6d4465e8d5dfbd81b45791756de28d4981af70d6dca128f1e" dependencies = [ "log", "once_cell", @@ -3158,22 +3345,22 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -3375,11 +3562,11 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -3391,7 +3578,7 @@ dependencies = [ "reqwest", "td-rs-derive", "td-rs-top", - "tokio 1.41.0", + "tokio 1.41.1", "tracing", "tracing-subscriber 0.3.18", ] @@ -3443,9 +3630,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.85" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -3458,6 +3645,17 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -3536,11 +3734,12 @@ dependencies = [ "cxx", "derive_more", "miette", + "pyo3", "pyo3-ffi", "ref-cast", "rgb", "td-rs-autocxx-build", - "tokio 1.41.0", + "tokio 1.41.1", "tracing", "tracing-subscriber 0.3.18", ] @@ -3644,14 +3843,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if 1.0.0", "fastrand", "once_cell", - "rustix 0.38.38", + "rustix 0.38.40", "windows-sys 0.59.0", ] @@ -3682,27 +3881,27 @@ checksum = "b7b3e525a49ec206798b40326a44121291b530c963cfb01018f63e135bac543d" dependencies = [ "smawk", "unicode-linebreak", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] name = "thiserror" -version = "1.0.65" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.65" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -3754,6 +3953,16 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" version = "1.8.0" @@ -3795,9 +4004,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.41.0" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes 1.8.0", @@ -3976,7 +4185,7 @@ dependencies = [ "futures-core", "futures-sink", "pin-project-lite", - "tokio 1.41.0", + "tokio 1.41.1", ] [[package]] @@ -4062,7 +4271,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -4180,12 +4389,6 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" -[[package]] -name = "unicode-bidi" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" - [[package]] name = "unicode-ident" version = "1.0.13" @@ -4228,12 +4431,24 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "unindent" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" + [[package]] name = "untrusted" version = "0.9.0" @@ -4260,15 +4475,27 @@ dependencies = [ [[package]] name = "url" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", "idna", "percent-encoding", ] +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "uuid" version = "1.11.0" @@ -4335,7 +4562,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", "wasm-bindgen-shared", ] @@ -4369,7 +4596,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4392,12 +4619,12 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.219.1" +version = "0.220.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29cbbd772edcb8e7d524a82ee8cef8dd046fc14033796a754c3ad246d019fa54" +checksum = "ebf48234b389415b226a4daef6562933d38c7b28a8b8f64c5c4130dad1561ab7" dependencies = [ "leb128", - "wasmparser 0.219.1", + "wasmparser 0.220.0", ] [[package]] @@ -4423,9 +4650,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.219.1" +version = "0.220.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c771866898879073c53b565a6c7b49953795159836714ac56a5befb581227c5" +checksum = "e246c2772ce3ebc83f89a2d4487ac5794cad6c309b2071818a88c7db7c36d87b" dependencies = [ "bitflags 2.6.0", "indexmap 2.6.0", @@ -4690,28 +4917,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f114407efbd09e4ef67053b6ae54c16455a821ef2f6096597fcba83b7625e59c" dependencies = [ "anyhow", - "heck", + "heck 0.4.1", "wit-parser", ] [[package]] name = "wast" -version = "219.0.1" +version = "220.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f79a9d9df79986a68689a6b40bcc8d5d40d807487b235bebc2ac69a242b54a1" +checksum = "4e708c8de08751fd66e70961a32bae9d71901f14a70871e181cb8461a3bb3165" dependencies = [ "bumpalo", "leb128", "memchr 2.7.4", - "unicode-width", + "unicode-width 0.2.0", "wasm-encoder", ] [[package]] name = "wat" -version = "1.219.1" +version = "1.220.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bc3cf014fb336883a411cd662f987abf6a1d2a27f2f0008616a0070bbf6bd0d" +checksum = "de4f1d7d59614ba690541360102b995c4eb1b9ed373701d5102cc1a968b1c5a3" dependencies = [ "wast", ] @@ -4830,7 +5057,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -4841,7 +5068,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -5061,6 +5288,18 @@ dependencies = [ "windows-core 0.58.0", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -5078,6 +5317,30 @@ dependencies = [ "td-rs-xtask", ] +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -5096,7 +5359,28 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", ] [[package]] @@ -5105,6 +5389,28 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "zip" version = "0.6.6" diff --git a/justfile b/justfile index e4e48e7..19a59cb 100644 --- a/justfile +++ b/justfile @@ -1,3 +1,31 @@ +# Ensure that we are using powershell and not `sh` distributed by git on windows +set windows-powershell := true + +# The local TouchDesigner Python distribution +touchdesigner_python := if os() == "windows" { + "C:/Program Files/Derivative/TouchDesigner/bin/python.exe" +} else { + "/Applications/TouchDesigner.app/Contents/Frameworks/Python.framework/Versions/3.11/bin/python3.11" +} + + +[windows] +venv-init: + Start-Process -NoNewWindow -Wait -FilePath {{ touchdesigner_python }} -ArgumentList "-m venv venv" +[macos] +venv-init: + {{ touchdesigner_python }} -m venv venv + +[macos] +venv-activate: + source venv/bin/activate + ln -sf $PWD/lib/_stubs $PWD/venv/lib/python3.11/site-packages/_stubs +[windows] +venv-activate: + . venv/Scripts/Activate.ps1 + +venv: venv-init venv-activate + build PLUGIN: cargo xtask build {{PLUGIN}} diff --git a/plugins/chop/python/Cargo.toml b/plugins/chop/python/Cargo.toml index f6a958e..0f8db14 100644 --- a/plugins/chop/python/Cargo.toml +++ b/plugins/chop/python/Cargo.toml @@ -11,7 +11,8 @@ name = "python_chop" crate-type = ["staticlib"] [dependencies] -pyo3-ffi = "0.22.5" +pyo3 = { git = "https://github.com/tychedelia/pyo3", branch = "td-rs", features = ["abi3-py311"] } +pyo3-ffi = { git = "https://github.com/tychedelia/pyo3", branch = "td-rs", features = ["abi3-py311"] } td-rs-chop = { path = "../../../td-rs-chop", features = ["python"] } td-rs-derive = { path = "../../../td-rs-derive" } td-rs-derive-py = { path = "../../../td-rs-derive-py" } diff --git a/plugins/chop/python/src/lib.rs b/plugins/chop/python/src/lib.rs index d1728e5..1e0e8f1 100644 --- a/plugins/chop/python/src/lib.rs +++ b/plugins/chop/python/src/lib.rs @@ -1,8 +1,13 @@ #![feature(min_specialization)] +use pyo3::impl_::pyclass::{PyClassImpl, PyMethods}; +use pyo3::prelude::PyAnyMethods; +use pyo3::{pyclass, pymethods, Bound, PyAny, PyResult}; +use std::pin::Pin; +use td_rs_chop::cxx::AsPlugin; use td_rs_chop::*; use td_rs_derive::*; -use td_rs_derive_py::*; +use td_rs_derive_py::PyOp; #[derive(Param, Default, Debug)] enum PythonChopShape { @@ -24,21 +29,34 @@ struct PythonChopParams { reset: Pulse, } -#[derive(PyOp, Debug)] +#[derive(PyOp)] +#[pyclass] pub struct PythonChop { - #[py(doc = "Get or Set the speed modulation.", auto_cook)] + #[pyo3(get, set)] speed: f32, - #[py(get, doc = "Get executed count.")] + #[pyo3(get)] execute_count: u32, offset: f32, params: PythonChopParams, - pub info: NodeInfo, +} + +#[pymethods] +impl PythonChop { + pub fn hello_world(&self, a: i32, b: i32, absTime: Bound<'_, PyAny>) -> PyResult { + let field_value = absTime.getattr("frame")?; + let frames: i32 = field_value.extract()?; + println!( + "Hello, world! execute={} frames={}", + self.execute_count, frames + ); + Ok(a + b) + } } impl OpNew for PythonChop { fn new(info: NodeInfo) -> Self { Self { - info, + // info, speed: 1.0, execute_count: 0, offset: 0.0, @@ -47,25 +65,6 @@ impl OpNew for PythonChop { } } -#[py_op_methods] -impl PythonChop { - fn reset_filter(&mut self) { - self.offset = 0.0; - } - - #[py_meth] - pub unsafe fn reset( - &mut self, - _args: *mut *mut pyo3_ffi::PyObject, - _nargs: usize, - ) -> *mut pyo3_ffi::PyObject { - self.reset_filter(); - let none = pyo3_ffi::Py_None(); - pyo3_ffi::Py_INCREF(none); - none - } -} - impl OpInfo for PythonChop { const OPERATOR_TYPE: &'static str = "Customsignalpython"; const OPERATOR_LABEL: &'static str = "Custom Signal Python"; @@ -97,9 +96,7 @@ impl Op for PythonChop { } fn pulse_pressed(&mut self, name: &str) { - if name == "Reset" { - self.reset_filter(); - } + if name == "Reset" {} } } @@ -132,25 +129,26 @@ impl Chop for PythonChop { // Apply Python class modifications self.params.speed *= self.speed; - let arg_tuple = self.info.context().create_arguments_tuple(1); - unsafe { - pyo3_ffi::PyTuple_SET_ITEM( - arg_tuple, - 1, - pyo3_ffi::PyFloat_FromDouble(self.params.speed as std::ffi::c_double), - ); - let res = self.info.context().call_python_callback( - "getSpeedAdjust", - arg_tuple, - std::ptr::null_mut(), - ); - if !res.is_null() { - if pyo3_ffi::PyFloat_Check(res) != 0 { - self.params.speed = pyo3_ffi::PyFloat_AsDouble(res) as f32; - } - pyo3_ffi::Py_DECREF(res); - } - } + // let arg_tuple = self.info.context().create_arguments_tuple(1); + // + // unsafe { + // pyo3_ffi::PyTuple_SET_ITEM( + // arg_tuple, + // 1, + // pyo3_ffi::PyFloat_FromDouble(self.params.speed as std::ffi::c_double), + // ); + // let res = self.info.context().call_python_callback( + // "getSpeedAdjust", + // arg_tuple, + // std::ptr::null_mut(), + // ); + // if !res.is_null() { + // if pyo3_ffi::PyFloat_Check(res) != 0 { + // self.params.speed = pyo3_ffi::PyFloat_AsDouble(res) as f32; + // } + // pyo3_ffi::Py_DECREF(res); + // } + // } let phase = 2.0 * std::f32::consts::PI / output.num_channels() as f32; let num_samples = output.num_samples(); diff --git a/td-rs-base/Cargo.toml b/td-rs-base/Cargo.toml index a5e37af..a467d46 100644 --- a/td-rs-base/Cargo.toml +++ b/td-rs-base/Cargo.toml @@ -14,7 +14,8 @@ rgb = "0.8.36" ref-cast = "1.0" auto_ops = "0.3.0" derive_more = { version = "1", features = ["full"] } -pyo3-ffi = { version = "0.22.5", optional = true} +pyo3 = { git = "https://github.com/tychedelia/pyo3", branch = "td-rs", features = ["abi3-py311"], optional = true } +pyo3-ffi = { git = "https://github.com/tychedelia/pyo3", branch = "td-rs", features = ["abi3-py311"], optional = true } tracing-base = { package = "tracing", version = "0.1", optional = true} tracing-subscriber = { version = "0.3", optional = true } tokio-core = { package = "tokio", version = "1", optional = true } @@ -22,7 +23,7 @@ tokio-core = { package = "tokio", version = "1", optional = true } [build-dependencies] td-rs-autocxx-build = { path = "../td-rs-autocxx-build" } autocxx-build = { git = "https://github.com/tychedelia/autocxx.git" } -miette = { version="5", features = [ "fancy" ] } +miette = { version = "5", features = [ "fancy" ] } [features] default = [] diff --git a/td-rs-base/src/RustPy.h b/td-rs-base/src/RustPy.h index 7562798..172f116 100644 --- a/td-rs-base/src/RustPy.h +++ b/td-rs-base/src/RustPy.h @@ -16,26 +16,18 @@ TD::PY_Context* getPyContext(TD::PY_Struct *pyStruct) { void setPyInfo(TD::OP_CustomOPInfo &opInfo, void *pymethods, size_t size, void *pygetsets, size_t getsetsize) { if (size == 0) { - return; + std::cout << "No methods" << std::endl; + opInfo.pythonMethods = nullptr; + } else { + opInfo.pythonMethods = static_cast(pymethods); } - PyMethodDef *pm = (PyMethodDef*) pymethods; - std::vector *methods = new std::vector(); - for (size_t i = 0; i < size; i++) { - methods->push_back(pm[i]); - } - PyMethodDef *arr = methods->data(); - opInfo.pythonMethods = arr; if (getsetsize == 0) { - return; - } - PyGetSetDef *pgs = (PyGetSetDef*) pygetsets; - std::vector *getsets = new std::vector(); - for (size_t i = 0; i < getsetsize; i++) { - getsets->push_back(pgs[i]); + std::cout << "No getsets" << std::endl; + opInfo.pythonGetSets = nullptr; + } else { + opInfo.pythonGetSets = static_cast(pygetsets); } - PyGetSetDef *arr2 = getsets->data(); - opInfo.pythonGetSets = arr2; } #else diff --git a/td-rs-base/src/py.rs b/td-rs-base/src/py.rs index c1fcc0b..dc7f66b 100644 --- a/td-rs-base/src/py.rs +++ b/td-rs-base/src/py.rs @@ -1,4 +1,9 @@ use pyo3_ffi::PyGetSetDef; +use crate::Op; + +pub trait PyOp : Op { + +} pub trait PyGetSets { fn get_get_sets() -> &'static [pyo3_ffi::PyGetSetDef]; @@ -27,6 +32,7 @@ pub(crate) unsafe fn py_op_info( let m_len = methods.len(); let m_arr = methods.as_ptr() as *mut autocxx::prelude::c_void; let get_sets = T::get_get_sets(); + println!("get_sets: {:?}", get_sets); let gs_len = get_sets.len(); let gs_arr = get_sets.as_ptr() as *mut autocxx::prelude::c_void; crate::cxx::setPyInfo(op_info, m_arr, m_len, gs_arr, gs_len); @@ -259,10 +265,11 @@ impl CheckPyObj for bool { impl FromPyObj for String { unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - let s = pyo3_ffi::PyUnicode_AsUTF8(obj); - let s = std::ffi::CStr::from_ptr(s); - let s = s.to_str().unwrap(); - s.to_owned() + // let s = pyo3_ffi::PyUnicode_AsUTF8(obj); + // let s = std::ffi::CStr::from_ptr(s); + // let s = s.to_str().unwrap(); + // s.to_owned() + todo!() } } @@ -281,10 +288,11 @@ impl CheckPyObj for String { impl FromPyObj for &str { unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - let s = pyo3_ffi::PyUnicode_AsUTF8(obj); - let s = std::ffi::CStr::from_ptr(s); - let s = s.to_str().unwrap(); - s + // let s = pyo3_ffi::PyUnicode_AsUTF8(obj); + // let s = std::ffi::CStr::from_ptr(s); + // let s = s.to_str().unwrap(); + // s + todo!() } } diff --git a/td-rs-derive-py/src/lib.rs b/td-rs-derive-py/src/lib.rs index 4511264..2132dfa 100644 --- a/td-rs-derive-py/src/lib.rs +++ b/td-rs-derive-py/src/lib.rs @@ -91,183 +91,177 @@ fn impl_py_op(input: &DeriveInput) -> TokenStream { let gen = match &input.data { syn::Data::Struct(data_struct) => match &data_struct.fields { syn::Fields::Named(fields_named) => { - let generated_get_sets: Vec<_> = fields_named.named.iter().filter_map(|field| { - // Check for our attribute - if let Some(attr) = field.attrs.iter().find(|attr| attr.path.is_ident("py")) { - let args = if let Ok(meta) = attr.parse_meta() { - if let syn::Meta::List(meta_list) = meta { - parse_attribute_args(meta_list.nested.into_iter().collect()).expect("Failed to parse attribute args") - } else { - PyOpArgs::default() + quote! { + impl<'a, 'py> pyo3::impl_::extract_argument::ExtractPyClassRef<'a, 'py> for #struct_name { + fn extract_ref( + obj: &'a pyo3::Bound<'py, pyo3::PyAny>, + holder: &'a mut Option>, + ) -> pyo3::PyResult<&'a Self> { + unsafe { + let me = obj.as_ptr(); + let py_struct = me as *mut cxx::PY_Struct; + let info = cxx::PY_GetInfo { + autoCook: true, + reserved: [0; 50], + }; + // SAFETY: + // Pinning the context is safe because the context is not moved or dropped as it is + // derived from our C++ operator instance which is not moved or dropped during the + // lifetime of the Python object. + let mut ctx = Pin::new_unchecked(&mut *cxx::getPyContext(py_struct)); + // Look up our operator instance. + let me = ctx.getNodeInstance(&info, std::ptr::null_mut()); + if me.is_null() { + return Err(pyo3::exceptions::PyTypeError::new_err("operator is null")); + } + let py_op = { + let me = cxx::plugin_cast(me); + let me = me.as_plugin().inner(); + &*(me as *const #struct_name) + }; + + Ok(py_op) } - } else { - PyOpArgs::default() - }; - let field_name = field.ident.as_ref().expect("Field must have a name").clone(); - let field_type = &field.ty; - let getter_name = format_ident!("get_{}", field_name); - let setter_name = format_ident!("set_{}", field_name); - let auto_cook = args.auto_cook; - - let get_fn = if args.get { - Some(quote! { - pub unsafe extern "C" fn #getter_name( - _self: *mut pyo3_ffi::PyObject, - closure: *mut std::ffi::c_void - ) -> *mut pyo3_ffi::PyObject { - use cxx::AsPlugin; - let py_struct = _self as *mut cxx::PY_Struct; - let info = cxx::PY_GetInfo { - autoCook: #auto_cook, - reserved: [0; 50] - }; + } + } - let mut ctx = std::pin::Pin::new_unchecked(&mut*cxx::getPyContext(py_struct));; - let me = ctx.getNodeInstance(&info, std::ptr::null_mut()); - if me.is_null() { - return std::ptr::null_mut(); - } - let py_chop = { - let me = cxx::plugin_cast(me); - let me = me.as_plugin().inner(); - &mut *(me as *mut #struct_name) - }; - py::ToPyObj::to_py_obj(py_chop.#field_name) + impl<'a, 'py> pyo3::impl_::extract_argument::ExtractPyClassRefMut<'a, 'py> for #struct_name { + fn extract_mut( + obj: &'a pyo3::Bound<'py, pyo3::PyAny>, + holder: &'a mut Option>, + ) -> PyResult<&'a mut Self> { + unsafe { + let me = obj.as_ptr(); + let py_struct = me as *mut cxx::PY_Struct; + let info = cxx::PY_GetInfo { + autoCook: true, + reserved: [0; 50], + }; + // SAFETY: + // Pinning the context is safe because the context is not moved or dropped as it is + // derived from our C++ operator instance which is not moved or dropped during the + // lifetime of the Python object. + let py_ctx = cxx::getPyContext(py_struct); + // Mark the node as dirty so that it will be cooked on the next frame. + Pin::new_unchecked(&mut *py_ctx).makeNodeDirty(std::ptr::null_mut()); + // Look up our operator instance. + let me = Pin::new_unchecked(&mut *py_ctx).getNodeInstance(&info, std::ptr::null_mut()); + if me.is_null() { + return Err(pyo3::exceptions::PyTypeError::new_err("operator is null")); } - }) - } else { - None - }; - - let set_fn = if args.set { - Some(quote! { - pub unsafe extern "C" fn #setter_name( - _self: *mut pyo3_ffi::PyObject, - value: *mut pyo3_ffi::PyObject, - closure: *mut std::ffi::c_void - ) -> i32 { - use cxx::AsPlugin; - if !<#field_type as CheckPyObj>::check_py_obj(value) { - pyo3_ffi::PyErr_SetString( - pyo3_ffi::PyExc_TypeError, - "could not check argument\0" - .as_ptr() - .cast::(), - ); - return -1; - } + // SAFETY: + // We have a valid operator instance pointer + let py_op = { + let me = cxx::plugin_cast(me); + let me = me.as_plugin_mut().innerMut(); + &mut *(me as *mut #struct_name) + }; + Ok(py_op) + } + } + } - let value = FromPyObj::from_py_obj(value); + impl PyGetSets for #struct_name { + fn get_get_sets() -> &'static [pyo3_ffi::PyGetSetDef] { + let clazz = pyo3::impl_::pyclass::PyClassImplCollector::<#struct_name>::new(); + let methods = clazz.py_methods(); + let mut getset_builders = std::collections::HashMap::<&std::ffi::CStr, pyo3::pyclass::create_type_object::GetSetDefBuilder>::new(); + for method in methods.methods { + println!("method"); + let method_def = match method { + pyo3::impl_::pyclass::MaybeRuntimePyMethodDef::Runtime(m) => &m(), + pyo3::impl_::pyclass::MaybeRuntimePyMethodDef::Static(m) => m, + }; + + match method_def { + pyo3::PyMethodDefType::Getter(getter) => { + getset_builders + .entry(getter.name) + .or_default() + .add_getter(getter) + } + pyo3::PyMethodDefType::Setter(setter) => { + getset_builders + .entry(setter.name) + .or_default() + .add_setter(setter) + } + _ => {} + } + } - let py_struct = _self as *mut cxx::PY_Struct; - let info = cxx::PY_GetInfo { - autoCook: #auto_cook, - reserved: [0; 50] + let items = #struct_name::items_iter(); + for item in items { + for method in item.methods { + println!("method"); + let method_def = match method { + pyo3::impl_::pyclass::MaybeRuntimePyMethodDef::Runtime(m) => &m(), + pyo3::impl_::pyclass::MaybeRuntimePyMethodDef::Static(m) => m, }; - let mut ctx = std::pin::Pin::new_unchecked(&mut*cxx::getPyContext(py_struct));; - let me = ctx.getNodeInstance(&info, std::ptr::null_mut()); - if me.is_null() { - pyo3_ffi::PyErr_SetString( - pyo3_ffi::PyExc_TypeError, - "operator is null\0" - .as_ptr() - .cast::(), - ); - return -1; + + match method_def { + pyo3::PyMethodDefType::Getter(getter) => { + getset_builders + .entry(getter.name) + .or_default() + .add_getter(getter) + } + pyo3::PyMethodDefType::Setter(setter) => { + getset_builders + .entry(setter.name) + .or_default() + .add_setter(setter) + } + _ => {} } - let py_chop = { - let me = cxx::plugin_cast(me); - let me = me.as_plugin_mut().innerMut(); - &mut *(me as *mut #struct_name) - }; - - py_chop.#field_name = value; - let mut ctx = std::pin::Pin::new_unchecked(&mut*cxx::getPyContext(py_struct));; - ctx.makeNodeDirty(std::ptr::null_mut()); - return 0; } - }) - } else { - None - }; - - - let get = if args.get { - quote! { - Some(#getter_name) - } - } else { - quote! { - None - } - }; - let set = if args.set { - quote! { - Some(#setter_name) - } - } else { - quote! { - None } - }; - let doc = if let Some(doc) = &args.doc { - quote! { - concat!(stringify!(#doc), '\0').as_ptr().cast::() - } - } else { - quote! { - std::ptr::null_mut() - } - }; - let get_set_def = quote! { - pyo3_ffi::PyGetSetDef { - name: concat!(stringify!(#field_name), '\0').as_ptr().cast::(), - get: #get, - set: #set, - doc: #doc, - closure: std::ptr::null_mut(), - }, - }; + let mut getset_destructors = Vec::with_capacity(getset_builders.len()); - Some(PyGetSet { - py_get_set_def: get_set_def, - get_body: get_fn, - set_body: set_fn, - }) - } else { - None - } - }).collect(); + let property_defs: Vec = getset_builders + .iter() + .map(|(name, builder)| { + let (def, destructor) = builder.as_get_set_def(name); + getset_destructors.push(destructor); + def + }) + .collect(); - let defs: Vec<_> = generated_get_sets - .iter() - .map(|gf| &gf.py_get_set_def) - .collect(); - let getters: Vec<_> = generated_get_sets.iter().map(|gf| &gf.get_body).collect(); - let setters: Vec<_> = generated_get_sets.iter().map(|gf| &gf.set_body).collect(); - let size = generated_get_sets.len() + 1; - quote! { - pub const GETSETS: [pyo3_ffi::PyGetSetDef; #size] = [ - #( #defs )* - pyo3_ffi::PyGetSetDef { - name: std::ptr::null_mut(), - get: None, - set: None, - doc: std::ptr::null_mut(), - closure: std::ptr::null_mut(), + // We just have to leak these to keep them alive + // TODO: right now we are leaking the memory, we should free it when the plugin is unloaded + // but unless you're loading and unloading the plugin a lot, it's not a big deal + getset_destructors.leak(); + property_defs.leak() } - ]; + } - impl PyGetSets for #struct_name { - fn get_get_sets() -> &'static [pyo3_ffi::PyGetSetDef] { - &GETSETS + impl td_rs_chop::PyMethods for #struct_name { + fn get_methods() -> &'static [pyo3_ffi::PyMethodDef] { + let clazz = pyo3::impl_::pyclass::PyClassImplCollector::<#struct_name>::new(); + let methods = clazz.py_methods(); + let mut method_defs = Vec::new(); + for method in methods.methods { + let method_def = match method { + pyo3::impl_::pyclass::MaybeRuntimePyMethodDef::Runtime(m) => &m(), + pyo3::impl_::pyclass::MaybeRuntimePyMethodDef::Static(m) => m, + }; + + match method_def { + pyo3::PyMethodDefType::Method(m) => { + method_defs.push(m.as_method_def()); + } + _ => {} + } + } + + method_defs.leak() } } - #( #getters )* - #( #setters )* + + impl PyOp for #struct_name {} } } _ => panic!("Only named fields are supported"), @@ -330,12 +324,12 @@ pub fn py_op_methods(_attr: TokenStream, item: TokenStream) -> TokenStream { ); return std::ptr::null_mut(); } - let py_chop = { + let py_op = { let me = cxx::plugin_cast(me); let me = me.as_plugin_mut().innerMut(); &mut *(me as *mut #struct_name) }; - let res = py_chop.#fn_name(args, nargs as usize); + let res = py_op.#fn_name(args, nargs as usize); let mut ctx = std::pin::Pin::new_unchecked(&mut*cxx::getPyContext(py_struct));; ctx.makeNodeDirty(std::ptr::null_mut()); res