D - How to set the calling convention of nested functions ... ???
- Matthew Wilson (40/40) Oct 10 2003 I vaguely recall something about this before, and being told that it was...
- Matthew Wilson (39/79) Oct 10 2003 Hmmm, that didn't format nicely, did it?
I vaguely recall something about this before, and being told that it was not
necessary to be able to set the calling convention of nested functions.
However,
I have a C function that looks like
typedef int (*hrecls_process_fn_t)(recls_info_t info,
recls_process_fn_param_t param);
private recls_rc_t Recls_SearchProcess( char
*searchRoot
, char
*pattern
, recls_uint32_t flags
, hrecls_process_fn_t pfn
, recls_process_fn_param_t
param);
Since pfn is a C ptr-to-func, I can't stick a D delegate in there, so I've
written a translation like
public recls_rc_t Search_Process( in char[]
searchRoot
, in char[]
pattern
, in int
flags
, int delegate(in Entry entry,
recls_process_fn_param_t param) dg
, recls_process_fn_param_t
param)
{
/* extern(Windows) */ int process_fn(recls_info_t entry,
recls_process_fn_param_t p)
{
return dg(Entry._make_Entry(entry), p);
}
return Recls_SearchProcess(searchRoot, pattern, flags, process_fn,
param);
}
Sadly, I cannot declare the nested function process_fn() to be __stdcall. If
I do not do so, it doesn't match.
The only fix I can think of is to take it outside Search_Process(), which
chews.
Is there an alternative?
Oct 10 2003
Hmmm, that didn't format nicely, did it?
Trying again:
I have a C function that looks like
typedef int (*hrecls_process_fn_t)(recls_info_t info,
recls_process_fn_param_t param);
private recls_rc_t Recls_SearchProcess(
char *searchRoot
, char *pattern
, recls_uint32_t flags
, hrecls_process_fn_t pfn
, recls_process_fn_param_t param);
Since pfn is a C ptr-to-func, I can't stick a D delegate in there, so I've
written a translation like
public recls_rc_t Search_Process(
in char[] searchRoot
, in char[] pattern
, in int flags
, int delegate(in Entry entry,
recls_process_fn_param_t param) dg
, recls_process_fn_param_t param)
{
/* extern(Windows) */ int process_fn(recls_info_t entry
, recls_process_fn_param_t p)
{
return dg(Entry._make_Entry(entry), p);
}
return Recls_SearchProcess(searchRoot, pattern
, flags, process_fn, param);
}
Sadly, I cannot declare the nested function process_fn() to be __stdcall. If
I do not do so, it doesn't match.
The only fix I can think of is to take it outside Search_Process(), which
chews.
Is there an alternative?
"Matthew Wilson" <matthew stlsoft.org> wrote in message
news:bm87cq$2urb$1 digitaldaemon.com...
I vaguely recall something about this before, and being told that it was
not
necessary to be able to set the calling convention of nested functions.
However,
I have a C function that looks like
typedef int (*hrecls_process_fn_t)(recls_info_t info,
recls_process_fn_param_t param);
private recls_rc_t Recls_SearchProcess( char
*searchRoot
, char
*pattern
, recls_uint32_t flags
, hrecls_process_fn_t
pfn
, recls_process_fn_param_t
param);
Since pfn is a C ptr-to-func, I can't stick a D delegate in there, so I've
written a translation like
public recls_rc_t Search_Process( in char[]
searchRoot
, in char[]
pattern
, in int
flags
, int delegate(in Entry entry,
recls_process_fn_param_t param) dg
, recls_process_fn_param_t
param)
{
/* extern(Windows) */ int process_fn(recls_info_t entry,
recls_process_fn_param_t p)
{
return dg(Entry._make_Entry(entry), p);
}
return Recls_SearchProcess(searchRoot, pattern, flags, process_fn,
param);
}
Sadly, I cannot declare the nested function process_fn() to be __stdcall.
If
I do not do so, it doesn't match.
The only fix I can think of is to take it outside Search_Process(), which
chews.
Is there an alternative?
Oct 10 2003








"Matthew Wilson" <matthew stlsoft.org>