diff --git a/src/coffi/ffi.clj b/src/coffi/ffi.clj index 772d342..b657e19 100644 --- a/src/coffi/ffi.clj +++ b/src/coffi/ffi.clj @@ -148,7 +148,7 @@ [type] (cond (qualified-keyword? type) type - (list? type) (keyword (first type)))) + (sequential? type) (keyword (first type)))) (defmulti c-layout "Gets the layout object for a given `type`. @@ -223,6 +223,8 @@ ([type] (alloc-instance type (connected-scope))) ([type scope] (MemorySegment/allocateNative ^long (size-of type) ^ResourceScope scope))) +(declare serialize serialize-into) + (defmulti serialize* "Constructs a serialized version of the `obj` and returns it. @@ -243,6 +245,10 @@ {:type type :object obj})))) +(defmethod serialize* ::pointer + [obj type scope] + (alloc-instance (serialize obj (second type) scope))) + (defmulti serialize-into "Writes a serialized version of the `obj` to the given `segment`.