InStream interface.
Inheritance: FanObj
Exemplo n.º 1
0
 //////////////////////////////////////////////////////////////////////////
 // .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);
 }
Exemplo n.º 2
0
 //////////////////////////////////////////////////////////////////////////
 // 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);
 }
Exemplo n.º 3
0
 //////////////////////////////////////////////////////////////////////////
 // Constructor
 //////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Construct for input stream.
 /// </summary>
 public ObjDecoder(InStream @in, Map options)
 {
     tokenizer = new Tokenizer(@in);
       this.options = options;
       consume();
 }
Exemplo n.º 4
0
 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));
     }
 }
Exemplo n.º 5
0
 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;
     }
 }
Exemplo n.º 6
0
 public static void make_(InStream self, InStream input)
 {
     self.m_in = input;
 }
Exemplo n.º 7
0
 public void @in(InStream @in)
 {
     checkRun(); this.m_in = @in;
 }
Exemplo n.º 8
0
 public abstract void encode(char ch, InStream @out);
Exemplo n.º 9
0
            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];
            }
Exemplo n.º 10
0
Arquivo: Zip.cs Projeto: nomit007/f4
 public static InStream gzipInStream(InStream i)
 {
     throw UnsupportedErr.make("Zip.gzipInStream").val;
 }
Exemplo n.º 11
0
 public abstract int decode(InStream @in);
Exemplo n.º 12
0
Arquivo: Zip.cs Projeto: nomit007/f4
 private Zip(InStream ins)
 {
     this.m_zipIn = new ZipInputStream(SysInStream.dotnet(ins));
 }
Exemplo n.º 13
0
Arquivo: Zip.cs Projeto: nomit007/f4
 public static Zip read(InStream ins)
 {
     return new Zip(ins);
 }
Exemplo n.º 14
0
 public override void encode(char ch, InStream input)
 {
     throw UnsupportedErr.make("binary write on StrBuf output").val;
 }
Exemplo n.º 15
0
 //////////////////////////////////////////////////////////////////////////
 // Construction
 //////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Construct for specified input stream.
 /// </summary>
 public Tokenizer(InStream @in)
 {
     m_in = @in;
       consume();
       consume();
 }
Exemplo n.º 16
0
 public override void encode(char ch, InStream @out)
 {
     // TODO - how does this work?
 }
Exemplo n.º 17
0
Arquivo: Pod.cs Projeto: nomit007/f4
        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;
              }
        }
Exemplo n.º 18
0
 public override int decode(InStream @in)
 {
     return @in.r();
 }
Exemplo n.º 19
0
 public static InStream gzipInStream(InStream i)
 {
     throw UnsupportedErr.make("Zip.gzipInStream").val;
 }
Exemplo n.º 20
0
 public override int decode(InStream @in)
 {
     int c1 = @in.r();
     int c2 = @in.r();
     if ((c1 | c2) < 0) return -1;
     return (c1 | (c2 << 8));
 }
Exemplo n.º 21
0
 public DotnetInputStream(InStream ins)
 {
     this.ins = ins;
 }
Exemplo n.º 22
0
 public override void encode(char c, InStream @out)
 {
     @out.unread((c >> 8) & 0xFF)
     .unread((c >> 0) & 0xFF);
 }
Exemplo n.º 23
0
 public override void encode(char ch, InStream input)
 {
     throw UnsupportedErr.make("binary write on StrBuf output").val;
 }
Exemplo n.º 24
0
 //////////////////////////////////////////////////////////////////////////
 // Construction
 //////////////////////////////////////////////////////////////////////////
 public static InStream make(InStream input)
 {
     InStream self = new InStream();
       make_(self, input);
       return self;
 }