Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace 'byte' with 'ubyte'. #50

Merged
merged 1 commit into from
Jan 12, 2021
Merged

Conversation

quickfur
Copy link
Contributor

Because 'y' is unsigned in the DBus spec.

Fixes issue #49

Copy link
Collaborator

@WebFreak001 WebFreak001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are more uses of byte in all files, need to change those as well

@WebFreak001
Copy link
Collaborator

in thin.d there is a breaking change with toString now returning an unsigned number if stored as int8, but as this is closer to the spec it makes sense.

Here is the diff what I did in that file:

diff --git a/source/ddbus/thin.d b/source/ddbus/thin.d
index 727bf59..7be360c 100644
--- a/source/ddbus/thin.d
+++ b/source/ddbus/thin.d
@@ -222,7 +222,8 @@ struct DBusAny {

   union {
     ///
-    byte int8;
+    ubyte uint8;
+    deprecated("use uint8 instead") byte int8;
     ///
     short int16;
     ///
@@ -273,8 +274,8 @@ struct DBusAny {
    +/
   this(T)(T value) {
     static if (is(T == byte) || is(T == ubyte)) {
-      this(typeCode!byte, null, false);
-      int8 = cast(byte) value;
+      this(typeCode!ubyte, null, false);
+      uint8 = cast(ubyte) value;
     } else static if (is(T == short)) {
       this(typeCode!short, null, false);
       int16 = cast(short) value;
@@ -410,8 +411,8 @@ struct DBusAny {
   string toString() const {
     string valueStr;
     switch (type) {
-    case typeCode!byte:
-      valueStr = int8.to!string;
+    case typeCode!ubyte:
+      valueStr = uint8.to!string;
       break;
     case typeCode!short:
       valueStr = int16.to!string;
@@ -712,7 +713,7 @@ unittest {
     b.toString();
   }

-  test(cast(ubyte) 184, set!"int8"(DBusAny('y', null, false), cast(byte) 184));
+  test(cast(ubyte) 184, set!"uint8"(DBusAny('y', null, false), cast(byte) 184));
   test(cast(short) 184, set!"int16"(DBusAny('n', null, false), cast(short) 184));
   test(cast(ushort) 184, set!"uint16"(DBusAny('q', null, false), cast(ushort) 184));
   test(cast(int) 184, set!"int32"(DBusAny('i', null, false), cast(int) 184));
@@ -726,7 +727,7 @@ unittest {
   test(cast(ubyte[])[1, 2, 3], set!"binaryData"(DBusAny('a', ['y'], false),
       cast(ubyte[])[1, 2, 3]));

-  test(variant(cast(ubyte) 184), set!"int8"(DBusAny('y', null, true), cast(byte) 184));
+  test(variant(cast(ubyte) 184), set!"uint8"(DBusAny('y', null, true), cast(byte) 184));
   test(variant(cast(short) 184), set!"int16"(DBusAny('n', null, true), cast(short) 184));
   test(variant(cast(ushort) 184), set!"uint16"(DBusAny('q', null, true), cast(ushort) 184));
   test(variant(cast(int) 184), set!"int32"(DBusAny('i', null, true), cast(int) 184));

Because 'y' is unsigned in the DBus spec.
@quickfur
Copy link
Contributor Author

OK, should be fixed now.

@quickfur quickfur requested a review from WebFreak001 January 12, 2021 09:43
@WebFreak001 WebFreak001 merged commit f988709 into trishume:master Jan 12, 2021
@quickfur quickfur deleted the issue49 branch January 12, 2021 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants