public static async Task <CurrentReport> GetAsync(Buoy buoy)
        {
            CurrentReport currentReport = new CurrentReport(buoy.Name, buoy.NbdcId);
            SpecData      specData      = new SpecData();

            string buoyStandardId = (buoy.NbdcId).ToUpper() + ".txt";
            string buoySpecId     = (buoy.NbdcId).ToUpper() + ".spec";

            string standardReportText = await GetBuoyData.FetchAsync(buoyStandardId);

            string spectralReportText = await GetBuoyData.FetchAsync(buoySpecId);

            string firstCharSpec     = (spectralReportText[0]).ToString();
            string firstCharStandard = (standardReportText[0].ToString());

            StandardData standardReport = ParseCurrentStandard.Get(standardReportText, buoy.NbdcId);

            if (firstCharSpec != "<" && firstCharStandard != "<")
            {
                specData      = ParseCurrentSpec.Get(spectralReportText, buoy.NbdcId);
                currentReport = new CurrentReport(buoy.Name, buoy.NbdcId, standardReport, specData);
            }
            else if (firstCharStandard != "<")
            {
                currentReport = new CurrentReport(buoy.Name, buoy.NbdcId, standardReport);
            }

            return(currentReport);
        }
Example #2
0
        public AmplitudeResult FindMaxAmplitudeInScope(double minFrequency = 0, double maxFrequency = 870)
        {
            var maxAmplitude = new AmplitudeResult
            {
                Amplitude = double.MinValue
            };

            var minFrequencyIndex = (int)(minFrequency / WaveFileReader.SamplingFrequency * FftLength);
            var maxFrequencyIndex = (int)(maxFrequency / WaveFileReader.SamplingFrequency * FftLength);

            foreach (var column in SpecData)
            {
                foreach (var amplitude in column.Take(maxFrequencyIndex).Skip(minFrequencyIndex))
                {
                    if (amplitude > maxAmplitude.Amplitude)
                    {
                        maxAmplitude = new AmplitudeResult
                        {
                            ColumnIndex = SpecData.IndexOf(column),
                            RowIndex    = column.IndexOf(amplitude),
                            Amplitude   = amplitude,
                            Frequency   = column.IndexOf(amplitude) * WaveFileReader.SamplingFrequency / FftLength,
                        };
                    }
                }
            }

            return(maxAmplitude);
        }
