Custom calling conventions

Manu turkeyman at
Tue Feb 21 04:29:29 PST 2012

On 21 February 2012 14:13, Daniel Murphy <yebblies at> wrote:

> Why can't you do that with existing language features?
> alias JniExternFunc!(void function(int)) someJNIFuncYouWantToCallFromD;
> mixin JniExportFunc!(&dFuncYouWantToCallUsingJNI);
> Where the templates generate the wrapper code/calling convention arg
> shuffle
> for each function.

You could, but that's really ugly. I did make the point in my OP that it
can be hacked right now, but I also listed the benefits of making it a
proper feature:
 1. It would be very neat and tidy. Clarity and readability is important
for code longevity.
 2. Ease of refactoring/delegation to scripts without refactoring all the
calling code throughout your app (this is real, I have done this on many
 3. Declaring functions in the regular way, and annotating them with
various properties (const/pure/etc) allows all the usual type safety and
optimisation potentials available to the language.
     As far as the compiler is concerned, it is a real and normal function
call. All surrounding code gen/optimisations are still applicable, the
language will simply substitute the marshalling function at the final step
of the call.
 4-ish. It actually seems relatively simple to implement... and it's not a
breaking change. I can't really see any down sides.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Digitalmars-d mailing list