simpleble 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +88 -0
- data/LICENSE.txt +21 -0
- data/README.md +350 -0
- data/ext/simpleble/extconf.rb +57 -0
- data/ext/simpleble/simpleble_ruby.c +682 -0
- data/lib/simpleble/adapter.rb +10 -0
- data/lib/simpleble/characteristic.rb +36 -0
- data/lib/simpleble/descriptor.rb +8 -0
- data/lib/simpleble/exceptions.rb +25 -0
- data/lib/simpleble/peripheral.rb +64 -0
- data/lib/simpleble/service.rb +16 -0
- data/lib/simpleble/version.rb +3 -0
- data/lib/simpleble.rb +40 -0
- data/vendor/simpleble/build_simplecble/CMakeFiles/4.0.3/CompilerIdCXX/CMakeCXXCompilerId.cpp +920 -0
- data/vendor/simpleble/build_simplecble/CMakeFiles/4.0.3/CompilerIdCXX/apple-sdk.cpp +1 -0
- data/vendor/simpleble/build_simplecble/CMakeFiles/4.1.0/CompilerIdCXX/CMakeCXXCompilerId.cpp +949 -0
- data/vendor/simpleble/build_simplecble/CMakeFiles/4.1.0/CompilerIdCXX/apple-sdk.cpp +1 -0
- data/vendor/simpleble/build_simplecble/export/simplecble/export.h +43 -0
- data/vendor/simpleble/build_simplecble/simpleble/export/simpleble/export.h +43 -0
- data/vendor/simpleble/dependencies/external/kvn/kvn_bytearray.h +222 -0
- data/vendor/simpleble/dependencies/external/kvn/kvn_safe_callback.hpp +66 -0
- data/vendor/simpleble/dependencies/external/kvn/logfwd.hpp +35 -0
- data/vendor/simpleble/dependencies/internal/fmt/args.h +220 -0
- data/vendor/simpleble/dependencies/internal/fmt/base.h +2962 -0
- data/vendor/simpleble/dependencies/internal/fmt/chrono.h +2338 -0
- data/vendor/simpleble/dependencies/internal/fmt/color.h +610 -0
- data/vendor/simpleble/dependencies/internal/fmt/compile.h +539 -0
- data/vendor/simpleble/dependencies/internal/fmt/core.h +5 -0
- data/vendor/simpleble/dependencies/internal/fmt/format-inl.h +1949 -0
- data/vendor/simpleble/dependencies/internal/fmt/format.h +4244 -0
- data/vendor/simpleble/dependencies/internal/fmt/os.h +427 -0
- data/vendor/simpleble/dependencies/internal/fmt/ostream.h +166 -0
- data/vendor/simpleble/dependencies/internal/fmt/printf.h +633 -0
- data/vendor/simpleble/dependencies/internal/fmt/ranges.h +850 -0
- data/vendor/simpleble/dependencies/internal/fmt/std.h +726 -0
- data/vendor/simpleble/dependencies/internal/fmt/xchar.h +373 -0
- data/vendor/simpleble/dependencies/internal/simplejni/Common.hpp +579 -0
- data/vendor/simpleble/dependencies/internal/simplejni/References.hpp +151 -0
- data/vendor/simpleble/dependencies/internal/simplejni/Registry.hpp +183 -0
- data/vendor/simpleble/dependencies/internal/simplejni/VM.hpp +88 -0
- data/vendor/simpleble/examples/simpleble/src/connect.cpp +67 -0
- data/vendor/simpleble/examples/simpleble/src/connect_safe.cpp +91 -0
- data/vendor/simpleble/examples/simpleble/src/list_adapters.cpp +22 -0
- data/vendor/simpleble/examples/simpleble/src/list_adapters_safe.cpp +33 -0
- data/vendor/simpleble/examples/simpleble/src/list_paired.cpp +27 -0
- data/vendor/simpleble/examples/simpleble/src/multiconnect.cpp +60 -0
- data/vendor/simpleble/examples/simpleble/src/notify.cpp +85 -0
- data/vendor/simpleble/examples/simpleble/src/notify_multi.cpp +101 -0
- data/vendor/simpleble/examples/simpleble/src/power_cycle.cpp +43 -0
- data/vendor/simpleble/examples/simpleble/src/read.cpp +82 -0
- data/vendor/simpleble/examples/simpleble/src/scan.cpp +62 -0
- data/vendor/simpleble/examples/simpleble/src/utils.cpp +59 -0
- data/vendor/simpleble/examples/simpleble/src/utils.hpp +27 -0
- data/vendor/simpleble/examples/simpleble/src/write.cpp +81 -0
- data/vendor/simpleble/examples/simplebluez/ble_nus/ble_nus.cpp +138 -0
- data/vendor/simpleble/examples/simplebluez/connect/connect.cpp +119 -0
- data/vendor/simpleble/examples/simplebluez/list_adapters/list_adapters.cpp +44 -0
- data/vendor/simpleble/examples/simplebluez/list_paired/list_paired.cpp +48 -0
- data/vendor/simpleble/examples/simplebluez/notify/notify.cpp +145 -0
- data/vendor/simpleble/examples/simplebluez/pair/pair.cpp +181 -0
- data/vendor/simpleble/examples/simplebluez/read/read.cpp +141 -0
- data/vendor/simpleble/examples/simplebluez/scan/scan.cpp +85 -0
- data/vendor/simpleble/examples/simplecble/c/connect.c +163 -0
- data/vendor/simpleble/examples/simplecble/c/notify.c +217 -0
- data/vendor/simpleble/examples/simplecble/c/scan.c +164 -0
- data/vendor/simpleble/examples/simpledbus/notification.cpp +24 -0
- data/vendor/simpleble/hitl/src/test_sanity.cpp +48 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Adapter.h +102 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/AdapterSafe.h +58 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Advanced.h +50 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Characteristic.h +39 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Config.h +55 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Descriptor.h +30 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Exceptions.h +72 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Logging.h +73 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Peripheral.h +82 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/PeripheralSafe.h +64 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Service.h +34 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/SimpleBLE.h +8 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Types.h +49 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Utils.h +13 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/export.h +43 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/kvn/kvn_bytearray.h +222 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/adapter.h +188 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/logging.h +37 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/peripheral.h +304 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/simpleble.h +21 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/types.h +73 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/utils.h +27 -0
- data/vendor/simpleble/simpleble/include/simpleble/Adapter.h +102 -0
- data/vendor/simpleble/simpleble/include/simpleble/AdapterSafe.h +58 -0
- data/vendor/simpleble/simpleble/include/simpleble/Characteristic.h +39 -0
- data/vendor/simpleble/simpleble/include/simpleble/Config.h +55 -0
- data/vendor/simpleble/simpleble/include/simpleble/Descriptor.h +30 -0
- data/vendor/simpleble/simpleble/include/simpleble/Exceptions.h +72 -0
- data/vendor/simpleble/simpleble/include/simpleble/Logging.h +73 -0
- data/vendor/simpleble/simpleble/include/simpleble/Peripheral.h +82 -0
- data/vendor/simpleble/simpleble/include/simpleble/PeripheralSafe.h +64 -0
- data/vendor/simpleble/simpleble/include/simpleble/Service.h +34 -0
- data/vendor/simpleble/simpleble/include/simpleble/SimpleBLE.h +8 -0
- data/vendor/simpleble/simpleble/include/simpleble/Types.h +49 -0
- data/vendor/simpleble/simpleble/include/simpleble/Utils.h +13 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/adapter.h +188 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/logging.h +37 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/peripheral.h +304 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/simpleble.h +21 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/types.h +73 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/utils.h +27 -0
- data/vendor/simpleble/simpleble/src/CommonUtils.h +63 -0
- data/vendor/simpleble/simpleble/src/Exceptions.cpp +31 -0
- data/vendor/simpleble/simpleble/src/Logging.cpp +136 -0
- data/vendor/simpleble/simpleble/src/LoggingInternal.h +85 -0
- data/vendor/simpleble/simpleble/src/Utils.cpp +24 -0
- data/vendor/simpleble/simpleble/src/backends/android/AdapterAndroid.cpp +101 -0
- data/vendor/simpleble/simpleble/src/backends/android/AdapterAndroid.h +70 -0
- data/vendor/simpleble/simpleble/src/backends/android/BackendAndroid.cpp +40 -0
- data/vendor/simpleble/simpleble/src/backends/android/BackendAndroid.h +20 -0
- data/vendor/simpleble/simpleble/src/backends/android/PeripheralAndroid.cpp +365 -0
- data/vendor/simpleble/simpleble/src/backends/android/PeripheralAndroid.h +90 -0
- data/vendor/simpleble/simpleble/src/backends/android/bridge/BluetoothGattCallback.cpp +432 -0
- data/vendor/simpleble/simpleble/src/backends/android/bridge/BluetoothGattCallback.h +102 -0
- data/vendor/simpleble/simpleble/src/backends/android/bridge/ScanCallback.cpp +142 -0
- data/vendor/simpleble/simpleble/src/backends/android/bridge/ScanCallback.h +55 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothAdapter.cpp +107 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothAdapter.h +55 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothDevice.cpp +68 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothDevice.h +54 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGatt.cpp +115 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGatt.h +75 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattCharacteristic.cpp +142 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattCharacteristic.h +66 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattDescriptor.cpp +67 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattDescriptor.h +46 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattService.cpp +106 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattService.h +47 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/BluetoothScanner.cpp +47 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/BluetoothScanner.h +37 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanRecord.cpp +69 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanRecord.h +41 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanResult.cpp +63 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanResult.h +42 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/os/ParcelUUID.cpp +32 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/os/ParcelUUID.h +30 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/util/SparseArray.cpp +54 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/util/SparseArray.h +37 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Iterator.cpp +36 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Iterator.h +28 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/List.cpp +29 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/List.h +27 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Set.cpp +33 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Set.h +28 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/UUID.cpp +26 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/UUID.h +29 -0
- data/vendor/simpleble/simpleble/src/backends/common/AdapterBase.cpp +53 -0
- data/vendor/simpleble/simpleble/src/backends/common/AdapterBase.h +81 -0
- data/vendor/simpleble/simpleble/src/backends/common/AdapterBaseTypes.h +22 -0
- data/vendor/simpleble/simpleble/src/backends/common/BackendBase.h +20 -0
- data/vendor/simpleble/simpleble/src/backends/common/BackendUtils.h +33 -0
- data/vendor/simpleble/simpleble/src/backends/common/CharacteristicBase.cpp +28 -0
- data/vendor/simpleble/simpleble/src/backends/common/CharacteristicBase.h +38 -0
- data/vendor/simpleble/simpleble/src/backends/common/DescriptorBase.cpp +7 -0
- data/vendor/simpleble/simpleble/src/backends/common/DescriptorBase.h +19 -0
- data/vendor/simpleble/simpleble/src/backends/common/PeripheralBase.h +82 -0
- data/vendor/simpleble/simpleble/src/backends/common/ServiceBase.cpp +18 -0
- data/vendor/simpleble/simpleble/src/backends/common/ServiceBase.h +28 -0
- data/vendor/simpleble/simpleble/src/backends/linux/AdapterLinux.cpp +102 -0
- data/vendor/simpleble/simpleble/src/backends/linux/AdapterLinux.h +55 -0
- data/vendor/simpleble/simpleble/src/backends/linux/BackendBluez.cpp +87 -0
- data/vendor/simpleble/simpleble/src/backends/linux/PeripheralLinux.cpp +376 -0
- data/vendor/simpleble/simpleble/src/backends/linux/PeripheralLinux.h +90 -0
- data/vendor/simpleble/simpleble/src/backends/macos/AdapterBaseMacOS.h +29 -0
- data/vendor/simpleble/simpleble/src/backends/macos/AdapterMac.h +78 -0
- data/vendor/simpleble/simpleble/src/backends/macos/PeripheralBaseMacOS.h +49 -0
- data/vendor/simpleble/simpleble/src/backends/macos/PeripheralMac.h +81 -0
- data/vendor/simpleble/simpleble/src/backends/macos/Utils.h +9 -0
- data/vendor/simpleble/simpleble/src/backends/plain/AdapterPlain.cpp +65 -0
- data/vendor/simpleble/simpleble/src/backends/plain/AdapterPlain.h +49 -0
- data/vendor/simpleble/simpleble/src/backends/plain/BackendPlain.cpp +30 -0
- data/vendor/simpleble/simpleble/src/backends/plain/PeripheralPlain.cpp +159 -0
- data/vendor/simpleble/simpleble/src/backends/plain/PeripheralPlain.h +72 -0
- data/vendor/simpleble/simpleble/src/backends/windows/AdapterWindows.cpp +330 -0
- data/vendor/simpleble/simpleble/src/backends/windows/AdapterWindows.h +89 -0
- data/vendor/simpleble/simpleble/src/backends/windows/BackendWinRT.cpp +67 -0
- data/vendor/simpleble/simpleble/src/backends/windows/BackendWinRT.h +18 -0
- data/vendor/simpleble/simpleble/src/backends/windows/MtaManager.cpp +49 -0
- data/vendor/simpleble/simpleble/src/backends/windows/MtaManager.h +90 -0
- data/vendor/simpleble/simpleble/src/backends/windows/PeripheralWindows.cpp +487 -0
- data/vendor/simpleble/simpleble/src/backends/windows/PeripheralWindows.h +129 -0
- data/vendor/simpleble/simpleble/src/backends/windows/Utils.cpp +146 -0
- data/vendor/simpleble/simpleble/src/backends/windows/Utils.h +47 -0
- data/vendor/simpleble/simpleble/src/builders/BuildVec.h +32 -0
- data/vendor/simpleble/simpleble/src/builders/BuilderBase.h +87 -0
- data/vendor/simpleble/simpleble/src/external/TaskRunner.hpp +99 -0
- data/vendor/simpleble/simpleble/src/external/ThreadRunner.h +52 -0
- data/vendor/simpleble/simpleble/src/external/kvn_safe_callback.hpp +66 -0
- data/vendor/simpleble/simpleble/src/external/kvn_safe_map.hpp +94 -0
- data/vendor/simpleble/simpleble/src/external/kvn_threadrunner.hpp +70 -0
- data/vendor/simpleble/simpleble/src/external/logfwd.hpp +35 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Adapter.cpp +111 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Backend.cpp +83 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Backend.h +76 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Characteristic.cpp +56 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Descriptor.cpp +21 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Peripheral.cpp +113 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Service.cpp +26 -0
- data/vendor/simpleble/simpleble/src/frontends/safe/AdapterSafe.cpp +158 -0
- data/vendor/simpleble/simpleble/src/frontends/safe/PeripheralSafe.cpp +219 -0
- data/vendor/simpleble/simpleble/src_c/adapter.cpp +204 -0
- data/vendor/simpleble/simpleble/src_c/logging.cpp +19 -0
- data/vendor/simpleble/simpleble/src_c/peripheral.cpp +444 -0
- data/vendor/simpleble/simpleble/src_c/simpleble.cpp +5 -0
- data/vendor/simpleble/simpleble/src_c/utils.cpp +15 -0
- data/vendor/simpleble/simpleble/test/src/main.cpp +8 -0
- data/vendor/simpleble/simpleble/test/src/test_bytearray.cpp +246 -0
- data/vendor/simpleble/simpleble/test/src/test_utils.cpp +24 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Adapter.h +46 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Agent.h +52 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Bluez.h +37 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/BluezOrg.h +22 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/BluezOrgBluez.h +26 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/BluezRoot.h +32 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Characteristic.h +46 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Descriptor.h +33 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Device.h +64 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Exceptions.h +43 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Service.h +27 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Types.h +9 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Adapter1.h +49 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Agent1.h +100 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/AgentManager1.h +24 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Battery1.h +32 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Device1.h +62 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattCharacteristic1.h +48 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattDescriptor1.h +41 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattService1.h +28 -0
- data/vendor/simpleble/simplebluez/src/Adapter.cpp +78 -0
- data/vendor/simpleble/simplebluez/src/Agent.cpp +72 -0
- data/vendor/simpleble/simplebluez/src/Bluez.cpp +45 -0
- data/vendor/simpleble/simplebluez/src/BluezOrg.cpp +20 -0
- data/vendor/simpleble/simplebluez/src/BluezOrgBluez.cpp +23 -0
- data/vendor/simpleble/simplebluez/src/BluezRoot.cpp +44 -0
- data/vendor/simpleble/simplebluez/src/Characteristic.cpp +64 -0
- data/vendor/simpleble/simplebluez/src/Descriptor.cpp +27 -0
- data/vendor/simpleble/simplebluez/src/Device.cpp +104 -0
- data/vendor/simpleble/simplebluez/src/Exceptions.cpp +29 -0
- data/vendor/simpleble/simplebluez/src/Logging.cpp +52 -0
- data/vendor/simpleble/simplebluez/src/Logging.h +57 -0
- data/vendor/simpleble/simplebluez/src/Service.cpp +33 -0
- data/vendor/simpleble/simplebluez/src/interfaces/Adapter1.cpp +123 -0
- data/vendor/simpleble/simplebluez/src/interfaces/Agent1.cpp +143 -0
- data/vendor/simpleble/simplebluez/src/interfaces/AgentManager1.cpp +34 -0
- data/vendor/simpleble/simplebluez/src/interfaces/Battery1.cpp +30 -0
- data/vendor/simpleble/simplebluez/src/interfaces/Device1.cpp +170 -0
- data/vendor/simpleble/simplebluez/src/interfaces/GattCharacteristic1.cpp +118 -0
- data/vendor/simpleble/simplebluez/src/interfaces/GattDescriptor1.cpp +78 -0
- data/vendor/simpleble/simplebluez/src/interfaces/GattService1.cpp +28 -0
- data/vendor/simpleble/simplebluez/test/src/helpers/PythonRunner.cpp +53 -0
- data/vendor/simpleble/simplebluez/test/src/helpers/PythonRunner.h +24 -0
- data/vendor/simpleble/simplebluez/test/src/main.cpp +16 -0
- data/vendor/simpleble/simplecble/include/simplecble/adapter.h +188 -0
- data/vendor/simpleble/simplecble/include/simplecble/logging.h +37 -0
- data/vendor/simpleble/simplecble/include/simplecble/peripheral.h +304 -0
- data/vendor/simpleble/simplecble/include/simplecble/simpleble.h +21 -0
- data/vendor/simpleble/simplecble/include/simplecble/types.h +73 -0
- data/vendor/simpleble/simplecble/include/simplecble/utils.h +27 -0
- data/vendor/simpleble/simplecble/src/adapter.cpp +204 -0
- data/vendor/simpleble/simplecble/src/logging.cpp +19 -0
- data/vendor/simpleble/simplecble/src/peripheral.cpp +444 -0
- data/vendor/simpleble/simplecble/src/simpleble.cpp +5 -0
- data/vendor/simpleble/simplecble/src/utils.cpp +15 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/advanced/Interface.h +67 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/advanced/InterfaceRegistry.h +64 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/advanced/Proxy.h +117 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Connection.h +50 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Exceptions.h +56 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Holder.h +147 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Logging.h +57 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Message.h +89 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Path.h +24 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/interfaces/ObjectManager.h +26 -0
- data/vendor/simpleble/simpledbus/src/advanced/Interface.cpp +155 -0
- data/vendor/simpleble/simpledbus/src/advanced/Proxy.cpp +375 -0
- data/vendor/simpleble/simpledbus/src/base/Connection.cpp +222 -0
- data/vendor/simpleble/simpledbus/src/base/Exceptions.cpp +39 -0
- data/vendor/simpleble/simpledbus/src/base/Holder.cpp +739 -0
- data/vendor/simpleble/simpledbus/src/base/Logging.cpp +52 -0
- data/vendor/simpleble/simpledbus/src/base/Message.cpp +622 -0
- data/vendor/simpleble/simpledbus/src/base/Path.cpp +129 -0
- data/vendor/simpleble/simpledbus/src/interfaces/ObjectManager.cpp +58 -0
- data/vendor/simpleble/simpledbus/test/src/helpers/PythonRunner.cpp +53 -0
- data/vendor/simpleble/simpledbus/test/src/helpers/PythonRunner.h +24 -0
- data/vendor/simpleble/simpledbus/test/src/main.cpp +16 -0
- data/vendor/simpleble/simpledbus/test/src/test_holder.cpp +184 -0
- data/vendor/simpleble/simpledbus/test/src/test_message.cpp +397 -0
- data/vendor/simpleble/simpledbus/test/src/test_path.cpp +76 -0
- data/vendor/simpleble/simpledbus/test/src/test_proxy_children.cpp +109 -0
- data/vendor/simpleble/simpledbus/test/src/test_proxy_interfaces.cpp +102 -0
- data/vendor/simpleble/simpledbus/test/src/test_proxy_lifetime.cpp +18 -0
- data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/ThreadRunner.h +89 -0
- data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/android_utils.cpp +55 -0
- data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/android_utils.h +18 -0
- data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/simpleble_android.cpp +813 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/AdapterWrapper.cpp +37 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/AdapterWrapper.h +23 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/Cache.cpp +58 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/Cache.h +34 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/PeripheralWrapper.cpp +17 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/PeripheralWrapper.h +19 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/ArrayList.cpp +257 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/ArrayList.h +78 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/HashMap.cpp +96 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/HashMap.h +54 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/Integer.cpp +93 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/Integer.h +49 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/Iterator.cpp +85 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/Iterator.h +48 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/AdapterCallback.cpp +91 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/AdapterCallback.h +90 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Characteristic.cpp +35 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Characteristic.h +60 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/DataCallback.cpp +33 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/DataCallback.h +45 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Descriptor.cpp +30 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Descriptor.h +49 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/PeripheralCallback.cpp +41 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/PeripheralCallback.h +51 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Service.cpp +33 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Service.h +54 -0
- data/vendor/simpleble/simplejavable/cpp/src/simplejavable.cpp +361 -0
- data/vendor/simpleble/simplepyble/src/main.cpp +55 -0
- data/vendor/simpleble/simplepyble/src/wrap_adapter.cpp +106 -0
- data/vendor/simpleble/simplepyble/src/wrap_characteristic.cpp +56 -0
- data/vendor/simpleble/simplepyble/src/wrap_config.cpp +136 -0
- data/vendor/simpleble/simplepyble/src/wrap_descriptor.cpp +21 -0
- data/vendor/simpleble/simplepyble/src/wrap_peripheral.cpp +217 -0
- data/vendor/simpleble/simplepyble/src/wrap_service.cpp +32 -0
- data/vendor/simpleble/simplepyble/src/wrap_types.cpp +21 -0
- data/vendor/simpleble/simplersble/src/bindings/Bindings.cpp +338 -0
- data/vendor/simpleble/simplersble/src/bindings/Bindings.hpp +178 -0
- metadata +430 -0
@@ -0,0 +1,129 @@
|
|
1
|
+
#include "simpledbus/base/Path.h"
|
2
|
+
|
3
|
+
#include <algorithm>
|
4
|
+
|
5
|
+
namespace SimpleDBus {
|
6
|
+
|
7
|
+
// TODO: Add path validation and throw exception if invalid
|
8
|
+
|
9
|
+
size_t Path::count_elements(const std::string& path) {
|
10
|
+
if (path.empty() || path == "/") {
|
11
|
+
return 0;
|
12
|
+
}
|
13
|
+
|
14
|
+
return std::count(path.begin(), path.end(), '/');
|
15
|
+
}
|
16
|
+
|
17
|
+
std::vector<std::string> Path::split_elements(const std::string& path) {
|
18
|
+
std::vector<std::string> elements;
|
19
|
+
|
20
|
+
if (path.empty() || path == "/") {
|
21
|
+
return elements;
|
22
|
+
}
|
23
|
+
|
24
|
+
// Note: Skip the first element, which is the root
|
25
|
+
std::string::const_iterator it = path.begin() + 1;
|
26
|
+
std::string::const_iterator end = path.end();
|
27
|
+
|
28
|
+
while (it != end) {
|
29
|
+
std::string::const_iterator next = std::find(it, end, '/');
|
30
|
+
elements.push_back(std::string(it, next));
|
31
|
+
it = next;
|
32
|
+
if (it != end) {
|
33
|
+
++it;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
return elements;
|
38
|
+
}
|
39
|
+
|
40
|
+
std::string Path::fetch_elements(const std::string& path, size_t count) {
|
41
|
+
if (count == 0) {
|
42
|
+
return "/";
|
43
|
+
}
|
44
|
+
|
45
|
+
if (count > count_elements(path)) {
|
46
|
+
// TODO: Should we throw an exception?
|
47
|
+
return path;
|
48
|
+
}
|
49
|
+
|
50
|
+
std::vector<std::string> elements = split_elements(path);
|
51
|
+
std::string result;
|
52
|
+
|
53
|
+
for (size_t i = 0; i < count; i++) {
|
54
|
+
result += "/" + elements[i];
|
55
|
+
}
|
56
|
+
|
57
|
+
return result;
|
58
|
+
}
|
59
|
+
|
60
|
+
bool Path::is_descendant(const std::string& base, const std::string& path) {
|
61
|
+
if (base.empty() || path.empty()) {
|
62
|
+
return false;
|
63
|
+
}
|
64
|
+
|
65
|
+
if (base == path) {
|
66
|
+
return false;
|
67
|
+
}
|
68
|
+
|
69
|
+
if (base == "/") {
|
70
|
+
return true;
|
71
|
+
}
|
72
|
+
|
73
|
+
return path.rfind(base) == 0;
|
74
|
+
}
|
75
|
+
|
76
|
+
bool Path::is_ascendant(const std::string& base, const std::string& path) {
|
77
|
+
if (base.empty() || path.empty()) {
|
78
|
+
return false;
|
79
|
+
}
|
80
|
+
|
81
|
+
if (base == path) {
|
82
|
+
return false;
|
83
|
+
}
|
84
|
+
|
85
|
+
return !is_descendant(base, path);
|
86
|
+
}
|
87
|
+
|
88
|
+
bool Path::is_child(const std::string& base, const std::string& path) {
|
89
|
+
if (base.empty() || path.empty()) {
|
90
|
+
return false;
|
91
|
+
}
|
92
|
+
|
93
|
+
if (base == path) {
|
94
|
+
return false;
|
95
|
+
}
|
96
|
+
|
97
|
+
if (!is_descendant(base, path)) {
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
|
101
|
+
return count_elements(base) + 1 == count_elements(path);
|
102
|
+
}
|
103
|
+
|
104
|
+
bool Path::is_parent(const std::string& base, const std::string& path) {
|
105
|
+
if (base.empty() || path.empty()) {
|
106
|
+
return false;
|
107
|
+
}
|
108
|
+
|
109
|
+
if (base == path) {
|
110
|
+
return false;
|
111
|
+
}
|
112
|
+
|
113
|
+
if (!is_ascendant(base, path)) {
|
114
|
+
return false;
|
115
|
+
}
|
116
|
+
|
117
|
+
return count_elements(base) - 1 == count_elements(path);
|
118
|
+
}
|
119
|
+
|
120
|
+
std::string Path::next_child(const std::string& base, const std::string& path) {
|
121
|
+
return fetch_elements(path, count_elements(base) + 1);
|
122
|
+
}
|
123
|
+
|
124
|
+
std::string Path::next_child_strip(const std::string& base, const std::string& path) {
|
125
|
+
const std::string child = next_child(base, path);
|
126
|
+
return child.substr(base.length() + 1);
|
127
|
+
}
|
128
|
+
|
129
|
+
} // namespace SimpleDBus
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#include <simpledbus/interfaces/ObjectManager.h>
|
2
|
+
|
3
|
+
using namespace SimpleDBus;
|
4
|
+
|
5
|
+
const AutoRegisterInterface<ObjectManager> ObjectManager::registry{
|
6
|
+
"org.freedesktop.DBus.ObjectManager",
|
7
|
+
// clang-format off
|
8
|
+
[](std::shared_ptr<Connection> conn, const std::string& bus_name, const std::string& path, const Holder& options) -> std::shared_ptr<SimpleDBus::Interface> {
|
9
|
+
return std::static_pointer_cast<SimpleDBus::Interface>(std::make_shared<ObjectManager>(conn, bus_name, path));
|
10
|
+
}
|
11
|
+
// clang-format on
|
12
|
+
};
|
13
|
+
|
14
|
+
ObjectManager::ObjectManager(std::shared_ptr<Connection> conn, std::string bus_name, std::string path)
|
15
|
+
: Interface(conn, bus_name, path, "org.freedesktop.DBus.ObjectManager") {}
|
16
|
+
|
17
|
+
Holder ObjectManager::GetManagedObjects(bool use_callbacks) {
|
18
|
+
Message query_msg = Message::create_method_call(_bus_name, _path, _interface_name, "GetManagedObjects");
|
19
|
+
Message reply_msg = _conn->send_with_reply_and_block(query_msg);
|
20
|
+
Holder managed_objects = reply_msg.extract();
|
21
|
+
// TODO: Remove immediate callback support.
|
22
|
+
if (use_callbacks) {
|
23
|
+
auto managed_object = managed_objects.get_dict_object_path();
|
24
|
+
for (auto& [path, options] : managed_object) {
|
25
|
+
if (InterfacesAdded) {
|
26
|
+
InterfacesAdded(path, options);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
return managed_objects;
|
31
|
+
}
|
32
|
+
|
33
|
+
void ObjectManager::message_handle(Message& msg) {
|
34
|
+
if (msg.is_signal(_interface_name, "InterfacesAdded")) {
|
35
|
+
std::string path = msg.extract().get_string();
|
36
|
+
msg.extract_next();
|
37
|
+
Holder options = msg.extract();
|
38
|
+
if (InterfacesAdded) {
|
39
|
+
InterfacesAdded(path, options);
|
40
|
+
}
|
41
|
+
} else if (msg.is_signal(_interface_name, "InterfacesRemoved")) {
|
42
|
+
std::string path = msg.extract().get_string();
|
43
|
+
msg.extract_next();
|
44
|
+
Holder options = msg.extract();
|
45
|
+
if (InterfacesRemoved) {
|
46
|
+
InterfacesRemoved(path, options);
|
47
|
+
}
|
48
|
+
// TODO: Make a call directly to the proxy to do this?
|
49
|
+
|
50
|
+
} else if (msg.is_method_call(_interface_name, "GetManagedObjects")) {
|
51
|
+
// TODO: Implement this.
|
52
|
+
// SimpleDBus::Holder result = _proxy->path_collect();
|
53
|
+
|
54
|
+
// SimpleDBus::Message reply = SimpleDBus::Message::create_method_return(msg);
|
55
|
+
// reply.append_argument(result, "a{oa{sa{sv}}}");
|
56
|
+
// _conn->send(reply);
|
57
|
+
}
|
58
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#include "PythonRunner.h"
|
2
|
+
#include <Python.h>
|
3
|
+
#include <mutex>
|
4
|
+
|
5
|
+
#include <csignal>
|
6
|
+
|
7
|
+
PythonRunner::PythonRunner(const std::string& script_path) : _script_path(script_path) {
|
8
|
+
// In order to get Python to properly find relative imports, the current location
|
9
|
+
// of the executable needs to be added to the Python path.
|
10
|
+
_import_path = std::filesystem::canonical("/proc/self/exe").parent_path();
|
11
|
+
}
|
12
|
+
|
13
|
+
PythonRunner::~PythonRunner() { uninit(); }
|
14
|
+
|
15
|
+
void PythonRunner::init() {
|
16
|
+
_async_thread = new std::thread(&PythonRunner::_async_thread_function, this);
|
17
|
+
while (!_python_initialized) {
|
18
|
+
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
19
|
+
}
|
20
|
+
std::this_thread::sleep_for(std::chrono::seconds(1));
|
21
|
+
}
|
22
|
+
|
23
|
+
void PythonRunner::uninit() {
|
24
|
+
if (Py_IsInitialized()) {
|
25
|
+
// This is a hack to get the Python interpreter to exit cleanly.
|
26
|
+
raise(SIGINT);
|
27
|
+
}
|
28
|
+
if (_async_thread) {
|
29
|
+
while (!_async_thread->joinable()) {
|
30
|
+
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
31
|
+
}
|
32
|
+
_async_thread->join();
|
33
|
+
delete _async_thread;
|
34
|
+
_async_thread = nullptr;
|
35
|
+
_python_initialized = false;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
void PythonRunner::_async_thread_function() {
|
40
|
+
Py_InitializeEx(0);
|
41
|
+
|
42
|
+
// Append the required import path to the Python path.
|
43
|
+
PyRun_SimpleString("import sys");
|
44
|
+
PyRun_SimpleString(("sys.path.append('" + _import_path.string() + "')").c_str());
|
45
|
+
_python_initialized = true;
|
46
|
+
|
47
|
+
// Run the script.
|
48
|
+
std::string full_script_path = (_import_path / _script_path).string();
|
49
|
+
FILE* fp = fopen(full_script_path.c_str(), "r");
|
50
|
+
PyRun_SimpleFile(fp, full_script_path.c_str());
|
51
|
+
fclose(fp);
|
52
|
+
Py_Finalize();
|
53
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <atomic>
|
4
|
+
#include <filesystem>
|
5
|
+
#include <string>
|
6
|
+
#include <thread>
|
7
|
+
|
8
|
+
class PythonRunner {
|
9
|
+
public:
|
10
|
+
PythonRunner(const std::string& script_path);
|
11
|
+
~PythonRunner();
|
12
|
+
PythonRunner(PythonRunner& other) = delete; // Remove the copy constructor
|
13
|
+
void operator=(const PythonRunner&) = delete; // Remove the copy assignment
|
14
|
+
|
15
|
+
void init();
|
16
|
+
void uninit();
|
17
|
+
|
18
|
+
private:
|
19
|
+
std::atomic_bool _python_initialized = {false};
|
20
|
+
std::filesystem::path _import_path;
|
21
|
+
std::string _script_path;
|
22
|
+
std::thread* _async_thread;
|
23
|
+
void _async_thread_function();
|
24
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
#include <gtest/gtest.h>
|
3
|
+
#include "helpers/PythonRunner.h"
|
4
|
+
|
5
|
+
int main(int argc, char** argv) {
|
6
|
+
PythonRunner runner("test_fixture.py");
|
7
|
+
|
8
|
+
runner.init();
|
9
|
+
|
10
|
+
::testing::InitGoogleTest(&argc, argv);
|
11
|
+
auto test_result = RUN_ALL_TESTS();
|
12
|
+
|
13
|
+
runner.uninit();
|
14
|
+
|
15
|
+
return test_result;
|
16
|
+
}
|
@@ -0,0 +1,184 @@
|
|
1
|
+
#include <gtest/gtest.h>
|
2
|
+
|
3
|
+
#include <simpledbus/base/Holder.h>
|
4
|
+
|
5
|
+
#include <any>
|
6
|
+
#include <map>
|
7
|
+
#include <string>
|
8
|
+
#include <variant>
|
9
|
+
|
10
|
+
using namespace SimpleDBus;
|
11
|
+
|
12
|
+
TEST(Holder, Boolean) {
|
13
|
+
Holder h = Holder::create_boolean(true);
|
14
|
+
EXPECT_EQ(h.get_boolean(), true);
|
15
|
+
|
16
|
+
EXPECT_EQ(h.type(), Holder::Type::BOOLEAN);
|
17
|
+
|
18
|
+
EXPECT_EQ(h.signature(), "b");
|
19
|
+
|
20
|
+
EXPECT_EQ(h.represent(), "true\n");
|
21
|
+
}
|
22
|
+
|
23
|
+
TEST(Holder, Byte) {
|
24
|
+
Holder h = Holder::create_byte(0x12);
|
25
|
+
EXPECT_EQ(h.get_byte(), 0x12);
|
26
|
+
|
27
|
+
EXPECT_EQ(h.type(), Holder::Type::BYTE);
|
28
|
+
|
29
|
+
EXPECT_EQ(h.signature(), "y");
|
30
|
+
|
31
|
+
EXPECT_EQ(h.represent(), "18\n");
|
32
|
+
}
|
33
|
+
|
34
|
+
TEST(Holder, Int16) {
|
35
|
+
Holder h = Holder::create_int16(0x1234);
|
36
|
+
EXPECT_EQ(h.get_int16(), 0x1234);
|
37
|
+
|
38
|
+
EXPECT_EQ(h.type(), Holder::Type::INT16);
|
39
|
+
|
40
|
+
EXPECT_EQ(h.signature(), "n");
|
41
|
+
|
42
|
+
EXPECT_EQ(h.represent(), "4660\n");
|
43
|
+
}
|
44
|
+
|
45
|
+
TEST(Holder, Int32) {
|
46
|
+
Holder h = Holder::create_int32(0x12345678);
|
47
|
+
EXPECT_EQ(h.get_int32(), 0x12345678);
|
48
|
+
|
49
|
+
EXPECT_EQ(h.type(), Holder::Type::INT32);
|
50
|
+
|
51
|
+
EXPECT_EQ(h.signature(), "i");
|
52
|
+
|
53
|
+
EXPECT_EQ(h.represent(), "305419896\n");
|
54
|
+
}
|
55
|
+
|
56
|
+
TEST(Holder, Int64) {
|
57
|
+
Holder h = Holder::create_int64(0x123456789abcdef0);
|
58
|
+
EXPECT_EQ(h.get_int64(), 0x123456789abcdef0);
|
59
|
+
|
60
|
+
EXPECT_EQ(h.type(), Holder::Type::INT64);
|
61
|
+
|
62
|
+
EXPECT_EQ(h.signature(), "x");
|
63
|
+
|
64
|
+
EXPECT_EQ(h.represent(), "1311768467463790320\n");
|
65
|
+
}
|
66
|
+
|
67
|
+
TEST(Holder, Double) {
|
68
|
+
Holder h = Holder::create_double(3.14);
|
69
|
+
EXPECT_EQ(h.get_double(), 3.14);
|
70
|
+
|
71
|
+
EXPECT_EQ(h.type(), Holder::Type::DOUBLE);
|
72
|
+
|
73
|
+
EXPECT_EQ(h.signature(), "d");
|
74
|
+
|
75
|
+
EXPECT_EQ(h.represent(), "3.14\n");
|
76
|
+
}
|
77
|
+
|
78
|
+
TEST(Holder, String) {
|
79
|
+
Holder h = Holder::create_string("Hello, world!");
|
80
|
+
EXPECT_EQ(h.get_string(), "Hello, world!");
|
81
|
+
|
82
|
+
EXPECT_EQ(h.type(), Holder::Type::STRING);
|
83
|
+
|
84
|
+
EXPECT_EQ(h.signature(), "s");
|
85
|
+
|
86
|
+
EXPECT_EQ(h.represent(), "Hello, world!\n");
|
87
|
+
}
|
88
|
+
|
89
|
+
TEST(Holder, ObjectPath) {
|
90
|
+
Holder h = Holder::create_object_path("/foo/bar");
|
91
|
+
EXPECT_EQ(h.get_object_path(), "/foo/bar");
|
92
|
+
|
93
|
+
EXPECT_EQ(h.type(), Holder::Type::OBJ_PATH);
|
94
|
+
|
95
|
+
EXPECT_EQ(h.signature(), "o");
|
96
|
+
|
97
|
+
EXPECT_EQ(h.represent(), "/foo/bar\n");
|
98
|
+
}
|
99
|
+
|
100
|
+
TEST(Holder, Signature) {
|
101
|
+
Holder h = Holder::create_signature("s");
|
102
|
+
EXPECT_EQ(h.get_signature(), "s");
|
103
|
+
|
104
|
+
EXPECT_EQ(h.type(), Holder::Type::SIGNATURE);
|
105
|
+
|
106
|
+
EXPECT_EQ(h.signature(), "g");
|
107
|
+
|
108
|
+
EXPECT_EQ(h.represent(), "s\n");
|
109
|
+
}
|
110
|
+
|
111
|
+
TEST(Holder, ArrayHomogeneous) {
|
112
|
+
Holder h = Holder::create_array();
|
113
|
+
h.array_append(Holder::create_int32(42));
|
114
|
+
|
115
|
+
EXPECT_EQ(h.get_array().size(), 1);
|
116
|
+
EXPECT_EQ(h.get_array()[0].get_int32(), 42);
|
117
|
+
|
118
|
+
EXPECT_EQ(h.type(), Holder::Type::ARRAY);
|
119
|
+
|
120
|
+
EXPECT_EQ(h.signature(), "ai");
|
121
|
+
|
122
|
+
EXPECT_EQ(h.represent(), "Array:\n 42\n");
|
123
|
+
}
|
124
|
+
|
125
|
+
TEST(Holder, ArrayHeterogeneous) {
|
126
|
+
Holder h = Holder::create_array();
|
127
|
+
h.array_append(Holder::create_int32(42));
|
128
|
+
h.array_append(Holder::create_string("Hello, world!"));
|
129
|
+
|
130
|
+
EXPECT_EQ(h.get_array().size(), 2);
|
131
|
+
|
132
|
+
EXPECT_EQ(h.type(), Holder::Type::ARRAY);
|
133
|
+
|
134
|
+
EXPECT_EQ(h.signature(), "av");
|
135
|
+
|
136
|
+
EXPECT_EQ(h.represent(), "Array:\n 42\n Hello, world!\n");
|
137
|
+
}
|
138
|
+
|
139
|
+
TEST(Holder, DictionaryHomogeneousString) {
|
140
|
+
Holder h = Holder::create_dict();
|
141
|
+
|
142
|
+
// Add three objects with string keys to the dictionary.
|
143
|
+
h.dict_append(Holder::Type::STRING, "string_key1", Holder::create_string("value1"));
|
144
|
+
h.dict_append(Holder::Type::STRING, "string_key2", Holder::create_string("value2"));
|
145
|
+
h.dict_append(Holder::Type::STRING, "string_key3", Holder::create_string("value3"));
|
146
|
+
|
147
|
+
EXPECT_EQ(h.type(), Holder::Type::DICT);
|
148
|
+
|
149
|
+
EXPECT_EQ(h.signature(), "a{ss}");
|
150
|
+
|
151
|
+
EXPECT_EQ(h.represent(), "Dictionary:\nstring_key1:\n value1\nstring_key2:\n value2\nstring_key3:\n value3\n");
|
152
|
+
}
|
153
|
+
|
154
|
+
TEST(Holder, DictionaryHeterogeneous) {
|
155
|
+
Holder h = Holder::create_dict();
|
156
|
+
|
157
|
+
// Add three objects with string keys to the dictionary.
|
158
|
+
h.dict_append(Holder::Type::STRING, "string_key1", Holder());
|
159
|
+
h.dict_append(Holder::Type::STRING, "string_key2", Holder());
|
160
|
+
h.dict_append(Holder::Type::STRING, "string_key3", Holder());
|
161
|
+
|
162
|
+
// Add three objects with int keys to the dictionary.
|
163
|
+
h.dict_append(Holder::Type::INT32, static_cast<int32_t>(123), Holder());
|
164
|
+
h.dict_append(Holder::Type::INT32, static_cast<int32_t>(456), Holder());
|
165
|
+
h.dict_append(Holder::Type::INT32, static_cast<int32_t>(789), Holder());
|
166
|
+
|
167
|
+
// Check that all objects with string keys are returned.
|
168
|
+
auto dict_string = h.get_dict_string();
|
169
|
+
EXPECT_EQ(dict_string.size(), 3);
|
170
|
+
EXPECT_EQ(dict_string.count("string_key1"), 1);
|
171
|
+
EXPECT_EQ(dict_string.count("string_key2"), 1);
|
172
|
+
EXPECT_EQ(dict_string.count("string_key3"), 1);
|
173
|
+
|
174
|
+
// Check that all objects with int32 keys are returned.
|
175
|
+
auto dict_int32 = h.get_dict_int32();
|
176
|
+
EXPECT_EQ(dict_int32.size(), 3);
|
177
|
+
EXPECT_EQ(dict_int32.count(123), 1);
|
178
|
+
EXPECT_EQ(dict_int32.count(456), 1);
|
179
|
+
EXPECT_EQ(dict_int32.count(789), 1);
|
180
|
+
|
181
|
+
// TODO: Expand this test to check with all remaining types.
|
182
|
+
}
|
183
|
+
|
184
|
+
// TODO: Add tests for equality comparison of Holders.
|