Hi Esteban,
not sure I'm understanding your snippet correctly.
Below is my try. It throws a SubscriptOutOfBounds exception in the last
line. The reason is that the implementation of ByteArray
replaceFrom:to:with:startingAt: does not consider that ea is meant to be
a pointer to a C byte array, not an object whose content is to be copied
directly.
| ea ba |
ea := ExternalAddress gcallocate: 200.
ba := ByteArray new: 100.
ba replaceFrom: 1 to: 50 with: ea startingAt: 51.
Am I missing some point?
On 2017-02-21 17:20, Esteban Lorenzano wrote:
usually, something more or less like this:
sourceByteArrayOrExternalAddress := … some ...
destEnternalAddressOrByteArray
replaceFrom: 1
to: sourceByteArrayOrExternalAddress size
with: sourceByteArrayOrExternalAddress
startingAt: 1
and or course you can play with the starting points and sizes.
cheers,
Esteban
On 21 Feb 2017, at 17:13, Raffaello Giulietti <raffaello.giulie...@lifeware.ch>
wrote:
Hi,
I'm having a hard time finding documentation on how to copy a portion of a
ByteArray to/from another portion of a heap allocated C byte array with UFFI.
My current reference is
https://ci.inria.fr/pharo-contribution/view/Books/job/PharoBookWorkInProgress/lastSuccessfulBuild/artifact/book-result/UnifiedFFI/UnifiedFFI.pdf
Thanks for directing me at relevant docs or examples and sorry in advance if I
missed some important point in the docs.
RG