Thread overview
How to repeat structure C++
Jan 15, 2017
MGW
Jan 15, 2017
MGW
Jan 16, 2017
Adam D. Ruppe
Jan 16, 2017
MGW
January 15, 2017
Hi!

I write plugin for 1C:Enterprise 8.3 on dmd now.

https://youtu.be/apLppufZulI

I try to repeat structure C++ (interface) on dmd.
But D no inheritance of structures. What it is possible
to replace with the D following code on C ++struct IInterface {};

C++
-----
struct IMsgBox : public IInterface {
	virtual bool Confirm(const wchar* queryText, tVariant* retVal) = 0;
	virtual bool Alert(const wchar* text) = 0;
};

January 15, 2017
On Sunday, 15 January 2017 at 19:00:49 UTC, MGW wrote:
> Hi!

struct IInterface {};
struct IMsgBox : public IInterface {
	virtual bool Confirm(const wchar* queryText, tVariant* retVal) = 0;
	virtual bool Alert(const wchar* text) = 0;
};

January 16, 2017
On Sunday, 15 January 2017 at 19:05:06 UTC, MGW wrote:
> struct IInterface {};
> struct IMsgBox : public IInterface {
> 	virtual bool Confirm(const wchar* queryText, tVariant* retVal) = 0;
> 	virtual bool Alert(const wchar* text) = 0;
> };

That's just interfaces and classes in D, so change struct to those words and go fro there.
January 16, 2017
On Monday, 16 January 2017 at 00:07:44 UTC, Adam D. Ruppe wrote:
> That's just interfaces and classes in D, so change struct to those words and go fro there.

// ------- jd.d:  compile: dmd -c jd
import std.stdio;
extern (C++) interface IHome { int sum(int, int); };
extern (C++) void printIHome(void* ptr) {
	IHome  ob = cast(jd.IHome)ptr;
	ob.sum(4, 5);
}

// ------- jc.cpp  compile: dmc jc.cpp jd.obj phobos.lib
#include <stdio.h>

struct IHome {
	int sum(int a, int b) {
		int s = a+b; printf("a = %d, b = %d, sum = %d\n", a, b, s);
		return s;
	}
};

extern "C" int 		rt_init();
extern "C" int 		rt_term();

extern void 		printIHome(void*);

void main() {
	IHome iMyHome;
	rt_init();
	// -------
	iMyHome.sum(2, 3);   // Call C++ method in C++
	IHome* ptriMyHome = &iMyHome;
	printIHome(ptriMyHome);    // Call C++ method in D --> ERROR :-(
	// -------
	rt_term();
}
// ---- compile ------------------------------------------
dmd -c jd
dmc jc.cpp jd.obj r:\dmd2\windows\lib\phobos.lib

// -------------------------------------------------------
Please, help to rewrite jd.d for the correct method call in structure ะก++.