[Openmcl-devel] #_ arg expansion problem

taube at uiuc.edu taube at uiuc.edu
Fri Jul 9 23:01:09 UTC 2004


I am working with a large ffi database (4,000+ function entries) that I
generated from Fink's GTK+2 developer package using OpenMCL's ffi tools. All the
#_ calls expand corrently in the ffi EXCEPT one entry that
%external-call-expander claims requires two arguments but actually only requires
one according to the .ffi and .h source files. The problem entry is for the glib
function "g_scanner_cur_value". Oddly enough, there are several other such
"g_scanner_" functions with identical arg declarations that do resolve correctly
in the ffi. 

Here is the C declaration of g_scanner_cur_value :

------ in gscanner.h:
  GTokenValue g_scanner_cur_value (GScanner *scanner);

And here is the entry in the "gtk.ffi" file that I created by doing "h-to-ffi
`pkg-config --cflags gtk+-2.0`" :

------ in gtk.ffi:
  (function ("/sw/include/glib-2.0/glib/gscanner.h" 215)
   "g_scanner_cur_value"
   (function
    ((pointer (typedef "GScanner")) )
    (typedef "GTokenValue")) (extern))

So both the .h and .ffi files indicate a function of one argument. Now here is
my Lisp wrapper function (I autogenerate defuns for all function and macro exprs
in the "gtk.ffi" file that I will eventually turn into a higher level of gtk
support than the raw #_ calls) The resulting "gtk.lisp" file has several
thousand such defuns -- this is the only one that causes problems:

----- in gtk.lisp:
  (defun g-scanner-cur-value (*GScanner)
    ;; source: /sw/include/glib-2.0/glib/gscanner.h
    ;; return: GTokenValue
    (#_g_scanner_cur_value *GScanner))

Now when I load the "gtk.lisp" file this defun is eventually evaluated and I get
this error:

> Error in process listener(1): Missing arguments in (OS::|g_scanner_cur_value|
*GSCANNER)
> While executing: CCL::%EXTERNAL-CALL-EXPANDER
> Type :POP to abort.
Type :? for other options.


When I look at the data that %external-call-expander is using to expand the
#_ expr this is what I see:

? (gethash 'os::|g_scanner_cur_value|
           (ftd-external-function-definitions *target-ftd*)

#S(EXTERNAL-FUNCTION-DEFINITION :ENTRY-NAME "_g_scanner_cur_value" :ARG-SPECS (
:ADDRESS :ADDRESS) :RESULT-SPEC :VOID :MIN-ARGS 2)

For what its worth, here is my ffi loading expressions at the top of my
"gtk.lisp" file:

(in-package :gtk)
(eval-when (:compile-toplevel :execute)
  (use-interface-dir :gtk2))
(eval-when (:compile-toplevel :load-toplevel :execute)
  (open-shared-library "/sw/lib/libgtk-x11-2.0.dylib"))


Any ideas on what could be causing the expanders info entry to be expecting two
args when the sources only list one?? Note that the :RESULT spec also seems
bogus. Any tips greatly appreciated!


Rick Taube
Associate Professor, Composition/Theory
School of Music
University of Illinois
Urbana, IL





More information about the Openmcl-devel mailing list