This section contains information on SWIG's support of MzScheme.
Example interface file:
/* define a macro for the struct creation */
%define handle_ptr(TYPE,NAME)
%typemap(argout) TYPE *NAME{
Scheme_Object *o = SWIG_NewStructFromPtr($1, $*1_mangle);
SWIG_APPEND_VALUE(o);
}
%typemap(in,numinputs=0) TYPE *NAME (TYPE temp) {
$1 = &temp;
}
%enddef
/* setup the typemaps for the pointer to an output parameter cntrs */
handle_ptr(struct diag_cntrs, cntrs);
Then in scheme, you can use regular struct access procedures like
; suppose a function created a struct foo as ; (define foo (make-diag-cntrs (#x1 #x2 #x3) (make-inspector)) ; Then you can do (format "0x~x" (diag-cntrs-field1 foo)) (format "0x~x" (diag-cntrs-field2 foo)) ;etc...
That's pretty much it. It works with nested structs as well.