Skip to content

Commit

Permalink
Add missing cast in generated array code
Browse files Browse the repository at this point in the history
Fixes #338
  • Loading branch information
robert-ancell committed Mar 28, 2022
1 parent a74f713 commit ed732a3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
24 changes: 12 additions & 12 deletions lib/src/dbus_dart_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -327,29 +327,29 @@ class DBusArrayType extends DBusDartType {
String dbusToNative(String name) {
switch (childSignature.value) {
case 'y':
return '$name.mapByte().toList()';
return '($name as DBusArray).mapByte().toList()';
case 'n':
return '$name.mapInt16().toList()';
return '($name as DBusArray).mapInt16().toList()';
case 'q':
return '$name.mapUint16().toList()';
return '($name as DBusArray).mapUint16().toList()';
case 'i':
return '$name.mapInt32().toList()';
return '($name as DBusArray).mapInt32().toList()';
case 'u':
return '$name.mapUint32().toList()';
return '($name as DBusArray).mapUint32().toList()';
case 'x':
return '$name.mapInt64().toList()';
return '($name as DBusArray).mapInt64().toList()';
case 't':
return '$name.mapUint64().toList()';
return '($name as DBusArray).mapUint64().toList()';
case 'd':
return '$name.mapDouble().toList()';
return '($name as DBusArray).mapDouble().toList()';
case 's':
return '$name.mapString().toList()';
return '($name as DBusArray).mapString().toList()';
case 'o':
return '$name.objectPath().toList()';
return '($name as DBusArray).objectPath().toList()';
case 'g':
return '$name.signature().toList()';
return '($name as DBusArray).signature().toList()';
case 'v':
return '$name.mapVariant().toList()';
return '($name as DBusArray).mapVariant().toList()';
default:
var childType = getDartType(childSignature);
var convertedValue = childType.dbusToNative('child');
Expand Down
2 changes: 1 addition & 1 deletion test/generated-code/method-multiple-inputs.server.out
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ComExampleTest extends DBusObject {
if (methodCall.signature != DBusSignature('ybnqiuxtdsogv(si)ayabanaqaiauaxatadasaoagava(si)aasa{sv}a{us}a{sa{sv}}')) {
return DBusMethodErrorResponse.invalidArgs();
}
return doHello((methodCall.values[0] as DBusByte).value, (methodCall.values[1] as DBusBoolean).value, (methodCall.values[2] as DBusInt16).value, (methodCall.values[3] as DBusUint16).value, (methodCall.values[4] as DBusInt32).value, (methodCall.values[5] as DBusUint32).value, (methodCall.values[6] as DBusInt64).value, (methodCall.values[7] as DBusUint64).value, (methodCall.values[8] as DBusDouble).value, (methodCall.values[9] as DBusString).value, (methodCall.values[10] as DBusObjectPath).value, methodCall.values[11] as DBusSignature, (methodCall.values[12] as DBusVariant).value, methodCall.values[13] as DBusStruct, methodCall.values[14].mapByte().toList(), (methodCall.values[15] as DBusArray).children.map((child) => (child as DBusBoolean).value).toList(), methodCall.values[16].mapInt16().toList(), methodCall.values[17].mapUint16().toList(), methodCall.values[18].mapInt32().toList(), methodCall.values[19].mapUint32().toList(), methodCall.values[20].mapInt64().toList(), methodCall.values[21].mapUint64().toList(), methodCall.values[22].mapDouble().toList(), methodCall.values[23].mapString().toList(), methodCall.values[24].objectPath().toList(), methodCall.values[25].signature().toList(), methodCall.values[26].mapVariant().toList(), (methodCall.values[27] as DBusArray).children.map((child) => child as DBusStruct).toList(), (methodCall.values[28] as DBusArray).children.map((child) => child.mapString().toList()).toList(), (methodCall.values[29] as DBusDict).mapStringVariant(), (methodCall.values[30] as DBusDict).children.map((key, value) => MapEntry((key as DBusUint32).value, (value as DBusString).value)), (methodCall.values[31] as DBusDict).children.map((key, value) => MapEntry((key as DBusString).value, (value as DBusDict).mapStringVariant())));
return doHello((methodCall.values[0] as DBusByte).value, (methodCall.values[1] as DBusBoolean).value, (methodCall.values[2] as DBusInt16).value, (methodCall.values[3] as DBusUint16).value, (methodCall.values[4] as DBusInt32).value, (methodCall.values[5] as DBusUint32).value, (methodCall.values[6] as DBusInt64).value, (methodCall.values[7] as DBusUint64).value, (methodCall.values[8] as DBusDouble).value, (methodCall.values[9] as DBusString).value, (methodCall.values[10] as DBusObjectPath).value, methodCall.values[11] as DBusSignature, (methodCall.values[12] as DBusVariant).value, methodCall.values[13] as DBusStruct, (methodCall.values[14] as DBusArray).mapByte().toList(), (methodCall.values[15] as DBusArray).children.map((child) => (child as DBusBoolean).value).toList(), (methodCall.values[16] as DBusArray).mapInt16().toList(), (methodCall.values[17] as DBusArray).mapUint16().toList(), (methodCall.values[18] as DBusArray).mapInt32().toList(), (methodCall.values[19] as DBusArray).mapUint32().toList(), (methodCall.values[20] as DBusArray).mapInt64().toList(), (methodCall.values[21] as DBusArray).mapUint64().toList(), (methodCall.values[22] as DBusArray).mapDouble().toList(), (methodCall.values[23] as DBusArray).mapString().toList(), (methodCall.values[24] as DBusArray).objectPath().toList(), (methodCall.values[25] as DBusArray).signature().toList(), (methodCall.values[26] as DBusArray).mapVariant().toList(), (methodCall.values[27] as DBusArray).children.map((child) => child as DBusStruct).toList(), (methodCall.values[28] as DBusArray).children.map((child) => (child as DBusArray).mapString().toList()).toList(), (methodCall.values[29] as DBusDict).mapStringVariant(), (methodCall.values[30] as DBusDict).children.map((key, value) => MapEntry((key as DBusUint32).value, (value as DBusString).value)), (methodCall.values[31] as DBusDict).children.map((key, value) => MapEntry((key as DBusString).value, (value as DBusDict).mapStringVariant())));
} else {
return DBusMethodErrorResponse.unknownMethod();
}
Expand Down
2 changes: 1 addition & 1 deletion test/generated-code/properties.client.out
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class ComExampleTest extends DBusRemoteObject {
/// Gets com.example.Test.ArrayProperty
Future<List<int>> getArrayProperty() async {
var value = await getProperty('com.example.Test', 'ArrayProperty', signature: DBusSignature('ay'));
return value.mapByte().toList();
return (value as DBusArray).mapByte().toList();
}

/// Sets com.example.Test.ArrayProperty
Expand Down
2 changes: 1 addition & 1 deletion test/generated-code/properties.server.out
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class ComExampleTest extends DBusObject {
if (value.signature != DBusSignature('ay')) {
return DBusMethodErrorResponse.invalidArgs();
}
return setArrayProperty(value.mapByte().toList());
return setArrayProperty((value as DBusArray).mapByte().toList());
} else if (name == 'DictProperty') {
if (value.signature != DBusSignature('a{sv}')) {
return DBusMethodErrorResponse.invalidArgs();
Expand Down
26 changes: 13 additions & 13 deletions test/generated-code/signal-multiple-args.client.out
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ class ComExampleTestEvent extends DBusSignal {
DBusSignature get signature_value => values[11] as DBusSignature;
DBusValue get variant_value => (values[12] as DBusVariant).value;
DBusStruct get struct_value => values[13] as DBusStruct;
List<int> get array_value_y => values[14].mapByte().toList();
List<int> get array_value_y => (values[14] as DBusArray).mapByte().toList();
List<bool> get array_value_b => (values[15] as DBusArray).children.map((child) => (child as DBusBoolean).value).toList();
List<int> get array_value_n => values[16].mapInt16().toList();
List<int> get array_value_q => values[17].mapUint16().toList();
List<int> get array_value_u => values[18].mapInt32().toList();
List<int> get array_value_n_ => values[19].mapUint32().toList();
List<int> get array_value_x => values[20].mapInt64().toList();
List<int> get array_value_t => values[21].mapUint64().toList();
List<double> get array_value_d => values[22].mapDouble().toList();
List<String> get array_value_s => values[23].mapString().toList();
List<String> get array_value_o => values[24].objectPath().toList();
List<DBusSignature> get array_value_g => values[25].signature().toList();
List<DBusValue> get array_value_v => values[26].mapVariant().toList();
List<int> get array_value_n => (values[16] as DBusArray).mapInt16().toList();
List<int> get array_value_q => (values[17] as DBusArray).mapUint16().toList();
List<int> get array_value_u => (values[18] as DBusArray).mapInt32().toList();
List<int> get array_value_n_ => (values[19] as DBusArray).mapUint32().toList();
List<int> get array_value_x => (values[20] as DBusArray).mapInt64().toList();
List<int> get array_value_t => (values[21] as DBusArray).mapUint64().toList();
List<double> get array_value_d => (values[22] as DBusArray).mapDouble().toList();
List<String> get array_value_s => (values[23] as DBusArray).mapString().toList();
List<String> get array_value_o => (values[24] as DBusArray).objectPath().toList();
List<DBusSignature> get array_value_g => (values[25] as DBusArray).signature().toList();
List<DBusValue> get array_value_v => (values[26] as DBusArray).mapVariant().toList();
List<DBusStruct> get array_value_struct => (values[27] as DBusArray).children.map((child) => child as DBusStruct).toList();
List<List<String>> get array_value_array => (values[28] as DBusArray).children.map((child) => child.mapString().toList()).toList();
List<List<String>> get array_value_array => (values[28] as DBusArray).children.map((child) => (child as DBusArray).mapString().toList()).toList();
Map<String, DBusValue> get dict_value_sv => (values[29] as DBusDict).mapStringVariant();
Map<int, String> get dict_value_us => (values[30] as DBusDict).children.map((key, value) => MapEntry((key as DBusUint32).value, (value as DBusString).value));
Map<String, Map<String, DBusValue>> get dict_value_dict => (values[31] as DBusDict).children.map((key, value) => MapEntry((key as DBusString).value, (value as DBusDict).mapStringVariant()));
Expand Down

0 comments on commit ed732a3

Please sign in to comment.