Skip to content

Commit

Permalink
Remove sliceValues in JS and MATLAB
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier committed Jul 23, 2024
1 parent 3612209 commit 762aa7f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 85 deletions.
11 changes: 0 additions & 11 deletions js/src/Ice/Stream.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,6 @@ declare module "ice" {
//
compactIdResolver: (compactID: number) => string;

//
// Determines the behavior of the stream when extracting instances of Slice classes.
// A instance is "sliced" when a factory cannot be found for a Slice type ID.
// The stream's default behavior is to slice instances.
//
// If slicing is disabled and the stream encounters a Slice type ID
// during decoding for which no value factory is installed, it raises
// NoValueFactoryException.
//
sliceValues: boolean;

//
// Determines whether the stream logs messages about slicing instances of Slice values.
//
Expand Down
50 changes: 5 additions & 45 deletions js/src/Ice/Stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ class IndirectPatchEntry {
}

class EncapsDecoder {
constructor(stream, encaps, sliceValues, classGraphDepth, f) {
constructor(stream, encaps, classGraphDepth, f) {
this._stream = stream;
this._encaps = encaps;
this._sliceValues = sliceValues;
this._classGraphDepthMax = classGraphDepth;
this._classGraphDepth = 0;
this._valueFactoryManager = f;
Expand Down Expand Up @@ -232,8 +231,8 @@ class EncapsDecoder {
}

class EncapsDecoder10 extends EncapsDecoder {
constructor(stream, encaps, sliceValues, classGraphDepth, f) {
super(stream, encaps, sliceValues, classGraphDepth, f);
constructor(stream, encaps, classGraphDepth, f) {
super(stream, encaps, classGraphDepth, f);
this._sliceType = SliceType.NoSlice;
}

Expand Down Expand Up @@ -427,13 +426,6 @@ class EncapsDecoder10 extends EncapsDecoder {
break;
}

//
// If slicing is disabled, stop unmarshaling.
//
if (!this._sliceValues) {
throw new NoValueFactoryException("no value factory found and slicing is disabled", this._typeId);
}

//
// Slice off what we don't understand.
//
Expand Down Expand Up @@ -469,8 +461,8 @@ class EncapsDecoder10 extends EncapsDecoder {
}

class EncapsDecoder11 extends EncapsDecoder {
constructor(stream, encaps, sliceValues, classGraphDepth, f, r) {
super(stream, encaps, sliceValues, classGraphDepth, f);
constructor(stream, encaps, classGraphDepth, f, r) {
super(stream, encaps, classGraphDepth, f);
this._compactIdResolver = r;
this._current = null;
this._valueIdIndex = 1;
Expand Down Expand Up @@ -802,16 +794,6 @@ class EncapsDecoder11 extends EncapsDecoder {
break;
}

//
// If slicing is disabled, stop unmarshaling.
//
if (!this._sliceValues) {
throw new NoValueFactoryException(
"no value factory found and slicing is disabled",
this._current.typeId,
);
}

//
// Slice off what we don't understand.
//
Expand Down Expand Up @@ -1030,7 +1012,6 @@ export class InputStream {
this._encapsStack = null;
this._encapsCache = null;
this._closure = null;
this._sliceValues = true;
this._startSeq = -1;
this._sizePos = -1;
this._compactIdResolver = null;
Expand Down Expand Up @@ -1080,7 +1061,6 @@ export class InputStream {
}

this._startSeq = -1;
this._sliceValues = true;
}

swap(other) {
Expand All @@ -1090,7 +1070,6 @@ export class InputStream {
[other._encoding, this._encoding] = [this._encoding, other._encoding];
[other._traceSlicing, this._traceSlicing] = [this._traceSlicing, other._traceSlicing];
[other._closure, this._closure] = [this._closure, other.closure];
[other._sliceValues, this._sliceValues] = [this._sliceValues, other._sliceValues];
[other._classGraphDepthMax, this._classGraphDepthMax] = [this._classGraphDepthMax, other._classGraphDepthMax];

//
Expand Down Expand Up @@ -1726,15 +1705,13 @@ export class InputStream {
this._encapsStack.decoder = new EncapsDecoder10(
this,
this._encapsStack,
this._sliceValues,
this._classGraphDepthMax,
this._valueFactoryManager,
);
} else {
this._encapsStack.decoder = new EncapsDecoder11(
this,
this._encapsStack,
this._sliceValues,
this._classGraphDepthMax,
this._valueFactoryManager,
this._compactIdResolver,
Expand Down Expand Up @@ -1793,23 +1770,6 @@ export class InputStream {
this._compactIdResolver = value !== undefined ? value : null;
}

//
// Determines the behavior of the stream when extracting instances of Slice classes.
// A instance is "sliced" when a factory cannot be found for a Slice type ID.
// The stream's default behavior is to slice instances.
//
// If slicing is disabled and the stream encounters a Slice type ID
// during decoding for which no value factory is installed, it raises
// NoValueFactoryException.
//
get sliceValues() {
return this._sliceValues;
}

set sliceValues(value) {
this._sliceValues = value;
}

//
// Determines whether the stream logs messages about slicing instances of Slice values.
//
Expand Down
5 changes: 2 additions & 3 deletions matlab/lib/+Ice/InputStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -799,11 +799,11 @@ function initEncaps(obj)
valueFactoryManager = obj.communicator.getValueFactoryManager();
if obj.encapsStack.encoding_1_0
obj.encapsStack.decoder = ...
IceInternal.EncapsDecoder10(obj, obj.encapsStack, obj.sliceValues, valueFactoryManager, ...
IceInternal.EncapsDecoder10(obj, obj.encapsStack, valueFactoryManager, ...
obj.communicator.getClassResolver(), obj.classGraphDepthMax);
else
obj.encapsStack.decoder = ...
IceInternal.EncapsDecoder11(obj, obj.encapsStack, obj.sliceValues, valueFactoryManager, ...
IceInternal.EncapsDecoder11(obj, obj.encapsStack, valueFactoryManager, ...
obj.communicator.getClassResolver(), obj.classGraphDepthMax);
end
obj.encapsStackDecoder = obj.encapsStack.decoder;
Expand Down Expand Up @@ -836,7 +836,6 @@ function throwUOE(expectedType, v)
encapsStack
encapsStackDecoder
encapsCache
sliceValues logical = true
buf
pos int32 = 1
size int32
Expand Down
4 changes: 1 addition & 3 deletions matlab/lib/+IceInternal/EncapsDecoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

classdef (Abstract) EncapsDecoder < handle
methods
function obj = EncapsDecoder(is, encaps, sliceValues, valueFactoryManager, classResolver, classGraphDepthMax)
function obj = EncapsDecoder(is, encaps, valueFactoryManager, classResolver, classGraphDepthMax)
obj.is = is;
obj.encaps = encaps;
obj.sliceValues = sliceValues;
obj.valueFactoryManager = valueFactoryManager;
obj.classResolver = classResolver;
obj.classGraphDepthMax = classGraphDepthMax;
Expand Down Expand Up @@ -235,7 +234,6 @@ function unmarshal(obj, index, v)
properties(Access=protected)
is
encaps
sliceValues
valueFactoryManager
classResolver
classGraphDepth
Expand Down
13 changes: 2 additions & 11 deletions matlab/lib/+IceInternal/EncapsDecoder10.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

classdef EncapsDecoder10 < IceInternal.EncapsDecoder
methods
function obj = EncapsDecoder10(is, encaps, sliceValues, valueFactoryManager, classResolver, classGraphDepthMax)
[email protected](is, encaps, sliceValues, valueFactoryManager, classResolver, ...
classGraphDepthMax);
function obj = EncapsDecoder10(is, encaps, valueFactoryManager, classResolver, classGraphDepthMax)
[email protected](is, encaps, valueFactoryManager, classResolver, classGraphDepthMax);
obj.sliceType = IceInternal.SliceType.NoSlice;
end

Expand Down Expand Up @@ -225,14 +224,6 @@ function readInstance(obj)
break;
end

%
% If slicing is disabled, stop unmarshaling.
%
if ~obj.sliceValues
reason = sprintf('cannot find a value factory for ''%s'' and slicing is disabled', obj.typeId);
throw(Ice.MarshalException(reason));
end

%
% Slice off what we don't understand.
%
Expand Down
14 changes: 2 additions & 12 deletions matlab/lib/+IceInternal/EncapsDecoder11.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

classdef EncapsDecoder11 < IceInternal.EncapsDecoder
methods
function obj = EncapsDecoder11(is, encaps, sliceValues, valueFactoryManager, classResolver, classGraphDepthMax)
[email protected](is, encaps, sliceValues, valueFactoryManager, classResolver, ...
classGraphDepthMax);
function obj = EncapsDecoder11(is, encaps, valueFactoryManager, classResolver, classGraphDepthMax)
[email protected](is, encaps, valueFactoryManager, classResolver, classGraphDepthMax);
obj.current = [];
obj.valueIdIndex = 1;
obj.compactIdCache = {};
Expand Down Expand Up @@ -367,15 +366,6 @@ function skipSlice(obj)
break;
end

%
% If slicing is disabled, stop unmarshaling.
%
if ~obj.sliceValues

reason = sprintf('cannot find value factory for type ID ''%s'' and slicing is disabled', current.typeId);
throw(Ice.MarshalException(reason));
end

%
% Slice off what we don't understand.
%
Expand Down

0 comments on commit 762aa7f

Please sign in to comment.