roxen.lists.pike.general

Subject Author Date
cmod inherit question Yvan Vander Sanden <yvan[at]youngmusic[dot]org> 03-11-2009
hi.

Something i'm confused about (again :-). I've made this class/structure:

PIKECLASS HostApiInfo {
    PIKEVAR int structVersion;
    PIKEVAR int type;
    PIKEVAR string name;
    PIKEVAR int deviceCount;
    PIKEVAR int defaultInputDevice;
    PIKEVAR int defaultOutputDevice;

    INIT{

    }

    EXIT{

    }
}

And want to use it in the next class:

PIKECLASS Control {
    INHERIT HostApiInfo;
    PIKEVAR HostApiInfo Info;

    PIKEFUN HostApiInfo get_host_api_info(int hostApi) {
        const PaHostApiInfo * info;
        info = Pa_GetHostApiInfo(hostApi);
        THIS->Info->structVersion = info->structVersion;
        [...]
        RETURN(THIS->Info);
    }

etc...

But it doesn't work that way. At least the HostApiInfo class was recognised
as a PIKEVAR, but when i use the structVersion function the compiler
complains:

    error: ‘struct object’ has no member named ‘structVersion’

I know, the structure is not initialized. But where and how to do that? I
tried something like

   THIS->Info = HostApiInfo();

But that didn't help. Probably I could get around it this time by using a
mapping instead of my own struct, but i'm gonna need the real thing sooner
or later anyway, and using a mapping for this is just not my idea of good
programming :-)

If anyone knows more about that, some hints would really help. Thanks!

yvan

-- 
Copyright only exists in the imagination of those who do not have any.