From ef02d87965bb281fe4383737232b84804656126c Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Fri, 17 Nov 2023 09:30:23 +1300 Subject: [PATCH] Fix generated code that uses DBusObjectPath --- lib/src/dbus_dart_type.dart | 7 ++++++- test/generated-code/method-multiple-inputs.client.out | 4 ++-- test/generated-code/method-multiple-inputs.server.out | 2 +- test/generated-code/properties.client.out | 6 +++--- test/generated-code/properties.server.out | 2 +- test/generated-code/signal-multiple-args.client.out | 4 ++-- test/generated-code/signal-multiple-args.server.out | 4 ++-- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/src/dbus_dart_type.dart b/lib/src/dbus_dart_type.dart index 6a9bd75..7a88aaa 100644 --- a/lib/src/dbus_dart_type.dart +++ b/lib/src/dbus_dart_type.dart @@ -214,9 +214,14 @@ class DBusStringType extends DBusDartType { /// Generates Dart code for the object path D-Bus type. class DBusObjectPathType extends DBusStringType { + @override + String get nativeType { + return 'DBusObjectPath'; + } + @override String nativeToDBus(String name) { - return 'DBusObjectPath($name)'; + return name; } @override diff --git a/test/generated-code/method-multiple-inputs.client.out b/test/generated-code/method-multiple-inputs.client.out index 0a036a1..a39ba19 100644 --- a/test/generated-code/method-multiple-inputs.client.out +++ b/test/generated-code/method-multiple-inputs.client.out @@ -4,7 +4,7 @@ class ComExampleTest extends DBusRemoteObject { ComExampleTest(DBusClient client, String destination, DBusObjectPath path) : super(client, name: destination, path: path); /// Invokes com.example.Test.Hello() - Future callHello(int byte_value, bool boolean_value, int int16_value, int uint16_value, int int32_value, int uint32_value, int int64_value, int uint64_value, double double_value, String string_value, String object_path_value, DBusSignature signature_value, DBusValue variant_value, ResourceHandle unix_fd_value, List struct_value, List array_value_y, List array_value_b, List array_value_n, List array_value_q, List array_value_u, List array_value_n, List array_value_x, List array_value_t, List array_value_d, List array_value_s, List array_value_o, List array_value_g, List array_value_v, List array_value_h, List> array_value_struct, List> array_value_array, Map dict_value_sv, Map dict_value_us, Map> dict_value_dict, {bool noAutoStart = false, bool allowInteractiveAuthorization = false}) async { - await callMethod('com.example.Test', 'Hello', [DBusByte(byte_value), DBusBoolean(boolean_value), DBusInt16(int16_value), DBusUint16(uint16_value), DBusInt32(int32_value), DBusUint32(uint32_value), DBusInt64(int64_value), DBusUint64(uint64_value), DBusDouble(double_value), DBusString(string_value), DBusObjectPath(object_path_value), signature_value, DBusVariant(variant_value), DBusUnixFd(unix_fd_value), struct_value, DBusArray.byte(array_value_y), DBusArray.boolean(array_value_b), DBusArray.int16(array_value_n), DBusArray.uint16(array_value_q), DBusArray.int32(array_value_u), DBusArray.uint32(array_value_n), DBusArray.int64(array_value_x), DBusArray.uint64(array_value_t), DBusArray.double(array_value_d), DBusArray.string(array_value_s), DBusArray.objectPath(array_value_o), DBusArray.signature(array_value_g), DBusArray.variant(array_value_v), DBusArray.unixFd(array_value_h), DBusArray(DBusSignature('(si)'), array_value_struct.map((child) => child)), DBusArray(DBusSignature('as'), array_value_array.map((child) => DBusArray.string(child))), DBusDict.stringVariant(dict_value_sv), DBusDict(DBusSignature('u'), DBusSignature('s'), dict_value_us.map((key, value) => MapEntry(DBusUint32(key), DBusString(value)))), DBusDict(DBusSignature('s'), DBusSignature('a{sv}'), dict_value_dict.map((key, value) => MapEntry(DBusString(key), DBusDict.stringVariant(value))))], replySignature: DBusSignature(''), noAutoStart: noAutoStart, allowInteractiveAuthorization: allowInteractiveAuthorization); + Future callHello(int byte_value, bool boolean_value, int int16_value, int uint16_value, int int32_value, int uint32_value, int int64_value, int uint64_value, double double_value, String string_value, DBusObjectPath object_path_value, DBusSignature signature_value, DBusValue variant_value, ResourceHandle unix_fd_value, List struct_value, List array_value_y, List array_value_b, List array_value_n, List array_value_q, List array_value_u, List array_value_n, List array_value_x, List array_value_t, List array_value_d, List array_value_s, List array_value_o, List array_value_g, List array_value_v, List array_value_h, List> array_value_struct, List> array_value_array, Map dict_value_sv, Map dict_value_us, Map> dict_value_dict, {bool noAutoStart = false, bool allowInteractiveAuthorization = false}) async { + await callMethod('com.example.Test', 'Hello', [DBusByte(byte_value), DBusBoolean(boolean_value), DBusInt16(int16_value), DBusUint16(uint16_value), DBusInt32(int32_value), DBusUint32(uint32_value), DBusInt64(int64_value), DBusUint64(uint64_value), DBusDouble(double_value), DBusString(string_value), object_path_value, signature_value, DBusVariant(variant_value), DBusUnixFd(unix_fd_value), struct_value, DBusArray.byte(array_value_y), DBusArray.boolean(array_value_b), DBusArray.int16(array_value_n), DBusArray.uint16(array_value_q), DBusArray.int32(array_value_u), DBusArray.uint32(array_value_n), DBusArray.int64(array_value_x), DBusArray.uint64(array_value_t), DBusArray.double(array_value_d), DBusArray.string(array_value_s), DBusArray.objectPath(array_value_o), DBusArray.signature(array_value_g), DBusArray.variant(array_value_v), DBusArray.unixFd(array_value_h), DBusArray(DBusSignature('(si)'), array_value_struct.map((child) => child)), DBusArray(DBusSignature('as'), array_value_array.map((child) => DBusArray.string(child))), DBusDict.stringVariant(dict_value_sv), DBusDict(DBusSignature('u'), DBusSignature('s'), dict_value_us.map((key, value) => MapEntry(DBusUint32(key), DBusString(value)))), DBusDict(DBusSignature('s'), DBusSignature('a{sv}'), dict_value_dict.map((key, value) => MapEntry(DBusString(key), DBusDict.stringVariant(value))))], replySignature: DBusSignature(''), noAutoStart: noAutoStart, allowInteractiveAuthorization: allowInteractiveAuthorization); } } diff --git a/test/generated-code/method-multiple-inputs.server.out b/test/generated-code/method-multiple-inputs.server.out index 29dad40..33d0c4d 100644 --- a/test/generated-code/method-multiple-inputs.server.out +++ b/test/generated-code/method-multiple-inputs.server.out @@ -5,7 +5,7 @@ class ComExampleTest extends DBusObject { ComExampleTest({DBusObjectPath path = const DBusObjectPath.unchecked('/')}) : super(path); /// Implementation of com.example.Test.Hello() - Future doHello(int byte_value, bool boolean_value, int int16_value, int uint16_value, int int32_value, int uint32_value, int int64_value, int uint64_value, double double_value, String string_value, String object_path_value, DBusSignature signature_value, DBusValue variant_value, ResourceHandle unix_fd_value, List struct_value, List array_value_y, List array_value_b, List array_value_n, List array_value_q, List array_value_u, List array_value_n, List array_value_x, List array_value_t, List array_value_d, List array_value_s, List array_value_o, List array_value_g, List array_value_v, List array_value_h, List> array_value_struct, List> array_value_array, Map dict_value_sv, Map dict_value_us, Map> dict_value_dict) async { + Future doHello(int byte_value, bool boolean_value, int int16_value, int uint16_value, int int32_value, int uint32_value, int int64_value, int uint64_value, double double_value, String string_value, DBusObjectPath object_path_value, DBusSignature signature_value, DBusValue variant_value, ResourceHandle unix_fd_value, List struct_value, List array_value_y, List array_value_b, List array_value_n, List array_value_q, List array_value_u, List array_value_n, List array_value_x, List array_value_t, List array_value_d, List array_value_s, List array_value_o, List array_value_g, List array_value_v, List array_value_h, List> array_value_struct, List> array_value_array, Map dict_value_sv, Map dict_value_us, Map> dict_value_dict) async { return DBusMethodErrorResponse.failed('com.example.Test.Hello() not implemented'); } diff --git a/test/generated-code/properties.client.out b/test/generated-code/properties.client.out index 1866bd9..888d598 100644 --- a/test/generated-code/properties.client.out +++ b/test/generated-code/properties.client.out @@ -114,14 +114,14 @@ class ComExampleTest extends DBusRemoteObject { } /// Gets com.example.Test.ObjectPathProperty - Future getObjectPathProperty() async { + Future getObjectPathProperty() async { var value = await getProperty('com.example.Test', 'ObjectPathProperty', signature: DBusSignature('o')); return value.asObjectPath(); } /// Sets com.example.Test.ObjectPathProperty - Future setObjectPathProperty (String value) async { - await setProperty('com.example.Test', 'ObjectPathProperty', DBusObjectPath(value)); + Future setObjectPathProperty (DBusObjectPath value) async { + await setProperty('com.example.Test', 'ObjectPathProperty', value); } /// Gets com.example.Test.SignatureProperty diff --git a/test/generated-code/properties.server.out b/test/generated-code/properties.server.out index 8cad3c2..19c804b 100644 --- a/test/generated-code/properties.server.out +++ b/test/generated-code/properties.server.out @@ -110,7 +110,7 @@ class ComExampleTest extends DBusObject { } /// Sets property com.example.Test.ObjectPathProperty - Future setObjectPathProperty(String value) async { + Future setObjectPathProperty(DBusObjectPath value) async { return DBusMethodErrorResponse.failed('Set com.example.Test.ObjectPathProperty not implemented'); } diff --git a/test/generated-code/signal-multiple-args.client.out b/test/generated-code/signal-multiple-args.client.out index 1b2e36b..7ede87d 100644 --- a/test/generated-code/signal-multiple-args.client.out +++ b/test/generated-code/signal-multiple-args.client.out @@ -12,7 +12,7 @@ class ComExampleTestEvent extends DBusSignal { int get uint64_value => values[7].asUint64(); double get double_value => values[8].asDouble(); String get string_value => values[9].asString(); - String get object_path_value => values[10].asObjectPath(); + DBusObjectPath get object_path_value => values[10].asObjectPath(); DBusSignature get signature_value => values[11].asSignature(); DBusValue get variant_value => values[12].asVariant(); ResourceHandle get unix_fd_value => values[13].asUnixFd(); @@ -27,7 +27,7 @@ class ComExampleTestEvent extends DBusSignal { List get array_value_t => values[22].asUint64Array().toList(); List get array_value_d => values[23].asDoubleArray().toList(); List get array_value_s => values[24].asStringArray().toList(); - List get array_value_o => values[25].asObjectPathArray().toList(); + List get array_value_o => values[25].asObjectPathArray().toList(); List get array_value_g => values[26].asSignatureArray().toList(); List get array_value_v => values[27].asVariantArray().toList(); List get array_value_h => values[28].asUnixFdArray().toList(); diff --git a/test/generated-code/signal-multiple-args.server.out b/test/generated-code/signal-multiple-args.server.out index 95215aa..b08b85e 100644 --- a/test/generated-code/signal-multiple-args.server.out +++ b/test/generated-code/signal-multiple-args.server.out @@ -5,8 +5,8 @@ class ComExampleTest extends DBusObject { ComExampleTest({DBusObjectPath path = const DBusObjectPath.unchecked('/')}) : super(path); /// Emits signal com.example.Test.Event - Future emitEvent(int byte_value, bool boolean_value, int int16_value, int uint16_value, int int32_value, int uint32_value, int int64_value, int uint64_value, double double_value, String string_value, String object_path_value, DBusSignature signature_value, DBusValue variant_value, ResourceHandle unix_fd_value, List struct_value, List array_value_y, List array_value_b, List array_value_n, List array_value_q, List array_value_u, List array_value_n_, List array_value_x, List array_value_t, List array_value_d, List array_value_s, List array_value_o, List array_value_g, List array_value_v, List array_value_h, List> array_value_struct, List> array_value_array, Map dict_value_sv, Map dict_value_us, Map> dict_value_dict) async { - await emitSignal('com.example.Test', 'Event', [DBusByte(byte_value), DBusBoolean(boolean_value), DBusInt16(int16_value), DBusUint16(uint16_value), DBusInt32(int32_value), DBusUint32(uint32_value), DBusInt64(int64_value), DBusUint64(uint64_value), DBusDouble(double_value), DBusString(string_value), DBusObjectPath(object_path_value), signature_value, DBusVariant(variant_value), DBusUnixFd(unix_fd_value), struct_value, DBusArray.byte(array_value_y), DBusArray.boolean(array_value_b), DBusArray.int16(array_value_n), DBusArray.uint16(array_value_q), DBusArray.int32(array_value_u), DBusArray.uint32(array_value_n_), DBusArray.int64(array_value_x), DBusArray.uint64(array_value_t), DBusArray.double(array_value_d), DBusArray.string(array_value_s), DBusArray.objectPath(array_value_o), DBusArray.signature(array_value_g), DBusArray.variant(array_value_v), DBusArray.unixFd(array_value_h), DBusArray(DBusSignature('(si)'), array_value_struct.map((child) => child)), DBusArray(DBusSignature('as'), array_value_array.map((child) => DBusArray.string(child))), DBusDict.stringVariant(dict_value_sv), DBusDict(DBusSignature('u'), DBusSignature('s'), dict_value_us.map((key, value) => MapEntry(DBusUint32(key), DBusString(value)))), DBusDict(DBusSignature('s'), DBusSignature('a{sv}'), dict_value_dict.map((key, value) => MapEntry(DBusString(key), DBusDict.stringVariant(value))))]); + Future emitEvent(int byte_value, bool boolean_value, int int16_value, int uint16_value, int int32_value, int uint32_value, int int64_value, int uint64_value, double double_value, String string_value, DBusObjectPath object_path_value, DBusSignature signature_value, DBusValue variant_value, ResourceHandle unix_fd_value, List struct_value, List array_value_y, List array_value_b, List array_value_n, List array_value_q, List array_value_u, List array_value_n_, List array_value_x, List array_value_t, List array_value_d, List array_value_s, List array_value_o, List array_value_g, List array_value_v, List array_value_h, List> array_value_struct, List> array_value_array, Map dict_value_sv, Map dict_value_us, Map> dict_value_dict) async { + await emitSignal('com.example.Test', 'Event', [DBusByte(byte_value), DBusBoolean(boolean_value), DBusInt16(int16_value), DBusUint16(uint16_value), DBusInt32(int32_value), DBusUint32(uint32_value), DBusInt64(int64_value), DBusUint64(uint64_value), DBusDouble(double_value), DBusString(string_value), object_path_value, signature_value, DBusVariant(variant_value), DBusUnixFd(unix_fd_value), struct_value, DBusArray.byte(array_value_y), DBusArray.boolean(array_value_b), DBusArray.int16(array_value_n), DBusArray.uint16(array_value_q), DBusArray.int32(array_value_u), DBusArray.uint32(array_value_n_), DBusArray.int64(array_value_x), DBusArray.uint64(array_value_t), DBusArray.double(array_value_d), DBusArray.string(array_value_s), DBusArray.objectPath(array_value_o), DBusArray.signature(array_value_g), DBusArray.variant(array_value_v), DBusArray.unixFd(array_value_h), DBusArray(DBusSignature('(si)'), array_value_struct.map((child) => child)), DBusArray(DBusSignature('as'), array_value_array.map((child) => DBusArray.string(child))), DBusDict.stringVariant(dict_value_sv), DBusDict(DBusSignature('u'), DBusSignature('s'), dict_value_us.map((key, value) => MapEntry(DBusUint32(key), DBusString(value)))), DBusDict(DBusSignature('s'), DBusSignature('a{sv}'), dict_value_dict.map((key, value) => MapEntry(DBusString(key), DBusDict.stringVariant(value))))]); } @override