Re: Marshaling a byte array by ref

Roger I Martin PhD <[email protected]> Thu, 13 Jul 2006 14:49:28 -0400
Newsgroups gmane.comp.windows.devel.jawin
Message-ID <[email protected]>
Hi Morten!

Are you still readily setup to zip and put a release online? Then the
auto gc will be available without cvs.

Then, I would like the cvs HEAD to be a playground for the next couple
of months (i.e. possibly some breakages while the HEAD gets some changes)

There will be some new stylesheets and I also decided to make some
transition stylesheets that use new features as they become available
but falls back on the old marshaling when necessary.

Best regards,

Roger

Morten Andersen wrote:
> 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 = (byte*)MarshalAllocator::SafeMalloc(sizeof(byte), m_pbr);
> // set the value to the java-value (if any)
> *pbyte = (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
>