The NCI interface slings these around and uses them to wrap things returned from external functions. They're handy things, but they're also opaque -- there's no good way to directly build up structs to pass into functions, and there's no good way to retrieve the data from the bits of the struct.

Read and write access to C-style structs should actually be easy enough to do, at least from a user bytecode level. Assume, for a moment, that we have a struct like:

   struct Foo {
      INTVAL bar;
      INTVAL baz;
      NUMVAL xyzzy;
      char *plugh;
   }

If that's living in an managedstruct, then accessing the struct elements should be as simple as:

   set I0, P20['bar']
   set S1, P20['plugh']
   set P20['baz'], 15

Or via the integer key interface:

   I0 = P20[0]
   S1 = P20[3]
   P20[1] = 15

All we need to do is get sufficient information into a particular (un)managedstruct to allow access to the individual elements of the base struct.

To do this strikes me as straightforward enough, we just need to decide what format we want the struct definition to be, and how to get it into the PMC since we probably don't want a custom class for each struct type.

the init vtable method is the obvious way to do this, but there are issues there since for many of these structs we won't *have* access to the init method, since the PMC is built around an already constructed struct, so an alternate method is needed to give the PMC the struct info it needs to figure out what's where.

So, here's the task:

1) Decide a good way to get the struct definition into the (un)managedstruct PMC
2) Write the code to take this information and access appropriate elements at runtime


--
                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to