mirror of
https://github.com/esiur/esiur-dart.git
synced 2026-04-03 17:58:21 +00:00
Guid to UUID
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
import '../Core/AsyncReply.dart';
|
||||
import 'dart:typed_data';
|
||||
import 'DC.dart';
|
||||
import 'Guid.dart';
|
||||
import 'UUID.dart';
|
||||
|
||||
class BinaryList {
|
||||
var _list = <int>[];
|
||||
@@ -52,12 +52,12 @@ class BinaryList {
|
||||
_list.insertAll(position, DC.dateTimeArrayToBytes(value, endian));
|
||||
}
|
||||
|
||||
void addGuid(Guid value) {
|
||||
_list.addAll(DC.guidToBytes(value));
|
||||
void addUUID(UUID value) {
|
||||
_list.addAll(DC.uuidToBytes(value));
|
||||
}
|
||||
|
||||
void insertGuid(int position, Guid value) {
|
||||
_list.insertAll(position, DC.guidToBytes(value));
|
||||
void insertUUID(int position, UUID value) {
|
||||
_list.insertAll(position, DC.uuidToBytes(value));
|
||||
}
|
||||
|
||||
void addUint8Array(Uint8List value) {
|
||||
|
||||
@@ -35,7 +35,7 @@ import '../Resource/Template/TemplateType.dart';
|
||||
|
||||
import 'DataDeserializer.dart';
|
||||
import 'DataSerializer.dart';
|
||||
import 'Guid.dart';
|
||||
import 'UUID.dart';
|
||||
import 'IRecord.dart';
|
||||
import 'Record.dart';
|
||||
import 'ResourceArrayType.dart';
|
||||
|
||||
@@ -24,7 +24,7 @@ import 'dart:typed_data';
|
||||
import 'dart:convert';
|
||||
import 'BinaryList.dart';
|
||||
import 'dart:collection';
|
||||
import 'Guid.dart';
|
||||
import 'UUID.dart';
|
||||
|
||||
const bool kIsWeb = identical(0, 0.0);
|
||||
|
||||
@@ -100,9 +100,9 @@ class DC with IterableMixin<int> {
|
||||
return rt;
|
||||
}
|
||||
|
||||
static DC guidToBytes(Guid value) {
|
||||
static DC uuidToBytes(UUID value) {
|
||||
var rt = new DC(16);
|
||||
rt.setGuid(0, value);
|
||||
rt.setUUID(0, value);
|
||||
return rt;
|
||||
}
|
||||
|
||||
@@ -615,12 +615,12 @@ class DC with IterableMixin<int> {
|
||||
return DateTime.fromMillisecondsSinceEpoch((ticks - UNIX_EPOCH) ~/ 10000);
|
||||
}
|
||||
|
||||
Guid getGuid(int offset) {
|
||||
return new Guid(this.clip(offset, 16));
|
||||
UUID getUUID(int offset) {
|
||||
return new UUID(this.clip(offset, 16));
|
||||
}
|
||||
|
||||
void setGuid(int offset, Guid guid) {
|
||||
set(guid.value, 0, offset, 16);
|
||||
void setUUID(int offset, UUID uuid) {
|
||||
set(uuid.value, 0, offset, 16);
|
||||
}
|
||||
|
||||
bool sequenceEqual(ar) {
|
||||
|
||||
@@ -155,7 +155,7 @@ class DataDeserializer {
|
||||
DistributedConnection? connection, List<int>? requestSequence) {
|
||||
var reply = new AsyncReply<IRecord>();
|
||||
|
||||
var classId = data.getGuid(offset);
|
||||
var classId = data.getUUID(offset);
|
||||
offset += 16;
|
||||
length -= 16;
|
||||
|
||||
@@ -210,7 +210,7 @@ class DataDeserializer {
|
||||
|
||||
static AsyncReply enumParser(DC data, int offset, int length,
|
||||
DistributedConnection? connection, List<int>? requestSequence) {
|
||||
var classId = data.getGuid(offset);
|
||||
var classId = data.getUUID(offset);
|
||||
offset += 16;
|
||||
var index = data[offset++];
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ class DataSerializer {
|
||||
|
||||
var rt = BinaryList();
|
||||
|
||||
rt.addGuid(template.classId);
|
||||
rt.addUUID(template.classId);
|
||||
rt.addUint8(cts.first.index);
|
||||
|
||||
return DataSerializerComposeResults(
|
||||
@@ -346,7 +346,7 @@ class DataSerializer {
|
||||
return DataSerializerComposeResults(
|
||||
TransmissionTypeIdentifier.Null, DC(0));
|
||||
|
||||
rt.addDC(DC.guidToBytes(template.classId));
|
||||
rt.addDC(DC.uuidToBytes(template.classId));
|
||||
|
||||
var recordData = record.serialize();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import '../Resource/Warehouse.dart';
|
||||
|
||||
import 'BinaryList.dart';
|
||||
import 'DC.dart';
|
||||
import 'Guid.dart';
|
||||
import 'UUID.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
class RepresentationTypeIdentifier {
|
||||
@@ -83,7 +83,7 @@ class RepresentationType {
|
||||
}
|
||||
|
||||
RepresentationType toNullable() {
|
||||
return RepresentationType(identifier, true, guid, subTypes);
|
||||
return RepresentationType(identifier, true, uuid, subTypes);
|
||||
}
|
||||
|
||||
static RepresentationType Void =
|
||||
@@ -127,7 +127,7 @@ class RepresentationType {
|
||||
// if (name == "List") {
|
||||
// // get sub type
|
||||
// getTypeFromName(args.first.input);
|
||||
// return RepresentationType(RepresentationTypeIdentifier.TypedList, nullable, guid, subTypes)
|
||||
// return RepresentationType(RepresentationTypeIdentifier.TypedList, nullable, uuid, subTypes)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -166,13 +166,13 @@ class RepresentationType {
|
||||
? runtimeTypes[identifier]![1]
|
||||
: runtimeTypes[identifier]![0];
|
||||
if (identifier == RepresentationTypeIdentifier.TypedRecord)
|
||||
return Warehouse.getTemplateByClassId(guid!, TemplateType.Record)
|
||||
return Warehouse.getTemplateByClassId(uuid!, TemplateType.Record)
|
||||
?.definedType;
|
||||
else if (identifier == RepresentationTypeIdentifier.TypedResource)
|
||||
return Warehouse.getTemplateByClassId(guid!, TemplateType.Resource)
|
||||
return Warehouse.getTemplateByClassId(uuid!, TemplateType.Resource)
|
||||
?.definedType;
|
||||
else if (identifier == RepresentationTypeIdentifier.Enum)
|
||||
return Warehouse.getTemplateByClassId(guid!, TemplateType.Enum)
|
||||
return Warehouse.getTemplateByClassId(uuid!, TemplateType.Enum)
|
||||
?.definedType;
|
||||
|
||||
return null;
|
||||
@@ -180,12 +180,12 @@ class RepresentationType {
|
||||
|
||||
int identifier;
|
||||
bool nullable;
|
||||
Guid? guid;
|
||||
UUID? uuid;
|
||||
|
||||
List<RepresentationType>? subTypes;
|
||||
|
||||
RepresentationType(this.identifier, this.nullable,
|
||||
[this.guid, this.subTypes]) {}
|
||||
[this.uuid, this.subTypes]) {}
|
||||
|
||||
DC compose() {
|
||||
var rt = BinaryList();
|
||||
@@ -195,7 +195,7 @@ class RepresentationType {
|
||||
else
|
||||
rt.addUint8(identifier);
|
||||
|
||||
if (guid != null) rt.addDC(DC.guidToBytes(guid!));
|
||||
if (uuid != null) rt.addDC(DC.uuidToBytes(uuid!));
|
||||
|
||||
if (subTypes != null)
|
||||
for (var i = 0; i < subTypes!.length; i++)
|
||||
@@ -215,13 +215,13 @@ class RepresentationType {
|
||||
var identifier = (header & 0x7F);
|
||||
|
||||
if ((header & 0x40) > 0) {
|
||||
var hasGUID = (header & 0x4) > 0;
|
||||
var hasUUID = (header & 0x4) > 0;
|
||||
var subsCount = (header >> 3) & 0x7;
|
||||
|
||||
Guid? guid = null;
|
||||
UUID? uuid = null;
|
||||
|
||||
if (hasGUID) {
|
||||
guid = data.getGuid(offset);
|
||||
if (hasUUID) {
|
||||
uuid = data.getUUID(offset);
|
||||
offset += 16;
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ class RepresentationType {
|
||||
}
|
||||
|
||||
return RepresentationTypeParseResults(offset - oOffset,
|
||||
RepresentationType(identifier, nullable, guid, subs));
|
||||
RepresentationType(identifier, nullable, uuid, subs));
|
||||
} else {
|
||||
return RepresentationTypeParseResults(
|
||||
1, RepresentationType(identifier, nullable, null, null));
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import 'DC.dart';
|
||||
|
||||
class Guid {
|
||||
class UUID {
|
||||
late DC _data;
|
||||
|
||||
Guid(this._data) {}
|
||||
UUID(this._data) {}
|
||||
|
||||
Guid.parse(String data) {
|
||||
UUID.parse(String data) {
|
||||
_data = DC.fromHex(data, '');
|
||||
}
|
||||
|
||||
DC get value => _data;
|
||||
|
||||
bool operator ==(other) {
|
||||
if (other is Guid)
|
||||
if (other is UUID)
|
||||
return _data.sequenceEqual(other._data);
|
||||
else
|
||||
return false;
|
||||
Reference in New Issue
Block a user