Back
definterface (clj)
(source)macro
(definterface name & sigs)
Creates a new Java interface with the given name and method sigs.
The method return types and parameter types may be specified with type hints,
defaulting to Object if omitted.
(definterface MyInterface
(^int method1 [x])
(^Bar method2 [^Baz b ^Quux q]))
Examples
clojure/core.typed
(ns clojure.core.typed.test.protocol-munge
(:require [clojure.core.typed :as t]))
(t/ann-protocol Bar
my_dash_interface [Bar -> t/Symbol])
(definterface Bar
(my_dash_interface []))
typedclojure/typedclojure
(ns typed-test.cljc.checker.cs-gen
(:require [clojure.data :as data]
[clojure.core.typed.util-vars :as vs]
[typed.clj.checker.test-utils :refer :all]
[typed.cljc.checker.cs-gen :as sut]
[typed.cljc.checker.type-rep :as r]
[typed.cljc.checker.type-ctors :as c]
[typed.cljc.checker.subst :as subst]
[typed.cljc.checker.cs-rep :as crep]
[typed.clj.checker.parse-unparse :refer [parse-type]]
[clojure.test :refer [deftest is testing]]
[typed.clojure :as t]))
(deftest cs-gen-RClass-Protocol-test
(is-tc-e (do (defprotocol [[a :variance :covariant]] Prot)
(definterface Inter)
(override-classes Inter [[[a :variance :covariant]]
:unchecked-ancestors
[(Prot a)]])
(fn [upcast :- (t/All [x] [(Prot x) :-> x])
inter :- (Inter t/Int)]
:- t/Int
(upcast inter)))
:requires [[typed.clojure.jvm :refer [override-classes]]])
(is-tc-err (do (defprotocol [[a :variance :covariant]] Prot)
(definterface Inter)
(override-classes Inter [[[a :variance :covariant]]
:unchecked-ancestors
[(Prot a)]])
(fn [upcast :- (t/All [x] [(Prot x) :-> x])
inter :- (Inter t/Int)]
:- t/Bool ;; bad return
(upcast inter)))
:requires [[typed.clojure.jvm :refer [override-classes]]]))
clojure/core.rrb-vector
(ns clojure.core.rrb-vector.transients
(:require [clojure.core.rrb-vector.parameters :as p]
[clojure.core.rrb-vector.nodes :refer [ranges last-range
overflow?]])
(:import (clojure.core.rrb_vector.nodes NodeManager)
(clojure.core ArrayManager)
(java.util.concurrent.atomic AtomicReference)))
(definterface ITransientHelper
(editableRoot [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
root])
(editableTail [^clojure.core.ArrayManager am
tail])
(ensureEditable [^clojure.core.rrb_vector.nodes.NodeManager nm
root])
(ensureEditable [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
^int shift])
(pushTail [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^int cnt
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
tail-node])
(popTail [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^int cnt
^java.util.concurrent.atomic.AtomicReference root-edit
current-node])
(doAssoc [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
^int i
val])
(newPath [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
tail
^java.util.concurrent.atomic.AtomicReference edit
^int shift
current-node]))
clojure/core.rrb-vector
(ns clojure.core.rrb-vector.transients
(:require [clojure.core.rrb-vector.parameters :as p]
[clojure.core.rrb-vector.nodes :refer [ranges last-range
overflow?]])
(:import (clojure.core.rrb_vector.nodes NodeManager)
(clojure.core ArrayManager)
(java.util.concurrent.atomic AtomicReference)))
(definterface ITransientHelper
(editableRoot [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
root])
(editableTail [^clojure.core.ArrayManager am
tail])
(ensureEditable [^clojure.core.rrb_vector.nodes.NodeManager nm
root])
(ensureEditable [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
^int shift])
(pushTail [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^int cnt
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
tail-node])
(popTail [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^int cnt
^java.util.concurrent.atomic.AtomicReference root-edit
current-node])
(doAssoc [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
^int i
val])
(newPath [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
tail
^java.util.concurrent.atomic.AtomicReference edit
^int shift
current-node]))
datastax/fallout
(ns clojure.core.rrb-vector.transients
(:require [clojure.core.rrb-vector.nodes :refer [ranges last-range]])
(:import (clojure.core.rrb_vector.nodes NodeManager)
(clojure.core ArrayManager)
(java.util.concurrent.atomic AtomicReference)))
(definterface ITransientHelper
(editableRoot [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
root])
(editableTail [^clojure.core.ArrayManager am
tail])
(ensureEditable [^clojure.core.rrb_vector.nodes.NodeManager nm
root])
(ensureEditable [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
^int shift])
(pushTail [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^int cnt
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
tail-node])
(popTail [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^int cnt
^java.util.concurrent.atomic.AtomicReference root-edit
current-node])
(doAssoc [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
^int shift
^java.util.concurrent.atomic.AtomicReference root-edit
current-node
^int i
val])
(newPath [^clojure.core.rrb_vector.nodes.NodeManager nm
^clojure.core.ArrayManager am
tail
^java.util.concurrent.atomic.AtomicReference edit
^int shift
current-node]))