From 138786b69e545f8508e711089565a3f3b26bb92b Mon Sep 17 00:00:00 2001 From: Joshua Suskalo Date: Wed, 15 Sep 2021 12:15:24 -0500 Subject: [PATCH] Change ::integer to ::int --- src/coffi/ffi.clj | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/coffi/ffi.clj b/src/coffi/ffi.clj index daa05e5..6364931 100644 --- a/src/coffi/ffi.clj +++ b/src/coffi/ffi.clj @@ -43,7 +43,7 @@ [_] Short/SIZE) -(defmethod size-of ::integer +(defmethod size-of ::int [_] Integer/SIZE) @@ -75,7 +75,7 @@ "Map of primitive type names to the [[CLinker]] types for a method handle." {::byte CLinker/C_CHAR ::short CLinker/C_SHORT - ::integer CLinker/C_INT + ::int CLinker/C_INT ::long CLinker/C_LONG ::long-long CLinker/C_LONG_LONG ::char CLinker/C_CHAR @@ -87,7 +87,7 @@ "Map of primitive type names to the Java types for a method handle." {::byte Byte/TYPE ::short Short/TYPE - ::integer Integer/TYPE + ::int Integer/TYPE ::long Long/TYPE ::long-long Long/TYPE ::char Byte/TYPE @@ -117,27 +117,27 @@ ;; body (defcfun strlen "Counts the number of bytes in a C String." - "strlen" [::c-string] ::integer) - ​ + "strlen" [::c-string] ::int) + ;; This function has an output parameter and requires some clojure code to ;; translate the values from the c fn to something sensible in clojure. (defcfun some-func "Gets some output value" - "someFunc" [::pointer] ::integer + "someFunc" [::pointer] ::int [] - (let [out-int (alloc-instance ::integer) - success? (zero? (some-func out-int))] + (let [out-int (alloc-instance ::int) + success? (zero? (some-func (.address out-int)))] (if success? - (deserialize ::integer out-int) + (deserialize ::int out-int) (throw (ex-info (getErrorString) {}))))) - ​ + ;; This function probably wouldn't actually get wrapped, since the cost of ;; marshalling is greater than the speed boost of using an in-place sort. That ;; said, this is a nice sample of what more complex marshalling looks like. (defcfun qsort "Quicksort implementation" "qsort" - [::pointer ::long ::long (fn [::pointer ::pointer] ::integer)] + [::pointer ::long ::long (fn [::pointer ::pointer] ::int)] ::void [type comparator list] (let [copied-list (alloc (* (count list) (size-of type)))