ReactOS 0.4.15-dev-7842-g558ab78
psstack.c File Reference
#include "psft.h"
#include "psglue.h"
#include "psfont.h"
#include "psstack.h"
#include "pserror.h"
Include dependency graph for psstack.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 cf2_stack_init (FT_Memory memory, FT_Error *e, FT_UInt stackSize)
 
 cf2_stack_free (CF2_Stack stack)
 
 cf2_stack_count (CF2_Stack stack)
 
 cf2_stack_pushInt (CF2_Stack stack, CF2_Int val)
 
 cf2_stack_pushFixed (CF2_Stack stack, CF2_Fixed val)
 
 cf2_stack_popInt (CF2_Stack stack)
 
 cf2_stack_popFixed (CF2_Stack stack)
 
 cf2_stack_getReal (CF2_Stack stack, CF2_UInt idx)
 
 cf2_stack_setReal (CF2_Stack stack, CF2_UInt idx, CF2_Fixed val)
 
 cf2_stack_pop (CF2_Stack stack, CF2_UInt num)
 
 cf2_stack_roll (CF2_Stack stack, CF2_Int count, CF2_Int shift)
 
 cf2_stack_clear (CF2_Stack stack)
 

Function Documentation

◆ cf2_stack_clear()

cf2_stack_clear ( CF2_Stack  stack)

Definition at line 322 of file psstack.c.

323 {
324 stack->top = stack->buffer;
325 }
Definition: _stack.h:55
reference top()
Definition: _stack.h:84

Referenced by cf2_doFlex(), cf2_doStems(), and cf2_interpT2CharString().

◆ cf2_stack_count()

cf2_stack_count ( CF2_Stack  stack)

Definition at line 100 of file psstack.c.

101 {
102 return (CF2_UInt)( stack->top - stack->buffer );
103 }
#define CF2_UInt
Definition: pstypes.h:64

Referenced by cf2_doBlend(), cf2_doStems(), cf2_interpT2CharString(), cf2_stack_getReal(), cf2_stack_pop(), cf2_stack_roll(), and cf2_stack_setReal().

◆ cf2_stack_free()

cf2_stack_free ( CF2_Stack  stack)

Definition at line 84 of file psstack.c.

85 {
86 if ( stack )
87 {
88 FT_Memory memory = stack->memory;
89
90 /* free the buffer */
91 FT_FREE( stack->buffer );
92
93 /* free the main structure */
94 FT_FREE( stack );
95 }
96 }
#define FT_FREE(ptr)
Definition: ftmemory.h:329
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
static char memory[1024 *256]
Definition: process.c:116

Referenced by cf2_interpT2CharString().

◆ cf2_stack_getReal()

cf2_stack_getReal ( CF2_Stack  stack,
CF2_UInt  idx 
)

Definition at line 187 of file psstack.c.

189 {
190 FT_ASSERT( cf2_stack_count( stack ) <= stack->stackSize );
191
192 if ( idx >= cf2_stack_count( stack ) )
193 {
194 CF2_SET_ERROR( stack->error, Stack_Overflow );
195 return cf2_intToFixed( 0 ); /* bounds error */
196 }
197
198 switch ( stack->buffer[idx].type )
199 {
200 case CF2_NumberInt:
201 return cf2_intToFixed( stack->buffer[idx].u.i );
202 case CF2_NumberFrac:
203 return cf2_fracToFixed( stack->buffer[idx].u.f );
204 default:
205 return stack->buffer[idx].u.r;
206 }
207 }
unsigned int idx
Definition: utils.c:41
#define FT_ASSERT(condition)
Definition: ftdebug.h:211
#define CF2_SET_ERROR(error, e)
Definition: pserror.h:109
#define cf2_intToFixed(i)
Definition: psfixed.h:60
@ CF2_NumberFrac
Definition: psfixed.h:83
@ CF2_NumberInt
Definition: psfixed.h:84
#define cf2_fracToFixed(x)
Definition: psfixed.h:74
cf2_stack_count(CF2_Stack stack)
Definition: psstack.c:100

Referenced by cf2_doBlend(), cf2_doFlex(), cf2_doStems(), and cf2_interpT2CharString().

◆ cf2_stack_init()

cf2_stack_init ( FT_Memory  memory,
FT_Error e,
FT_UInt  stackSize 
)

Definition at line 53 of file psstack.c.

56 {
57 FT_Error error = FT_Err_Ok; /* for FT_NEW */
58
60
61
62 if ( !FT_NEW( stack ) )
63 {
64 /* initialize the structure; FT_NEW zeroes it */
65 stack->memory = memory;
66 stack->error = e;
67 }
68
69 /* allocate the stack buffer */
70 if ( FT_NEW_ARRAY( stack->buffer, stackSize ) )
71 {
72 FT_FREE( stack );
73 return NULL;
74 }
75
76 stack->stackSize = stackSize;
77 stack->top = stack->buffer; /* empty stack */
78
79 return stack;
80 }
#define NULL
Definition: types.h:112
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:333
#define FT_NEW(ptr)
Definition: ftmemory.h:331
int FT_Error
Definition: fttypes.h:300
#define e
Definition: ke_i.h:82
#define error(str)
Definition: mkdosfs.c:1605

Referenced by cf2_interpT2CharString().

◆ cf2_stack_pop()

cf2_stack_pop ( CF2_Stack  stack,
CF2_UInt  num 
)

Definition at line 229 of file psstack.c.

231 {
232 if ( num > cf2_stack_count( stack ) )
233 {
234 CF2_SET_ERROR( stack->error, Stack_Underflow );
235 return;
236 }
237 stack->top -= num;
238 }
GLuint GLuint num
Definition: glext.h:9618

Referenced by cf2_doBlend(), and cf2_interpT2CharString().

