[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: compiled and registered swarm XPCOM - could i have a crash course ?
From: |
Marcus G. Daniels |
Subject: |
Re: compiled and registered swarm XPCOM - could i have a crash course ? |
Date: |
18 Dec 2001 09:36:40 -0700 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.7 |
>>>>> "DK" == daniel kottow <address@hidden> writes:
DK> here actually comes my first question, what are the suffixes C and
DK> S for swarm interfaces about ? for many objects i see:
DK> swarmISwarmObject, swarmISwarmObjectC, swarmISwarmObjectS.
It's the same convention as in Java, explained here:
http://www.santafe.edu/projects/swarm/archive/list-archive.0112/0036.html
Unfortunately, I need to work on something else right now [about ready
to take the phone off the hook!], and so I can't make a Python test
case, but the steps for instantiating an object are:
1) look up the contract ID by its URN. That has the form
urn:swarm:MODULE:CLASSImpl, e.g. urn:swarm:space:Grid2dImpl
2) Call createInstance with the interface you want, e.g. swarmIGrid2d
3) Call the Swarm create method, passing the Zone (globalZone can be
aquired via urn:swarm:SwarmEnvironmentImpl (which also needs to
be instantiated)
4) Call QueryInterface to get the specific interface you want from your
object in #2.
[I haven't checked to confirm, but my understanding is that XPCOM now has
a `interface flattening' feature that means that it isn't necessary
to do QueryInterface to get specific interfaces.]
There is a more complex form of this that involves phase switching
(the "C" interfaces), along the lines of the URL above.
In JavaScript, I found it was pretty easy to hide object creation
complexity by adding a few functions, like these:
function createComponentUsing (typeName, iid, constructorName, retiid)
{
var moduleName = env.typeModule (typeName);
var modulePrefix = moduleName.length == 0 ? "" : moduleName + ".";
var contractid = "urn:swarm:" + modulePrefix + typeName + "Impl";
var obj = Components.classes[contractid].createInstance (iid);
var arglist = new Array ();
if (constructorName == null)
constructorName = "create";
for (var i = 4; i < arguments.length; i++)
arglist[i - 4 + 1] = arguments[i];
arglist[0] = env.globalZone;
obj[constructorName].apply (obj, arglist);
obj = obj.QueryInterface (retiid != null
? retiid
: Components.interfaces["swarmI" + typeName]);
return obj;
}
function createComponent (typeName)
{
return createComponentUsing (typeName,
Components.interfaces.swarmICreate,
"create", null);
}
Then, building on them to make convenience functions like this:
function createRepeatingSchedule (interval)
{
return createComponentUsing ("Schedule",
Components.interfaces.swarmISchedule,
"create_setRepeatInterval",
Components.interfaces.swarmISchedule,
interval);
}
==================================
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.
- scripting support for swarm ?, daniel kottow, 2001/12/11
- RE: scripting support for swarm ?, J. McKenzie Alexander, 2001/12/11
- Re: scripting support for swarm ?, Marcus G. Daniels, 2001/12/11
- Re: scripting support for swarm ?, daniel kottow, 2001/12/12
- Re: scripting support for swarm ?, Marcus G. Daniels, 2001/12/12
- Re: scripting support for swarm ?, Marcus G. Daniels, 2001/12/12
- starting to try out XPCOM, daniel kottow, 2001/12/17
- Re: starting to try out XPCOM, Marcus G. Daniels, 2001/12/17
- compiled and registered swarm XPCOM - could i have a crash course ?, daniel kottow, 2001/12/18
- Re: compiled and registered swarm XPCOM - could i have a crash course ?,
Marcus G. Daniels <=
- now *only* missing a symbol, daniel kottow, 2001/12/18
- Re: now *only* missing a symbol, Marcus G. Daniels, 2001/12/18
- Re: now *only* missing a symbol, Marcus G. Daniels, 2001/12/18
- seg-faults on the road, daniel kottow, 2001/12/19
- Re: seg-faults on the road, Marcus G. Daniels, 2001/12/19
- Re: seg-faults on the road, daniel kottow, 2001/12/19
- Re: seg-faults on the road, Marcus G. Daniels, 2001/12/19
- its getting better, daniel kottow, 2001/12/19
- Re: its getting better, Marcus G. Daniels, 2001/12/19
- limits, daniel kottow, 2001/12/19