Next: , Previous: translate-camelcase-name, Up: Functions


translate-name-from-foreign

Syntax

— Function: translate-name-from-foreign foreign-name package &optional varp ⇒ symbol

Arguments and Values

foreign-name
A string denoting a foreign function.
package
A Lisp package
varp
A generalized boolean.
symbol
The Lisp symbol to be used a function name.

Description

translate-name-from-foreign is used by defcfun to handle the conversion of foreign names to lisp 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 "someXmlFunction" ...)
  => SOMEXMLFUNCTION
  CFFI> (defmethod translate-name-from-foreign ((spec string)
                                                (package (eql *package*))
                                                &optional varp)
          (let ((name (translate-camelcase-name spec)))
            (if varp (intern (format nil "*~a*" name)) name)))
  => #<STANDARD-METHOD TRANSLATE-NAME-FROM-FOREIGN (STRING (EQL #<Package "SOME-PACKAGE">))>
  CFFI> (defcfun "someXmlFunction" ...)
  => SOME-XML-FUNCTION

See Also

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