1 //========================================================================
5 // Copyright 1996-2003 Glyph & Cog, LLC
7 //========================================================================
11 #ifdef USE_GCC_PRAGMAS
12 #pragma implementation
23 //------------------------------------------------------------------------
25 //------------------------------------------------------------------------
27 char *objTypeNames[numObjTypes] = {
45 int Object::numAlloc[numObjTypes] =
46 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
49 Object *Object::initArray(XRef *xref) {
51 array = new Array(xref);
55 Object *Object::initDict(XRef *xref) {
57 dict = new Dict(xref);
61 Object *Object::initStream(Stream *streamA) {
67 Object *Object::copy(Object *obj) {
71 obj->string = string->copy();
74 obj->name = copyString(name);
86 obj->cmd = copyString(cmd);
97 Object *Object::fetch(XRef *xref, Object *obj) {
98 return (type == objRef && xref) ?
99 xref->fetch(ref.num, ref.gen, obj) : copy(obj);
102 void Object::free() {
111 if (!array->decRef()) {
116 if (!dict->decRef()) {
121 if (!stream->decRef()) {
137 char *Object::getTypeName() {
138 return objTypeNames[type];
141 void Object::print(FILE *f) {
147 fprintf(f, "%s", booln ? "true" : "false");
150 fprintf(f, "%d", intg);
153 fprintf(f, "%g", real);
157 fwrite(string->getCString(), 1, string->getLength(), stdout);
161 fprintf(f, "/%s", name);
168 for (i = 0; i < arrayGetLength(); ++i) {
179 for (i = 0; i < dictGetLength(); ++i) {
180 fprintf(f, " /%s ", dictGetKey(i));
181 dictGetValNF(i, &obj);
188 fprintf(f, "<stream>");
191 fprintf(f, "%d %d R", ref.num, ref.gen);
194 fprintf(f, "%s", cmd);
197 fprintf(f, "<error>");
203 fprintf(f, "<none>");
208 void Object::memCheck(FILE *f) {
214 for (i = 0; i < numObjTypes; ++i)
217 fprintf(f, "Allocated objects:\n");
218 for (i = 0; i < numObjTypes; ++i) {
220 fprintf(f, " %-20s: %6d\n", objTypeNames[i], numAlloc[i]);