Mercurial > hg > aim92
comparison stitch/source.h @ 0:5242703e91d3 tip
Initial checkin for AIM92 aimR8.2 (last updated May 1997).
author | tomwalters |
---|---|
date | Fri, 20 May 2011 15:19:45 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:5242703e91d3 |
---|---|
1 /* | |
2 source.h | |
3 ======== | |
4 | |
5 | |
6 | |
7 */ | |
8 | |
9 #ifndef _SOURCE_H_ | |
10 #define _SOURCE_H_ | |
11 | |
12 #include "buffer.h" | |
13 | |
14 /* standard entry points */ | |
15 | |
16 #define PullSome( _source, _bytes ) ( _SPTR( _source )->returned = _SPTR( _source )->pull( _SPTR( _source ), (ByteCount *) ( _bytes ) ) ) | |
17 #define FillSome( _source, _bytes, _buffer ) ( _SPTR( _source )->returned = _SPTR( _source )->fill( _SPTR( _source ), (ByteCount *) ( _bytes ), (Pointer ) ( _buffer ) ) ) | |
18 #define RollSome( _source, _bytes, _kept ) ( _SPTR( _source )->returned = _SPTR( _source )->roll( _SPTR( _source ), (ByteCount *) ( _bytes ), (ByteCount) ( _kept ) ) ) | |
19 | |
20 /* for compatability */ | |
21 | |
22 #define Pull( _source, _bytes ) ( _SPTR( _source )->returned = oldPull( _SPTR( _source ), (ByteCount ) ( _bytes ) ) ) | |
23 #define Fill( _source, _bytes, _buffer ) ( _SPTR( _source )->returned = oldFill( _SPTR( _source ), (ByteCount ) ( _bytes ), (Pointer ) ( _buffer ) ) ) | |
24 #define Roll( _source, _bytes, _kept ) ( _SPTR( _source )->returned = oldRoll( _SPTR( _source ), (ByteCount ) ( _bytes ), (ByteCount) ( _kept ) ) ) | |
25 | |
26 /* for more compatability */ | |
27 | |
28 #define Shift( _source, _bytes, _kept ) Roll( _source, _bytes, _kept ) | |
29 | |
30 /* count conversions */ | |
31 | |
32 #define ToPoints( _type, _bytes ) ( ( _bytes ) >> ( sizeof(_type) >> 1 ) ) | |
33 #define ToBytes( _type, _points ) ( ( char *) ( (_type *) 0l + ( _points ) ) - ( char *) 0l ) | |
34 | |
35 /* for convenience */ | |
36 | |
37 #define PullItems( _source, _number, _type ) ( (_type *) Pull( _source, ToBytes( _type, _number ) ) ) | |
38 | |
39 #define PullChars( _source, _number ) PullItems( _source, _number, char ) | |
40 #define PullShorts( _source, _number ) PullItems( _source, _number, short ) | |
41 #define PullInts( _source, _number ) PullItems( _source, _number, int ) | |
42 #define PullDoubles( _source, _number ) PullItems( _source, _number, double ) | |
43 | |
44 | |
45 #define FillItems( _source, _number, _buffer, _type ) ( (_type *) Fill( _source, ToBytes( _type, _number ), (Pointer) ( _buffer ) ) ) | |
46 | |
47 #define FillChars( _source, _number, _buffer ) FillItems( _source, _number, _buffer, char ) | |
48 #define FillShorts( _source, _number, _buffer ) FillItems( _source, _number, _buffer, short ) | |
49 #define FillInts( _source, _number, _buffer ) FillItems( _source, _number, _buffer, int ) | |
50 #define FillDoubles( _source, _number, _buffer ) FillItems( _source, _number, _buffer, double ) | |
51 | |
52 | |
53 #define RollItems( _source, _number, _keep, _type ) ( (_type *) Roll( _source, ToBytes( _type, _number ), ( _keep ) * sizeof ( _type ) ) ) | |
54 | |
55 #define RollChars( _source, _number, _keep ) RollItems( _source, _number, _keep, char ) | |
56 #define RollShorts( _source, _number, _keep ) RollItems( _source, _number, _keep, short ) | |
57 #define RollInts( _source, _number, _keep ) RollItems( _source, _number, _keep, int ) | |
58 #define RollDoubles( _source, _number, _keep ) RollItems( _source, _number, _keep, double ) | |
59 | |
60 /* operators on sources */ | |
61 | |
62 #define SetSource( _src, _puller, _filler, _roller, _name ) setSource( (struct _source *) _src, _puller, _filler, _roller, _name ) | |
63 #define TypeSource( _src, _type ) typeSource( (struct _source *) _src, _type ) | |
64 #define SourceType( _src ) sourceType( (struct _source *) _src ) | |
65 #define SourceName( _src ) sourceName( (struct _source *) _src ) | |
66 #define DeleteSource( _src ) deleteSource( (struct _source *) _src ) | |
67 | |
68 #if 00 | |
69 #define NameOfClass BasicSourceClass | |
70 | |
71 #define SetSource( _source, _puller, _filler, _roller, _name ) NameOfClass.set( (struct _source *) _source, _puller, _filler, _roller, _name ) | |
72 #define TypeSource( _source, _type ) NameOfClass.setType( (struct _source *) _source, _type ) | |
73 #define SourceType( _source ) NameOfClass.getType( (struct _source *) _source ) | |
74 #define SourceName( _source ) NameOfClass.getName( (struct _source *) _source ) | |
75 #define DeleteSource( _source ) NameOfClass.delete( (struct _source *) _source ) | |
76 #endif | |
77 | |
78 | |
79 | |
80 #define SinkSource( _source, _framebytes , _frames ) \ | |
81 sinkSource( _source, (ByteCount) ( _framebytes ), (long) _frames ) | |
82 | |
83 #define SinkAndCloseSource( _source, _framebytes , _frames ) \ | |
84 sinkAndCloseSource( _source, (ByteCount) ( _framebytes ), (long) _frames ) | |
85 | |
86 /* moving towards buffer abstraction, slowly */ | |
87 | |
88 #define SourceBuffer( _source ) ( ( _source )->buffer ) | |
89 #define SetSourceBuffer( _source, _buffer ) ( ( _source )->buffer = _buffer ) | |
90 | |
91 /* only pure source */ | |
92 | |
93 #define NewTappingSource( _source , _state, _callback, _close, _name ) \ | |
94 newTappingSource( (Pointer) ( _source ), _state, _callback, _close, _name ) | |
95 | |
96 #define NewRollableSource( _source ) \ | |
97 newRollableSource( _source ) | |
98 | |
99 #if 0 | |
100 /* for compatability */ | |
101 | |
102 #define NewShiftableSource( _source ) \ | |
103 NewRollableSource( _source ) | |
104 #endif | |
105 | |
106 /* for binding with C++ perhaps someday */ | |
107 | |
108 #if defined(__cplusplus) || defined(c_plusplus) | |
109 #define CPLPL 1 | |
110 #else | |
111 #define CPLPL 0 | |
112 #endif | |
113 | |
114 #if CPLPL | |
115 | |
116 #define _SPTR( _s ) ((_s).ptr) | |
117 #define _MANY_ARGS ... | |
118 #define _ONE_SOURCE Source source | |
119 #define _TWO_SOURCES Source source1, Source source2 | |
120 #define _ONE_SOURCE_PLUS Source source... | |
121 | |
122 typedef class _source &Source ; /* ?? or something */ | |
123 | |
124 #else | |
125 | |
126 #define _SPTR( _s ) _s | |
127 #define _MANY_ARGS /* ... */ | |
128 #define _ONE_SOURCE /* Source source */ | |
129 #define _TWO_SOURCES /* Source source1, Source source2 */ | |
130 #define _ONE_SOURCE_PLUS /* Source source... */ | |
131 | |
132 /* basic types */ | |
133 | |
134 typedef struct _source *Source, *SourceArray[1] ; | |
135 | |
136 #endif | |
137 | |
138 typedef Source CharSource, ShortSource, IntSource, FloatSource, DoubleSource, ComplexSource ; | |
139 typedef SourceArray CharSourceArray, ShortSourceArray, IntSourceArray, FloatSourceArray, DoubleSourceArray, ComplexSourceArray ; | |
140 | |
141 typedef int ByteCount ; | |
142 | |
143 /* dependant on type of source */ | |
144 | |
145 struct _source { Pointer (*pull)(), (*fill)(), (*roll)(), returned ; char *name, *type ; int opened ; Source (*open)() ; } ; | |
146 struct _source_operators { Source (*set)() ; Pointer (*delete)() ; Source (*setType)() ; char *(*getType)() ; char *(*getName)() ; } ; | |
147 | |
148 struct _pullable_source { struct _source parent ; } ; | |
149 struct _fillable_source { struct _source parent ; Buffer buffer ; } ; | |
150 | |
151 #if 00 | |
152 extern struct _source_operators NameOfClass ; | |
153 extern struct _source *call_conversions ; | |
154 #endif | |
155 | |
156 extern Source setSource() ; | |
157 extern Source typeSource() ; | |
158 extern char *sourceType() ; | |
159 extern char *sourceName() ; | |
160 extern Pointer deleteSource() ; | |
161 | |
162 extern Pointer oldPull(), oldFill(), oldRoll() ; | |
163 | |
164 | |
165 extern void sinkSource() ; | |
166 extern void CloseSource() ; | |
167 extern void sinkAndCloseSource() ; | |
168 | |
169 /* derived source types for different purposes */ | |
170 | |
171 extern Source newTappingSource() ; | |
172 extern Source newRollableSource() ; | |
173 | |
174 extern Pointer nonRoller() ; | |
175 | |
176 #include "pullable.h" | |
177 | |
178 #include "fillable.h" | |
179 | |
180 extern Source *BindSources() ; | |
181 | |
182 /* for compatability... for now */ | |
183 | |
184 extern Source stdStaticSource() ; | |
185 extern Source stdSlaveSource() ; | |
186 extern Source stdAutoSource() ; | |
187 extern Source stdSelfSource() ; | |
188 | |
189 #endif | |
190 | |
191 extern Source EmptySource ; |