swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BOOL type in lisp SCM files.


From: Marcus G. Daniels
Subject: Re: BOOL type in lisp SCM files.
Date: 16 Feb 2000 10:20:25 -0800
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "GO" == Gadi ORON <address@hidden> writes:

GO> How do you specify values of BOOL type in the archiver SCM files?
GO> Tryed many things but I always get random results and errors ...

This will work in the snapshots, but there is a hitch:  Objective C
doesn't specifically encode a type for booleans; they are unsigned chars.
So the `fix' was to disable unsigned chars and make them booleans.
In Java, the boolean encoding is precise.

Also, another new feature is used in the example below.  In 2.0.1 and
before, it was necessary to have put{Shallow,Deep}:object: calls coordinated
by an updateArchiver: method.  That is no longer necessary for either
Archiver.  Now put{Shallow,Deep}:object: can be considered immediate.
In the HDF5 case, the object will be saved right then, and in the Lisp
case the object will be saved to an in-memory serialized snapshot (which
is finally written by the call to `sync').

#import <simtools.h> // initSwarmBatch
#import <defobj/Create.h> // CreateDrop

@interface Agent: CreateDrop
{
  BOOL activeFlag;
}
- (BOOL)getActiveFlag;
@end

@implementation Agent
+ createBegin: aZone
{
  Agent *obj = [super createBegin: aZone];
  obj->activeFlag = YES;
  return obj;
}

- (BOOL)getActiveFlag
{
  return activeFlag;
}
@end

int
main (int argc, const char **argv)
{
  initSwarmBatch (argc, argv);

  {
    id agent;
    
    if ((agent = [lispAppArchiver getObject: "agent"]))
      printf ("activeFlag: %s\n", [agent getActiveFlag] ? "yes" : "no");
    else
      {
        agent = [Agent create: globalZone];
        
        [lispAppArchiver putDeep: "agent" object: agent];
        [lispAppArchiver sync];
      }
  }
  return 0;
}

/*
Local Variables:
compile-command: "$SWARMHOME/bin/libtool-swarm --mode=link gcc 
-DAPPNAME=archiveBoolean -o archiveBoolean -Wall -Werror -g -Wno-import 
-I$SWARMHOME/include/swarm -L$SWARMHOME/lib/swarm archiveBoolean.m -lswarm 
-lobjc"
End:
*/

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]