On 2019-04-14 20:01:27 +0000, diniz said:

Le 14/04/2019 à 20:03, Robert M. Münch via Digitalmars-d-learn a écrit :
struct IM;
struct C {
 IM *impl;
};

int cInit(C* self);

class I {
    C handler;

    this(){cInit(&handler);}
}

Is there a simple way that I can use handler without the address-of operator and automatically get *impl?

Something like:

class I {
    C handler;

    this(){cInit(handler);}
}

And later can use I in a way like this without having to define/write explicit casts everywhere?

someFunc(C* self);

I myI;
someFunc(myI);

Do you have a clear and correct view of what you want to express, of the application? How does it look (for us), if you replace IM, C, impl, cInit, I, handler, with meaningful (and correctly chosen) terms?

Well, ok... even it really doesn't matter a lot.

IM = Implementaiton Context (C-API)
C  = Core Context (C-API)
I  = Implementation D Class

The C side requires that *impl is the 1st member in the struct/class whereever it is stored. Hence, the wrapping in a struct and not directly putting it into a D class.

--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster

Reply via email to