std.lib.impl

*override*

dynamic

*self*

dynamic

+dimpl-fn-args+

build-form

added in 3.0

(build-form body)

allows multiple forms to be built

build-impl

macro

added in 3.0

(build-impl & body)

build macro for generating functions from protocols

build-template-fn

added in 3.0

(build-template-fn {:keys [variadic with-opts], :as opts})

contructs a template from returned vals with support for variadic

((build-template-fn {}) ’([-val (obj(val obj))] [-val (obj k(val obj k))] [-get (obj(get obj))])) => ’((clojure.core/defn val (obj(val obj)) (obj k(val obj k))) (clojure.core/defn get (obj(get obj))))

((build-template-fn {:variadic ’#{-mul}}) ’([-mul (obj ks(mul obj ks))])) => ’((clojure.core/defn mul (obj & ks(mul obj ks))))

build-template-protocol

added in 3.0

(build-template-protocol {:keys [protocol inner outer fns variadic with-opts], :as params})

helper for build

(build-template-protocol ’{:protocol ITest :outer {:suffix “-outer”} :inner {:prefix “inner-”} :fns {:default {:body-sym-fn impl:unwrap-sym}}})

=> ’((clojure.core/defn val-outer (obj(inner-val obj)) (obj k(inner-val obj k))) (clojure.core/defn get-outer (obj(inner-get obj))))

build-variadic-fn

added in 3.0

(build-variadic-fn fsym arr)

builds a variadic function if indicated

build-with-opts-fn

added in 3.0

(build-with-opts-fn fsym arr)

builds a function with an optional component

create-body-fn

added in 3.0

(create-body-fn {:keys [body-fn], :as fns})

creates a body function

((create-body-fn {:body-sym-fn impl:unwrap-sym}) {:name ’-val :arglist ’cache val :prefix “test/”}) => ’(cache val(test/val cache val))

defimpl

macro

added in 3.0

(defimpl sym bindings & body)

creates a high level deftype or defrecord interface

dimpl-fn-forms

added in 3.0

(dimpl-fn-forms invoke)

creates the IFn forms

dimpl-fn-invoke

added in 3.0

(dimpl-fn-invoke method n)

creates an invoke method

dimpl-form

added in 3.0

(dimpl-form sym bindings body)

helper for defimpl

dimpl-print-method

added in 3.0

(dimpl-print-method sym)

creates a print method form

dimpl-template-fn

added in 3.0

(dimpl-template-fn inputs)

helper function for defimpl

dimpl-template-interface

added in 3.0

(dimpl-template-interface {:keys [interface method body], :as params})

creates forms for the interface

(dimpl-template-interface {:interface ’ITest :method ’{invoke {entry submit-invoke}} :body ’{bulk? {entry false}}}) => ’(ITest (invoke entry(submit-invoke entry)) (bulk? entry false))

dimpl-template-protocol

added in 3.0

(dimpl-template-protocol {:keys [protocol prefix suffix fns custom], :as params})

coverts the entry into a template

(dimpl-template-protocol {:protocol ’ITest :prefix “impl/” :suffix “-test”}) => ’(ITest (-val obj(impl/val-test obj)) (-val obj k(impl/val-test obj k)) (-get obj(impl/get-test obj)))

eimpl-form

added in 3.0

(eimpl-form class body)

creates the extend-impl form

eimpl-print-method

added in 3.0

(eimpl-print-method type string)

creates a print method form

eimpl-template-fn

added in 3.0

(eimpl-template-fn inputs)

creates forms compatible with extend-type and extend-protocol

(eimpl-template-fn ’([-val (obj(val obj))] [-val (obj k(val obj k))] [-get (obj(get obj))])) => ’((-val (obj(val obj)) (obj k(val obj k))) (-get (obj(get obj))))

eimpl-template-protocol

added in 3.0

(eimpl-template-protocol {:keys [protocol prefix suffix fns custom], :as params})

helper for eimpl-form

(eimpl-template-protocol {:protocol ’ITest :prefix “impl/” :suffix “-test”}) => ’(ITest (-val (obj(impl/val-test obj)) (obj k(impl/val-test obj k))) (-get (obj(impl/get-test obj))))

extend-impl

macro

added in 3.0

(extend-impl type & body)

extends a class with the protocols

impl:doto

added in 3.0

(impl:doto sym)

operates on a proxy and returns object

((impl:doto :) ’[(-add-channel (mq(add-channel-atom mq)))]) => ’((-add-channel mq(do (add-channel-atom :) mq)))

impl:proxy

added in 3.0

(impl:proxy sym)

creates a proxy template given a symbol

((impl:proxy :) ’[(-add-channel (mq(add-channel-atom mq) mq))]) => ’((-add-channel mq(add-channel-atom :) mq))

impl:unwrap-sym

added in 3.0

(impl:unwrap-sym {:keys [name prefix suffix], :or {prefix "", suffix ""}})

unwraps the protocol symbol

(impl:unwrap-sym {:name ’-val :prefix “test/” :suffix “-mock”}) => ’test/val-mock

impl:wrap-sym

added in 3.0

(impl:wrap-sym {:keys [protocol name]})

wraps the protocol symbol

(impl:wrap-sym {:protocol ’protocol.test/ITest :name ’-val}) => ’protocol.test/-val

interface-fns

added in 3.0

(interface-fns type template)

helper for interface forms

(interface-fns :body {}) => (contains {:body-output-fn fn?})

parse-impl

added in 3.0

(parse-impl signatures {:keys [method body include exclude], :as params})

parses the different transform types

(parse-impl (template-signatures ’IHello {:prefix “impl/”}) {:body ’{-hi “Hi There”}}) => ’{:method #{}, :body #{-hi}, :default #{-delete}}

protocol-fns

added in 3.0

(protocol-fns type template)

helpers for protocol forms

(protocol-fns :body {}) => (contains {:body-output-fn fn?})

split-all

added in 3.0

(split-all forms)(split-all forms tag-key)(split-all forms tag-key params)

splits all entries

(split-all ’[ITest :include -test :body {-val 3} IMore IProtocols :exclude []] :protocol {:prefix “test/”}) => ’[{:prefix “test/”, :include -test, :body {-val 3}, :protocol ITest} {:prefix “test/”, :protocol IMore} {:prefix “test/”, :exclude [], :protocol IProtocols}]

split-body

added in 3.0

(split-body body)

splits a body depending on keyword pairs

(split-body [:a 1 :b 2 ’hellothere]) => [{:a 1, :b 2} ’(hello there)]

split-single

added in 3.0

(split-single forms)(split-single forms tag-key)

splits out a given entry

standard-body-input-fn

added in 3.0

(standard-body-input-fn _)

creates a standard input function

standard-body-output-fn

added in 3.0

(standard-body-output-fn {:keys [body-sym-fn body-arg-fn], :or {body-sym-fn :name, body-arg-fn identity}})

creates a standard output function

template-gen

added in 3.0

(template-gen type-fn types signatures params fns)

generates forms given various formats

(template-gen protocol-fns :default (template-signatures ’ITest) {} {}) => ’([-val (obj(val obj))] [-val (obj k(val obj k))] [-get (obj(get obj))])

template-signatures

added in 3.0

(template-signatures protocol)(template-signatures protocol params)

finds template signatures for a protocol

template-transform

added in 3.0

(template-transform signatures {:keys [template-fn], :as fns, :or {template-fn identity}})

transforms all functions