Skip to main content



      Home
Home » Archived » 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
Eclipse UserFriend
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
Eclipse UserFriend
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: Thu May 08 09:07:22 EDT 2025

Powered by FUDForum. Page generated in 0.03096 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top