swarm-support
[Top][All Lists]
Advanced

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

Re: java method signature for eventOccurredOn


From: Marcus G. Daniels
Subject: Re: java method signature for eventOccurredOn
Date: 10 May 2000 20:57:34 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "SB" == Steve Brophy <address@hidden> writes:

SB> I'm missing something on how to make my java function result in a
SB> JavaProxy which gives an override match with the objective c
SB> method

Ok, I've majorly worked over the way that selectors are managed so
that this will work.  It's not perfect yet, but it's enough so
that you can it to work if you really want to.

   ftp://ftp.swarm.org/pub/swarm/binaries/w32/2.1.1-fixes
   ftp://ftp.swarm.org/pub/swarm/src/testing/swarm-2000-05-10.tar.gz

Below is an example I adapted from yours.  The main remaining problem
that is that the Selector needs to be registered ahead of time.  See
the try/catch clause.  The respondsTo that follows (an arbitrary call
into Objective C) is what ends up registering the selector in the
multilanguage interface.

import swarm.Globals;
import swarm.simtoolsgui.GUISwarmImpl;
import swarm.Selector;
import swarm.defobj.Zone;

// class Node extends SwarmObjectImpl
// (in fuller program, could also extend from SwarmObjectImpl
// to see the other error message, but doesn't run in this
// smaller example)
import swarm.objectbase.EmptyProbeMapImpl;
import swarm.objectbase.ProbeMap;
import swarm.objectbase.SwarmObjectImpl;
import swarm.objectbase.VarProbe;
import swarm.objectbase.VarProbeImpl;

class Node {
    public int var1;
    public Node() {
        // super(Globals.env.globalZone);
        ProbeMap pmap = new EmptyProbeMapImpl(
                                Globals.env.globalZone, getClass());
        VarProbe vprobe =
                Globals.env.probeLibrary.getProbeForVariable$inClass(
                                "var1", getClass());
        ((VarProbeImpl) vprobe).setObjectToNotify(this);
        pmap.addProbe(vprobe);
        Globals.env.probeLibrary.setProbeMap$For(pmap, getClass());
    }

    public void eventOccurredOn$via$withProbeType$on$ofType$withData (
                Object anObject,
                VarProbe aProbe,
                String aProbeType,
                String probedElement,
                char datatype,
                int data) {
        System.out.println("Event occurred type: " + aProbeType + " element: " 
+ probedElement + " datatype: " + datatype);
    }
}

public class ProbeNotify extends GUISwarmImpl {
  ProbeNotify (Zone aZone) {
    super (aZone);

    try {
      Selector sel = new Selector
        (Node.class,
         "eventOccurredOn:via:withProbeType:on:ofType:withData:",
         true);
      respondsTo (sel);
    } catch (Exception e) {
      e.printStackTrace (System.err);
      System.exit (1);
    }
    Node node = new Node();
    Globals.env.probeDisplayManager.createProbeDisplayFor(node);
    Globals.env.probeDisplayManager.update();
  }
  
  static public void main (String[] args) {
    Globals.env.initSwarm ("ProbeNotify", "0.0", "smb", args);
    
    ProbeNotify probeNotify = new ProbeNotify (Globals.env.globalZone);
    probeNotify.buildObjects ();
    probeNotify.buildActions ();
    probeNotify.activateIn (null);
    probeNotify.go ();
  }
}

                  ==================================
   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]