Example #3
0
        public static IEnumerable<EnumType> GetAllEnums(string cleanString, SpecData specificationData)
        {
            var enums = new List<EnumType>();

            foreach (Match eTypeMatch in EnumParser.Matches(cleanString))
            {
                var enumDefinition = new EnumType
                {
                    Name = eTypeMatch.Groups["name"].Value,
                    SpecNames = new[] { specificationData.Name }
                };
                if (eTypeMatch.Groups["enumvalues"].Length > 0)
                {
                    enumDefinition.EnumValues = GetAllEnumValues(eTypeMatch.Groups["enumvalues"].Value);
                }

                if (!enums.Contains(enumDefinition))
                {
                    enums.Add(enumDefinition);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Duplicate enum: " + enumDefinition.Name);
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
            }

            return enums;
        }
Example #4
0
        public static IEnumerable<TypeDefType> GetAllTypeDefs(string typeDefData, SpecData specificationData)
        {
            var typeDefs = new List<TypeDefType>();

            typeDefData = typeDefData.Trim('.').Trim();

            foreach (var typeDefDefinition in from Match typeDefMatch in TypeDefParser.Matches(typeDefData)
                                              select new TypeDefType
                                              {
                                                  Name = typeDefMatch.Groups["item"].Value.Trim(),
                                                  Type = typeDefMatch.Groups["type"].Value.Trim(),
                                                  SpecNames = new[] { specificationData.Name }
                                              })
            {
                if (!typeDefs.Contains(typeDefDefinition))
                {
                    typeDefs.Add(typeDefDefinition);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Duplicate typedef: " + typeDefDefinition.Name);
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
            }

            return typeDefs;
        }
Example #5
0
 public CurrentReport(string buoyName, string nbcdId, StandardData std, SpecData spc)
 {
     BuoyName = buoyName;
     NbdcId   = nbcdId;
     CurrentStandardReport = std;
     CurrentSpecReport     = spc;
     ContainsSpec          = "true";
     ContainsStandard      = "true";
 }
Example #6
0
        public static IEnumerable<DictionaryType> GetAllDictionaries(string cleanString, SpecData specificationData)
        {
            var dictionaries = new List<DictionaryType>();

            foreach (Match dictionaryMatch in DictionaryParser.Matches(cleanString))
            {
                var dictionaryDefinition = new DictionaryType
                {
                    Name = dictionaryMatch.Groups["name"].Value.Trim(),
                    IsPartial = !string.IsNullOrWhiteSpace(dictionaryMatch.Groups["partial"].Value),
                    ExtendedAttribute = CleanString(dictionaryMatch.Groups["extended"].Value),
                    SpecNames = new[] { specificationData.Name }
                };

                var constructors = dictionaryDefinition.Constructors.ToList();
                var exposed = dictionaryDefinition.Exposed.ToList();
                if (!string.IsNullOrWhiteSpace(dictionaryDefinition.ExtendedAttribute))
                {
                    foreach (Match m in DictionaryExtendedParser.Matches(dictionaryDefinition.ExtendedAttribute))
                    {
                        var constructor = m.Groups["constructor"].Value.Trim();
                        if (!string.IsNullOrWhiteSpace(constructor))
                        {
                            constructors.Add(constructor);
                        }
                        var exposedValue = RegexLibrary.GroupingCleaner.Replace(m.Groups["exposed"].Value, string.Empty);
                        if (!string.IsNullOrWhiteSpace(exposedValue))
                        {
                            exposed.AddRange(exposedValue.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(item => item.Trim()));
                        }
                    }
                }
                dictionaryDefinition.Constructors = constructors.Distinct();
                dictionaryDefinition.Exposed = exposed.Distinct();

                var inherits = dictionaryMatch.Groups["inherits"].Value;
                dictionaryDefinition.Inherits = inherits.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(api => api.Trim());
                if (dictionaryMatch.Groups["members"].Length > 0)
                {
                    dictionaryDefinition.Members = GetAllDictionaryMembers(dictionaryMatch.Groups["members"].Value, specificationData);
                }

                if (!dictionaries.Contains(dictionaryDefinition))
                {
                    dictionaries.Add(dictionaryDefinition);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Duplicate dictionary: " + dictionaryDefinition.Name);
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
            }

            return dictionaries;
        }
        private SpecData getSpecDataFor(string id)
        {
            var data = new SpecData
            {
                data    = _hierarchy.Specifications[id],
                id      = id,
                results = _results.ResultsFor(id).ToArray()
            };

            return(data);
        }
Example #8
0
        public static void ProcessFile(string fileItems, SpecData specificationData)
        {
            var cleanString = CleanString(fileItems);

            specificationData.Callbacks.AddRange(DataCollectors.GetAllCallbacks(cleanString, specificationData));
            specificationData.Dictionaries.AddRange(DataCollectors.GetAllDictionaries(cleanString, specificationData));
            specificationData.Enumerations.AddRange(DataCollectors.GetAllEnums(cleanString, specificationData));
            specificationData.Implements.AddRange(DataCollectors.GetAllImplements(cleanString, specificationData));
            specificationData.Interfaces.AddRange(DataCollectors.GetAllInterfaces(cleanString, specificationData));
            specificationData.Namespaces.AddRange(DataCollectors.GetAllNamespaces(cleanString, specificationData));
            specificationData.TypeDefs.AddRange(DataCollectors.GetAllTypeDefs(cleanString, specificationData));
        }
Example #9
0
        private SpecData SMemGetSpec()
        {
            SpecData s  = new SpecData();
            Spec     sp = ((BIDSSharedMemoryData)Marshal.PtrToStructure(pMemory, typeof(BIDSSharedMemoryData))).SpecData;

            s.ATSCheck = sp.A;
            s.B67      = sp.J;
            s.Brake    = sp.B;
            s.CarNum   = sp.C;
            s.Power    = sp.P;
            return(s);
        }
Example #10
0
        public static void ProcessRespec(IEnumerable<IElement> respecItems, string selector, SpecData specificationData)
        {
            var cleanString = CleanString(GenerateRespecIdls(respecItems, selector));

            specificationData.Callbacks.AddRange(DataCollectors.GetAllCallbacks(cleanString, specificationData));
            specificationData.Dictionaries.AddRange(DataCollectors.GetAllDictionaries(cleanString, specificationData));
            specificationData.Enumerations.AddRange(DataCollectors.GetAllEnums(cleanString, specificationData));
            specificationData.Implements.AddRange(DataCollectors.GetAllImplements(cleanString, specificationData));
            specificationData.Interfaces.AddRange(DataCollectors.GetAllInterfaces(cleanString, specificationData));
            specificationData.Namespaces.AddRange(DataCollectors.GetAllNamespaces(cleanString, specificationData));
            specificationData.TypeDefs.AddRange(DataCollectors.GetAllTypeDefs(cleanString, specificationData));
        }
Example #11
0
        private static void MergeDictionaries(SpecData data, bool keepPartials, ref SortedDictionary<string, DictionaryType> finalDictionaryTypes)
        {
            foreach (var dictionaryType in data.Dictionaries)
            {
                var dictionaryName = dictionaryType.Name;

                if (!finalDictionaryTypes.ContainsKey(dictionaryName))
                {
                    if (!keepPartials)
                    {
                        dictionaryType.IsPartial = false;
                    }

                    finalDictionaryTypes.Add(dictionaryName, dictionaryType);
                    continue;
                }

                var currentDictionary = finalDictionaryTypes[dictionaryName];
                if (!keepPartials)
                {
                    currentDictionary.IsPartial = false;
                }

                currentDictionary.Constructors = currentDictionary.Constructors.Union(dictionaryType.Constructors);
                currentDictionary.Exposed = currentDictionary.Exposed.Union(dictionaryType.Exposed).OrderBy(a => a);
                currentDictionary.Inherits = currentDictionary.Inherits.Union(dictionaryType.Inherits).OrderBy(a => a);
                currentDictionary.SpecNames = currentDictionary.SpecNames.Union(dictionaryType.SpecNames).OrderBy(a => a);

                var sortedMembers = new SortedDictionary<string, DictionaryMember>(currentDictionary.Members.ToDictionary(a => a.Name, b => b));
                foreach (var member in dictionaryType.Members)
                {
                    var memberName = member.Name;

                    if (!sortedMembers.ContainsKey(memberName))
                    {
                        sortedMembers.Add(memberName, member);
                    }

                    var currentMemeber = sortedMembers[memberName];

                    currentMemeber.Clamp = currentMemeber.Clamp || member.Clamp;
                    currentMemeber.EnforceRange = currentMemeber.EnforceRange || member.EnforceRange;

                    currentMemeber.SpecNames = currentMemeber.SpecNames.Union(member.SpecNames).OrderBy(a => a);

                    sortedMembers[memberName] = currentMemeber;
                }

                currentDictionary.Members = sortedMembers.Values;

                finalDictionaryTypes[dictionaryName] = currentDictionary;
            }
        }
Example #12
0
 public static void ProcessIdl(IEnumerable<IElement> idlItems, SpecData specificationData)
 {
     foreach (var cleanString in idlItems.Select(item => CleanString(item.TextContent)))
     {
         specificationData.Callbacks.AddRange(DataCollectors.GetAllCallbacks(cleanString, specificationData));
         specificationData.Dictionaries.AddRange(DataCollectors.GetAllDictionaries(cleanString, specificationData));
         specificationData.Enumerations.AddRange(DataCollectors.GetAllEnums(cleanString, specificationData));
         specificationData.Implements.AddRange(DataCollectors.GetAllImplements(cleanString, specificationData));
         specificationData.Interfaces.AddRange(DataCollectors.GetAllInterfaces(cleanString, specificationData));
         specificationData.Namespaces.AddRange(DataCollectors.GetAllNamespaces(cleanString, specificationData));
         specificationData.TypeDefs.AddRange(DataCollectors.GetAllTypeDefs(cleanString, specificationData));
     }
 }
Example #13
0
        private string CreateWebIdl(SpecData specData)
        {
            var finalRecreate = new StringBuilder();

            foreach (var enumerationType in specData.Enumerations)
            {
                finalRecreate.AppendLine(enumerationType.Reconstruct());
            }

            foreach (var typeDefType in specData.TypeDefs)
            {
                finalRecreate.AppendLine(typeDefType.Reconstruct());
            }

            foreach (var callbackType in specData.Callbacks)
            {
                finalRecreate.AppendLine(callbackType.Reconstruct());
            }

            foreach (var dictionaryType in specData.Dictionaries)
            {
                finalRecreate.AppendLine(dictionaryType.Reconstruct(_showSpecNames));
            }

            foreach (var namespaceType in specData.Namespaces)
            {
                finalRecreate.AppendLine(namespaceType.Reconstruct(_showSpecNames));
            }

            foreach (var interfaceType in specData.Interfaces)
            {
                var name = interfaceType.Name;
                finalRecreate.Append(interfaceType.Reconstruct(_showSpecNames));
                if (specData.Implements.Exists(a => a.DestinationInterface.Equals(name, StringComparison.OrdinalIgnoreCase)))
                {
                    var thisTypeImplements =
                        specData.Implements.FindAll(
                            a => a.DestinationInterface.Equals(name, StringComparison.OrdinalIgnoreCase))
                            .Distinct(new ImplementsCompare())
                            .OrderBy(s => s.OriginatorInterface)
                            .ToList();
                    foreach (var implements in thisTypeImplements)
                    {
                        finalRecreate.AppendLine(implements.Reconstruct);
                    }
                }
                finalRecreate.AppendLine();
            }

            return finalRecreate.ToString().Trim();
        }
Example #14
0
        public static IEnumerable<CallbackType> GetAllCallbacks(string callbackData, SpecData specificationData)
        {
            var callbackDefs = new List<CallbackType>();

            callbackData = callbackData.Trim('.').Trim();

            foreach (var callbackDefinition in from Match callbackMatch in CallbackParser.Matches(callbackData)
                                               select new CallbackType(callbackMatch.Groups["name"].Value.Trim())
                                               {
                                                   Type = RegexLibrary.OldTypeCleaner.Replace(RegexLibrary.TypeCleaner.Replace(callbackMatch.Groups["type"].Value.Replace("≺", "<").Replace("≻", ">"), "?"), string.Empty).Trim(),
                                                   Args = callbackMatch.Groups["args"].Value.Trim(),
                                                   ExtendedAttribute = callbackMatch.Groups["extended"].Value.Trim(),
                                                   SpecNames = new[] { specificationData.Name }
                                               })
            {
                if (!string.IsNullOrWhiteSpace(callbackDefinition.ExtendedAttribute))
                {
                    //Designed for future expansion of extended attributes
                    foreach (Match cep in CallbackExtendedParser.Matches(callbackDefinition.ExtendedAttribute))
                    {
                        callbackDefinition.TreatNonObjectAsNull = !string.IsNullOrWhiteSpace(cep.Groups["treatnonobjectasnull"].Value.Trim());
                    }
                }

                try
                {
                    callbackDefinition.ArgTypes = GetArgTypes(callbackDefinition.Args);
                }
                catch (ArgumentException)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Fail argument for callback- " + callbackDefinition.Name);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    continue;
                }

                if (!callbackDefs.Contains(callbackDefinition))
                {
                    callbackDefs.Add(callbackDefinition);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Duplicate callback: " + callbackDefinition.Name);
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
            }

            return callbackDefs;
        }
Example #15
0
    private void ShowSpecs(List <ProductInfo> list)
    {
        Hide();
        _bulletinWindow.ShowScrool();

        for (int i = 0; i < list.Count; i++)
        {
            var spec = new SpecData(list[i]);

            var a = SpecTile.CreateTile(_bulletinWindow.Content.gameObject.transform, spec,
                                        new Vector3());

            _reportsSpec.Add(a);
        }
    }
Example #16
0
        public static IEnumerable<NamespaceType> GetAllNamespaces(string cleanString, SpecData specificationData)
        {
            var namespaces = new List<NamespaceType>();

            foreach (Match _namespace in NamespaceParser.Matches(cleanString))
            {
                var namespaceDefinition = new NamespaceType
                {
                    Name = _namespace.Groups["name"].Value.Trim(),
                    IsPartial = !string.IsNullOrWhiteSpace(_namespace.Groups["partial"].Value.Trim()),
                    ExtendedAttribute = CleanString(_namespace.Groups["extended"].Value),
                    SpecNames = new[] { specificationData.Name }
                };

                if (!string.IsNullOrWhiteSpace(namespaceDefinition.ExtendedAttribute))
                {
                    var exposed = namespaceDefinition.Exposed.ToList();

                    foreach (Match m in NamespaceExtendedParser.Matches(namespaceDefinition.ExtendedAttribute))
                    {
                        namespaceDefinition.SecureContext = namespaceDefinition.SecureContext || !string.IsNullOrWhiteSpace(m.Groups["securecontext"].Value.Trim());

                        var exposedValue = RegexLibrary.GroupingCleaner.Replace(m.Groups["exposed"].Value, string.Empty);
                        if (!string.IsNullOrWhiteSpace(exposedValue))
                        {
                            exposed.AddRange(exposedValue.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(api => api.Trim()));
                        }
                    }

                    namespaceDefinition.Exposed = exposed.Distinct();
                }

                namespaceDefinition.Members = _namespace.Groups["members"].Length > 0 ? GetAllNamespaceMembers(_namespace.Groups["members"].Value, specificationData) : new List<NamespaceMember>();

                if (!namespaces.Contains(namespaceDefinition))
                {
                    namespaces.Add(namespaceDefinition);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Duplicate namespace: " + namespaceDefinition.Name);
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
            }

            return namespaces;
        }
Example #17
0
        private static IEnumerable<DictionaryMember> GetAllDictionaryMembers(string memberItems, SpecData specificationData)
        {
            var memberList = new List<DictionaryMember>();

            memberItems = CleanString(memberItems);

            var members = memberItems.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(m => m.Trim()).ToArray();

            foreach (var item in members)
            {
                if (DictionaryMemberParser.IsMatch(item))
                {
                    var m = DictionaryMemberParser.Match(item);

                    var memberItem = new DictionaryMember(m.Groups["item"].Value.Trim())
                    {
                        ExtendedAttribute = m.Groups["extended"].Value.Trim(),
                        Type = RegexLibrary.OldTypeCleaner.Replace(RegexLibrary.TypeCleaner.Replace(m.Groups["type"].Value.Replace("≺", "<").Replace("≻", ">"), "?"), string.Empty).Trim(),
                        Value = m.Groups["value"].Value.Trim(),
                        IsRequired = !string.IsNullOrWhiteSpace(m.Groups["required"].Value.Trim()),
                        SpecNames = new[] { specificationData.Name }
                    };

                    if (!string.IsNullOrWhiteSpace(memberItem.ExtendedAttribute))
                    {
                        foreach (Match mep in DictionaryMemberExtendedParser.Matches(memberItem.ExtendedAttribute))
                        {
                            memberItem.Clamp = memberItem.Clamp || !string.IsNullOrWhiteSpace(mep.Groups["clamp"].Value.Trim());
                            memberItem.EnforceRange = memberItem.EnforceRange || !string.IsNullOrWhiteSpace(mep.Groups["enforcerange"].Value.Trim());
                        }
                    }

                    if (!memberList.Contains(memberItem))
                    {
                        memberList.Add(memberItem);
                    }
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Fail dictionary memember- " + item);
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
            }

            return memberList;
        }
Example #18
0
        // method required text data in string format as well as the buoy id
        public static List <SpecData> Get(string waveReportText, string buoyId)
        {
            // create an empty list to hold the hourly info report objects parsed from the text
            List <SpecData> reports = new List <SpecData>();
            // a counter to keep track of which line in the text file we are at
            int count = 0;
            // string pattern to match each line from the text data. Each line contains the data
            // for one hourly report
            string pattern = @"\n\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+";

            // itterate through the string pattern matches
            foreach (Match m in Regex.Matches(waveReportText, pattern))
            {
                // increase count. The first two lines matched are just headings
                // and do not contain data
                count++;
                if (count > 1)
                {
                    // create a list to hold all the individual data
                    // parsed from each line
                    List <string> properties = new List <string>();
                    // create another string pattern to match each reading
                    // from the report
                    string secondPattern = @"\S+";
                    // itterate through the pattern matches
                    foreach (Match mm in Regex.Matches(m.Value, secondPattern))
                    {
                        // add each peice of data to the list
                        properties.Add(mm.Value);
                    }
                    // use a constructor function to create a new instance of a
                    // report object containing all the data from the current hourly report
                    SpecData report = new SpecData(properties[0], properties[1], properties[2],
                                                   properties[3], properties[4], properties[5], properties[6], properties[7],
                                                   properties[8], properties[9], properties[10], properties[11], properties[12],
                                                   properties[13], properties[14], buoyId);

                    // add the report to the list of reports
                    reports.Add(report);
                }
            }

            // return the reports
            return(reports);
        }
Example #19
0
    private void ShowSpecs(List <ProductInfo> list)
    {
        Hide();
        _bulletinWindow.ShowScrool();

        for (int i = 0; i < list.Count; i++)
        {
            var iniPosHere = _bulletinWindow.ScrollIniPosGo.transform.localPosition +
                             new Vector3(0, -3.5f * i, 0);

            var spec = new SpecData(list[i]);

            var a = SpecTile.CreateTile(_bulletinWindow.Content.gameObject.transform, spec,
                                        iniPosHere);

            _reportsSpec.Add(a);
        }
    }
Example #20
0
    internal static SpecTile CreateTile(Transform container, SpecData spec, Vector3 iniPos, string specialInfo = "")
    {
        SpecTile obj = null;

        obj = (SpecTile)Resources.Load(Root.spec_Tile, typeof(SpecTile));
        obj = (SpecTile)Instantiate(obj, new Vector3(), Quaternion.identity);

        var iniScale = obj.transform.localScale;

        obj.transform.SetParent(container);
        obj.transform.localPosition = iniPos;
        obj.transform.localScale    = iniScale;

        obj.Spec        = spec;
        obj.SpecialInfo = specialInfo;

        return(obj);
    }
Example #21
0
        public static SpecData MergeSpecData(IEnumerable<SpecData> allSpecData, string name, bool keepPartials = false)
        {
            var finalInterfaceTypes = new SortedDictionary<string, InterfaceType>();
            var finalCallbackTypes = new SortedDictionary<string, CallbackType>();
            var finalDictionaryTypes = new SortedDictionary<string, DictionaryType>();
            var finalNamespaceTypes = new SortedDictionary<string, NamespaceType>();
            var finalImplementsTypes = new Dictionary<Tuple<string, string>, ImplementsType>();
            var finalTypeDefsTypes = new SortedDictionary<string, TypeDefType>();
            var finalEnumTypes = new SortedDictionary<string, EnumType>();

            //Consolidate all specs into merged interfaces, dictionaries, callbacks, etc..., merge partials
            foreach (var specData in allSpecData)
            {
                //Merge partials
                MergeInterfaces(specData, keepPartials, ref finalInterfaceTypes);

                MergeCallbacks(specData, ref finalCallbackTypes);

                MergeDictionaries(specData, keepPartials, ref finalDictionaryTypes);

                MergeNamespaces(specData, keepPartials, ref finalNamespaceTypes);

                MergeImplements(specData, ref finalImplementsTypes);

                MergeTypeDefs(specData, ref finalTypeDefsTypes);

                MergeEnumerations(specData, ref finalEnumTypes);
            }

            var fullSpecData = new SpecData
            {
                Name = name,
                Interfaces = finalInterfaceTypes.Values.ToList(),
                Callbacks = finalCallbackTypes.Values.ToList(),
                Dictionaries = finalDictionaryTypes.Values.ToList(),
                Namespaces = finalNamespaceTypes.Values.ToList(),
                Implements = finalImplementsTypes.Values.ToList(),
                TypeDefs = finalTypeDefsTypes.Values.ToList(),
                Enumerations = finalEnumTypes.Values.ToList()
            };

            return fullSpecData;
        }
Example #22
0
        public SpecData LoadSpecification(string id)
        {
            return(_lock.Read(() =>
            {
                if (!_hierarchy.Specifications.Has(id))
                {
                    return null;
                }

                var data = new SpecData
                {
                    data = _hierarchy.Specifications[id],
                    id = id,
                    results = Results.ResultsFor(id).ToArray()
                };

                return data;
            }));
        }
Example #23
0
        public void SpecReadInContextTest()
        {
            SpecFile spec         = SpecFile.ParseContractFile("..\\..\\Contracts\\test.RnR", SpecFileFormat.Ini);
            string   testBytesStr = @"03 F2 00 00 00 08 00 00 00 04 C8 02 00 B8";

            byte[] readBytes = TypeCache.HexPatternStringToByteArray(testBytesStr);

            MemoryStream readSrc  = new MemoryStream(readBytes);
            MemoryStream writeSrc = new MemoryStream();

            using (StreamContext sc = new StreamContext(spec, readSrc, writeSrc))
            {
                Dictionary <string, object> ReqDict = sc.GetContextRequest();
                if (!SpecData.ReadAs <short>(ReqDict, "ESP_SuccessFlag").Equals((short)1010))
                {
                    Console.WriteLine("*读取数据错误!");
                }
                else
                {
                    sc.SetPosition(0);

                    Dictionary <string, object> result = new Dictionary <string, object>(StringComparer.InvariantCultureIgnoreCase);
                    //result["ESP_SuccessFlag"] = (short)1010;
                    result["ESP_SuccessFlag"]  = "Success";
                    result["ESP_CustomCode"]   = (int)0008;
                    result["ESP_LeaveLength"]  = (int)4;
                    result["ESP_TransferData"] = TypeCache.HexPatternStringToByteArray(@"C8 02 00 B8");
                    sc.WriteContextResponse(result);
                }

                if (writeSrc.Length > 0)
                {
                    string result = TypeCache.ByteArrayToHexString(writeSrc.ToArray());
                    Console.WriteLine(result);
                    Debug.Assert(testBytesStr == result);
                }
                else
                {
                    Console.WriteLine("*没有写入数据!");
                }
                writeSrc.Dispose();
            }
        }
Example #24
0
        private static void MergeCallbacks(SpecData data, ref SortedDictionary<string, CallbackType> finalCallbackTypes)
        {
            foreach (var callbackType in data.Callbacks)
            {
                var callbackName = callbackType.Name;

                if (!finalCallbackTypes.ContainsKey(callbackName))
                {
                    finalCallbackTypes.Add(callbackName, callbackType);
                    continue;
                }

                var currentCallback = finalCallbackTypes[callbackName];

                currentCallback.TreatNonObjectAsNull = currentCallback.TreatNonObjectAsNull || callbackType.TreatNonObjectAsNull;

                currentCallback.SpecNames = currentCallback.SpecNames.Union(callbackType.SpecNames).OrderBy(a => a);

                finalCallbackTypes[callbackName] = currentCallback;
            }
        }
Example #25
0
        public static SpecData Get(string waveReportText, string buoyId)
        {
            Console.WriteLine(waveReportText);
            int      count   = 0;
            string   pattern = @"\n\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+";
            SpecData report  = new SpecData();

            foreach (Match m in Regex.Matches(waveReportText, pattern))
            {
                count++;
                List <string> properties = new List <string>();

                // the third line is the first line of data, so check the counter
                // for a value of 2
                if (count == 2)
                {
                    string secondPattern = @"\S+";
                    foreach (Match mm in Regex.Matches(m.Value, secondPattern))
                    {
                        string prop = mm.Value;
                        properties.Add(prop);
                    }

                    report = new SpecData(properties[0], properties[1],
                                          properties[2], properties[3], properties[4],
                                          properties[5], properties[6], properties[7],
                                          properties[8], properties[9], properties[10],
                                          properties[11], properties[12], properties[13],
                                          properties[14], buoyId);
                }

                // break the loop after it reads the third line
                if (count == 2)
                {
                    break;
                }
            }
            return(report);
        }
Example #26
0
        public void AnalyzeValues()
        {
            if (WaveFileReader.Samples.Count == 0)
            {
                return;
            }

            var audioBatches = SplitIntoChunks(WaveFileReader.Samples, FftLength);

            foreach (var batch in audioBatches)
            {
                var samples = (List <float>)batch;
                if (samples.Count < FftLength)
                {
                    continue;
                }

                LastFftSamples = new Complex[FftLength];
                foreach (var sample in samples)
                {
                    var i = samples.IndexOf(sample);
                    LastFftSamples[i].X = (float)(sample * FastFourierTransform.HammingWindow(i, FftLength));
                    LastFftSamples[i].Y = 0;
                }

                FastFourierTransform.FFT(true, (int)Math.Log(FftLength, 2.0), LastFftSamples);

                var specDataColumn = new List <double>();
                foreach (var sampleAfterFFT in LastFftSamples)
                {
                    var magnitude     = 2 * Math.Sqrt(sampleAfterFFT.X * sampleAfterFFT.X + sampleAfterFFT.Y * sampleAfterFFT.Y) / FftLength;
                    var amplitudeInDb = 10 * Math.Log10(magnitude);
                    specDataColumn.Add(amplitudeInDb);
                }
                specDataColumn.Reverse();
                SpecData.Add(specDataColumn);
            }
        }
        private void ComputeData(ComputationContext context, int index, NodeId node, string path)
        {
            var data = new SpecData();

            data.Path = path;

            context.Visitor.VisitTransitiveDependencies(node, context.Dependencies, n => true);
            data.DependencyCount = context.Dependencies.VisitedCount;

            context.Visitor.VisitTransitiveDependents(node, context.Dependents, n =>
            {
                context.DependentSet.Add(n);
                return(true);
            });

            data.DependentCount = context.Dependents.VisitedCount;

            context.Visitor.VisitTransitiveDependencies(context.DependentSet, context.Dependencies, n => true);
            data.ImpliedDependencyCount = context.Dependencies.VisitedCount;

            m_results[index] = data;

            context.Clear();
        }
Example #28
0
        public static IEnumerable<ImplementsType> GetAllImplements(string cleanString, SpecData specificationData)
        {
            var implements = new List<ImplementsType>();

            foreach (var implementsDefinition in from Match implementsMatch in ImplementsParser.Matches(cleanString)
                                                 select new ImplementsType(implementsMatch.Groups["destination"].Value.Trim(), implementsMatch.Groups["originator"].Value.Trim())
                                                 {
                                                     SpecNames = new[] { specificationData.Name }
                                                 })
            {
                if (!implements.Contains(implementsDefinition))
                {
                    implements.Add(implementsDefinition);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Duplicate implements: " + implementsDefinition.DestinationInterface + " " + implementsDefinition.OriginatorInterface);
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
            }

            return implements;
        }
Example #29
0
        private SpecData PipeGetSpec()
        {
            SpecData rd = new SpecData();

            return(rd);
        }
Example #30
0
        private static void MergeImplements(SpecData data, ref Dictionary<Tuple<string, string>, ImplementsType> finalImplementsTypes)
        {
            foreach (var implementsType in data.Implements)
            {
                var implementsKey = implementsType.Key;

                if (!finalImplementsTypes.ContainsKey(implementsKey))
                {
                    finalImplementsTypes.Add(implementsKey, implementsType);
                    continue;
                }

                var currentImplements = finalImplementsTypes[implementsKey];
                currentImplements.SpecNames = currentImplements.SpecNames.Union(implementsType.SpecNames).OrderBy(a => a);

                finalImplementsTypes[implementsKey] = currentImplements;
            }
        }
Example #31
0
        private static void MergeEnumerations(SpecData data, ref SortedDictionary<string, EnumType> finalEnumTypes)
        {
            foreach (var enumType in data.Enumerations)
            {
                var enumTypeName = enumType.Name;

                if (!finalEnumTypes.ContainsKey(enumTypeName))
                {
                    finalEnumTypes.Add(enumTypeName, enumType);
                    continue;
                }

                var currentEnumeration = finalEnumTypes[enumTypeName];
                currentEnumeration.SpecNames = currentEnumeration.SpecNames.Union(enumType.SpecNames).OrderBy(a => a);

                finalEnumTypes[enumTypeName] = currentEnumeration;
            }
        }
Example #32
0
        public static IEnumerable<InterfaceType> GetAllInterfaces(string cleanString, SpecData specificationData)
        {
            var interfaces = new List<InterfaceType>();

            foreach (Match iface in InterfaceParser.Matches(cleanString))
            {
                var interfaceDefinition = new InterfaceType
                {
                    Name = iface.Groups["name"].Value.Trim(),
                    IsPartial = !string.IsNullOrWhiteSpace(iface.Groups["partial"].Value.Trim()),
                    IsCallback = !string.IsNullOrWhiteSpace(iface.Groups["callback"].Value.Trim()),
                    ExtendedAttribute = CleanString(iface.Groups["extended"].Value),
                    SpecNames = new[] { specificationData.Name }
                };

                if (!string.IsNullOrWhiteSpace(interfaceDefinition.ExtendedAttribute))
                {
                    var constructors = interfaceDefinition.Constructors.ToList();
                    var namedConstructors = interfaceDefinition.NamedConstructors.ToList();
                    var exposed = interfaceDefinition.Exposed.ToList();
                    var globals = interfaceDefinition.Globals.ToList();
                    var primaryGlobals = interfaceDefinition.PrimaryGlobals.ToList();
                    foreach (Match m in InterfaceExtendedParser.Matches(interfaceDefinition.ExtendedAttribute))
                    {
                        interfaceDefinition.IsGlobal = interfaceDefinition.IsGlobal || !string.IsNullOrWhiteSpace(m.Groups["global"].Value.Trim());
                        interfaceDefinition.ImplicitThis = interfaceDefinition.ImplicitThis || !string.IsNullOrWhiteSpace(m.Groups["implicitthis"].Value.Trim());
                        interfaceDefinition.ArrayClass = interfaceDefinition.ArrayClass || !string.IsNullOrWhiteSpace(m.Groups["arrayclass"].Value.Trim());
                        interfaceDefinition.LegacyArrayClass = interfaceDefinition.LegacyArrayClass || !string.IsNullOrWhiteSpace(m.Groups["legacyarrayclass"].Value.Trim());
                        interfaceDefinition.LegacyUnenumerableNamedProperties = interfaceDefinition.LegacyUnenumerableNamedProperties || !string.IsNullOrWhiteSpace(m.Groups["legacyunenumerablenamedproperties"].Value.Trim());
                        interfaceDefinition.NoInterfaceObject = interfaceDefinition.NoInterfaceObject || !string.IsNullOrWhiteSpace(m.Groups["nointerfaceobject"].Value.Trim());
                        interfaceDefinition.OverrideBuiltins = interfaceDefinition.OverrideBuiltins || !string.IsNullOrWhiteSpace(m.Groups["overridebuiltins"].Value.Trim());
                        interfaceDefinition.IsPrimaryGlobal = interfaceDefinition.IsPrimaryGlobal || !string.IsNullOrWhiteSpace(m.Groups["primaryglobal"].Value.Trim());
                        interfaceDefinition.SecureContext = interfaceDefinition.SecureContext || !string.IsNullOrWhiteSpace(m.Groups["securecontext"].Value.Trim());
                        interfaceDefinition.Unforgeable = interfaceDefinition.Unforgeable || !string.IsNullOrWhiteSpace(m.Groups["unforgeable"].Value.Trim());

                        var constructor = m.Groups["constructor"].Value.Trim();
                        if (!string.IsNullOrWhiteSpace(constructor))
                        {
                            constructors.Add(RegexLibrary.ParenCleaner.Replace(constructor, string.Empty));
                        }
                        var named = m.Groups["namedconstructor"].Value.Trim();
                        if (!string.IsNullOrWhiteSpace(named))
                        {
                            namedConstructors.Add(named);
                        }
                        var exposedValue = RegexLibrary.GroupingCleaner.Replace(m.Groups["exposed"].Value, string.Empty);
                        if (!string.IsNullOrWhiteSpace(exposedValue))
                        {
                            exposed.AddRange(exposedValue.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(api => api.Trim()));
                        }
                        var globalsValue = RegexLibrary.GroupingCleaner.Replace(m.Groups["globals"].Value, string.Empty);
                        if (!string.IsNullOrWhiteSpace(globalsValue))
                        {
                            globals.AddRange(globalsValue.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(api => api.Trim()));
                        }
                        var primaryGlobalsValue = RegexLibrary.GroupingCleaner.Replace(m.Groups["primaryglobals"].Value, string.Empty);
                        if (!string.IsNullOrWhiteSpace(primaryGlobalsValue))
                        {
                            primaryGlobals.AddRange(primaryGlobalsValue.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(api => api.Trim()));
                        }
                    }
                    interfaceDefinition.Constructors = constructors.Distinct();
                    interfaceDefinition.NamedConstructors = namedConstructors.Distinct();
                    interfaceDefinition.Exposed = exposed.Distinct();
                    interfaceDefinition.Globals = globals.Distinct();
                    interfaceDefinition.PrimaryGlobals = primaryGlobals.Distinct();
                }

                var inherits = iface.Groups["inherits"].Value;
                interfaceDefinition.Inherits = inherits.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(api => api.Trim());
                interfaceDefinition.Members = iface.Groups["members"].Length > 0 ? GetAllInterfaceMembers(iface.Groups["members"].Value, specificationData, ref interfaceDefinition) : new List<Member>();

                if (!interfaces.Contains(interfaceDefinition))
                {
                    interfaces.Add(interfaceDefinition);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Duplicate interface: " + interfaceDefinition.Name);
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
            }

            return interfaces;
        }
Example #33
0
 public JsonDataBuilder(SpecData allCombinedSpecData)
 {
     _specData = allCombinedSpecData;
 }
Example #34
0
 public abstract string Generate(SpecData spec);
Example #35
0
        private static IEnumerable<Member> GetAllInterfaceMembers(string memberItems, SpecData specificationData, ref InterfaceType interfaceDefinition)
        {
            var memberList = new List<Member>();

            memberItems = CleanString(memberItems);

            var members = memberItems.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(m => m.Trim()).ToArray();

            foreach (var item in members.Where(item => !string.IsNullOrWhiteSpace(item)))
            {
                if (IndividualInterfaceMember.IsMatch(item))
                {
                    var m = IndividualInterfaceMember.Match(item);

                    var isProperty = !string.IsNullOrWhiteSpace(m.Groups["attribute"].Value) &&
                                    string.IsNullOrWhiteSpace(m.Groups["function"].Value) &&
                                    string.IsNullOrWhiteSpace(m.Groups["maplike"].Value) &&
                                    string.IsNullOrWhiteSpace(m.Groups["setlike"].Value) &&
                                    !(RegexLibrary.TypeCleaner.Replace(m.Groups["type"].Value, "?")
                                        .Trim())
                                        .Equals("function", StringComparison.OrdinalIgnoreCase);

                    var name = m.Groups["item"].Value.Trim();
                    //Skip special CSSOM definitions
                    if (new[] { "_camel_cased_attribute", "_webkit_cased_attribute", "_dashed_attribute" }.Contains(name))
                    {
                        continue;
                    }
                    var memberItem = new Member(name)
                    {
                        Type = RegexLibrary.OldTypeCleaner.Replace(RegexLibrary.TypeCleaner.Replace(m.Groups["type"].Value.Replace("≺", "<").Replace("≻", ">"), "?"), string.Empty).Trim(),
                        Args = m.Groups["args"].Value.Trim(),
                        Function = !string.IsNullOrWhiteSpace(m.Groups["function"].Value),
                        Attribute = !string.IsNullOrWhiteSpace(m.Groups["attribute"].Value),
                        ExtendedAttribute = m.Groups["extended"].Value.Trim(),
                        Static = !string.IsNullOrWhiteSpace(m.Groups["static"].Value),
                        HasGet = isProperty,
                        Getter = !string.IsNullOrWhiteSpace(m.Groups["getter"].Value),
                        Setter = !string.IsNullOrWhiteSpace(m.Groups["setter"].Value),
                        Creator = !string.IsNullOrWhiteSpace(m.Groups["creator"].Value),
                        Deleter = !string.IsNullOrWhiteSpace(m.Groups["deleter"].Value),
                        LegacyCaller = !string.IsNullOrWhiteSpace(m.Groups["legacycaller"].Value),
                        Stringifier = !string.IsNullOrWhiteSpace(m.Groups["stringifier"].Value),
                        Serializer = !string.IsNullOrWhiteSpace(m.Groups["serializer"].Value),
                        Inherit = !string.IsNullOrWhiteSpace(m.Groups["inherit"].Value),
                        MapLike = !string.IsNullOrWhiteSpace(m.Groups["maplike"].Value),
                        SetLike = !string.IsNullOrWhiteSpace(m.Groups["setlike"].Value),
                        Readonly = !string.IsNullOrWhiteSpace(m.Groups["readonly"].Value) || !string.IsNullOrWhiteSpace(m.Groups["setraises"].Value),
                        Required = !string.IsNullOrWhiteSpace(m.Groups["required"].Value),
                        Iterable = !string.IsNullOrWhiteSpace(m.Groups["iterable"].Value),
                        LegacyIterable = !string.IsNullOrWhiteSpace(m.Groups["legacyiterable"].Value),
                        Bracket = m.Groups["bracket"].Value.Trim(),
                        Const = !string.IsNullOrWhiteSpace(m.Groups["const"].Value),
                        Value = m.Groups["value"].Value.Trim(),
                        SpecNames = new[] { specificationData.Name }
                    };

                    if (!string.IsNullOrWhiteSpace(memberItem.ExtendedAttribute))
                    {
                        var exposed = new List<string>();
                        foreach (Match mep in MemberExtendedParser.Matches(memberItem.ExtendedAttribute))
                        {
                            memberItem.Clamp = memberItem.Clamp || !string.IsNullOrWhiteSpace(mep.Groups["clamp"].Value.Trim());
                            memberItem.EnforceRange = memberItem.EnforceRange || !string.IsNullOrWhiteSpace(mep.Groups["enforcerange"].Value.Trim());
                            memberItem.LenientSetter = memberItem.LenientSetter || !string.IsNullOrWhiteSpace(mep.Groups["lenientsetter"].Value.Trim());
                            memberItem.LenientThis = memberItem.LenientThis || !string.IsNullOrWhiteSpace(mep.Groups["lenientthis"].Value.Trim());
                            memberItem.NewObject = memberItem.NewObject || !string.IsNullOrWhiteSpace(mep.Groups["newobject"].Value.Trim());
                            memberItem.PutForwards = mep.Groups["putforwards"].Value.Trim();
                            memberItem.Replaceable = memberItem.Replaceable || !string.IsNullOrWhiteSpace(mep.Groups["replaceable"].Value.Trim());
                            memberItem.SameObject = memberItem.SameObject || !string.IsNullOrWhiteSpace(mep.Groups["sameobject"].Value.Trim());
                            memberItem.SecureContext = memberItem.SecureContext || !string.IsNullOrWhiteSpace(mep.Groups["securecontext"].Value.Trim());
                            memberItem.TreatNullAs = mep.Groups["treatnullas"].Value.Trim();
                            memberItem.TreatUndefinedAs = mep.Groups["treatundefinedas"].Value.Trim();
                            memberItem.Unforgeable = memberItem.Unforgeable || !string.IsNullOrWhiteSpace(mep.Groups["unforgeable"].Value.Trim());
                            memberItem.Unscopeable = memberItem.Unscopeable || !string.IsNullOrWhiteSpace(mep.Groups["unscopeable"].Value.Trim());

                            var exposedValue = RegexLibrary.GroupingCleaner.Replace(mep.Groups["exposed"].Value, string.Empty);
                            if (!string.IsNullOrWhiteSpace(exposedValue))
                            {
                                exposed.AddRange(exposedValue.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(api => api.Trim()));
                            }
                        }
                        memberItem.Exposed = exposed.Distinct();
                    }

                    try
                    {
                        memberItem.ArgTypes = GetArgTypes(memberItem.Args);
                    }
                    catch (ArgumentException)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Fail argument for member- " + item);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        continue;
                    }

                    memberItem.HasSet = (!memberItem.Readonly & isProperty) ||
                                        (memberItem.Readonly &&
                                         memberItem.ExtendedAttribute.IndexOf("replaceable", StringComparison.OrdinalIgnoreCase) > -1);

                    if (!memberList.Contains(memberItem))
                    {
                        memberList.Add(memberItem);
                    }
                }
                else
                {
                    //detect if its an interface extended attribute
                    if ((item.StartsWith("constructor", StringComparison.InvariantCultureIgnoreCase)) && (InterfaceExtendedParser.IsMatch(item)))
                    {
                        var constructors = interfaceDefinition.Constructors.ToList();
                        constructors.AddRange(from Match m in InterfaceExtendedParser.Matches(item) select m.Groups["constructor"].Value.Trim() into constructor where !string.IsNullOrWhiteSpace(constructor) select RegexLibrary.ParenCleaner.Replace(constructor, string.Empty));
                        interfaceDefinition.Constructors = constructors.Distinct();
                        continue;
                    }

                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Fail member- " + item);
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
            }

            return memberList.OrderBy(a => a.Name).ToList();
        }
Example #36
0
        public static void ProcessCss(IEnumerable<IElement> items, SpecData specificationData)
        {
            var properties = BuildCssPropertyList(items);

            specificationData.Interfaces.AddRange(GenerateInterfacesForCss(properties, specificationData));
        }
Example #37
0
        public static void ProcessSvGCss(IParentNode items, SpecData specificationData)
        {
            var properties = BuildSvgPropertyList(items);

            specificationData.Interfaces.AddRange(GenerateInterfacesForCss(properties, specificationData));
        }
Example #38
0
 private static Member CreateCssOmMember(string name, SpecData specificationData)
 {
     return new Member(name)
     {
         ExtendedAttribute = "TreatNullAs=EmptyString",
         TreatNullAs = "EmptyString",
         Type = "DOMString",
         Attribute = true,
         HasGet = true,
         HasSet = true,
         SpecNames = new[] { specificationData.Name }
     };
 }
Example #39
0
        private static IEnumerable<InterfaceType> GenerateInterfacesForCss(IEnumerable<Property> properties, SpecData specificationData)
        {
            var interfaces = new List<InterfaceType>();

            var interfaceDefinition = new InterfaceType
            {
                Name = "CSSStyleDeclaration",
                IsPartial = true,
                SpecNames = new[] { specificationData.Name }
            };

            var memberList = new List<Member>();
            foreach (var property in properties)
            {
                var memberOmItem = CreateCssOmMember(property.OmName, specificationData);
                if (!memberList.Contains(memberOmItem))
                {
                    memberList.Add(memberOmItem);
                }
                var memberPropertyItem = CreateCssOmMember(property.Name, specificationData);
                if (!memberList.Contains(memberPropertyItem))
                {
                    memberList.Add(memberPropertyItem);
                }
                if (string.IsNullOrWhiteSpace(property.WebkitOmName))
                {
                    continue;
                }
                var memberWebkitItem = CreateCssOmMember(property.WebkitOmName, specificationData);
                if (!memberList.Contains(memberWebkitItem))
                {
                    memberList.Add(memberWebkitItem);
                }
            }

            interfaceDefinition.Members = memberList;
            interfaces.Add(interfaceDefinition);
            return interfaces;
        }
Example #40
0
        private static void MergeInterfaces(SpecData data, bool keepPartials, ref SortedDictionary<string, InterfaceType> finalInterfaceTypes)
        {
            foreach (var interfaceType in data.Interfaces)
            {
                var interfaceName = interfaceType.Name;

                if (!finalInterfaceTypes.ContainsKey(interfaceName))
                {
                    if (!keepPartials)
                    {
                        interfaceType.IsPartial = false;
                    }
                    finalInterfaceTypes.Add(interfaceName, interfaceType);
                    continue;
                }

                var currentInterface = finalInterfaceTypes[interfaceName];
                if (!keepPartials)
                {
                    currentInterface.IsPartial = false;
                }

                currentInterface.IsCallback = currentInterface.IsCallback || interfaceType.IsCallback;
                currentInterface.ImplicitThis = currentInterface.ImplicitThis || interfaceType.ImplicitThis;
                currentInterface.IsGlobal = currentInterface.IsGlobal || interfaceType.IsGlobal;
                currentInterface.IsPrimaryGlobal = currentInterface.IsPrimaryGlobal || interfaceType.IsPrimaryGlobal;
                currentInterface.LegacyArrayClass = currentInterface.LegacyArrayClass || interfaceType.LegacyArrayClass;
                currentInterface.LegacyUnenumerableNamedProperties = currentInterface.LegacyUnenumerableNamedProperties || interfaceType.LegacyUnenumerableNamedProperties;
                currentInterface.NoInterfaceObject = currentInterface.NoInterfaceObject || interfaceType.NoInterfaceObject;
                currentInterface.OverrideBuiltins = currentInterface.OverrideBuiltins || interfaceType.OverrideBuiltins;
                currentInterface.SecureContext = currentInterface.SecureContext || interfaceType.SecureContext;
                currentInterface.Unforgeable = currentInterface.Unforgeable || interfaceType.Unforgeable;

                currentInterface.Exposed = currentInterface.Exposed.Union(interfaceType.Exposed).OrderBy(a => a);
                currentInterface.Globals = currentInterface.Globals.Union(interfaceType.Globals).OrderBy(a => a);
                currentInterface.PrimaryGlobals = currentInterface.PrimaryGlobals.Union(interfaceType.PrimaryGlobals).OrderBy(a => a);
                currentInterface.Constructors = currentInterface.Constructors.Union(interfaceType.Constructors);
                currentInterface.ExtendedBy = currentInterface.ExtendedBy.Union(interfaceType.ExtendedBy).OrderBy(a => a);
                currentInterface.Inherits = currentInterface.Inherits.Union(interfaceType.Inherits).OrderBy(a => a);
                currentInterface.NamedConstructors = currentInterface.NamedConstructors.Union(interfaceType.NamedConstructors);
                currentInterface.SpecNames = currentInterface.SpecNames.Union(interfaceType.SpecNames).OrderBy(a => a);

                var members = currentInterface.Members.ToList();

                foreach (var member in interfaceType.Members)
                {
                    if (!members.Contains(member))
                    {
                        members.Add(member);
                    }

                    var currentMember = members.Single(a => a.Equals(member));

                    currentMember.Clamp = currentMember.Clamp || member.Clamp;
                    currentMember.EnforceRange = currentMember.EnforceRange || member.EnforceRange;
                    currentMember.Exposed = currentMember.Exposed.Union(member.Exposed).OrderBy(a => a);
                    currentMember.LenientSetter = currentMember.LenientSetter || member.LenientSetter;
                    currentMember.LenientThis = currentMember.LenientThis || member.LenientThis;
                    currentMember.NewObject = currentMember.NewObject || member.NewObject;
                    currentMember.PutForwards = currentMember.PutForwards ?? member.PutForwards;
                    currentMember.Replaceable = currentMember.Replaceable || member.Replaceable;
                    currentMember.SameObject = currentMember.SameObject || member.SameObject;
                    currentMember.SecureContext = currentMember.SecureContext || member.SecureContext;
                    currentMember.TreatNullAs = currentMember.TreatNullAs ?? member.TreatNullAs;
                    currentMember.TreatUndefinedAs = currentMember.TreatUndefinedAs ?? member.TreatUndefinedAs;
                    currentMember.Unforgeable = currentMember.Unforgeable || member.Unforgeable;
                    currentMember.Unscopeable = currentMember.Unscopeable || member.Unscopeable;

                    currentMember.SpecNames = currentMember.SpecNames.Union(member.SpecNames).OrderBy(a => a);

                    members.Remove(member);
                    members.Add(currentMember);
                }
                currentInterface.Members = members;
                currentInterface.Members = currentInterface.Members.OrderBy(a => a.Name);

                finalInterfaceTypes[interfaceName] = currentInterface;
            }
        }
Example #41
0
        private static void MergeNamespaces(SpecData data, bool keepPartials, ref SortedDictionary<string, NamespaceType> finalNamespaceTypes)
        {
            foreach (var namespaceType in data.Namespaces)
            {
                var namespaceName = namespaceType.Name;

                if (!finalNamespaceTypes.ContainsKey(namespaceName))
                {
                    if (!keepPartials)
                    {
                        namespaceType.IsPartial = false;
                    }
                    finalNamespaceTypes.Add(namespaceName, namespaceType);
                    continue;
                }

                var currentNamespace = finalNamespaceTypes[namespaceName];
                if (!keepPartials)
                {
                    currentNamespace.IsPartial = false;
                }

                currentNamespace.SecureContext = currentNamespace.SecureContext || namespaceType.SecureContext;
                currentNamespace.Exposed = currentNamespace.Exposed.Union(namespaceType.Exposed).OrderBy(a => a);
                currentNamespace.SpecNames = currentNamespace.SpecNames.Union(namespaceType.SpecNames).OrderBy(a => a);

                var members = currentNamespace.Members.ToList();

                foreach (var member in namespaceType.Members)
                {
                    if (!members.Contains(member))
                    {
                        members.Add(member);
                    }

                    var currentMember = members.Single(a => a.Equals(member));

                    currentMember.Exposed = currentMember.Exposed.Union(member.Exposed).OrderBy(a => a);
                    currentMember.SecureContext = currentMember.SecureContext || member.SecureContext;
                    currentMember.SpecNames = currentMember.SpecNames.Union(member.SpecNames).OrderBy(a => a);

                    members.Remove(member);
                    members.Add(currentMember);
                }
                currentNamespace.Members = members;
                currentNamespace.Members = currentNamespace.Members.OrderBy(a => a.Name);

                finalNamespaceTypes[namespaceName] = currentNamespace;
            }
        }
Example #42
0
        private static void MergeTypeDefs(SpecData data, ref SortedDictionary<string, TypeDefType> finalTypeDefsTypes)
        {
            foreach (var typeDefType in data.TypeDefs)
            {
                var typeDefName = typeDefType.Name;

                if (!finalTypeDefsTypes.ContainsKey(typeDefName))
                {
                    finalTypeDefsTypes.Add(typeDefName, typeDefType);
                    continue;
                }

                var currentTypeDef = finalTypeDefsTypes[typeDefName];
                currentTypeDef.SpecNames = currentTypeDef.SpecNames.Union(typeDefType.SpecNames).OrderBy(a => a);

                finalTypeDefsTypes[typeDefName] = currentTypeDef;
            }
        }
Example #43
0
        private static IEnumerable<NamespaceMember> GetAllNamespaceMembers(string memberItems, SpecData specificationData)
        {
            var memberList = new List<NamespaceMember>();

            memberItems = CleanString(memberItems);

            var members = memberItems.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(m => m.Trim()).ToArray();

            foreach (var item in members.Where(item => !string.IsNullOrWhiteSpace(item)))
            {
                if (!IndividualNamespaceMember.IsMatch(item))
                {
                    continue;
                }
                var m = IndividualNamespaceMember.Match(item);

                var name = m.Groups["item"].Value.Trim();
                //Skip special CSSOM definitions
                if (new[] { "_camel_cased_attribute", "_webkit_cased_attribute", "_dashed_attribute" }.Contains(name))
                {
                    continue;
                }

                var memberItem = new NamespaceMember(name)
                {
                    Type = RegexLibrary.OldTypeCleaner.Replace(RegexLibrary.TypeCleaner.Replace(m.Groups["type"].Value.Replace("≺", "<").Replace("≻", ">"), "?"), string.Empty).Trim(),
                    Args = m.Groups["args"].Value.Trim(),
                    Function = !string.IsNullOrWhiteSpace(m.Groups["function"].Value),
                    ExtendedAttribute = m.Groups["extended"].Value.Trim(),
                    SpecNames = new[] { specificationData.Name }
                };

                if (!string.IsNullOrWhiteSpace(memberItem.ExtendedAttribute))
                {
                    var exposed = new List<string>();
                    foreach (Match mep in NamespaceMemberExtendedParser.Matches(memberItem.ExtendedAttribute))
                    {
                        memberItem.SecureContext = memberItem.SecureContext || !string.IsNullOrWhiteSpace(mep.Groups["securecontext"].Value.Trim());

                        var exposedValue = RegexLibrary.GroupingCleaner.Replace(mep.Groups["exposed"].Value, string.Empty);
                        if (!string.IsNullOrWhiteSpace(exposedValue))
                        {
                            exposed.AddRange(exposedValue.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(api => api.Trim()));
                        }
                    }
                    memberItem.Exposed = exposed.Distinct();
                }

                try
                {
                    memberItem.ArgTypes = GetArgTypes(memberItem.Args);
                }
                catch (ArgumentException)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Fail argument for namespace member- " + item);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    continue;
                }

                if (!memberList.Contains(memberItem))
                {
                    memberList.Add(memberItem);
                }
            }

            return memberList.OrderBy(a => a.Name).ToList();
        }
Example #44
0
 public WebIdlBuilder(SpecData specData, bool showSpecNames = false)
 {
     _specData = specData;
     _showSpecNames = showSpecNames;
 }