From f2d98af532864e0f7e515929bb5fa5ea1278dc8e Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sat, 25 May 2024 11:16:37 +0200 Subject: [PATCH] rename to servicepoint, new dir structure, WIP build.rs --- .gitignore | 1 + Cargo.lock | 339 ++++++++++++++++-- Cargo.toml | 8 +- README.md | 26 +- .../servicepoint}/Cargo.lock | 0 .../servicepoint}/Cargo.toml | 8 +- .../servicepoint}/src/bit_vec.rs | 2 +- .../servicepoint}/src/byte_grid.rs | 0 .../servicepoint}/src/c_slice.rs | 0 .../servicepoint}/src/command.rs | 0 .../servicepoint}/src/command_code.rs | 0 .../servicepoint}/src/compression.rs | 0 .../servicepoint}/src/compression_code.rs | 0 .../servicepoint}/src/connection.rs | 8 +- .../servicepoint}/src/data_ref.rs | 0 .../servicepoint}/src/grid.rs | 2 +- .../servicepoint}/src/lib.rs | 0 .../servicepoint}/src/packet.rs | 0 .../servicepoint}/src/pixel_grid.rs | 0 crates/servicepoint_binding_c/Cargo.toml | 13 + crates/servicepoint_binding_c/build.rs | 13 + .../servicepoint_binding_c}/cbindgen.toml | 3 + .../servicepoint_binding_c/servicepoint.h | 0 crates/servicepoint_binding_c/src/lib.rs | 0 .../servicepoint_binding_cs}/Cargo.lock | 0 .../servicepoint_binding_cs}/Cargo.toml | 5 +- .../servicepoint_binding_cs/ServicePoint.sln | 2 +- crates/servicepoint_binding_cs/build.rs | 19 + .../src/BindGen/ServicePoint.g.cs | 286 +++++++++++++++ .../src/BindGen/ServicePoint2.g.cs | 4 +- .../servicepoint_binding_cs}/src/BitVec.cs | 6 +- .../servicepoint_binding_cs}/src/ByteGrid.cs | 6 +- .../servicepoint_binding_cs}/src/Command.cs | 6 +- .../src/Connection.cs | 6 +- .../servicepoint_binding_cs}/src/Constants.cs | 2 +- .../src/GlobalUsings.cs | 0 .../servicepoint_binding_cs}/src/Packet.cs | 6 +- .../servicepoint_binding_cs}/src/PixelGrid.cs | 6 +- .../src/ServicePoint.csproj | 20 +- .../src/ServicePointExtensions.cs | 4 +- .../src/SpNativeInstance.cs | 8 +- .../servicepoint_binding_cs}/src/lib.rs | 0 examples/announce/Cargo.toml | 2 +- examples/announce/src/main.rs | 2 +- examples/game_of_life/Cargo.toml | 2 +- examples/game_of_life/src/main.rs | 2 +- examples/lang_c/Cargo.toml | 13 + examples/lang_c/Makefile | 6 +- examples/lang_c/build.rs | 8 + examples/lang_c/src/lib.rs | 0 examples/lang_c/{ => src}/main.c | 2 +- examples/lang_cs/Program.cs | 4 +- examples/lang_cs/lang_cs.csproj | 2 +- examples/moving_line/Cargo.toml | 4 +- examples/moving_line/src/main.rs | 2 +- examples/random_brightness/Cargo.toml | 2 +- examples/random_brightness/src/main.rs | 4 +- examples/wiping_clear/Cargo.toml | 2 +- examples/wiping_clear/src/main.rs | 2 +- servicepoint2-binding-c/generate.sh | 4 - servicepoint2-binding-cs/build.rs | 19 - 61 files changed, 751 insertions(+), 140 deletions(-) rename {servicepoint2 => crates/servicepoint}/Cargo.lock (100%) rename {servicepoint2 => crates/servicepoint}/Cargo.toml (81%) rename {servicepoint2 => crates/servicepoint}/src/bit_vec.rs (99%) rename {servicepoint2 => crates/servicepoint}/src/byte_grid.rs (100%) rename {servicepoint2 => crates/servicepoint}/src/c_slice.rs (100%) rename {servicepoint2 => crates/servicepoint}/src/command.rs (100%) rename {servicepoint2 => crates/servicepoint}/src/command_code.rs (100%) rename {servicepoint2 => crates/servicepoint}/src/compression.rs (100%) rename {servicepoint2 => crates/servicepoint}/src/compression_code.rs (100%) rename {servicepoint2 => crates/servicepoint}/src/connection.rs (90%) rename {servicepoint2 => crates/servicepoint}/src/data_ref.rs (100%) rename {servicepoint2 => crates/servicepoint}/src/grid.rs (97%) rename {servicepoint2 => crates/servicepoint}/src/lib.rs (100%) rename {servicepoint2 => crates/servicepoint}/src/packet.rs (100%) rename {servicepoint2 => crates/servicepoint}/src/pixel_grid.rs (100%) create mode 100644 crates/servicepoint_binding_c/Cargo.toml create mode 100644 crates/servicepoint_binding_c/build.rs rename {servicepoint2-binding-c => crates/servicepoint_binding_c}/cbindgen.toml (95%) rename servicepoint2-binding-c/servicepoint2.h => crates/servicepoint_binding_c/servicepoint.h (100%) create mode 100644 crates/servicepoint_binding_c/src/lib.rs rename {servicepoint2-binding-cs => crates/servicepoint_binding_cs}/Cargo.lock (100%) rename {servicepoint2-binding-cs => crates/servicepoint_binding_cs}/Cargo.toml (53%) rename servicepoint2-binding-cs/ServicePoint2.sln => crates/servicepoint_binding_cs/ServicePoint.sln (94%) create mode 100644 crates/servicepoint_binding_cs/build.rs create mode 100644 crates/servicepoint_binding_cs/src/BindGen/ServicePoint.g.cs rename {servicepoint2-binding-cs => crates/servicepoint_binding_cs}/src/BindGen/ServicePoint2.g.cs (99%) rename {servicepoint2-binding-cs => crates/servicepoint_binding_cs}/src/BitVec.cs (93%) rename {servicepoint2-binding-cs => crates/servicepoint_binding_cs}/src/ByteGrid.cs (95%) rename {servicepoint2-binding-cs => crates/servicepoint_binding_cs}/src/Command.cs (96%) rename {servicepoint2-binding-cs => crates/servicepoint_binding_cs}/src/Connection.cs (84%) rename {servicepoint2-binding-cs => crates/servicepoint_binding_cs}/src/Constants.cs (95%) rename {servicepoint2-binding-cs => crates/servicepoint_binding_cs}/src/GlobalUsings.cs (100%) rename {servicepoint2-binding-cs => crates/servicepoint_binding_cs}/src/Packet.cs (88%) rename {servicepoint2-binding-cs => crates/servicepoint_binding_cs}/src/PixelGrid.cs (94%) rename servicepoint2-binding-cs/src/ServicePoint2.csproj => crates/servicepoint_binding_cs/src/ServicePoint.csproj (78%) rename servicepoint2-binding-cs/src/ServicePoint2Extensions.cs => crates/servicepoint_binding_cs/src/ServicePointExtensions.cs (82%) rename servicepoint2-binding-cs/src/Sp2NativeInstance.cs => crates/servicepoint_binding_cs/src/SpNativeInstance.cs (85%) rename {servicepoint2-binding-cs => crates/servicepoint_binding_cs}/src/lib.rs (100%) create mode 100644 examples/lang_c/Cargo.toml create mode 100644 examples/lang_c/build.rs create mode 100644 examples/lang_c/src/lib.rs rename examples/lang_c/{ => src}/main.c (95%) delete mode 100755 servicepoint2-binding-c/generate.sh delete mode 100644 servicepoint2-binding-cs/build.rs diff --git a/.gitignore b/.gitignore index bec1c54..39156e2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ target out bin obj +.direnv diff --git a/Cargo.lock b/Cargo.lock index f8b8d84..7eed9c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,9 +21,9 @@ dependencies = [ name = "announce" version = "0.1.0" dependencies = [ - "clap", + "clap 4.5.4", "env_logger", - "servicepoint2", + "servicepoint", ] [[package]] @@ -75,6 +75,35 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + [[package]] name = "bzip2" version = "0.4.4" @@ -97,10 +126,29 @@ dependencies = [ ] [[package]] -name = "cc" -version = "1.0.97" +name = "cbindgen" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" +checksum = "da6bc11b07529f16944307272d5bd9b22530bc7d05751717c9d416586cedab49" +dependencies = [ + "clap 3.2.25", + "heck 0.4.1", + "indexmap", + "log", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn 1.0.109", + "tempfile", + "toml", +] + +[[package]] +name = "cc" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" dependencies = [ "jobserver", "libc", @@ -113,6 +161,21 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "clap" +version = "3.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +dependencies = [ + "atty", + "bitflags 1.3.2", + "clap_lex 0.2.4", + "indexmap", + "strsim 0.10.0", + "termcolor", + "textwrap", +] + [[package]] name = "clap" version = "4.5.4" @@ -131,8 +194,8 @@ checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstream", "anstyle", - "clap_lex", - "strsim", + "clap_lex 0.7.0", + "strsim 0.11.1", ] [[package]] @@ -141,10 +204,19 @@ version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", ] [[package]] @@ -161,9 +233,9 @@ checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -201,6 +273,22 @@ dependencies = [ "log", ] +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + [[package]] name = "flate2" version = "1.0.30" @@ -215,10 +303,10 @@ dependencies = [ name = "game_of_life" version = "0.1.0" dependencies = [ - "clap", + "clap 4.5.4", "env_logger", "rand", - "servicepoint2", + "servicepoint", ] [[package]] @@ -232,24 +320,61 @@ dependencies = [ "wasi", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "heck" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + [[package]] name = "humantime" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + [[package]] name = "jobserver" version = "0.1.31" @@ -259,11 +384,25 @@ dependencies = [ "libc", ] +[[package]] +name = "lang_c" +version = "0.1.0" +dependencies = [ + "cc", + "servicepoint", +] + [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" @@ -279,9 +418,9 @@ checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" dependencies = [ "adler", ] @@ -290,9 +429,9 @@ dependencies = [ name = "moving_line" version = "0.1.0" dependencies = [ - "clap", + "clap 4.5.4", "env_logger", - "servicepoint2", + "servicepoint", ] [[package]] @@ -301,6 +440,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "os_str_bytes" +version = "6.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" + [[package]] name = "pkg-config" version = "0.3.30" @@ -315,9 +460,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" dependencies = [ "unicode-ident", ] @@ -365,10 +510,10 @@ dependencies = [ name = "random_brightness" version = "0.1.0" dependencies = [ - "clap", + "clap 4.5.4", "env_logger", "rand", - "servicepoint2", + "servicepoint", ] [[package]] @@ -411,15 +556,57 @@ dependencies = [ ] [[package]] -name = "servicepoint-binding-cs" -version = "0.4.2" +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "csbindgen", - "servicepoint2", + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", ] [[package]] -name = "servicepoint2" +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "serde" +version = "1.0.202" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.202" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.65", +] + +[[package]] +name = "serde_json" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "servicepoint" version = "0.4.2" dependencies = [ "bzip2", @@ -429,6 +616,27 @@ dependencies = [ "zstd", ] +[[package]] +name = "servicepoint_binding_c" +version = "0.4.2" +dependencies = [ + "cbindgen", +] + +[[package]] +name = "servicepoint_binding_cs" +version = "0.4.2" +dependencies = [ + "csbindgen", + "servicepoint", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "strsim" version = "0.11.1" @@ -448,15 +656,51 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.63" +version = "2.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" +checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + [[package]] name = "unicode-ident" version = "1.0.12" @@ -481,6 +725,37 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "windows-sys" version = "0.52.0" @@ -558,9 +833,9 @@ checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" name = "wiping_clear" version = "0.1.0" dependencies = [ - "clap", + "clap 4.5.4", "env_logger", - "servicepoint2", + "servicepoint", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f5eaca7..9159b88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,13 @@ [workspace] resolver = "2" members = [ - "servicepoint2", - "servicepoint2-binding-cs", + "crates/servicepoint", + "crates/servicepoint_binding_c", + "crates/servicepoint_binding_cs", "examples/announce", "examples/game_of_life", "examples/moving_line", "examples/wiping_clear", - "examples/random_brightness" + "examples/random_brightness", + "examples/lang_c" ] diff --git a/README.md b/README.md index fff4a4d..b422c20 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# servicepoint2 +# servicepoint -[![crates.io](https://img.shields.io/crates/v/servicepoint2.svg)](https://crates.io/crates/servicepoint2) -[![Crates.io Total Downloads](https://img.shields.io/crates/d/servicepoint2)](https://crates.io/crates/servicepoint2) -[![docs.rs](https://img.shields.io/docsrs/servicepoint2)](https://docs.rs/servicepoint2/latest/servicepoint2/) -[![GPLv3 licensed](https://img.shields.io/crates/l/servicepoint2)](./LICENSE) +[![crates.io](https://img.shields.io/crates/v/servicepoint.svg)](https://crates.io/crates/servicepoint) +[![Crates.io Total Downloads](https://img.shields.io/crates/d/servicepoint)](https://crates.io/crates/servicepoint) +[![docs.rs](https://img.shields.io/docsrs/servicepoint)](https://docs.rs/servicepoint/latest/servicepoint/) +[![GPLv3 licensed](https://img.shields.io/crates/l/servicepoint)](./LICENSE) In [CCCB](https://berlin.ccc.de/), there is a big pixel matrix hanging on the wall. It is called "Service Point Display" or "Airport Display". @@ -23,17 +23,17 @@ This is where the library works the best. Any API usage accepted by the compiler in a safe context is either safe or buggy (issues welcome) ```bash -cargo add servicepoint2 +cargo add servicepoint ``` ```rust fn main() { // establish connection - let connection = servicepoint2::Connection::open("172.23.42.29:2342") + let connection = servicepoint::Connection::open("172.23.42.29:2342") .expect("connection failed"); // clear screen content - connection.send(servicepoint2::Command::Clear.into()) + connection.send(servicepoint::Command::Clear.into()) .expect("send failed"); } ``` @@ -54,7 +54,7 @@ The lowest common denominator. Things to keep in mind: ```c++ #include -#include "servicepoint2.h" +#include "servicepoint.h" int main(void) { sp2_Connection *connection = sp2_connection_open("localhost:2342"); @@ -87,7 +87,7 @@ Uses C bindings internally to provide a similar API to rust. Things to keep in m - Reading and writing to instances concurrently is not safe. Only reading concurrently is safe. ```csharp -using ServicePoint2; +using ServicePoint; // using statement calls Dispose() on scope exit, which frees unmanaged instances using var connection = Connection.Open("127.0.0.1:2342"); @@ -116,7 +116,7 @@ git submodule add https://github.com/kaesaecracker/servicepoint.git git commit -m "add servicepoint submodule" ``` -You can now reference `servicepoint2-bindings-cs/src/ServicePoint2.csproj` in your project. +You can now reference `servicepoint-bindings-cs/src/ServicePoint.csproj` in your project. The rust library will automatically be built. Please provide more information in the form of an issue if you need the build to copy a different library file for your platform. @@ -136,7 +136,7 @@ If you do not need compression/decompression support you can disable those featu In the likely case you only need one of them, you can include that one specifically. ```toml -[dependencies.servicepoint2] +[dependencies.servicepoint] git = "https://github.com/kaesaecracker/servicepoint.git" default-features = false features = ["compression-bz"] @@ -154,7 +154,7 @@ To add yourself to the list, open a pull request. ## Where is servicepoint1? -This library is a spiritual mix of a not-yet-working rust library called `servicepoint` and a bunch of working but also unfinished C# code. Because most of the API concept and a bunch of code is taken from the rust library, the result is called `servicepoint2`. +This library is a spiritual mix of a not-yet-working rust library called `servicepoint` and a bunch of working but also unfinished C# code. Because most of the API concept and a bunch of code is taken from the rust library, the result is called `servicepoint`. ## Contributing diff --git a/servicepoint2/Cargo.lock b/crates/servicepoint/Cargo.lock similarity index 100% rename from servicepoint2/Cargo.lock rename to crates/servicepoint/Cargo.lock diff --git a/servicepoint2/Cargo.toml b/crates/servicepoint/Cargo.toml similarity index 81% rename from servicepoint2/Cargo.toml rename to crates/servicepoint/Cargo.toml index 7dfa663..3991728 100644 --- a/servicepoint2/Cargo.toml +++ b/crates/servicepoint/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "servicepoint2" +name = "servicepoint" version = "0.4.2" publish = true edition = "2021" license = "GPL-3.0-or-later" description = "A rust library for the CCCB Service Point Display." -homepage = "https://docs.rs/crate/servicepoint2" -repository = "https://github.com/kaesaecracker/servicepoint" +homepage = "https://docs.rs/crate/servicepoint" +repository = "https://github.com/cccb/servicepoint" readme = "../README.md" [lib] @@ -20,7 +20,7 @@ zstd = { version = "0.13", optional = true } rust-lzma = { version = "0.6.0", optional = true } [features] -default = ["compression_lzma"] +default = ["compression_lzma", "c_api"] compression_zlib = ["dep:flate2"] compression_bzip2 = ["dep:bzip2"] compression_lzma = ["dep:rust-lzma"] diff --git a/servicepoint2/src/bit_vec.rs b/crates/servicepoint/src/bit_vec.rs similarity index 99% rename from servicepoint2/src/bit_vec.rs rename to crates/servicepoint/src/bit_vec.rs index 27cb8b2..a21ab4a 100644 --- a/servicepoint2/src/bit_vec.rs +++ b/crates/servicepoint/src/bit_vec.rs @@ -72,7 +72,7 @@ impl BitVec { /// /// # Examples /// ``` - /// use servicepoint2::BitVec; + /// use servicepoint::BitVec; /// let mut vec = BitVec::new(8); /// vec.fill(true); /// ``` diff --git a/servicepoint2/src/byte_grid.rs b/crates/servicepoint/src/byte_grid.rs similarity index 100% rename from servicepoint2/src/byte_grid.rs rename to crates/servicepoint/src/byte_grid.rs diff --git a/servicepoint2/src/c_slice.rs b/crates/servicepoint/src/c_slice.rs similarity index 100% rename from servicepoint2/src/c_slice.rs rename to crates/servicepoint/src/c_slice.rs diff --git a/servicepoint2/src/command.rs b/crates/servicepoint/src/command.rs similarity index 100% rename from servicepoint2/src/command.rs rename to crates/servicepoint/src/command.rs diff --git a/servicepoint2/src/command_code.rs b/crates/servicepoint/src/command_code.rs similarity index 100% rename from servicepoint2/src/command_code.rs rename to crates/servicepoint/src/command_code.rs diff --git a/servicepoint2/src/compression.rs b/crates/servicepoint/src/compression.rs similarity index 100% rename from servicepoint2/src/compression.rs rename to crates/servicepoint/src/compression.rs diff --git a/servicepoint2/src/compression_code.rs b/crates/servicepoint/src/compression_code.rs similarity index 100% rename from servicepoint2/src/compression_code.rs rename to crates/servicepoint/src/compression_code.rs diff --git a/servicepoint2/src/connection.rs b/crates/servicepoint/src/connection.rs similarity index 90% rename from servicepoint2/src/connection.rs rename to crates/servicepoint/src/connection.rs index 559cdcb..099e379 100644 --- a/servicepoint2/src/connection.rs +++ b/crates/servicepoint/src/connection.rs @@ -23,7 +23,7 @@ impl Connection { /// /// # Examples /// ```rust - /// let connection = servicepoint2::Connection::open("172.23.42.29:2342") + /// let connection = servicepoint::Connection::open("172.23.42.29:2342") /// .expect("connection failed"); /// ``` pub fn open(addr: impl ToSocketAddrs + Debug) -> std::io::Result { @@ -48,8 +48,8 @@ impl Connection { /// # Examples /// /// ```rust - /// use servicepoint2::{Command, CompressionCode, Grid, PixelGrid}; - /// let connection = servicepoint2::Connection::open("172.23.42.29:2342") + /// use servicepoint::{Command, CompressionCode, Grid, PixelGrid}; + /// let connection = servicepoint::Connection::open("172.23.42.29:2342") /// .expect("connection failed"); /// /// // turn off all pixels @@ -61,7 +61,7 @@ impl Connection { /// pixels.fill(true); /// /// // send pixels to display - /// connection.send(Command::BitmapLinearWin(servicepoint2::Origin(0, 0), pixels, CompressionCode::Uncompressed)) + /// connection.send(Command::BitmapLinearWin(servicepoint::Origin(0, 0), pixels, CompressionCode::Uncompressed)) /// .expect("send failed"); /// ``` pub fn send(&self, packet: impl Into) -> Result<(), std::io::Error> { diff --git a/servicepoint2/src/data_ref.rs b/crates/servicepoint/src/data_ref.rs similarity index 100% rename from servicepoint2/src/data_ref.rs rename to crates/servicepoint/src/data_ref.rs diff --git a/servicepoint2/src/grid.rs b/crates/servicepoint/src/grid.rs similarity index 97% rename from servicepoint2/src/grid.rs rename to crates/servicepoint/src/grid.rs index 2660899..55cab90 100644 --- a/servicepoint2/src/grid.rs +++ b/crates/servicepoint/src/grid.rs @@ -35,7 +35,7 @@ pub trait Grid { /// # Examples /// To avoid boxing, this example is using the concrete type `ByteGrid`. /// ``` - /// use servicepoint2::{ByteGrid, Grid}; + /// use servicepoint::{ByteGrid, Grid}; /// fn split(grid: ByteGrid) -> (ByteGrid, ByteGrid) { /// assert!(grid.width() >= 2); /// let split_x = grid.width() / 2; diff --git a/servicepoint2/src/lib.rs b/crates/servicepoint/src/lib.rs similarity index 100% rename from servicepoint2/src/lib.rs rename to crates/servicepoint/src/lib.rs diff --git a/servicepoint2/src/packet.rs b/crates/servicepoint/src/packet.rs similarity index 100% rename from servicepoint2/src/packet.rs rename to crates/servicepoint/src/packet.rs diff --git a/servicepoint2/src/pixel_grid.rs b/crates/servicepoint/src/pixel_grid.rs similarity index 100% rename from servicepoint2/src/pixel_grid.rs rename to crates/servicepoint/src/pixel_grid.rs diff --git a/crates/servicepoint_binding_c/Cargo.toml b/crates/servicepoint_binding_c/Cargo.toml new file mode 100644 index 0000000..79ab5b9 --- /dev/null +++ b/crates/servicepoint_binding_c/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "servicepoint_binding_c" +version = "0.4.2" +publish = false +edition = "2021" +license = "GPL-3.0-or-later" +description = "C bindings for the servicepoint crate." +homepage = "https://docs.rs/crate/servicepoint" +repository = "https://github.com/cccb/servicepoint" +readme = "../README.md" + +[build-dependencies] +cbindgen = "0.26.0" diff --git a/crates/servicepoint_binding_c/build.rs b/crates/servicepoint_binding_c/build.rs new file mode 100644 index 0000000..6ed5849 --- /dev/null +++ b/crates/servicepoint_binding_c/build.rs @@ -0,0 +1,13 @@ +use std::env; + +use cbindgen::{generate_with_config, Config}; + +fn main() { + let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + let config = Config::from_file(crate_dir.clone() + "/cbindgen.toml").unwrap(); + let servicepoint_dir = crate_dir.clone() + "/../servicepoint"; + + generate_with_config(servicepoint_dir, config) + .unwrap() + .write_to_file("servicepoint.h"); +} diff --git a/servicepoint2-binding-c/cbindgen.toml b/crates/servicepoint_binding_c/cbindgen.toml similarity index 95% rename from servicepoint2-binding-c/cbindgen.toml rename to crates/servicepoint_binding_c/cbindgen.toml index b10b660..42d7d04 100644 --- a/servicepoint2-binding-c/cbindgen.toml +++ b/crates/servicepoint_binding_c/cbindgen.toml @@ -27,6 +27,9 @@ usize_is_size_t = true [export] prefix = "sp2_" +[parse] +#include = ["servicepoint"] + [parse.expand] features = ["c-api"] all_features = true diff --git a/servicepoint2-binding-c/servicepoint2.h b/crates/servicepoint_binding_c/servicepoint.h similarity index 100% rename from servicepoint2-binding-c/servicepoint2.h rename to crates/servicepoint_binding_c/servicepoint.h diff --git a/crates/servicepoint_binding_c/src/lib.rs b/crates/servicepoint_binding_c/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/servicepoint2-binding-cs/Cargo.lock b/crates/servicepoint_binding_cs/Cargo.lock similarity index 100% rename from servicepoint2-binding-cs/Cargo.lock rename to crates/servicepoint_binding_cs/Cargo.lock diff --git a/servicepoint2-binding-cs/Cargo.toml b/crates/servicepoint_binding_cs/Cargo.toml similarity index 53% rename from servicepoint2-binding-cs/Cargo.toml rename to crates/servicepoint_binding_cs/Cargo.toml index 1b549cc..8cedffc 100644 --- a/servicepoint2-binding-cs/Cargo.toml +++ b/crates/servicepoint_binding_cs/Cargo.toml @@ -1,13 +1,14 @@ [package] -name = "servicepoint-binding-cs" +name = "servicepoint_binding_cs" version = "0.4.2" edition = "2021" +publish = false [lib] crate-type = ["cdylib"] [dependencies] -servicepoint2 = { path = "../servicepoint2", features = ["c_api"] } +servicepoint = { path = "../servicepoint", features = ["c_api"] } [build-dependencies] csbindgen = "1.8.0" diff --git a/servicepoint2-binding-cs/ServicePoint2.sln b/crates/servicepoint_binding_cs/ServicePoint.sln similarity index 94% rename from servicepoint2-binding-cs/ServicePoint2.sln rename to crates/servicepoint_binding_cs/ServicePoint.sln index 5fa11f6..c505f07 100644 --- a/servicepoint2-binding-cs/ServicePoint2.sln +++ b/crates/servicepoint_binding_cs/ServicePoint.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServicePoint2", "src/ServicePoint2.csproj", "{70EFFA3F-012A-4518-9627-466BEAE4252E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServicePoint", "src/ServicePoint.csproj", "{70EFFA3F-012A-4518-9627-466BEAE4252E}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lang-cs", "../examples/lang_cs/lang_cs.csproj", "{DA3B8B6E-993A-47DA-844B-F92AF520FF59}" EndProject diff --git a/crates/servicepoint_binding_cs/build.rs b/crates/servicepoint_binding_cs/build.rs new file mode 100644 index 0000000..23a0377 --- /dev/null +++ b/crates/servicepoint_binding_cs/build.rs @@ -0,0 +1,19 @@ +fn main() { + println!("cargo:rerun-if-changed=DOESNOTEXIST"); // rebuild every time + csbindgen::Builder::default() + .input_extern_file("../servicepoint/src/bit_vec.rs") + .input_extern_file("../servicepoint/src/byte_grid.rs") + .input_extern_file("../servicepoint/src/command.rs") + .input_extern_file("../servicepoint/src/compression_code.rs") + .input_extern_file("../servicepoint/src/connection.rs") + .input_extern_file("../servicepoint/src/pixel_grid.rs") + .input_extern_file("../servicepoint/src/lib.rs") + .input_extern_file("../servicepoint/src/c_slice.rs") + .input_extern_file("../servicepoint/src/packet.rs") + .csharp_dll_name("servicepoint") + .csharp_namespace("ServicePoint.BindGen") + .csharp_use_nint_types(true) + .csharp_class_accessibility("public") + .generate_csharp_file("src/BindGen/ServicePoint.g.cs") + .unwrap(); +} diff --git a/crates/servicepoint_binding_cs/src/BindGen/ServicePoint.g.cs b/crates/servicepoint_binding_cs/src/BindGen/ServicePoint.g.cs new file mode 100644 index 0000000..d138126 --- /dev/null +++ b/crates/servicepoint_binding_cs/src/BindGen/ServicePoint.g.cs @@ -0,0 +1,286 @@ +// +// This code is generated by csbindgen. +// DON'T CHANGE THIS DIRECTLY. +// +#pragma warning disable CS8500 +#pragma warning disable CS8981 +using System; +using System.Runtime.InteropServices; + + +namespace ServicePoint.BindGen +{ + public static unsafe partial class NativeMethods + { + const string __DllName = "servicepoint"; + + + + /// Creates a new `BitVec` instance. The returned instance has to be freed with `bit_vec_dealloc`. + [DllImport(__DllName, EntryPoint = "sp2_bit_vec_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern BitVec* sp2_bit_vec_new(nuint size); + + /// Loads a `BitVec` from the provided data. The returned instance has to be freed with `bit_vec_dealloc`. + [DllImport(__DllName, EntryPoint = "sp2_bit_vec_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern BitVec* sp2_bit_vec_load(byte* data, nuint data_length); + + /// Clones a `BitVec`. The returned instance has to be freed with `bit_vec_dealloc`. + [DllImport(__DllName, EntryPoint = "sp2_bit_vec_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern BitVec* sp2_bit_vec_clone(BitVec* @this); + + /// Deallocates a `BitVec`. Note: do not call this if the grid has been consumed in another way, e.g. to create a command. + [DllImport(__DllName, EntryPoint = "sp2_bit_vec_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void sp2_bit_vec_dealloc(BitVec* @this); + + /// Gets the value of a bit from the `BitVec`. + [DllImport(__DllName, EntryPoint = "sp2_bit_vec_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [return: MarshalAs(UnmanagedType.U1)] + public static extern bool sp2_bit_vec_get(BitVec* @this, nuint index); + + /// Sets the value of a bit in the `BitVec`. + [DllImport(__DllName, EntryPoint = "sp2_bit_vec_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [return: MarshalAs(UnmanagedType.U1)] + public static extern bool sp2_bit_vec_set(BitVec* @this, nuint index, [MarshalAs(UnmanagedType.U1)] bool value); + + /// Sets the value of all bits in the `BitVec`. + [DllImport(__DllName, EntryPoint = "sp2_bit_vec_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void sp2_bit_vec_fill(BitVec* @this, [MarshalAs(UnmanagedType.U1)] bool value); + + /// Gets the length of the `BitVec` in bits. + [DllImport(__DllName, EntryPoint = "sp2_bit_vec_len", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern nuint sp2_bit_vec_len(BitVec* @this); + + /// Returns true if length is 0. + [DllImport(__DllName, EntryPoint = "sp2_bit_vec_is_empty", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [return: MarshalAs(UnmanagedType.U1)] + public static extern bool sp2_bit_vec_is_empty(BitVec* @this); + + /// Gets an unsafe reference to the data of the `BitVec` instance. ## Safety The caller has to make sure to never access the returned memory after the `BitVec` instance has been consumed or manually deallocated. Reading and writing concurrently to either the original instance or the returned data will result in undefined behavior. + [DllImport(__DllName, EntryPoint = "sp2_bit_vec_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern CByteSlice sp2_bit_vec_unsafe_data_ref(BitVec* @this); + + /// Creates a new `ByteGrid` instance. The returned instance has to be freed with `byte_grid_dealloc`. + [DllImport(__DllName, EntryPoint = "sp2_byte_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern ByteGrid* sp2_byte_grid_new(nuint width, nuint height); + + /// Loads a `ByteGrid` with the specified dimensions from the provided data. The returned instance has to be freed with `byte_grid_dealloc`. + [DllImport(__DllName, EntryPoint = "sp2_byte_grid_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern ByteGrid* sp2_byte_grid_load(nuint width, nuint height, byte* data, nuint data_length); + + /// Clones a `ByteGrid`. The returned instance has to be freed with `byte_grid_dealloc`. + [DllImport(__DllName, EntryPoint = "sp2_byte_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern ByteGrid* sp2_byte_grid_clone(ByteGrid* @this); + + /// Deallocates a `ByteGrid`. Note: do not call this if the grid has been consumed in another way, e.g. to create a command. + [DllImport(__DllName, EntryPoint = "sp2_byte_grid_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void sp2_byte_grid_dealloc(ByteGrid* @this); + + /// Get the current value at the specified position + [DllImport(__DllName, EntryPoint = "sp2_byte_grid_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern byte sp2_byte_grid_get(ByteGrid* @this, nuint x, nuint y); + + /// Sets the current value at the specified position + [DllImport(__DllName, EntryPoint = "sp2_byte_grid_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void sp2_byte_grid_set(ByteGrid* @this, nuint x, nuint y, byte value); + + /// Fills the whole `ByteGrid` with the specified value + [DllImport(__DllName, EntryPoint = "sp2_byte_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void sp2_byte_grid_fill(ByteGrid* @this, byte value); + + /// Gets the width in pixels of the `ByteGrid` instance. + [DllImport(__DllName, EntryPoint = "sp2_byte_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern nuint sp2_byte_grid_width(ByteGrid* @this); + + /// Gets the height in pixels of the `ByteGrid` instance. + [DllImport(__DllName, EntryPoint = "sp2_byte_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern nuint sp2_byte_grid_height(ByteGrid* @this); + + /// Gets an unsafe reference to the data of the `ByteGrid` instance. ## Safety The caller has to make sure to never access the returned memory after the `ByteGrid` instance has been consumed or manually deallocated. Reading and writing concurrently to either the original instance or the returned data will result in undefined behavior. + [DllImport(__DllName, EntryPoint = "sp2_byte_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern CByteSlice sp2_byte_grid_unsafe_data_ref(ByteGrid* @this); + + /// Tries to turn a `Packet` into a `Command`. The packet is gets deallocated in the process. Returns: pointer to command or NULL + [DllImport(__DllName, EntryPoint = "sp2_command_try_from_packet", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Command* sp2_command_try_from_packet(Packet* packet); + + /// Clones a `Command` instance + [DllImport(__DllName, EntryPoint = "sp2_command_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Command* sp2_command_clone(Command* original); + + /// Allocates a new `Command::Clear` instance + [DllImport(__DllName, EntryPoint = "sp2_command_clear", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Command* sp2_command_clear(); + + /// Allocates a new `Command::HardReset` instance + [DllImport(__DllName, EntryPoint = "sp2_command_hard_reset", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Command* sp2_command_hard_reset(); + + /// Allocates a new `Command::FadeOut` instance + [DllImport(__DllName, EntryPoint = "sp2_command_fade_out", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Command* sp2_command_fade_out(); + + /// Allocates a new `Command::Brightness` instance + [DllImport(__DllName, EntryPoint = "sp2_command_brightness", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Command* sp2_command_brightness(byte brightness); + + /// Allocates a new `Command::CharBrightness` instance. The passed `ByteGrid` gets deallocated in the process. + [DllImport(__DllName, EntryPoint = "sp2_command_char_brightness", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Command* sp2_command_char_brightness(nuint x, nuint y, ByteGrid* byte_grid); + + /// Allocates a new `Command::BitmapLinear` instance. The passed `BitVec` gets deallocated in the process. + [DllImport(__DllName, EntryPoint = "sp2_command_bitmap_linear", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Command* sp2_command_bitmap_linear(nuint offset, BitVec* bit_vec, CompressionCode compression); + + /// Allocates a new `Command::BitmapLinearAnd` instance. The passed `BitVec` gets deallocated in the process. + [DllImport(__DllName, EntryPoint = "sp2_command_bitmap_linear_and", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Command* sp2_command_bitmap_linear_and(nuint offset, BitVec* bit_vec, CompressionCode compression); + + /// Allocates a new `Command::BitmapLinearOr` instance. The passed `BitVec` gets deallocated in the process. + [DllImport(__DllName, EntryPoint = "sp2_command_bitmap_linear_or", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Command* sp2_command_bitmap_linear_or(nuint offset, BitVec* bit_vec, CompressionCode compression); + + /// Allocates a new `Command::BitmapLinearXor` instance. The passed `BitVec` gets deallocated in the process. + [DllImport(__DllName, EntryPoint = "sp2_command_bitmap_linear_xor", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Command* sp2_command_bitmap_linear_xor(nuint offset, BitVec* bit_vec, CompressionCode compression); + + /// Allocates a new `Command::Cp437Data` instance. The passed `ByteGrid` gets deallocated in the process. + [DllImport(__DllName, EntryPoint = "sp2_command_cp437_data", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Command* sp2_command_cp437_data(nuint x, nuint y, ByteGrid* byte_grid); + + /// Allocates a new `Command::BitmapLinearWin` instance. The passed `PixelGrid` gets deallocated in the process. + [DllImport(__DllName, EntryPoint = "sp2_command_bitmap_linear_win", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Command* sp2_command_bitmap_linear_win(nuint x, nuint y, PixelGrid* byte_grid, CompressionCode compression_code); + + /// Deallocates a `Command`. Note that connection_send does this implicitly, so you only need to do this if you use the library for parsing commands. + [DllImport(__DllName, EntryPoint = "sp2_command_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void sp2_command_dealloc(Command* ptr); + + /// Creates a new instance of Connection. The returned instance has to be deallocated with `connection_dealloc`. returns: NULL if connection fails or connected instance Panics: bad string encoding + [DllImport(__DllName, EntryPoint = "sp2_connection_open", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Connection* sp2_connection_open(byte* host); + + /// Sends the command instance. The instance is consumed / destroyed and cannot be used after this call. + [DllImport(__DllName, EntryPoint = "sp2_connection_send", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [return: MarshalAs(UnmanagedType.U1)] + public static extern bool sp2_connection_send(Connection* connection, Packet* command_ptr); + + /// Closes and deallocates a connection instance + [DllImport(__DllName, EntryPoint = "sp2_connection_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void sp2_connection_dealloc(Connection* ptr); + + /// Creates a new `PixelGrid` instance. The returned instance has to be freed with `pixel_grid_dealloc`. + [DllImport(__DllName, EntryPoint = "sp2_pixel_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern PixelGrid* sp2_pixel_grid_new(nuint width, nuint height); + + /// Loads a `PixelGrid` with the specified dimensions from the provided data. The returned instance has to be freed with `pixel_grid_dealloc`. + [DllImport(__DllName, EntryPoint = "sp2_pixel_grid_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern PixelGrid* sp2_pixel_grid_load(nuint width, nuint height, byte* data, nuint data_length); + + /// Clones a `PixelGrid`. The returned instance has to be freed with `pixel_grid_dealloc`. + [DllImport(__DllName, EntryPoint = "sp2_pixel_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern PixelGrid* sp2_pixel_grid_clone(PixelGrid* @this); + + /// Deallocates a `PixelGrid`. Note: do not call this if the grid has been consumed in another way, e.g. to create a command. + [DllImport(__DllName, EntryPoint = "sp2_pixel_grid_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void sp2_pixel_grid_dealloc(PixelGrid* @this); + + /// Get the current value at the specified position + [DllImport(__DllName, EntryPoint = "sp2_pixel_grid_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [return: MarshalAs(UnmanagedType.U1)] + public static extern bool sp2_pixel_grid_get(PixelGrid* @this, nuint x, nuint y); + + /// Sets the current value at the specified position + [DllImport(__DllName, EntryPoint = "sp2_pixel_grid_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void sp2_pixel_grid_set(PixelGrid* @this, nuint x, nuint y, [MarshalAs(UnmanagedType.U1)] bool value); + + /// Fills the whole `PixelGrid` with the specified value + [DllImport(__DllName, EntryPoint = "sp2_pixel_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void sp2_pixel_grid_fill(PixelGrid* @this, [MarshalAs(UnmanagedType.U1)] bool value); + + /// Gets the width in pixels of the `PixelGrid` instance. + [DllImport(__DllName, EntryPoint = "sp2_pixel_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern nuint sp2_pixel_grid_width(PixelGrid* @this); + + /// Gets the height in pixels of the `PixelGrid` instance. + [DllImport(__DllName, EntryPoint = "sp2_pixel_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern nuint sp2_pixel_grid_height(PixelGrid* @this); + + /// Gets an unsafe reference to the data of the `PixelGrid` instance. ## Safety The caller has to make sure to never access the returned memory after the `PixelGrid` instance has been consumed or manually deallocated. Reading and writing concurrently to either the original instance or the returned data will result in undefined behavior. + [DllImport(__DllName, EntryPoint = "sp2_pixel_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern CByteSlice sp2_pixel_grid_unsafe_data_ref(PixelGrid* @this); + + /// Turns a `Command` into a `Packet`. The command gets deallocated in the process. + [DllImport(__DllName, EntryPoint = "sp2_packet_from_command", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Packet* sp2_packet_from_command(Command* command); + + /// Tries to load a `Packet` from the passed array with the specified length. returns: NULL in case of an error, pointer to the allocated packet otherwise + [DllImport(__DllName, EntryPoint = "sp2_packet_try_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern Packet* sp2_packet_try_load(byte* data, nuint length); + + /// Deallocates a `Packet`. Note: do not call this if the instance has been consumed in another way, e.g. by sending it. + [DllImport(__DllName, EntryPoint = "sp2_packet_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void sp2_packet_dealloc(Packet* @this); + + + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe partial struct BitVec + { + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe partial struct ByteGrid + { + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe partial struct Connection + { + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe partial struct PixelGrid + { + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe partial struct CByteSlice + { + public byte* start; + public nuint length; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe partial struct Packet + { + } + + + public enum Command + { + Clear, + HardReset, + FadeOut, + CharBrightness, + Brightness, + BitmapLegacy, + BitmapLinear, + BitmapLinearAnd, + BitmapLinearOr, + BitmapLinearXor, + Cp437Data, + BitmapLinearWin, + } + + public enum CompressionCode : ushort + { + Uncompressed = 0, + Zlib = 26490, + Bzip2 = 25210, + Lzma = 27770, + Zstd = 31347, + } + + +} diff --git a/servicepoint2-binding-cs/src/BindGen/ServicePoint2.g.cs b/crates/servicepoint_binding_cs/src/BindGen/ServicePoint2.g.cs similarity index 99% rename from servicepoint2-binding-cs/src/BindGen/ServicePoint2.g.cs rename to crates/servicepoint_binding_cs/src/BindGen/ServicePoint2.g.cs index d2df47b..d138126 100644 --- a/servicepoint2-binding-cs/src/BindGen/ServicePoint2.g.cs +++ b/crates/servicepoint_binding_cs/src/BindGen/ServicePoint2.g.cs @@ -8,11 +8,11 @@ using System; using System.Runtime.InteropServices; -namespace ServicePoint2.BindGen +namespace ServicePoint.BindGen { public static unsafe partial class NativeMethods { - const string __DllName = "servicepoint2"; + const string __DllName = "servicepoint"; diff --git a/servicepoint2-binding-cs/src/BitVec.cs b/crates/servicepoint_binding_cs/src/BitVec.cs similarity index 93% rename from servicepoint2-binding-cs/src/BitVec.cs rename to crates/servicepoint_binding_cs/src/BitVec.cs index 4d6da0b..3d61d92 100644 --- a/servicepoint2-binding-cs/src/BitVec.cs +++ b/crates/servicepoint_binding_cs/src/BitVec.cs @@ -1,8 +1,8 @@ -using ServicePoint2.BindGen; +using ServicePoint.BindGen; -namespace ServicePoint2; +namespace ServicePoint; -public sealed class BitVec : Sp2NativeInstance +public sealed class BitVec : SpNativeInstance { public static BitVec New(int size) { diff --git a/servicepoint2-binding-cs/src/ByteGrid.cs b/crates/servicepoint_binding_cs/src/ByteGrid.cs similarity index 95% rename from servicepoint2-binding-cs/src/ByteGrid.cs rename to crates/servicepoint_binding_cs/src/ByteGrid.cs index 2c6913d..2722a68 100644 --- a/servicepoint2-binding-cs/src/ByteGrid.cs +++ b/crates/servicepoint_binding_cs/src/ByteGrid.cs @@ -1,9 +1,9 @@ using System.Text; -using ServicePoint2.BindGen; +using ServicePoint.BindGen; -namespace ServicePoint2; +namespace ServicePoint; -public sealed class ByteGrid : Sp2NativeInstance +public sealed class ByteGrid : SpNativeInstance { public static ByteGrid New(int width, int height) { diff --git a/servicepoint2-binding-cs/src/Command.cs b/crates/servicepoint_binding_cs/src/Command.cs similarity index 96% rename from servicepoint2-binding-cs/src/Command.cs rename to crates/servicepoint_binding_cs/src/Command.cs index 50e5824..b25b564 100644 --- a/servicepoint2-binding-cs/src/Command.cs +++ b/crates/servicepoint_binding_cs/src/Command.cs @@ -1,9 +1,9 @@ using System.Diagnostics.CodeAnalysis; -using ServicePoint2.BindGen; +using ServicePoint.BindGen; -namespace ServicePoint2; +namespace ServicePoint; -public sealed class Command : Sp2NativeInstance +public sealed class Command : SpNativeInstance { public static bool TryFromPacket(Packet packet, [MaybeNullWhen(false)] out Command command) { diff --git a/servicepoint2-binding-cs/src/Connection.cs b/crates/servicepoint_binding_cs/src/Connection.cs similarity index 84% rename from servicepoint2-binding-cs/src/Connection.cs rename to crates/servicepoint_binding_cs/src/Connection.cs index 13220f3..0f95709 100644 --- a/servicepoint2-binding-cs/src/Connection.cs +++ b/crates/servicepoint_binding_cs/src/Connection.cs @@ -1,9 +1,9 @@ using System.Text; -using ServicePoint2.BindGen; +using ServicePoint.BindGen; -namespace ServicePoint2; +namespace ServicePoint; -public sealed class Connection : Sp2NativeInstance +public sealed class Connection : SpNativeInstance { public static Connection Open(string host) { diff --git a/servicepoint2-binding-cs/src/Constants.cs b/crates/servicepoint_binding_cs/src/Constants.cs similarity index 95% rename from servicepoint2-binding-cs/src/Constants.cs rename to crates/servicepoint_binding_cs/src/Constants.cs index bad08fd..9980f64 100644 --- a/servicepoint2-binding-cs/src/Constants.cs +++ b/crates/servicepoint_binding_cs/src/Constants.cs @@ -1,4 +1,4 @@ -namespace ServicePoint2; +namespace ServicePoint; public static class Constants { diff --git a/servicepoint2-binding-cs/src/GlobalUsings.cs b/crates/servicepoint_binding_cs/src/GlobalUsings.cs similarity index 100% rename from servicepoint2-binding-cs/src/GlobalUsings.cs rename to crates/servicepoint_binding_cs/src/GlobalUsings.cs diff --git a/servicepoint2-binding-cs/src/Packet.cs b/crates/servicepoint_binding_cs/src/Packet.cs similarity index 88% rename from servicepoint2-binding-cs/src/Packet.cs rename to crates/servicepoint_binding_cs/src/Packet.cs index e04a02d..822e601 100644 --- a/servicepoint2-binding-cs/src/Packet.cs +++ b/crates/servicepoint_binding_cs/src/Packet.cs @@ -1,9 +1,9 @@ using System.Diagnostics.CodeAnalysis; -using ServicePoint2.BindGen; +using ServicePoint.BindGen; -namespace ServicePoint2; +namespace ServicePoint; -public sealed class Packet : Sp2NativeInstance +public sealed class Packet : SpNativeInstance { public static Packet FromCommand(Command command) { diff --git a/servicepoint2-binding-cs/src/PixelGrid.cs b/crates/servicepoint_binding_cs/src/PixelGrid.cs similarity index 94% rename from servicepoint2-binding-cs/src/PixelGrid.cs rename to crates/servicepoint_binding_cs/src/PixelGrid.cs index 0a7394c..2d12f93 100644 --- a/servicepoint2-binding-cs/src/PixelGrid.cs +++ b/crates/servicepoint_binding_cs/src/PixelGrid.cs @@ -1,8 +1,8 @@ -using ServicePoint2.BindGen; +using ServicePoint.BindGen; -namespace ServicePoint2; +namespace ServicePoint; -public sealed class PixelGrid : Sp2NativeInstance +public sealed class PixelGrid : SpNativeInstance { public static PixelGrid New(int width, int height) { diff --git a/servicepoint2-binding-cs/src/ServicePoint2.csproj b/crates/servicepoint_binding_cs/src/ServicePoint.csproj similarity index 78% rename from servicepoint2-binding-cs/src/ServicePoint2.csproj rename to crates/servicepoint_binding_cs/src/ServicePoint.csproj index ad74039..f090283 100644 --- a/servicepoint2-binding-cs/src/ServicePoint2.csproj +++ b/crates/servicepoint_binding_cs/src/ServicePoint.csproj @@ -11,15 +11,15 @@ - ServicePoint2 + ServicePoint 0.3.0 Repository Authors None - ServicePoint2 + ServicePoint CCCB - C# bindings for the rust crate servicepoint2. You will need a suitable native shared library to use this. - For documentation, see the rust documentation: https://docs.rs/servicepoint2/latest/servicepoint2/. + C# bindings for the rust crate servicepoint. You will need a suitable native shared library to use this. + For documentation, see the rust documentation: https://docs.rs/servicepoint/latest/servicepoint/. Note that this library is still in early development. Breaking changes are expected before 1.0 is released. README.md @@ -27,11 +27,11 @@ - + - + @@ -43,14 +43,14 @@ - - libservicepoint2.so + + libservicepoint.so - - libservicepoint2.so + + libservicepoint.so diff --git a/servicepoint2-binding-cs/src/ServicePoint2Extensions.cs b/crates/servicepoint_binding_cs/src/ServicePointExtensions.cs similarity index 82% rename from servicepoint2-binding-cs/src/ServicePoint2Extensions.cs rename to crates/servicepoint_binding_cs/src/ServicePointExtensions.cs index e92031f..0e569ff 100644 --- a/servicepoint2-binding-cs/src/ServicePoint2Extensions.cs +++ b/crates/servicepoint_binding_cs/src/ServicePointExtensions.cs @@ -1,8 +1,8 @@ using System.Diagnostics.CodeAnalysis; -namespace ServicePoint2; +namespace ServicePoint; -public static class ServicePoint2Extensions +public static class ServicePointExtensions { public static Packet IntoPacket(this Command command) { diff --git a/servicepoint2-binding-cs/src/Sp2NativeInstance.cs b/crates/servicepoint_binding_cs/src/SpNativeInstance.cs similarity index 85% rename from servicepoint2-binding-cs/src/Sp2NativeInstance.cs rename to crates/servicepoint_binding_cs/src/SpNativeInstance.cs index 9b4d94a..23013c8 100644 --- a/servicepoint2-binding-cs/src/Sp2NativeInstance.cs +++ b/crates/servicepoint_binding_cs/src/SpNativeInstance.cs @@ -1,6 +1,6 @@ -namespace ServicePoint2; +namespace ServicePoint; -public abstract class Sp2NativeInstance +public abstract class SpNativeInstance : IDisposable where T : unmanaged { @@ -16,7 +16,7 @@ public abstract class Sp2NativeInstance } } - private protected unsafe Sp2NativeInstance(T* instance) + private protected unsafe SpNativeInstance(T* instance) { ArgumentNullException.ThrowIfNull(instance); _instance = instance; @@ -44,7 +44,7 @@ public abstract class Sp2NativeInstance GC.SuppressFinalize(this); } - ~Sp2NativeInstance() + ~SpNativeInstance() { ReleaseUnmanagedResources(); } diff --git a/servicepoint2-binding-cs/src/lib.rs b/crates/servicepoint_binding_cs/src/lib.rs similarity index 100% rename from servicepoint2-binding-cs/src/lib.rs rename to crates/servicepoint_binding_cs/src/lib.rs diff --git a/examples/announce/Cargo.toml b/examples/announce/Cargo.toml index ce589a0..0b9ceed 100644 --- a/examples/announce/Cargo.toml +++ b/examples/announce/Cargo.toml @@ -5,6 +5,6 @@ edition = "2021" publish = false [dependencies] -servicepoint2 = { path = "../../servicepoint2" } +servicepoint = { path = "../../crates/servicepoint" } clap = { version = "4.5", features = ["derive"] } env_logger = "0.11" diff --git a/examples/announce/src/main.rs b/examples/announce/src/main.rs index 1c9929d..a1fb81e 100644 --- a/examples/announce/src/main.rs +++ b/examples/announce/src/main.rs @@ -1,6 +1,6 @@ use clap::Parser; -use servicepoint2::{ByteGrid, Command, Connection, Grid, Origin}; +use servicepoint::{ByteGrid, Command, Connection, Grid, Origin}; #[derive(Parser, Debug)] struct Cli { diff --git a/examples/game_of_life/Cargo.toml b/examples/game_of_life/Cargo.toml index 999e868..df05972 100644 --- a/examples/game_of_life/Cargo.toml +++ b/examples/game_of_life/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" publish = false [dependencies] -servicepoint2 = { path = "../../servicepoint2" } +servicepoint = { path = "../../crates/servicepoint" } clap = { version = "4.5", features = ["derive"] } env_logger = "0.11" diff --git a/examples/game_of_life/src/main.rs b/examples/game_of_life/src/main.rs index 04be3cd..dae06f4 100644 --- a/examples/game_of_life/src/main.rs +++ b/examples/game_of_life/src/main.rs @@ -3,7 +3,7 @@ use std::thread; use clap::Parser; use rand::{distributions, Rng}; -use servicepoint2::*; +use servicepoint::*; #[derive(Parser, Debug)] struct Cli { diff --git a/examples/lang_c/Cargo.toml b/examples/lang_c/Cargo.toml new file mode 100644 index 0000000..5b7dc6e --- /dev/null +++ b/examples/lang_c/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "lang_c" +version = "0.1.0" +edition = "2021" +publish = false + +[lib] + +[build-dependencies] +cc = "1.0" + +[dependencies] +servicepoint = { path = "../../crates/servicepoint" } diff --git a/examples/lang_c/Makefile b/examples/lang_c/Makefile index 56b7f23..489db4c 100644 --- a/examples/lang_c/Makefile +++ b/examples/lang_c/Makefile @@ -1,8 +1,8 @@ ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) OUT_DIR := ${ROOT_DIR}/out -SP2_DIR := ${ROOT_DIR}/../../servicepoint2 -SP2_INCLUDE := ${ROOT_DIR}/../../servicepoint2-binding-c +SP2_DIR := ${ROOT_DIR}/../../servicepoint +SP2_INCLUDE := ${ROOT_DIR}/../../servicepoint-binding-c SP2_TARGET_RELEASE := ${SP2_DIR}/target/release .PHONY: build run clean @@ -19,4 +19,4 @@ clean: ${OUT_DIR}/lang_c: main.c cd ${SP2_DIR} && cargo build --release --all-features mkdir -p ${OUT_DIR} - gcc main.c -I ${SP2_INCLUDE} -L ${SP2_TARGET_RELEASE} -Wl,-Bstatic -lservicepoint2 -Wl,-Bdynamic -o ${OUT_DIR}/lang_c \ No newline at end of file + gcc main.c -I ${SP2_INCLUDE} -L ${SP2_TARGET_RELEASE} -Wl,-Bstatic -lservicepoint -Wl,-Bdynamic -o ${OUT_DIR}/lang_c diff --git a/examples/lang_c/build.rs b/examples/lang_c/build.rs new file mode 100644 index 0000000..ff2c59c --- /dev/null +++ b/examples/lang_c/build.rs @@ -0,0 +1,8 @@ + +fn main() { + println!("cargo::rerun-if-changed=src/main.c"); + + cc::Build::new() + .file("src/main.c") + .compile("lang_c"); +} diff --git a/examples/lang_c/src/lib.rs b/examples/lang_c/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/examples/lang_c/main.c b/examples/lang_c/src/main.c similarity index 95% rename from examples/lang_c/main.c rename to examples/lang_c/src/main.c index cf4fcff..7077eff 100644 --- a/examples/lang_c/main.c +++ b/examples/lang_c/src/main.c @@ -1,5 +1,5 @@ #include -#include "servicepoint2.h" +#include "servicepoint.h" int main(void) { sp2_Connection *connection = sp2_connection_open("localhost:2342"); diff --git a/examples/lang_cs/Program.cs b/examples/lang_cs/Program.cs index 718cee3..adfc32e 100644 --- a/examples/lang_cs/Program.cs +++ b/examples/lang_cs/Program.cs @@ -1,5 +1,5 @@ -using ServicePoint2; -using CompressionCode = ServicePoint2.BindGen.CompressionCode; +using ServicePoint; +using CompressionCode = ServicePoint.BindGen.CompressionCode; using var connection = Connection.Open("127.0.0.1:2342"); diff --git a/examples/lang_cs/lang_cs.csproj b/examples/lang_cs/lang_cs.csproj index b7d2828..d4fed5f 100644 --- a/examples/lang_cs/lang_cs.csproj +++ b/examples/lang_cs/lang_cs.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/moving_line/Cargo.toml b/examples/moving_line/Cargo.toml index 4397611..23645de 100644 --- a/examples/moving_line/Cargo.toml +++ b/examples/moving_line/Cargo.toml @@ -5,6 +5,6 @@ edition = "2021" publish = false [dependencies] -servicepoint2 = { path = "../../servicepoint2" } +servicepoint = { path = "../../crates/servicepoint" } clap = { version = "4.5", features = ["derive"] } -env_logger = "0.11" \ No newline at end of file +env_logger = "0.11" diff --git a/examples/moving_line/src/main.rs b/examples/moving_line/src/main.rs index 6ec9f1b..5e812f7 100644 --- a/examples/moving_line/src/main.rs +++ b/examples/moving_line/src/main.rs @@ -2,7 +2,7 @@ use std::thread; use clap::Parser; -use servicepoint2::*; +use servicepoint::*; #[derive(Parser, Debug)] struct Cli { diff --git a/examples/random_brightness/Cargo.toml b/examples/random_brightness/Cargo.toml index 479af50..4330960 100644 --- a/examples/random_brightness/Cargo.toml +++ b/examples/random_brightness/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" publish = false [dependencies] -servicepoint2 = { path = "../../servicepoint2" } +servicepoint = { path = "../../crates/servicepoint" } clap = { version = "4.5", features = ["derive"] } env_logger = "0.11" diff --git a/examples/random_brightness/src/main.rs b/examples/random_brightness/src/main.rs index aa0d1f6..b4194e8 100644 --- a/examples/random_brightness/src/main.rs +++ b/examples/random_brightness/src/main.rs @@ -3,8 +3,8 @@ use std::time::Duration; use clap::Parser; use rand::Rng; -use servicepoint2::Command::{BitmapLinearWin, Brightness, CharBrightness}; -use servicepoint2::*; +use servicepoint::Command::{BitmapLinearWin, Brightness, CharBrightness}; +use servicepoint::*; #[derive(Parser, Debug)] struct Cli { diff --git a/examples/wiping_clear/Cargo.toml b/examples/wiping_clear/Cargo.toml index 1135b9c..7ba5c58 100644 --- a/examples/wiping_clear/Cargo.toml +++ b/examples/wiping_clear/Cargo.toml @@ -5,6 +5,6 @@ edition = "2021" publish = false [dependencies] -servicepoint2 = { path = "../../servicepoint2" } +servicepoint = { path = "../../crates/servicepoint" } clap = { version = "4.5", features = ["derive"] } env_logger = "0.11" diff --git a/examples/wiping_clear/src/main.rs b/examples/wiping_clear/src/main.rs index 08131b6..7e5d0be 100644 --- a/examples/wiping_clear/src/main.rs +++ b/examples/wiping_clear/src/main.rs @@ -3,7 +3,7 @@ use std::time::Duration; use clap::Parser; -use servicepoint2::*; +use servicepoint::*; #[derive(Parser, Debug)] struct Cli { diff --git a/servicepoint2-binding-c/generate.sh b/servicepoint2-binding-c/generate.sh deleted file mode 100755 index 9ccb70a..0000000 --- a/servicepoint2-binding-c/generate.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh - -# if the script crashes here, run `cargo install cbindgen` -cbindgen --config cbindgen.toml --clean --output servicepoint2.h ../servicepoint2 diff --git a/servicepoint2-binding-cs/build.rs b/servicepoint2-binding-cs/build.rs deleted file mode 100644 index 333066b..0000000 --- a/servicepoint2-binding-cs/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -fn main() { - println!("cargo:rerun-if-changed=DOESNOTEXIST"); // rebuild every time - csbindgen::Builder::default() - .input_extern_file("../servicepoint2/src/bit_vec.rs") - .input_extern_file("../servicepoint2/src/byte_grid.rs") - .input_extern_file("../servicepoint2/src/command.rs") - .input_extern_file("../servicepoint2/src/compression_code.rs") - .input_extern_file("../servicepoint2/src/connection.rs") - .input_extern_file("../servicepoint2/src/pixel_grid.rs") - .input_extern_file("../servicepoint2/src/lib.rs") - .input_extern_file("../servicepoint2/src/c_slice.rs") - .input_extern_file("../servicepoint2/src/packet.rs") - .csharp_dll_name("servicepoint2") - .csharp_namespace("ServicePoint2.BindGen") - .csharp_use_nint_types(true) - .csharp_class_accessibility("public") - .generate_csharp_file("src/BindGen/ServicePoint2.g.cs") - .unwrap(); -}