◆ cf2_stack_popFixed()

cf2_stack_popFixed ( CF2_Stack  stack)

Definition at line 162 of file psstack.c.

163 {
164 if ( stack->top == stack->buffer )
165 {
166 CF2_SET_ERROR( stack->error, Stack_Underflow );
167 return cf2_intToFixed( 0 ); /* underflow */
168 }
169
170 stack->top--;
171
172 switch ( stack->top->type )
173 {
174 case CF2_NumberInt:
175 return cf2_intToFixed( stack->top->u.i );
176 case CF2_NumberFrac:
177 return cf2_fracToFixed( stack->top->u.f );
178 default:
179 return stack->top->u.r;
180 }
181 }

Referenced by cf2_interpT2CharString().

◆ cf2_stack_popInt()

cf2_stack_popInt ( CF2_Stack  stack)

Definition at line 140 of file psstack.c.

141 {
142 if ( stack->top == stack->buffer )
143 {
144 CF2_SET_ERROR( stack->error, Stack_Underflow );
145 return 0; /* underflow */
146 }
147 if ( stack->top[-1].type != CF2_NumberInt )
148 {
149 CF2_SET_ERROR( stack->error, Syntax_Error );
150 return 0; /* type mismatch */
151 }
152
153 stack->top--;
154
155 return stack->top->u.i;
156 }

Referenced by cf2_interpT2CharString().

◆ cf2_stack_pushFixed()

cf2_stack_pushFixed ( CF2_Stack  stack,
CF2_Fixed  val 
)

Definition at line 123 of file psstack.c.

125 {
126 if ( stack->top == stack->buffer + stack->stackSize )
127 {
128 CF2_SET_ERROR( stack->error, Stack_Overflow );
129 return; /* stack overflow */
130 }
131
132 stack->top->u.r = val;
133 stack->top->type = CF2_NumberFixed;
134 stack->top++;
135 }
GLuint GLfloat * val
Definition: glext.h:7180
@ CF2_NumberFixed
Definition: psfixed.h:82

Referenced by cf2_interpT2CharString().

◆ cf2_stack_pushInt()

cf2_stack_pushInt ( CF2_Stack  stack,
CF2_Int  val 
)

Definition at line 107 of file psstack.c.

109 {
110 if ( stack->top == stack->buffer + stack->stackSize )
111 {
112 CF2_SET_ERROR( stack->error, Stack_Overflow );
113 return; /* stack overflow */
114 }
115
116 stack->top->u.i = val;
117 stack->top->type = CF2_NumberInt;
118 stack->top++;
119 }

Referenced by cf2_interpT2CharString().

◆ cf2_stack_roll()

cf2_stack_roll ( CF2_Stack  stack,
CF2_Int  count,
CF2_Int  shift 
)

Definition at line 242 of file psstack.c.

245 {
246 /* we initialize this variable to avoid compiler warnings */
248
249 CF2_Int start_idx, idx, i;
250
251
252 if ( count < 2 )
253 return; /* nothing to do (values 0 and 1), or undefined value */
254
256 {
257 CF2_SET_ERROR( stack->error, Stack_Overflow );
258 return;
259 }
260
261 if ( shift < 0 )
262 shift = -( ( -shift ) % count );
263 else
264 shift %= count;
265
266 if ( shift == 0 )
267 return; /* nothing to do */
268
269 /* We use the following algorithm to do the rolling, */
270 /* which needs two temporary variables only. */
271 /* */
272 /* Example: */
273 /* */
274 /* count = 8 */
275 /* shift = 2 */
276 /* */
277 /* stack indices before roll: 7 6 5 4 3 2 1 0 */
278 /* stack indices after roll: 1 0 7 6 5 4 3 2 */
279 /* */
280 /* The value of index 0 gets moved to index 2, while */
281 /* the old value of index 2 gets moved to index 4, */
282 /* and so on. We thus have the following copying */
283 /* chains for shift value 2. */
284 /* */
285 /* 0 -> 2 -> 4 -> 6 -> 0 */
286 /* 1 -> 3 -> 5 -> 7 -> 1 */
287 /* */
288 /* If `count' and `shift' are incommensurable, we */
289 /* have a single chain only. Otherwise, increase */
290 /* the start index by 1 after the first chain, then */
291 /* do the next chain until all elements in all */
292 /* chains are handled. */
293
294 start_idx = -1;
295 idx = -1;
296 for ( i = 0; i < count; i++ )
297 {
298 CF2_StackNumber tmp;
299
300
301 if ( start_idx == idx )
302 {
303 start_idx++;
304 idx = start_idx;
305 last = stack->buffer[idx];
306 }
307
308 idx += shift;
309 if ( idx >= count )
310 idx -= count;
311 else if ( idx < 0 )
312 idx += count;
313
314 tmp = stack->buffer[idx];
315 stack->buffer[idx] = last;
316 last = tmp;
317 }
318 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define CF2_Int
Definition: pstypes.h:65
static UINT UINT last
Definition: font.c:45
#define shift
Definition: input.c:1755
FT_BEGIN_HEADER struct CF2_StackNumber_ CF2_StackNumber

Referenced by cf2_interpT2CharString().

◆ cf2_stack_setReal()

cf2_stack_setReal ( CF2_Stack  stack,
CF2_UInt  idx,
CF2_Fixed  val 
)

Definition at line 212 of file psstack.c.

215 {
216 if ( idx > cf2_stack_count( stack ) )
217 {
218 CF2_SET_ERROR( stack->error, Stack_Overflow );
219 return;
220 }
221
222 stack->buffer[idx].u.r = val;
223 stack->buffer[idx].type = CF2_NumberFixed;
224 }

Referenced by cf2_doBlend(), and cf2_interpT2CharString().