Marcus Daniels, email swarm-support DEc. 31, 2000
PJ> 3. I understand from Marcus's example code the procedure to
create
PJ> an instance of an objc class that requries the
PJ> createBegin/createEnd routine.  I can manage that.  I can't
PJ> understand how to create subclasses of such things, however.  

Here's an example.  It does need the current snapshots, but that
is because of this particular example, not because of subclassing itself.


import swarm.Globals;
import swarm.SwarmEnvironmentC;
import swarm.SwarmEnvironmentCImpl;
import swarm.SwarmEnvironmentImpl;
import swarm.defobj.Arguments;
import swarm.defobj.ArgumentsC;
import swarm.defobj.ArgumentsCImpl;
import swarm.defobj.ArgumentsImpl;
import swarm.defobj.Zone;

class MyArgumentsCImpl extends ArgumentsCImpl {
  MyArgumentsCImpl (Arguments arg) {
    super (arg);
  }
  
  public Object setArgc$Argv (int argc, String argv[]) {
    return super.setArgc$Argv (argc, argv);
  }
 
  public int parseKey$arg (int key, String arg) {
    if (super.parseKey$arg (key, arg) != 0) {
      if (key == (int) 'M') {
        ((MyArgumentsImpl) nextPhase).arg = arg;
      }
    }  
    return 0;
  }
}

class MyArgumentsImpl extends ArgumentsImpl {
  String arg;

  MyArgumentsImpl () {
    super ();
  }
}


public class TestArguments {
  static void main (String args[]) {
    Zone aZone = Globals.env.globalZone;
    
    ArgumentsC argumentsC = new MyArgumentsCImpl (new MyArgumentsImpl ());
    MyArgumentsImpl arguments;

    int i, len = args.length;
    String argv[] = new String[1 + len];

    argv[0] = "TestArguments";

    for (i = 0; i < len; i++)
      argv[1 + i] = args[i];

    argumentsC.createBegin (aZone);
    argumentsC.setAppName (argv[0]);
    argumentsC.setArgc$Argv (len + 1, argv);
    argumentsC.setAppModeString ("default");
    argumentsC.setBugAddress ("bug-swarm@swarm.org");
    argumentsC.setVersion ("0.0");
      
    argumentsC.addOption$key$arg$flags$doc$group ("myarg", (int) 'M', "argvalue", 0, "My
Argument", 0);
    arguments = (MyArgumentsImpl) argumentsC.createEnd ();

    Globals.envC.setArguments (arguments);
    Globals.envC.createEnd ();
    
    System.out.println (arguments.arg);
  }
}



