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())
117 if (!stream->decRef())
132 char *Object::getTypeName() {
133 return objTypeNames[type];
136 void Object::print(FILE *f) {
142 fprintf(f, "%s", booln ? "true" : "false");
145 fprintf(f, "%d", intg);
148 fprintf(f, "%g", real);
151 fprintf(f, "(%s)", string->getCString());
154 fprintf(f, "/%s", name);
161 for (i = 0; i < arrayGetLength(); ++i) {
172 for (i = 0; i < dictGetLength(); ++i) {
173 fprintf(f, " /%s ", dictGetKey(i));
174 dictGetValNF(i, &obj);
181 fprintf(f, "<stream>");
184 fprintf(f, "%d %d R", ref.num, ref.gen);
187 fprintf(f, "%s", cmd);
190 fprintf(f, "<error>");
196 fprintf(f, "<none>");
201 void Object::memCheck(FILE *f) {
207 for (i = 0; i < numObjTypes; ++i)
210 fprintf(f, "Allocated objects:\n");
211 for (i = 0; i < numObjTypes; ++i) {
213 fprintf(f, " %-20s: %6d\n", objTypeNames[i], numAlloc[i]);