InStream interface.
Наследование: FanObj
Пример #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);
 }
Пример #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);
 }
Пример #3
0
 //////////////////////////////////////////////////////////////////////////
 // Constructor
 //////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Construct for input stream.
 /// </summary>
 public ObjDecoder(InStream @in, Map options)
 {
     tokenizer = new Tokenizer(@in);
       this.options = options;
       consume();
 }
Пример #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));
     }
 }
Пример #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;
     }
 }
Пример #6
0
 public static void make_(InStream self, InStream input)
 {
     self.m_in = input;
 }
Пример #7
0
 public void @in(InStream @in)
 {
     checkRun(); this.m_in = @in;
 }
Пример #8
0
 public abstract void encode(char ch, InStream @out);
Пример #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];
            }
Пример #10
0
Файл: Zip.cs Проект: nomit007/f4
 public static InStream gzipInStream(InStream i)
 {
     throw UnsupportedErr.make("Zip.gzipInStream").val;
 }
Пример #11
0
 public abstract int decode(InStream @in);
Пример #12
0
Файл: Zip.cs Проект: nomit007/f4
 private Zip(InStream ins)
 {
     this.m_zipIn = new ZipInputStream(SysInStream.dotnet(ins));
 }
Пример #13
0
Файл: Zip.cs Проект: nomit007/f4
 public static Zip read(InStream ins)
 {
     return new Zip(ins);
 }
Пример #14
0
 public override void encode(char ch, InStream input)
 {
     throw UnsupportedErr.make("binary write on StrBuf output").val;
 }
Пример #15
0
 //////////////////////////////////////////////////////////////////////////
 // Construction
 //////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Construct for specified input stream.
 /// </summary>
 public Tokenizer(InStream @in)
 {
     m_in = @in;
       consume();
       consume();
 }
Пример #16
0
 public override void encode(char ch, InStream @out)
 {
     // TODO - how does this work?
 }
Пример #17
0
Файл: Pod.cs Проект: 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;
              }
        }
Пример #18
0
 public override int decode(InStream @in)
 {
     return @in.r();
 }
Пример #19
0
 public static InStream gzipInStream(InStream i)
 {
     throw UnsupportedErr.make("Zip.gzipInStream").val;
 }
Пример #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));
 }
Пример #21
0
 public DotnetInputStream(InStream ins)
 {
     this.ins = ins;
 }
Пример #22
0
 public override void encode(char c, InStream @out)
 {
     @out.unread((c >> 8) & 0xFF)
     .unread((c >> 0) & 0xFF);
 }
Пример #23
0
 public override void encode(char ch, InStream input)
 {
     throw UnsupportedErr.make("binary write on StrBuf output").val;
 }
Пример #24
0
 //////////////////////////////////////////////////////////////////////////
 // Construction
 //////////////////////////////////////////////////////////////////////////
 public static InStream make(InStream input)
 {
     InStream self = new InStream();
       make_(self, input);
       return self;
 }