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

ProtocolConstants: remove signatures. #322

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/Tmds.DBus.Protocol/MessageWriter.Basic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<byte> value)
{
WriteSignature(ProtocolConstants.StringSignature);
WriteSignature(Signature.String);
WriteString(value);
}

public void WriteVariantSignature(scoped ReadOnlySpan<byte> value)
{
WriteSignature(ProtocolConstants.SignatureSignature);
WriteSignature(Signature.Sig);
WriteSignature(value);
}

public void WriteVariantObjectPath(scoped ReadOnlySpan<byte> 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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tmds.DBus.Protocol/MessageWriter.Handle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public void WriteHandle(SafeHandle value)

public void WriteVariantHandle(SafeHandle value)
{
WriteSignature(ProtocolConstants.UnixFdSignature);
WriteSignature(Signature.UnixFd);
WriteHandle(value);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tmds.DBus.Protocol/MessageWriter.Header.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void WriteError(
{
WriteStructureStart();
WriteByte((byte)MessageHeader.Signature);
WriteVariantSignature(ProtocolConstants.StringSignature);
WriteVariantSignature(Signature.String);
}

WriteHeaderEnd(start);
Expand Down
17 changes: 0 additions & 17 deletions src/Tmds.DBus.Protocol/ProtocolConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<byte> ByteSignature => new byte[] { (byte)'y' };
public static ReadOnlySpan<byte> BooleanSignature => new byte[] { (byte)'b' };
public static ReadOnlySpan<byte> Int16Signature => new byte[] { (byte)'n' };
public static ReadOnlySpan<byte> UInt16Signature => new byte[] { (byte)'q' };
public static ReadOnlySpan<byte> Int32Signature => new byte[] { (byte)'i' };
public static ReadOnlySpan<byte> UInt32Signature => new byte[] { (byte)'u' };
public static ReadOnlySpan<byte> Int64Signature => new byte[] { (byte)'x' };
public static ReadOnlySpan<byte> UInt64Signature => new byte[] { (byte)'t' };
public static ReadOnlySpan<byte> DoubleSignature => new byte[] { (byte)'d' };
public static ReadOnlySpan<byte> UnixFdSignature => new byte[] { (byte)'h' };
public static ReadOnlySpan<byte> StringSignature => new byte[] { (byte)'s' };
public static ReadOnlySpan<byte> ObjectPathSignature => new byte[] { (byte)'o' };
public static ReadOnlySpan<byte> SignatureSignature => new byte[] { (byte)'g' };
public static ReadOnlySpan<byte> VariantSignature => new byte[] { (byte)'v' };

public const int StructAlignment = 8;
public const int UInt32Alignment = 4;

Expand Down
2 changes: 1 addition & 1 deletion src/Tmds.DBus.Protocol/VariantValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading