Next: , Previous: , Up: Functions   [Contents][Index]


translate-name-to-foreign

translate-name-to-foreign

Syntax

Function: translate-name-to-foreign lisp-name package &optional varp ⇒ string

Arguments and Values

lisp-name

A symbol naming the Lisp function to be created.

package

A Lisp package

varp

A generalized boolean.

string

The string representing the foreign function name.

Description

translate-name-to-foreign is used by defcfun to handle the conversion of lisp names to foreign names. By default, it translates using translate-underscore-separated-name. However, you can create specialized methods on this function to make translating more closely match the foreign library’s naming conventions.

Specialize package on some package. This allows other packages to load libraries with different naming conventions.

Examples

  CFFI> (defcfun some-xml-function ...)
  ⇒ "some_xml_function"
  CFFI> (defmethod translate-name-to-foreign ((spec symbol)
                                              (package (eql *package*))
                                              &optional varp)
          (let ((name (translate-camelcase-name spec)))
            (if varp (subseq name 1 (1- (length name))) name)))
  ⇒ #<STANDARD-METHOD TRANSLATE-NAME-TO-FOREIGN (STRING (EQL #<Package "SOME-PACKAGE">))>
  CFFI> (defcfun some-xml-function ...)
  ⇒ "someXmlFunction"

See Also

defcfun
translate-camelcase-name
translate-name-from-foreign
translate-underscore-separated-name