diff options
author | Sven Gothel <[email protected]> | 2021-01-11 15:07:25 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2021-01-11 15:07:25 +0100 |
commit | eccc38ca45f740bf0f80b668fdf1400a59e04496 (patch) | |
tree | 8865a88a00ccaa0eb1e831a73911f8be7420b152 | |
parent | d874fad4b312d5d404386e61be5fc3c0253b9560 (diff) |
Replace std::vector w/ jau::darray: Adapt JNI methods
-rw-r--r-- | java/jni/direct_bt/DBTAdapter.cxx | 2 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTDevice.cxx | 5 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTGattCharacteristic.cxx | 5 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTGattService.cxx | 7 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTManager.cxx | 5 | ||||
-rw-r--r-- | java/jni/tinyb/DBusAdapter.cxx | 4 | ||||
-rw-r--r-- | java/jni/tinyb/DBusDevice.cxx | 4 | ||||
-rw-r--r-- | java/jni/tinyb/DBusGattCharacteristic.cxx | 4 | ||||
-rw-r--r-- | java/jni/tinyb/DBusGattService.cxx | 4 | ||||
-rw-r--r-- | java/jni/tinyb/DBusManager.cxx | 15 | ||||
-rw-r--r-- | scripts/build.sh | 4 |
11 files changed, 32 insertions, 27 deletions
diff --git a/java/jni/direct_bt/DBTAdapter.cxx b/java/jni/direct_bt/DBTAdapter.cxx index 4e362910..38674b6d 100644 --- a/java/jni/direct_bt/DBTAdapter.cxx +++ b/java/jni/direct_bt/DBTAdapter.cxx @@ -791,7 +791,7 @@ jobject Java_direct_1bt_tinyb_DBTAdapter_getDiscoveredDevicesImpl(JNIEnv *env, j { try { DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj); - std::vector<std::shared_ptr<DBTDevice>> array = adapter->getDiscoveredDevices(); + jau::darray<std::shared_ptr<DBTDevice>> array = adapter->getDiscoveredDevices(); return convert_vector_sharedptr_to_jarraylist(env, array); } catch(...) { rethrow_and_raise_java_exception(env); diff --git a/java/jni/direct_bt/DBTDevice.cxx b/java/jni/direct_bt/DBTDevice.cxx index 71141ddb..38e02a57 100644 --- a/java/jni/direct_bt/DBTDevice.cxx +++ b/java/jni/direct_bt/DBTDevice.cxx @@ -598,7 +598,7 @@ jobject Java_direct_1bt_tinyb_DBTDevice_getServicesImpl(JNIEnv *env, jobject obj DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj); JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); - std::vector<GATTServiceRef> services = device->getGATTServices(); // implicit GATT connect and discovery if required incl GenericAccess retrieval + jau::darray<GATTServiceRef> services = device->getGATTServices(); // implicit GATT connect and discovery if required incl GenericAccess retrieval if( services.size() > 0 ) { std::shared_ptr<GattGenericAccessSvc> ga = device->getGATTGenericAccess(); if( nullptr != ga ) { @@ -635,7 +635,8 @@ jobject Java_direct_1bt_tinyb_DBTDevice_getServicesImpl(JNIEnv *env, jobject obj env_->DeleteLocalRef(jservice); return JavaGlobalObj::GetObject(jServiceRef); }; - return convert_vector_sharedptr_to_jarraylist<GATTService>(env, services, _serviceClazzCtorArgs.c_str(), ctor_service); + return convert_vector_sharedptr_to_jarraylist<jau::darray<GATTServiceRef>, GATTService>( + env, services, _serviceClazzCtorArgs.c_str(), ctor_service); } catch(...) { rethrow_and_raise_java_exception(env); } diff --git a/java/jni/direct_bt/DBTGattCharacteristic.cxx b/java/jni/direct_bt/DBTGattCharacteristic.cxx index 70a19051..e1406a1e 100644 --- a/java/jni/direct_bt/DBTGattCharacteristic.cxx +++ b/java/jni/direct_bt/DBTGattCharacteristic.cxx @@ -65,7 +65,7 @@ jobject Java_direct_1bt_tinyb_DBTGattCharacteristic_getDescriptorsImpl(JNIEnv *e GATTCharacteristic *characteristic = getJavaUplinkObject<GATTCharacteristic>(env, obj); JavaGlobalObj::check(characteristic->getJavaObject(), E_FILE_LINE); - std::vector<GATTDescriptorRef> & descriptorList = characteristic->descriptorList; + jau::darray<GATTDescriptorRef> & descriptorList = characteristic->descriptorList; // DBTGattDescriptor(final long nativeInstance, final DBTGattCharacteristic characteristic, // final String type_uuid, final short handle, final byte[] value) @@ -101,7 +101,8 @@ jobject Java_direct_1bt_tinyb_DBTGattCharacteristic_getDescriptorsImpl(JNIEnv *e env_->DeleteLocalRef(jdesc); return JavaGlobalObj::GetObject(jDescRef); }; - return convert_vector_sharedptr_to_jarraylist<GATTDescriptor>(env, descriptorList, _descriptorClazzCtorArgs.c_str(), ctor_desc); + return convert_vector_sharedptr_to_jarraylist<jau::darray<GATTDescriptorRef>, GATTDescriptor>( + env, descriptorList, _descriptorClazzCtorArgs.c_str(), ctor_desc); } catch(...) { rethrow_and_raise_java_exception(env); } diff --git a/java/jni/direct_bt/DBTGattService.cxx b/java/jni/direct_bt/DBTGattService.cxx index 7b3690bf..eeda1458 100644 --- a/java/jni/direct_bt/DBTGattService.cxx +++ b/java/jni/direct_bt/DBTGattService.cxx @@ -67,7 +67,7 @@ jobject Java_direct_1bt_tinyb_DBTGattService_getCharacteristicsImpl(JNIEnv *env, GATTService *service = getJavaUplinkObject<GATTService>(env, obj); JavaGlobalObj::check(service->getJavaObject(), E_FILE_LINE); - std::vector<std::shared_ptr<GATTCharacteristic>> & characteristics = service->characteristicList; + jau::darray<std::shared_ptr<GATTCharacteristic>> & characteristics = service->characteristicList; // DBTGattCharacteristic(final long nativeInstance, final DBTGattService service, // final short handle, final String[] properties, @@ -82,7 +82,7 @@ jobject Java_direct_1bt_tinyb_DBTGattService_getCharacteristicsImpl(JNIEnv *env, JavaGlobalObj::check(_service->getJavaObject(), E_FILE_LINE); jobject jservice = JavaGlobalObj::GetObject(_service->getJavaObject()); - std::vector<std::unique_ptr<std::string>> props = GATTCharacteristic::getPropertiesStringList(characteristic->properties); + jau::darray<std::unique_ptr<std::string>> props = GATTCharacteristic::getPropertiesStringList(characteristic->properties); size_t props_size = props.size(); jobjectArray jproperties; @@ -118,7 +118,8 @@ jobject Java_direct_1bt_tinyb_DBTGattService_getCharacteristicsImpl(JNIEnv *env, env_->DeleteLocalRef(jcharVal); return JavaGlobalObj::GetObject(jCharRef); }; - return convert_vector_sharedptr_to_jarraylist<GATTCharacteristic>(env, characteristics, _characteristicClazzCtorArgs.c_str(), ctor_char); + return convert_vector_sharedptr_to_jarraylist<jau::darray<std::shared_ptr<GATTCharacteristic>>, GATTCharacteristic>( + env, characteristics, _characteristicClazzCtorArgs.c_str(), ctor_char); } catch(...) { rethrow_and_raise_java_exception(env); } diff --git a/java/jni/direct_bt/DBTManager.cxx b/java/jni/direct_bt/DBTManager.cxx index efc7a0a1..75aa961d 100644 --- a/java/jni/direct_bt/DBTManager.cxx +++ b/java/jni/direct_bt/DBTManager.cxx @@ -171,7 +171,7 @@ jobject Java_direct_1bt_tinyb_DBTManager_getAdapterListImpl(JNIEnv *env, jobject DBTManager *manager = getInstance<DBTManager>(env, obj); DBG_PRINT("Java_direct_1bt_tinyb_DBTManager_getAdapterListImpl: Manager %s", manager->toString().c_str()); - std::vector<std::unique_ptr<DBTAdapter>> adapters; + jau::darray<std::unique_ptr<DBTAdapter>> adapters; const int adapterCount = manager->getAdapterCount(); for(int dev_id = 0; dev_id < adapterCount; dev_id++) { if( nullptr == manager->getAdapterInfo(dev_id) ) { @@ -190,7 +190,8 @@ jobject Java_direct_1bt_tinyb_DBTManager_getAdapterListImpl(JNIEnv *env, jobject } adapters.push_back(std::move(adapter)); } - return convert_vector_uniqueptr_to_jarraylist<DBTAdapter>(env, adapters, _adapterClazzCtorArgs.c_str(), _createJavaAdapter); + return convert_vector_uniqueptr_to_jarraylist<jau::darray<std::unique_ptr<DBTAdapter>>, DBTAdapter>( + env, adapters, _adapterClazzCtorArgs.c_str(), _createJavaAdapter); } catch(...) { rethrow_and_raise_java_exception(env); } diff --git a/java/jni/tinyb/DBusAdapter.cxx b/java/jni/tinyb/DBusAdapter.cxx index 41273a5d..2a7efc6f 100644 --- a/java/jni/tinyb/DBusAdapter.cxx +++ b/java/jni/tinyb/DBusAdapter.cxx @@ -84,8 +84,8 @@ jobject Java_tinyb_dbus_DBusAdapter_getDevices(JNIEnv *env, jobject obj) try { BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj); std::vector<std::unique_ptr<BluetoothDevice>> array = obj_adapter->get_devices(); - jobject result = convert_vector_uniqueptr_to_jarraylist<BluetoothDevice>(env, array, - "(J)V"); + jobject result = convert_vector_uniqueptr_to_jarraylist<std::vector<std::unique_ptr<BluetoothDevice>>, BluetoothDevice>( + env, array, "(J)V"); return result; } catch(...) { diff --git a/java/jni/tinyb/DBusDevice.cxx b/java/jni/tinyb/DBusDevice.cxx index 530c72dd..aa5c804d 100644 --- a/java/jni/tinyb/DBusDevice.cxx +++ b/java/jni/tinyb/DBusDevice.cxx @@ -172,8 +172,8 @@ jobject Java_tinyb_dbus_DBusDevice_getServices(JNIEnv *env, jobject obj) try { BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj); std::vector<std::unique_ptr<BluetoothGattService>> array = obj_device->get_services(); - jobject result = convert_vector_uniqueptr_to_jarraylist<BluetoothGattService>(env, array, - "(J)V"); + jobject result = convert_vector_uniqueptr_to_jarraylist<std::vector<std::unique_ptr<BluetoothGattService>>, BluetoothGattService>( + env, array, "(J)V"); return result; } catch(...) { diff --git a/java/jni/tinyb/DBusGattCharacteristic.cxx b/java/jni/tinyb/DBusGattCharacteristic.cxx index 9c95110b..0becc560 100644 --- a/java/jni/tinyb/DBusGattCharacteristic.cxx +++ b/java/jni/tinyb/DBusGattCharacteristic.cxx @@ -234,8 +234,8 @@ jobject Java_tinyb_dbus_DBusGattCharacteristic_getDescriptors(JNIEnv *env, jobje getInstance<BluetoothGattCharacteristic>(env, obj); std::vector<std::unique_ptr<BluetoothGattDescriptor>> array = obj_gatt_char->get_descriptors(); - jobject result = convert_vector_uniqueptr_to_jarraylist<BluetoothGattDescriptor>(env, array, - "(J)V"); + jobject result = convert_vector_uniqueptr_to_jarraylist<std::vector<std::unique_ptr<BluetoothGattDescriptor>>, BluetoothGattDescriptor>( + env, array, "(J)V"); return result; } catch(...) { rethrow_and_raise_java_exception(env); diff --git a/java/jni/tinyb/DBusGattService.cxx b/java/jni/tinyb/DBusGattService.cxx index 60978a42..99284e39 100644 --- a/java/jni/tinyb/DBusGattService.cxx +++ b/java/jni/tinyb/DBusGattService.cxx @@ -109,8 +109,8 @@ jobject Java_tinyb_dbus_DBusGattService_getCharacteristics(JNIEnv *env, jobject BluetoothGattService *obj_gatt_serv = getInstance<BluetoothGattService>(env, obj); std::vector<std::unique_ptr<BluetoothGattCharacteristic>> array = obj_gatt_serv->get_characteristics(); - jobject result = convert_vector_uniqueptr_to_jarraylist<BluetoothGattCharacteristic>(env, array, - "(J)V"); + jobject result = convert_vector_uniqueptr_to_jarraylist<std::vector<std::unique_ptr<BluetoothGattCharacteristic>>, BluetoothGattCharacteristic>( + env, array, "(J)V"); return result; } catch(...) { rethrow_and_raise_java_exception(env); diff --git a/java/jni/tinyb/DBusManager.cxx b/java/jni/tinyb/DBusManager.cxx index 8985495a..e3abf7ba 100644 --- a/java/jni/tinyb/DBusManager.cxx +++ b/java/jni/tinyb/DBusManager.cxx @@ -192,7 +192,8 @@ jobject Java_tinyb_dbus_DBusManager_getObjects(JNIEnv *env, jobject obj, jint ty identifier_to_write, b_parent); getObject_cleaner(name_to_write, identifier_to_write); - jobject result = convert_vector_uniqueptr_to_jarraylist<BluetoothObject>(env, array, "(J)V"); + jobject result = convert_vector_uniqueptr_to_jarraylist<std::vector<std::unique_ptr<BluetoothObject>>, BluetoothObject>( + env, array, "(J)V"); return result; } catch(...) { rethrow_and_raise_java_exception(env); @@ -206,8 +207,8 @@ jobject Java_tinyb_dbus_DBusManager_getAdapters(JNIEnv *env, jobject obj) BluetoothManager *manager = getInstance<BluetoothManager>(env, obj); std::vector<std::unique_ptr<BluetoothAdapter>> array = manager->get_adapters(); - jobject result = convert_vector_uniqueptr_to_jarraylist<BluetoothAdapter>(env, array, - "(J)V"); + jobject result = convert_vector_uniqueptr_to_jarraylist<std::vector<std::unique_ptr<BluetoothAdapter>>, BluetoothAdapter>( + env, array, "(J)V"); return result; } catch(...) { rethrow_and_raise_java_exception(env); @@ -221,8 +222,8 @@ jobject Java_tinyb_dbus_DBusManager_getDevices(JNIEnv *env, jobject obj) BluetoothManager *manager = getInstance<BluetoothManager>(env, obj); std::vector<std::unique_ptr<BluetoothDevice>> array = manager->get_devices(); - jobject result = convert_vector_uniqueptr_to_jarraylist<BluetoothDevice>(env, array, - "(J)V"); + jobject result = convert_vector_uniqueptr_to_jarraylist<std::vector<std::unique_ptr<BluetoothDevice>>, BluetoothDevice>( + env, array, "(J)V"); return result; } catch(...) { rethrow_and_raise_java_exception(env); @@ -236,8 +237,8 @@ jobject Java_tinyb_dbus_DBusManager_getServices(JNIEnv *env, jobject obj) BluetoothManager *manager = getInstance<BluetoothManager>(env, obj); std::vector<std::unique_ptr<BluetoothGattService>> array = manager->get_services(); - jobject result = convert_vector_uniqueptr_to_jarraylist<BluetoothGattService>(env, array, - "(J)V"); + jobject result = convert_vector_uniqueptr_to_jarraylist<std::vector<std::unique_ptr<BluetoothGattService>>, BluetoothGattService>( + env, array, "(J)V"); return result; } catch(...) { rethrow_and_raise_java_exception(env); diff --git a/scripts/build.sh b/scripts/build.sh index 67703c24..0b4b7e80 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -28,10 +28,10 @@ buildit() { mkdir -p build-$archabi cd build-$archabi CLANG_ARGS="-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++" - cmake $CLANG_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/dist-$archabi -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TESTING=ON .. + # cmake $CLANG_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/dist-$archabi -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TESTING=ON .. + cmake $CLANG_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/dist-$archabi -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TESTING=ON -DDEBUG=ON .. # cmake $CLANG_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/dist-$archabi -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TESTING=ON -DGPROF=ON .. # cmake $CLANG_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/dist-$archabi -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TESTING=ON -DPERF_ANALYSIS=ON .. - # cmake $CLANG_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/dist-$archabi -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TESTING=ON -DDEBUG=ON .. # cmake $CLANG_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/dist-$archabi -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TESTING=ON -DDEBUG=ON -DINSTRUMENTATION=ON .. # cmake $CLANG_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/dist-$archabi -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TESTING=ON -DDEBUG=ON -DINSTRUMENTATION_UNDEFINED=ON .. # cmake $CLANG_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/dist-$archabi -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TESTING=ON -DDEBUG=ON -DINSTRUMENTATION_THREAD=ON .. |