source: release/1.5/source/contrib/krueger/InterfaceProjects/Utilities/nslog-utils.lisp

Last change on this file was 13646, checked in by R. Matthew Emerson, 15 years ago

Merge r13631, r13636 from trunk. (Paul Krueger's updated InterfaceProjects
contrib; fix for ticket:652)

File size: 2.0 KB
RevLine 
[13390]1;; nslog-utils.lisp
2
[13646]3(eval-when (:compile-toplevel :load-toplevel :execute)
4 (require :ns-string-utils))
[13390]5
6(defpackage :interface-utilities
7 (:nicknames :iu)
[13646]8 (:export ns-log ns-error log-rect log-size log-float interleave log-4floats))
[13390]9
10(in-package :iu)
11
[13646]12(defun ns-log (lisp-str)
13 (#_NSLog (lisp-to-temp-nsstring lisp-str)))
14
15(defmacro ns-error (format-string &rest args)
16 `(progn
17 (ns-log (format nil ,format-string ,@args))
18 (error "See console log for information")))
19
[13390]20(defun log-rect (r &optional (log-string ""))
21 (#_NSLog (lisp-to-temp-nsstring (concatenate 'string
22 log-string
23 "x = %F y = %F width = %F height = %F"))
24 #>CGFloat (ns:ns-rect-x r)
25 #>CGFloat (ns:ns-rect-y r)
26 #>CGFloat (ns:ns-rect-width r)
27 #>CGFloat (ns:ns-rect-height r)))
28
29(defun log-size (s &optional (log-string ""))
30 (#_NSLog (lisp-to-temp-nsstring (concatenate 'string
31 log-string
32 "width = %F height = %F"))
33 #>CGFloat (ns:ns-size-width s)
34 #>CGFloat (ns:ns-size-height s)))
35
36(defun log-float (f &optional (log-string ""))
37 (#_NSLog (lisp-to-temp-nsstring (concatenate 'string
38 log-string
39 "%F"))
40 #>CGFloat f))
41
42(defun interleave (l1 l2)
43 (let ((lst1 (if (listp l1) l1 (list l1)))
44 (lst2 (if (listp l2) l2 (list l2))))
45 (if (atom l1)
46 (setf (cdr lst1) lst1)
47 (if (atom l2)
48 (setf (cdr lst2) lst2)))
49 (mapcan #'(lambda (el1 el2)
50 (list el1 el2))
51 lst1
52 lst2)))
53
54(defun log-4floats (f1 f2 f3 f4 &optional (log-strings '("" "" "" "")))
55 (#_NSLog (lisp-to-temp-nsstring (apply #'concatenate 'string
56 (interleave log-strings "%F ")))
57 #>CGFloat f1
58 #>CGFloat f2
59 #>CGFloat f3
60 #>CGFloat f4))
Note: See TracBrowser for help on using the repository browser.