Re: Using a delegate when interfacing with C

2014-07-06 Thread Marco Cosentino via Digitalmars-d-learn
Hey Adam, an interesting aspect of what I'd like to achieve is to use compile-time reflection to generate the wrapper functions for all the delegates (there are ~ 10). The pattern is like what I presented eariler and in addition to that there are some delegates which have no return type (void).

Re: Using a delegate when interfacing with C

2014-07-05 Thread Marco Cosentino via Digitalmars-d-learn
On Saturday, 5 July 2014 at 22:28:48 UTC, Adam D. Ruppe wrote: In general, remember any class reference in D is already equivalent to a pointer in C or C++ and can be casted straight to void* without needing to take its address. Thanks Adam, you're a life saver ;). It works like a charme.

Using a delegate when interfacing with C

2014-07-05 Thread Marco Cosentino via Digitalmars-d-learn
Hi, I'm quite new to D and I'm not able to find out what I'm doing wrong. Consider the following code: class ClientImplementation { private ProcessDelegate processDelegate; void setProcessDelegate(ProcessDelegate deleg) { this.processDelegate = deleg; extern(C) ProcessCallback

Re: Returning dynamic array from the function

2014-06-14 Thread Marco Cosentino via Digitalmars-d-learn
int[] data = [1,2,3,4];// create new array on the heap Thanks for the answer. This is the bit of information I was missing: how to create an array in the heap. Is also this a valid way to do so? int[] data = new int[0]; data ~= [4,2,3,1];

Re: Returning dynamic array from the function

2014-06-14 Thread Marco Cosentino via Digitalmars-d-learn
Hi, I'm new to D and stumbled upon this very interesting discussion. My question now is: can you provide an example of how to return a collection of homogeneous elements whose size is not known at compile time (for wich you would normally use a dynamic array) from a function? Thanks, Marco