.. wrote:
How do we marshall a type like this from a C++/CLI class wrapper to an
unmanaged method?
typedef struct
{
UINT32 blah : 1;
UINT32 blah2 : 1;
UINT32 blah3: 1;
UINT32 someValue : 12;
}SOMESTRUCT;
The C++ language doesn't really have the notion of an unmanaged method. A
method that is implemented in native code cannot access CLR types, but
otherwise that's it. The API can have CLR types or it can have native types.
Of course, ref classes do not allow bit fields (mostly because the
efficiency win is probably outweighed by the working set caused by the CLR).
Wrapping is about containing a native type though, not creating a replica of
it with a CLR type. That said, here's an example in the new C++ syntax.
// Native type with bitfield
struct X {
int a : 1;
int b : 2;
int c : 3;
};
// CLR type that wraps X
ref class W {
X * x;
public:
W(int a, int b, int c) {
x = new X;
x->a = a;
x->b = b;
x->c = c;
}
~W() {
delete x;
}
!W() {
delete x;
}
property X* MyX {
X* get() { return x; }
}
};
// Native API
void F(X* x) { /*...*/ }
// Managed API
void F(W^ w) {
F(w->MyX);
}
--
Brandon Bray, Visual C++ Compiler
http://blogs.msdn.com/branbray/
This posting is provided AS IS with no warranties, and confers no rights.