Skip to content

Commit

Permalink
Remove DefaultFormat, use null for unspecified class format
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier committed Jul 31, 2024
1 parent 8204de3 commit 10c57a6
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 35 deletions.
2 changes: 1 addition & 1 deletion cpp/src/slice2cs/Gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace
{
case DefaultFormat:
{
return "Ice.FormatType.DefaultFormat";
return "null";
}
case CompactFormat:
{
Expand Down
2 changes: 1 addition & 1 deletion csharp/src/Ice/CurrentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static OutgoingResponse createOutgoingResponse<TResult>(
this Current current,
TResult result,
Action<OutputStream, TResult> marshal,
FormatType formatType = FormatType.DefaultFormat)
FormatType? formatType = null)
{
OutputStream ostr = current.startReplyStream();
if (current.requestId != 0)
Expand Down
1 change: 0 additions & 1 deletion csharp/src/Ice/FormatType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Ice;
/// </summary>
public enum FormatType
{
DefaultFormat,
CompactFormat,
SlicedFormat
}
2 changes: 1 addition & 1 deletion csharp/src/Ice/Internal/OpaqueEndpointI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public OpaqueEndpointI(short type, Ice.InputStream s)
//
public override void streamWrite(Ice.OutputStream s)
{
s.startEncapsulation(_rawEncoding, Ice.FormatType.DefaultFormat);
s.startEncapsulation(_rawEncoding);
s.writeBlob(_rawBytes);
s.endEncapsulation();
}
Expand Down
4 changes: 2 additions & 2 deletions csharp/src/Ice/Internal/OutgoingAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ protected void invoke(string operation, bool synchronous)

public void invoke(string operation,
Ice.OperationMode mode,
Ice.FormatType format,
Ice.FormatType? format,
Dictionary<string, string> context,
bool synchronous,
System.Action<Ice.OutputStream> write)
Expand Down Expand Up @@ -1144,7 +1144,7 @@ public OutgoingAsyncT(Ice.ObjectPrxHelperBase prx,

public void invoke(string operation,
Ice.OperationMode mode,
Ice.FormatType format,
Ice.FormatType? format,
Dictionary<string, string> context,
bool synchronous,
System.Action<Ice.OutputStream> write = null,
Expand Down
32 changes: 8 additions & 24 deletions csharp/src/Ice/OutputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#nullable enable

using System.Diagnostics;
using System.Net.Http.Headers;
using System.Text;

using Protocol = Ice.Internal.Protocol;

namespace Ice;
Expand All @@ -22,8 +21,6 @@ public sealed class OutputStream
/// <param name="format">The class format.</param>
public OutputStream(EncodingVersion? encoding = null, FormatType format = FormatType.CompactFormat)
{
Debug.Assert(format != FormatType.DefaultFormat); // TODO: remove default format from enum

_buf = new Internal.Buffer();
_encoding = encoding ?? Util.currentEncoding;
_format = format;
Expand Down Expand Up @@ -68,15 +65,6 @@ public void clear()
}
}

/// <summary>
/// Sets the encoding format for class and exception instances.
/// </summary>
/// <param name="fmt">The encoding format.</param>
public void setFormat(FormatType fmt)
{
_format = fmt;
}

/// <summary>
/// Retrieves the closure object associated with this stream.
/// </summary>
Expand Down Expand Up @@ -225,16 +213,17 @@ public void startEncapsulation()
}
else
{
startEncapsulation(_encoding, FormatType.DefaultFormat);
startEncapsulation(_encoding, format: null);
}
}

/// <summary>
/// Writes the start of an encapsulation to the stream.
/// </summary>
/// <param name="encoding">The encoding version of the encapsulation.</param>
/// <param name="format">Specify the compact or sliced format.</param>
public void startEncapsulation(EncodingVersion encoding, FormatType format)
/// <param name="format">Specify the compact or sliced format. When null, use the OutputStream's class format.
/// </param>
public void startEncapsulation(EncodingVersion encoding, FormatType? format = null)
{
Protocol.checkSupportedEncoding(encoding);

Expand All @@ -251,7 +240,7 @@ public void startEncapsulation(EncodingVersion encoding, FormatType format)
curr.next = _encapsStack;
_encapsStack = curr;

_encapsStack.format = format;
_encapsStack.format = format ?? _format;
_encapsStack.setEncoding(encoding);
_encapsStack.start = _buf.b.position();

Expand Down Expand Up @@ -1771,7 +1760,7 @@ public void expand(int n)

private Ice.Internal.Buffer _buf;
private object? _closure;
private FormatType _format;
private readonly FormatType _format;

private enum SliceType { NoSlice, ValueSlice, ExceptionSlice }

Expand Down Expand Up @@ -2341,7 +2330,7 @@ internal void setEncoding(EncodingVersion encoding)
internal int start;
internal EncodingVersion encoding;
internal bool encoding_1_0;
internal FormatType format = FormatType.DefaultFormat;
internal FormatType format;

internal EncapsEncoder? encoder;

Expand Down Expand Up @@ -2380,11 +2369,6 @@ private void initEncaps()
_encapsStack.setEncoding(_encoding);
}

if (_encapsStack.format == FormatType.DefaultFormat)
{
_encapsStack.format = _format;
}

if (_encapsStack.encoder == null) // Lazy initialization.
{
if (_encapsStack.encoding_1_0)
Expand Down
8 changes: 4 additions & 4 deletions csharp/src/Ice/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ private void iceI_ice_isA(string id,
iceCheckAsyncTwowayOnly(_ice_isA_name);
getOutgoingAsync<bool>(completed).invoke(_ice_isA_name,
OperationMode.Idempotent,
FormatType.DefaultFormat,
FormatType.CompactFormat,
context,
synchronous,
(OutputStream os) => { os.writeString(id); },
Expand Down Expand Up @@ -647,7 +647,7 @@ private void iceI_ice_ping(Dictionary<string, string>? context, OutgoingAsyncCom
{
getOutgoingAsync<object>(completed).invoke(_ice_ping_name,
OperationMode.Idempotent,
FormatType.DefaultFormat,
FormatType.CompactFormat,
context,
synchronous);
}
Expand Down Expand Up @@ -702,7 +702,7 @@ private void iceI_ice_ids(Dictionary<string, string>? context, OutgoingAsyncComp
iceCheckAsyncTwowayOnly(_ice_ids_name);
getOutgoingAsync<string[]>(completed).invoke(_ice_ids_name,
OperationMode.Idempotent,
FormatType.DefaultFormat,
FormatType.CompactFormat,
context,
synchronous,
read: (InputStream iss) => { return iss.readStringSeq(); });
Expand Down Expand Up @@ -755,7 +755,7 @@ private void iceI_ice_id(Dictionary<string, string>? context,
{
getOutgoingAsync<string>(completed).invoke(_ice_id_name,
OperationMode.Idempotent,
FormatType.DefaultFormat,
FormatType.CompactFormat,
context,
synchronous,
read: (InputStream iss) => { return iss.readString(); });
Expand Down
2 changes: 1 addition & 1 deletion csharp/test/Ice/objects/UnexpectedObjectExceptionTestI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public override bool ice_invoke(byte[] inParams, out byte[] outParams, Ice.Curre
{
var communicator = current.adapter.getCommunicator();
var @out = new Ice.OutputStream(communicator);
@out.startEncapsulation(current.encoding, Ice.FormatType.DefaultFormat);
@out.startEncapsulation(current.encoding, FormatType.SlicedFormat);
var ae = new Test.AlsoEmpty();
@out.writeValue(ae);
@out.writePendingValues();
Expand Down

0 comments on commit 10c57a6

Please sign in to comment.