[squeak-dev] [FFI] Endless C structs and unions
Hernán Morales Durand
hernan.morales at gmail.com
Mon Mar 30 17:22:25 UTC 2009
Dear list,
I have a couple of questions, I started to play with FFI, so these
are newbie ones, my intention is to port the ZOOM library. I was there
happily writing ExternalStructure's until I found one that kills the
VM. Then I've realized I have some basic doubts about FFI:
1) I have this C struct
odr Struct Reference
===============
int direction
int error
unsigned char * buf
int top
int size
int pos
const unsigned char * bp
NMEM mem
struct Odr_private * op
which I wrote (with a lot of brilliant inspiration) like:
ZOOMODR class>> fields
" self defineFields "
^ #(
(direction 'long')
(error 'long')
(buf 'char *')
(top 'long')
(size 'long')
(pos 'long')
(bp 'char *')
(mem 'ZOOMNMem')
(odrPrivate 'void *') " ========= HERE ========= "
)
I don't know if this exists, the HERE means : I want to avoid to write
an external structure for this...
Odr_private Struct Reference
=====================
struct odr_constack * stack_first
struct odr_constack * stack_top
const char ** tmp_names_buf
int tmp_names_sz
struct Odr_ber_tag odr_ber_tag
yaz_iconv_t iconv_handle
int error_id
char element [80]
void(* stream_write )(ODR o, void *handle, int type,
const char *buf, int len)
void(* stream_close )(void *handle)
int can_grow
int t_class
int t_tag
int enable_bias
int choice_bias
int lenlen
FILE * print
int indent
After a look at the fields, I supose I do not care about the contents
of that struct. It is ok the
... (odrPrivate 'void *') ...
magic line to "stop" these C structs?
If not, is there a way to say "I don't care what follows from here"
(i.e. pass automagically nil to that pointer) ?
2)
Z_NamePlusRecord Struct Reference
=================================
Z_DatabaseName * databaseName
int which
union {
Z_External * databaseRecord
Z_DiagRec * surrogateDiagnostic
Z_FragmentSyntax * startingFragment
Z_FragmentSyntax * intermediateFragment
Z_FragmentSyntax * finalFragment
} u
Is there something special to do about an union in the #fields method?
Thanks in advance.
Hernán
More information about the Squeak-dev
mailing list
|