mirror of
				https://github.com/esiur/esiur-dart.git
				synced 2025-10-30 23:31:36 +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; | ||||
| @@ -94,7 +94,7 @@ import '../Packets/IIPPacketEvent.dart'; | ||||
| import '../Packets/IIPPacketReport.dart'; | ||||
| import '../../Data/BinaryList.dart'; | ||||
| import '../NetworkConnection.dart'; | ||||
| import '../../Data/Guid.dart'; | ||||
| import '../../Data/UUID.dart'; | ||||
| import '../../Resource/Template/TypeTemplate.dart'; | ||||
| import '../../Security/Permissions/Ruling.dart'; | ||||
| import '../../Security/Permissions/ActionType.dart'; | ||||
| @@ -156,13 +156,13 @@ class DistributedConnection extends NetworkConnection implements IStore { | ||||
|   KeyList<int, DistributedResourceAttachRequestInfo> _resourceRequests = | ||||
|       new KeyList<int, DistributedResourceAttachRequestInfo>(); | ||||
|  | ||||
|   KeyList<Guid, AsyncReply<TypeTemplate?>> _templateRequests = | ||||
|       new KeyList<Guid, AsyncReply<TypeTemplate?>>(); | ||||
|   KeyList<UUID, AsyncReply<TypeTemplate?>> _templateRequests = | ||||
|       new KeyList<UUID, AsyncReply<TypeTemplate?>>(); | ||||
|  | ||||
|   KeyList<String, AsyncReply<TypeTemplate?>> _templateByNameRequests = | ||||
|       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 = | ||||
|       new KeyList<int, AsyncReply<dynamic>>(); | ||||
|   int _callbackCounter = 0; | ||||
| @@ -2013,7 +2013,7 @@ class DistributedConnection extends NetworkConnection implements IStore { | ||||
|         if (r is DistributedResource) { | ||||
|           // reply ok | ||||
|           _sendReply(IIPPacketAction.AttachResource, callback) | ||||
|             ..addGuid(r.instance?.template.classId as Guid) | ||||
|             ..addUUID(r.instance?.template.classId as UUID) | ||||
|             ..addUint64(r.instance?.age as int) | ||||
|             ..addUint16(link.length) | ||||
|             ..addDC(link) | ||||
| @@ -2025,7 +2025,7 @@ class DistributedConnection extends NetworkConnection implements IStore { | ||||
|         } else { | ||||
|           // reply ok | ||||
|           _sendReply(IIPPacketAction.AttachResource, callback) | ||||
|             ..addGuid((r.instance as Instance).template.classId) | ||||
|             ..addUUID((r.instance as Instance).template.classId) | ||||
|             ..addUint64((r.instance as Instance).age) | ||||
|             ..addUint16(link.length) | ||||
|             ..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); | ||||
|     if (t != null) | ||||
|       _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) { | ||||
|     var template = Warehouse.getTemplateByClassId(classId); | ||||
|  | ||||
| @@ -3043,9 +3043,9 @@ class DistributedConnection extends NetworkConnection implements IStore { | ||||
|   /// <summary> | ||||
|   /// Get the TypeTemplate for a given class Id. | ||||
|   /// </summary> | ||||
|   /// <param name="classId">Class GUID.</param> | ||||
|   /// <param name="classId">Class UUID.</param> | ||||
|   /// <returns>TypeTemplate.</returns> | ||||
|   AsyncReply<TypeTemplate?> getTemplate(Guid classId) { | ||||
|   AsyncReply<TypeTemplate?> getTemplate(UUID classId) { | ||||
|     //Warehouse.getTemplateByClassId(classId) | ||||
|  | ||||
|     if (_templates.containsKey(classId)) | ||||
| @@ -3056,7 +3056,7 @@ class DistributedConnection extends NetworkConnection implements IStore { | ||||
|     var reply = new AsyncReply<TypeTemplate>(); | ||||
|     _templateRequests.add(classId, reply); | ||||
|  | ||||
|     (_sendRequest(IIPPacketAction.TemplateFromClassId)..addGuid(classId)).done() | ||||
|     (_sendRequest(IIPPacketAction.TemplateFromClassId)..addUUID(classId)).done() | ||||
|       ..then((rt) { | ||||
|         if (rt != null) { | ||||
|           _templateRequests.remove(classId); | ||||
| @@ -3145,8 +3145,8 @@ class DistributedConnection extends NetworkConnection implements IStore { | ||||
|   /// <summary> | ||||
|   /// Fetch a resource from the other end | ||||
|   /// </summary> | ||||
|   /// <param name="classId">Class GUID</param> | ||||
|   /// <param name="id">Resource Id</param>Guid classId | ||||
|   /// <param name="classId">Class UUID</param> | ||||
|   /// <param name="id">Resource Id</param>UUID classId | ||||
|   /// <returns>DistributedResource</returns> | ||||
|   AsyncReply<DistributedResource> fetch(int id, List<int>? requestSequence) { | ||||
|     var resource = _attachedResources[id]?.target; | ||||
| @@ -3200,7 +3200,7 @@ class DistributedConnection extends NetworkConnection implements IStore { | ||||
|         DistributedResource dr; | ||||
|         TypeTemplate? template; | ||||
|  | ||||
|         Guid classId = rt[0] as Guid; | ||||
|         UUID classId = rt[0] as UUID; | ||||
|  | ||||
|         if (resource == null) { | ||||
|           template = | ||||
| @@ -3249,7 +3249,7 @@ class DistributedConnection extends NetworkConnection implements IStore { | ||||
|  | ||||
|         if (template == null) { | ||||
|           //print("tmp == null"); | ||||
|           getTemplate(rt[0] as Guid) | ||||
|           getTemplate(rt[0] as UUID) | ||||
|             ..then((tmp) { | ||||
|               // ClassId, ResourceAge, ResourceLink, Content | ||||
|               if (resource == null) { | ||||
| @@ -3608,7 +3608,7 @@ class DistributedConnection extends NetworkConnection implements IStore { | ||||
|       TemplateDescriber("Esiur.Net.IIP.DistributedConnection"); | ||||
|  | ||||
|   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 reply = AsyncReply<dynamic>(); | ||||
| @@ -3618,7 +3618,7 @@ class DistributedConnection extends NetworkConnection implements IStore { | ||||
|     _sendParams() | ||||
|       ..addUint8((0x40 | IIPPacketAction.StaticCall)) | ||||
|       ..addUint32(c) | ||||
|       ..addGuid(classId) | ||||
|       ..addUUID(classId) | ||||
|       ..addUint8(index) | ||||
|       ..addDC(pb) | ||||
|       ..done(); | ||||
|   | ||||
| @@ -24,7 +24,7 @@ SOFTWARE. | ||||
| import '../../Data/TransmissionType.dart'; | ||||
|  | ||||
| import '../../Data/DC.dart'; | ||||
| import '../../Data/Guid.dart'; | ||||
| import '../../Data/UUID.dart'; | ||||
|  | ||||
| import 'IIPPacketAction.dart'; | ||||
| import 'IIPPacketCommand.dart'; | ||||
| @@ -59,7 +59,7 @@ class IIPPacket { | ||||
|   String errorMessage = ""; | ||||
|   String className = ""; | ||||
|   String resourceLink = ""; | ||||
|   Guid classId = Guid(DC(0)); | ||||
|   UUID classId = UUID(DC(0)); | ||||
|   int methodIndex = 0; | ||||
|   String methodName = ""; | ||||
|   int callbackId = 0; | ||||
| @@ -264,7 +264,7 @@ class IIPPacket { | ||||
|       } else if (action == IIPPacketAction.TemplateFromClassId) { | ||||
|         if (_notEnough(offset, ends, 16)) return -_dataLengthNeeded; | ||||
|  | ||||
|         classId = data.getGuid(offset); | ||||
|         classId = data.getUUID(offset); | ||||
|         offset += 16; | ||||
|       } else if (action == IIPPacketAction.TemplateFromResourceId) { | ||||
|         if (_notEnough(offset, ends, 4)) return -_dataLengthNeeded; | ||||
| @@ -406,7 +406,7 @@ class IIPPacket { | ||||
|       } else if (action == IIPPacketAction.StaticCall) { | ||||
|         if (_notEnough(offset, ends, 18)) return -_dataLengthNeeded; | ||||
|  | ||||
|         classId = data.getGuid(offset); | ||||
|         classId = data.getUUID(offset); | ||||
|         offset += 16; | ||||
|  | ||||
|         methodIndex = data[offset++]; | ||||
| @@ -422,7 +422,7 @@ class IIPPacket { | ||||
|           action == IIPPacketAction.ReattachResource) { | ||||
|         if (_notEnough(offset, ends, 26)) return -_dataLengthNeeded; | ||||
|  | ||||
|         classId = data.getGuid(offset); | ||||
|         classId = data.getUUID(offset); | ||||
|         offset += 16; | ||||
|  | ||||
|         resourceAge = data.getUint64(offset); | ||||
|   | ||||
| @@ -141,32 +141,32 @@ class TemplateGenerator { | ||||
|  | ||||
|     if (representationType.identifier == | ||||
|         RepresentationTypeIdentifier.TypedResource) { | ||||
|       if (representationType.guid == forTemplate.classId) | ||||
|       if (representationType.uuid == forTemplate.classId) | ||||
|         name = forTemplate.className.split('.').last; | ||||
|       else | ||||
|         name = _translateClassName(templates | ||||
|             .singleWhere((x) => | ||||
|                 x.classId == representationType.guid && | ||||
|                 x.classId == representationType.uuid && | ||||
|                 (x.type == TemplateType.Resource)) | ||||
|             .className); | ||||
|     } else if (representationType.identifier == | ||||
|         RepresentationTypeIdentifier.TypedRecord) { | ||||
|       if (representationType.guid == forTemplate.classId) | ||||
|       if (representationType.uuid == forTemplate.classId) | ||||
|         name = forTemplate.className.split('.').last; | ||||
|       else | ||||
|         name = _translateClassName(templates | ||||
|             .singleWhere((x) => | ||||
|                 x.classId == representationType.guid && | ||||
|                 x.classId == representationType.uuid && | ||||
|                 x.type == TemplateType.Record) | ||||
|             .className); | ||||
|     } else if (representationType.identifier == | ||||
|         RepresentationTypeIdentifier | ||||
|             .Enum) if (representationType.guid == forTemplate.classId) | ||||
|             .Enum) if (representationType.uuid == forTemplate.classId) | ||||
|       name = forTemplate.className.split('.').last; | ||||
|     else | ||||
|       name = _translateClassName(templates | ||||
|           .singleWhere((x) => | ||||
|               x.classId == representationType.guid && | ||||
|               x.classId == representationType.uuid && | ||||
|               x.type == TemplateType.Enum) | ||||
|           .className); | ||||
|     else if (representationType.identifier == | ||||
| @@ -339,17 +339,17 @@ class TemplateGenerator { | ||||
|       // Warehouse.defineType<test.MyService>( | ||||
|       //     () => test.MyService(), | ||||
|       //     RepresentationType(RepresentationTypeIdentifier.TypedResource, false, | ||||
|       //         Guid(DC.fromList([1, 2, 3])))); | ||||
|       //         UUID(DC.fromList([1, 2, 3])))); | ||||
|  | ||||
|       var defineCreators = templates.map((tmp) { | ||||
|         // creator | ||||
|         var className = _translateClassName(tmp.className); | ||||
|         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) { | ||||
|           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) { | ||||
|           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"); | ||||
|  | ||||
| @@ -496,7 +496,7 @@ class TemplateGenerator { | ||||
|       rt.writeln("var rt = AsyncReply<$rtTypeName>();"); | ||||
|       if (f.isStatic) { | ||||
|         rt.writeln( | ||||
|             "connection.staticCall(Guid.parse('${template.classId.toString()}'), ${f.index}, args)"); | ||||
|             "connection.staticCall(UUID.parse('${template.classId.toString()}'), ${f.index}, args)"); | ||||
|       } else { | ||||
|         rt.writeln("internal_invoke(${f.index}, args)"); | ||||
|       } | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
| // import '../../Data/ParseResult.dart'; | ||||
|  | ||||
| // import '../../Data/DataType.dart'; | ||||
| // import '../../Data/Guid.dart'; | ||||
| // import '../../Data/UUID.dart'; | ||||
| // import '../../Data/DC.dart'; | ||||
| // import '../../Data/BinaryList.dart'; | ||||
| // import 'TypeTemplate.dart'; | ||||
| @@ -16,11 +16,11 @@ | ||||
|  | ||||
| // class TemplateDataType { | ||||
| //   late int type; | ||||
| //   TypeTemplate? get typeTemplate => typeGuid == null | ||||
| //   TypeTemplate? get typeTemplate => typeUUID == null | ||||
| //       ? null | ||||
| //       : Warehouse.getTemplateByClassId(typeGuid as Guid); | ||||
| //       : Warehouse.getTemplateByClassId(typeUUID as UUID); | ||||
|  | ||||
| //   Guid? typeGuid; | ||||
| //   UUID? typeUUID; | ||||
|  | ||||
| // //  @TODO: implement fromType | ||||
| //   TemplateDataType.fromType(type, bool isArray) { | ||||
| @@ -67,7 +67,7 @@ | ||||
| //       var template = Warehouse.getTemplateByType(type); | ||||
|  | ||||
| //       if (template != null) { | ||||
| //         typeGuid = template.classId; | ||||
| //         typeUUID = template.classId; | ||||
| //         dt = template.type == TemplateType.Resource | ||||
| //             ? DataType.Resource | ||||
| //             : DataType.Record; | ||||
| @@ -78,9 +78,9 @@ | ||||
| //       //   try { | ||||
| //       //     var ins = Warehouse.createInstance(type); | ||||
| //       //     if (ins is IResource) { | ||||
| //       //       typeGuid = TypeTemplate.getTypeGuid(ins.template.nameSpace); | ||||
| //       //       typeUUID = TypeTemplate.getTypeUUID(ins.template.nameSpace); | ||||
| //       //     } else if (ins is IRecord) { | ||||
| //       //       typeGuid = TypeTemplate.getTypeGuid(ins.template.nameSpace); | ||||
| //       //       typeUUID = TypeTemplate.getTypeUUID(ins.template.nameSpace); | ||||
| //       //     } else { | ||||
| //       //       dt = DataType.Void; | ||||
| //       //     } | ||||
| @@ -101,13 +101,13 @@ | ||||
| //         type == DataType.RecordArray) { | ||||
| //       return (BinaryList() | ||||
| //             ..addUint8(type) | ||||
| //             ..addDC((typeGuid as Guid).value)) | ||||
| //             ..addDC((typeUUID as UUID).value)) | ||||
| //           .toDC(); | ||||
| //     } else | ||||
| //       return DC.fromList([type]); | ||||
| //   } | ||||
|  | ||||
| //   TemplateDataType(this.type, this.typeGuid); | ||||
| //   TemplateDataType(this.type, this.typeUUID); | ||||
|  | ||||
| //   static ParseResult<TemplateDataType> parse(DC data, int offset) { | ||||
| //     var type = data[offset++]; | ||||
| @@ -115,9 +115,9 @@ | ||||
| //         type == DataType.ResourceArray || | ||||
| //         type == DataType.Record || | ||||
| //         type == DataType.RecordArray) { | ||||
| //       var guid = data.getGuid(offset); | ||||
| //       var uuid = data.getUUID(offset); | ||||
| //       return ParseResult<TemplateDataType>( | ||||
| //           17, new TemplateDataType(type, guid)); | ||||
| //           17, new TemplateDataType(type, uuid)); | ||||
| //     } else | ||||
| //       return ParseResult<TemplateDataType>(1, new TemplateDataType(type, null)); | ||||
| //   } | ||||
|   | ||||
| @@ -13,7 +13,7 @@ import '../Warehouse.dart'; | ||||
| import './TemplateDescriber.dart'; | ||||
|  | ||||
| import './MemberTemplate.dart'; | ||||
| import '../../Data/Guid.dart'; | ||||
| import '../../Data/UUID.dart'; | ||||
| import '../../Data/DC.dart'; | ||||
| import './EventTemplate.dart'; | ||||
| import './PropertyTemplate.dart'; | ||||
| @@ -27,8 +27,8 @@ class TypeTemplate { | ||||
|  | ||||
|   bool get isWrapper => _isWrapper; | ||||
|  | ||||
|    late Guid _classId; | ||||
|   Guid? _parentId = null; | ||||
|    late UUID _classId; | ||||
|   UUID? _parentId = null; | ||||
|  | ||||
|   String? _annotation; | ||||
|  | ||||
| @@ -52,7 +52,7 @@ class TypeTemplate { | ||||
|  | ||||
|   TemplateType get type => _templateType; | ||||
|  | ||||
|   Guid? get parentId => _parentId; | ||||
|   UUID? get parentId => _parentId; | ||||
|  | ||||
|   Type? _definedType; | ||||
|  | ||||
| @@ -104,13 +104,15 @@ class TypeTemplate { | ||||
|     return null; | ||||
|   } | ||||
|  | ||||
|   static Guid getTypeGuid(String typeName) { | ||||
|   static UUID getTypeUUID(String typeName) { | ||||
|     var tn = DC.stringToBytes(typeName); | ||||
|     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; | ||||
|  | ||||
| @@ -154,8 +156,8 @@ class TypeTemplate { | ||||
|  | ||||
|     _className = describer.nameSpace; | ||||
|  | ||||
|     // set guid | ||||
|     _classId = getTypeGuid(_className); | ||||
|     // set UUID | ||||
|     _classId = getTypeUUID(_className); | ||||
|  | ||||
|     _version = describer.version; | ||||
|  | ||||
| @@ -264,7 +266,7 @@ class TypeTemplate { | ||||
|     // bake it binarily | ||||
|     var b = BinaryList() | ||||
|       ..addUint8((_annotation != null ? 0x40 : 0x0) | _templateType.index) | ||||
|       ..addGuid(classId) | ||||
|       ..addUUID(classId) | ||||
|       ..addUint8(className.length) | ||||
|       ..addString(className); | ||||
|  | ||||
| @@ -304,13 +306,13 @@ class TypeTemplate { | ||||
|  | ||||
|     _templateType = TemplateType.values[data.getUint8(offset++) & 0xF]; | ||||
|  | ||||
|     _classId = data.getGuid(offset); | ||||
|     _classId = data.getUUID(offset); | ||||
|     offset += 16; | ||||
|     _className = data.getString(offset + 1, data[offset]); | ||||
|     offset += data[offset] + 1; | ||||
|  | ||||
|     if (hasParent) { | ||||
|       _parentId = data.getGuid(offset); | ||||
|       _parentId = data.getUUID(offset); | ||||
|       offset += 16; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -40,7 +40,7 @@ import '../Data/AutoList.dart'; | ||||
| import 'FactoryEntry.dart'; | ||||
| import 'Template/TemplateType.dart'; | ||||
| import 'Template/TypeTemplate.dart'; | ||||
| import '../Data/Guid.dart'; | ||||
| import '../Data/UUID.dart'; | ||||
| import '../Data/KeyList.dart'; | ||||
| import '../Security/Permissions/IPermissionsManager.dart'; | ||||
| import 'IResource.dart'; | ||||
| @@ -59,15 +59,15 @@ class Warehouse { | ||||
|       new Map<int, WeakReference<IResource>>(); | ||||
|   static int resourceCounter = 0; | ||||
|  | ||||
|   static KeyList<TemplateType, KeyList<Guid, TypeTemplate>> _templates = | ||||
|   static KeyList<TemplateType, KeyList<UUID, TypeTemplate>> _templates = | ||||
|       _initTemplates(); // | ||||
|  | ||||
|   static KeyList<TemplateType, KeyList<Guid, TypeTemplate>> _initTemplates() { | ||||
|     var rt = new KeyList<TemplateType, KeyList<Guid, TypeTemplate>>(); | ||||
|   static KeyList<TemplateType, KeyList<UUID, TypeTemplate>> _initTemplates() { | ||||
|     var rt = new KeyList<TemplateType, KeyList<UUID, TypeTemplate>>(); | ||||
|  | ||||
|     rt.add(TemplateType.Resource, new KeyList<Guid, TypeTemplate>()); | ||||
|     rt.add(TemplateType.Record, new KeyList<Guid, TypeTemplate>()); | ||||
|     rt.add(TemplateType.Enum, new KeyList<Guid, TypeTemplate>()); | ||||
|     rt.add(TemplateType.Resource, new KeyList<UUID, TypeTemplate>()); | ||||
|     rt.add(TemplateType.Record, new KeyList<UUID, TypeTemplate>()); | ||||
|     rt.add(TemplateType.Enum, new KeyList<UUID, TypeTemplate>()); | ||||
|  | ||||
|     return rt; | ||||
|   } | ||||
| @@ -593,7 +593,7 @@ class Warehouse { | ||||
|   /// </summary> | ||||
|   /// <param name="classId">Class Id.</param> | ||||
|   /// <returns>Resource template.</returns> | ||||
|   static TypeTemplate? getTemplateByClassId(Guid classId, | ||||
|   static TypeTemplate? getTemplateByClassId(UUID classId, | ||||
|       [TemplateType? templateType = null]) { | ||||
|     if (templateType == null) { | ||||
|       // look into resources | ||||
|   | ||||
		Reference in New Issue
	
	Block a user