/* readClass reads a class method description */ static void readMethods(FILE* fd, bool printit) { ObjectHandle classObj, methTable, theMethod, selector; # define LINEBUFFERSIZE 16384 char *cp, *eoftest, lineBuffer[LINEBUFFERSIZE]; ObjectHandle protocol; Parser pp; lineBuffer[0] = '\0'; protocol = nilobj; if (ll.nextToken() != nameconst) sysError("missing name","following Method keyword"); classObj = findClass(ll.strToken().c_str()); pp.setInstanceVariables(classObj); if (printit) cp = objectRef(classObj->basicAt(nameInClass)).charPtr(); /* now find or create a method table */ methTable = classObj->basicAt(methodsInClass); if (methTable == nilobj) { /* must make */ methTable = newDictionary(MethodTableSize); classObj->basicAtPut(methodsInClass, methTable); } if(ll.nextToken() == strconst) { protocol = newStString(ll.strToken().c_str()); } /* now go read the methods */ do { if (lineBuffer[0] == '|') /* get any left over text */ strcpy(textBuffer,&lineBuffer[1]); else textBuffer[0] = '\0'; while((eoftest = fgets(lineBuffer, LINEBUFFERSIZE, fd)) != NULL) { if ((lineBuffer[0] == '|') || (lineBuffer[0] == ']')) break; strcat(textBuffer, lineBuffer); } if (eoftest == NULL) { sysError("unexpected end of file","while reading method"); break; } /* now we have a method */ theMethod = newMethod(); pp.setLexer(Lexer(textBuffer)); if (pp.parseMessageHandler(theMethod, savetext)) { selector = theMethod->basicAt(messageInMethod); theMethod->basicAtPut(methodClassInMethod, classObj); theMethod->basicAtPut(protocolInMethod, protocol); if (printit) dspMethod(cp, selector->charPtr()); nameTableInsert(methTable, selector.hash(), selector, theMethod); } else { /* get rid of unwanted method */ givepause(); } } while (lineBuffer[0] != ']'); }
/* readClass reads a class method description */ static void readMethods(FILE *fd, boolean printit) { object classObj, methTable, theMethod, selector; # define LINEBUFFERSIZE 512 char *cp, *eoftest, lineBuffer[LINEBUFFERSIZE]; if (nextToken() != nameconst) sysError("missing name", "following Method keyword"); classObj = findClass(tokenString); setInstanceVariables(classObj); if (printit) cp = charPtr(basicAt(classObj, nameInClass)); /* now find or create a method table */ methTable = basicAt(classObj, methodsInClass); if (methTable == nilobj) /* must make */ { methTable = newDictionary(MethodTableSize); basicAtPut(classObj, methodsInClass, methTable); } /* now go read the methods */ do { if (lineBuffer[0] == '|') /* get any left over text */ strcpy(textBuffer, &lineBuffer[1]); else textBuffer[0] = '\0'; while ((eoftest = fgets(lineBuffer, LINEBUFFERSIZE, fd)) != NULL) { if ((lineBuffer[0] == '|') || (lineBuffer[0] == ']')) break; strcat(textBuffer, lineBuffer); } if (eoftest == NULL) { sysError("unexpected end of file", "while reading method"); break; } /* now we have a method */ theMethod = newMethod(); if (parse(theMethod, textBuffer, savetext)) { selector = basicAt(theMethod, messageInMethod); basicAtPut(theMethod, methodClassInMethod, classObj); if (printit) dspMethod(cp, charPtr(selector)); nameTableInsert(methTable, (int) selector, selector, theMethod); } else { /* get rid of unwanted method */ incr(theMethod); decr(theMethod); givepause(); } } while (lineBuffer[0] != ']'); }