Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DSDP - Real-Time Software Components (RTSC) » Recipe for abstract instances
Recipe for abstract instances [message #722521] Mon, 05 September 2011 23:18 Go to previous message
Naoki Kawada is currently offline Naoki Kawada
Messages: 10
Registered: June 2010
Junior Member
Hi,

I would like to use abstract instance, just like xdc.runtime.Memory module.
As you know xdc.runtime.Memory module can use abstract instance inheriting IHeap interface. I would like to do same thing with my modules.

As for me, I have tried the following.
I have my.audio.decoder.Dec module which has a proxy for actual decoder instance and some actual decoder implementations in my.audio.decoder.impls package(e.g. .Mp3/.DecNull) inheriting my.audio.decoder.IDecProvider interface.

Each module looks below.
=== Dec.xdc ===
module Dec {
    config IDecProvider.Handle defaultInstance = null;

    UInt decode(IDecProvider.Handle hdl, Void *inBufp, Void *outBufp, ....);
    Void reset(IDecProvider.Handle hdl);
    ...
    ...

 internal:
    proxy DecProxy inherits IDecProvider;
}


== Dec.c ===
...

Void Dec_reset(IDecProvider_Handle hdl)
{
    Dec_DecProxy_reset(hdl);
}

...


=== IDecProvider.xdc ===
interface IDecProvider {
instance:
    create();
    UInt decode(Void *inBufp, Void *outBufp, ....);
    Void reset ();
    ...
    ...
}


=== Mp3.xdc ===
@InstanceInitError
@InstanceFinalize
module Mp3 inherits IDecProvider {
    ...
 instance:
    create();
    config UInt format;
    ...
 
 internal:
    struct Instance_State {
       ....
       ....
    };
}


=== DecNull.xdc ===
@InstanceInitError
@InstanceFinalize
module DecNull inherits IDecProvider {
    ...
 instance:
    create();
    ...
 
 internal:
    struct Instance_State {
       Uint dummy;
    };
}


During the configuration, Dec.DecProxy is bound to DecNull moudle in package.xs:
==== package.xs ====
function close()
{
    var Dec = this.Dec;
    if (Dec.$used) {
        if (Dec.defaultInstance == null) {
            var DecNull = xdc.useModule ("my.audio.decoder.impls.DecNull");
            var decNullParams = new DecNull.Params();
            Dec.defaultInstance = DecNull.create(decNullParams);
            print ("Dec proxy has been bound to DecNull");
        }
        Dec.DecProxy = Dec.defaultInstance.$module;
        Dec.DecProxy.abstractInstance$ = true;
}


In .cfg, common$.fxntab is being enabled explicitly.
==== .cfg =====
Defautls = xdc.useModule ("xdc.runtime.Defaults");
Defaults.common$.fxntab = true;


Now, I saw a runtime error (Exception abort) at the following code.
==== test.c =====
Mp3_Handle mp3Dec;
IDecProvider idec;

mp3Dec = Mp3_create (&my3Params, NULL);
idec = Mp3_Handle_upCast (mp3Dec);
if (idec != NULL) {
    Dec_reset (idec); <===== at this point, exception happened.
    ....
}


According to my debug, exception itself was caused by the reference to NULL pointer.

Please note, idec itself is not NULL, but idec contents looks incorrect with my scheme... Could you show me the recipe/suggestions for abstract instance ?






[Updated on: Tue, 06 September 2011 21:50]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:ARM cortex a8 and cortex A15 support
Next Topic:Math functions for c28_float target
Goto Forum:
  


Current Time: Sat May 25 23:03:29 EDT 2013

Powered by FUDForum. Page generated in 0.01586 seconds