Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 2691x 2691x 41x 41x 335x 335x 27x 27x 308x 335x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 2685x 52x 2685x 2685x 2685x 883x 2685x 2685x 2685x 2659x 2685x 2685x 2685x 2685x 2685x 6x 6x 2685x | // Copyright (c) ZeroC, Inc.
/**
* Implements SliceLoader using generated classes that register themselves by calling defineClass.
*/
class DefaultSliceLoader {
/**
* Creates a new DefaultSliceLoader.
*/
constructor() {
this.typeIdToTypeMap = new Map(); // Map<String, Type>
}
/**
* Adds a new type to the typeIdToTypeMap.
* @param typeId The type ID or compact type ID.
* @param type The type.
*/
add(typeId, type) {
this.typeIdToTypeMap.set(typeId, type);
}
newInstance(typeId) {
const type = this.typeIdToTypeMap.get(typeId);
if (type === undefined) {
return null;
}
return new type();
}
}
/**
* The DefaultSliceLoader singleton.
*/
export const defaultSliceLoaderInstance = new DefaultSliceLoader();
/**
* Registers the class for a mapped Slice class or exception. Also adds some methods to the JS class.
* @param classType The JS class.
* @param typeId The type ID.
* @param compactId The compact type ID.
*/
export function defineClass(classType, typeId, compactId = -1) {
classType.prototype.ice_id = function () {
return typeId;
};
classType.prototype._iceMostDerivedType = function () {
return classType;
};
classType.ice_staticId = function () {
return typeId;
};
defaultSliceLoaderInstance.add(typeId, classType);
if (compactId !== -1) {
defaultSliceLoaderInstance.add(compactId.toString(), classType);
}
}
|