Rename defstruct to defcstruct
This commit is contained in:
parent
0cc650103c
commit
8889da56b2
1 changed files with 5 additions and 6 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
(ns coffi.ffi
|
(ns coffi.ffi
|
||||||
(:refer-clojure :exclude [defstruct])
|
|
||||||
(:require
|
(:require
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
|
|
@ -1146,14 +1145,14 @@
|
||||||
(s/fdef defcfn
|
(s/fdef defcfn
|
||||||
:args ::defcfn-args)
|
:args ::defcfn-args)
|
||||||
|
|
||||||
(s/def ::defstruct-args
|
(s/def ::defcstruct-args
|
||||||
(s/cat :struct-name qualified-keyword?
|
(s/cat :struct-name qualified-keyword?
|
||||||
;:layout (s/? keyword?)
|
;:layout (s/? keyword?)
|
||||||
:docstring (s/? string?)
|
:docstring (s/? string?)
|
||||||
:fields (s/* (s/cat :field-name simple-keyword?
|
:fields (s/* (s/cat :field-name simple-keyword?
|
||||||
:field-type ::type))))
|
:field-type ::type))))
|
||||||
|
|
||||||
(defmacro defstruct
|
(defmacro defcstruct
|
||||||
"Defines a type alias for a struct with the given name and fields.
|
"Defines a type alias for a struct with the given name and fields.
|
||||||
|
|
||||||
The fields are provided as keyword args.
|
The fields are provided as keyword args.
|
||||||
|
|
@ -1163,7 +1162,7 @@
|
||||||
[& args]
|
[& args]
|
||||||
;; TODO(Joshua): Support adding padding to the structure (and make it
|
;; TODO(Joshua): Support adding padding to the structure (and make it
|
||||||
;; extensible?)
|
;; extensible?)
|
||||||
(let [args (s/conform ::defstruct-args args)]
|
(let [args (s/conform ::defcstruct-args args)]
|
||||||
`(let [struct-type# [::struct ~(mapv (juxt :field-name :field-type) (:fields args))]]
|
`(let [struct-type# [::struct ~(mapv (juxt :field-name :field-type) (:fields args))]]
|
||||||
(defmethod c-layout ~(:struct-name args)
|
(defmethod c-layout ~(:struct-name args)
|
||||||
[_type#]
|
[_type#]
|
||||||
|
|
@ -1174,5 +1173,5 @@
|
||||||
(defmethod deserialize-from ~(:struct-name args)
|
(defmethod deserialize-from ~(:struct-name args)
|
||||||
[segment# _type#]
|
[segment# _type#]
|
||||||
(deserialize-from segment# struct-type#)))))
|
(deserialize-from segment# struct-type#)))))
|
||||||
(s/fdef defstruct
|
(s/fdef defcstruct
|
||||||
:args ::defstruct-args)
|
:args ::defcstruct-args)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue