Dan Sugalski wrote:

At 10:17 AM +0100 12/24/03, Leopold Toetsch wrote:
the UnManagedStruct PMC has an interface to deal with almost arbitrary
structures and arrays of types.


Using the source is only helpful when the docs are sufficient to actually *find* the thing you're thinking of doing, which turns out not to be the case here. (And unfortunately libpcre.imc doesn't do what I need it to either, so either I'm missing something or I've got to deal with this anyway)

Sorry, yes. It was one of the interim hacks w/o any priority. I asked, how the struct interface should work, got warnocked IIRC.


Anyway, I found one comment in unmanagedstruct.pmc stating that the initializer should be an array of triples. Going on from that now we have currently:

Be "init" an array PMC and "i" the i-th structure element:

  init[0 + i] ... datatype
e.g.
  .include "datatypes.pasm"
    init[0] = .DATATYPE_INT

  init[1 + i] ... possible array count 0 means 1 element
  init[2 + i] ... offset of struct item in bytes - 0 if to use natural
                    item size (not acounting for any packing issues)

With

new P0, .UnManagedStruct, init

you get an PMC w/o storage to access data coming *in* from external

with
  new P0, .ManagedStruct
  set P0, 80

you get malloced memory with sizeof(80)

assgin P0, init

overlays above structure for accessing the structures data

with
  set I0, P0[0;0]

you get the first (int) array element of structure item 0

set N0, P0[1]

you get e.g. a float being the 2. structure element.
Currently int/short/char/float/double and arrays of these should work.


It looks like single characters may not be sufficient soon, though, but tha's a separate issue.

Which single characters?



leo





Reply via email to