swarm-support
[Top][All Lists]
Advanced

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

Re: seg-faults on the road


From: Marcus G. Daniels
Subject: Re: seg-faults on the road
Date: 19 Dec 2001 11:08:09 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.7

>>>>> "DK" == daniel kottow <address@hidden> writes:

DK> what xpcshell is about, but that fails for me because of an
DK> unresolved symbol.

xpcshell is the JavaScript command shell.  Mozilla and xpcshell use
the SpiderMonkey JavaScript engine (written in C) which is integrated
with XPCOM, via complex software called XPConnect.  I don't know about
Rhino & XPCOM, but I suspect it won't work as the Java support in
Mozilla isn't integrated in this kind of tight way, and the XPCOM/Java
support that exists never seemed to work very well (last time I tried
Java/XPCOM stuff was in June or so).

DK> maybe you could provide an explicit "hello swarm" snippet which i
DK> can try from rhino ?

In the attached code, note the output of "Hello World" is done using
Swarm's verboseMessage method on SwarmEnvironment, which only prints
when in verbose mode.  Verbose mode is set in this case by setting the
"-v" option (which would typically by on a command line).  The
preceding "2" says that the array that follows is two items long.
env.guiFlag will print as false (by default true), because the "-b"
option is passed.

DK> what i still dont understand is how to call swarm's create method
DK> on such an object.  create is part of the swarmISelector
DK> interface, but this interface doesnt seem supported by the swarm
DK> components like the cls from the example above.

Continuing in the code, following `verboseMessage' is an example.  The
thing with COM is that you have to remember that +create: is typically
an inherited method.  To get it, here I query for the swarmICreate
interface.  Then I call the create method.  However, the Create
protocol just has the basic creation methods.  To send other messages
means first requesting the right interface.  In this case, I ask for
the GetName interface and then send it the getName method.  (See what
happens if you comment out the QueryInterface line.)

I believe there are some new `flattening' support code and conventions
for creating interfaces & implementations & modules for XPCOM such
that it isn't necessary to ask for the (very) specific interface that
has the method you want.  The new system, as I understand it, acts
like Objective C protocols or Java interfaces.  I haven't investigated
that yet.  I remember discussion about a similar system in the Python
front end, as well.  `Flattened' interfaces would certainly be easier
to use, but meanwhile QueryInterface is doable once you get used to it.

env = Components.classes["urn:swarm:SwarmEnvironmentImpl"]. 
        createInstance (Components.interfaces.swarmISwarmEnvironment);

env.initSwarm_version_bugAddress_argCount_args ("hello world", "0.0",
                                                "address@hidden",
                                                2, ["-v", "-b"]);

env.verboseMessage ("Hello World " + env.guiFlag);

obj = Components.classes["urn:swarm:objectbase.SwarmObjectImpl"].createInstance 
(Components.interfaces.swarmICreate);
obj.create (env.globalZone);
env.xprint (obj);

obj = obj.QueryInterface (Components.interfaces.swarmIGetName);
env.verboseMessage (obj.getName ());


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