[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Swig and MzScheme's _scheme_get_type_name



Quoting Paul Fernhout:
> This was because "_scheme_get_type_name" can't be found by the linker.
> Any thoughts on what I might be doing wrong?

It is not exported by the MzScheme/MrEd binaries for Windows, though it
should be. The root of the problem is that scheme_get_type_name() is
declared in the wrong place in the source code, so that it doesn't get
put into the list of variables to be exported from the binary.

Fixing the problem requires rebuilding the binary, with
scheme_get_type_name added to plt/src/mzscheme/include/mzwin.def.


As an aside, I'm uneasy about the way SWIG is checking types:

 void *swig_get_c_pointer(Scheme_Object *so, char *c_type) {
    Scheme_Type st = SCHEME_TYPE(so);
    //char *type_name = scheme_get_type_name(st);
    //if(strcmp(type_name, c_type))
    //scheme_signal_error("wrong type in foreign object %s", type_name);

    return (void *) ((swig_proxy *) so)->object;
 }

What if an extension accidentally choose a name for a type that
MzScheme or some other extension is already using? The type id returned
by scheme_make_type() is guranteed to be unique, but the type name is
not. 

Maybe this is an unavoidable compromise in SWIG's design, though.

Matthew