# HG changeset patch # Parent d38e5b26ff83a84b91f62029cdaec5f693a78931 Add docstrings for my own sanity. (stas) MAKE-FUNCTION-POINTER typo. Refactor to remove compile warnings. diff --git a/src/cffi-abcl.lisp b/src/cffi-abcl.lisp --- a/src/cffi-abcl.lisp +++ b/src/cffi-abcl.lisp @@ -191,11 +191,11 @@ (defun make-shareable-byte-vector (size) "Create a Lisp vector of SIZE bytes can passed to WITH-POINTER-TO-VECTOR-DATA." - (error "unimplemented")) + (error "Unimplemented.")) (defmacro with-pointer-to-vector-data ((ptr-var vector) &body body) "Bind PTR-VAR to a foreign pointer to the data in VECTOR." - (warn "unimplemented")) + (warn "Unimplemented.")) ;;;# Dereferencing @@ -205,11 +205,11 @@ ((:int :unsigned-int) "java.lang.Integer") ((:long :unsigned-long) "com.sun.jna.NativeLong") ((:long-long :unsigned-long-long) "java.lang.Long") - (:pointer "com.sun.jna.Pointer") + (:pointer "com.sun.jna.Pointer") ;; void * is pointer? (:float "java.lang.Float") (:double "java.lang.Double") ((:char :unsigned-char) "java.lang.Byte") - ((:short :unsigned-short) "java.lang.Short")))) + ((:short :unsigned-short) "java.lang.Short")))) (defun %foreign-type-size (type) "Return the size in bytes of a foreign type." @@ -242,7 +242,7 @@ ((:short :unsigned-short) "getShort"))) (defun lispify-value (value type) - (when (and (eq type :pointer) (null value)) + (when (and (eq type :pointer) (or (null value) (eq +null+ value))) (return-from lispify-value (null-pointer))) (when (or (eq type :long) (eq type :unsigned-long)) (setq value (jcall (jmethod "com.sun.jna.NativeLong" "longValue") value))) @@ -312,7 +312,7 @@ (:stdcall "ALT_CONVENTION") (:cdecl "C_CONVENTION"))) -(defun make-function-pointer (pointer cconv) +(defun make-function-pointer (pointer convention) (jnew (private-jconstructor "com.sun.jna.Function" "com.sun.jna.Pointer" "int") pointer @@ -408,10 +408,18 @@ ,body))))) (jvm::define-class-name +callback-object+ "com.sun.jna.Callback") -(defconstant +dynamic-callback-package+ - "org/armedbear/jna/dynamic/callbacks") +(defconstant + +dynamic-callback-package+ + "org/armedbear/jna/dynamic/callbacks" + "The slash-delimited Java package in which we create classes dynamically.") (defun define-jna-callback-interface (returns args) + "Return the name of the java virtual machine interface which + specifies the contracts for a class which contains each method in + METHODS that matches the corresponding parameter signature in ARGS. + +As a side effect, this interface is dynamically created and injected +into the current virtual machine process." (multiple-value-bind (interface interface-name) (%define-jna-callback-interface (foreign-to-callback-type returns) @@ -468,10 +476,9 @@ (defun load-class (class-bytes) "Load the Java byte[] array CLASS-BYTES as a Java class." - (let ((load-class-method - (jmethod "org.armedbear.lisp.JavaClassLoader" - "loadClassFromByteArray" "[B"))) - (jcall load-class-method java::*classloader* class-bytes))) + (jcall + (jmethod "org.armedbear.lisp.JavaClassLoader" "loadClassFromByteArray" "[B") + java::*classloader* class-bytes)) ;;; Test function: unused in CFFI (defun write-class (class-bytes pathname) @@ -515,9 +522,9 @@ "Returns a pointer to a foreign symbol NAME." (flet ((find-it (name library) (let ((p (ignore-errors - (jcall (private-jmethod "com.sun.jna.NativeLibrary" - "getSymbolAddress") - library name)))) + (jcall + (private-jmethod "com.sun.jna.NativeLibrary" "getSymbolAddress") + library name)))) (unless (null p) (make-pointer p))))) (if (eq library :default) diff --git a/tests/GNUmakefile b/tests/GNUmakefile --- a/tests/GNUmakefile +++ b/tests/GNUmakefile @@ -43,7 +43,7 @@ endif else ifeq ($(OSTYPE), SunOS) -CFLAGS := -c -Wall -std=c99 -pedantic +CFLAGS := -m64 -c -Wall -std=c99 -pedantic else # Let's assume this is win32 SHLIB_EXT := .dll