1 //========================================================================
5 // Copyright 1996 Derek B. Noonburg
7 //========================================================================
10 #pragma implementation
21 //------------------------------------------------------------------------
23 //------------------------------------------------------------------------
25 char *objTypeNames[numObjTypes] = {
43 int Object::numAlloc[numObjTypes] =
44 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
47 Object *Object::initArray() {
53 Object *Object::initDict() {
59 Object *Object::initStream(Stream *stream1) {
65 Object *Object::copy(Object *obj) {
69 obj->string = string->copy();
72 obj->name = copyString(name);
84 obj->cmd = copyString(cmd);
95 Object *Object::fetch(Object *obj) {
96 return (type == objRef && xref) ?
97 xref->fetch(ref.num, ref.gen, obj) : copy(obj);
100 void Object::free() {
109 if (!array->decRef()) {
114 if (!dict->decRef()) {
119 if (!stream->decRef()) {
135 char *Object::getTypeName() {
136 return objTypeNames[type];
139 void Object::print(FILE *f) {
145 fprintf(f, "%s", booln ? "true" : "false");
148 fprintf(f, "%d", intg);
151 fprintf(f, "%g", real);
154 fprintf(f, "(%s)", string->getCString());
157 fprintf(f, "/%s", name);
164 for (i = 0; i < arrayGetLength(); ++i) {
175 for (i = 0; i < dictGetLength(); ++i) {
176 fprintf(f, " /%s ", dictGetKey(i));
177 dictGetValNF(i, &obj);
184 fprintf(f, "<stream>");
187 fprintf(f, "%d %d R", ref.num, ref.gen);
190 fprintf(f, "%s", cmd);
193 fprintf(f, "<error>");
199 fprintf(f, "<none>");
204 void Object::memCheck(FILE *f) {
210 for (i = 0; i < numObjTypes; ++i)
213 fprintf(f, "Allocated objects:\n");
214 for (i = 0; i < numObjTypes; ++i) {
216 fprintf(f, " %-20s: %6d\n", objTypeNames[i], numAlloc[i]);