Re: WeakRefs for a CPP->D wrapper

2014-01-13 Thread MGW
Hi yes I think noticed in another thread that you were wrapping Qt with dynamic loading of the qt libs, interesting idea - does your code allow subclassing of the Qt classes and overriding the virtual methods? I'm taking a much more traditional approach, but there is method in my madness :-)

Re: WeakRefs for a CPP->D wrapper

2014-01-12 Thread Abdulhaq
On Sunday, 12 January 2014 at 16:17:23 UTC, MGW wrote: Maybe this will be useful in the work: Compile Windows: dmd st1.d Linux: dmd st1.d -L-ldl // --- // MGW 05.01.14 // Model in D a C++ object QByteArray of Qt. //--

Re: WeakRefs for a CPP->D wrapper

2014-01-12 Thread MGW
Maybe this will be useful in the work: Compile Windows: dmd st1.d Linux: dmd st1.d -L-ldl // --- // MGW 05.01.14 // Model in D a C++ object QByteArray of Qt. // import core.runtime; // Load DLL for Wi

Re: WeakRefs for a CPP->D wrapper

2014-01-12 Thread Abdulhaq
On Sunday, 12 January 2014 at 12:12:53 UTC, Tobias Pankrath wrote: On Sunday, 12 January 2014 at 10:48:15 UTC, Abdulhaq wrote: No, try this: import std.stdio; class X {} void foo(X x) { writeln(cast(void*) x); } void main() { X x; // null reference by default. writeln(cast(void*)

Re: WeakRefs for a CPP->D wrapper

2014-01-12 Thread Tobias Pankrath
On Sunday, 12 January 2014 at 10:48:15 UTC, Abdulhaq wrote: No, try this: import std.stdio; class X {} void foo(X x) { writeln(cast(void*) x); } void main() { X x; // null reference by default. writeln(cast(void*) x); foo(x); x = new X; writeln(cast(void

Re: WeakRefs for a CPP->D wrapper

2014-01-12 Thread Abdulhaq
On Sunday, 12 January 2014 at 10:48:15 UTC, Abdulhaq wrote: No, try this: import std.stdio; class X {} void foo(X x) { writeln(cast(void*) x); } void main() { X x; // null reference by default. writeln(cast(void*) x); foo(x); x = new X; writeln(cast(void

Re: WeakRefs for a CPP->D wrapper

2014-01-12 Thread Abdulhaq
No, try this: import std.stdio; class X {} void foo(X x) { writeln(cast(void*) x); } void main() { X x; // null reference by default. writeln(cast(void*) x); foo(x); x = new X; writeln(cast(void*) x); foo(x); } Thanks Tobias that indeed wo

Re: WeakRefs for a CPP->D wrapper

2014-01-11 Thread Tobias Pankrath
On Saturday, 11 January 2014 at 20:38:33 UTC, Abdulhaq wrote: On Saturday, 11 January 2014 at 20:17:14 UTC, Tobias Pankrath wrote: class X {}; X x; x is an reference to an instance of X, with other words a pointer without arithmetic but with syntax sugar. &x will take the address of this poi

Re: WeakRefs for a CPP->D wrapper

2014-01-11 Thread Abdulhaq
On Saturday, 11 January 2014 at 20:17:14 UTC, Tobias Pankrath wrote: class X {}; X x; x is an reference to an instance of X, with other words a pointer without arithmetic but with syntax sugar. &x will take the address of this pointer/reference. If you want the address of the actual instance

Re: WeakRefs for a CPP->D wrapper

2014-01-11 Thread Tobias Pankrath
Object[void*] wrappingRegistry; but of course that prevents the wrapped objects from being garbage collected - I need weak ref semantics. I had a go at making it e.g. ulong[ulong] and storing the cast(ulong) address of the D object, but it seems that I don't understand what taking the addres