On Friday, 8 June 2018 at 00:55:35 UTC, cc wrote:
I've defined it in D, as per
https://dlang.org/spec/cpp_interface.html#classes :
change this to class, or even abstract class as shown in example
extern(C++) {
interface CCallbackBase {
//this() { m_nCallbackFlags = 0; m_iCallback = 0; }
void Run( void *pvParam );
void Run( void *pvParam, bool bIOFailure, SteamAPICall_t
hSteamAPICall );
int GetICallback();
int GetCallbackSizeBytes();
enum { k_ECallbackFlagsRegistered = 0x01,
k_ECallbackFlagsGameServer = 0x02 }
//uint8 m_nCallbackFlags;
//int m_iCallback;
//friend class CCallbackMgr;
//CCallbackBase( const CCallbackBase& );
//CCallbackBase& operator=( const CCallbackBase& );
}
}
add extern(C++) to class as well to
class CImpl : CCallbackBase {
extern(C++) {
this() { m_nCallbackFlags = 0; m_iCallback = 0; }
void Run( void *pvParam ) { writeln("Run1"); }
void Run( void *pvParam, bool bIOFailure, SteamAPICall_t
hSteamAPICall ) { writeln("Run2"); }
int GetICallback() { return m_iCallback; }
int GetCallbackSizeBytes() { return
NumberOfCurrentPlayers_t.sizeof; } // ordinarily use templates
to determine what type struct ptr to return
}
uint8 m_nCallbackFlags;
int m_iCallback;
}
you also may or may not need to mark non-virtual C++ methods as
final.
Of course I haven't used D for quite some time so I can be
mistaken.
But the lesson I learned the hard way is that in D for
extern(C++) you don't use interface(it simply has no mapping to
C++ types?), and for defining COM-interfaces use interface or it
will bite you.
I hope it helps.