Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DSDP - Real-Time Software Components (RTSC) » Is there handle up-casting in meta-domain?
Is there handle up-casting in meta-domain? [message #1629] Wed, 11 March 2009 20:10 Go to next message
Ramsey Harris is currently offline Ramsey Harris
Messages: 22
Registered: July 2009
Junior Member
Champs,

In the meta-domain, is there a notion of up-casting an object handle to its inherited interface?

For example, when creating a MessageQ instance, it requires an ISync.Handle. I have the following target code which up-casts the SyncSemThread handle.

/* create a synchronizer for the message queue */
obj->sync = SyncSemThread_create(NULL, eb);

/* create the message queue for inbound messages */
MessageQ_Params_init(&mqParams);
mqParams.synchronizer = SyncSemThread_Handle_upCast(obj->sync);
obj->msgQ = MessageQ_create(name, &mqParams, eb);

I'm wondering what the equivalent meta code would look like. Here is what I currently have (without any up-cast).

/* create a synchronizer for the message queue */
obj.sync = SyncSemThread.create();

/* create the message queue for inbound messages */
var MessageQParams = new MessageQ.Params();
MessageQParams.synchronizer = obj.sync;
obj.msgQ = MessageQ.create(name, MessageQParams);

Is this meta code correct, or do I need to do something else?

Thanks
~ Ramsey
Re: Is there handle up-casting in meta-domain? [message #1851 is a reply to message #1629] Mon, 16 March 2009 11:41 Go to previous message
Dave Russo is currently offline Dave Russo
Messages: 172
Registered: July 2009
Senior Member
Ramsey Harris wrote:
> Champs,
>
> In the meta-domain, is there a notion of up-casting an object handle to
> its inherited interface?
Yes. See http://rtsc.eclipse.org/docs-tip/XDCscript_-_Typed-Object.%2 4orig

>
> For example, when creating a MessageQ instance, it requires an
> ISync.Handle. I have the following target code which up-casts the
> SyncSemThread handle.
>
> /* create a synchronizer for the message queue */
> obj->sync = SyncSemThread_create(NULL, eb);
>
> /* create the message queue for inbound messages */
> MessageQ_Params_init(&mqParams);
> mqParams.synchronizer = SyncSemThread_Handle_upCast(obj->sync);
> obj->msgQ = MessageQ_create(name, &mqParams, eb);
>
> I'm wondering what the equivalent meta code would look like. Here is
> what I currently have (without any up-cast).
>
> /* create a synchronizer for the message queue */
> obj.sync = SyncSemThread.create();
>
> /* create the message queue for inbound messages */
> var MessageQParams = new MessageQ.Params();
> MessageQParams.synchronizer = obj.sync;
> obj.msgQ = MessageQ.create(name, MessageQParams);
>
> Is this meta code correct, or do I need to do something else?
If you don't get a type error when the code runs, it is correct (from an
up-cast point of view). If you get a type error you can cast typed objects.

For example, in the ti.targets package we cast xdc.bld.ITarget modules
to ti.target.ITarget modules as follows:
/* check type before casting, to avoid cast error */
if (mod instanceof this.ITarget.Module) {
/* cast so we can access extened methods */
var targ = this.ITarget.Module(mod);
:
}

>
> Thanks
> ~ Ramsey
Previous Topic:How to handle error in Module_startup()?
Next Topic:runtime initialization of statically created and constructed instances
Goto Forum:
  


Current Time: Tue Sep 02 02:50:43 EDT 2014

Powered by FUDForum. Page generated in 0.01617 seconds