private EnumCollection ProcessNames(EnumCollection enums, XPathNavigator nav, string apiname) { EnumCollection processed_enums = new EnumCollection(); foreach (var e in enums.Values) { // Note that we cannot modify a collection while iterating over it, // so we keep a list of modified enums and remove/readd the // modified items to refresh their keys. string name = e.Name; name = ReplaceName(nav, apiname, name); name = TranslateEnumName(name); e.Name = name; processed_enums.Add(e.Name, e); } // Mark enums differing only in case as not CLS-compliant. var list = enums.Values.ToList(); while (list.Count > 0) { var e1 = list.Last(); list.RemoveAt(list.Count - 1); var e2 = list.FirstOrDefault(l => String.Compare(e1.Name, l.Name, true) == 0); if (e2 != null) { e1.CLSCompliant = false; e2.CLSCompliant = false; } } return(processed_enums); }
/// <summary> /// Merges the given enum into the enum list. If an enum of the same name exists, /// it merges their respective constants. /// </summary> /// <param name="enums"></param> /// <param name="t"></param> internal static void Merge(EnumCollection enums, Enum t) { if (!enums.ContainsKey(t.Name)) { enums.Add(t.Name, t); } else { Enum e = enums[t.Name]; foreach (Constant c in t.ConstantCollection.Values) { Merge(e, c); } } }
public void activeAction(PlayerActions playerAction, Vector3 look, MeleeStrikeType meleeStrike) { ServerRoundPlayer player = instant.serverRoundPlayerManager.ResolveServerRoundPlayer(networkPlayer.id); if (player == null) { return; } OwnerPacketToServer ownerPacketToServer = ComponentReferenceManager.genericObjectPools.ownerPacketToServer.Obtain(); byte spawnInstance = player.PlayerBase.PlayerStartData.SpawnInstance; Vector2 axis = new Vector2();; axis.x = look.x; axis.y = look.z; ownerPacketToServer.Instance = new byte?(spawnInstance); ownerPacketToServer.OwnerPosition = new Vector3?(player.PlayerTransform.position); ownerPacketToServer.OwnerInputAxis = new Vector2?(axis); ownerPacketToServer.OwnerRotationY = new float?(look.y); ownerPacketToServer.Swimming = player.PlayerBase.State.Has(20); double networkTime = uLinkNetworkConnectionsCollection.networkTime; ownerPacketToServer.PacketTimestamp = new double?(networkTime); EnumCollection <PlayerActions> enumCollection = ComponentReferenceManager.genericObjectPools.playerActionsEnumCollection.Obtain(); enumCollection.Add((int)playerAction); ownerPacketToServer.CameraForward = new Vector3?(player.PlayerTransform.forward); ownerPacketToServer.CameraPosition = new Vector3(0.3f, 1.5f, -1.0f); ownerPacketToServer.ActionCollection = enumCollection; player.uLinkStrictPlatformerCreator.HandleOwnerPacketToServer(ownerPacketToServer); if (playerAction == PlayerActions.FireFirearm) { ServerPacketToProxy proxy = new ServerPacketToProxy(); proxy.PlayerID = (ushort)networkPlayer.id; proxy.Timestamp = networkTime; proxy.ActionCollection = enumCollection; proxy.State = player.ServerPlayerBase.State; CharacterServerNetworkUpdateableObjectRPCHandler.Instance.RegisterPacket(networkPlayer, proxy, true); } if (meleeStrike != MeleeStrikeType.None) { PlayerMeleeStrikePacket playerMeleeStrikePacket = ComponentReferenceManager.genericObjectPools.playerMeleeStrikePacket.Obtain(); playerMeleeStrikePacket.AttackTime = uLinkNetworkConnectionsCollection.networkTime; playerMeleeStrikePacket.AttackingPlayerID = player.NetworkPlayerID; playerMeleeStrikePacket.AttackingPlayerMeleeWeaponDamageDealerTypeID = player.WeaponHolder.ActiveWeaponDetails.damageDealerTypeID; playerMeleeStrikePacket.MeleeStrikeType = meleeStrike; instant.meleeStrikeManager.MeleeAttackStrike(playerMeleeStrikePacket); } }
static EnumCollection ProcessNames(EnumCollection enums, XPathNavigator nav) { EnumCollection processed_enums = new EnumCollection(); foreach (var e in enums.Values) { // Note that we cannot modify a collection while iterating over it, // so we keep a list of modified enums and remove/readd the // modified items to refresh their keys. string name = e.Name; name = ReplaceName(nav, name); name = TranslateEnumName(name); e.Name = name; processed_enums.Add(e.Name, e); } return processed_enums; }
EnumCollection ProcessNames(EnumCollection enums, XPathNavigator nav, string apiname) { EnumCollection processed_enums = new EnumCollection(); foreach (var e in enums.Values) { // Note that we cannot modify a collection while iterating over it, // so we keep a list of modified enums and remove/readd the // modified items to refresh their keys. string name = e.Name; name = ReplaceName(nav, apiname, name); name = TranslateEnumName(name); e.Name = name; processed_enums.Add(e.Name, e); } return(processed_enums); }
/// <summary> /// Merges the given enum into the enum list. If an enum of the same name exists, /// it merges their respective constants. /// </summary> /// <param name="enums"></param> /// <param name="t"></param> internal static void Merge(EnumCollection enums, Enum t) { if (!enums.ContainsKey(t.Name)) { enums.Add(t.Name, t); } else { Enum e = enums[t.Name]; foreach (Constant c in t.ConstantCollection.Values) { Merge(e, c); } } }
public virtual EnumCollection ReadEnums(StreamReader specFile) { Trace.WriteLine("Reading opengl enumerant specs."); Trace.Indent(); EnumCollection enums = new EnumCollection(); // complete_enum contains all opengl enumerants. Enum complete_enum = new Enum(); complete_enum.Name = Settings.CompleteEnumName; do { string line = NextValidLine(specFile); if (String.IsNullOrEmpty(line)) break; line = line.Replace('\t', ' '); // We just encountered the start of a new enumerant: while (!String.IsNullOrEmpty(line) && line.Contains("enum")) { string[] words = line.Split(Utilities.Separators, StringSplitOptions.RemoveEmptyEntries); if (words.Length == 0) continue; // Declare a new enumerant Enum e = new Enum(); e.Name = Char.IsDigit(words[0][0]) ? Settings.ConstantPrefix + words[0] : words[0]; // And fill in the values for this enumerant do { line = NextValidLine(specFile); if (String.IsNullOrEmpty(line) || line.StartsWith("#")) continue; if (line.Contains("enum:") || specFile.EndOfStream) break; line = line.Replace('\t', ' '); words = line.Split(Utilities.Separators, StringSplitOptions.RemoveEmptyEntries); if (words.Length == 0) continue; // If we reach this point, we have found a new value for the current enumerant Constant c = new Constant(); if (line.Contains("=")) { // Trim the name's prefix, but only if not in Tao compat mode. if (Settings.Compatibility == Settings.Legacy.Tao) { } else { if (words[0].StartsWith(Settings.ConstantPrefix)) words[0] = words[0].Substring(Settings.ConstantPrefix.Length); if (Char.IsDigit(words[0][0])) words[0] = Settings.ConstantPrefix + words[0]; } c.Name = words[0]; c.Value = words[2]; } else if (words[0] == "use") { // Trim the prefix. if (words[2].StartsWith(Settings.ConstantPrefix)) words[2] = words[2].Substring(Settings.ConstantPrefix.Length); // If the remaining string starts with a digit, we were wrong above. // Re-add the "GL_" if (Char.IsDigit(words[2][0])) words[2] = Settings.ConstantPrefix + words[2]; c.Name = words[2]; c.Reference = words[1]; c.Value = words[2]; } else { // Typical cause is hand-editing the specs and forgetting to add an '=' sign. throw new InvalidOperationException(String.Format( "[Error] Invalid constant definition: \"{0}\"", line)); } //if (!String.IsNullOrEmpty(c.Name) && !e.Members.Contains.Contains(c)) //SpecTranslator.Merge(e.Members, c); if (!e.ConstantCollection.ContainsKey(c.Name)) e.ConstantCollection.Add(c.Name, c); else Trace.WriteLine(String.Format( "Spec error: Constant {0} defined twice in enum {1}, discarding last definition.", c.Name, e.Name)); // Insert the current constant in the list of all constants. //SpecTranslator.Merge(complete_enum.Members, c); complete_enum = Utilities.Merge(complete_enum, c); } while (!specFile.EndOfStream); // At this point, the complete value list for the current enumerant has been read, so add this // enumerant to the list. //e.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "public enum " + e.Name)); //e.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, "public enum " + e.Name)); // (disabled) Hack - discard Boolean enum, it fsucks up the fragile translation code ahead. //if (!e.Name.Contains("Bool")) //Utilities.Merge(enums, e); //e.Translate(); if (!enums.ContainsKey(e.Name)) enums.Add(e.Name, e); else { // The enum already exists, merge constants. foreach (Constant t in e.ConstantCollection.Values) Utilities.Merge(enums[e.Name], t); } } } while (!specFile.EndOfStream); enums.Add(complete_enum.Name, complete_enum); Trace.Unindent(); return enums; }
public virtual EnumCollection ReadEnums(StreamReader specFile) { Trace.WriteLine("Reading opengl enumerant specs."); Trace.Indent(); EnumCollection enums = new EnumCollection(); // complete_enum contains all opengl enumerants. Bind.Structures.Enum complete_enum = new Bind.Structures.Enum(); complete_enum.Name = Settings.CompleteEnumName; do { string line = NextValidLine(specFile); if (String.IsNullOrEmpty(line)) break; line = line.Replace('\t', ' '); // We just encountered the start of a new enumerant: while (!String.IsNullOrEmpty(line) && line.Contains("enum")) { string[] words = line.Split(Utilities.Separators, StringSplitOptions.RemoveEmptyEntries); if (words.Length == 0) continue; // Declare a new enumerant Bind.Structures.Enum e = new Bind.Structures.Enum(); e.Name = Char.IsDigit(words[0][0]) ? Settings.ConstantPrefix + words[0] : words[0]; // And fill in the values for this enumerant do { line = NextValidLine(specFile); if (String.IsNullOrEmpty(line) || line.StartsWith("#")) continue; if (line.Contains("enum:") || specFile.EndOfStream) break; line = line.Replace('\t', ' '); words = line.Split(Utilities.Separators, StringSplitOptions.RemoveEmptyEntries); if (words.Length == 0) continue; // If we reach this point, we have found a new value for the current enumerant Constant c = new Constant(); if (line.Contains("=")) { // Trim the name's prefix, but only if not in Tao compat mode. if (Settings.Compatibility == Settings.Legacy.Tao) { } else { if (words[0].StartsWith(Settings.ConstantPrefix)) words[0] = words[0].Substring(Settings.ConstantPrefix.Length); if (Char.IsDigit(words[0][0])) words[0] = Settings.ConstantPrefix + words[0]; } c.Name = words[0]; uint number; if (UInt32.TryParse(words[2].Replace("0x", String.Empty), System.Globalization.NumberStyles.AllowHexSpecifier, null, out number)) { // The value is a number, check if it should be unchecked. if (number > 0x7FFFFFFF) { c.Unchecked = true; } } else { // The value is not a number. Strip the prefix. if (words[2].StartsWith(Settings.ConstantPrefix)) words[2] = words[2].Substring(Settings.ConstantPrefix.Length); // If the name now starts with a digit (doesn't matter whether we // stripped "GL_" above), add a "GL_" prefix. // (e.g. GL_4_BYTES). if (Char.IsDigit(words[2][0])) words[2] = Settings.ConstantPrefix + words[2]; } c.Value = words[2]; } else if (words[0] == "use") { // Trim the prefix. if (words[2].StartsWith(Settings.ConstantPrefix)) words[2] = words[2].Substring(Settings.ConstantPrefix.Length); // If the remaining string starts with a digit, we were wrong above. // Re-add the "GL_" if (Char.IsDigit(words[2][0])) words[2] = Settings.ConstantPrefix + words[2]; c.Name = words[2]; c.Reference = words[1]; c.Value = words[2]; } //if (!String.IsNullOrEmpty(c.Name) && !e.Members.Contains.Contains(c)) //SpecTranslator.Merge(e.Members, c); if (!e.ConstantCollection.ContainsKey(c.Name)) e.ConstantCollection.Add(c.Name, c); else Trace.WriteLine(String.Format( "Spec error: Constant {0} defined twice in enum {1}, discarding last definition.", c.Name, e.Name)); // Insert the current constant in the list of all constants. //SpecTranslator.Merge(complete_enum.Members, c); complete_enum = Utilities.Merge(complete_enum, c); } while (!specFile.EndOfStream); // At this point, the complete value list for the current enumerant has been read, so add this // enumerant to the list. //e.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "public enum " + e.Name)); //e.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, "public enum " + e.Name)); // (disabled) Hack - discard Boolean enum, it fsucks up the fragile translation code ahead. //if (!e.Name.Contains("Bool")) //Utilities.Merge(enums, e); //e.Translate(); if (!enums.ContainsKey(e.Name)) { enums.Add(e.Name, e); } else { // The enum already exists, merge constants. Trace.WriteLine(String.Format("Conflict: Enum {0} already exists, merging constants.", e.Name)); foreach (Constant t in e.ConstantCollection.Values) { Utilities.Merge(enums[e.Name], t); } } //enums.Add(e); } //SpecTranslator.Merge(enums, complete_enum); } while (!specFile.EndOfStream); enums.Add(complete_enum.Name, complete_enum); Trace.Unindent(); return enums; }
public virtual EnumCollection ReadEnums(StreamReader specFile) { Trace.WriteLine("Reading opengl enumerant specs."); Trace.Indent(); EnumCollection enums = new EnumCollection(); // complete_enum contains all opengl enumerants. Enum complete_enum = new Enum(); complete_enum.Name = Settings.CompleteEnumName; do { string line = NextValidLine(specFile); if (String.IsNullOrEmpty(line)) { break; } line = line.Replace('\t', ' '); // We just encountered the start of a new enumerant: while (!String.IsNullOrEmpty(line) && line.Contains("enum")) { string[] words = line.Split(Utilities.Separators, StringSplitOptions.RemoveEmptyEntries); if (words.Length == 0) { continue; } // Declare a new enumerant Enum e = new Enum(); e.Name = Char.IsDigit(words[0][0]) ? Settings.ConstantPrefix + words[0] : words[0]; // And fill in the values for this enumerant do { line = NextValidLine(specFile); if (String.IsNullOrEmpty(line) || line.StartsWith("#")) { continue; } if (line.Contains("enum:") || specFile.EndOfStream) { break; } line = line.Replace('\t', ' '); words = line.Split(Utilities.Separators, StringSplitOptions.RemoveEmptyEntries); if (words.Length == 0) { continue; } // If we reach this point, we have found a new value for the current enumerant Constant c = new Constant(); if (line.Contains("=")) { // Trim the name's prefix, but only if not in Tao compat mode. if (Settings.Compatibility == Settings.Legacy.Tao) { } else { if (words[0].StartsWith(Settings.ConstantPrefix)) { words[0] = words[0].Substring(Settings.ConstantPrefix.Length); } if (Char.IsDigit(words[0][0])) { words[0] = Settings.ConstantPrefix + words[0]; } } c.Name = words[0]; c.Value = words[2]; } else if (words[0] == "use") { // Trim the prefix. if (words[2].StartsWith(Settings.ConstantPrefix)) { words[2] = words[2].Substring(Settings.ConstantPrefix.Length); } // If the remaining string starts with a digit, we were wrong above. // Re-add the "GL_" if (Char.IsDigit(words[2][0])) { words[2] = Settings.ConstantPrefix + words[2]; } c.Name = words[2]; c.Reference = words[1]; c.Value = words[2]; } else { // Typical cause is hand-editing the specs and forgetting to add an '=' sign. throw new InvalidOperationException(String.Format( "[Error] Invalid constant definition: \"{0}\"", line)); } //if (!String.IsNullOrEmpty(c.Name) && !e.Members.Contains.Contains(c)) //SpecTranslator.Merge(e.Members, c); if (!e.ConstantCollection.ContainsKey(c.Name)) { e.ConstantCollection.Add(c.Name, c); } else { Trace.WriteLine(String.Format( "Spec error: Constant {0} defined twice in enum {1}, discarding last definition.", c.Name, e.Name)); } // Insert the current constant in the list of all constants. //SpecTranslator.Merge(complete_enum.Members, c); complete_enum = Utilities.Merge(complete_enum, c); }while (!specFile.EndOfStream); // At this point, the complete value list for the current enumerant has been read, so add this // enumerant to the list. //e.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "public enum " + e.Name)); //e.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, "public enum " + e.Name)); // (disabled) Hack - discard Boolean enum, it breaks up the fragile translation code ahead. //if (!e.Name.Contains("Bool")) //Utilities.Merge(enums, e); //e.Translate(); if (!enums.ContainsKey(e.Name)) { enums.Add(e.Name, e); } else { // The enum already exists, merge constants. foreach (Constant t in e.ConstantCollection.Values) { Utilities.Merge(enums[e.Name], t); } } } }while (!specFile.EndOfStream); enums.Add(complete_enum.Name, complete_enum); Trace.Unindent(); return(enums); }
EnumCollection ProcessNames(EnumCollection enums, XPathNavigator nav, string apiname) { EnumCollection processed_enums = new EnumCollection(); foreach (var e in enums.Values) { // Note that we cannot modify a collection while iterating over it, // so we keep a list of modified enums and remove/readd the // modified items to refresh their keys. string name = e.Name; name = ReplaceName(nav, apiname, name); name = TranslateEnumName(name); e.Name = name; processed_enums.Add(e.Name, e); } // Mark enums differing only in case as not CLS-compliant. var list = enums.Values.ToList(); while (list.Count > 0) { var e1 = list.Last(); list.RemoveAt(list.Count - 1); var e2 = list.FirstOrDefault(l => String.Compare(e1.Name, l.Name, true) == 0); if (e2 != null) { e1.CLSCompliant = false; e2.CLSCompliant = false; } } foreach (var e in enums.Values) { } return processed_enums; }
public virtual EnumCollection ReadEnums(StreamReader specFile) { Trace.WriteLine("Reading opengl enumerant specs."); Trace.Indent(); EnumCollection enums = new EnumCollection(); // complete_enum contains all opengl enumerants. Bind.Structures.Enum complete_enum = new Bind.Structures.Enum(); complete_enum.Name = Settings.CompleteEnumName; do { string line = NextValidLine(specFile); if (String.IsNullOrEmpty(line)) { break; } line = line.Replace('\t', ' '); // We just encountered the start of a new enumerant: while (!String.IsNullOrEmpty(line) && line.Contains("enum")) { string[] words = line.Split(Utilities.Separators, StringSplitOptions.RemoveEmptyEntries); if (words.Length == 0) { continue; } // Declare a new enumerant Bind.Structures.Enum e = new Bind.Structures.Enum(); e.Name = Char.IsDigit(words[0][0]) ? Settings.ConstantPrefix + words[0] : words[0]; // And fill in the values for this enumerant do { line = NextValidLine(specFile); if (String.IsNullOrEmpty(line) || line.StartsWith("#")) { continue; } if (line.Contains("enum:") || specFile.EndOfStream) { break; } line = line.Replace('\t', ' '); words = line.Split(Utilities.Separators, StringSplitOptions.RemoveEmptyEntries); if (words.Length == 0) { continue; } // If we reach this point, we have found a new value for the current enumerant Constant c = new Constant(); if (line.Contains("=")) { // Trim the name's prefix, but only if not in Tao compat mode. if (Settings.Compatibility == Settings.Legacy.Tao) { } else { if (words[0].StartsWith(Settings.ConstantPrefix)) { words[0] = words[0].Substring(Settings.ConstantPrefix.Length); } if (Char.IsDigit(words[0][0])) { words[0] = Settings.ConstantPrefix + words[0]; } } c.Name = words[0]; uint number; if (UInt32.TryParse(words[2].Replace("0x", String.Empty), System.Globalization.NumberStyles.AllowHexSpecifier, null, out number)) { // The value is a number, check if it should be unchecked. if (number > 0x7FFFFFFF) { c.Unchecked = true; } } else { // The value is not a number. Strip the prefix. if (words[2].StartsWith(Settings.ConstantPrefix)) { words[2] = words[2].Substring(Settings.ConstantPrefix.Length); } // If the name now starts with a digit (doesn't matter whether we // stripped "GL_" above), add a "GL_" prefix. // (e.g. GL_4_BYTES). if (Char.IsDigit(words[2][0])) { words[2] = Settings.ConstantPrefix + words[2]; } } c.Value = words[2]; } else if (words[0] == "use") { // Trim the prefix. if (words[2].StartsWith(Settings.ConstantPrefix)) { words[2] = words[2].Substring(Settings.ConstantPrefix.Length); } // If the remaining string starts with a digit, we were wrong above. // Re-add the "GL_" if (Char.IsDigit(words[2][0])) { words[2] = Settings.ConstantPrefix + words[2]; } c.Name = words[2]; c.Reference = words[1]; c.Value = words[2]; } //if (!String.IsNullOrEmpty(c.Name) && !e.Members.Contains.Contains(c)) //SpecTranslator.Merge(e.Members, c); if (!e.ConstantCollection.ContainsKey(c.Name)) { e.ConstantCollection.Add(c.Name, c); } else { Trace.WriteLine(String.Format( "Spec error: Constant {0} defined twice in enum {1}, discarding last definition.", c.Name, e.Name)); } // Insert the current constant in the list of all constants. //SpecTranslator.Merge(complete_enum.Members, c); complete_enum = Utilities.Merge(complete_enum, c); }while (!specFile.EndOfStream); // At this point, the complete value list for the current enumerant has been read, so add this // enumerant to the list. //e.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "public enum " + e.Name)); //e.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, "public enum " + e.Name)); // (disabled) Hack - discard Boolean enum, it fsucks up the fragile translation code ahead. //if (!e.Name.Contains("Bool")) //Utilities.Merge(enums, e); //e.Translate(); if (!enums.ContainsKey(e.Name)) { enums.Add(e.Name, e); } else { // The enum already exists, merge constants. Trace.WriteLine(String.Format("Conflict: Enum {0} already exists, merging constants.", e.Name)); foreach (Constant t in e.ConstantCollection.Values) { Utilities.Merge(enums[e.Name], t); } } //enums.Add(e); } //SpecTranslator.Merge(enums, complete_enum); }while (!specFile.EndOfStream); enums.Add(complete_enum.Name, complete_enum); Trace.Unindent(); return(enums); }