public LSLLibraryEventSignature LSLEvent(string name) { var ev = _scriptLibrary.Keywords.Get(name) as Event; if (ev != null) { var match = _eventSig.Regex.Match(ev.Desc); if (match.Success) { var sig = LSLLibraryEventSignature.Parse(match.ToString()); sig.DocumentationString = _eventSig.Regex.Replace(ev.Desc, ""); Log.WriteLineWithHeader("[FirestormLibraryData]: ", "script_library name={0}: event {1} signature {2} found in docstring", _scriptLibrary.Name, ev.Name, sig.SignatureString); return(sig); } Log.WriteLineWithHeader("[FirestormLibraryData]: ", "script_library name={0}: event {1} has no signature in doc string", _scriptLibrary.Name, ev.Name); return(null); } return(null); }
/// <summary> /// Returns all <see cref="LSLEventSignature" /> that could be parsed out of a given string. /// </summary> /// <param name="inString">The string to parse <see cref="LSLEventSignature" /> objects from.</param> /// <returns>An enumerable of <see cref="LSLEventSignature" /> objects that were successfully parsed from the string.</returns> public IEnumerable <LSLEventSignature> GetSignatures(string inString) { var matches = Regex.Matches(inString); foreach (Match m in matches) { if (!m.Success) { continue; } var name = m.Groups[1].ToString(); var param = m.Groups[2].ToString(); var sig = new LSLLibraryEventSignature(name); var ps = param.Split(','); if (ps.Length == 1 && string.IsNullOrWhiteSpace(ps[0])) { yield return(sig); } else { foreach (var p in ps) { var prm = p.Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); sig.AddParameter(new LSLParameterSignature(LSLTypeTools.FromLSLTypeName(prm[0]), prm[1], false)); } yield return(sig); } } }
public LSLLibraryEventSignature LSLEvent(string name) { var map = GetEventOSDMap(_data, name); if (map == null) { return(null); } LSLLibraryEventSignature ev = new LSLLibraryEventSignature(name) { DocumentationString = DocumentEvent(_data, name) }; ev.Subsets.SetSubsets(_subsets); ev.Deprecated = map.ContainsKey("deprecated"); if (map.ContainsKey("arguments")) { var args = map["arguments"] as OSDArray; if (args == null) { return(ev); } var paramNameDuplicates = new HashMap <string, int>(); foreach (var arg in args.Cast <OSDMap>()) { var argName = arg.Keys.First(); var paramDetails = (OSDMap)arg[argName]; if (paramNameDuplicates.ContainsKey(argName)) { //rename duplicates with a trailing number int curValue = paramNameDuplicates[argName]; int newValue = curValue + 1; paramNameDuplicates[argName] = newValue; argName = argName + "_" + newValue; } else { paramNameDuplicates.Add(argName, 0); } ev.AddParameter(new LSLParameterSignature( LSLTypeTools.FromLSLTypeName(paramDetails["type"].AsString()), argName, false)); } } return(ev); }
public string DocumentEvent(LSLLibraryEventSignature eventHandler) { if (!_scriptLibrary.Keywords.Contains(eventHandler.Name)) { Log.WriteLineWithHeader("[FirestormDocumentationScraper]: ", "script_library name={0}: Event {1} not defined in firestorm script library", _scriptLibrary.Name, eventHandler.Name); return(null); } var e = _scriptLibrary.Keywords.Get(eventHandler.Name); if (string.IsNullOrWhiteSpace(e.Desc)) { Log.WriteLineWithHeader("[FirestormDocumentationScraper]: ", "script_library name={0}: Docstring for event {1} is empty", _scriptLibrary.Name, eventHandler.Name); return(null); } var match = _eventSig.Regex.Match(e.Desc); if (match.Success) { var sig = LSLLibraryEventSignature.Parse(match.ToString()); if (!sig.SignatureMatches(eventHandler)) { Log.WriteLineWithHeader("[FirestormDocumentationScraper]: ", "script_library name={0}: Docstring signature for event {1} mismatches passed event signature", _scriptLibrary.Name, e.Name); } else { Log.WriteLineWithHeader("[FirestormDocumentationScraper]: ", "script_library name={0}: Docstring signature for event {1} matches passed event signature", _scriptLibrary.Name, e.Name); } return(_functionSig.Regex.Replace(e.Desc, "")); } Log.WriteLineWithHeader("[FirestormDocumentationScraper]: ", "script_library name={0}: Docstring for event {1} does not contain a signature", _scriptLibrary.Name, e.Name); return(e.Desc); }
private LSLLibraryEventSignature GetSigFromEventPage(string url) { var page = _client.DownloadString(url); var match = _eventSignature.Regex.Match(page); if (match.Success) { var eventSignature = LSLLibraryEventSignature.Parse(match.Groups[1].ToString()); eventSignature.Subsets.SetSubsets(_subsets); Log.WriteLineWithHeader( "[SecondlifeWikiLibraryData]: ", "Retrieved event {0}; from {1}", eventSignature.SignatureString, url); return(eventSignature); } return(null); }
public IEnumerable <LSLLibraryEventSignature> LSLEvents() { foreach (var ev in _scriptLibrary.Keywords.Where(x => x is Event)) { var match = _eventSig.Regex.Match(ev.Desc); if (match.Success) { var sig = LSLLibraryEventSignature.Parse(match.ToString()); sig.DocumentationString = _eventSig.Regex.Replace(ev.Desc, ""); yield return(sig); } else { Log.WriteLineWithHeader("[FirestormLibraryData]: ", "script_library name={0}: event {1} has no signature in doc string", _scriptLibrary.Name, ev.Name); } } }
public string DocumentEvent(LSLLibraryEventSignature eventHandler) { return(""); }
public string DocumentEvent(LSLLibraryEventSignature eventHandler) { return _providers.Select(documentationProvider => documentationProvider.DocumentEvent(eventHandler)) .FirstOrDefault(d => !string.IsNullOrWhiteSpace(d)); }
public string DocumentEvent(LSLLibraryEventSignature eventHandler) { var v = LLSDLibraryData.DocumentEvent(_data, eventHandler.Name); return(v); }