GNU Info

Info Node: (g-wrap.info)Manually defining functions

(g-wrap.info)Manually defining functions


Next: Scanning source code for functions to export Prev: Defining a new function Up: Defining a new function
Enter node , (file) or (file)node

Manually defining functions
---------------------------

 - Function: new-function scheme-name ret-type c-name param-list
          description
     Exports a C-function to the Scheme interpreter.  C-NAME must be a
     string naming the function to be exported.  SCHEME-NAME must be a
     symbol naming the corresponding function to be provided at the
     Scheme level.  RET-TYPE must be a symbol or a list of the form
     (TYPE-SYM . OPTIONS) which describes the function's return type,
     and PARAM-LIST describes the function's parameters.  PARAM-LIST
     must be a list where each element is also a list of the form
     (TYPE-SYM ARG-NAME . OPTIONS).  For both the return value and the
     arguments, TYPE-SYM is a symbol of a type assigned using NEW-TYPE,
     ADD-TYPE or GWRAP-C-ASSUME-TYPES-WRAPPED, and OPTIONS must be
     symbols.  Currently 'cleanup and 'no-cleanup are the only
     available options and they are used to override the default
     cleanup behaviors on a per-argument/return-value basis.  See the
     discussion of 'cleanup in the `make-complex-c-type' documentation
     for details.

     DESCRIPTION must be a string, and will be added to the
     automatically generated documentation file.

     Examples:

          (new-function
           'eig-dsyev
           'void "eig_dsyev" '((MAT A) (MAT Z) (VEC w))
           "calculates eigenvectors Z and eigenvalues w
          of real symmetric matrix A")

     This writes a wrapper function which accepts three arguments,
     checks them to make sure they are of types `MAT', `MAT', and
     `VEC', converts the parameters to the corresponding C-types, then
     calls the C function `eig_dsyev' on the converted arguments.  The
     wrapper function returns an "unspecified" value because the return
     type is void--otherwise the return value of the C function would be
     converted to a Scheme value and returned.  The wrapper-function is
     bound to the Scheme symbol `eig-dsyev'.

     *For Guile*
     This command also adds a pair of the form `(SCHEME-SYM .
     DESCRIPTION)' to a list exported to the Guile interpreter as
     `*gw:descriptions*' which describes the function.

     In the example above, the following pair is then added to
     `*gw:descriptions*' when the interpreter is initialized (or when
     the module is dynamically linked to the interpreter):

          (eig-dsyev .
          "(eig-dsyev A Z w)
            A is a MAT, Z is a MAT, w is a VEC.
            no return value.
          calculates eigenvectors Z and eigenvalues w
          of real symmetric matrix A")

     The following example depicts the use of the cleanup options:

          (new-function
           'some-function
           '(some-type no-cleanup)
           "some_function"
           '((some-other-type x cleanup) (yet-another-type y 'no-cleanup))
           "Do something to x and y to produce an answer of type some-type.")


Scanning source code for functions to export

automatically generated by info2www version 1.2.2.9