D
DebGuria
We are writing a wrapper in Managed C++. Wrapper is based on a C dll.
That wrapper will be used from .Net based application and VB also.
Our initial understanding that a .NET Application developer will pass
a delegate to the Managed C++ wrapper and in this wrapper, we have to
cast the delegate into function pointer. The argument list of that
function pointer is not compatible in .NET.
A .NET developer will pass a delegate to get the desired output. Is
their any other way?
..Please guide, how we will write wrapper for the following C Code?
SetProgressProc(void * userdata, ProgressProc callback);
// message callback proc
typedef void __stdcall MessageProc(
const void * context, // IN: message proc context
MyString & text, // OUT: message text
int & number); // OUT: message number
// progress callback proc
typedef bool __stdcall ProgressProc( // RETURN: cancel operation?
double progress, // IN: fractional progress (0.0 .. 1.0)
const void * userdata, // IN: progress callback userdata
const void * context, // IN: message proc context
MessageProc * message, // IN: message proc; else 0
unsigned int step, // IN: global step number (1 .. count)
unsigned int count); // IN: global step count
struct MyString
{
enum Type // encoding type
{
Type_ASCII = 1, // local encoding (8-bit)
Type_UTF8 = 2, // Unicode (8-bit)
Type_Wide = 3, // Unicode (wchar_t)
};
Type type; // encoding type
size_t size; // size of string data buffer in characters
void * data; // pointer to string data buffer
};
That wrapper will be used from .Net based application and VB also.
Our initial understanding that a .NET Application developer will pass
a delegate to the Managed C++ wrapper and in this wrapper, we have to
cast the delegate into function pointer. The argument list of that
function pointer is not compatible in .NET.
A .NET developer will pass a delegate to get the desired output. Is
their any other way?
..Please guide, how we will write wrapper for the following C Code?
SetProgressProc(void * userdata, ProgressProc callback);
// message callback proc
typedef void __stdcall MessageProc(
const void * context, // IN: message proc context
MyString & text, // OUT: message text
int & number); // OUT: message number
// progress callback proc
typedef bool __stdcall ProgressProc( // RETURN: cancel operation?
double progress, // IN: fractional progress (0.0 .. 1.0)
const void * userdata, // IN: progress callback userdata
const void * context, // IN: message proc context
MessageProc * message, // IN: message proc; else 0
unsigned int step, // IN: global step number (1 .. count)
unsigned int count); // IN: global step count
struct MyString
{
enum Type // encoding type
{
Type_ASCII = 1, // local encoding (8-bit)
Type_UTF8 = 2, // Unicode (8-bit)
Type_Wide = 3, // Unicode (wchar_t)
};
Type type; // encoding type
size_t size; // size of string data buffer in characters
void * data; // pointer to string data buffer
};