| Is there handle up-casting in meta-domain? [message #1629] | 
Wed, 11 March 2009 20:10   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.36028 seconds