diff --git a/src/Tmds.DBus.Protocol/MessageWriter.Basic.cs b/src/Tmds.DBus.Protocol/MessageWriter.Basic.cs index bdf3da9..cc33aa0 100644 --- a/src/Tmds.DBus.Protocol/MessageWriter.Basic.cs +++ b/src/Tmds.DBus.Protocol/MessageWriter.Basic.cs @@ -56,91 +56,91 @@ public void WriteSignature(string s) public void WriteVariantBool(bool value) { - WriteSignature(ProtocolConstants.BooleanSignature); + WriteSignature(Signature.Boolean); WriteBool(value); } public void WriteVariantByte(byte value) { - WriteSignature(ProtocolConstants.ByteSignature); + WriteSignature(Signature.Byte); WriteByte(value); } public void WriteVariantInt16(short value) { - WriteSignature(ProtocolConstants.Int16Signature); + WriteSignature(Signature.Int16); WriteInt16(value); } public void WriteVariantUInt16(ushort value) { - WriteSignature(ProtocolConstants.UInt16Signature); + WriteSignature(Signature.UInt16); WriteUInt16(value); } public void WriteVariantInt32(int value) { - WriteSignature(ProtocolConstants.Int32Signature); + WriteSignature(Signature.Int32); WriteInt32(value); } public void WriteVariantUInt32(uint value) { - WriteSignature(ProtocolConstants.UInt32Signature); + WriteSignature(Signature.UInt32); WriteUInt32(value); } public void WriteVariantInt64(long value) { - WriteSignature(ProtocolConstants.Int64Signature); + WriteSignature(Signature.Int64); WriteInt64(value); } public void WriteVariantUInt64(ulong value) { - WriteSignature(ProtocolConstants.UInt64Signature); + WriteSignature(Signature.UInt64); WriteUInt64(value); } public void WriteVariantDouble(double value) { - WriteSignature(ProtocolConstants.DoubleSignature); + WriteSignature(Signature.Double); WriteDouble(value); } public void WriteVariantString(scoped ReadOnlySpan value) { - WriteSignature(ProtocolConstants.StringSignature); + WriteSignature(Signature.String); WriteString(value); } public void WriteVariantSignature(scoped ReadOnlySpan value) { - WriteSignature(ProtocolConstants.SignatureSignature); + WriteSignature(Signature.Sig); WriteSignature(value); } public void WriteVariantObjectPath(scoped ReadOnlySpan value) { - WriteSignature(ProtocolConstants.ObjectPathSignature); + WriteSignature(Signature.ObjectPath); WriteObjectPath(value); } public void WriteVariantString(string value) { - WriteSignature(ProtocolConstants.StringSignature); + WriteSignature(Signature.String); WriteString(value); } public void WriteVariantSignature(string value) { - WriteSignature(ProtocolConstants.SignatureSignature); + WriteSignature(Signature.Sig); WriteSignature(value); } public void WriteVariantObjectPath(string value) { - WriteSignature(ProtocolConstants.ObjectPathSignature); + WriteSignature(Signature.ObjectPath); WriteObjectPath(value); } diff --git a/src/Tmds.DBus.Protocol/MessageWriter.Handle.cs b/src/Tmds.DBus.Protocol/MessageWriter.Handle.cs index a473fea..f85a0d6 100644 --- a/src/Tmds.DBus.Protocol/MessageWriter.Handle.cs +++ b/src/Tmds.DBus.Protocol/MessageWriter.Handle.cs @@ -11,7 +11,7 @@ public void WriteHandle(SafeHandle value) public void WriteVariantHandle(SafeHandle value) { - WriteSignature(ProtocolConstants.UnixFdSignature); + WriteSignature(Signature.UnixFd); WriteHandle(value); } diff --git a/src/Tmds.DBus.Protocol/MessageWriter.Header.cs b/src/Tmds.DBus.Protocol/MessageWriter.Header.cs index f00b973..98629d1 100644 --- a/src/Tmds.DBus.Protocol/MessageWriter.Header.cs +++ b/src/Tmds.DBus.Protocol/MessageWriter.Header.cs @@ -120,7 +120,7 @@ public void WriteError( { WriteStructureStart(); WriteByte((byte)MessageHeader.Signature); - WriteVariantSignature(ProtocolConstants.StringSignature); + WriteVariantSignature(Signature.String); } WriteHeaderEnd(start); diff --git a/src/Tmds.DBus.Protocol/ProtocolConstants.cs b/src/Tmds.DBus.Protocol/ProtocolConstants.cs index b9d0537..6b37d09 100644 --- a/src/Tmds.DBus.Protocol/ProtocolConstants.cs +++ b/src/Tmds.DBus.Protocol/ProtocolConstants.cs @@ -3,23 +3,6 @@ namespace Tmds.DBus.Protocol; static class ProtocolConstants { public const int MaxSignatureLength = 256; - - // note: C# compiler treats these as static data. - public static ReadOnlySpan ByteSignature => new byte[] { (byte)'y' }; - public static ReadOnlySpan BooleanSignature => new byte[] { (byte)'b' }; - public static ReadOnlySpan Int16Signature => new byte[] { (byte)'n' }; - public static ReadOnlySpan UInt16Signature => new byte[] { (byte)'q' }; - public static ReadOnlySpan Int32Signature => new byte[] { (byte)'i' }; - public static ReadOnlySpan UInt32Signature => new byte[] { (byte)'u' }; - public static ReadOnlySpan Int64Signature => new byte[] { (byte)'x' }; - public static ReadOnlySpan UInt64Signature => new byte[] { (byte)'t' }; - public static ReadOnlySpan DoubleSignature => new byte[] { (byte)'d' }; - public static ReadOnlySpan UnixFdSignature => new byte[] { (byte)'h' }; - public static ReadOnlySpan StringSignature => new byte[] { (byte)'s' }; - public static ReadOnlySpan ObjectPathSignature => new byte[] { (byte)'o' }; - public static ReadOnlySpan SignatureSignature => new byte[] { (byte)'g' }; - public static ReadOnlySpan VariantSignature => new byte[] { (byte)'v' }; - public const int StructAlignment = 8; public const int UInt32Alignment = 4; diff --git a/src/Tmds.DBus.Protocol/VariantValue.cs b/src/Tmds.DBus.Protocol/VariantValue.cs index cc43e15..d5c1ee0 100644 --- a/src/Tmds.DBus.Protocol/VariantValue.cs +++ b/src/Tmds.DBus.Protocol/VariantValue.cs @@ -1719,7 +1719,7 @@ private void WriteValueTo(ref MessageWriter writer, int nestingOffset) nesting += nestingOffset; while (nesting > 1) { - writer.WriteSignature(ProtocolConstants.VariantSignature); + writer.WriteSignature(Protocol.Signature.Variant); nesting--; } if (nesting == 1)