File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -98,8 +98,8 @@ SLOT-NAME is a symbol and TYPE is an FFI type descriptor."
9898(defmacro define-ffi-array (name type length &optional docstring )
9999 ; ; This is a hack until libffi gives us direct support.
100100 (let ((type-description
101- (apply #'ffi--define-struct ( make-list ( eval length )
102- ( symbol-name type)))))
101+ (apply #'ffi--define-struct
102+ ( make-list ( eval length ) ( symbol-value type)))))
103103 `(defvar , name , type-description , docstring )))
104104
105105(defsubst ffi-aref (array type index )
@@ -109,7 +109,7 @@ SLOT-NAME is a symbol and TYPE is an FFI type descriptor."
109109 (declare (indent defun ))
110110 `(let ((,(car binding) (ffi-allocate ,@(cdr binding))))
111111 (unwind-protect
112- ,@body
112+ ( progn ,@body )
113113 (ffi-free ,(car binding)))))
114114
115115(defmacro with-ffi-temporaries (bindings &rest body )
@@ -126,7 +126,7 @@ SLOT-NAME is a symbol and TYPE is an FFI type descriptor."
126126 (declare (indent defun ))
127127 `(let ((,(car binding) (ffi-make-c-string ,@(cdr binding))))
128128 (unwind-protect
129- ,@body
129+ ( progn ,@body )
130130 (ffi-free ,(car binding)))))
131131
132132(defmacro with-ffi-strings (bindings &rest body )
Original file line number Diff line number Diff line change 9797 (should (eq (test-not t ) nil ))
9898 (should (eq (test-not 0 ) nil ))
9999 (should (eq (test-not " hi" ) nil )))
100+
101+ (defconst test-user-defined-char :char )
102+
103+ (ert-deftest ffi-array ()
104+ (should (eq (define-ffi-array arr1 :char 1024 ) 'arr1 ))
105+ (should (eq (define-ffi-array arr2 test-user-defined-char 1024 ) 'arr2 )))
106+
107+ (ert-deftest ffi-with-ffi-multi-stat ()
108+ (should (eq (with-ffi-temporary (a :int ) 1 2 3 ) 3 ))
109+ (should (eq (with-ffi-temporaries ((a :int ) (b :int )) 1 2 3 ) 3 ))
110+ (should (eq (with-ffi-string (a " test" ) 1 2 3 ) 3 ))
111+ (should (eq (with-ffi-strings ((a " s1" ) (b " s2" )) 1 2 3 ) 3 )))
112+
You can’t perform that action at this time.
0 commit comments