Map java.util.UUID to System.Guid

This commit is contained in:
Sam Harwell 2014-07-04 18:42:29 -05:00
parent 0da1f54f19
commit 9a23a7f3c5
4 changed files with 19 additions and 18 deletions

View File

@ -143,6 +143,7 @@
-typeMapping java.util.concurrent.Semaphore System.Threading.Semaphore -typeMapping java.util.concurrent.Semaphore System.Threading.Semaphore
-typeMapping java.util.Enumeration System.Collections.Generic.IEnumeration -typeMapping java.util.Enumeration System.Collections.Generic.IEnumeration
-typeMapping java.lang.ProcessBuilder System.Diagnostics.ProcessStartInfo -typeMapping java.lang.ProcessBuilder System.Diagnostics.ProcessStartInfo
-typeMapping java.util.UUID System.Guid
-propertyMapping java.lang.Class.getSimpleName Name -propertyMapping java.lang.Class.getSimpleName Name
-propertyMapping java.nio.charset.Charset.defaultCharset Default -propertyMapping java.nio.charset.Charset.defaultCharset Default
-propertyMapping java.util.Locale.getDefault CurrentCulture -propertyMapping java.util.Locale.getDefault CurrentCulture

View File

@ -50,7 +50,7 @@ namespace Antlr4.Runtime.Atn
/// <summary>This is the earliest supported serialized UUID.</summary> /// <summary>This is the earliest supported serialized UUID.</summary>
/// <remarks>This is the earliest supported serialized UUID.</remarks> /// <remarks>This is the earliest supported serialized UUID.</remarks>
private static readonly UUID BaseSerializedUuid; private static readonly Guid BaseSerializedUuid;
/// <summary> /// <summary>
/// This UUID indicates an extension of /// This UUID indicates an extension of
@ -59,7 +59,7 @@ namespace Antlr4.Runtime.Atn
/// <see cref="ILexerAction"/> /// <see cref="ILexerAction"/>
/// instances. /// instances.
/// </summary> /// </summary>
private static readonly UUID AddedLexerActions; private static readonly Guid AddedLexerActions;
/// <summary> /// <summary>
/// This list contains all of the currently supported UUIDs, ordered by when /// This list contains all of the currently supported UUIDs, ordered by when
@ -69,17 +69,17 @@ namespace Antlr4.Runtime.Atn
/// This list contains all of the currently supported UUIDs, ordered by when /// This list contains all of the currently supported UUIDs, ordered by when
/// the feature first appeared in this branch. /// the feature first appeared in this branch.
/// </remarks> /// </remarks>
private static readonly IList<UUID> SupportedUuids; private static readonly IList<Guid> SupportedUuids;
/// <summary>This is the current serialized UUID.</summary> /// <summary>This is the current serialized UUID.</summary>
/// <remarks>This is the current serialized UUID.</remarks> /// <remarks>This is the current serialized UUID.</remarks>
public static readonly UUID SerializedUuid; public static readonly Guid SerializedUuid;
static ATNDeserializer() static ATNDeserializer()
{ {
BaseSerializedUuid = UUID.FromString("E4178468-DF95-44D0-AD87-F22A5D5FB6D3"); BaseSerializedUuid = Guid.FromString("E4178468-DF95-44D0-AD87-F22A5D5FB6D3");
AddedLexerActions = UUID.FromString("AB35191A-1603-487E-B75A-479B831EAF6D"); AddedLexerActions = Guid.FromString("AB35191A-1603-487E-B75A-479B831EAF6D");
SupportedUuids = new List<UUID>(); SupportedUuids = new List<Guid>();
SupportedUuids.Add(BaseSerializedUuid); SupportedUuids.Add(BaseSerializedUuid);
SupportedUuids.Add(AddedLexerActions); SupportedUuids.Add(AddedLexerActions);
SerializedUuid = AddedLexerActions; SerializedUuid = AddedLexerActions;
@ -105,19 +105,19 @@ namespace Antlr4.Runtime.Atn
/// <summary> /// <summary>
/// Determines if a particular serialized representation of an ATN supports /// Determines if a particular serialized representation of an ATN supports
/// a particular feature, identified by the /// a particular feature, identified by the
/// <see cref="Antlr4.Runtime.Sharpen.UUID"/> /// <see cref="System.Guid"/>
/// used for serializing /// used for serializing
/// the ATN at the time the feature was first introduced. /// the ATN at the time the feature was first introduced.
/// </summary> /// </summary>
/// <param name="feature"> /// <param name="feature">
/// The /// The
/// <see cref="Antlr4.Runtime.Sharpen.UUID"/> /// <see cref="System.Guid"/>
/// marking the first time the feature was /// marking the first time the feature was
/// supported in the serialized ATN. /// supported in the serialized ATN.
/// </param> /// </param>
/// <param name="actualUuid"> /// <param name="actualUuid">
/// The /// The
/// <see cref="Antlr4.Runtime.Sharpen.UUID"/> /// <see cref="System.Guid"/>
/// of the actual serialized ATN which is /// of the actual serialized ATN which is
/// currently being deserialized. /// currently being deserialized.
/// </param> /// </param>
@ -134,7 +134,7 @@ namespace Antlr4.Runtime.Atn
/// <code>false</code> /// <code>false</code>
/// . /// .
/// </returns> /// </returns>
protected internal virtual bool IsFeatureSupported(UUID feature, UUID actualUuid) protected internal virtual bool IsFeatureSupported(Guid feature, Guid actualUuid)
{ {
int featureIndex = SupportedUuids.IndexOf(feature); int featureIndex = SupportedUuids.IndexOf(feature);
if (featureIndex < 0) if (featureIndex < 0)
@ -159,7 +159,7 @@ namespace Antlr4.Runtime.Atn
string reason = string.Format(CultureInfo.CurrentCulture, "Could not deserialize ATN with version %d (expected %d).", version, SerializedVersion); string reason = string.Format(CultureInfo.CurrentCulture, "Could not deserialize ATN with version %d (expected %d).", version, SerializedVersion);
throw new NotSupportedException(new InvalidClassException(typeof(ATN).FullName, reason)); throw new NotSupportedException(new InvalidClassException(typeof(ATN).FullName, reason));
} }
UUID uuid = ToUUID(data, p); Guid uuid = ToUUID(data, p);
p += 8; p += 8;
if (!SupportedUuids.Contains(uuid)) if (!SupportedUuids.Contains(uuid))
{ {
@ -1096,11 +1096,11 @@ nextState_break: ;
return lowOrder | ((long)ToInt32(data, offset + 2) << 32); return lowOrder | ((long)ToInt32(data, offset + 2) << 32);
} }
protected internal static UUID ToUUID(char[] data, int offset) protected internal static Guid ToUUID(char[] data, int offset)
{ {
long leastSigBits = ToLong(data, offset); long leastSigBits = ToLong(data, offset);
long mostSigBits = ToLong(data, offset + 4); long mostSigBits = ToLong(data, offset + 4);
return new UUID(mostSigBits, leastSigBits); return new Guid(mostSigBits, leastSigBits);
} }
[NotNull] [NotNull]

View File

@ -480,7 +480,7 @@ namespace Antlr4.Runtime.Atn
string reason = string.Format("Could not deserialize ATN with version %d (expected %d).", version, ATNDeserializer.SerializedVersion); string reason = string.Format("Could not deserialize ATN with version %d (expected %d).", version, ATNDeserializer.SerializedVersion);
throw new NotSupportedException(new InvalidClassException(typeof(ATN).FullName, reason)); throw new NotSupportedException(new InvalidClassException(typeof(ATN).FullName, reason));
} }
UUID uuid = ATNDeserializer.ToUUID(data, p); Guid uuid = ATNDeserializer.ToUUID(data, p);
p += 8; p += 8;
if (!uuid.Equals(ATNDeserializer.SerializedUuid)) if (!uuid.Equals(ATNDeserializer.SerializedUuid))
{ {
@ -699,7 +699,7 @@ namespace Antlr4.Runtime.Atn
return new Antlr4.Runtime.Atn.ATNSerializer(atn, ruleNames, tokenNames).Decode(data); return new Antlr4.Runtime.Atn.ATNSerializer(atn, ruleNames, tokenNames).Decode(data);
} }
private void SerializeUUID(List<int> data, UUID uuid) private void SerializeUUID(List<int> data, Guid uuid)
{ {
SerializeLong(data, uuid.GetLeastSignificantBits()); SerializeLong(data, uuid.GetLeastSignificantBits());
SerializeLong(data, uuid.GetMostSignificantBits()); SerializeLong(data, uuid.GetMostSignificantBits());

View File

@ -51,7 +51,7 @@ namespace Antlr4.Runtime.Atn
/// <remarks>This is the current serialized UUID.</remarks> /// <remarks>This is the current serialized UUID.</remarks>
[System.ObsoleteAttribute(@"Use ATNDeserializer.CheckCondition(bool) instead.")] [System.ObsoleteAttribute(@"Use ATNDeserializer.CheckCondition(bool) instead.")]
[Obsolete] [Obsolete]
public static readonly UUID SerializedUuid; public static readonly Guid SerializedUuid;
static ATNSimulator() static ATNSimulator()
{ {
@ -145,7 +145,7 @@ namespace Antlr4.Runtime.Atn
[Obsolete] [Obsolete]
[System.ObsoleteAttribute(@"Use ATNDeserializer.ToUUID(char[], int) instead.")] [System.ObsoleteAttribute(@"Use ATNDeserializer.ToUUID(char[], int) instead.")]
public static UUID ToUUID(char[] data, int offset) public static Guid ToUUID(char[] data, int offset)
{ {
return ATNDeserializer.ToUUID(data, offset); return ATNDeserializer.ToUUID(data, offset);
} }