Lines 68-84
Link Here
|
68 |
//------------------------------------------------------------------------ |
68 |
//------------------------------------------------------------------------ |
69 |
|
69 |
|
70 |
#ifdef DEBUG_MEM |
70 |
#ifdef DEBUG_MEM |
71 |
#define initObj(t) ++numAlloc[type = t] |
71 |
#define initObj(t) zeroUnion(); ++numAlloc[type = t] |
72 |
#else |
72 |
#else |
73 |
#define initObj(t) type = t |
73 |
#define initObj(t) zeroUnion(); type = t |
74 |
#endif |
74 |
#endif |
75 |
|
75 |
|
76 |
class Object { |
76 |
class Object { |
77 |
public: |
77 |
public: |
78 |
|
78 |
// attempt to clear the anonymous union |
|
|
79 |
void zeroUnion() { this->name = NULL; } |
79 |
// Default constructor. |
80 |
// Default constructor. |
80 |
Object(): |
81 |
Object(): |
81 |
type(objNone) {} |
82 |
type(objNone) { zeroUnion(); } |
82 |
|
83 |
|
83 |
// Initialize an object. |
84 |
// Initialize an object. |
84 |
Object *initBool(GBool boolnA) |
85 |
Object *initBool(GBool boolnA) |
Lines 219-234
Link Here
|
219 |
#include "Array.h" |
220 |
#include "Array.h" |
220 |
|
221 |
|
221 |
inline int Object::arrayGetLength() |
222 |
inline int Object::arrayGetLength() |
222 |
{ return array->getLength(); } |
223 |
{ if (type != objArray) return 0; return array->getLength(); } |
223 |
|
224 |
|
224 |
inline void Object::arrayAdd(Object *elem) |
225 |
inline void Object::arrayAdd(Object *elem) |
225 |
{ array->add(elem); } |
226 |
{ if (type == objArray) array->add(elem); } |
226 |
|
227 |
|
227 |
inline Object *Object::arrayGet(int i, Object *obj) |
228 |
inline Object *Object::arrayGet(int i, Object *obj) |
228 |
{ return array->get(i, obj); } |
229 |
{ if (type != objArray) return obj->initNull(); return array->get(i, obj); } |
229 |
|
230 |
|
230 |
inline Object *Object::arrayGetNF(int i, Object *obj) |
231 |
inline Object *Object::arrayGetNF(int i, Object *obj) |
231 |
{ return array->getNF(i, obj); } |
232 |
{ if (type != objArray) return obj->initNull(); return array->getNF(i, obj); } |
232 |
|
233 |
|
233 |
//------------------------------------------------------------------------ |
234 |
//------------------------------------------------------------------------ |
234 |
// Dict accessors. |
235 |
// Dict accessors. |
Lines 237-267
Link Here
|
237 |
#include "Dict.h" |
238 |
#include "Dict.h" |
238 |
|
239 |
|
239 |
inline int Object::dictGetLength() |
240 |
inline int Object::dictGetLength() |
240 |
{ return dict->getLength(); } |
241 |
{ if (type != objDict) return 0; return dict->getLength(); } |
241 |
|
242 |
|
242 |
inline void Object::dictAdd(char *key, Object *val) |
243 |
inline void Object::dictAdd(char *key, Object *val) |
243 |
{ dict->add(key, val); } |
244 |
{ if (type == objDict) dict->add(key, val); } |
244 |
|
245 |
|
245 |
inline GBool Object::dictIs(const char *dictType) |
246 |
inline GBool Object::dictIs(const char *dictType) |
246 |
{ return dict->is(dictType); } |
247 |
{ return (type == objDict) && dict->is(dictType); } |
247 |
|
248 |
|
248 |
inline GBool Object::isDict(const char *dictType) |
249 |
inline GBool Object::isDict(const char *dictType) |
249 |
{ return type == objDict && dictIs(dictType); } |
250 |
{ return (type == objDict) && dictIs(dictType); } |
250 |
|
251 |
|
251 |
inline Object *Object::dictLookup(const char *key, Object *obj) |
252 |
inline Object *Object::dictLookup(const char *key, Object *obj) |
252 |
{ return dict->lookup(key, obj); } |
253 |
{ if (type != objDict) return obj->initNull(); return dict->lookup(key, obj); } |
253 |
|
254 |
|
254 |
inline Object *Object::dictLookupNF(const char *key, Object *obj) |
255 |
inline Object *Object::dictLookupNF(const char *key, Object *obj) |
255 |
{ return dict->lookupNF(key, obj); } |
256 |
{ if (type != objDict) return obj->initNull(); return dict->lookupNF(key, obj); } |
256 |
|
257 |
|
257 |
inline char *Object::dictGetKey(int i) |
258 |
inline char *Object::dictGetKey(int i) |
258 |
{ return dict->getKey(i); } |
259 |
{ if (type != objDict) return NULL; return dict->getKey(i); } |
259 |
|
260 |
|
260 |
inline Object *Object::dictGetVal(int i, Object *obj) |
261 |
inline Object *Object::dictGetVal(int i, Object *obj) |
261 |
{ return dict->getVal(i, obj); } |
262 |
{ if (type != objDict) return obj->initNull(); return dict->getVal(i, obj); } |
262 |
|
263 |
|
263 |
inline Object *Object::dictGetValNF(int i, Object *obj) |
264 |
inline Object *Object::dictGetValNF(int i, Object *obj) |
264 |
{ return dict->getValNF(i, obj); } |
265 |
{ if (type != objDict) return obj->initNull(); return dict->getValNF(i, obj); } |
265 |
|
266 |
|
266 |
//------------------------------------------------------------------------ |
267 |
//------------------------------------------------------------------------ |
267 |
// Stream accessors. |
268 |
// Stream accessors. |
Lines 270-302
Link Here
|
270 |
#include "Stream.h" |
271 |
#include "Stream.h" |
271 |
|
272 |
|
272 |
inline GBool Object::streamIs(const char *dictType) |
273 |
inline GBool Object::streamIs(const char *dictType) |
273 |
{ return stream->getDict()->is(dictType); } |
274 |
{ return (type == objStream) && stream->getDict()->is(dictType); } |
274 |
|
275 |
|
275 |
inline GBool Object::isStream(const char *dictType) |
276 |
inline GBool Object::isStream(const char *dictType) |
276 |
{ return type == objStream && streamIs(dictType); } |
277 |
{ return (type == objStream) && streamIs(dictType); } |
277 |
|
278 |
|
278 |
inline void Object::streamReset() |
279 |
inline void Object::streamReset() |
279 |
{ stream->reset(); } |
280 |
{ if (type == objStream) stream->reset(); } |
280 |
|
281 |
|
281 |
inline void Object::streamClose() |
282 |
inline void Object::streamClose() |
282 |
{ stream->close(); } |
283 |
{ if (type == objStream) stream->close(); } |
283 |
|
284 |
|
284 |
inline int Object::streamGetChar() |
285 |
inline int Object::streamGetChar() |
285 |
{ return stream->getChar(); } |
286 |
{ if (type != objStream) return EOF; return stream->getChar(); } |
286 |
|
287 |
|
287 |
inline int Object::streamLookChar() |
288 |
inline int Object::streamLookChar() |
288 |
{ return stream->lookChar(); } |
289 |
{ if (type != objStream) return EOF; return stream->lookChar(); } |
289 |
|
290 |
|
290 |
inline char *Object::streamGetLine(char *buf, int size) |
291 |
inline char *Object::streamGetLine(char *buf, int size) |
291 |
{ return stream->getLine(buf, size); } |
292 |
{ if (type != objStream) return NULL; return stream->getLine(buf, size); } |
292 |
|
293 |
|
293 |
inline Guint Object::streamGetPos() |
294 |
inline Guint Object::streamGetPos() |
294 |
{ return stream->getPos(); } |
295 |
{ if (type != objStream) return 0; return stream->getPos(); } |
295 |
|
296 |
|
296 |
inline void Object::streamSetPos(Guint pos, int dir) |
297 |
inline void Object::streamSetPos(Guint pos, int dir) |
297 |
{ stream->setPos(pos, dir); } |
298 |
{ if (type == objStream) stream->setPos(pos, dir); } |
298 |
|
299 |
|
299 |
inline Dict *Object::streamGetDict() |
300 |
inline Dict *Object::streamGetDict() |
300 |
{ return stream->getDict(); } |
301 |
{ if (type != objStream) return NULL; return stream->getDict(); } |
301 |
|
302 |
|
302 |
#endif |
303 |
#endif |