Re: Marshaling a byte array by ref
Paul Schauble <[email protected]> Thu, 13 Jul 2006 18:36:42 -0700
| Newsgroups | gmane.comp.windows.devel.jawin |
|---|---|
| Message-ID | <0165EECEBB4CF745ACF095E1176B03EA0738638E@SUNCA-EXB-AV1.ticketmaster.corp> |
But isn't VT_ARRAY|VT_UI1|VT_BYREF exactly what he wants?=20
Unlike in Java, by the way, the type library specifications of [in] and
[out] control whether then item is copied back to the caller. Not the
BYREF setting.
++PLS
-----Original Message-----
From: Discussion of Java/Win32/COM integration with Jawin
[mailto:[email protected]] On Behalf Of Morten Andersen
Sent: Thursday, July 13, 2006 11:24 AM
To: [email protected]
Subject: Re: [JAWIN] Marshaling a byte array by ref
Hi Al,
Ok. Then I think we have a problem. I looked into the native marshalling
in Transform.cpp, and for VT_BYREF combined with "simple" types, like
e.g. VT_UI1 we set the VARIANT reference (e.g. for VT_BYREF|VT_UI1:
*pbVal in the VARIANT-struct) to point to a *one-byte* allocated
reference.
This is the source from Transform.cpp which takes care of this (you can
see that we only SafeMalloc one byte:
byte* pbyte =3D (byte*)MarshalAllocator::SafeMalloc(sizeof(byte), =
m_pbr);
// set the value to the java-value (if any)
*pbyte =3D (byte)in.readByteOrDie();
// and finally write the pointer to the out stream
out.writeIntOrDie((int)pbyte);
So I am pretty sure that your request can only be satisfied by adding
support for this in both the CPP and Java-marshalling code. That would
also require some thought on what java-types should marshal into this.
E.g.
- a ByrefHolder(byte[])-instance is already used for marshalling to
VT_ARRAY|VT_UI1|VT_BYREF.
- a simple byte[]-instance is already used for marshalling to
VT_ARRAY|VT_UI1.
Unfortunately I don't have the equipment (I am mostly on Mac lately),
software tools (VC++) or time for working out such a change right now.
So to answer your originally question in short:
"Can JAWIN marshall a byte array by ref?"
We unfortunately only support to marshall to VARIANT SafeArray's, and
don't support plain-old-style C byte*-arrays. We only support these for
old-style DLL exported functions.
Sorry to disappoint you.
Best Regards
Morten