mirror of
https://github.com/esiur/esiur-dart.git
synced 2025-05-06 04:02:57 +00:00
Guid to UUID
This commit is contained in:
parent
8c5a4a0e98
commit
2380baf9ff
@ -39,7 +39,7 @@ export 'src/Data/AutoList.dart';
|
|||||||
export 'src/Data/BinaryList.dart';
|
export 'src/Data/BinaryList.dart';
|
||||||
export 'src/Data/Codec.dart';
|
export 'src/Data/Codec.dart';
|
||||||
export 'src/Data/DC.dart';
|
export 'src/Data/DC.dart';
|
||||||
export 'src/Data/Guid.dart';
|
export 'src/Data/UUID.dart';
|
||||||
export 'src/Data/KeyList.dart';
|
export 'src/Data/KeyList.dart';
|
||||||
export 'src/Data/NotModified.dart';
|
export 'src/Data/NotModified.dart';
|
||||||
export 'src/Data/PropertyValue.dart';
|
export 'src/Data/PropertyValue.dart';
|
||||||
|
File diff suppressed because one or more lines are too long
@ -27,7 +27,7 @@
|
|||||||
import '../Core/AsyncReply.dart';
|
import '../Core/AsyncReply.dart';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'DC.dart';
|
import 'DC.dart';
|
||||||
import 'Guid.dart';
|
import 'UUID.dart';
|
||||||
|
|
||||||
class BinaryList {
|
class BinaryList {
|
||||||
var _list = <int>[];
|
var _list = <int>[];
|
||||||
@ -52,12 +52,12 @@ class BinaryList {
|
|||||||
_list.insertAll(position, DC.dateTimeArrayToBytes(value, endian));
|
_list.insertAll(position, DC.dateTimeArrayToBytes(value, endian));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addGuid(Guid value) {
|
void addUUID(UUID value) {
|
||||||
_list.addAll(DC.guidToBytes(value));
|
_list.addAll(DC.uuidToBytes(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void insertGuid(int position, Guid value) {
|
void insertUUID(int position, UUID value) {
|
||||||
_list.insertAll(position, DC.guidToBytes(value));
|
_list.insertAll(position, DC.uuidToBytes(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addUint8Array(Uint8List value) {
|
void addUint8Array(Uint8List value) {
|
||||||
|
@ -35,7 +35,7 @@ import '../Resource/Template/TemplateType.dart';
|
|||||||
|
|
||||||
import 'DataDeserializer.dart';
|
import 'DataDeserializer.dart';
|
||||||
import 'DataSerializer.dart';
|
import 'DataSerializer.dart';
|
||||||
import 'Guid.dart';
|
import 'UUID.dart';
|
||||||
import 'IRecord.dart';
|
import 'IRecord.dart';
|
||||||
import 'Record.dart';
|
import 'Record.dart';
|
||||||
import 'ResourceArrayType.dart';
|
import 'ResourceArrayType.dart';
|
||||||
|
@ -24,7 +24,7 @@ import 'dart:typed_data';
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'BinaryList.dart';
|
import 'BinaryList.dart';
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
import 'Guid.dart';
|
import 'UUID.dart';
|
||||||
|
|
||||||
const bool kIsWeb = identical(0, 0.0);
|
const bool kIsWeb = identical(0, 0.0);
|
||||||
|
|
||||||
@ -100,9 +100,9 @@ class DC with IterableMixin<int> {
|
|||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DC guidToBytes(Guid value) {
|
static DC uuidToBytes(UUID value) {
|
||||||
var rt = new DC(16);
|
var rt = new DC(16);
|
||||||
rt.setGuid(0, value);
|
rt.setUUID(0, value);
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,12 +615,12 @@ class DC with IterableMixin<int> {
|
|||||||
return DateTime.fromMillisecondsSinceEpoch((ticks - UNIX_EPOCH) ~/ 10000);
|
return DateTime.fromMillisecondsSinceEpoch((ticks - UNIX_EPOCH) ~/ 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Guid getGuid(int offset) {
|
UUID getUUID(int offset) {
|
||||||
return new Guid(this.clip(offset, 16));
|
return new UUID(this.clip(offset, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setGuid(int offset, Guid guid) {
|
void setUUID(int offset, UUID uuid) {
|
||||||
set(guid.value, 0, offset, 16);
|
set(uuid.value, 0, offset, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sequenceEqual(ar) {
|
bool sequenceEqual(ar) {
|
||||||
|
@ -155,7 +155,7 @@ class DataDeserializer {
|
|||||||
DistributedConnection? connection, List<int>? requestSequence) {
|
DistributedConnection? connection, List<int>? requestSequence) {
|
||||||
var reply = new AsyncReply<IRecord>();
|
var reply = new AsyncReply<IRecord>();
|
||||||
|
|
||||||
var classId = data.getGuid(offset);
|
var classId = data.getUUID(offset);
|
||||||
offset += 16;
|
offset += 16;
|
||||||
length -= 16;
|
length -= 16;
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ class DataDeserializer {
|
|||||||
|
|
||||||
static AsyncReply enumParser(DC data, int offset, int length,
|
static AsyncReply enumParser(DC data, int offset, int length,
|
||||||
DistributedConnection? connection, List<int>? requestSequence) {
|
DistributedConnection? connection, List<int>? requestSequence) {
|
||||||
var classId = data.getGuid(offset);
|
var classId = data.getUUID(offset);
|
||||||
offset += 16;
|
offset += 16;
|
||||||
var index = data[offset++];
|
var index = data[offset++];
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ class DataSerializer {
|
|||||||
|
|
||||||
var rt = BinaryList();
|
var rt = BinaryList();
|
||||||
|
|
||||||
rt.addGuid(template.classId);
|
rt.addUUID(template.classId);
|
||||||
rt.addUint8(cts.first.index);
|
rt.addUint8(cts.first.index);
|
||||||
|
|
||||||
return DataSerializerComposeResults(
|
return DataSerializerComposeResults(
|
||||||
@ -346,7 +346,7 @@ class DataSerializer {
|
|||||||
return DataSerializerComposeResults(
|
return DataSerializerComposeResults(
|
||||||
TransmissionTypeIdentifier.Null, DC(0));
|
TransmissionTypeIdentifier.Null, DC(0));
|
||||||
|
|
||||||
rt.addDC(DC.guidToBytes(template.classId));
|
rt.addDC(DC.uuidToBytes(template.classId));
|
||||||
|
|
||||||
var recordData = record.serialize();
|
var recordData = record.serialize();
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import '../Resource/Warehouse.dart';
|
|||||||
|
|
||||||
import 'BinaryList.dart';
|
import 'BinaryList.dart';
|
||||||
import 'DC.dart';
|
import 'DC.dart';
|
||||||
import 'Guid.dart';
|
import 'UUID.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
|
||||||
class RepresentationTypeIdentifier {
|
class RepresentationTypeIdentifier {
|
||||||
@ -83,7 +83,7 @@ class RepresentationType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RepresentationType toNullable() {
|
RepresentationType toNullable() {
|
||||||
return RepresentationType(identifier, true, guid, subTypes);
|
return RepresentationType(identifier, true, uuid, subTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RepresentationType Void =
|
static RepresentationType Void =
|
||||||
@ -127,7 +127,7 @@ class RepresentationType {
|
|||||||
// if (name == "List") {
|
// if (name == "List") {
|
||||||
// // get sub type
|
// // get sub type
|
||||||
// getTypeFromName(args.first.input);
|
// 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]![1]
|
||||||
: runtimeTypes[identifier]![0];
|
: runtimeTypes[identifier]![0];
|
||||||
if (identifier == RepresentationTypeIdentifier.TypedRecord)
|
if (identifier == RepresentationTypeIdentifier.TypedRecord)
|
||||||
return Warehouse.getTemplateByClassId(guid!, TemplateType.Record)
|
return Warehouse.getTemplateByClassId(uuid!, TemplateType.Record)
|
||||||
?.definedType;
|
?.definedType;
|
||||||
else if (identifier == RepresentationTypeIdentifier.TypedResource)
|
else if (identifier == RepresentationTypeIdentifier.TypedResource)
|
||||||
return Warehouse.getTemplateByClassId(guid!, TemplateType.Resource)
|
return Warehouse.getTemplateByClassId(uuid!, TemplateType.Resource)
|
||||||
?.definedType;
|
?.definedType;
|
||||||
else if (identifier == RepresentationTypeIdentifier.Enum)
|
else if (identifier == RepresentationTypeIdentifier.Enum)
|
||||||
return Warehouse.getTemplateByClassId(guid!, TemplateType.Enum)
|
return Warehouse.getTemplateByClassId(uuid!, TemplateType.Enum)
|
||||||
?.definedType;
|
?.definedType;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -180,12 +180,12 @@ class RepresentationType {
|
|||||||
|
|
||||||
int identifier;
|
int identifier;
|
||||||
bool nullable;
|
bool nullable;
|
||||||
Guid? guid;
|
UUID? uuid;
|
||||||
|
|
||||||
List<RepresentationType>? subTypes;
|
List<RepresentationType>? subTypes;
|
||||||
|
|
||||||
RepresentationType(this.identifier, this.nullable,
|
RepresentationType(this.identifier, this.nullable,
|
||||||
[this.guid, this.subTypes]) {}
|
[this.uuid, this.subTypes]) {}
|
||||||
|
|
||||||
DC compose() {
|
DC compose() {
|
||||||
var rt = BinaryList();
|
var rt = BinaryList();
|
||||||
@ -195,7 +195,7 @@ class RepresentationType {
|
|||||||
else
|
else
|
||||||
rt.addUint8(identifier);
|
rt.addUint8(identifier);
|
||||||
|
|
||||||
if (guid != null) rt.addDC(DC.guidToBytes(guid!));
|
if (uuid != null) rt.addDC(DC.uuidToBytes(uuid!));
|
||||||
|
|
||||||
if (subTypes != null)
|
if (subTypes != null)
|
||||||
for (var i = 0; i < subTypes!.length; i++)
|
for (var i = 0; i < subTypes!.length; i++)
|
||||||
@ -215,13 +215,13 @@ class RepresentationType {
|
|||||||
var identifier = (header & 0x7F);
|
var identifier = (header & 0x7F);
|
||||||
|
|
||||||
if ((header & 0x40) > 0) {
|
if ((header & 0x40) > 0) {
|
||||||
var hasGUID = (header & 0x4) > 0;
|
var hasUUID = (header & 0x4) > 0;
|
||||||
var subsCount = (header >> 3) & 0x7;
|
var subsCount = (header >> 3) & 0x7;
|
||||||
|
|
||||||
Guid? guid = null;
|
UUID? uuid = null;
|
||||||
|
|
||||||
if (hasGUID) {
|
if (hasUUID) {
|
||||||
guid = data.getGuid(offset);
|
uuid = data.getUUID(offset);
|
||||||
offset += 16;
|
offset += 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ class RepresentationType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return RepresentationTypeParseResults(offset - oOffset,
|
return RepresentationTypeParseResults(offset - oOffset,
|
||||||
RepresentationType(identifier, nullable, guid, subs));
|
RepresentationType(identifier, nullable, uuid, subs));
|
||||||
} else {
|
} else {
|
||||||
return RepresentationTypeParseResults(
|
return RepresentationTypeParseResults(
|
||||||
1, RepresentationType(identifier, nullable, null, null));
|
1, RepresentationType(identifier, nullable, null, null));
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
import 'DC.dart';
|
import 'DC.dart';
|
||||||
|
|
||||||
class Guid {
|
class UUID {
|
||||||
late DC _data;
|
late DC _data;
|
||||||
|
|
||||||
Guid(this._data) {}
|
UUID(this._data) {}
|
||||||
|
|
||||||
Guid.parse(String data) {
|
UUID.parse(String data) {
|
||||||
_data = DC.fromHex(data, '');
|
_data = DC.fromHex(data, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
DC get value => _data;
|
DC get value => _data;
|
||||||
|
|
||||||
bool operator ==(other) {
|
bool operator ==(other) {
|
||||||
if (other is Guid)
|
if (other is UUID)
|
||||||
return _data.sequenceEqual(other._data);
|
return _data.sequenceEqual(other._data);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
@ -94,7 +94,7 @@ import '../Packets/IIPPacketEvent.dart';
|
|||||||
import '../Packets/IIPPacketReport.dart';
|
import '../Packets/IIPPacketReport.dart';
|
||||||
import '../../Data/BinaryList.dart';
|
import '../../Data/BinaryList.dart';
|
||||||
import '../NetworkConnection.dart';
|
import '../NetworkConnection.dart';
|
||||||
import '../../Data/Guid.dart';
|
import '../../Data/UUID.dart';
|
||||||
import '../../Resource/Template/TypeTemplate.dart';
|
import '../../Resource/Template/TypeTemplate.dart';
|
||||||
import '../../Security/Permissions/Ruling.dart';
|
import '../../Security/Permissions/Ruling.dart';
|
||||||
import '../../Security/Permissions/ActionType.dart';
|
import '../../Security/Permissions/ActionType.dart';
|
||||||
@ -156,13 +156,13 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
KeyList<int, DistributedResourceAttachRequestInfo> _resourceRequests =
|
KeyList<int, DistributedResourceAttachRequestInfo> _resourceRequests =
|
||||||
new KeyList<int, DistributedResourceAttachRequestInfo>();
|
new KeyList<int, DistributedResourceAttachRequestInfo>();
|
||||||
|
|
||||||
KeyList<Guid, AsyncReply<TypeTemplate?>> _templateRequests =
|
KeyList<UUID, AsyncReply<TypeTemplate?>> _templateRequests =
|
||||||
new KeyList<Guid, AsyncReply<TypeTemplate?>>();
|
new KeyList<UUID, AsyncReply<TypeTemplate?>>();
|
||||||
|
|
||||||
KeyList<String, AsyncReply<TypeTemplate?>> _templateByNameRequests =
|
KeyList<String, AsyncReply<TypeTemplate?>> _templateByNameRequests =
|
||||||
new KeyList<String, AsyncReply<TypeTemplate?>>();
|
new KeyList<String, AsyncReply<TypeTemplate?>>();
|
||||||
|
|
||||||
Map<Guid, TypeTemplate> _templates = new Map<Guid, TypeTemplate>();
|
Map<UUID, TypeTemplate> _templates = new Map<UUID, TypeTemplate>();
|
||||||
KeyList<int, AsyncReply<dynamic>> _requests =
|
KeyList<int, AsyncReply<dynamic>> _requests =
|
||||||
new KeyList<int, AsyncReply<dynamic>>();
|
new KeyList<int, AsyncReply<dynamic>>();
|
||||||
int _callbackCounter = 0;
|
int _callbackCounter = 0;
|
||||||
@ -2013,7 +2013,7 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
if (r is DistributedResource) {
|
if (r is DistributedResource) {
|
||||||
// reply ok
|
// reply ok
|
||||||
_sendReply(IIPPacketAction.AttachResource, callback)
|
_sendReply(IIPPacketAction.AttachResource, callback)
|
||||||
..addGuid(r.instance?.template.classId as Guid)
|
..addUUID(r.instance?.template.classId as UUID)
|
||||||
..addUint64(r.instance?.age as int)
|
..addUint64(r.instance?.age as int)
|
||||||
..addUint16(link.length)
|
..addUint16(link.length)
|
||||||
..addDC(link)
|
..addDC(link)
|
||||||
@ -2025,7 +2025,7 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
} else {
|
} else {
|
||||||
// reply ok
|
// reply ok
|
||||||
_sendReply(IIPPacketAction.AttachResource, callback)
|
_sendReply(IIPPacketAction.AttachResource, callback)
|
||||||
..addGuid((r.instance as Instance).template.classId)
|
..addUUID((r.instance as Instance).template.classId)
|
||||||
..addUint64((r.instance as Instance).age)
|
..addUint64((r.instance as Instance).age)
|
||||||
..addUint16(link.length)
|
..addUint16(link.length)
|
||||||
..addDC(link)
|
..addDC(link)
|
||||||
@ -2572,7 +2572,7 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void iipRequestTemplateFromClassId(int callback, Guid classId) {
|
void iipRequestTemplateFromClassId(int callback, UUID classId) {
|
||||||
var t = Warehouse.getTemplateByClassId(classId);
|
var t = Warehouse.getTemplateByClassId(classId);
|
||||||
if (t != null)
|
if (t != null)
|
||||||
_sendReply(IIPPacketAction.TemplateFromClassId, callback)
|
_sendReply(IIPPacketAction.TemplateFromClassId, callback)
|
||||||
@ -2670,7 +2670,7 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
void iipRequestStaticCall(int callback, Guid classId, int index,
|
void iipRequestStaticCall(int callback, UUID classId, int index,
|
||||||
TransmissionType transmissionType, DC content) {
|
TransmissionType transmissionType, DC content) {
|
||||||
var template = Warehouse.getTemplateByClassId(classId);
|
var template = Warehouse.getTemplateByClassId(classId);
|
||||||
|
|
||||||
@ -3043,9 +3043,9 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the TypeTemplate for a given class Id.
|
/// Get the TypeTemplate for a given class Id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="classId">Class GUID.</param>
|
/// <param name="classId">Class UUID.</param>
|
||||||
/// <returns>TypeTemplate.</returns>
|
/// <returns>TypeTemplate.</returns>
|
||||||
AsyncReply<TypeTemplate?> getTemplate(Guid classId) {
|
AsyncReply<TypeTemplate?> getTemplate(UUID classId) {
|
||||||
//Warehouse.getTemplateByClassId(classId)
|
//Warehouse.getTemplateByClassId(classId)
|
||||||
|
|
||||||
if (_templates.containsKey(classId))
|
if (_templates.containsKey(classId))
|
||||||
@ -3056,7 +3056,7 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
var reply = new AsyncReply<TypeTemplate>();
|
var reply = new AsyncReply<TypeTemplate>();
|
||||||
_templateRequests.add(classId, reply);
|
_templateRequests.add(classId, reply);
|
||||||
|
|
||||||
(_sendRequest(IIPPacketAction.TemplateFromClassId)..addGuid(classId)).done()
|
(_sendRequest(IIPPacketAction.TemplateFromClassId)..addUUID(classId)).done()
|
||||||
..then((rt) {
|
..then((rt) {
|
||||||
if (rt != null) {
|
if (rt != null) {
|
||||||
_templateRequests.remove(classId);
|
_templateRequests.remove(classId);
|
||||||
@ -3145,8 +3145,8 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetch a resource from the other end
|
/// Fetch a resource from the other end
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="classId">Class GUID</param>
|
/// <param name="classId">Class UUID</param>
|
||||||
/// <param name="id">Resource Id</param>Guid classId
|
/// <param name="id">Resource Id</param>UUID classId
|
||||||
/// <returns>DistributedResource</returns>
|
/// <returns>DistributedResource</returns>
|
||||||
AsyncReply<DistributedResource> fetch(int id, List<int>? requestSequence) {
|
AsyncReply<DistributedResource> fetch(int id, List<int>? requestSequence) {
|
||||||
var resource = _attachedResources[id]?.target;
|
var resource = _attachedResources[id]?.target;
|
||||||
@ -3200,7 +3200,7 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
DistributedResource dr;
|
DistributedResource dr;
|
||||||
TypeTemplate? template;
|
TypeTemplate? template;
|
||||||
|
|
||||||
Guid classId = rt[0] as Guid;
|
UUID classId = rt[0] as UUID;
|
||||||
|
|
||||||
if (resource == null) {
|
if (resource == null) {
|
||||||
template =
|
template =
|
||||||
@ -3249,7 +3249,7 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
|
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
//print("tmp == null");
|
//print("tmp == null");
|
||||||
getTemplate(rt[0] as Guid)
|
getTemplate(rt[0] as UUID)
|
||||||
..then((tmp) {
|
..then((tmp) {
|
||||||
// ClassId, ResourceAge, ResourceLink, Content
|
// ClassId, ResourceAge, ResourceLink, Content
|
||||||
if (resource == null) {
|
if (resource == null) {
|
||||||
@ -3608,7 +3608,7 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
TemplateDescriber("Esiur.Net.IIP.DistributedConnection");
|
TemplateDescriber("Esiur.Net.IIP.DistributedConnection");
|
||||||
|
|
||||||
AsyncReply<dynamic> staticCall(
|
AsyncReply<dynamic> staticCall(
|
||||||
Guid classId, int index, Map<UInt8, dynamic> parameters) {
|
UUID classId, int index, Map<UInt8, dynamic> parameters) {
|
||||||
var pb = Codec.compose(parameters, this);
|
var pb = Codec.compose(parameters, this);
|
||||||
|
|
||||||
var reply = AsyncReply<dynamic>();
|
var reply = AsyncReply<dynamic>();
|
||||||
@ -3618,7 +3618,7 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
_sendParams()
|
_sendParams()
|
||||||
..addUint8((0x40 | IIPPacketAction.StaticCall))
|
..addUint8((0x40 | IIPPacketAction.StaticCall))
|
||||||
..addUint32(c)
|
..addUint32(c)
|
||||||
..addGuid(classId)
|
..addUUID(classId)
|
||||||
..addUint8(index)
|
..addUint8(index)
|
||||||
..addDC(pb)
|
..addDC(pb)
|
||||||
..done();
|
..done();
|
||||||
|
@ -24,7 +24,7 @@ SOFTWARE.
|
|||||||
import '../../Data/TransmissionType.dart';
|
import '../../Data/TransmissionType.dart';
|
||||||
|
|
||||||
import '../../Data/DC.dart';
|
import '../../Data/DC.dart';
|
||||||
import '../../Data/Guid.dart';
|
import '../../Data/UUID.dart';
|
||||||
|
|
||||||
import 'IIPPacketAction.dart';
|
import 'IIPPacketAction.dart';
|
||||||
import 'IIPPacketCommand.dart';
|
import 'IIPPacketCommand.dart';
|
||||||
@ -59,7 +59,7 @@ class IIPPacket {
|
|||||||
String errorMessage = "";
|
String errorMessage = "";
|
||||||
String className = "";
|
String className = "";
|
||||||
String resourceLink = "";
|
String resourceLink = "";
|
||||||
Guid classId = Guid(DC(0));
|
UUID classId = UUID(DC(0));
|
||||||
int methodIndex = 0;
|
int methodIndex = 0;
|
||||||
String methodName = "";
|
String methodName = "";
|
||||||
int callbackId = 0;
|
int callbackId = 0;
|
||||||
@ -264,7 +264,7 @@ class IIPPacket {
|
|||||||
} else if (action == IIPPacketAction.TemplateFromClassId) {
|
} else if (action == IIPPacketAction.TemplateFromClassId) {
|
||||||
if (_notEnough(offset, ends, 16)) return -_dataLengthNeeded;
|
if (_notEnough(offset, ends, 16)) return -_dataLengthNeeded;
|
||||||
|
|
||||||
classId = data.getGuid(offset);
|
classId = data.getUUID(offset);
|
||||||
offset += 16;
|
offset += 16;
|
||||||
} else if (action == IIPPacketAction.TemplateFromResourceId) {
|
} else if (action == IIPPacketAction.TemplateFromResourceId) {
|
||||||
if (_notEnough(offset, ends, 4)) return -_dataLengthNeeded;
|
if (_notEnough(offset, ends, 4)) return -_dataLengthNeeded;
|
||||||
@ -406,7 +406,7 @@ class IIPPacket {
|
|||||||
} else if (action == IIPPacketAction.StaticCall) {
|
} else if (action == IIPPacketAction.StaticCall) {
|
||||||
if (_notEnough(offset, ends, 18)) return -_dataLengthNeeded;
|
if (_notEnough(offset, ends, 18)) return -_dataLengthNeeded;
|
||||||
|
|
||||||
classId = data.getGuid(offset);
|
classId = data.getUUID(offset);
|
||||||
offset += 16;
|
offset += 16;
|
||||||
|
|
||||||
methodIndex = data[offset++];
|
methodIndex = data[offset++];
|
||||||
@ -422,7 +422,7 @@ class IIPPacket {
|
|||||||
action == IIPPacketAction.ReattachResource) {
|
action == IIPPacketAction.ReattachResource) {
|
||||||
if (_notEnough(offset, ends, 26)) return -_dataLengthNeeded;
|
if (_notEnough(offset, ends, 26)) return -_dataLengthNeeded;
|
||||||
|
|
||||||
classId = data.getGuid(offset);
|
classId = data.getUUID(offset);
|
||||||
offset += 16;
|
offset += 16;
|
||||||
|
|
||||||
resourceAge = data.getUint64(offset);
|
resourceAge = data.getUint64(offset);
|
||||||
|
@ -141,32 +141,32 @@ class TemplateGenerator {
|
|||||||
|
|
||||||
if (representationType.identifier ==
|
if (representationType.identifier ==
|
||||||
RepresentationTypeIdentifier.TypedResource) {
|
RepresentationTypeIdentifier.TypedResource) {
|
||||||
if (representationType.guid == forTemplate.classId)
|
if (representationType.uuid == forTemplate.classId)
|
||||||
name = forTemplate.className.split('.').last;
|
name = forTemplate.className.split('.').last;
|
||||||
else
|
else
|
||||||
name = _translateClassName(templates
|
name = _translateClassName(templates
|
||||||
.singleWhere((x) =>
|
.singleWhere((x) =>
|
||||||
x.classId == representationType.guid &&
|
x.classId == representationType.uuid &&
|
||||||
(x.type == TemplateType.Resource))
|
(x.type == TemplateType.Resource))
|
||||||
.className);
|
.className);
|
||||||
} else if (representationType.identifier ==
|
} else if (representationType.identifier ==
|
||||||
RepresentationTypeIdentifier.TypedRecord) {
|
RepresentationTypeIdentifier.TypedRecord) {
|
||||||
if (representationType.guid == forTemplate.classId)
|
if (representationType.uuid == forTemplate.classId)
|
||||||
name = forTemplate.className.split('.').last;
|
name = forTemplate.className.split('.').last;
|
||||||
else
|
else
|
||||||
name = _translateClassName(templates
|
name = _translateClassName(templates
|
||||||
.singleWhere((x) =>
|
.singleWhere((x) =>
|
||||||
x.classId == representationType.guid &&
|
x.classId == representationType.uuid &&
|
||||||
x.type == TemplateType.Record)
|
x.type == TemplateType.Record)
|
||||||
.className);
|
.className);
|
||||||
} else if (representationType.identifier ==
|
} else if (representationType.identifier ==
|
||||||
RepresentationTypeIdentifier
|
RepresentationTypeIdentifier
|
||||||
.Enum) if (representationType.guid == forTemplate.classId)
|
.Enum) if (representationType.uuid == forTemplate.classId)
|
||||||
name = forTemplate.className.split('.').last;
|
name = forTemplate.className.split('.').last;
|
||||||
else
|
else
|
||||||
name = _translateClassName(templates
|
name = _translateClassName(templates
|
||||||
.singleWhere((x) =>
|
.singleWhere((x) =>
|
||||||
x.classId == representationType.guid &&
|
x.classId == representationType.uuid &&
|
||||||
x.type == TemplateType.Enum)
|
x.type == TemplateType.Enum)
|
||||||
.className);
|
.className);
|
||||||
else if (representationType.identifier ==
|
else if (representationType.identifier ==
|
||||||
@ -339,17 +339,17 @@ class TemplateGenerator {
|
|||||||
// Warehouse.defineType<test.MyService>(
|
// Warehouse.defineType<test.MyService>(
|
||||||
// () => test.MyService(),
|
// () => test.MyService(),
|
||||||
// RepresentationType(RepresentationTypeIdentifier.TypedResource, false,
|
// RepresentationType(RepresentationTypeIdentifier.TypedResource, false,
|
||||||
// Guid(DC.fromList([1, 2, 3]))));
|
// UUID(DC.fromList([1, 2, 3]))));
|
||||||
|
|
||||||
var defineCreators = templates.map((tmp) {
|
var defineCreators = templates.map((tmp) {
|
||||||
// creator
|
// creator
|
||||||
var className = _translateClassName(tmp.className);
|
var className = _translateClassName(tmp.className);
|
||||||
if (tmp.type == TemplateType.Resource) {
|
if (tmp.type == TemplateType.Resource) {
|
||||||
return "Warehouse.defineType<${className}>(() => ${className}(), RepresentationType(RepresentationTypeIdentifier.TypedResource, false, Guid.parse('${tmp.classId.toString()}')));\r\n";
|
return "Warehouse.defineType<${className}>(() => ${className}(), RepresentationType(RepresentationTypeIdentifier.TypedResource, false, UUID.parse('${tmp.classId.toString()}')));\r\n";
|
||||||
} else if (tmp.type == TemplateType.Record) {
|
} else if (tmp.type == TemplateType.Record) {
|
||||||
return "Warehouse.defineType<${className}>(() => ${className}(), RepresentationType(RepresentationTypeIdentifier.TypedRecord, false, Guid.parse('${tmp.classId.toString()}')));\r\n";
|
return "Warehouse.defineType<${className}>(() => ${className}(), RepresentationType(RepresentationTypeIdentifier.TypedRecord, false, UUID.parse('${tmp.classId.toString()}')));\r\n";
|
||||||
} else if (tmp.type == TemplateType.Enum) {
|
} else if (tmp.type == TemplateType.Enum) {
|
||||||
return "Warehouse.defineType<${className}>(() => ${className}(), RepresentationType(RepresentationTypeIdentifier.Enum, false, Guid.parse('${tmp.classId.toString()}')));\r\n";
|
return "Warehouse.defineType<${className}>(() => ${className}(), RepresentationType(RepresentationTypeIdentifier.Enum, false, UUID.parse('${tmp.classId.toString()}')));\r\n";
|
||||||
}
|
}
|
||||||
}).join("\r\n");
|
}).join("\r\n");
|
||||||
|
|
||||||
@ -496,7 +496,7 @@ class TemplateGenerator {
|
|||||||
rt.writeln("var rt = AsyncReply<$rtTypeName>();");
|
rt.writeln("var rt = AsyncReply<$rtTypeName>();");
|
||||||
if (f.isStatic) {
|
if (f.isStatic) {
|
||||||
rt.writeln(
|
rt.writeln(
|
||||||
"connection.staticCall(Guid.parse('${template.classId.toString()}'), ${f.index}, args)");
|
"connection.staticCall(UUID.parse('${template.classId.toString()}'), ${f.index}, args)");
|
||||||
} else {
|
} else {
|
||||||
rt.writeln("internal_invoke(${f.index}, args)");
|
rt.writeln("internal_invoke(${f.index}, args)");
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
// import '../../Data/ParseResult.dart';
|
// import '../../Data/ParseResult.dart';
|
||||||
|
|
||||||
// import '../../Data/DataType.dart';
|
// import '../../Data/DataType.dart';
|
||||||
// import '../../Data/Guid.dart';
|
// import '../../Data/UUID.dart';
|
||||||
// import '../../Data/DC.dart';
|
// import '../../Data/DC.dart';
|
||||||
// import '../../Data/BinaryList.dart';
|
// import '../../Data/BinaryList.dart';
|
||||||
// import 'TypeTemplate.dart';
|
// import 'TypeTemplate.dart';
|
||||||
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
// class TemplateDataType {
|
// class TemplateDataType {
|
||||||
// late int type;
|
// late int type;
|
||||||
// TypeTemplate? get typeTemplate => typeGuid == null
|
// TypeTemplate? get typeTemplate => typeUUID == null
|
||||||
// ? null
|
// ? null
|
||||||
// : Warehouse.getTemplateByClassId(typeGuid as Guid);
|
// : Warehouse.getTemplateByClassId(typeUUID as UUID);
|
||||||
|
|
||||||
// Guid? typeGuid;
|
// UUID? typeUUID;
|
||||||
|
|
||||||
// // @TODO: implement fromType
|
// // @TODO: implement fromType
|
||||||
// TemplateDataType.fromType(type, bool isArray) {
|
// TemplateDataType.fromType(type, bool isArray) {
|
||||||
@ -67,7 +67,7 @@
|
|||||||
// var template = Warehouse.getTemplateByType(type);
|
// var template = Warehouse.getTemplateByType(type);
|
||||||
|
|
||||||
// if (template != null) {
|
// if (template != null) {
|
||||||
// typeGuid = template.classId;
|
// typeUUID = template.classId;
|
||||||
// dt = template.type == TemplateType.Resource
|
// dt = template.type == TemplateType.Resource
|
||||||
// ? DataType.Resource
|
// ? DataType.Resource
|
||||||
// : DataType.Record;
|
// : DataType.Record;
|
||||||
@ -78,9 +78,9 @@
|
|||||||
// // try {
|
// // try {
|
||||||
// // var ins = Warehouse.createInstance(type);
|
// // var ins = Warehouse.createInstance(type);
|
||||||
// // if (ins is IResource) {
|
// // if (ins is IResource) {
|
||||||
// // typeGuid = TypeTemplate.getTypeGuid(ins.template.nameSpace);
|
// // typeUUID = TypeTemplate.getTypeUUID(ins.template.nameSpace);
|
||||||
// // } else if (ins is IRecord) {
|
// // } else if (ins is IRecord) {
|
||||||
// // typeGuid = TypeTemplate.getTypeGuid(ins.template.nameSpace);
|
// // typeUUID = TypeTemplate.getTypeUUID(ins.template.nameSpace);
|
||||||
// // } else {
|
// // } else {
|
||||||
// // dt = DataType.Void;
|
// // dt = DataType.Void;
|
||||||
// // }
|
// // }
|
||||||
@ -101,13 +101,13 @@
|
|||||||
// type == DataType.RecordArray) {
|
// type == DataType.RecordArray) {
|
||||||
// return (BinaryList()
|
// return (BinaryList()
|
||||||
// ..addUint8(type)
|
// ..addUint8(type)
|
||||||
// ..addDC((typeGuid as Guid).value))
|
// ..addDC((typeUUID as UUID).value))
|
||||||
// .toDC();
|
// .toDC();
|
||||||
// } else
|
// } else
|
||||||
// return DC.fromList([type]);
|
// return DC.fromList([type]);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// TemplateDataType(this.type, this.typeGuid);
|
// TemplateDataType(this.type, this.typeUUID);
|
||||||
|
|
||||||
// static ParseResult<TemplateDataType> parse(DC data, int offset) {
|
// static ParseResult<TemplateDataType> parse(DC data, int offset) {
|
||||||
// var type = data[offset++];
|
// var type = data[offset++];
|
||||||
@ -115,9 +115,9 @@
|
|||||||
// type == DataType.ResourceArray ||
|
// type == DataType.ResourceArray ||
|
||||||
// type == DataType.Record ||
|
// type == DataType.Record ||
|
||||||
// type == DataType.RecordArray) {
|
// type == DataType.RecordArray) {
|
||||||
// var guid = data.getGuid(offset);
|
// var uuid = data.getUUID(offset);
|
||||||
// return ParseResult<TemplateDataType>(
|
// return ParseResult<TemplateDataType>(
|
||||||
// 17, new TemplateDataType(type, guid));
|
// 17, new TemplateDataType(type, uuid));
|
||||||
// } else
|
// } else
|
||||||
// return ParseResult<TemplateDataType>(1, new TemplateDataType(type, null));
|
// return ParseResult<TemplateDataType>(1, new TemplateDataType(type, null));
|
||||||
// }
|
// }
|
||||||
|
@ -13,7 +13,7 @@ import '../Warehouse.dart';
|
|||||||
import './TemplateDescriber.dart';
|
import './TemplateDescriber.dart';
|
||||||
|
|
||||||
import './MemberTemplate.dart';
|
import './MemberTemplate.dart';
|
||||||
import '../../Data/Guid.dart';
|
import '../../Data/UUID.dart';
|
||||||
import '../../Data/DC.dart';
|
import '../../Data/DC.dart';
|
||||||
import './EventTemplate.dart';
|
import './EventTemplate.dart';
|
||||||
import './PropertyTemplate.dart';
|
import './PropertyTemplate.dart';
|
||||||
@ -27,8 +27,8 @@ class TypeTemplate {
|
|||||||
|
|
||||||
bool get isWrapper => _isWrapper;
|
bool get isWrapper => _isWrapper;
|
||||||
|
|
||||||
late Guid _classId;
|
late UUID _classId;
|
||||||
Guid? _parentId = null;
|
UUID? _parentId = null;
|
||||||
|
|
||||||
String? _annotation;
|
String? _annotation;
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ class TypeTemplate {
|
|||||||
|
|
||||||
TemplateType get type => _templateType;
|
TemplateType get type => _templateType;
|
||||||
|
|
||||||
Guid? get parentId => _parentId;
|
UUID? get parentId => _parentId;
|
||||||
|
|
||||||
Type? _definedType;
|
Type? _definedType;
|
||||||
|
|
||||||
@ -104,13 +104,15 @@ class TypeTemplate {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Guid getTypeGuid(String typeName) {
|
static UUID getTypeUUID(String typeName) {
|
||||||
var tn = DC.stringToBytes(typeName);
|
var tn = DC.stringToBytes(typeName);
|
||||||
var hash = SHA256.compute(tn).clip(0, 16);
|
var hash = SHA256.compute(tn).clip(0, 16);
|
||||||
return new Guid(hash);
|
hash.setUint8(6, (hash.getUint8(6) & 0xF) | 0x80);
|
||||||
|
hash.setUint8(8, (hash.getUint8(8) & 0xF) | 0x80);
|
||||||
|
return new UUID(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
Guid get classId => _classId;
|
UUID get classId => _classId;
|
||||||
|
|
||||||
String get className => _className;
|
String get className => _className;
|
||||||
|
|
||||||
@ -154,8 +156,8 @@ class TypeTemplate {
|
|||||||
|
|
||||||
_className = describer.nameSpace;
|
_className = describer.nameSpace;
|
||||||
|
|
||||||
// set guid
|
// set UUID
|
||||||
_classId = getTypeGuid(_className);
|
_classId = getTypeUUID(_className);
|
||||||
|
|
||||||
_version = describer.version;
|
_version = describer.version;
|
||||||
|
|
||||||
@ -264,7 +266,7 @@ class TypeTemplate {
|
|||||||
// bake it binarily
|
// bake it binarily
|
||||||
var b = BinaryList()
|
var b = BinaryList()
|
||||||
..addUint8((_annotation != null ? 0x40 : 0x0) | _templateType.index)
|
..addUint8((_annotation != null ? 0x40 : 0x0) | _templateType.index)
|
||||||
..addGuid(classId)
|
..addUUID(classId)
|
||||||
..addUint8(className.length)
|
..addUint8(className.length)
|
||||||
..addString(className);
|
..addString(className);
|
||||||
|
|
||||||
@ -304,13 +306,13 @@ class TypeTemplate {
|
|||||||
|
|
||||||
_templateType = TemplateType.values[data.getUint8(offset++) & 0xF];
|
_templateType = TemplateType.values[data.getUint8(offset++) & 0xF];
|
||||||
|
|
||||||
_classId = data.getGuid(offset);
|
_classId = data.getUUID(offset);
|
||||||
offset += 16;
|
offset += 16;
|
||||||
_className = data.getString(offset + 1, data[offset]);
|
_className = data.getString(offset + 1, data[offset]);
|
||||||
offset += data[offset] + 1;
|
offset += data[offset] + 1;
|
||||||
|
|
||||||
if (hasParent) {
|
if (hasParent) {
|
||||||
_parentId = data.getGuid(offset);
|
_parentId = data.getUUID(offset);
|
||||||
offset += 16;
|
offset += 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ import '../Data/AutoList.dart';
|
|||||||
import 'FactoryEntry.dart';
|
import 'FactoryEntry.dart';
|
||||||
import 'Template/TemplateType.dart';
|
import 'Template/TemplateType.dart';
|
||||||
import 'Template/TypeTemplate.dart';
|
import 'Template/TypeTemplate.dart';
|
||||||
import '../Data/Guid.dart';
|
import '../Data/UUID.dart';
|
||||||
import '../Data/KeyList.dart';
|
import '../Data/KeyList.dart';
|
||||||
import '../Security/Permissions/IPermissionsManager.dart';
|
import '../Security/Permissions/IPermissionsManager.dart';
|
||||||
import 'IResource.dart';
|
import 'IResource.dart';
|
||||||
@ -59,15 +59,15 @@ class Warehouse {
|
|||||||
new Map<int, WeakReference<IResource>>();
|
new Map<int, WeakReference<IResource>>();
|
||||||
static int resourceCounter = 0;
|
static int resourceCounter = 0;
|
||||||
|
|
||||||
static KeyList<TemplateType, KeyList<Guid, TypeTemplate>> _templates =
|
static KeyList<TemplateType, KeyList<UUID, TypeTemplate>> _templates =
|
||||||
_initTemplates(); //
|
_initTemplates(); //
|
||||||
|
|
||||||
static KeyList<TemplateType, KeyList<Guid, TypeTemplate>> _initTemplates() {
|
static KeyList<TemplateType, KeyList<UUID, TypeTemplate>> _initTemplates() {
|
||||||
var rt = new KeyList<TemplateType, KeyList<Guid, TypeTemplate>>();
|
var rt = new KeyList<TemplateType, KeyList<UUID, TypeTemplate>>();
|
||||||
|
|
||||||
rt.add(TemplateType.Resource, new KeyList<Guid, TypeTemplate>());
|
rt.add(TemplateType.Resource, new KeyList<UUID, TypeTemplate>());
|
||||||
rt.add(TemplateType.Record, new KeyList<Guid, TypeTemplate>());
|
rt.add(TemplateType.Record, new KeyList<UUID, TypeTemplate>());
|
||||||
rt.add(TemplateType.Enum, new KeyList<Guid, TypeTemplate>());
|
rt.add(TemplateType.Enum, new KeyList<UUID, TypeTemplate>());
|
||||||
|
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
@ -593,7 +593,7 @@ class Warehouse {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="classId">Class Id.</param>
|
/// <param name="classId">Class Id.</param>
|
||||||
/// <returns>Resource template.</returns>
|
/// <returns>Resource template.</returns>
|
||||||
static TypeTemplate? getTemplateByClassId(Guid classId,
|
static TypeTemplate? getTemplateByClassId(UUID classId,
|
||||||
[TemplateType? templateType = null]) {
|
[TemplateType? templateType = null]) {
|
||||||
if (templateType == null) {
|
if (templateType == null) {
|
||||||
// look into resources
|
// look into resources
|
||||||
|
Loading…
x
Reference in New Issue
Block a user