/* (Marcus G. Daniels) 02/17/2000 GO> How can you ask a superclass to be allocated through the GO> lispArchiver? By default, all the variables of the class and its superclasses are collected and saved. The +createBegin: of the class named by the argument of make-instance in the .scm file is the one that runs. When you have a class that requires some parameters to be create-time, then that class needs to have a lispInCreate: method so that these are set before -createEnd runs. If your Rectangle was a real GUI rectangle, then you'd probably want that. Here's an example (without the extra lispInCreate: method). */ #import // initSwarmBatch #import // CreateDrop #import // lispAppArchvier #import // OutputStream @interface Shape: CreateDrop { unsigned scale; int x, y; } + createBegin: aZone; - (void)describe: stream; @end @implementation Shape + createBegin: aZone { Shape *shape = [super createBegin: aZone]; shape->scale = 2; shape->x = 100; shape->y = 200; return shape; } - (void)describe: (id )stream { [stream catC: "+"]; [stream catInt: x]; [stream catC: "+"]; [stream catInt: y]; [stream catC: " *"]; [stream catUnsigned: scale]; } @end @interface Rect: Shape { unsigned width; unsigned height; } + createBegin: aZone; - (void)describe: (id )stream; @end @implementation Rect + createBegin: aZone { Rect *rectangle = [super createBegin: aZone]; rectangle->height = 10; rectangle->width = 20; return rectangle; } - (void)describe: (id )stream { [stream catC: "["]; [stream catC: [self getName]]; [stream catC: "] "]; [stream catUnsigned: width]; [stream catC: "x"]; [stream catUnsigned: height]; [super describe: stream]; [stream catC: "\n"]; } @end int main (int argc, const char **argv) { initSwarmBatch (argc, argv); { id rectangle; if ((rectangle = [lispAppArchiver getObject: "rectangle"])) xprint (rectangle); else { rectangle = [Rect create: globalZone]; [lispAppArchiver putDeep: "rectangle" object: rectangle]; [lispAppArchiver sync]; } } return 0; } /* Local Variables: compile-command: "$SWARMHOME/bin/libtool-swarm --mode=link gcc -DAPPNAME=archiveShape -o archiveShape -Wall -Werror -g -Wno-import -I$SWARMHOME/include/swarm -L$SWARMHOME/lib/swarm archiveShape.m -lswarm -lobjc" End: */