Mercurial > lasercutter
view src/clojure/contrib/condition/Condition.clj @ 10:ef7dbbd6452c
added clojure source goodness
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 21 Aug 2010 06:25:44 -0400 |
parents | |
children |
line wrap: on
line source
1 ;; Copyright (c) Stephen C. Gilardi. All rights reserved. The use and2 ;; distribution terms for this software are covered by the Eclipse Public3 ;; License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can4 ;; be found in the file epl-v10.html at the root of this distribution. By5 ;; using this software in any fashion, you are agreeing to be bound by the6 ;; terms of this license. You must not remove this notice, or any other,7 ;; from this software.8 ;;9 ;; Condition.clj10 ;;11 ;; Used by clojure.contrib.condition to implement a "Throwable map"12 ;;13 ;; scgilardi (gmail)14 ;; Created 09 June 200916 (ns clojure.contrib.condition.Condition17 (:gen-class :extends Throwable18 :implements [clojure.lang.IMeta]19 :state state20 :init init21 :post-init post-init22 :constructors {[clojure.lang.IPersistentMap]23 [String Throwable]}))25 (defn -init26 "Constructs a Condition object with condition (a map) as its27 metadata. Also initializes the superclass with the values at :message28 and :cause, if any, so they are also available via .getMessage and29 .getCause."30 [condition]31 [[(:message condition) (:cause condition)] (atom condition)])33 (defn -post-init34 "Adds :stack-trace to the condition. Drops the bottom 3 frames because35 they are always the same: implementation details of Condition and raise."36 [this condition]37 (swap! (.state this) assoc38 :stack-trace (into-array (drop 3 (.getStackTrace this)))))40 (defn -meta41 "Returns this object's metadata, the condition"42 [this]43 @(.state this))