chicken-hackers
[Top][All Lists]
Advanced

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

[Chicken-hackers] swig


From: Tony Sidaway
Subject: [Chicken-hackers] swig
Date: Wed, 11 Nov 2009 12:58:59 +0000

Is the chicken module of swig usable?

I just ran swig 1.3.40 on the chicken/simple example bundled with swig
using the makefile that comes with it.  It created a file "simple.so"
but warned:

Warning: library unit `example' compiled in dynamic mode
Warning: global variable `swig-init-return' is never used

When run in csi (4.2.0), the provided test script tries to load
simple.so but barfs:

Error: (load) unable to load compiled module
"simple.so"
#f

The source file for that appears to be a library unit--a file with
(declare (unit example)) at its head.

I seem to recall something like this working at one time.

Presumably the file should now be a chicken 4 module with declared
exports.  That would require an update to swig's chicken module.

I did try recompiling the Scheme file using Chicken 3.4.0 and running
the script in a Chicken 3.4.0 REPL but that didn't help.

Looking at the source file all it does it this:

(define swig-init (##core#primitive "swig_example_init"))
(define swig-init-return (swig-init))

swig_example_init, the Scheme primitive, is defined and exported by
example_wrap.c. It seems to do what I'd expect: calls some SWIG
initialization functions, and then this:

    a = 
C_alloc(2*4+C_SIZEOF_INTERNED_SYMBOL(11)+C_SIZEOF_INTERNED_SYMBOL(4)+C_SIZEOF_INTERNED_SYMBOL(3)+C_SIZEOF_INTERNED_SYMBOL(8));


    sym = C_intern (&a, 11, "My-variable");
    C_mutate ((C_word*)sym+1, (*a=C_CLOSURE_TYPE|1,
a[1]=(C_word)_wrap_My_variable, tmp=(C_word)a, a+=2, tmp));
    sym = C_intern (&a, 4, "fact");
    C_mutate ((C_word*)sym+1, (*a=C_CLOSURE_TYPE|1,
a[1]=(C_word)_wrap_fact, tmp=(C_word)a, a+=2, tmp));
    sym = C_intern (&a, 3, "mod");
    C_mutate ((C_word*)sym+1, (*a=C_CLOSURE_TYPE|1,
a[1]=(C_word)_wrap_mod, tmp=(C_word)a, a+=2, tmp));
    sym = C_intern (&a, 8, "get-time");
    C_mutate ((C_word*)sym+1, (*a=C_CLOSURE_TYPE|1,
a[1]=(C_word)_wrap_get_time, tmp=(C_word)a, a+=2, tmp));
    C_kontinue (continuation, ret);

In other words, pop some references on the stack and call its
continuation.  "My_variable" is a C variable that is supposed to be
accessible from Chicken, and the others are all C functions that are
supposed to interface to Chicken.

So it seems to be basically sane, but somewhere along the line it's
been affected by the dreaded bitrot.

Would be nice to be able to get it running again.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]