Creating ByteArrays in C primitives

Lendvai Attila Attila.Lendvai at netvisor.hu
Mon Oct 18 01:47:18 PDT 2004


hi!

I've got a pidgin function:

oh@(ObjectHeap pointer) newByteArrayFrom: buffer sized: bytes
"Creates a new slate ByteArray object and initializes from the given
buffer."
[| result!(ByteArray pointer) buffer!(Byte pointer) |
  result: (oh newByteArray: ByteArrayProto sized: bytes)!(ByteArray
pointer) cast.
  buffer copyBytes: bytes into: (result elements)!(Byte pointer).
  result
]!(ByteArray pointer) inline export.

that turns into:

static struct ByteArray * PSObjectHeap_newByteArrayFrom_sized_(struct
ObjectHeap * oh, Byte * buffer, unsigned long int bytes);

and creates a Slate ByteArray object.

Be warned: In the VM code and in the pidgin doc "ByteArray" is used for
two things: one is a raw array of bytes in the memory, and one is a
full-featured Slate ByteArray object. This method created the Slate
object ByteArray.

water, novo, may I check it in?

- 101




More information about the Slate mailing list