def calculateOffset(self, xs: Union[list, dict, set]): result = 0 for ref in xs: if ref is None: result += 2 else: result += V64().singleV64Offset( self.typeByName[ref.skillName].typeID() - 31) result += V64().singleV64Offset(ref.getSkillID()) return result
def singleOffset(self, x): if x is None: size = 0 else: size = len(x) if size == 0: return 1 return V64().singleV64Offset(len(x)) + self.keyType.calculateOffset( x.keys()) + self.valueType.calculateOffset(x.values())
def addKnownField(self, name, string, annotation): if name == "age": F6(V64(), self) elif name == "name": F7(string, self) elif name == "reflectivelyvisible": F8(string, self)
def singleOffset(self, name): """ Calculates offset of the id of the string with the specified name :param name: name of the string :return: offset of the id """ if name is None: return 1 else: return V64().singleV64Offset(self.stringIDs.get(name))
def calculateOffset(self, xs: Union[list, dict, set]): result = 0 for x in xs: size = len(x) if size == 0: result += 1 else: result += V64().singleV64Offset( size) + self.keyType.calculateOffset(x.keys()) result += self.valueType.calculateOffset(x.values()) return result
def calculateOffset(self, xs: Union[list, dict, set]): result = 0 for x in xs: if x is None: size = 0 else: size = len(x) if size == 0: result += 1 else: result += V64().singleV64Offset(size) result += self.groundType.calculateOffset(x)
def fieldType(self): """ Reads typeID and returns corresponding FieldType. :return: FieldType """ typeID = self.inStream.v64() if typeID == 0: return ConstantI8(self.inStream.i8()) elif typeID == 1: return ConstantI16(self.inStream.i16()) elif typeID == 2: return ConstantI32(self.inStream.i32()) elif typeID == 3: return ConstantI64(self.inStream.i64()) elif typeID == 4: return ConstantV64(self.inStream.v64()) elif typeID == 5: return self.annotation elif typeID == 6: return BoolType() elif typeID == 7: return I8() elif typeID == 8: return I16() elif typeID == 9: return I32() elif typeID == 10: return I64() elif typeID == 11: return V64() elif typeID == 12: return F32() elif typeID == 13: return F64() elif typeID == 14: return self.strings elif typeID == 15: return ConstantLengthArray(self.inStream.v64(), self.fieldType()) elif typeID == 17: return VariableLengthArray(self.fieldType()) elif typeID == 18: return ListType(self.fieldType()) elif typeID == 19: return SetType(self.fieldType()) elif typeID == 20: return MapType(self.fieldType(), self.fieldType()) elif typeID >= 32: return self.types[typeID - 32] else: raise ParseException(self.inStream, self.blockCounter, None, "Invalid type ID: []", typeID)
def calculateOffset(self, xs): """ Calculates offset of all strings in collection xs. :param xs: Collection of strings :return: offset """ if len(self.stringIDs) < 128: return len(xs) result = 0 for s in xs: if s is None: result += 1 else: result += V64().singleV64Offset(self.stringIDs.get(s)) return result
def calculateOffset(self, xs: []): """ Calculates offset of list filled with instances :param xs: list :return: calculated offset """ if len(self._data) < 128: return len(xs) result = 0 for x in xs: if x is None: result += 1 else: result += V64().singleV64Offset(x.skillID) return result
def addKnownField(self, name, string, annotation): if name == "float": F3(F32(), self) elif name == "message": F4(string, self) elif name == "none": F5(self.owner().Properties, self) elif name == "nopdefault": F6(V64(), self) elif name == "system": F7(annotation, self)
def addKnownField(self, name, string, annotation): if name == "degrees": F11(F32(), self) elif name == "degrees2": F12(F64(), self) elif name == "negative": F13(I32(), self) elif name == "negative2": F14(V64(), self) elif name == "positive": F15(I8(), self) elif name == "positive2": F16(I16(), self)
def addKnownField(self, name, string, annotation): if name == "age": F4(V64(), self) elif name == "name": F5(string, self) elif name == "seen": F6(BoolType(), self) elif name == "someintegersinalist": F7(ListType(I32()), self) elif name == "somemap": F8(MapType(string, string), self) elif name == "somereference": F9(self.owner().NoSerializedData, self)
def addKnownField(self, name, string, annotation): if name == "arr": F0(ConstantLengthArray(3, V64()), self) elif name == "f": F1(MapType(string, MapType(V64(), V64())), self) elif name == "l": F2(ListType(V64()), self) elif name == "s": F3(SetType(V64()), self) elif name == "someset": F4(SetType(self.owner().SomethingElse), self) elif name == "varr": F5(VariableLengthArray(V64()), self)
def addKnownField(self, name, string, annotation): if name == "basicint": F8(V64(), self)
def addKnownField(self, name, string, annotation): if name == "age": F0(V64(), self)
def singleOffset(self, x): if x is None: return 1 return V64().singleV64Offset( len(x) + self.groundType.calculateOffset(x))
def singleOffset(self, x): if x is None: return 2 name = V64().singleV64Offset(self.typeByName[x.skillName].typeID() - 31) return name + V64().singleV64Offset(x.getSkillID())