private RubyStackTraceBuilder(RubyContext /*!*/ context) { _hasFileAccessPermission = DetectFileAccessPermissions(); _exceptionDetail = context.Options.ExceptionDetail; _encoding = context.GetPathEncoding(); _trace = new RubyArray(); }
public static RubyArray /*!*/ GetAllNames(RubyContext /*!*/ context, RubyEncoding /*!*/ self) { var result = new RubyArray(); string name = self.Name; result.Add(MutableString.Create(name)); foreach (var alias in RubyEncoding.Aliases) { if (StringComparer.OrdinalIgnoreCase.Equals(alias.Value, name)) { result.Add(MutableString.CreateAscii(alias.Key)); } } if (self == context.RubyOptions.LocaleEncoding) { result.Add(MutableString.CreateAscii("locale")); } if (self == context.DefaultExternalEncoding) { result.Add(MutableString.CreateAscii("external")); } if (self == context.GetPathEncoding()) { result.Add(MutableString.CreateAscii("filesystem")); } return(result); }
public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, RubyFile /*!*/ self) { return(MutableString.CreateMutable(context.GetPathEncoding()). Append("#<File:"). Append(self.Path). Append(self.Closed ? " (closed)" : ""). Append('>')); }
internal static MutableString /*!*/ HostNameToMutableString(RubyContext /*!*/ context, string /*!*/ str) { if (str.IsAscii()) { return(MutableString.CreateAscii(str)); } else { return(MutableString.Create(str, context.GetPathEncoding())); } }
/// <summary> /// If the SCRIPT_LINES__ constant is set, we need to publish the file being loaded, /// along with the contents of the file /// </summary> private void AddScriptLines(SourceUnit file) { ConstantStorage storage; if (!_context.ObjectClass.TryResolveConstant(null, "SCRIPT_LINES__", out storage)) { return; } IDictionary scriptLines = storage.Value as IDictionary; if (scriptLines == null) { return; } lock (scriptLines) { // Read in the contents of the file RubyArray lines = new RubyArray(); SourceCodeReader reader = file.GetReader(); RubyEncoding encoding = RubyEncoding.GetRubyEncoding(reader.Encoding); using (reader) { reader.SeekLine(1); while (true) { string lineStr = reader.ReadLine(); if (lineStr == null) { break; } MutableString line = MutableString.CreateMutable(lineStr.Length + 1, encoding); line.Append(lineStr).Append('\n'); lines.Add(line); } } // Publish the contents of the file, keyed by the file name MutableString path = MutableString.Create(file.Document.FileName, _context.GetPathEncoding()); scriptLines[path] = lines; } }
public static MutableString /*!*/ GetZone(RubyContext /*!*/ context, RubyTime /*!*/ self) { if (self.Kind == DateTimeKind.Utc) { return(MutableString.CreateAscii("UTC")); } else { var name = RubyTime.GetCurrentZoneName(); if (name.IsAscii()) { return(MutableString.CreateAscii(name)); } else { // TODO: what encoding should we use? return(MutableString.Create(name, context.GetPathEncoding())); } } }
internal static MutableString/*!*/ HostNameToMutableString(RubyContext/*!*/ context, string/*!*/ str) { if (str.IsAscii()) { return MutableString.CreateAscii(str); } else { return MutableString.Create(str, context.GetPathEncoding()); } }
private RubyStackTraceBuilder(RubyContext/*!*/ context) { _hasFileAccessPermission = DetectFileAccessPermissions(); _exceptionDetail = context.Options.ExceptionDetail; _encoding = context.GetPathEncoding(); _trace = new RubyArray(); }
public static MutableString/*!*/ Inspect(RubyContext/*!*/ context, RubyFile/*!*/ self) { return MutableString.CreateMutable(context.GetPathEncoding()). Append("#<File:"). Append(self.Path). Append(self.Closed ? " (closed)" : ""). Append('>'); }
private static MutableString /*!*/ FrozenString(RubyContext /*!*/ context, object value) { return(MutableString.Create((string)value ?? "", context.GetPathEncoding()).Freeze()); }
public static RubyArray GetAllNames(RubyContext/*!*/ context, RubyEncoding/*!*/ self) { var result = new RubyArray(); string name = self.Name; result.Add(MutableString.Create(name)); foreach (var alias in RubyEncoding.Aliases) { if (StringComparer.OrdinalIgnoreCase.Equals(alias.Value, name)) { result.Add(MutableString.CreateAscii(alias.Key)); } } if (self == context.RubyOptions.LocaleEncoding) { result.Add(MutableString.CreateAscii("locale")); } if (self == context.DefaultExternalEncoding) { result.Add(MutableString.CreateAscii("external")); } if (self == context.GetPathEncoding()) { result.Add(MutableString.CreateAscii("filesystem")); } return result; }
/*!*/ private static MutableString FrozenString(RubyContext/*!*/ context, object value) { return MutableString.Create((string)value ?? "", context.GetPathEncoding()).Freeze(); }