////////////////////////////////////////////////////////////////////////// // .NET Conversion ////////////////////////////////////////////////////////////////////////// /// <summary> /// Get a System.IO.Stream for the specified input stream. /// </summary> public static Stream dotnet(InStream ins) { if (ins is SysInStream) return ((SysInStream)ins).inStream; else return new DotnetInputStream (ins); }
////////////////////////////////////////////////////////////////////////// // Construction ////////////////////////////////////////////////////////////////////////// public BootEnv() { this.m_args = initArgs(); this.m_vars = initVars(); this.m_host = initHost(); this.m_user = initUser(); this.m_in = new SysInStream(Console.OpenStandardInput()); this.m_out = new SysOutStream(Console.OpenStandardOutput()); this.m_err = new SysOutStream(Console.OpenStandardError()); this.m_homeDir = new LocalFile(new DirectoryInfo(Sys.m_homeDir), true).normalize(); this.m_tempDir = m_homeDir.plus(Uri.fromStr("temp/"), false); }
////////////////////////////////////////////////////////////////////////// // Constructor ////////////////////////////////////////////////////////////////////////// /// <summary> /// Construct for input stream. /// </summary> public ObjDecoder(InStream @in, Map options) { tokenizer = new Tokenizer(@in); this.options = options; consume(); }
public override void encode(char c, InStream @out) { if (c <= 0x007F) { @out.unread(c); } else if (c > 0x07FF) { @out.unread(0x80 | ((c >> 0) & 0x3F)) .unread(0x80 | ((c >> 6) & 0x3F)) .unread(0xE0 | ((c >> 12) & 0x0F)); } else { @out.unread(0x80 | ((c >> 0) & 0x3F)) .unread(0xC0 | ((c >> 6) & 0x1F)); } }
public override int decode(InStream @in) { int c = @in.r(); if (c < 0) return -1; int c2, c3; switch (c >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: /* 0xxxxxxx*/ return c; case 12: case 13: /* 110x xxxx 10xx xxxx*/ c2 = @in.r(); if ((c2 & 0xC0) != 0x80) throw IOErr.make("Invalid UTF-8 encoding").val; return ((c & 0x1F) << 6) | (c2 & 0x3F); case 14: /* 1110 xxxx 10xx xxxx 10xx xxxx */ c2 = @in.r(); c3 = @in.r(); if (((c2 & 0xC0) != 0x80) || ((c3 & 0xC0) != 0x80)) throw IOErr.make("Invalid UTF-8 encoding").val; return (((c & 0x0F) << 12) | ((c2 & 0x3F) << 6) | ((c3 & 0x3F) << 0)); default: throw IOErr.make("Invalid UTF-8 encoding").val; } }
public static void make_(InStream self, InStream input) { self.m_in = input; }
public void @in(InStream @in) { checkRun(); this.m_in = @in; }
public abstract void encode(char ch, InStream @out);
public override int decode(InStream @in) { // TODO - well shit, how do we know how many bytes to read generically? int len = 1; int b = @in.r(); if (b < 0) return -1; bbuf[0] = (byte)b; cbuf = charset.m_encoding.GetChars(bbuf, 0, len); return cbuf[0]; }
public static InStream gzipInStream(InStream i) { throw UnsupportedErr.make("Zip.gzipInStream").val; }
public abstract int decode(InStream @in);
private Zip(InStream ins) { this.m_zipIn = new ZipInputStream(SysInStream.dotnet(ins)); }
public static Zip read(InStream ins) { return new Zip(ins); }
public override void encode(char ch, InStream input) { throw UnsupportedErr.make("binary write on StrBuf output").val; }
////////////////////////////////////////////////////////////////////////// // Construction ////////////////////////////////////////////////////////////////////////// /// <summary> /// Construct for specified input stream. /// </summary> public Tokenizer(InStream @in) { m_in = @in; consume(); consume(); }
public override void encode(char ch, InStream @out) { // TODO - how does this work? }
public static Pod load(InStream @in) { FPod fpod = null; try { fpod = new FPod(null, null); fpod.readFully(new ZipInputStream(SysInStream.dotnet(@in))); } catch (Exception e) { throw Err.make(e).val; } string name = fpod.m_podName; lock (m_podsByName) { // check for duplicate pod name if (m_podsByName[name] != null) throw Err.make("Duplicate pod name: " + name).val; // create Pod and add to master table Pod pod = new Pod(fpod); m_podsByName[name] = pod; //new SoftReference(pod); return pod; } }
public override int decode(InStream @in) { return @in.r(); }
public override int decode(InStream @in) { int c1 = @in.r(); int c2 = @in.r(); if ((c1 | c2) < 0) return -1; return (c1 | (c2 << 8)); }
public DotnetInputStream(InStream ins) { this.ins = ins; }
public override void encode(char c, InStream @out) { @out.unread((c >> 8) & 0xFF) .unread((c >> 0) & 0xFF); }
////////////////////////////////////////////////////////////////////////// // Construction ////////////////////////////////////////////////////////////////////////// public static InStream make(InStream input) { InStream self = new InStream(); make_(self, input); return self; }