annotate dwt/dwthelper/InflaterInputStream.d @ 360:ee1dd551f5b1

Make compilable for tango 0.99.8
author Frank Benoit <benoit@tionex.de>
date Fri, 20 Mar 2009 20:30:32 +0100
parents 8ebacc5c07dc
children 4bffbf81e2d6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
1 /**
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
2 * Authors: Frank Benoit <keinfarbton@googlemail.com>
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
3 */
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
4 module dwt.dwthelper.InflaterInputStream;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
5
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
6 public import dwt.dwthelper.InputStream;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
7 import dwt.dwthelper.utils;
132
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
8 import tango.io.Stdout;
134
116d23207a86 changed PNG loader to use internal inflating
Frank Benoit <benoit@tionex.de>
parents: 132
diff changeset
9 import tango.io.compress.ZlibStream;
307
9995e4a9d2ee sync with dwt-win
Frank Benoit <benoit@tionex.de>
parents: 276
diff changeset
10 version(Windows){
9995e4a9d2ee sync with dwt-win
Frank Benoit <benoit@tionex.de>
parents: 276
diff changeset
11 version(build){
9995e4a9d2ee sync with dwt-win
Frank Benoit <benoit@tionex.de>
parents: 276
diff changeset
12 pragma(link,"zlib");
9995e4a9d2ee sync with dwt-win
Frank Benoit <benoit@tionex.de>
parents: 276
diff changeset
13 }
9995e4a9d2ee sync with dwt-win
Frank Benoit <benoit@tionex.de>
parents: 276
diff changeset
14 }
316
a2166f25ce17 update TANGOSVN
Frank Benoit <benoit@tionex.de>
parents: 307
diff changeset
15 version(TANGOSVN){
a2166f25ce17 update TANGOSVN
Frank Benoit <benoit@tionex.de>
parents: 307
diff changeset
16 import tango.io.device.Conduit;
a2166f25ce17 update TANGOSVN
Frank Benoit <benoit@tionex.de>
parents: 307
diff changeset
17 } else {
a2166f25ce17 update TANGOSVN
Frank Benoit <benoit@tionex.de>
parents: 307
diff changeset
18 import tango.io.Conduit;
a2166f25ce17 update TANGOSVN
Frank Benoit <benoit@tionex.de>
parents: 307
diff changeset
19 }
276
9d67c3170a58 Removed version=TANGOSVN for release 0.99.7
Frank Benoit <benoit@tionex.de>
parents: 271
diff changeset
20
132
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
21 class InputStreamWrapper : tango.io.model.IConduit.InputStream {
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
22
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
23 dwt.dwthelper.InputStream.InputStream istr;
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
24
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
25 this( dwt.dwthelper.InputStream.InputStream istr ){
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
26 this.istr = istr;
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
27 }
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
28
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
29 uint read (void[] dst){
134
116d23207a86 changed PNG loader to use internal inflating
Frank Benoit <benoit@tionex.de>
parents: 132
diff changeset
30 int res = istr.read( cast(byte[])dst );
132
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
31 return res;
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
32 }
360
ee1dd551f5b1 Make compilable for tango 0.99.8
Frank Benoit <benoit@tionex.de>
parents: 356
diff changeset
33
ee1dd551f5b1 Make compilable for tango 0.99.8
Frank Benoit <benoit@tionex.de>
parents: 356
diff changeset
34 IOStream flush () {
ee1dd551f5b1 Make compilable for tango 0.99.8
Frank Benoit <benoit@tionex.de>
parents: 356
diff changeset
35 return this;
ee1dd551f5b1 Make compilable for tango 0.99.8
Frank Benoit <benoit@tionex.de>
parents: 356
diff changeset
36 }
ee1dd551f5b1 Make compilable for tango 0.99.8
Frank Benoit <benoit@tionex.de>
parents: 356
diff changeset
37
ee1dd551f5b1 Make compilable for tango 0.99.8
Frank Benoit <benoit@tionex.de>
parents: 356
diff changeset
38 void[] load ( size_t max = -1 ) {
ee1dd551f5b1 Make compilable for tango 0.99.8
Frank Benoit <benoit@tionex.de>
parents: 356
diff changeset
39 return Conduit.load (this, max);
262
e10de397beb1 ADD version TANGOSVN
Frank Benoit <benoit@tionex.de>
parents: 134
diff changeset
40 }
132
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
41
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
42 tango.io.model.IConduit.InputStream clear (){
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
43 return this;
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
44 }
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
45
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
46 tango.io.model.IConduit.IConduit conduit (){
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
47 return null;
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
48 }
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
49
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
50 void close (){
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
51 istr.close();
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
52 }
360
ee1dd551f5b1 Make compilable for tango 0.99.8
Frank Benoit <benoit@tionex.de>
parents: 356
diff changeset
53 tango.io.model.IConduit.InputStream input (){
ee1dd551f5b1 Make compilable for tango 0.99.8
Frank Benoit <benoit@tionex.de>
parents: 356
diff changeset
54 return null;
ee1dd551f5b1 Make compilable for tango 0.99.8
Frank Benoit <benoit@tionex.de>
parents: 356
diff changeset
55 }
ee1dd551f5b1 Make compilable for tango 0.99.8
Frank Benoit <benoit@tionex.de>
parents: 356
diff changeset
56 long seek (long offset, Anchor anchor = Anchor.Begin){
ee1dd551f5b1 Make compilable for tango 0.99.8
Frank Benoit <benoit@tionex.de>
parents: 356
diff changeset
57 return 0;
356
8ebacc5c07dc Fixes for TANGOSVN r4235 -- still some warnings but builds
John Reimer <terminal.node@gmail.com>
parents: 316
diff changeset
58 }
132
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
59 }
12
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
60
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
61 public class InflaterInputStream : dwt.dwthelper.InputStream.InputStream {
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
62
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
63 alias dwt.dwthelper.InputStream.InputStream.read read;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
64 alias dwt.dwthelper.InputStream.InputStream.skip skip;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
65 alias dwt.dwthelper.InputStream.InputStream.available available;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
66 alias dwt.dwthelper.InputStream.InputStream.close close;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
67 alias dwt.dwthelper.InputStream.InputStream.mark mark;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
68 alias dwt.dwthelper.InputStream.InputStream.reset reset;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
69 alias dwt.dwthelper.InputStream.InputStream.markSupported markSupported;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
70
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
71 protected byte[] buf;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
72 protected int len;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
73 package bool usesDefaultInflater = false;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
74
134
116d23207a86 changed PNG loader to use internal inflating
Frank Benoit <benoit@tionex.de>
parents: 132
diff changeset
75 ZlibInput tangoIstr;
132
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
76
12
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
77 public this ( dwt.dwthelper.InputStream.InputStream istr ){
134
116d23207a86 changed PNG loader to use internal inflating
Frank Benoit <benoit@tionex.de>
parents: 132
diff changeset
78 tangoIstr = new ZlibInput( new InputStreamWrapper(istr ));
12
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
79 }
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
80
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
81 public int read(){
132
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
82 ubyte[1] data;
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
83 uint res = tangoIstr.read( data );
134
116d23207a86 changed PNG loader to use internal inflating
Frank Benoit <benoit@tionex.de>
parents: 132
diff changeset
84 if( res !is 1 ){
132
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
85 return data[0] & 0xFF;
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
86 }
e22f9b443521 Working on ControlExample, png loading makes problems
Frank Benoit <benoit@tionex.de>
parents: 12
diff changeset
87 return -1;
12
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
88 }
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
89
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
90 public int read( byte[] b, int off, int len ){
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
91 implMissing( __FILE__, __LINE__ );
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
92 return 0;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
93 }
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
94
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
95 public int available(){
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
96 implMissing( __FILE__, __LINE__ );
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
97 return 0;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
98 }
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
99
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
100 public long skip( long n ){
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
101 implMissing( __FILE__, __LINE__ );
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
102 return 0L;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
103 }
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
104
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
105 public void close(){
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
106 implMissing( __FILE__, __LINE__ );
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
107 }
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
108
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
109 public void fill(){
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
110 implMissing( __FILE__, __LINE__ );
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
111 }
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
112
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
113 public bool markSupported(){
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
114 implMissing( __FILE__, __LINE__ );
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
115 return false;
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
116 }
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
117
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
118 public synchronized void mark( int readlimit ){
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
119 implMissing( __FILE__, __LINE__ );
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
120 }
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
121
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
122 public synchronized void reset(){
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
123 implMissing( __FILE__, __LINE__ );
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
124 }
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
125 }
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
126
0c78fa47d476 helper classes
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
127