private IEnumerable <LSLLibraryConstantSignature> LSLConstantsFromParticlePage() { var particleConstants = _client.DownloadString(SecondlifeWikiBaseUrl + "LlParticleSystem"); var matches = _physicsConstantTableRow.Matches(particleConstants); foreach (Match match in matches) { var matchString = match.ToString(); var valueCase1 = Regex.Match(matchString, "title=\"Hexadecimal notation for: (.*?)\""); var valueCase2 = Regex.Match(matchString, "<td align=\"center\">(.*)"); var name = match.Groups[1].ToString(); if (string.IsNullOrWhiteSpace(name)) { name = match.Groups[2].ToString(); } if (string.IsNullOrWhiteSpace(valueCase1.Groups[1].ToString())) { var constant = new LSLLibraryConstantSignature(LSLType.Integer, name, valueCase2.Groups[1].ToString()); constant.Subsets.SetSubsets(_subsets); yield return(constant); } else { var constant = new LSLLibraryConstantSignature(LSLType.Integer, name, valueCase1.Groups[1].ToString()); constant.Subsets.SetSubsets(_subsets); yield return(constant); } } }
public LSLLibraryConstantSignature GetSignature(IReadOnlyGenericArray <string> subsets) { var f = new LSLLibraryConstantSignature(LSLType.String, Name) { DocumentationString = Desc }; f.Subsets.SetSubsets(subsets); return(f); }
private IEnumerable <LSLLibraryConstantSignature> LSLConstantsFromKeywordsAll() { var data = _client.DownloadString(SecondlifeWikiBaseUrl + "Category:LSL_Keywords/All"); var group = _constantsGroupKeywordsAll.Match(data); if (group.Success) { var groupString = group.ToString(); foreach (Match constantMatch in _constantInKeywordsAll.Matches(groupString)) { var type = LSLTypeTools.FromLSLTypeName(constantMatch.Groups[1].ToString()); var webVal = constantMatch.Groups[3].ToString(); var strVal = ""; if (type == LSLType.Integer) { strVal = webVal.Contains("x") ? Convert.ToInt32(webVal, 16).ToString() : webVal; } if (type == LSLType.Vector || type == LSLType.Rotation) { strVal = webVal.Replace("<", "").Replace(">", ""); } if (type == LSLType.String || type == LSLType.Key) { strVal = webVal.Replace(""", "").Replace("\"", ""); } LSLLibraryConstantSignature result; if (string.IsNullOrWhiteSpace(strVal)) { result = new LSLLibraryConstantSignature( LSLTypeTools.FromLSLTypeName(constantMatch.Groups[1].ToString()), constantMatch.Groups[2].ToString()); } else { result = new LSLLibraryConstantSignature( LSLTypeTools.FromLSLTypeName(constantMatch.Groups[1].ToString()), constantMatch.Groups[2].ToString(), strVal); } result.Subsets.SetSubsets(_subsets); yield return(result); } } }
public LSLLibraryConstantSignature GetSignature(IReadOnlyGenericArray <string> subsets) { var s = Desc.Split(','); var t = s.Length == 3 ? LSLType.Vector : LSLType.Rotation; var f = new LSLLibraryConstantSignature(t, Name) { DocumentationString = Desc }; f.Subsets.SetSubsets(subsets); return(f); }
private IEnumerable <LSLLibraryConstantSignature> LSLConstantsFromClickActionPage() { var particleConstants = _client.DownloadString(SecondlifeWikiBaseUrl + "LlSetClickAction"); var matches = _clickActionConstants.Matches(particleConstants); foreach (Match match in matches) { var c = new LSLLibraryConstantSignature(LSLType.Integer, match.Groups[2].ToString(), match.Groups[1].ToString()); c.Subsets.SetSubsets(_subsets); yield return(c); } }
private IEnumerable <LSLLibraryConstantSignature> LSLConstantsFromChangedEventPage() { var particleConstants = _client.DownloadString(SecondlifeWikiBaseUrl + "Changed"); var tableMatch = _changedEventConstantsTable.Match(particleConstants); var table = tableMatch.ToString(); var matches = _changedEventConstants.Matches(table); foreach (Match match in matches) { var s = Convert.ToInt32(match.Groups[2].ToString(), 16); var c = new LSLLibraryConstantSignature(LSLType.Integer, match.Groups[1].ToString(), s.ToString(CultureInfo.InvariantCulture)); c.Subsets.SetSubsets(_subsets); yield return(c); } }
public string DocumentConstant(LSLLibraryConstantSignature constant) { if (_scriptLibrary.Keywords.Contains(constant.Name)) { var c = _scriptLibrary.Keywords.Get(constant.Name); if (string.IsNullOrWhiteSpace(c.Desc)) { Log.WriteLineWithHeader("[FirestormDocumentationScraper]: ", "script_library name={0}: Docstring for constant {1} is empty", _scriptLibrary.Name, c.Name); return(null); } Log.WriteLineWithHeader("[FirestormDocumentationScraper]: ", "script_library name={0}: Docstring for constant {1} found in firestorm data", _scriptLibrary.Name, c.Name); return(c.Desc); } Log.WriteLineWithHeader("[FirestormDocumentationScraper]: ", "script_library name={0}: Constant {1} not defined in firestorm script library", _scriptLibrary.Name, constant.Name); return(null); }
public LSLLibraryConstantSignature LSLConstant(string name) { var map = GetConstantOSDMap(_data, name); if (map == null) { return(null); } if (!map.ContainsKey("type")) { return(null); } LSLType type = LSLTypeTools.FromLSLTypeName(map["type"].AsString()); if (!map.ContainsKey("value")) { return(null); } var val = map["value"].AsString(); switch (type) { case LSLType.String: val = replaceStringCodePoints(val); val = val.Replace(""", ""). Replace("\"", ""); break; case LSLType.Integer: val = replaceHexInts(val); break; case LSLType.Rotation: case LSLType.Vector: val = val.Replace("<", ""). Replace(">", ""). Replace("<", ""). Replace(">", ""); break; case LSLType.Key: val = val.Replace(""", ""). Replace("\"", ""); break; } var sig = new LSLLibraryConstantSignature(type, name, val) { DocumentationString = DocumentConstant(_data, name) }; sig.Subsets.SetSubsets(_subsets); sig.Deprecated = map.ContainsKey("deprecated"); return(sig); }
/// <summary> /// Allows modification of a constant signature after its basic information has been serialized from an objects /// Property, before its returned. /// </summary> /// <param name="serializer">The <see cref="LSLLibraryDataReflectionSerializer" /> this add-on belongs to.</param> /// <param name="info">The <see cref="FieldInfo" /> object the library constant signature was serialized from.</param> /// <param name="signature">The signature.</param> /// <returns><c>true</c> if the constant needs to be filtered from the results.</returns> public bool MutateSignature(LSLLibraryDataReflectionSerializer serializer, FieldInfo info, LSLLibraryConstantSignature signature) { return(Filters.Any(filter => filter.MutateSignature(serializer, info, signature))); }
private LSLLibraryConstantSignature GetSigFromConstantPage(string url) { var page = _client.DownloadString(url); var match = _constantSignature.Match(page); if (!match.Success) { return(null); } var val = match.Groups[3].ToString(); string strValue; var type = LSLTypeTools.FromLSLTypeName(match.Groups[1].ToString()); if (type == LSLType.Integer || type == LSLType.Float) { var hxMatch = _hexNotation.Match(val); if (hxMatch.Success) { strValue = hxMatch.Groups[1].ToString(); } else if (val.Contains("x")) { strValue = Convert.ToInt32(val, 16).ToString(CultureInfo.InvariantCulture); } else { strValue = val; } } else if (type == LSLType.Rotation || type == LSLType.Vector) { strValue = val.Replace("<", ""). Replace(">", ""). Replace("<", ""). Replace(">", ""); } else if (type == LSLType.String || type == LSLType.Key) { strValue = val.Replace(""", ""). Replace("\"", ""); var specialUnicode = _matchConstantllUnescapeUrl.Match(strValue); if (specialUnicode.Success) { strValue = HttpUtility.UrlDecode(specialUnicode.Groups[1].ToString()); } } else { strValue = val; } var constantSignature = new LSLLibraryConstantSignature(type, match.Groups[2].ToString().Replace(' ', '_'), strValue) { Deprecated = _deprecatedMarker.IsMatch(page) }; constantSignature.Subsets.SetSubsets(_subsets); Log.WriteLineWithHeader( "[SecondlifeWikiLibraryData]: ", "Retrieved" + (constantSignature.Deprecated ? " (DEPRECATED) " : " ") + "constant {0}; from {1}", constantSignature.SignatureString, url); return(constantSignature); }
public LSLLibraryConstantSignature LSLConstant(string name) { if (!IncludeConstants) { return(null); } const BindingFlags bindingFlags = BindingFlags.Default | BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic; if (name == "GCDummy") { return(null); } foreach (var constantContrainerType in _scriptConstantContainerClasses) { var subsets = _subsetsMap[constantContrainerType]; var constant = constantContrainerType.GetField(name, bindingFlags); if (constant != null) { var type = LslTypeFromCsharpType(constant.FieldType); if (type != null) { var con = new LSLLibraryConstantSignature(type.Value, constant.Name, constant.GetValue(null).ToString()); con.DocumentationString = _documentationProvider.DocumentConstant(con); con.Subsets.SetSubsets(subsets); return(con); } Log.WriteLineWithHeader("[OpenSimLibraryDataReflector]: ", "constant {0} of {1}, type is an un-recognized data type ({2})", name, constantContrainerType.FullName, constant.Name); return(null); } Log.WriteLineWithHeader("[OpenSimLibraryDataReflector]: ", "constant {0} does not exist in {1}", name, constantContrainerType.FullName); } foreach (var constantContrainerType in _attributedScriptModuleClasses) { var subsets = _subsetsMap[constantContrainerType]; var constant = constantContrainerType.GetField(name, bindingFlags); if (constant == null) { Log.WriteLineWithHeader("[OpenSimLibraryDataReflector]: ", "constant {0} does not exist in {1}", name, constantContrainerType.FullName); return(null); } if (constant.GetCustomAttributes(ScriptModuleConstantAttribute, true).Any()) { continue; } var type = LslTypeFromCsharpType(constant.FieldType); if (type != null) { var con = new LSLLibraryConstantSignature(type.Value, constant.Name, constant.GetValue(null).ToString()); con.Expand = true; con.DocumentationString = _documentationProvider.DocumentConstant(con); con.Subsets.SetSubsets(subsets); return(con); } Log.WriteLineWithHeader("[OpenSimLibraryDataReflector]: ", "constant {0} of {1}, type is an un-recognized data type ({2})", name, constantContrainerType.FullName, constant.Name); return(null); } return(null); }
public string DocumentConstant(LSLLibraryConstantSignature constant) { return _providers.Select(documentationProvider => documentationProvider.DocumentConstant(constant)) .FirstOrDefault(d => !string.IsNullOrWhiteSpace(d)); }
/// <summary> /// Allows modification of a constant signature after its basic information has been serialized from an objects /// Property, before its returned. /// </summary> /// <param name="serializer">The <see cref="LSLLibraryDataReflectionSerializer" /> this add-on belongs to.</param> /// <param name="info">The <see cref="FieldInfo" /> object the library constant signature was serialized from.</param> /// <param name="signature">The signature.</param> /// <returns><c>true</c> if the constant needs to be filtered from the results.</returns> public bool MutateSignature(LSLLibraryDataReflectionSerializer serializer, FieldInfo info, LSLLibraryConstantSignature signature) { return(MutateFieldConstant != null && MutateFieldConstant(serializer, info, signature)); }
public IEnumerable <LSLLibraryConstantSignature> LSLConstants() { if (!IncludeConstants) { yield break; } const BindingFlags bindingFlags = BindingFlags.Default | BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic; foreach (var constantContrainerType in _scriptConstantContainerClasses) { var constantContainer = Activator.CreateInstance(constantContrainerType); var subsets = _subsetsMap[constantContrainerType]; IEnumerable <FieldInfo> fields = constantContrainerType.GetFields(bindingFlags); foreach (var c in fields.Where(x => x.Name != "GCDummy")) { var valueString = c.GetValue(constantContainer).ToString(); var type = LslTypeFromCsharpType(c.FieldType); if (type == null) { Log.WriteLineWithHeader("[OpenSimLibraryDataReflector]: ", "constant {0} of {1}, type is an un-recognized data type ({2})", c.Name, constantContrainerType.FullName, c.FieldType.Name); } else { var f = new LSLLibraryConstantSignature(type.Value, c.Name, valueString); f.Subsets.SetSubsets(subsets); f.DocumentationString = _documentationProvider.DocumentConstant(f); yield return(f); } } } foreach (var module in _attributedScriptModuleClasses) { var fields = module.GetFields(bindingFlags) .Where(x => x.GetCustomAttributes(ScriptModuleConstantAttribute, true).Any()); var subsets = _subsetsMap[module]; foreach (var c in fields.Where(x => x.Name != "GCDummy")) { var valueString = c.GetValue(null).ToString(); var type = LslTypeFromCsharpType(c.FieldType); if (type == null) { Log.WriteLineWithHeader("[OpenSimLibraryDataReflector]: ", "constant {0} of optional script module {1}, type is an un-recognized data type ({2})", c.Name, module.FullName, c.FieldType.Name); } else { var f = new LSLLibraryConstantSignature(type.Value, c.Name, valueString); f.Expand = true; f.Subsets.SetSubsets(subsets); f.DocumentationString = _documentationProvider.DocumentConstant(f); yield return(f); } } } }
public string DocumentConstant(LSLLibraryConstantSignature constant) { return(""); }
public string DocumentConstant(LSLLibraryConstantSignature constant) { var v = LLSDLibraryData.DocumentConstant(_data, constant.Name); return(v); }