Recipe for abstract instances [message #722521] |
Tue, 06 September 2011 03:18 |
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: Wed, 07 September 2011 01:50] Report message to a moderator
|
|
|
|
Re: Recipe for abstract instances [message #722862 is a reply to message #722839] |
Wed, 07 September 2011 01:40 |
Naoki Kawada Messages: 10 Registered: June 2010 |
Junior Member |
|
|
Hello Sasha,
Thank you for your help !
That was just my typo... I have fixed it at my original message.
Now my code looks like this, but the problem is still there.
Do you have any other suspicions about the issue ?
Any suggestions will be helpful for me.
Please note I'm using xdctools v3.22.01.21
Best Regards,
Kawada
[Updated on: Wed, 07 September 2011 01:45] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03326 seconds