OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* ftstream.h */ | 3 /* ftstream.h */ |
4 /* */ | 4 /* */ |
5 /* Stream handling (specification). */ | 5 /* Stream handling (specification). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 1996-2002, 2004-2006, 2011 by */ | 7 /* Copyright 1996-2002, 2004-2006, 2011, 2013 by */ |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
9 /* */ | 9 /* */ |
10 /* This file is part of the FreeType project, and may only be used, */ | 10 /* This file is part of the FreeType project, and may only be used, */ |
11 /* modified, and distributed under the terms of the FreeType project */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
15 /* */ | 15 /* */ |
16 /***************************************************************************/ | 16 /***************************************************************************/ |
17 | 17 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 #define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 } | 147 #define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 } |
148 | 148 |
149 | 149 |
150 /*************************************************************************/ | 150 /*************************************************************************/ |
151 /* */ | 151 /* */ |
152 /* Integer extraction macros -- the `buffer' parameter must ALWAYS be of */ | 152 /* Integer extraction macros -- the `buffer' parameter must ALWAYS be of */ |
153 /* type `char*' or equivalent (1-byte elements). */ | 153 /* type `char*' or equivalent (1-byte elements). */ |
154 /* */ | 154 /* */ |
155 | 155 |
156 #define FT_BYTE_( p, i ) ( ((const FT_Byte*)(p))[(i)] ) | 156 #define FT_BYTE_( p, i ) ( ((const FT_Byte*)(p))[(i)] ) |
157 #define FT_INT8_( p, i ) ( ((const FT_Char*)(p))[(i)] ) | |
158 | 157 |
159 #define FT_INT16( x ) ( (FT_Int16)(x) ) | 158 #define FT_INT16( x ) ( (FT_Int16)(x) ) |
160 #define FT_UINT16( x ) ( (FT_UInt16)(x) ) | 159 #define FT_UINT16( x ) ( (FT_UInt16)(x) ) |
161 #define FT_INT32( x ) ( (FT_Int32)(x) ) | 160 #define FT_INT32( x ) ( (FT_Int32)(x) ) |
162 #define FT_UINT32( x ) ( (FT_UInt32)(x) ) | 161 #define FT_UINT32( x ) ( (FT_UInt32)(x) ) |
163 | 162 |
164 #define FT_BYTE_I16( p, i, s ) ( FT_INT16( FT_BYTE_( p, i ) ) << (s) ) | 163 |
165 #define FT_BYTE_U16( p, i, s ) ( FT_UINT16( FT_BYTE_( p, i ) ) << (s) ) | 164 #define FT_BYTE_U16( p, i, s ) ( FT_UINT16( FT_BYTE_( p, i ) ) << (s) ) |
166 #define FT_BYTE_I32( p, i, s ) ( FT_INT32( FT_BYTE_( p, i ) ) << (s) ) | |
167 #define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) ) | 165 #define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) ) |
168 | 166 |
169 #define FT_INT8_I16( p, i, s ) ( FT_INT16( FT_INT8_( p, i ) ) << (s) ) | |
170 #define FT_INT8_U16( p, i, s ) ( FT_UINT16( FT_INT8_( p, i ) ) << (s) ) | |
171 #define FT_INT8_I32( p, i, s ) ( FT_INT32( FT_INT8_( p, i ) ) << (s) ) | |
172 #define FT_INT8_U32( p, i, s ) ( FT_UINT32( FT_INT8_( p, i ) ) << (s) ) | |
173 | 167 |
174 | 168 #define FT_PEEK_SHORT( p ) FT_INT16( FT_BYTE_U16( p, 0, 8) | \ |
175 #define FT_PEEK_SHORT( p ) FT_INT16( FT_INT8_I16( p, 0, 8) | \ | 169 FT_BYTE_U16( p, 1, 0) ) |
176 FT_BYTE_I16( p, 1, 0) ) | |
177 | 170 |
178 #define FT_PEEK_USHORT( p ) FT_UINT16( FT_BYTE_U16( p, 0, 8 ) | \ | 171 #define FT_PEEK_USHORT( p ) FT_UINT16( FT_BYTE_U16( p, 0, 8 ) | \ |
179 FT_BYTE_U16( p, 1, 0 ) ) | 172 FT_BYTE_U16( p, 1, 0 ) ) |
180 | 173 |
181 #define FT_PEEK_LONG( p ) FT_INT32( FT_INT8_I32( p, 0, 24 ) | \ | 174 #define FT_PEEK_LONG( p ) FT_INT32( FT_BYTE_U32( p, 0, 24 ) | \ |
182 FT_BYTE_I32( p, 1, 16 ) | \ | 175 FT_BYTE_U32( p, 1, 16 ) | \ |
183 FT_BYTE_I32( p, 2, 8 ) | \ | 176 FT_BYTE_U32( p, 2, 8 ) | \ |
184 FT_BYTE_I32( p, 3, 0 ) ) | 177 FT_BYTE_U32( p, 3, 0 ) ) |
185 | 178 |
186 #define FT_PEEK_ULONG( p ) FT_UINT32( FT_BYTE_U32( p, 0, 24 ) | \ | 179 #define FT_PEEK_ULONG( p ) FT_UINT32( FT_BYTE_U32( p, 0, 24 ) | \ |
187 FT_BYTE_U32( p, 1, 16 ) | \ | 180 FT_BYTE_U32( p, 1, 16 ) | \ |
188 FT_BYTE_U32( p, 2, 8 ) | \ | 181 FT_BYTE_U32( p, 2, 8 ) | \ |
189 FT_BYTE_U32( p, 3, 0 ) ) | 182 FT_BYTE_U32( p, 3, 0 ) ) |
190 | 183 |
191 #define FT_PEEK_OFF3( p ) FT_INT32( FT_INT8_I32( p, 0, 16 ) | \ | 184 #define FT_PEEK_OFF3( p ) FT_INT32( FT_BYTE_U32( p, 0, 16 ) | \ |
192 FT_BYTE_I32( p, 1, 8 ) | \ | 185 FT_BYTE_U32( p, 1, 8 ) | \ |
193 FT_BYTE_I32( p, 2, 0 ) ) | 186 FT_BYTE_U32( p, 2, 0 ) ) |
194 | 187 |
195 #define FT_PEEK_UOFF3( p ) FT_UINT32( FT_BYTE_U32( p, 0, 16 ) | \ | 188 #define FT_PEEK_UOFF3( p ) FT_UINT32( FT_BYTE_U32( p, 0, 16 ) | \ |
196 FT_BYTE_U32( p, 1, 8 ) | \ | 189 FT_BYTE_U32( p, 1, 8 ) | \ |
197 FT_BYTE_U32( p, 2, 0 ) ) | 190 FT_BYTE_U32( p, 2, 0 ) ) |
198 | 191 |
199 #define FT_PEEK_SHORT_LE( p ) FT_INT16( FT_INT8_I16( p, 1, 8 ) | \ | 192 #define FT_PEEK_SHORT_LE( p ) FT_INT16( FT_BYTE_U16( p, 1, 8 ) | \ |
200 FT_BYTE_I16( p, 0, 0 ) ) | 193 FT_BYTE_U16( p, 0, 0 ) ) |
201 | 194 |
202 #define FT_PEEK_USHORT_LE( p ) FT_UINT16( FT_BYTE_U16( p, 1, 8 ) | \ | 195 #define FT_PEEK_USHORT_LE( p ) FT_UINT16( FT_BYTE_U16( p, 1, 8 ) | \ |
203 FT_BYTE_U16( p, 0, 0 ) ) | 196 FT_BYTE_U16( p, 0, 0 ) ) |
204 | 197 |
205 #define FT_PEEK_LONG_LE( p ) FT_INT32( FT_INT8_I32( p, 3, 24 ) | \ | 198 #define FT_PEEK_LONG_LE( p ) FT_INT32( FT_BYTE_U32( p, 3, 24 ) | \ |
206 FT_BYTE_I32( p, 2, 16 ) | \ | 199 FT_BYTE_U32( p, 2, 16 ) | \ |
207 FT_BYTE_I32( p, 1, 8 ) | \ | 200 FT_BYTE_U32( p, 1, 8 ) | \ |
208 FT_BYTE_I32( p, 0, 0 ) ) | 201 FT_BYTE_U32( p, 0, 0 ) ) |
209 | 202 |
210 #define FT_PEEK_ULONG_LE( p ) FT_UINT32( FT_BYTE_U32( p, 3, 24 ) | \ | 203 #define FT_PEEK_ULONG_LE( p ) FT_UINT32( FT_BYTE_U32( p, 3, 24 ) | \ |
211 FT_BYTE_U32( p, 2, 16 ) | \ | 204 FT_BYTE_U32( p, 2, 16 ) | \ |
212 FT_BYTE_U32( p, 1, 8 ) | \ | 205 FT_BYTE_U32( p, 1, 8 ) | \ |
213 FT_BYTE_U32( p, 0, 0 ) ) | 206 FT_BYTE_U32( p, 0, 0 ) ) |
214 | 207 |
215 #define FT_PEEK_OFF3_LE( p ) FT_INT32( FT_INT8_I32( p, 2, 16 ) | \ | 208 #define FT_PEEK_OFF3_LE( p ) FT_INT32( FT_BYTE_U32( p, 2, 16 ) | \ |
216 FT_BYTE_I32( p, 1, 8 ) | \ | 209 FT_BYTE_U32( p, 1, 8 ) | \ |
217 FT_BYTE_I32( p, 0, 0 ) ) | 210 FT_BYTE_U32( p, 0, 0 ) ) |
218 | 211 |
219 #define FT_PEEK_UOFF3_LE( p ) FT_UINT32( FT_BYTE_U32( p, 2, 16 ) | \ | 212 #define FT_PEEK_UOFF3_LE( p ) FT_UINT32( FT_BYTE_U32( p, 2, 16 ) | \ |
220 FT_BYTE_U32( p, 1, 8 ) | \ | 213 FT_BYTE_U32( p, 1, 8 ) | \ |
221 FT_BYTE_U32( p, 0, 0 ) ) | 214 FT_BYTE_U32( p, 0, 0 ) ) |
222 | 215 |
223 | 216 |
224 #define FT_NEXT_CHAR( buffer ) \ | 217 #define FT_NEXT_CHAR( buffer ) \ |
225 ( (signed char)*buffer++ ) | 218 ( (signed char)*buffer++ ) |
226 | 219 |
227 #define FT_NEXT_BYTE( buffer ) \ | 220 #define FT_NEXT_BYTE( buffer ) \ |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 /* by an array of FT_Frame_Field records. */ | 479 /* by an array of FT_Frame_Field records. */ |
487 FT_BASE( FT_Error ) | 480 FT_BASE( FT_Error ) |
488 FT_Stream_ReadFields( FT_Stream stream, | 481 FT_Stream_ReadFields( FT_Stream stream, |
489 const FT_Frame_Field* fields, | 482 const FT_Frame_Field* fields, |
490 void* structure ); | 483 void* structure ); |
491 | 484 |
492 | 485 |
493 #define FT_STREAM_POS() \ | 486 #define FT_STREAM_POS() \ |
494 FT_Stream_Pos( stream ) | 487 FT_Stream_Pos( stream ) |
495 | 488 |
496 #define FT_STREAM_SEEK( position ) \ | 489 #define FT_STREAM_SEEK( position ) \ |
497 FT_SET_ERROR( FT_Stream_Seek( stream, position ) ) | 490 FT_SET_ERROR( FT_Stream_Seek( stream, \ |
| 491 (FT_ULong)(position) ) ) |
498 | 492 |
499 #define FT_STREAM_SKIP( distance ) \ | 493 #define FT_STREAM_SKIP( distance ) \ |
500 FT_SET_ERROR( FT_Stream_Skip( stream, distance ) ) | 494 FT_SET_ERROR( FT_Stream_Skip( stream, \ |
| 495 (FT_Long)(distance) ) ) |
501 | 496 |
502 #define FT_STREAM_READ( buffer, count ) \ | 497 #define FT_STREAM_READ( buffer, count ) \ |
503 FT_SET_ERROR( FT_Stream_Read( stream, \ | 498 FT_SET_ERROR( FT_Stream_Read( stream, \ |
504 (FT_Byte*)buffer, \ | 499 (FT_Byte*)(buffer), \ |
505 count ) ) | 500 (FT_ULong)(count) ) ) |
506 | 501 |
507 #define FT_STREAM_READ_AT( position, buffer, count ) \ | 502 #define FT_STREAM_READ_AT( position, buffer, count ) \ |
508 FT_SET_ERROR( FT_Stream_ReadAt( stream, \ | 503 FT_SET_ERROR( FT_Stream_ReadAt( stream, \ |
509 position, \ | 504 (FT_ULong)(position), \ |
510 (FT_Byte*)buffer, \ | 505 (FT_Byte*)buffer, \ |
511 count ) ) | 506 (FT_ULong)(count) ) ) |
512 | 507 |
513 #define FT_STREAM_READ_FIELDS( fields, object ) \ | 508 #define FT_STREAM_READ_FIELDS( fields, object ) \ |
514 FT_SET_ERROR( FT_Stream_ReadFields( stream, fields, object ) ) | 509 FT_SET_ERROR( FT_Stream_ReadFields( stream, fields, object ) ) |
515 | 510 |
516 | 511 |
517 #define FT_FRAME_ENTER( size ) \ | 512 #define FT_FRAME_ENTER( size ) \ |
518 FT_SET_ERROR( \ | 513 FT_SET_ERROR( \ |
519 FT_DEBUG_INNER( FT_Stream_EnterFrame( stream, size ) ) ) | 514 FT_DEBUG_INNER( FT_Stream_EnterFrame( stream, \ |
| 515 (FT_ULong)(size) ) ) ) |
520 | 516 |
521 #define FT_FRAME_EXIT() \ | 517 #define FT_FRAME_EXIT() \ |
522 FT_DEBUG_INNER( FT_Stream_ExitFrame( stream ) ) | 518 FT_DEBUG_INNER( FT_Stream_ExitFrame( stream ) ) |
523 | 519 |
524 #define FT_FRAME_EXTRACT( size, bytes ) \ | 520 #define FT_FRAME_EXTRACT( size, bytes ) \ |
525 FT_SET_ERROR( \ | 521 FT_SET_ERROR( \ |
526 FT_DEBUG_INNER( FT_Stream_ExtractFrame( stream, size, \ | 522 FT_DEBUG_INNER( FT_Stream_ExtractFrame( stream, \ |
| 523 (FT_ULong)(size), \ |
527 (FT_Byte**)&(bytes) ) ) ) | 524 (FT_Byte**)&(bytes) ) ) ) |
528 | 525 |
529 #define FT_FRAME_RELEASE( bytes ) \ | 526 #define FT_FRAME_RELEASE( bytes ) \ |
530 FT_DEBUG_INNER( FT_Stream_ReleaseFrame( stream, \ | 527 FT_DEBUG_INNER( FT_Stream_ReleaseFrame( stream, \ |
531 (FT_Byte**)&(bytes) ) ) | 528 (FT_Byte**)&(bytes) ) ) |
532 | 529 |
533 | 530 |
534 FT_END_HEADER | 531 FT_END_HEADER |
535 | 532 |
536 #endif /* __FTSTREAM_H__ */ | 533 #endif /* __FTSTREAM_H__ */ |
537 | 534 |
538 | 535 |
539 /* END */ | 536 /* END */ |
OLD | NEW |