id
int64 0
45.1k
| file_name
stringlengths 4
68
| file_path
stringlengths 14
193
| content
stringlengths 32
9.62M
| size
int64 32
9.62M
| language
stringclasses 1
value | extension
stringclasses 6
values | total_lines
int64 1
136k
| avg_line_length
float64 3
903k
| max_line_length
int64 3
4.51M
| alphanum_fraction
float64 0
1
| repo_name
stringclasses 779
values | repo_stars
int64 0
882
| repo_forks
int64 0
108
| repo_open_issues
int64 0
90
| repo_license
stringclasses 8
values | repo_extraction_date
stringclasses 146
values | sha
stringlengths 64
64
| __index_level_0__
int64 0
45.1k
| exdup_ids_cmlisp_stkv2
sequencelengths 1
47
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
26,255 | morph.lsp | Leon-Focker_layers/src/morph.lsp | ;; ** morph.lsp
;;; home of morph-patterns and interpolate-patterns - two ways of transitioning
;;; from one pattern (any kind of list with numbers) to another
(in-package :ly)
;; *** patterns-to-rhythms-list
;;; list of style '((1 1 (1) 1 1 (1)) ((1) 1 1 (1) 1))
;;; to '((1 1 1 1 1 1) (1 1 1 1 1))
;;; could this be easier with sc::flatten?
(defun patterns-to-rhythms-list (patterns)
(loop for pattern in patterns
collect
(loop for i in pattern
collect
(let ((rhythm (if (listp i)
(car i)
i)))
(if (numberp rhythm)
rhythm
(error "pattern holds weird value: ~a" rhythm))))))
;; *** scale-pattern
;; (scale-pattern '(1 1 1 (1) 1 1) 5) => (5/6 5/6 5/6 (5/6) 5/6 5/6)
(defun scale-pattern (pattern new-duration)
(let* ((old-duration (loop for i in (flatten pattern) sum i))
(factor (/ new-duration old-duration)))
(loop for i in pattern
collect (if (atom i) (* i factor) `(,(* (car i) factor))))))
;; *** nested-pattern
;;; if a pattern contains values that are greater than 'longest', they will be
;;; replaced with a version of the pattern, whose elements sum to the original
;;; value.
(defun nested-pattern-aux (rhythms longest pattern &optional carry-rests)
(let (flag)
(setf rhythms
(loop for d in rhythms
for val = (if (atom d) d (car d))
unless (> val longest) collect d
when (> val longest)
append (progn (setf flag t)
(if (and (listp d) carry-rests)
`(,(scale-pattern pattern val))
(scale-pattern pattern val)))))
(if flag (nested-pattern-aux rhythms longest pattern) rhythms)))
(defun nested-pattern (pattern longest &optional carry-rests)
(nested-pattern-aux pattern longest pattern carry-rests))
;; *** mod1
;;; (mod x 1), but return 1 if (and (= 0 (mod x 1)) (not (= 0 x)))
(defun mod1 (x)
(let ((x (rational x)))
(cond ((= 0 x) 0)
((= 0 (mod x 1)) 1)
(t (mod x 1)))))
(export 'mod1 :ly)
;; *** envelope-interp
;;; slippery chicken provides #'interpolate. Is there a difference?
;;; copied from the common lisp music package
(defun envelope-interp (x fn &optional (base 1)) ;order of args is like NTH
(cond ((null fn) 0.0) ;no data -- return 0.0
((or (<= x (first fn)) ;we're sitting on x val (or if < we blew it)
(null (third fn))) ;or we're at the end of the list
(second fn)) ;so return current y value
((> (third fn) x) ;x <= next fn x axis value
(if (= (second fn) (fourth fn))
(second fn) ;y1=y0, so just return y0 (avoid endless calculations below)
(if (= 1 base) ;linear envelope
(+ (second fn) ;y0+(x-x0)*(y1-y0)/(x1-x0)
(* (- x (first fn))
(/ (- (fourth fn) (second fn))
(- (third fn) (first fn)))))
(if (= 0 base) ; step env
(second fn) ; or 4th? 2nd mimics env, I think
(+ (second fn) ;y0+[[[y1-y0] [-1.0 + [base ^ [x-x0]/[x1-x0]]] / [base-1]
(* (/ (- (fourth fn) (second fn))
(- base 1.0)) ;scaled y1-y0
(- (expt base (/ (- x (first fn))
(- (third fn) (first fn))))
1.0)))))))
(t (envelope-interp x (cddr fn) base)))) ;go on looking for x segment
;; *** morph-patterns
;;; morph between two patterns, using a morphing-function,
;;; eg. fibonacci-transition. This morphing-function will determine which
;;; pattern to choose the next element from. The numerical values in patterns
;;; are not changed, but the patterns are mixed.
;;; patterns - a list of patterns - list of sublists containing durations.
;;; Can also contain durations in parentheses (rests). Here is a simple example
;;; for patterns:
;;; '((.25 (.25) .25 (.25)) ((.25) .25 (.25) .25))
;;; -> two patterns, each have a total duration of 1.
;;; duration - the sum of all durations in the result
;;; -> the duration of the resulting sequence
;;; cut-end? - t or nil, tries to avoid a repetition of an entire unaltered
;;; pattern at the end of the sequence. Should be nil for most cases.
;;; Also this currently only works when a list is given for the transition
;;; overlap-duration - t will append the last rhythm without squeezing it
;;; perfectly into the given duration (no subtraction of last rhythm)
;;; length - when nil, generate a list with duration, when a number, generate
;;; a list with this length.
;;; collect-indices - if nil, everything happens as normal. If t, don't collect
;;; the rhythm value but a list with two values - the first being the index of
;;; the pattern in patterns and the second being the index of the rhythm value
;;; in the pattern. This way, you could morph a second set of patterns
;;; according to the original set of patterns. For example the first set of
;;; patterns could be some rhythms and the second set could be note names.
;;; These could normally not be processed by morph-patterns but can then be
;;; morphed using the indices the call to morph-patterns with the rhythms
;;; produced.
;;; morphing-function - determines how the transition between the patterns
;;; is happening. Can be a list (eg. one made from fibonacci-transitions).
;;; Can also be a function, which must accept one rational number as an
;;; argument and returns one rational number.
(defun morph-patterns (patterns duration &optional
cut-end?
overlap-duration
length
collect-indices
(morphing-function
(sc::fibonacci-transition 20)))
;; sanity checks
(unless (and (typep patterns 'list) (> (length patterns) 1))
(error "morph-patterns needs patterns to be a list of at least two patterns: ~&~a"
patterns))
(unless (or (not length) (numberp length))
(error "length in morph-patterns should either be nil or a number: ~&~a"
length))
(unless (> (or length duration) 0)
(error "for morph-patterns, duration or length must be greater than 0: ~a"
(or length duration)))
(unless (typep morphing-function 'function)
(if (typep morphing-function 'list)
(setf morphing-function
(make-list-into-function
morphing-function
(or length
(+ duration (if cut-end?
(length (last patterns))
0)))))
(error "morphing-function must either be of type function or list: ~a"
morphing-function)))
(unless (numberp (funcall morphing-function 0))
(error "morphing function not usefull: ~a" morphing-function))
(when (or length collect-indices) (setf overlap-duration t))
#|(visualize
(loop for i below length collect (funcall morphing-function i)))|#
;; the important part:
(let* ((rhythms-list (patterns-to-rhythms-list patterns)))
(loop for i from 0
for sum = 0 then (+ sum (if (= 0 rhythm) 1 (rational rhythm)))
for key = (round (mirrors (funcall morphing-function
(if length i sum))
0 (1- (length patterns))))
for pattern = (nth key patterns)
for rhythms = (nth key rhythms-list)
;; position relative to the pattern
for index = (let ((pat-dur (loop for i in rhythms sum (rational i))))
(if (not (= pat-dur 0))
(decider (min (rationalize (+ (sc::rescale
(mod sum pat-dur)
0
pat-dur
0
1)
;; i hate it but this is the
;; only way to combat
;; floating point errors
(expt 10.0d0 -7)))
1)
rhythms)
0))
;; rhythm is the duration of the event
for rhythm = (nth index rhythms)
;; event can be a rest or a note with a duration
;; Alternatively it's a list of the indices at which to find the event.
for event = (if collect-indices `(,key ,index) (nth index pattern))
until (if length (>= i (1- length)) (>= (+ sum rhythm) duration))
;; if collect-indices is t, collect lists, in which the first element is
;; the index of the pattern and the second element is the index within
;; that pattern. Else collect event (element in pattern at that position)
collect event into ls
;; when the next rhythm would complete the sequence:
finally
;; add a difference, to bring sequence to its max length
;; if the rhythm-value was a rest, the added difference will
;; too be a rest
(let* ((difference (- (rational duration) sum)))
(unless (sc::equal-within-tolerance difference 0)
(cond (overlap-duration (setf ls (append ls (list event))))
((atom event) (setf ls (append ls (list difference))))
(t (setf ls (append ls (list (list difference))))))))
;; return the final rhythm sequence:
(return ls))))
;; *** interpolate-patterns
;;; interpolate the numerical values in one pattern until it matches the next
;;; pattern. The patterns do not have to have the same length.
;;; patterns - list of sublists containing durations - see morph-patterns
;;; duration - the sum of all durations in the result
;;; -> the duration of the resulting sequence
;;; overlap-duration - t will append the last rhythm without squeezing it
;;; perfectly into the given duration (no subtraction of last rhythm)
;;; transition-ratios - the duration of the interpolation between one pattern
;;; and the next, relative to the duration of the result. This must be a list
;;; with one less item than the patterns argument, so if you want to morph
;;; three patterns, transition-ratios would initially be '(1 1) but could be
;;; set to any list containing any two numbers.
;;; transition-envelopes - this controlls the interpolation itself. If nil,
;;; normal linear interpolation is happening. If it is an envelope, the linear
;;; interpolation coefficient is set to (envelope-interp coeff env). If it is
;;; a list of envelopes, they are cycled through with mod. The envelopes should
;;; range from 0 to 1. This can be useful for a million different things.
;;; A very simple usecase might be a slight swing in a drum pattern (using a
;;; static env '(0 .2)) for example. Rhythms could also be humanized by very
;;; long varying envelopes with small changes.
;;; length - also analog to morph-patterns, instead of a duration supply the
;;; length for the final list.
(defun interpolate-patterns (patterns duration
&optional overlap-duration
transition-ratios
transition-envelopes
length)
;; outsource work to -aux function that handles patterns and envelopes
(interpolate-patterns-aux patterns duration
overlap-duration transition-ratios
transition-envelopes
nil length))
;; *** interpolate-envelopes
;;; similar to interpolate-patterns but takes list of envelopes. These are then
;;; split into the x-values and y-values, which are then interpolated
;;; separately. Then envelopes are formed again.
;;; EXAMPLE
#|
(interpolate-envelopes '((0 1 .5 1 1 1) (0 0 .2 3 3 0) (0 1 .2 4 1 1)) 24)
=> ((0 1 3984589/8388608 7/6 4/3 5/6)
(0 3/4 13421773/33554432 5/3 11/6 7/12)
(0 1/2 5452595/16777216 13/6 7/3 1/3)
(0 1/4 1/4 8/3 17/6 1/12)
(0 0 13421773/67108864 37/12 8/3 1/6)
(0 1/4 6710887/33554432 10/3 13/6 5/12)
(0 1/2 13421773/67108864 43/12 5/3 2/3)
(0 3/4 13421773/67108864 23/6 7/6 11/12))
|#
(defun interpolate-envelopes (envelopes length
&optional
transition-ratios
transition-envelopes)
(unless (and (listp envelopes)
(loop for env in envelopes always
(and (listp env) (= 0 (mod (length env) 2)))))
(error "the supplied envelopes seem to be malformed. ~
Or do you want to use interpolate-patterns?"))
;; outsource work to -aux function that handles patterns and envelopes
(interpolate-patterns-aux envelopes 0
t transition-ratios
transition-envelopes t length))
;; the auxiliary function doing all the work:
(defun interpolate-patterns-aux (patterns duration
&optional overlap-duration
transition-ratios
transition-envelopes
patterns-are-envelopes
length)
;; sanity checks
(unless (listp transition-ratios)
(error "transition-ratios must be nil or a list but is: ~a"
transition-ratios))
(if transition-ratios
(unless (= (1- (length patterns)) (length transition-ratios))
(error "different number of pattern-transitions and transition-ratios ~
in interpolate-patterns: ~a, ~a"
(1- (length patterns)) (length transition-ratios)))
(setf transition-ratios (sc::ml 1 (1- (length patterns)))))
(unless transition-envelopes (setf transition-envelopes '((0 0 1 1))))
(unless (listp transition-envelopes)
(error "transition-envelopes must be an envelope of a list of envelopes ~
but is ~a" transition-envelopes))
(unless (listp (first transition-envelopes))
(setf transition-envelopes (list transition-envelopes)))
(unless (or (not length) (numberp length))
(error "length in interpolate-patterns should either be nil or a number: ~
~&~a" length))
;; check that all envelopes have (= 0 (mod (length env) 2))
(unless (loop for i in transition-envelopes always (= 0 (mod (length i) 2)))
(error "interpolate-patterns detected a weird envelope in ~
transition-envelopes"))
(unless (listp patterns)
(error "interpolate-patterns needs patterns to be a list: ~a" patterns))
(unless (> (or length duration) 0)
(error "for interpolate-patterns, duration or length must be greater than ~
0: ~a" (or length duration)))
(when length (setf overlap-duration t))
(let* ((ratio-sum (loop for i in transition-ratios sum i))
(trans-durs (loop for i in transition-ratios
collect (* (/ i ratio-sum) (or length duration))))
(trans-starts (append '(0) (loop for i in trans-durs
sum i into sum collect sum)))
(tr-env-len (length transition-envelopes))
(x-list '())
(y-list '()))
;; if patterns are envelopes, split into two lists
(if patterns-are-envelopes
(loop for pattern in patterns do
(loop for x in pattern by #'cddr and y in (cdr pattern) by #'cddr
collect x into ls1
collect y into ls2
finally (push ls1 x-list)
(push ls2 y-list))
finally (setf x-list (reverse x-list)
y-list (reverse y-list)))
(setf x-list patterns))
;; the fun part, but as a closure:
(flet ((interp-pttns-aux-aux (patterns)
(loop for i from 0
for env = (nth (mod i tr-env-len) transition-envelopes)
for sum = 0 then (+ sum (rational rhythm))
for progress = (if length (/ i length) (/ sum duration))
for n = (decider progress trans-durs)
for interp = (envelope-interp
(rational (/ (- (if length i sum)
(nth n trans-starts))
(- (nth (1+ n) trans-starts)
(nth n trans-starts))))
env)
for pattern1 = (nth n patterns)
for pattern2 = (nth (1+ n) patterns)
for event1 = (nth (mod i (length pattern1)) pattern1)
for event2 = (nth (mod i (length pattern2)) pattern2)
for rhythm = (rational (+ (* (- 1 (mod1 interp))
(if (listp event1) (car event1)
event1))
(* (mod1 interp)
(if (listp event2) (car event2)
event2))))
for event = (if (listp (if (>= (mod1 interp) 0.5)
event2
event1))
(list rhythm)
rhythm)
until (if length
(>= i (1- length))
(>= (+ sum rhythm) duration))
collect event into ls
finally
;; add a difference, to bring sequence to its max length
;; if the rhythm-value was a rest, the added difference will
;; too be a rest
(let* ((difference (- (rational duration) sum)))
(unless (sc::equal-within-tolerance difference 0)
(cond (overlap-duration
(setf ls (append ls (list event))))
((atom event)
(setf ls (append ls (list difference))))
(t (setf ls
(append ls (list (list difference))))))))
;; return the final rhythm sequence:
(return ls))))
;; if envelopes, do for x and y:
(if patterns-are-envelopes
(lists-to-envelopes
(interp-pttns-aux-aux x-list)
(interp-pttns-aux-aux y-list))
(interp-pttns-aux-aux x-list)))))
(export '(layers
morph-patterns
interpolate-patterns
interpolate-envelopes
envelope-interp))
;; EOF morph.lsp
| 16,063 | Common Lisp | .l | 364 | 39.387363 | 86 | 0.662629 | Leon-Focker/layers | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 5ac90ca67f640d8525bf3d8f8875f9f04fc0e9ce3f9a27da7ebd963dd9b5665c | 26,255 | [
-1
] |
26,256 | layers.lsp | Leon-Focker_layers/src/layers.lsp | ;; ** layers
;;;; the class to rule them all, a layers object basically represents a piece
(in-package :layers)
;; *** layers
;;; new class layers, which represents the whole piece
(defclass layers (list-object)
())
;;; *layers* can only be an object of type layers
(declaim (type layers *layers*))
;; *** make-layers
;;; create a layers-object and push it into *all-layers*
(defun make-layers (id list-of-layers)
(let ((lys (make-instance 'layers
:id id
:data list-of-layers)))
(pushnew lys *all-layers*)
lys))
;; *** add-layer-to-layers
;;; add a layer-object to the piece (layers-object)
(defmethod add-layer-to-layers ((ly layer) (lys layers)
&key (warn-if-double t))
(if (null (data lys))
(setf (data lys) (list ly))
(let* ((double (member (id ly)
(loop for i in (data lys) collect (get-id i)))))
(if double
(progn
(when warn-if-double
(warn (format nil "the id ~a is already in the lys ~a ~
and will be replaced"
(get-id ly) (get-id lys))))
(setf (data lys)
(remove-nth (- (length (data lys))
(length double))
(data lys)))
(push ly (data lys)))
(push ly (data lys))))))
;; *** play-layer
;;; play a layer from a layers-object
(defmethod play-layer (layer-id (lys layers))
(let* ((ly (loop for layer in (data lys) do
(when (eq layer-id (get-id layer))
(return layer)))))
(if ly
(play-this ly :printing *print-to-console*)
(error "~&there is no Layer with ID ~a in layers ~a"
layer-id (get-id lys)))))
;; *** next-trigger-for-layer
;;; helper function for next-trigger and set-n
(defun next-trigger-for-layer (remaining ly &key (index 1) (threshold 0.01))
(setf remaining (+ remaining (see-with-relative-index (list-of-durations ly) index)))
(if (> remaining threshold) remaining (next-trigger-for-layer remaining ly :index (+ index 1))))
;; *** next-trigger
;;; this function is called when the timer within pure data reaches 0
;;; trigger all triggers all layers but thus screws with the timing, no?
(defmethod next-trigger ((lys layers) &key current-time trigger-all)
(unless lys (error "in next-trigger, the layers object is nil"))
;; subtract current next-trigger from time until next trigger of each layer
;; and look for the times until the next layer will be triggered
(let* ((next-triggers (loop for ly in (data lys)
do (setf (remaining-duration ly)
(- (remaining-duration ly) *next-trigger*))
collect (let* ((remaining (remaining-duration ly)))
(if (> remaining 0.01)
remaining
(next-trigger-for-layer remaining ly)))))
(next-layers-triggered '()))
(when *print-to-console* (format t "~&next-triggers: ~a" next-triggers))
;; here we decide which layers are to be triggered
;; usually layers with remaining time < 0.01 are chosen.
;; when playback is started, all layers must be triggered
(setf next-layers-triggered
(loop for ly in (data lys)
;; somehow the following doesn't work:
;do (when (> (remaining-duration ly) 0.01)
; (setf (play-length ly) (- (play-length ly) *next-trigger*)))
when (or trigger-all (<= (remaining-duration ly) 0.01))
collect ly))
;; set *next-trigger* to the minimal time until the next layer needs one
(setf *next-trigger* (* 0.01 (round (* 100 (apply #'min next-triggers)))))
;; set timer to next-trigger and send list of layers that will be triggered
(when (and current-time *print-to-console*)
(format t "~¤t-time: ~a" current-time))
(append
(list 'trigger *next-trigger*)
(loop for ly in next-layers-triggered append
(play-this ly :printing *print-to-console*
:offset-start (if (> (remaining-duration ly) 0.01)
(- (this-length ly) (remaining-duration ly))
0))))))
;; *** set-n
;;; change the n-for-list-of-durations value even while playing
(defmethod set-n (n layer-id (lys layers) current-time current-timer)
;; look for the layer we want to change n for
(let* ((ly (handler-case (find-with-id layer-id (data lys))
;; if no layer with id is found, just take first one in list
;; to prevent this function crashing
(id-not-found (c)
(warn (text c))
(first (data lys)))))
;; check and see if n is too big, then choose list-of-durations (ls)
(ls (progn (when (>= n (length (data (structure ly))))
(warn "~&n ~a is too big for structure of layer ~a"
n layer-id)
(setf n (- (length (data (structure ly))) 1)))
(nth n (data (structure ly)))))
;; some neat variables
(len (length ls))
(current-duration-index 0)
;; in new list, look for next trigger time and sum
(new-next-trigger (loop for n from 0 and i = (nth (mod n len) ls)
sum i into sum
until (> sum current-time)
finally (progn (setf current-duration-index
(mod n len))
(return sum))))
;; (old-next-trigger (current-time ly))
(passed-timer (- *next-trigger* current-timer))
(reset-timer-flag 0))
;; store new n in layer
(setf (n-for-list-of-durations ly) n)
;; setting "current-duration-index" should be obsolete, since the next length
;; will be chosen by using the current-time anyways. but for good measure:
(update-list-of-durations ly current-duration-index)
;; function get-next sets current time of layer to the time
;; when the next sample will be triggered. (old-next-trigger)
;; reset to new-next-trigger
(setf (current-time ly)
new-next-trigger
;; set this-length according to current-time
(this-length ly)
(see-current (list-of-durations ly))
;; (get-next-by-time (print (current-time ly)) (list-of-durations ly))
;; set new play-length (?) and remaining time (time between last and next general trigger)
;; (play-length ly)
;; (- new-next-trigger current-time)
(remaining-duration ly)
(+ passed-timer ; last-trigger until now
(- new-next-trigger current-time)) ; now until end of sample
;; choose soundfile again... maybe we don't want this here?
(current-stored-file ly)
(determine-new-stored-file ly))
(when (< (remaining-duration ly) 0)
(warn "something is off, remaining-duration is negative: ~a"
(remaining-duration ly)))
;; find new *next-trigger*, calling this function solves all my troubles,
;; idk why
(next-trigger *layers* :trigger-all t)
;; information as to what has happened:
(format t "~&n for Layer ~a has been set to ~a" layer-id n)
(when *print-to-console*
(format t "~&SET TIMER TO: ~a ~a"
(- *next-trigger* current-timer) reset-timer-flag))
;; finally tell PD what to do:
(list 'update
;; time until next trigger
(float (- *next-trigger* current-timer))
;; reset-timer in pd?
reset-timer-flag
;; layer ID
layer-id
;; remaining time for currently played file
(float (- new-next-trigger current-time))
;; new decay
(float (see-next (list-of-durations ly))))))
;; *** update-times
;;; after chanigng a structure, similar to set-n, the timings for the next
;;; trigger etc might have shiftet. This method aims to update all timers.
(defmethod update-times ((lys layers) current-time current-timer)
(loop for ly in (data lys)
collect (update-times ly current-time current-timer)))
;; *** reset-layers
;;; resets everything to the start of the piece and re-read structure
(defun reset-layers (&optional layers-object)
(setf (data *random-number*) *seed*) ; reset *random-number*
(unless layers-object (setf layers-object *layers*))
(let ((sts '()))
;; re-generate structures
(loop for layer in (data layers-object) do
(unless (member (structure layer) sts)
(push (structure layer) sts)))
(loop for st in sts do
(re-gen-structure st))
;; update each layer, reset some init values
(loop for layer in (data layers-object) do
(reset-layer layer)
(reset-index layer)
(setf (play layer) t)
(setf (current-time layer) 0)))
(setf *next-trigger* 0)
(format t "~&Layers have been reset"))
;; *** reload-layers
;;; even better than a reset. reloads everything
(defun reload-layers (&optional load-all)
(let ((score *score-file*))
(when load-all (load-all))
(if score (load score)
(warn "*score-file* is nil, so no score is loaded after reload-layers"))
nil))
;; *** get-ids
;;; get ids of all stored-files in stored-file-list
(defmethod get-ids ((lys layers))
(loop for ly in (data lys) collect
(get-id ly)))
;;;; EOF layers.lsp
| 8,589 | Common Lisp | .l | 205 | 37.307317 | 98 | 0.660215 | Leon-Focker/layers | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 64b859b43e9b4b1237d49985377722dce160325eab3b1a926e2457588450aea0 | 26,256 | [
-1
] |
26,257 | length-dependant-list.lsp | Leon-Focker_layers/src/length-dependant-list.lsp | ;; ** length-dependant-list
;;;; length-dependant-list object
(in-package :layers)
;; *** length-dependant-list
;;; list of pairs of soundfile-ids and allocated lengths
;;; -> the length of the currently played soundfile decides the next file
(defclass length-dependant-list (list-object)
())
;; *** make-length-dependant-list
;;; make an instance of length-dependant-list
(defun make-length-dependant-list (id ldl)
(make-instance 'length-dependant-list :data ldl :id id))
;;; example:
#|(make-length-dependant-list 'test
'(("/E/test.wav" 0.5)
("/E/test1.wav" 2)
("/E/test2.wav" 10)))|#
;; *** decide-for-snd-file
;;; returns the car of the chosen sublist of a length-dependant-list object
;;; (the id of the next soundfile)
(defmethod decide-for-snd-file ((ldl length-dependant-list) current-length)
(loop for ls in ldl do
(when (> current-length (cadr ls)) (return (car ls)))))
;;;; EOF length-dependant-list.lsp
| 950 | Common Lisp | .l | 24 | 37.125 | 75 | 0.702174 | Leon-Focker/layers | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 90385f487e140ca88d941b04358b4dd82b5b9ff343def8c09cc59cc422f7e2e3 | 26,257 | [
-1
] |
26,258 | stored-file.lsp | Leon-Focker_layers/src/stored-file.lsp | ;; ** stored-file
;;;; storing and categorising soundfiles etc.
(in-package :layers)
;; *** stored-file
;;; a file in the data-base, with certain properties, eg. a markov-list,
;;; which links it to other soundfiles
(defclass stored-file (base-object)
((name :accessor name :initarg :name :initform nil)
(path :accessor path :initarg :path :initform nil)
(markov-list :accessor markov-list :initarg :markov-list
:initform nil)
;; this helps decide the next file dependant on the current play-length
(length-dependant-list :accessor length-dependant-list
:initarg :length-dependant-list
:initform nil)
(preferred-length :accessor preferred-length :initarg :preferred-length
:initform nil)
;; duration in seconds
(duration :accessor duration :initarg :duration :initform 0)
;; duration in samples
(total-samples :accessor total-samples :initarg :total-samples :initform 0)
;; samplerate of the soundfile
(samplerate :accessor samplerate :initarg :samplerate :initform 48000)
(start :accessor start :initarg :start :initform 0)
;; multiplier when playing soundfile back
(amplitude :accessor amplitude :initarg :amplitude :initform 1)
;; loudest sample in the soundfile
(peak :accessor peak :initarg :peak :initform nil)
(peak-index :accessor peak-index :initarg :peak-index :initform 0)
(loop-flag :accessor loop-flag :initarg :loop-flag :initform nil)
(decay :accessor decay :initarg :decay :initform 0)
(panorama :accessor panorama :initarg :panorama :initform 45)
;; analysed, not user set data:
;; spectral centroid
(centroid :accessor centroid :initarg :centroid :initform nil)
;; spectral spread
(spread :accessor spread :initarg :spread :initform nil)
;; spectral flatness
(flatness :accessor flatness :initarg :flatness :initform nil)
;; dominant frequency
(dominant-frequency :accessor dominant-frequency :initarg :dominant-frequency
:initform nil)
;; envelope smoothness
(smoothness :accessor smoothness :initarg :smoothness :initform nil)
;; biggest jump up in the envelope
(transient :accessor transient :initarg :transient :initform nil)
;; position in a 3d coordinate space - can also be used to get next file
(x :accessor x :initarg :x :initform 0.5 :reader x)
(y :accessor y :initarg :y :initform 0.5 :reader y)
(z :accessor z :initarg :z :initform 0.5 :reader z)))
(defmethod print-object ((sf stored-file) stream)
(format stream "<STORED-FILE ~a>" (id sf)))
;; *** setf-markov
;;; sets the markov list of a stored-file
(defmethod setf-markov ((sf stored-file) new-markov-list)
(setf (markov-list sf) new-markov-list))
;; *** create-rest
;;; make a stored-file-list object representing a rest
(defun create-rest () (make-stored-file 'rest "/rest.wav" :markov '() :decay 0))
;;; example
#+nil(make-stored-file
'noisy1
"/rhythmic/noisy/1.wav"
:markov '((noisy1 1)
(noisy2 1)
(noisy3 1)
(noisy4 1)
(noisy5 1))
:decay 10)
;; *** spectral-centroid
;;; dominant frequency, centroid, flatness and spread of soundfile.
;;; (function needs new name?)
;;; file can either be an array or the path to a file
(defun spectral-centroid (file &key fft-size (srate 48000))
(let* ((ar (not (stringp file)))
(srate (if ar srate (clm::sound-srate file)))
(sample-len (if ar (length file) (soundfile-duration file)))
;; if not supplied, fft-size is set to the hightes possible power of two
;; (up until ca. a second)
(fft-size (or fft-size
(loop with num = 1 for i from 1 until (or (> num srate)
(> num sample-len))
finally (return (expt 2 (- i 2)))
do (setf num (* num 2)))))
;; by repeating fft-size/4 times we take into account freqs up to 12kHz
(repeats (/ fft-size 4))
(base-freq (/ srate fft-size))
(arithmetic-mean 0)
(geometric-mean 0)
(a 0)
(b 0)
(c 0)
(d 0)
(e '(0 0))
(m '()))
(setf m (clm::fft-from-file file
:fft-size fft-size
:window clm::hanning-window))
(loop for i from 0 and j in m repeat repeats do
(when (> j (car e)) (setf e (list j (* i base-freq 1.0))))
(incf a (* i base-freq (expt j 2)))
(incf b (expt j 2))
(incf arithmetic-mean j)
(incf geometric-mean (log j)))
(setf arithmetic-mean (/ arithmetic-mean repeats))
(setf geometric-mean (exp (/ geometric-mean repeats)))
(setf c (/ a b))
(loop for i from 0 and j in m repeat repeats do
(incf d (* (expt (- (* i base-freq) c) 2)
(expt j 2))))
(values c ;; centroid
(sqrt (/ d b)) ;; spread
(/ geometric-mean ;; flatness
arithmetic-mean)
(cadr e) ;; dominant frequency
)))
;; *** analyse-soundfile
;;; analyse some basic parameters and write them into the sf-object
(defmethod analyse-soundfile ((sf stored-file) &key fft-size (srate 48000))
;;(clm::play (path sf))
(let* ((array (clm::table-from-file (path sf)))
(envelope (clm::envelope-follower array))
(max (max-of-array-with-index array t)))
(multiple-value-bind (c s f d)
(spectral-centroid array :fft-size fft-size :srate srate)
(setf (centroid sf) c
(spread sf) s
(flatness sf) f
(dominant-frequency sf) d))
(setf (peak sf) (first max))
(setf (peak-index sf) (second max))
(setf (smoothness sf) (flatness-of-list envelope))
(setf (transient sf) (biggest-jump (reduce-by envelope 50))))
sf)
;; *** map-soundfile
;;; map x y z of a soundfile according to analysis
(defmethod map-soundfile ((sf stored-file) &key f1 f2 f3 fft-size)
(setf f1 (or f1 #'(lambda (sf) (/ (log (centroid sf)) 12000))))
(setf f2 (or f2 #'(lambda (sf) (+ (* (/ (log (spread sf)) 12000)
0.5)
(* (flatness sf) 0.5)))))
(setf f3 (or f3 #'(lambda (sf) (+ (* (- 1
(expt (smoothness sf)
0.5))
0.4)
(* (expt (transient sf) 0.7)
0.6)))))
(analyse-soundfile sf :fft-size fft-size)
(setf (x sf) (funcall f1 sf))
(setf (y sf) (funcall f2 sf))
(setf (z sf) (funcall f3 sf))
sf)
;; *** make-stored-file
;;; create an instance of stored-file and config with markov-list etc.
(defun make-stored-file (id relative-path
&key
markov
(decay 100)
(directory *default-sample-dir*)
(start 0)
(amplitude 1)
(panorama 45)
(loop-flag nil)
(preferred-length nil)
(x 0.5)
(y 0.5)
(z 0.5)
analyse)
(let* ((path (format nil "~a~a" directory relative-path)))
(unless (probe-file path)
(warn "~&the file with path ~a does not exist" path))
(let ((sf (make-instance 'stored-file
:id id
:name (pathname-name relative-path)
:path path
:decay decay ; in seconds
:markov-list (make-markov-list nil (or markov
`((,id 1))))
:duration (soundfile-duration path)
:total-samples (soundfile-framples path)
:samplerate (soundfile-samplerate path)
:start start
:amplitude amplitude
:panorama panorama
:loop-flag loop-flag
:preferred-length preferred-length
:x x
:y y
:z z)))
(if analyse (analyse-soundfile sf) sf))))
;; *** check-sanity
(defmethod check-sanity ((sf stored-file) &optional (error-fun #'warn))
(loop for slot in '(path) do
(unless (stringp (funcall slot sf))
(funcall error-fun "weird ~a for stored-file ~a: ~a"
slot (id sf) (funcall slot sf))))
(loop for slot in '(duration total-samples samplerate start amplitude
peak decay centroid spread flatness dominant-frequency
smoothness transient)
do
(unless (or (not (funcall slot sf)) (numberp (funcall slot sf))
(equal (funcall slot sf) 'random))
(funcall error-fun "weird ~a for stored-file ~a: ~a"
slot (id sf) (funcall slot sf))))
(loop for slot in '(x y z) do
(unless (and (numberp (funcall slot sf)) (<= 0 (funcall slot sf) 1))
(funcall error-fun "weird ~a for stored-file ~a: ~a"
slot (id sf) (funcall slot sf))))
(unless (or (not (markov-list sf))
(equal (type-of (markov-list sf)) 'markov-list))
(funcall error-fun "weird ~a for stored-file ~a: ~a"
'markov-list (id sf) (markov-list sf)))
(unless (or (not (LENGTH-DEPENDANT-LIST sf))
(equal (type-of (LENGTH-DEPENDANT-LIST sf))
'LENGTH-DEPENDANT-LIST))
(funcall error-fun "weird ~a for stored-file ~a: ~a"
'LENGTH-DEPENDANT-LIST (id sf) (LENGTH-DEPENDANT-LIST sf)))
(unless (or (not (peak-index sf)) (integerp (peak-index sf)))
(funcall error-fun "weird ~a for stored-file ~a: ~a"
'peak-index (id sf) (peak-index sf)))
(unless (and (numberp (panorama sf)) (<= 0 (panorama sf) 90))
(funcall error-fun "weird ~a for stored-file ~a: ~a"
'panorama (id sf) (panorama sf)))
t)
;; *** make-load-form
(defmethod make-load-form ((sf stored-file) &optional environment)
(declare (ignore environment))
`(make-instance 'stored-file
:id ',(id sf)
:data ',(data sf)
:name ',(name sf)
:path ',(path sf)
:markov-list ,(make-load-file (markov-list sf))
:length-dependant-list ',(length-dependant-list sf)
:preferred-length ',(preferred-length sf)
:duration ',(duration sf)
:total-samples ',(total-samples sf)
:samplerate ',(samplerate sf)
:start ',(start sf)
:amplitude ',(amplitude sf)
:peak ',(peak sf)
:peak-index ',(peak-index sf)
:loop-flag ',(loop-flag sf)
:decay ',(decay sf)
:panorama ',(panorama sf)
:centroid ',(centroid sf)
:spread ',(spread sf)
:flatness ',(flatness sf)
:dominant-frequency ',(dominant-frequency sf)
:smoothness ',(smoothness sf)
:transient ',(transient sf)
:x ',(x sf)
:y ',(y sf)
:z ',(z sf)))
;; *** store-in-text-file
;;; store a sfl in a text file, so the analysis can be skipped by reading in
;;; the soundfiles.
(defmethod store-in-text-file ((sf stored-file) &optional file)
(let* ((file (or file (format nil "~a~a-load-file.txt" *src-dir* (id sf)))))
(sc::write-to-file file (make-load-form sf))
(format t "~&wrote ~a into ~a" (id sf) file)))
;;;; EOF stored-file.lsp
| 10,178 | Common Lisp | .l | 262 | 34.114504 | 80 | 0.646233 | Leon-Focker/layers | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 3280ab127588122fd359ed9a0499404bf7de39bb63ea2d589e409962987e88b3 | 26,258 | [
-1
] |
26,259 | transitions.lsp | Leon-Focker_layers/src/transitions.lsp | ;; * transitions.lsp
;;; Collection of transition-functions, basically a way of generating lists.
;;; These are intended to use as "control data", for example as a
;;; morphing-function in morph-patterns. But of course they can be used in any
;;; way possible.
(in-package :ly)
;; ** fibonacci-transitions
;;; see sc::fibonacci-transitions
;; ** procession
;;; see sc::procession
;; ** kernel-transition
;; *** move-item
;;; move items from a certain index to a new index. This is not achieved
;;; by swapping items! The item is taken from the list and then placed into
;;; the list at the new position.
(defun move-item (list index new-index)
(let ((index (mod index (length list)))
(new-index (mod new-index (length list))))
(unless (= index new-index)
(let* ((min (min index new-index))
(max (max index new-index))
(diff (1+ (- max min)))
(list-head (subseq list 0 min))
(list-tail (nthcdr min list))
(mid '()))
(setf mid (subseq list-tail 0 diff)
mid (if (> index new-index)
(append (last mid) (subseq mid 0 (1- diff)))
(append (cdr mid) (list (first mid))))
list-tail (nthcdr diff list-tail)
list (append list-head mid list-tail))))
list))
;; *** kernel-transitions
;;; unpredictable transition between items
;;; total-items - length of the list of results
;;; levels - either a number (how many different elements)
;;; or a list, with the elements to transition over
;;; kernel - list of numbers, as many numbers as wanted
;;; every number represents items moved to the left (positive) or the right
;;; (negative) during a loop. - Just experiment :D
;;; e - exponent for the list we start with, controls the ratio of items used in
;;; the final list.
;;; Below 1 -> more of the higher levels: 0.5 => (0 0 1 1 1 1)
;;; Above 1 -> more of the lower levels: 2 => (0 0 0 0 0 1)
#|
(kernel-transitions 20 3 '(-3 2 4))
=> (1 1 1 1 0 1 1 2 2 2 2 0 2 0 0 0 0 0 1 2)
|#
(defun kernel-transitions (total-items levels &optional (kernel '(0)) (e 1))
;; make sure that all arguments are valid:
(unless (and (numberp total-items) (numberp e) (listp kernel))
(error "total-items and e must be a number, kernel a list in ~
make-transition but are: ~&~a~&~a~&~a"
total-items e kernel))
(unless (or (numberp levels) (listp levels))
(error "levels must either be a number or a list in make-transition ~
but is: ~&~a" levels))
(let* ((result '())
(total-levels levels))
;; make sure levels is a list and total-levels its length:
(if (numberp levels)
(setf levels (loop for i below levels collect i))
(setf total-levels (length levels)))
;; get a basic transition to then transform:
(setf result
(loop for i below 1 by (/ 1 total-items)
collect (nth (floor (* (expt i e) total-levels)) levels)))
;; move everything around according to kernel:
(loop for i to (1- total-items) do
(loop for j in kernel do
(setf result (move-item result i (- i j)))))
result))
;; ** window-transition
;; *** index-of-min-within-range
;;; get the index of the smallest element in an array,
;;; within a min and max index
(defun index-of-min-within (array &optional (from 0) (to (1- (length array))))
(unless (arrayp array)
(error "index-of-min-within-range didn't get an array as input: ~a" array))
(loop for i from from to (min to (1- (length array)))
with min-i = from with min = (aref array i)
when (< (aref array i) min) do (setf min-i i min (aref array i))
finally (return min-i)))
;; *** window-transitions
;;; make a transition over items, using a sort of window.
;;; total-items - length of the list of results
;;; levels - either a number (how many different elements)
;;; or a list, with the elements to transition over
;;; e - exponent for the list we start with, controls the ratio of items used in
;;; the final list.
;;; Below 1 -> more of the higher levels: 0.5 => (0 0 1 1 1 1)
;;; Above 1 -> more of the lower levels: 2 => (0 0 0 0 0 1)
;;; window-size - controls which items can be chosen at any point. The closer to
;;; 1 it is, the longer will earlier items be chosen. If it is 0, no earlier
;;; item will be chosen.
;;; This controls which items can be chosen at any point. If 0, only the item
;;; at that point in the original sequence is chosen, If 1, all items can be
;;; chosen at the end of the transition.
;;; control-function - this should be a function with two arguments - total-items
;;; and levels, which will be called for the generation of the control-sequence
;;; instead of the linear/exponential standard function. Thus 'e will be ignored.
;;; the function must return a list!
;;; for example 'fibonacci-transitions or 'procession.
#|
EXAMPLE
(window-transitions 20 3)
=> (0 0 0 0 0 0 0 1 1 1 0 1 0 1 2 2 2 0 2 1)
=> #(10 6 4)
|#
(defun window-transitions (total-items levels &optional (e 1) (window-size 0.5)
control-function)
;; make sure that all arguments are valid:
(unless (and (numberp total-items) (numberp e) (numberp window-size)
(>= total-items 0) (>= e 0) (>= window-size 0))
(error "total-items, e and window-size must be a positive number in ~
make-transition but are: ~&~a~&~a~&~a"
total-items e window-size))
(unless (or (numberp levels) (listp levels))
(error "levels must either be a number or a list in make-transition ~
but is: ~&~a" levels))
(let* ((control '())
(window 0)
(weights '())
(spread '())
(total-levels levels))
;; make sure levels is a list and total-levels its length:
(if (numberp levels)
(setf levels (loop for i below levels collect i))
(setf total-levels (length levels)))
;; get actual window, control sequence and initial weights:
(setf window
(round (* window-size total-levels))
control
(if control-function
(funcall control-function total-items total-levels)
(loop for i below 1 by (/ 1 total-items)
;; other control sequences might be fun:
;; collect (* (expt (sin (* i 20)) e) total-levels))
collect (* (expt i e) total-levels)))
weights
(make-array total-levels :initial-element 0)
spread
(make-array total-levels :initial-element 0))
;; *magically* generate the actual result, using window and weights:
(values
(if (= window-size 0)
control
(loop for el in control
for min = (max 0 (floor (- el window)))
for n = (index-of-min-within weights min el)
do (incf (aref weights n) el)
(incf (aref spread n))
collect (nth (floor n) levels)))
spread)))
;; EOF transitions.lsp
| 6,645 | Common Lisp | .l | 155 | 39.277419 | 82 | 0.664969 | Leon-Focker/layers | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 2af37e811625cc8e7c12cef659873ab60472a67fda953cde1e0558314722d7ba | 26,259 | [
-1
] |
26,260 | analysis.lsp | Leon-Focker_layers/src/analysis.lsp | ;; ** analysis
;;;; some functions to analyse soundfiles with clm
(in-package :clm)
(defparameter *separate* (format nil ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;~
;;;;;;;;;;;;;;;;;;;;;;;;"))
(defparameter *layers-buffer* '())
;; *** table-from-file
;;; get an array from a soundfile
(definstrument table-from-file (file &optional start length)
(let ((f (open-input* file)))
(unwind-protect
(let* ((st (or start 0))
(len (mus-length file))
(size (or length (1- len)))
(ar (make-double-array size :initial-element 0.0d0))
(readin0 (make-readin f :start st)))
(unless (< (+ st size) len)
(error "~&start ~a and size ~ too big for file ~
with ~a samples" start size len))
(run*
(ar)
(loop for i below size do
(setf (aref ar i) (readin readin0)))))
(close-input f))))
;; *** fft-from-file
;;; file can be a pathname or an array
(defun fft-from-file (file &key
(fft-size 2048)
(start-sample 0)
(window 0)
visualize)
(let* ((fdr (let* ((frame (make-double-array
fft-size
:initial-contents
(cond ((stringp file)
(table-from-file file start-sample
fft-size))
((arrayp file)
(subseq file
start-sample
(+ start-sample fft-size)))
(t (error "fft-from-file: file is of a weird~
type: ~a" (type-of file)))))))
(ly::multiply-arrays frame (make-fft-window window fft-size))))
(fdi (make-double-array fft-size))
(magnitudes '())
(phases '()))
;; visualize amplitude of file:
(if visualize (progn (ly::visualize fdr)
(terpri)
*separate*))
;; do fft
(fft fdr fdi fft-size 1)
(loop for i below fft-size do
(let ((real (aref fdr i))
(im (aref fdi i)))
(push (sqrt (+ (* real real) (* im im))) magnitudes)
(push (atan (/ im (+ real 0.0000000001d0 ))) phases)))
(setf magnitudes (reverse magnitudes)
phases (reverse phases))
;; visualize magnitues and phases
(if visualize (progn (ly::visualize magnitudes)
(terpri)
*separate*))
(if visualize (ly::visualize phases))
;; output
(values magnitudes
phases
fdr
fdi)))
;; *** envelope-follower-file
;;; returns the envelope of a soundfile
(definstrument envelope-follower-file (file &optional (len 30) (as-list t))
(let ((f (open-input* file)))
(unwind-protect
(let* ((st 0)
(nd (file-frample-count file))
(readin0 (make-readin f :start st))
(fil (make-hilbert-transform len)))
(setf *layers-buffer*
(make-double-array (- nd st) :initial-element 0.0))
(run*
(*layers-buffer*)
(loop for i from st to nd do
(let ((x (readin readin0)))
(setf (aref *layers-buffer* i)
(sqrt (+ (expt x 2)
(expt (fir-filter fil x) 2))))))))
(close-input f))
(if as-list
(loop for i across *layers-buffer* collect i)
*layers-buffer*)))
;; *** envelope-follower-array
;;; returns the envelope of an array as a list
(defun envelope-follower-array (array &optional (len 30))
(let* ((fil (make-hilbert-transform len)))
(loop for x across array collect
(sqrt (+ (expt (fir-filter fil x) 2)
(expt x 2))))))
;; *** envelope-follower
;;; returns the envelope of an array or a soundfile as a list
(defun envelope-follower (file-or-array &optional (len 30))
(typecase file-or-array
(string (envelope-follower-file (probe-file file-or-array)))
(array (envelope-follower-array file-or-array len))
(t (error "envelope-follower needs either and array or a pathname but got:~& ~a: ~a"
(type-of file-or-array) file-or-array))))
| 3,704 | Common Lisp | .l | 107 | 29.028037 | 88 | 0.600279 | Leon-Focker/layers | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | f0ba41ef48c1556df784a6a2f4bfe2d74e22b746ccf4daf782f483591dc87ff6 | 26,260 | [
-1
] |
26,261 | show-structure.lsp | Leon-Focker_layers/src/show-structure.lsp | (ql:quickload :imago)
; (ql:quickload :imago/pngload)
(in-package :imago)
(defun show-structure (structure-list &optional file (size-factor 1))
(let* ((h (* 100 size-factor))
(w (* 1000 size-factor))
(ls (loop for l in structure-list collect
(mapcar (lambda (x) (sc::rescale x
0
(loop for j in l sum j)
0
1))
l)))
(length (length ls))
(height (* h length))
(array (make-array `(,height ,w)))
(n 0)
(sublist '())
(sublength 0)
(index 0)
(color 0)
(element 0)
(name (or file (format nil "~a~a" ly::*src-dir* "structure.png"))))
(loop for y from 0 to (1- height) do
(setf n (floor y h))
(setf sublist (nth n ls))
(setf sublength (length sublist))
(loop for x from 0 to (1- w) do
(setf index (sc::decider (/ x w) sublist))
(setf element (nth index sublist))
(setf color (make-color (floor (* (expt (- 1 (/ element 1)) 15) 255))
(floor (* (/ n length) 100))
(floor (* (/ index sublength) 100)))) ;(/ n length)
(setf (aref array y x) color)
))
(write-png
(make-instance 'rgb-image
:pixels array)
name)
name))
(in-package :layers)
(defmethod visualize-structure ((st structure) &optional file (size-factor 1/2))
(format t "~&visualizing structure: ~a" (id st))
(imago::show-structure (reverse (reverse (data st))) file size-factor))
#|
(ql:quickload :sketch)
(in-package :layers)
(defun show-structure (structure-list)
;(sketch::defsketch structure ())
;(sketch::make-instance 'structure)
(sketch::defsketch structure ((title "structure")
(width 1000)
(height 600))
(loop for ls in structure-list and k from 0 do
(setf ls (mapcar (lambda (x) (sc::rescale x
0
(loop for j in ls sum j)
0
1000))
ls))
(loop for val in ls and last = 0 then (+ last val) and i from 0 do
(sketch::with-pen
(sketch::make-pen :fill
(sketch::lerp-color sketch::+black+ sketch::+white+
(/ val (apply #'max ls))))
(sketch::rect last (* k 100) val 100))))))
|#
;; EOF show-structure.lsp
| 2,119 | Common Lisp | .l | 68 | 26.220588 | 80 | 0.602056 | Leon-Focker/layers | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | f9ab70c78260342ea1bfe9d9e53c95c0d9f26a7443b6f116b43ed475c29bc0cc | 26,261 | [
-1
] |
26,262 | layers-test-suite.lsp | Leon-Focker_layers/tests/layers-test-suite.lsp | ;; * layers test suite
;; this is very sparse for now :)
;; ** functionality
;;; because I don't want to test all of slippery chicken every time but still
;;; use it's testing capabilities, I'm doing the bare minimum here to make a
;;; unique testing suite for layers. this should be replaced with the asdf
;;; testing facilities.
(in-package :ly)
(import '(sc-test-check file-write-ok-multi probe-delete-multi test-suite-file
equal-within-less-tolerance probe-delete file-size file-write-ok)
'slippery-chicken)
(defparameter *ly-test-all-tests* nil)
(load-from-test-suite-dir "sc-test-suite-aux.lsp")
;;; 08.12.2011 SAR: Added a line to push the name of each newly defined test
;;; into the list of all tests
(defmacro ly-deftest (name parameters &body body)
"Define a test function. Within a test function we can call other test
functions or use 'sc-test-check' to run individual test cases."
(unless (member `,name *ly-test-all-tests*) (push `,name *ly-test-all-tests*))
`(defun ,name ,parameters
(let ((sc::*sc-test-name* (append sc::*sc-test-name* (list ',name))))
,@body)))
;;; 08.12.11 SAR: Added a macro to test all tests stored in the
;;; *ly-test-all-tests* list
(defmacro ly-test-test-all ()
"Run all tests whose names are stored within *ly-test-all-tests* (which
should be all tests defined using ly-deftest)"
`(sc::sc-test-combine-results
;; MDE Thu Dec 15 22:54:32 2011 -- reverse so that they run in the order
;; in which they were defined
,@(loop for at in (reverse *ly-test-all-tests*) collect (list at))))
(defun ly-test-next-test (last-test)
(nth (1+ (position last-test *ly-test-all-tests*)) *ly-test-all-tests*))
;; ** base-object.lsp
(ly-deftest base-object ()
(let ((bo (make-instance 'base-object :data '(0 1 2 3 4) :id 'testsuite)))
(sc-test-check
(equal (get-id bo) 'testsuite)
(equal (data bo) '(0 1 2 3 4)))))
;; ** utilities.lsp
(ly-deftest utils ()
(let* ((ls1 '(0 1 2 3 4 5 6 7 8 9))
(ls2 '(0 1 (2) 3 (4 (5) 6) 7))
(ls3 '(0 1 2 4 -1 6 3 4 2)))
(probe-delete (format nil "~a~a" *src-dir* "midi-output.mid"))
(sc-test-check
;; some little helpers:
(equal (remove-nth 3 ls1) '(0 1 2 4 5 6 7 8 9))
(equal (rotate ls1 4) '(4 5 6 7 8 9 0 1 2 3))
;; re-order
(equal (re-order '(a b c d e) '(4 1 3 2 0)) '(e b d c a))
(equal (re-order '(a b c d e) '(3 4 1)) '(d e b a c))
(equal (re-order '(a b c d e) '(2 3 4 6 0 1)) '(c d e b a))
(equal (re-order '(a b c d e) '(0 3 7 0 7 3 5)) '(a d c b e))
(equal (re-order '(a b c d e) '(0 0 0)) '(a b c d e))
;; more small ones
(= (depth ls2) 3)
(= (rqq-depth '(1 ((1 (3)) 1 1))) 1)
(equal (normalize-depth ls2)
'(((0)) ((1)) ((2)) ((3)) ((4) (5) (6)) ((7))))
(= (mirrors 10 1 3) 2)
(equal (get-start-times ls1) '(0 0 1 3 6 10 15 21 28 36))
(equal (get-durations ls1) '(1 1 1 1 1 1 1 1 1))
(equal (avoid-repetition '(0 1 2 2 3 4 2)) '(0 1 2 3 4 2))
(equal (insert '(0 1 2 3 4 5 6 7 8 9) 5 22) '(0 1 2 3 4 22 5 6 7 8 9))
(equal (insert-multiple '(0 1 2 3 4 5) '(2 4 2 2 1) '(a b c d e))
'(0 E 1 A C D 2 3 B 4 5))
(= (dry-wet 3 5 .2) 3.4)
(= (biggest-jump ls3) 7)
(= (biggest-jump-up ls3) 7)
(= (biggest-jump-down ls3) 5)
(equal (reduce-by ls1 2)
'(1/2 5/2 9/2 13/2 17/2))
;; beat prox:
(= (get-beat-prox 0) 0)
(= (get-beat-prox 1) 0)
(= (beat-proximity .66) 3)
(= (thomaes-function .66 10) 8)
(equal (loop for i from 0 to 1 by .125 collect (beat-proximity i))
'(0 3 2 3 1 3 2 3 0))
;; indispensability:
(equal (loop for i from 0 to 1 by 0.125 collect
(funcall (rqq-to-indispensability-function
'(2 ((2 ((2 (1 1)) (2 (1 1))))
(2 ((2 (1 1)) (2 (1 1)))))))
i))
'(0 7 3 5 1 6 2 4 0))
(equal (loop for i from 0 to 1 by 0.125 collect
(funcall (rqq-to-indispensability-function
'(8 (1 1 1 1 1 1 1 1)))
i))
'(0 7 6 5 4 3 2 1 0))
;; list-interp
(equal (loop for i from 1 to 9 by .4 collect
(list-interp i '(0 1 2 3 4 5 6 7 8 9)))
'(1 1.3999999 1.8 2.2 2.6000001 3.0000005 3.4000003
3.8000002 4.2000003 4.6000004 5.0 5.4000006 5.8000007
6.200001 6.600001 7.000001 7.400001 7.800001
8.200001 8.6 9))
;; list-into-function
(= (funcall (list-to-function '(1 2 3) 1) .5) 2)
;; lists-into-envelopes
(equal (lists-to-envelopes '(0 1 2 0 3 0.2 4 5 6 1)
'(0 1 2 3 4 5 6 7 8 9))
'((0 0 1 1 2 2) (0 3 3 4) (0.2 5 4 6 5 7 6 8) (1 9)))
;; function-to-env
(equal (make-function-into-env #'sin)
'(0 0.0 0.1 0.09983342 0.2 0.19866933 0.3 0.29552022 0.4 0.38941833
0.5 0.47942555 0.6 0.5646425 0.70000005 0.6442177 0.8000001
0.71735615 0.9000001 0.783327))
(equal (function-to-env #'(lambda (x) (1+ x)) 0 20 1)
'(0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14
14 15 15 16 16 17 17 18 18 19 19 20 20 21))
;; flatness
(= (flatness-of-list '(0 1 2 3 4 5 6 7 8 9)) 0.2008)
;; midi (the test files should be written to tmp...)
(lists-to-midi '(e3 54 c2) '(1) '(1 5) :velocity-list '(.1 .4 .8))
(file-write-ok (format nil "~a~a" *src-dir* "midi-output.mid"))
(equal (midi-file-to-list (format nil "~a~a" *src-dir* "midi-output.mid"))
'((1.0 52 1.0 0.09448819 0 2.0) (1.0 36 1.0 0.79527557 0 2.0)
(5.0000005 54 1.0 0.39370078 0 6.0000005)))
;;
(= (distance-between-points (vector 3 5 1) (vector 0 0 0)) 5.91608)
(= (max-of-array (vector 0 3 6 2 6 1 -9) t) 9)
(equal (max-of-array-with-index (vector 0 3 6 2 6 1 -9) t) '(-9 6))
(= (get-spectral-centroid '((440 0.5) (630 0.46) (880 0.25))) 603.1405)
)
(probe-delete (format nil "~a~a" *src-dir* "midi-output.mid"))))
;; ** morph.lsp
(ly-deftest test-morph ()
(let* ((pts1 '((1 1 (1) 1 1 (1)) ((1) 1 1 (1) 1)))
(pts2 '((2 3 4) (5 (6) 7) (8 (9) (0))))
(pts3 '((2 3) (4 5 (6) 7) (8 (9) (0)))))
(sc-test-check
(= 0 (mod1 0))
(= .5 (mod1 1.5))
(= 1 (mod1 2))
;; morph-patterns
(equal (patterns-to-rhythms-list pts1) '((1 1 1 1 1 1) (1 1 1 1 1)))
(equal (morph-patterns pts2 25) '(2 3 (6) 3 7 3 (1)))
(equal (morph-patterns pts2 0 t t 10) '(2 3 (6) 3 4 2 5 (6) 7 5))
(equal (morph-patterns pts2 0 t t 10 t)
'((0 0) (0 1) (1 1) (0 1) (0 2) (0 0) (1 0) (1 1) (1 2) (1 0)))
(equal (morph-patterns pts3 25 nil nil nil nil
(list-to-function '(0 4 5 2 3) 1))
'(2 4 5 (6) 7 1))
;; interpolate-patterns
(equal (interpolate-patterns pts2 25)
'(2 87/25 3322/625 71732/15625 (2614317/390625)
(15975862/9765625) 12552463/9765625))
(equal (interpolate-patterns pts3 25 t '(2 1)
'((0 0 1 1) (0 .2) (0 2 .5 1 1 0.1)))
'(2 114085069/33554432 3573547/1048576 2144933511/419430400
80530637/33554432 27468205/8388608 (17571859529/2621440000)))
(equal (interpolate-patterns pts3 25 t '(2 1)
'((0 0 1 1) (0 .2) (0 2 .5 1 1 0.1)) 10)
'(2 114085069/33554432 7549747/2097152 24/5 80530637/33554432
34393293/8388608 (28/5) 248302797/33554432 3355443/1048576
71/10))
(equal (interpolate-envelopes '((0 1 .5 1 1 1) (0 0 .2 3 3 0)
(0 1 .2 4 1 1))
24)
'((0 1 3984589/8388608 7/6 4/3 5/6)
(0 3/4 13421773/33554432 5/3 11/6 7/12)
(0 1/2 5452595/16777216 13/6 7/3 1/3)
(0 1/4 1/4 8/3 17/6 1/12)
(0 0 13421773/67108864 37/12 8/3 1/6)
(0 1/4 6710887/33554432 10/3 13/6 5/12)
(0 1/2 13421773/67108864 43/12 5/3 2/3)
(0 3/4 13421773/67108864 23/6 7/6 11/12)))
)))
(ly-deftest test-combine-envelopes ()
(sc-test-check
(equal (combine-envelopes '((0 0 1 1) (0 3 5 3)) '(5 5))
'(0.0 0 5.0 1 5.0001 3 10.0 3))))
;; EOF layers-test-suite.lsp
| 7,947 | Common Lisp | .l | 176 | 39.352273 | 80 | 0.570286 | Leon-Focker/layers | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 467c6fb0bca30bd21848ee7b8330fed7a8ede21687d211a48421fa443dcd9b62 | 26,262 | [
-1
] |
26,263 | example.lsp | Leon-Focker_layers/scores/example.lsp | ;;; if you want to listen to something in real time, open the pure data patch:
;;; ".../layers/pd/Layers.pd"
;;; load layers and set this file to current score file:
(unless (find-package 'ly)
#-(or win32 win64)(load "/E/code/layers/src/all.lsp") ; set to correct path
#+(or win32 win64)(load "e:/code/layers/src/all.lsp"))
(in-package :ly)
(setf *score-file* *load-pathname*)
;;; load soundfiles:
(load-from-same-dir "stored-files.lsp") ; fill in with your own samples!
;;; make structure:
(defparameter *structure*
(make-fractal-structure '(2)
'((1 ((2 2)))
(2 ((1 1))))
'((1 1)
(2 1))
:smallest 1))
;;; define each layer:
(defparameter *layer1* (make-layer '1 *drums* *structure* 0 45))
(defparameter *layer2* (make-layer '2 *drums* *structure* 1 45))
(defparameter *layer3* (make-layer '3 *drumloops* *structure* 0 45))
(defparameter *layer4* (make-layer '4 *background* *structure* 4 0))
(defparameter *layer5* (make-layer '5 *background* *structure* 3 90))
;;; define layers-object:
(defparameter *layers*
(make-layers 'layers (list *layer1* *layer2* *layer3* *layer4* *layer5*)))
(start-osc)
;; EOF example.lsp
| 1,163 | Common Lisp | .l | 29 | 37.551724 | 78 | 0.677966 | Leon-Focker/layers | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 37178cb181c5fbd74369f15a20a103009ab4de8fc792763bbac7b4f6de00da12 | 26,263 | [
-1
] |
26,264 | no-input.lsp | Leon-Focker_layers/scores/no-input.lsp | (in-package :sc)
;;; load soundfiles:
(load "/E/code/layers/src/layers.lsp")
;; * stored files
;; ** accents
(defparameter *accents* (make-stored-file-list 'accents '()))
(store-file-in-list (create-rest) *accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent1
"/no-input/accents/accent1.wav"
'((rest 3)
(accent1 0)
(accent2 1)
(accent3 3)
(accent4 3)
(accent5 1)
(accent6 1)
(accent7 1)
(accent8 1)
(accent9 3))
0.5
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length '(0.3 5))
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent2
"/no-input/accents/accent2.wav"
'((rest 0)
(accent1 1)
(accent2 1)
(accent3 1)
(accent4 3)
(accent5 3)
(accent6 3)
(accent7 5)
(accent8 3)
(accent9 1))
0.1
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length '(0.2 0.5))
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent3
"/no-input/accents/accent3.wav"
'((rest 1)
(accent1 3)
(accent2 1)
(accent3 1)
(accent4 1)
(accent5 1)
(accent6 1)
(accent7 3)
(accent8 4)
(accent9 3))
0.1
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length '(0.8 1.5))
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent4
"/no-input/accents/accent4.wav"
'((rest 2)
(accent1 3)
(accent2 2)
(accent3 1)
(accent4 0)
(accent5 1)
(accent6 1)
(accent7 1)
(accent8 1)
(accent9 2))
0.7
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length nil)
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent5
"/no-input/accents/accent5.wav"
'((rest 5)
(accent1 1)
(accent2 1)
(accent3 1)
(accent4 1)
(accent5 5)
(accent6 1)
(accent7 4)
(accent8 1)
(accent9 1))
0.2
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length '(0.4 3))
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent6
"/no-input/accents/accent6.wav"
'((rest 2)
(accent1 1)
(accent2 1)
(accent3 3)
(accent4 1)
(accent5 1)
(accent6 1)
(accent7 1)
(accent8 1)
(accent9 3))
0.2
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length '(0.3 2))
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent7
"/no-input/accents/accent7.wav"
'((rest 3)
(accent1 2)
(accent2 2)
(accent3 2)
(accent4 0)
(accent5 1)
(accent6 0)
(accent7 1)
(accent8 0)
(accent9 2))
0.3
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length '(0.2 0.45))
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent8
"/no-input/accents/accent8.wav"
'((rest 3)
(accent1 1)
(accent2 1)
(accent3 1)
(accent4 4)
(accent5 1)
(accent6 1)
(accent7 1)
(accent8 1)
(accent9 1))
0.2
:loop-flag t
:start 'random
:panorama 'random
:preferred-length '(0.2 5))
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent9
"/no-input/accents/accent9.wav"
'((rest 2)
(accent1 4)
(accent2 1)
(accent3 1)
(accent4 1)
(accent5 1)
(accent6 1)
(accent7 1)
(accent8 5)
(accent9 1))
0.5
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length nil)
*accents*)
;; ** transformations
(defparameter *transformations* (make-stored-file-list 'transformations '()))
;; (store-file-in-list (create-rest) *transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation1
"/no-input/transformations/transformation1.wav"
'((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
15
:loop-flag t
:preferred-length '(12 34))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation2
"/no-input/transformations/transformation2.wav"
'((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
5
:loop-flag t
:preferred-length '(16 30))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation3
"/no-input/transformations/transformation3.wav"
'((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
5
:loop-flag t
:preferred-length '(2 42))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation4
"/no-input/transformations/transformation4.wav"
'((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
3
:loop-flag t
:preferred-length '(8 12.5))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation5
"/no-input/transformations/transformation5.wav"
'((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
4
:loop-flag t
:preferred-length '(5 20))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation6
"/no-input/transformations/transformation6.wav"
'((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
20
:loop-flag t
:preferred-length '(10 50))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation7
"/no-input/transformations/transformation7.wav"
'((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
5
:loop-flag t
:preferred-length '(20 40))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation8
"/no-input/transformations/transformation8.wav"
'((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
2
:loop-flag t
:preferred-length '(2 20))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation9
"/no-input/transformations/transformation9.wav"
'((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
6
:loop-flag t
:preferred-length '(1 8))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation10
"/no-input/transformations/transformation10.wav"
'((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
3
:loop-flag t
:preferred-length '(15 25))
*transformations*)
;; ** set alternate-sfls
(set-alternate-sfls *accents* 0 6 *accents* *transformations*)
(set-alternate-sfls *transformations* 2 100 *accents* *transformations*)
;; * structure
;;; make structure:
(defparameter *structure*
(make-structure '(2)
'((1 ((2 1)))
(2 ((3 1 3)))
(3 ((2))))
'((1 1)
(2 5)
(3 .2))))
(defparameter *structure1*
(make-structure '(2)
'((1 ((1 2)))
(2 ((3 1 3)))
(3 ((1 1 3 1))))
'((1 1)
(2 4)
(3 .2))))
(defparameter *structure2*
(scale-biggest-value-to
(make-structure '(1)
'((1 ((1 2 3 1 2 2 4 3)))
(2 ((2 1 4 2)))
(3 ((1 2 2 3 1)))
(4 ((2 1 3))))
`((1 ,(/ 3 2))
(2 1)
(3 1)
(4 1))
:id "rhythmen"
:type 'compartmentalise
:smallest 0.05)
0.25))
;; * layers
;;; define each layer:
(defparameter *layer1* (make-layer '1 *accents* *structure2* 0 45 nil))
(defparameter *layer2* (make-layer '2 *accents* *structure2* 1 45 nil))
(defparameter *layer3* (make-layer '3 *accents* *structure2* 0 45))
(defparameter *layer4* (make-layer '4 *transformations* *structure2* 3 0))
(defparameter *layer5* (make-layer '5 *transformations* *structure2* 2 90))
;;;define layers-object:
(defparameter *layers*
(make-layers 'layers (list *layer1* *layer2* *layer3* *layer4* *layer5*)))
| 9,531 | Common Lisp | .l | 445 | 17.705618 | 77 | 0.635138 | Leon-Focker/layers | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 91d29ffe914dcbefb5ba7fa81e8d4b6740a06dc600eac0d4f4f706807e545fb7 | 26,264 | [
-1
] |
26,265 | piece.lsp | Leon-Focker_layers/scores/piece.lsp | ;;; load layers and set this file to current score file:
(unless (find-package 'ly)
#-(or win32 win64)(load "/E/code/layers/src/all.lsp")
#+(or win32 win64)(load "e:/code/layers/src/all.lsp"))
(in-package :ly)
(setf *score-file* *load-pathname*)
;;; load soundfiles:
(load-from-same-dir "stored-files.lsp")
;;; make structure:
(defparameter *structure*
(make-fractal-structure '(2)
'((1 ((2 1)))
(2 ((3 1 3)))
(3 ((2))))
'((1 1)
(2 5)
(3 .2))))
(defparameter *structure1*
(make-fractal-structure '(2)
'((1 ((1 2)))
(2 ((3 1 3)))
(3 ((1 1 3 1))))
'((1 1)
(2 4)
(3 .2))))
(defparameter *structure2*
(make-fractal-structure '(2)
'((1 ((2 2)))
(2 ((1 1))))
'((1 1)
(2 1))
:smallest 1))
;;; define each layer:
(defparameter *layer1* (make-layer '1 *drums* *structure2* 0 45))
(defparameter *layer2* (make-layer '2 *drums* *structure2* 1 45))
(defparameter *layer3* (make-layer '3 *drumloops* *structure2* 0 45))
(defparameter *layer4* (make-layer '4 *background* *structure2* 4 0))
(defparameter *layer5* (make-layer '5 *background* *structure2* 3 90))
;;;define layers-object:
(defparameter *layers*
(make-layers 'layers (list *layer1* *layer2* *layer3* *layer4* *layer5*)))
| 1,284 | Common Lisp | .l | 41 | 27.560976 | 76 | 0.608943 | Leon-Focker/layers | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | fbd1500a9669cd63c4e8f1c63c4ab256c1ecceb41fb916d2e9aa7a254d54ec24 | 26,265 | [
-1
] |
26,266 | test.lsp | Leon-Focker_layers/scores/test.lsp | (in-package :ly)
;;; load layers and set this file to current score file:
(unless (fboundp 'ly::layers-has-been-loaded)
(load "/E/code/layers/src/all.lsp"))
(setf *score-file* *load-pathname*)
;; * stored files
;; ** glitch
(defparameter *glitch* (make-stored-file-list 'glitch '()))
(defparameter *glitch-txt* "/E/code/layers/scores/glitch.txt")
(if (probe-file *glitch-txt*)
(progn
(folder-to-stored-file-list *glitch*
"/E/code/layers/samples/one-shots/glitch/"
:decay 100
:auto-map t
:auto-scale-mapping t
:remap t)
(store-in-text-file *glitch* *glitch-txt*))
(setf *glitch* (load-from-file *glitch-txt*)))
(defparameter *one-shots* (make-stored-file-list 'one-shots '()))
(folder-to-stored-file-list *one-shots*
"/E/code/layers/samples/one-shots/bass/"
:decay 100
:auto-map t)
(folder-to-stored-file-list *one-shots*
"/E/code/layers/samples/one-shots/breath/"
:decay 100
:auto-map t)
(folder-to-stored-file-list *one-shots*
"/E/code/layers/samples/one-shots/drums/"
:decay 100
:auto-map t)
(folder-to-stored-file-list *one-shots*
"/E/code/layers/samples/one-shots/glitch/"
:decay 100
:auto-map t)
(folder-to-stored-file-list *one-shots*
"/E/code/layers/samples/one-shots/whispers/"
:decay 100
:auto-map t)
(auto-scale-mapping *one-shots* :remap t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defparameter *drums1* (make-stored-file-list 'drums1 '()))
(folder-to-stored-file-list *drums1*
"/E/code/layers/samples/one-shots/drums/"
:decay 100
:auto-map t
:auto-scale-mapping t
:remap t)
;; ** snare
(defparameter *snare* (make-stored-file-list 'snare '()))
;;#################
(store-file-in-list
(make-stored-file
'snare
"/one-shots/drums/snare.wav"
:markov '((snare 1))
:decay 4.0
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5))
*snare*)
;; ** drums
(defparameter *drums* (make-stored-file-list 'drums '()))
;;(store-file-in-list (create-rest) *drums*)
;;#################
(store-file-in-list
(make-stored-file
'kick1
"/one-shots/drums/kick1.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0
:y 0
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'kick2
"/one-shots/drums/kick2.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.35
:y 0
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'kick3
"/one-shots/drums/kick3.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.7
:y 0
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'kick4
"/one-shots/drums/kick4.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 1
:y 0
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'snare1
"/one-shots/drums/snare1.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0
:y 0.3
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'snare2
"/one-shots/drums/snare2.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.35
:y 0.5
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'snare3
"/one-shots/drums/snare3.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.7
:y 0.7
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'snare4
"/one-shots/drums/snare4.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 1
:y 1
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'hat1
"/one-shots/drums/hat1.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.2
:y 0.2
:z 0.5)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'hat2
"/one-shots/drums/hat2.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.4
:y 0.4
:z 0.6)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'hat3
"/one-shots/drums/hat3.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.7
:y 0.7
:z 0.7)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'hat4
"/one-shots/drums/hat4.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.8
:y 0.8
:z 0.9)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'ride1
"/one-shots/drums/ride1.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0
:y 0
:z 1)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'ride2
"/one-shots/drums/ride2.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0
:y 1
:z 1)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'ride3
"/one-shots/drums/ride3.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 1
:y 0
:z 1)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'ride4
"/one-shots/drums/ride4.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 1
:y 1
:z 1)
*drums*)
#|
;; ** accents
(defparameter *accents* (make-stored-file-list 'accents '()))
(store-file-in-list (create-rest) *accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent1
"/no-input/accents/accent1.wav"
:markov '((rest 3)
(accent1 0)
(accent2 1)
(accent3 3)
(accent4 3)
(accent5 1)
(accent6 1)
(accent7 1)
(accent8 1)
(accent9 3))
:decay 0.5
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length '(0.3 5))
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent2
"/no-input/accents/accent2.wav"
:markov '((rest 0)
(accent1 1)
(accent2 1)
(accent3 1)
(accent4 3)
(accent5 3)
(accent6 3)
(accent7 5)
(accent8 3)
(accent9 1))
:decay 0.1
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length '(0.2 0.5))
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent3
"/no-input/accents/accent3.wav"
:markov '((rest 1)
(accent1 3)
(accent2 1)
(accent3 1)
(accent4 1)
(accent5 1)
(accent6 1)
(accent7 3)
(accent8 4)
(accent9 3))
:decay 0.1
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length '(0.8 1.5))
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent4
"/no-input/accents/accent4.wav"
:markov '((rest 2)
(accent1 3)
(accent2 2)
(accent3 1)
(accent4 0)
(accent5 1)
(accent6 1)
(accent7 1)
(accent8 1)
(accent9 2))
:decay 0.7
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length nil)
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent5
"/no-input/accents/accent5.wav"
:markov '((rest 5)
(accent1 1)
(accent2 1)
(accent3 1)
(accent4 1)
(accent5 5)
(accent6 1)
(accent7 4)
(accent8 1)
(accent9 1))
:decay 0.2
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length '(0.4 3))
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent6
"/no-input/accents/accent6.wav"
:markov '((rest 2)
(accent1 1)
(accent2 1)
(accent3 3)
(accent4 1)
(accent5 1)
(accent6 1)
(accent7 1)
(accent8 1)
(accent9 3))
:decay 0.2
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length '(0.3 2))
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent7
"/no-input/accents/accent7.wav"
:markov '((rest 3)
(accent1 2)
(accent2 2)
(accent3 2)
(accent4 0)
(accent5 1)
(accent6 0)
(accent7 1)
(accent8 0)
(accent9 2))
:decay 0.3
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length '(0.2 0.45))
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent8
"/no-input/accents/accent8.wav"
:markov '((rest 3)
(accent1 1)
(accent2 1)
(accent3 1)
(accent4 4)
(accent5 1)
(accent6 1)
(accent7 1)
(accent8 1)
(accent9 1))
:decay 0.2
:loop-flag t
:start 'random
:panorama 'random
:preferred-length '(0.2 5))
*accents*)
;;#################
(store-file-in-list
(make-stored-file
'accent9
"/no-input/accents/accent9.wav"
:markov '((rest 2)
(accent1 4)
(accent2 1)
(accent3 1)
(accent4 1)
(accent5 1)
(accent6 1)
(accent7 1)
(accent8 5)
(accent9 1))
:decay 0.5
:loop-flag nil
:start 'random
:panorama 'random
:preferred-length nil)
*accents*)
;; ** transformations
(defparameter *transformations* (make-stored-file-list 'transformations '()))
;; (store-file-in-list (create-rest) *transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation1
"/no-input/transformations/transformation1.wav"
:markov '((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
:decay 15
:loop-flag t
:preferred-length '(12 34))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation2
"/no-input/transformations/transformation2.wav"
:markov '((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
:decay 5
:loop-flag t
:preferred-length '(16 30))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation3
"/no-input/transformations/transformation3.wav"
:markov '((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
:decay 5
:loop-flag t
:preferred-length '(2 42))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation4
"/no-input/transformations/transformation4.wav"
:markov '((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
:decay 3
:loop-flag t
:preferred-length '(8 12.5))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation5
"/no-input/transformations/transformation5.wav"
:markov '((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
:decay 4
:loop-flag t
:preferred-length '(5 20))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation6
"/no-input/transformations/transformation6.wav"
:markov '((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
:decay 20
:loop-flag t
:preferred-length '(10 50))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation7
"/no-input/transformations/transformation7.wav"
:markov '((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
:decay 5
:loop-flag t
:preferred-length '(20 40))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation8
"/no-input/transformations/transformation8.wav"
:markov '((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
:decay 2
:loop-flag t
:preferred-length '(2 20))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation9
"/no-input/transformations/transformation9.wav"
:markov '((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
:decay 6
:loop-flag t
:preferred-length '(1 8))
*transformations*)
;;#################
(store-file-in-list
(make-stored-file
'transformation10
"/no-input/transformations/transformation10.wav"
:markov '((rest 0)
(transformation1 1)
(transformation2 1)
(transformation3 1)
(transformation4 1)
(transformation5 1)
(transformation6 1)
(transformation7 1)
(transformation8 1)
(transformation9 1)
(transformation10 1))
:decay 3
:loop-flag t
:preferred-length '(15 25))
*transformations*)
|#
;; * structure
;;; make structure:
(defparameter *structure*
(make-structure '(2)
'((1 ((2 2)))
(2 ((1 1))))
'((1 1)
(2 1))
:id "test"
:type 'compartmentalise
:smallest 0.5))
(defparameter *structure1*
(make-structure '(2)
'((1 ((1 2)))
(2 ((3 1 3)))
(3 ((1 1 3 1))))
'((1 1)
(2 4)
(3 .2))
:type 'lindenmayer))
;; * layers
;;; define each layer:
(defparameter *layer1* (make-layer '1 *drums1* *structure1* 2 0 nil))
(defparameter *layer2* (make-layer '2 *drums1* *structure1* 2 90 nil))
(defparameter *layer3* (make-layer '3 *glitch* *structure1* 0 90))
(defparameter *layer4* (make-layer '4 *glitch* *structure1* 1 0))
(defparameter *layer5* (make-layer '5 *one-shots* *structure1* 2 45))
;;;define layers-object:
(setf *layers*
(make-layers 'layers (list *layer1* *layer2* *layer3* *layer4* *layer5*)))
| 14,923 | Common Lisp | .l | 717 | 17.401674 | 80 | 0.625575 | Leon-Focker/layers | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 25077f2d660a97ca111022dd14c37617b63b1bcd52811f17ecc230a1db9cf9b5 | 26,266 | [
-1
] |
26,267 | stored-files.lsp | Leon-Focker_layers/scores/stored-files.lsp | (in-package :ly)
;; * stored files
;; ** chords
(defparameter *chords* (make-stored-file-list 'chords '()))
(folder-to-stored-file-list
*chords*
"/E/code/layers/samples/chords/organ/normal"
:markov-list '((rest 2)
(organchord-whining-3 0.5)
(organchord-whining-4 1.5))
:decay 20)
(folder-to-stored-file-list
*chords*
"/E/code/layers/samples/chords/organ/whining"
:markov-list '((rest 2)
(organchord1 1)
(organchord4 0.5))
:decay 20)
;; add a rest
(store-file-in-list (create-rest) *chords*)
;; ** noisy
(defparameter *noisy* (make-stored-file-list 'noisy '()))
(store-file-in-list (create-rest) *noisy*)
(store-file-in-list
(make-stored-file
'noisy1
"/rhythmic/noisy/1.wav"
:markov '((rest 2)
(noisy1 1)
(noisy2 1)
(noisy3 1)
(noisy4 1)
(noisy5 1))
:start 0
:loop-flag 1)
*noisy*)
(store-file-in-list
(make-stored-file
'noisy2
"/rhythmic/noisy/2.wav"
:markov '((rest 2)
(noisy1 1)
(noisy2 1)
(noisy3 1)
(noisy4 1)
(noisy5 1))
:start 0
:loop-flag 1)
*noisy*)
(store-file-in-list
(make-stored-file
'noisy3
"/rhythmic/noisy/3.wav"
:markov '((rest 2)
(noisy1 1)
(noisy2 1)
(noisy3 1)
(noisy4 1)
(noisy5 1))
:start 0
:loop-flag 1)
*noisy*)
(store-file-in-list
(make-stored-file
'noisy4
"/rhythmic/noisy/4.wav"
:markov '((rest 2)
(noisy1 1)
(noisy2 1)
(noisy3 1)
(noisy4 1)
(noisy5 1))
:start 0
:loop-flag 1)
*noisy*)
(store-file-in-list
(make-stored-file
'noisy5
"/rhythmic/noisy/5.wav"
:markov '((rest 2)
(noisy1 1)
(noisy2 1)
(noisy3 1)
(noisy4 1)
(noisy5 1))
:start 0
:loop-flag 1)
*noisy*)
;; ** background
(defparameter *background* (make-stored-file-list 'bg '()))
(store-file-in-list (create-rest) *background*)
(store-file-in-list
(make-stored-file
'atmo-bass-conv-organ
"/background/atmo/bass-conv-organ.wav"
:markov '((rest 1)
(atmo-bass-conv-organ 1)
(atmo-organ-conv-organ 1)
(atmo-whiningOrgan-long 1)
(atmo-whiningOrgan-long1 1)
(atmo-piano 2)
(atmo-piano1 1)
(atmo-piano2 1)
(atmo-drone-gnarly 1)
(digital-asmr 1)
(phrases-piccolo 1))
:start 20
:loop-flag 1)
*background*)
(store-file-in-list
(make-stored-file
'atmo-organ-conv-organ
"/background/atmo/organ-conv-organ.wav"
:markov '((atmo-organ-conv-organ 3)
(atmo-bass-conv-organ 1)
(atmo-whiningOrgan-long 1)
(atmo-piano 1)
(atmo-drone-gnarly 1)
(digital-asmr 1)
(phrases-piccolo 1))
:start 20)
*background*)
(store-file-in-list
(make-stored-file
'atmo-whiningOrgan-long
"/background/atmo/whiningOrgan-long.wav"
:markov '((atmo-whiningOrgan-long 2)
(atmo-whiningOrgan-long1 1)
(atmo-bass-conv-organ 1)
(atmo-organ-conv-organ 1)
(atmo-piano 1)
(rest 0.5)
(atmo-drone-gnarly 1)
(digital-asmr 1)
(phrases-piccolo 1))
:start 20
:loop-flag 1)
*background*)
(store-file-in-list
(make-stored-file
'atmo-whiningOrgan-long1
"/background/atmo/whiningOrgan-long1.wav"
:markov '((atmo-whiningOrgan-long 0.5)
(atmo-bass-conv-organ 1)
(atmo-organ-conv-organ 1)
(atmo-piano 1)
(rest 0.5)
(atmo-drone-gnarly 1)
(digital-asmr 1)
(phrases-piccolo 1))
:start 20
:loop-flag 1)
*background*)
(store-file-in-list
(make-stored-file
'atmo-piano
"/background/atmo/piano.wav"
:markov '((atmo-piano 4)
(atmo-piano1 2)
(atmo-piano2 2)
(rest 3)
(atmo-bass-conv-organ 1)
(atmo-organ-conv-organ 1)
(atmo-whiningOrgan-long 1)
(atmo-whiningOrgan-long1 1)
(atmo-piano 2)
(atmo-drone-gnarly 1)
(digital-asmr 1)
(phrases-piccolo 1))
:start 20
:loop-flag 1)
*background*)
(store-file-in-list
(make-stored-file
'atmo-piano1
"/background/atmo/piano1.wav"
:markov '((atmo-piano 4)
(rest 3)
(atmo-bass-conv-organ 1)
(atmo-organ-conv-organ 1)
(atmo-whiningOrgan-long 1)
(atmo-whiningOrgan-long1 1))
:start 20
:loop-flag 1)
*background*)
(store-file-in-list
(make-stored-file
'atmo-piano2
"/background/atmo/piano2.wav"
:markov '((atmo-piano1 4)
(rest 3)
(atmo-bass-conv-organ 1)
(atmo-organ-conv-organ 1)
(atmo-whiningOrgan-long 1)
(atmo-whiningOrgan-long1 1))
:start 20
:loop-flag 1)
*background*)
(store-file-in-list
(make-stored-file
'phrases-piccolo
"/phrases/piccolo.wav"
:markov '((atmo-bass-conv-organ 1)
(atmo-organ-conv-organ 1)
(atmo-whiningOrgan-long 1)
(atmo-whiningOrgan-long1 1)
(atmo-drone-gnarly 1)
(atmo-piano 1)
(digital-asmr 1))
:start 20
:loop-flag 1)
*background*)
(store-file-in-list
(make-stored-file
'digital-asmr
"/background/digital/asmr.wav"
:markov '((rest 2)
(atmo-bass-conv-organ 1)
(atmo-organ-conv-organ 1)
(atmo-whiningOrgan-long 1)
(atmo-piano 1)
(atmo-drone-gnarly 1)
(phrases-piccolo 1))
:start 20
:loop-flag 1)
*background*)
(store-file-in-list
(make-stored-file
'atmo-drone-gnarly
"/background/atmo/drone-gnarly.wav"
:markov '((atmo-piano 4)
(rest 3)
(atmo-bass-conv-organ 1)
(atmo-organ-conv-organ 1)
(atmo-whiningOrgan-long 1)
(atmo-piano 2)
(digital-asmr 1)
(phrases-piccolo 1))
:start 20
:loop-flag 1)
*background*)
;; ** bass
(defparameter *bass* (make-stored-file-list 'bass '()))
(store-file-in-list (create-rest) *bass*)
(store-file-in-list
(make-stored-file
'bass-1
"/one-shots/bass/bass-1.wav"
:markov '((rest 5)
(bass-1 0.5)
(bass-2 2)
(bass-4 2)
(bass-5 2))
:start 0.5)
*bass*)
(store-file-in-list
(make-stored-file
'bass-2
"/one-shots/bass/bass-2.wav"
:markov '((rest 3)
(bass-1 1)
(bass-2 2)
(bass-3 3))
:start 0.5)
*bass*)
(store-file-in-list
(make-stored-file
'bass-3
"/one-shots/bass/bass-3.wav"
:markov '((rest 4)
(bass-3 3)
(bass-5 3)
(bass-1 3))
:start 0.5)
*bass*)
(store-file-in-list
(make-stored-file
'bass-4
"/one-shots/bass/bass-4.wav"
:markov '((rest 3)
(bass-1 1)
(bass-2 2)
(bass-4 2)
(bass-5 1))
:start 0.5)
*bass*)
(store-file-in-list
(make-stored-file
'bass-5
"/one-shots/bass/bass-5.wav"
:markov '((rest 3)
(bass-5 4)
(bass-4 3)
(bass-5 4))
:start 0.5)
*bass*)
(store-file-in-list
(make-stored-file
'bass-6
"/one-shots/bass/bass-6.wav"
:markov '((rest 1)
(bass-1 2)
(bass-4 1)
(bass-5 1)
(bass-7 3))
:start 0.5)
*bass*)
(store-file-in-list
(make-stored-file
'bass-7
"/one-shots/bass/bass-7.wav"
:markov '((rest 3)
(bass-4 2)
(bass-1 2)
(bass-8 4))
:start 0.5)
*bass*)
(store-file-in-list
(make-stored-file
'bass-8
"/one-shots/bass/bass-8.wav"
:markov '((rest 1)
(bass-5 4)
(bass-6 3)
(bass-8 4))
:start 0.5)
*bass*)
;; ** breath
(defparameter *breath* (make-stored-file-list 'breath '()))
(folder-to-stored-file-list
*breath*
"/E/code/layers/samples/one-shots/breath/"
:decay 0.5)
;; ** piano-swells
(defparameter *piano-swells* (make-stored-file-list 'piano-swells '()))
(folder-to-stored-file-list
*piano-swells*
"/E/code/layers/samples/background/atmo/piano-swells/"
:decay 10
:start 'random
:loop-flag 1)
;; ** whispers
(defparameter *whispers* (make-stored-file-list 'whispers '()))
(folder-to-stored-file-list
*whispers*
"/E/code/layers/samples/one-shots/whispers/"
:decay 1
:start 'random)
;; ** drumloops
(defparameter *drumloops* (make-stored-file-list 'drumloops '()))
(folder-to-stored-file-list
*drumloops*
"/E/code/layers/samples/phrases/drums/"
:decay 0.1
:start 0 ; 'random
:loop-flag 1
:panorama 90
)
;; ** drums
(defparameter *drums* (make-stored-file-list 'drums '()))
;;(store-file-in-list (create-rest) *drums*)
;;#################
(store-file-in-list
(make-stored-file
'kick1
"/one-shots/drums/kick1.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0
:y 0
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'kick2
"/one-shots/drums/kick2.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.35
:y 0
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'kick3
"/one-shots/drums/kick3.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.7
:y 0
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'kick4
"/one-shots/drums/kick4.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 1
:y 0
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'snare1
"/one-shots/drums/snare1.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0
:y 0.3
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'snare2
"/one-shots/drums/snare2.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.35
:y 0.5
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'snare3
"/one-shots/drums/snare3.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.7
:y 0.7
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'snare4
"/one-shots/drums/snare4.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 1
:y 1
:z 0)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'hat1
"/one-shots/drums/hat1.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.2
:y 0.2
:z 0.5)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'hat2
"/one-shots/drums/hat2.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.4
:y 0.4
:z 0.6)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'hat3
"/one-shots/drums/hat3.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.7
:y 0.7
:z 0.7)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'hat4
"/one-shots/drums/hat4.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0.8
:y 0.8
:z 0.9)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'ride1
"/one-shots/drums/ride1.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0
:y 0
:z 1)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'ride2
"/one-shots/drums/ride2.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 0
:y 1
:z 1)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'ride3
"/one-shots/drums/ride3.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 1
:y 0
:z 1)
*drums*)
;;#################
(store-file-in-list
(make-stored-file
'ride4
"/one-shots/drums/ride4.wav"
:decay 0.5
:loop-flag nil
:start 0
:panorama 45
:preferred-length '(0.3 5)
:x 1
:y 1
:z 1)
*drums*)
;; ** set alternate-sfls
(set-alternate-sfls *whispers* 0.5 100 *bass* *whispers*) ; noisy was breath
(set-alternate-sfls *bass* 0 0.5 *bass* *whispers*)
(set-alternate-sfls *background* 13 100 *piano-swells* *background*)
(set-alternate-sfls *piano-swells* 0 17 *piano-swells* *background*)
| 11,574 | Common Lisp | .l | 590 | 16.555932 | 76 | 0.635747 | Leon-Focker/layers | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 1633d24720fb9680aa23f8681fae8b832f8ae368954300f9d706947dea335207 | 26,267 | [
-1
] |
26,310 | ool.lisp | fsaporito_OOL/ool.lisp | ;;;; OOL
;;;; Hash Table Used To Store Classes Informations
(defparameter *classes-specs* (make-hash-table))
;;;; Function Used To Insert The class-spec To The Hash Table
;;;; Return The Class Name
(defun add-class-spec (name class-spec)
(setf (gethash name *classes-specs*) ;; Links The Class Name With The Class
class-spec) ;; Definition And Puts Them In The Table
(car (list name))) ;; Returns The Class Name
;;;; Function That Recovers The class-spec From The Hash Table
;;;; Uses The Function: gethash key hashtable
;;;; Wich Finds The Object In hashtable With key As Key
;;;; If Key Not Found, Returns nil
(defun get-class-spec (name)
(gethash name *classes-specs*))
;;;; Find Slot
;;;; This Function Find The Slot-Name In The
;;;; List. Nil If Not Found
(defun find-slot (list-arg slot-name)
(if (not (null list-arg)) ;; Instance Mustn't Be Nil
(if (equal (first list-arg)
slot-name) ;; Slot Found
(cons slot-name ;; Return (slot-name . slot-value)
(second list-arg))
(find-slot (rest (rest list-arg)) slot-name)) ;; Recursive Step
Nil))
;;;; Find Slot Parent
;;;; This Function Find The Slot-Name Recursively
;;;; In The Parents. Nil If Not Found
(defun find-slot-p (parent slot-name)
(if (not (null parent)) ;; Parent Mustn't Be Nil
(if (not (null (get-class-spec parent))) ;; Parent Class Must Be Defined
(let ((slotl (find-slot (rest (get-class-spec parent)) slot-name)))
(if (not (null slotl)) ;; Slot Musn't Be Null
slotl ;; Return Slot Value
(find-slot-p (first (get-class-spec parent)) ;; Try Looking In The
slot-name))) ;; Grandparent
Nil)
Nil))
;;;; Get Slot
(defun get-slot (instance slot-name)
(if (and (not (null instance)) ;; Instance Mustn't Be Null
(symbolp slot-name)) ;; slot-name Must Be A Symbol
(if (not (null (find-slot (rest instance) ;; Check If The Associated
slot-name))) ;; slot-values Isn't Null
(cdr (find-slot (rest instance) ;; Return The Found slot-value
slot-name))
(let ((class-sp (get-class-spec (first instance))))
(if (not (null class-sp)) ;; Class Defined
(if (not (null (find-slot (rest class-sp) ;; Look Into The
slot-name))) ;; The Class
(cdr (find-slot (rest class-sp) ;; Slot Value Found
slot-name)) ;; Return It
(let ((slot-par (find-slot-p (first class-sp) slot-name)))
(if (not (null slot-par)) ;; Look Into Parent Class
(cdr slot-par) ;; Slot Value Found, Return It
(error "Slot Not Found"))))
(error "Slot Not Found"))))
(error "Wrong Input")))
;;;; Input Checking For The Slots
(defun check-slot (slot-values)
(if (null slot-values) ;; slot-values Is Empty, Return True
T
(if (symbolp (first slot-values)) ;; The First Element Must Be A Symbol
(check-slot (rest (rest slot-values))) ;; Check From Third Element
Nil)))
;;;; Input Checking For The Class
(defun input-class-check (name parent slot-values)
(if (symbolp name) ;; Name Must Be A Symbol
(if (symbolp parent) ;; Parent Must Be A Symbol
(if (not (atom slot-values)) ;; Slot Values Must Be A List
(if (evenp (length slot-values))
(check-slot slot-values)
Nil)
Nil)
Nil)
Nil))
;;;; Rewrite Method
;;;; This Function Add The Argument This To The Method
(defun rewrite-method (method-spec)
(list 'lambda (append (list 'this) ;; Add The THIS Argument
(second method-spec))
(cons 'progn (rest (rest method-spec))))) ;; Eval All The Method's Body
;;;; Method-Process
;;;; Function Used To Process Methods, Rewriting Them To
;;;; Lisp Functions
(defun method-process (method-name method-spec)
(setf (fdefinition method-name) ;; Associate The Lambda To The Method's Name
(lambda (this &rest args) ;; Adds The THIS Argument
(apply (get-slot this
method-name)
(append (list this)
args))))
(eval (rewrite-method method-spec))) ;; Returned Value
;;;; Slot-Values-Proc
;;;; Modify The Slot-Values By Processing All The Methods
(defun slot-values-proc (slot-values)
(if (null slot-values)
() ;; Return The Slot-Values
(if (and (not (atom (second slot-values))) ;; Looks For Methods
(equal (car (second slot-values))
'method))
(append (list (first slot-values)) ;; Substitute With Processed Method
(list (method-process (first slot-values)
(second slot-values)))
(slot-values-proc (rest (rest slot-values))))
(append (list (first slot-values) ;; Simply Copy The Slot-Name And
(second slot-values)) ;; SLot Value
(slot-values-proc (rest (rest slot-values)))))))
;;;; Define-Class
;;;; Function Used To Define A New Class
(defun define-class (class-name parent &rest slot-values)
(if (input-class-check class-name parent slot-values)
(if (not (get-class-spec class-name)) ;; Check If Class Is Already Defined
(if (null parent) ;; Check If Orphan
(add-class-spec class-name ;; Add List To Hash Table
(append (list parent)
(slot-values-proc slot-values)))
(if (not (null (get-class-spec parent))) ;; Parent Class Defined
(add-class-spec class-name ;; Add List To Hash Table
(append (list parent)
(slot-values-proc slot-values)))
(error "Parent Class Not Defined !!!")))
(error "Class Already Defined !!!"))
(error "Wrong Input!!!")))
;;;; New
;;;; Instantiate A New Class Previously Defined
(defun new (class-name &rest slot-values)
(if (symbolp class-name) ;; Class Name Must Be A Symbol
(if (get-class-spec class-name) ;; The Class Must Be Defined
(if (evenp (length slot-values)) ;; NUmber Or Arguments Must Be Even
(if (check-slot slot-values) ;; Arguments Are Valid
(append (list class-name) ;; Create List With Name And
(slot-values-proc slot-values)) ;; Processed Slot
(error "Wrong Slot Values"))
(error "Wrong Slot Values"))
(error "Class Not Defined !!!"))
(error "Wrong Class Name")))
| 6,055 | Common Lisp | .lisp | 138 | 39.130435 | 80 | 0.659829 | fsaporito/OOL | 1 | 0 | 0 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 5c771dbe01de53152bc16e9f3363b1ccdaaca95671858733329f8edfdd4e5c60 | 26,310 | [
-1
] |
26,311 | test.lisp | fsaporito_OOL/test.lisp | ;;;; Test File
;;;; Loading File With OOL API
(load "ool.lisp")
;;;; Definition Of A Class Person
(define-class 'person nil 'name "Eve" 'age "undefined")
;;;; Definition Of A Class Students, Subclass Of Person
(define-class 'student 'person
'name "Eva Lu Ator"
'university "Berkeley"
'talk '(method ()
(princ "My name is ")
(princ (get-slot this 'name))
(terpri)
(princ "My age is ")
(princ (get-slot this 'age))
(terpri)))
;;;; Definition Of A Class Pdh, Subclass Of Student
(define-class 'phd 'student 'subject "ComputerScience")
;;;; Istances Of Class Person
(defparameter *eve* (new 'person))
(defparameter *adam* (new 'person 'name "Adam"))
;;;; Instances Of Class Student
(defparameter *s1* (new 'student
'name "Eduardo De Filippo"
'age 108))
(defparameter *s2* (new 'student 'adress "My Home"))
;;;; Instance Of Class Phd
(defparameter *me* (new 'phd 'name "Ernest" 'age "24"))
;;;; Istances Ispection
(get-slot *eve* 'age)
(get-slot *adam* 'name)
(get-slot *s1* 'name)
(get-slot *s1* 'age)
(get-slot *s2* 'name)
(get-slot *s2* 'age)
(get-slot *s2* 'adress)
;;;; Methods Calling
(princ "talk S1")
(terpri)
(talk *s1*)
(terpri)
(terpri)
(princ "talk S2")
(terpri)
(talk *s2*)
(terpri)
(terpri)
(princ "talk Me")
(terpri)
(talk *me*)
(terpri)
(terpri)
| 1,334 | Common Lisp | .lisp | 52 | 23.173077 | 55 | 0.675829 | fsaporito/OOL | 1 | 0 | 0 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 1a96debed93c31c36c7c862d56c48251d27d597c5b927da801b359c8c31f8982 | 26,311 | [
-1
] |
26,329 | process-html-file.lisp | nydel_cl-html-embed/process-html-file.lisp | (defun load-html-file (filepath)
(with-open-file (fstream filepath :direction :input)
(loop for line = (read-line fstream nil 'eof)
until (eq line 'eof) collect line)))
(defun string-list-to-string (string-list)
(eval (append '(concatenate 'string) string-list)))
(defun process-a-string (string)
(let ((lhs (search "<(" string))
(rhs (search ")>" string)))
(cond ((or (null lhs) (null rhs)) string)
(t
(let* ((mid (subseq string (+ 2 lhs) rhs))
(mid2 (read-from-string mid))
(mid3 (eval mid2))
(mid4 (if (stringp mid3) mid3 (write-to-string mid3))))
(concatenate 'string
(subseq string 0 lhs)
mid4
(process-a-string
(subseq string (+ 2 rhs)))))))))
(defun process-html-file (filepath)
(process-a-string
(string-list-to-string
(load-html-file filepath))))
(defun htcl-to-html (inpath &optional outpath)
(let ((processed-data (process-html-file inpath))
(outpath (if outpath outpath
(concatenate 'string inpath ".html"))))
(with-open-file (fstream outpath :direction :output
:if-does-not-exist :create
:if-exists :rename)
(format fstream "~a" processed-data))))
| 1,183 | Common Lisp | .lisp | 32 | 32.1875 | 59 | 0.650392 | nydel/cl-html-embed | 1 | 0 | 0 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | f91f1ed82d245ee889bc9d87191762fe138750cc2c9bd55856e81cf1fcaa9c04 | 26,329 | [
-1
] |
26,330 | index.htcl | nydel_cl-html-embed/index.htcl | <!DOCTYPE html>
<html>
<head>
<title>cl-html-embed test</title>
</head>
<body>
<div id="mainContainer">
<p>the sum of 5 and 3 is <((format nil "~a" (+ 5 3)))></p>
<p>this paragraph has no embedded lisp</p>
<p>a second sum, of 10 and 20 is <((format nil "~a" (+ 10 20)))></p>
<br />
<p>the current timestamp is <((get-universal-time))> in universal format</p>
<p>the next paragraph will be a list of numbers one through twenty!</p>
<p><((loop for i from 1 to 20 collect i))></p>
</div>
</body>
</html>
| 501 | Common Lisp | .cl | 17 | 28.470588 | 76 | 0.657025 | nydel/cl-html-embed | 1 | 0 | 0 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 5daf1db3e4e9bfc5a4084e460700027bd29f743051c4641791e1c3f543d39e62 | 26,330 | [
-1
] |
26,331 | index.htcl.html | nydel_cl-html-embed/index.htcl.html | <!DOCTYPE html><html><head><title>cl-html-embed test</title></head><body><div id="mainContainer"><p>the sum of 5 and 3 is 8</p><p>this paragraph has no embedded lisp</p><p>a second sum, of 10 and 20 is 30</p><br /><p>the current timestamp is 3602581134 in universal format</p><p>the next paragraph will be a list of numbers one through twenty!</p><p>(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20)</p></div></body></html> | 426 | Common Lisp | .cl | 1 | 426 | 426 | 0.692488 | nydel/cl-html-embed | 1 | 0 | 0 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 9887e7d3d07c942f3a161378b445f0f7174b3075d600bd6cdc86626fe1dbc434 | 26,331 | [
-1
] |
26,350 | main.lisp | Fhoughton_cl-fasttrie/src/main.lisp | (defstruct trie
"Trie data structure definition"
(isend nil :type boolean)
(map (make-hash-table) :type hash-table))
(defun trie-insert (root str)
"Inserts a new string into the Trie"
(declare (optimize (speed 3) (safety 0))
(type simple-string str))
(when (null root)
(setf root (make-trie)))
(let ((temp root))
(loop for x across str do
(when (null (gethash x (trie-map temp)))
(setf (gethash x (trie-map temp)) (make-trie)))
(setf temp (gethash x (trie-map temp))))
(setf (trie-isend temp) T))
root)
(defun trie-search (root str)
"Searches the Trie and returns true if in Trie"
(declare (optimize (speed 3) (safety 0))
(type simple-string str))
(when (null root)
(return-from trie-search nil)) ;false
(let ((temp root))
(loop for x across str do
(setf temp (gethash x (trie-map temp)))
(when (null temp) (return-from trie-search nil)) ;false
)
(trie-isend temp)))
(defun trie-search-recursive (root str)
"Searches the Trie and returns true if in Trie"
(declare (optimize (speed 3) (safety 0))
(type simple-string str))
(and root
(loop :for x :across str
:do (setf root (gethash x (trie-map root)))
:never (null root))
(trie-isend root)))
| 1,322 | Common Lisp | .lisp | 38 | 29.052632 | 64 | 0.624512 | Fhoughton/cl-fasttrie | 1 | 0 | 0 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 18c93d34f08be39a23d77acf78c044f90961337406dbfdb08fe52661abac2544 | 26,350 | [
-1
] |
26,351 | cl-fasttrie.asd | Fhoughton_cl-fasttrie/cl-fasttrie.asd | (defsystem "cl-fasttrie"
:author "Fhoughton"
:license "LGPL-3.0"
:description "A collection of functions and structs to allow a fast version of the trie data structure using hash tables."
:version "1.0.0"
;; Project files / load order
:components ((:module "src"
:components ((:file "package")
(:file "stuff" :depends-on ("package"))
))) | 436 | Common Lisp | .asd | 10 | 32.8 | 125 | 0.572104 | Fhoughton/cl-fasttrie | 1 | 0 | 0 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 8af0642006876f463fcb951e8c0be61b6d41bfcb4e515e9ae8cfa3ac73119890 | 26,351 | [
-1
] |
26,369 | cl-pinner.lisp | ahungry_cl-pinner/src/cl-pinner.lisp | ;; cl-pinner - A project template generated by ahungry-fleece
;; Copyright (C) 2016 Your Name <[email protected]>
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU Affero General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;;; cl-pinner.lisp
(in-package #:cl-user)
(defpackage cl-pinner
(:use :cl)
(:export :main
:print-usage))
(in-package #:cl-pinner)
(defun print-usage ()
(format t
"cl-pinner v/~a.
Usage:
$ cl-pinner [-h, --help] # Print this help
"
(asdf:component-version (asdf:find-system :cl-pinner))))
(defun main (&rest argv)
(unless argv
(setf argv (cdr sb-ext:*posix-argv*)))
(if (or (equal (first argv) "-h")
(equal (first argv) "--help"))
(print-usage)
(cond
(t (print-usage)))))
;;; "cl-pinner" goes here. Hacks and glory await!
| 1,387 | Common Lisp | .lisp | 38 | 33.473684 | 78 | 0.697083 | ahungry/cl-pinner | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 7d643106648432482b0cceaf9ee5b3ae6e638283d6581b637489dc3ad3d07612 | 26,369 | [
-1
] |
26,370 | cl-pinner.lib.stub.lisp | ahungry_cl-pinner/src/libs/cl-pinner.lib.stub.lisp | ;; cl-pinner - A project template generated by ahungry-fleece
;; Copyright (C) 2016 Your Name <[email protected]>
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU Affero General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;;; cl-pinner.lib.stub.lisp
(in-package #:cl-user)
(defpackage cl-pinner.lib.stub
(:use :cl)
(:export
:echo))
(in-package #:cl-pinner.lib.stub)
(defun echo (input)
input)
;;; "cl-pinner.lib.stub" goes here. Hacks and glory await!
| 1,034 | Common Lisp | .lisp | 25 | 39.76 | 78 | 0.747757 | ahungry/cl-pinner | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 8c28245b12e0b0128666439833e4a9e841440e696eac4c6893c1c0b6e5d44220 | 26,370 | [
-1
] |
26,371 | cl-pinner.lib.fetch.lisp | ahungry_cl-pinner/src/libs/cl-pinner.lib.fetch.lisp | ;; cl-pinner - A project template generated by ahungry-fleece
;; Copyright (C) 2016 Your Name <[email protected]>
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU Affero General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;;; cl-pinner.lib.stub.lisp
(in-package #:cl-user)
(defpackage cl-pinner.lib.fetch
(:use :cl)
(:export
:fetch
:fetch-and-load))
(in-package #:cl-pinner.lib.fetch)
(defparameter *base-directory* (asdf:system-source-directory :cl-pinner))
(defun fetch-dir (package version)
"Get the fetch dir to work in."
(merge-pathnames (format nil "pinned/v~a.~a" version package) *base-directory*))
(defun fetch-git (package uri version)
"Clone and check out from URI the specified VERSION."
(let* ((path (format nil "~a.tmp" (fetch-dir package version)))
(cwd (sb-posix:getcwd)))
(sb-ext:run-program "/usr/bin/git" (list "clone" uri (format nil "~a" path)))
(sb-posix:chdir path)
(sb-ext:run-program "/usr/bin/git" (list "checkout" version))
(sb-posix:chdir cwd)))
(defun clean-defined-packages (package-list)
"For each package in PACKAGE-LIST, remove characters such as quotes
and leading colon/hashes."
(mapcar (lambda (package)
(cl-ppcre:regex-replace-all "(^[\"#:]*|[\"]$)" package ""))
package-list))
(defun find-defined-packages-in-directory (directory)
"Recurse through DIRECTORY, finding all defined packages.
This returns 2 values, the list of package defining files, and
the packages defined within those files."
(let ((package-defining-files
(append (af.lib.io:find-file-matches directory "(defpackage " ".asd")
(af.lib.io:find-file-matches directory "(defpackage " ".lisp"))))
(values
package-defining-files
(clean-defined-packages
(loop for file in package-defining-files
collect (aref
(nth-value
1
(cl-ppcre:scan-to-strings
"(?m)\\(defpackage +(.*?)( +|$)"
(af.lib.io:file-get-contents file)))
0))))))
(defun rename-package-list (packages version)
"Prepend VERSION to each package in PACKAGES in a newly generated alist.
This format is primarily used for af.lib.io:file-replace-strings call."
(mapcar (lambda (package)
(cons (format nil "([\\(:\"# ]+)~a" package)
(format nil "\\1v~a.~a" version package)))
packages))
(defun redefine-packages-in-directory (directory version)
"Recurse through DIRECTORY, redefining PACKAGE to VERSION.PACKAGE."
(multiple-value-bind (package-files defined-packages)
(find-defined-packages-in-directory directory)
(declare (ignore package-files)) ; we may want to just iterate these sometime
(let ((package-replacement-list (rename-package-list defined-packages version))
(file-list (append (af.lib.io:find-file directory ".lisp$")
;;(af.lib.io:find-file directory ".asd")
(af.lib.io:find-file directory ".ros$")
(af.lib.io:find-file directory ".cl$"))))
(loop for file in file-list
do (progn
;; First pass, prefix with v0.0.0 on each package
(af.lib.io:file-replace-strings file package-replacement-list)
;; Second pass, remove any dupes from package name overlapping
;; with our initial clone project rename (yes, this is horribly
;; inefficient, but fine for now as we prototype things...)
(af.lib.io:file-replace-strings
file
(list (cons (format nil "v~a\\.v~a" version version)
(format nil "v~a" version))))
)))))
(defun undefine-redefined-package-files (directory version)
"The redefine step may have altered file names by incorrectly
adding a v0.0.0 prefix, so if so, strip it out at this time."
(loop for file in (af.lib.io:find-file directory ".asd")
do (progn
(af.lib.io:file-replace-strings
file
(list (cons (format nil "(?m)(\\(:file .*?)v~a\\." version) "\\1"))))))
(defun recombobulate-package (package version)
"Take in a PACKAGE and rename it to the appropriate VERSION.
Assumes a PACKAGE.tmp directory already exists (it builds the version
specific package off a copy of it."
(let* ((clone-to (fetch-dir package version))
(clone-from (format nil "~a.tmp" clone-to)))
;; This handles recurisvely copying the directory
(af.lib.clone:clone-project
clone-from
clone-to
package
(format nil "v~a.~a" version package))
;; package) ; Don't rename yet, we do in next step
;; Now, we want to go through the directory redefining all
;; defpackages to have the version prefix (incase supporting
;; packages are defined, that do not match the main package name).
(redefine-packages-in-directory clone-to version)
))
;;(undefine-redefined-package-files clone-to version)))
(defun fetch (type package uri version)
"Perform the operations."
(declare (ignore type)) ;; only git supported atm...
(fetch-git package uri version)
;; Rename the files so multiple versions can work with each other
(recombobulate-package package version)
;; Add it to the ASDF registry
(pushnew (truename (fetch-dir package version)) asdf:*central-registry*))
(defun fetch-and-load (type package uri version)
(fetch type package uri version)
(ql:quickload (format nil "v~a.~a" version package)))
;;; "cl-pinner.lib.stub" goes here. Hacks and glory await!
| 6,224 | Common Lisp | .lisp | 127 | 41.976378 | 83 | 0.662496 | ahungry/cl-pinner | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 604418a171c67a1b70f1a39e7985ceceeb07486f6deb86f0f7d01b34068d6163 | 26,371 | [
-1
] |
26,372 | cl-pinner.run.tests.lisp | ahungry_cl-pinner/t/cl-pinner.run.tests.lisp | ;; cl-pinner - A project template generated by ahungry-fleece
;; Copyright (C) 2016 Your Name <[email protected]>
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU Affero General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;;; cl-pinner.run.tests.lisp
(in-package #:cl-user)
(defpackage cl-pinner.run.tests
(:use :cl
:cl-pinner.lib.stub
:af.lib.ansi-colors
:af.lib.coverage
:af.lib.testy)
(:export :main))
(in-package #:cl-pinner.run.tests)
(defparameter *base-directory* (asdf:system-source-directory :cl-pinner))
(defun main ()
"Run the tests, or the tests with coverage."
(if (and (sb-ext:posix-getenv "AF_LIB_TESTY_COVERAGE")
(> (length (sb-ext:posix-getenv "AF_LIB_TESTY_COVERAGE")) 0))
(coverage)
(test)
))
(defun test ()
"Begin the tests!"
(unless (and (sb-ext:posix-getenv "AF_LIB_TESTY_COLORIZE")
(> (length (sb-ext:posix-getenv "AF_LIB_TESTY_COLORIZE")) 0))
(setf af.lib.ansi-colors:*colorize-p* nil))
(if (suite
"cl-pinner.lib"
(desc
"cl-pinner.lib.stub"
(it "Should echo the input"
(eq 3 (cl-pinner.lib.stub:echo 3)))
)
) ;; end suite
(setf sb-ext:*exit-hooks* (list (lambda () (sb-ext:exit :code 0))))
(setf sb-ext:*exit-hooks* (list (lambda () (sb-ext:exit :code 1)))))
)
(defun coverage ()
"Begin the tests!"
;; See if we're in the shell environment or not (SLIME will use 'dumb' here)
(af.lib.coverage:with-coverage :cl-pinner
(test)
(terpri)
(with-color :blue (format t "Summary of coverage:~%"))
(with-open-stream (*error-output* (make-broadcast-stream))
(sb-cover:report (merge-pathnames #P"coverage/" *base-directory*)))
(with-open-stream (*error-output* (make-broadcast-stream))
(af.lib.coverage:report-cli (merge-pathnames #P"coverage/" *base-directory*))
)
(with-open-stream (*error-output* (make-broadcast-stream))
(af.lib.coverage:report-json (merge-pathnames #P"coverage/" *base-directory*))
)
(with-color :light-blue
(format t "~%Full coverage report generated in: ~a" (merge-pathnames #P"coverage/" *base-directory*))
(format t "~%Coverage summary generated in: ~acoverage.json~%~%" (merge-pathnames #P"coverage/" *base-directory*))
)
)
)
;;; "cl-pinner.run.tests" goes here. Hacks and glory await!
| 2,989 | Common Lisp | .lisp | 71 | 36.929577 | 120 | 0.661729 | ahungry/cl-pinner | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 84553aa08984fa4bd5378b66545f888e3c9b0d9f872d0e1ef71f977336040ca4 | 26,372 | [
-1
] |
26,373 | cl-pinner.asd | ahungry_cl-pinner/cl-pinner.asd | ;; cl-pinner - A project template generated by ahungry-fleece
;; Copyright (C) 2016 Your Name <[email protected]>
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU Affero General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;;;; cl-pinner.asd
(in-package :cl-user)
(defpackage cl-pinner-asd
(:use :cl :asdf))
(in-package :cl-pinner-asd)
(asdf:defsystem #:cl-pinner
:version "0.0.1"
:description "Your project template"
:author "Your Name <[email protected]>"
:license "GPLv3"
:depends-on (#:ahungry-fleece)
:serial t
:components
(
;; The lib modules
(:module "libs"
:pathname "src/libs"
:components
(
(:file "cl-pinner.lib.stub")
(:file "cl-pinner.lib.fetch")
))
;; The main module
(:module "cl-pinner"
:pathname "src"
:depends-on ("libs")
:components
((:file "cl-pinner")))
;; The testing module
(:module "t"
:pathname "t"
:depends-on ("libs" "cl-pinner")
:components
((:file "cl-pinner.run.tests")))
)
)
;;:in-order-to ((test-op (load-op alluring-allegory-test))))
| 1,756 | Common Lisp | .asd | 52 | 28.538462 | 78 | 0.646226 | ahungry/cl-pinner | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 5cfc51b51bc74b3f8b77de1d581526d4e089bf4087d9a653c8372c622a3f5ae9 | 26,373 | [
-1
] |
26,375 | pinned.yml | ahungry_cl-pinner/pinned.yml | # Define some dependencies
system:
# A great utility library
ahungry-fleece:
type: git
uri: https://github.com/ahungry/ahungry-fleece.git
version: 0.3.1
| 169 | Common Lisp | .l | 7 | 20.857143 | 54 | 0.728395 | ahungry/cl-pinner | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | a665164e7ff20fbf4e9b0e2cd1422a612664a970d3f514dd822ea8cdf2d9f1de | 26,375 | [
-1
] |
26,378 | Makefile.in | ahungry_cl-pinner/Makefile.in | LISP?= sbcl
AF_LIB_TESTY_COLORIZE?= yes
TFLAGS = --non-interactive \
--eval '(ql:quickload :cl-pinner)' \
--eval '(cl-pinner.run.tests:main)'
CFLAGS = --disable-debugger \
--eval "(mapc \#'require '(sb-bsd-sockets sb-posix sb-introspect sb-cltl2 sb-rotate-byte sb-cover asdf))" \
--eval '(sb-ext:save-lisp-and-die "bin/cl-pinner.core")'
TEFLAGS = --disable-debugger \
--eval '(ql:quickload :cl-pinner)' \
--eval '(sb-ext:save-lisp-and-die "bin/cl-pinner-test" :executable t)'
EFLAGS = --disable-debugger \
--eval '(ql:quickload :cl-pinner)' \
--eval '(sb-ext:save-lisp-and-die "bin/cl-pinner" :executable t :toplevel '"\#'cl-pinner::main)"
CORE = bin/cl-pinner.core
EXE = bin/cl-pinner
TEXE = bin/cl-pinner-test
all: $(EXE)
$(CORE):
$(LISP) $(CFLAGS)
$(EXE): $(CORE)
$(LISP) --core $< $(EFLAGS)
$(TEXE): $(CORE)
$(LISP) --core $< $(TEFLAGS)
test: $(TEXE)
AF_LIB_TESTY_COLORIZE=$(AF_LIB_TESTY_COLORIZE) $< $(TFLAGS)
coverage: $(TEXE)
AF_LIB_TESTY_COVERAGE='y' \
AF_LIB_TESTY_COLORIZE=$(AF_LIB_TESTY_COLORIZE) $< $(TFLAGS)
clean:
-rm $(CORE)
-rm $(EXE)
-rm $(TEXE)
.PHONY:
all test
| 1,111 | Common Lisp | .l | 35 | 29.857143 | 108 | 0.665099 | ahungry/cl-pinner | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 5450d10e5b8d023125fc4341f672a94e012c57b88aa4653b692438523304b664 | 26,378 | [
-1
] |
26,382 | cl-pinner.ros | ahungry_cl-pinner/roswell/cl-pinner.ros | #!/bin/sh
#|-*- mode:lisp -*-|#
#| A skelly project for Common Lisp dependant on SBCL, generated by Ahungry Fleece
exec ros -Q -L sbcl-bin -- $0 "$@"
|#
#-sbcl
(error "cl-pinner requires SBCL. Make sure it is installed with `ros install sbcl' and use it with `ros use sbcl'.")
(progn ;;init forms
(ql:quickload '(#:cl-pinner) :silent t))
(defpackage #:ros.script.cl-pinner
(:use #:cl))
(in-package :ros.script.cl-pinner)
(defun main (&rest argv)
(cl-pinner:main argv))
;;; vim: set ft=lisp lisp:
| 507 | Common Lisp | .l | 15 | 32.066667 | 116 | 0.683778 | ahungry/cl-pinner | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 18ef0c41661dd18ae6b9eaca373bbe642f210a4350235f7e92729005b857379b | 26,382 | [
-1
] |
26,399 | SetMText.lsp | Voulz_Autocad-Scripts/LISP/SetMText.lsp | (defun C:SetMText ( / items it name block text area)
(setq items (ssget)
text nil)
(if (/= nil items) (progn
(while (> (sslength items) 0) (progn
(setq it (ssname items 0)
vla (vlax-ename->vla-object it))
(if (vlax-property-available-p vla 'Textstring) (progn ;if has a Textstring
;(vla-put-textstring vla "")
;(vla-put-textstring vla "plop")
(setq text (append text (list vla)))
))
(ssdel it items)
))
(if (= nil text)
(print "No MText Selected")
(progn
(setq str (getstring T "New Text: "))
(while (/= nil (vl-string-search "/" str))
(setq str (vl-string-subst "\\" "/" str))
)
(foreach vla text
(progn
(vla-put-textstring vla "")
(vla-put-textstring vla str)
)
)
))
))
)
| 771 | Common Lisp | .l | 30 | 21.466667 | 78 | 0.597297 | Voulz/Autocad-Scripts | 1 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | e88cb07f1ec639ec36a11a32c9178b0cc870c3a3bdac5b6326394426c689ee8f | 26,399 | [
-1
] |
26,400 | LinkArea.lsp | Voulz_Autocad-Scripts/LISP/LinkArea.lsp | (vl-load-com)
;; End Undo - Lee Mac
;; Closes an Undo Group.
(defun LM:endundo ( doc )
(while (= 8 (logand 8 (getvar 'undoctl)))
(vla-endundomark doc)
)
)
(defun C:LinkArea ( / *error* getFromSelection getUserOptions saveVars restoreVars createAreaString findFields AllOfProperty FieldCode
overrideText addText replaceText
items options txt blk att text obj fcode tmp)
(princ " :: Link Area v0.3.1 - © Voulz\n")
;;;;; Error Handling ;;;;;
(defun *error* ( msg )
(LM:endundo (vla-get-activedocument (vlax-get-acad-object)))
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\nError: " msg))
)
(princ (strcat "\nError: " msg))
(princ)
);; -- *error* -- ;;
;;;;; Prepare the Selection ;;;;;
(defun getFromSelection ( / items it name block text area)
(setq items (ssget))
(while (> (sslength items) 0) (progn
(setq it (ssname items 0)
name (cdr (assoc 0 (entget it))))
(cond
((= name "INSERT") ;if a block
(setq block (append block (list it))) )
((vlax-property-available-p (vlax-ename->vla-object it) 'Textstring) ;if has a Textstring
(setq text (append text (list it))) )
((vlax-property-available-p (vlax-ename->vla-object it) 'Area) ;if has area
(setq area (append area (list it))) )
)
(ssdel it items)
))
(list (cons 'block block)
(cons 'text text)
(cons 'area area))
);; -- getFromSelection -- ;;
;;;;; Save the given Variables ;;;;;
(defun saveVars ( var / result)
(while (car var)
(setq result (append result (list (cons (strcase (car var)) (getvar (car var)))))
var (cdr var))
)
result
);; -- saveVars -- ;;
;;;;; Restore the given Variables ;;;;;
(defun restoreVars ( vars varname / it)
(if varname ;if we provided a varname, find and reset the one that is matching
(if (and (setq it (assoc (strcase varname) vars))
(cdr it))
(setvar (car it) (cdr it)))
;else reset them all
(while (setq it (car vars))
(if (cdr it) ;if the value is not nil
(setvar (car it) (cdr it)) )
(setq vars (cdr vars))
)
)
);; -- restoreVars -- ;;
;;;;; get User Options ;;;;;
(defun getUserOptions ( / *error* vars appname attr conv prec pref suff mode Done new)
;; Error Handling ;;
(defun *error* ( msg )
(restoreVars vars nil)
(LM:endundo (vla-get-activedocument (vlax-get-acad-object)))
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\nError: " msg))
)
(princ)
);; -- Error Handling -- ;;
(setq vars (saveVars (list "unitmode" "DYNPROMPT"))
appname "Voulz:LinkArea"
attr (getcfg (strcat "AppData/" appname "/Attribute"))
conv (getcfg (strcat "AppData/" appname "/ConversionFactor"))
prec (getcfg (strcat "AppData/" appname "/Precision"))
pref (getcfg (strcat "AppData/" appname "/Prefix"))
suff (getcfg (strcat "AppData/" appname "/Suffix"))
mode (getcfg (strcat "AppData/" appname "/Mode")) ;valid Modes: 'Override', 'Add', 'ReplaceOrOverride'
Done nil)
(if (or (not attr) (= attr "")) (setq attr "AREA"))
(if (or (not conv) (= conv "")) (setq conv 1e-6) (setq conv (atof conv)))
(if (or (not prec) (= prec "")) (setq prec 1) (setq prec (atoi prec)))
(if (not pref) (setq pref ""))
(if (not suff) (setq suff ""))
(if (or (not mode) (= mode "")) (setq mode "ReplaceOrOverride"))
(while (not Done)
(initget "Attribute ConversionFactor Precision pRefix Suffix Mode")
(setvar "unitmode" 1) ;needed to convert real to string with as few decimal as possible
(setq new (strcat "Enter an Option "
"{\"" attr "\", " (rtos conv 2 10) ", " (itoa prec) ", \"" pref "\", \"" suff "\", \"" mode "\"}"
"[Attribute/ConversionFactor/Precision/pRefix/Suffix/Mode]: "))
(restoreVars vars "unitmode") (setq Done nil)
(setq Choice (getkword new)) ;(print Choice)
(cond
((not Choice) (setq Done T))
((= Choice "Attribute")
(setq new (getstring T (strcat "\nAttribute of the block to set (case sensitive): <" attr "> ")))
(if (or (= new "") (= new " ")) (setq new attr))
(setq attr new)
(setcfg (strcat "AppData/" appname "/Attribute") attr)
)
((= Choice "ConversionFactor")
(setvar "unitmode" 1) ;needed to convert real to string with as few decimal as possible
(setq new (getreal (strcat "\nConversion Factor: <" (rtos conv 2 10) "> ")))
(if new (progn
(setq conv new)
(setcfg (strcat "AppData/" appname "/ConversionFactor") (rtos conv 2 10))
))
(restoreVars vars "unitmode")
)
((= Choice "Precision")
(setq new (getint (strcat "\nPrecision (-1 for Document Precision): <" (itoa prec) "> ")))
(if new (progn
(if (< new 0) (setq new -1))
(setq prec new)
(setcfg (strcat "AppData/" appname "/Precision") (itoa prec))
))
)
((= Choice "pRefix")
(setvar "DYNPROMPT" 0) ;needed to allow leading and trailing spaces
(setq new (getstring T (strcat "\nPrefix" (if (not (= "" pref)) " (type space to remove the Prefix)" "") ": <" pref "> ")))
(if (= new "") (setq new pref))
(if (= new " ") (setq new ""))
(setq pref new)
(setcfg (strcat "AppData/" appname "/Prefix") pref)
(restoreVars vars "DYNPROMPT")
)
((= Choice "Suffix")
(setvar "DYNPROMPT" 0) ;needed to allow leading and trailing spaces
(setq new (getstring T (strcat "\nSuffix" (if (not (= "" suff)) " (type space to remove the Suffix)" "") ": <" suff "> ")))
(if (= new "") (setq new suff))
(if (= new " ") (setq new ""))
(setq suff new)
(setcfg (strcat "AppData/" appname "/Suffix") suff)
(restoreVars vars "DYNPROMPT")
)
((= Choice "Mode")
(setq Done nil)
(while (not Done)
(setq Done T)
(initget "Override Add ReplaceOrOverride")
(setq Choice (getkword (strcat "Mode [Override/Add/ReplaceOrOverride]: <" mode ">")))
(cond
((not Choice) (setq Done T))
((= Choice "Override") (setq mode "Override"))
((= Choice "Add") (setq mode "Add"))
((= Choice "ReplaceOrOverride") (setq mode "ReplaceOrOverride"))
(T (setq Done nil))
)
)
(setcfg (strcat "AppData/" appname "/Mode") mode)
(setq Done nil)
); end of Choice
); end of cond
);end of while
(restoreVars vars nil)
(list (cons 'attr attr)
(cons 'conv conv)
(cons 'prec prec)
(cons 'pref pref)
(cons 'suff suff)
(cons 'mode mode))
);; -- getUserOptions -- ;;
;;;;; create the Field String for the Area of the given objects ;;;;;
(defun createAreaString ( items options / vars area endString txt)
(setq vars (saveVars (list "unitmode"))
area (cdr (assoc 'area items)))
(setvar "unitmode" 1) ;needed to convert real to string with as few decimal as possible
(setq endString (strcat " \\f \""
"%lu2" ;decimals
(if (not (< (cdr (assoc 'prec options)) 0))
(strcat "%pr" (itoa (cdr (assoc 'prec options))))
"")
(if (/= (cdr (assoc 'conv options)) 1)
(strcat "%ct8[" (rtos (cdr (assoc 'conv options)) 2 10) "]" )
"")
(if (or (/= (cdr (assoc 'pref options)) "")
(/= (cdr (assoc 'suff options)) ""))
(strcat "%ps[" (cdr (assoc 'pref options)) "," (cdr (assoc 'suff options)) "]")
"")
"\">%"))
(if (= (length area) 1)(progn
(setq txt (strcat "%<\\AcObjProp.16.2 Object(%<\\_ObjId "
(itoa (vla-get-ObjectID (vlax-ename->vla-object (car area))))
">%).Area"
endString))
)(progn
(setq txt "%<\\AcExpr (" )
(while (car area)
(setq txt (strcat txt
"%<\\AcObjProp Object(%<\\_ObjId "
(itoa(vla-get-ObjectID (vlax-ename->vla-object (car area))))
">%).Area>%+"))
(setq area (cdr area))
)
(setq txt (strcat (vl-string-right-trim "+" txt)
")"
endString))
))
(restoreVars vars nil)
txt
);; -- createAreaString -- ;;
;;;;; Create a hierarchical structure of the fields in the object ;;;;;
(defun findFields ( enx / ent fld pos str lst chld tmp prev)
(setq str (cdr (assoc 2 enx))
prev nil
child nil
lst (list (cons 'txt (if (= (cdr (assoc 1 enx)) "_text") str (strcat "%<" str ">%")))
(cons 'type (cdr (assoc 1 enx)))
(cons 'ent enx))
tmp enx)
(while (assoc 6 tmp)
(if (= (cdr (assoc 6 tmp)) "ObjectPropertyId")(progn
;(print (assoc 0 (entget (cdr (assoc 331 tmp)))))
;(print (itoa (vla-get-ObjectID (vlax-ename->vla-object (cdr (assoc 331 tmp))))))
(setq lst (append lst (list (cons 'id (cdr (assoc 331 tmp)))))) )
)
(if (= (cdr (assoc 6 tmp)) "ObjectPropertyName")
(setq lst (append lst (list (cons 'prop (cdr (assoc 1 tmp))))))
)
(setq tmp (cdr (member (assoc 6 tmp) tmp)))
)
(setq tmp (cdr (assoc 300 (member (assoc 7 enx) enx))))
(if (and tmp (/= tmp ""))
(setq lst (append lst (list (cons 'format tmp)))) )
(while (assoc 360 enx)
(setq ent (assoc 360 enx)
fld (entget (cdr ent))
pos (vl-string-search "%<\\_FldIdx" str prev) )
(setq chld (append chld (list (append
(list (cons 'pos pos))
(findFields fld)))))
(setq enx (vl-remove (assoc 360 enx) enx))
(setq prev (1+ pos))
)
(if chld
(setq lst (append lst (list (cons 'children chld)))) )
lst
);; -- findFields -- ;;
;;;;; Create a fieldcode for the object based on the findFields Output ;;;;;
(defun FieldCode ( fields / i children child lst pos)
(if (cdr (assoc 'override fields))
(cdr (assoc 'override fields)) ;if it has an override, return the override
(progn
(if (setq children (cdr (assoc 'children fields))) (progn
(setq i 0)
(while (setq child (car children))
(setq lst (append lst (list (cons i (FieldCode child)))))
(setq i (1+ i)
children (cdr children))
)
))
(if lst (progn ; if it has children, replace them in the string
(setq str (cdr (assoc 'txt fields)))
(while (car lst)
(setq str (vl-string-subst (cdr (car lst))
(strcat "%<\\_FldIdx " (itoa (car (car lst))) ">%")
str)
lst (cdr lst))
)
str
)(progn
(if (cdr (assoc 'id fields)) (progn ;if it has an ID, put it in the string
(setq str (cdr (assoc 'txt fields))
pos (vl-string-search "%<\\_ObjIdx" str))
(strcat
(substr str 1 (+ pos 9)) " "
(itoa (vla-get-ObjectID (vlax-ename->vla-object (cdr (assoc 'id fields)))))
(substr str (1+ (vl-string-search ">%" str pos)))
)
) (cdr (assoc 'txt fields))) ;if it doesn't have ID or Children, just output its text
))
);end of progn "else"
)
);; -- FieldCode -- ;;
;;;;; Check if the field or all its subfields are of the same property ;;;;;
(defun AllOfProperty ( fields propName / continue children child )
(setq continue T)
;if it has a property name and it is not the right one, then return it
(if (assoc 'prop fields)
(if (/= (strcase (cdr (assoc 'prop fields))) (strcase propName))
(setq continue nil))
(progn
(if (= "AcExpr" (cdr (assoc 'type fields)))(progn
(setq children (cdr (assoc 'children fields)))
(while (and
continue
(setq child (car children)))
(setq continue (AllOfProperty child propName)
children (cdr children))
)
)(setq continue nil))
)
)
continue
);; -- AllOfProperty -- ;;
;;;;; Return a list of the attributes of a list of blocks matching the givien name ;;;;;
(defun getAttributes ( blocks attName / b vla atts tmp)
(setq atts nil)
(while (setq b (car blocks))
(setq vla (vlax-ename->vla-object b))
(if (vlax-method-applicable-p vla 'getattributes)(progn
(setq tmp (vlax-invoke vla 'getattributes)
idx (vl-position (strcase attName) (mapcar 'strcase (mapcar 'vla-get-tagstring tmp))))
(if idx (setq atts (append atts (list (vlax-vla-object->ename (nth idx tmp))))))
))
(setq blocks (cdr blocks))
)
atts
);; -- getAttributes -- ;;
;;;;; Override the text of the entity ;;;;;
(defun overrideText ( ent txt / vla)
(setq vla (vlax-ename->vla-object ent))
(vla-put-textstring vla "")
(vla-put-textstring vla txt)
);; -- overrideText -- ;;
;;;;; Add the text to the entity ;;;;;
(defun addText ( ent txt / tmp fields fcode)
(setq tmp (entget ent)
tmp (cdr (assoc 360 tmp))
tmp (dictsearch tmp "ACAD_FIELD"))
(if tmp (progn ;if it has fields
(setq tmp (dictsearch (cdr (assoc -1 tmp)) "TEXT")
fields (findFields tmp)
fcode (FieldCode fields))
) (setq fcode (vla-get-textstring (vlax-ename->vla-object ent))) )
(overrideText ent (strcat fcode txt))
);; -- addText -- ;;
;;;;; Replace the text of the entity ;;;;;
(defun replaceText ( ent txt propName / tmp fields fcode children i Done)
(setq tmp (entget ent)
tmp (cdr (assoc 360 tmp)) )
(if (and tmp (setq tmp (dictsearch tmp "ACAD_FIELD")) ) (progn ;if it has fields
(setq tmp (dictsearch (cdr (assoc -1 tmp)) "TEXT")
fields (findFields tmp)
children (cdr (assoc 'children fields)) ;get the children of the field.
i 0
Done nil)
(while (and (not Done) (< i (length children)))
(if (AllOfProperty (nth i children) propName) ;if all the property are of type "propName", then replace it
(setq children (subst (append
(list (cons 'override txt))
(nth i children))
(nth i children)
children)
Done T)
)
(setq i (1+ i))
)
(if Done ;reflect the changes
(setq fields (subst (cons 'children children)
(assoc 'children fields)
fields)
fcode (FieldCode fields))
(setq fcode txt) ;else override
)
) (setq fcode txt) )
(overrideText ent fcode)
);; -- overrideText -- ;;
;;;;;; --------------------------------------------------------------------- ;;;;;;
;;;;;; ------------------ Actual Linking of the Area ----------------------- ;;;;;;
;;;;;; --------------------------------------------------------------------- ;;;;;;
(setq items (getFromSelection))
(if (and (cdr (assoc 'area items)) ;if there is at least one object with area
(or (cdr (assoc 'text items)) ;and one text object
(cdr (assoc 'block items)) )); or one block object
(progn
(setq options (getUserOptions)
txt (createAreaString items options)
blk (cdr (assoc 'block items))
att (getAttributes blk (cdr (assoc 'attr options)))
text (cdr (assoc 'text items))
obj att)
(cond
((= "Override" (cdr (assoc 'mode options))) ;Override/Add/ReplaceOrOverride
(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
(while (car obj)
(overrideText (car obj) txt)
(setq obj (cdr obj))
)
(setq obj text)
(while (car obj)
(overrideText (car obj) txt)
(setq obj (cdr obj))
)
(setq tmp (getvar "cmdecho"))(setvar "cmdecho" 0)(command "regen")(setvar "cmdecho" tmp)
(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
(princ "\n")
)
((= "Add" (cdr (assoc 'mode options)))
(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
(while (car obj)
(addText (car obj) txt)
(setq obj (cdr obj))
)
(setq obj text)
(while (car obj)
(addText (car obj) txt)
(setq obj (cdr obj))
)
(setq tmp (getvar "cmdecho"))(setvar "cmdecho" 0)(command "regen")(setvar "cmdecho" tmp)
(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
(princ "\n")
)
(T
(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
(while (car obj)
(replaceText (car obj) txt "area")
(setq obj (cdr obj))
)
(setq obj text)
(while (car obj)
(replaceText (car obj) txt "area")
(setq obj (cdr obj))
)
(setq tmp (getvar "cmdecho"))(setvar "cmdecho" 0)(command "regen")(setvar "cmdecho" tmp)
(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
(princ "\n")
)
);end of cond
(if (< (length att) (length blk))
(princ (strcat (itoa (- (length blk) (length att))) " object(s) discarded\n")) )
(princ (strcat " --- Area of "
(itoa (length (cdr (assoc 'area items)))) " object" (if (= (length (cdr (assoc 'area items))) 1) "" "s") " linked to "
(if att (strcat (itoa (length att)) " block" (if (= (length att) 1) "" "s")) "")
(if (and att text) " and " "")
(if text (strcat (itoa (length text)) " text" (if (= (length text) 1) "" "s")) "")
" !"))
)
(princ "\n [ ERROR ] You need to select at least a Block or a MText and an object with an Area (Polyline, Hatch)")
)
(princ)
)
(princ "\n >> Loading: LinkArea v0.3.1 - © Voulz")
| 16,874 | Common Lisp | .l | 438 | 33.059361 | 134 | 0.590437 | Voulz/Autocad-Scripts | 1 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 62894d43e8d9c8eaa659c06c70b72c09bf6db0626d53d5fa1da68036c8bbba5e | 26,400 | [
-1
] |
26,401 | XXA.lsp | Voulz_Autocad-Scripts/LISP/XXA.lsp | (vl-load-com)
(defun c:XXA (/ xrefs file)
(if (setq xrefs (_xxaSelect)) (progn
(if (and (setq file (getfiled "Select Reference File" "" "dwg" 0))
(findfile file))
(_XXA xrefs file))
))
);end of XXA
(defun c:-XXA (/ xrefs file)
(if (setq xrefs (_xxaSelect)) (progn
(setq file nil)
(while (not file)
(setq file (getstring T "Enter Reference Filename: "))
(if (not (findfile file)) (progn
(print "File not found")
(setq file nil)
))
)
(_XXA xrefs file)
))
);end of XXA
(defun _xxaSelect (/ first xrefs idx en)
(setq first T
xrefs nil)
(while (not xrefs)
(if first
(setq xrefs (ssget "I" '((0 . "INSERT"))))
(progn
(setq xrefs (ssget '((0 . "INSERT"))))
(setq first nil)
))
(if xrefs (progn
(setq idx -1)
(repeat (sslength xrefs)
(setq en (ssname xrefs (setq idx (1+ idx))) )
(if (not (vlax-property-available-p (vlax-ename->vla-object en) 'Path)) (progn
;(command "._select" xrefs "_remove" en "")
(ssdel en xrefs)
(setq idx (1- idx))
))
)
(if (= (sslength xrefs) 0)
(setq xrefs nil)
(if first
(print (sslength xrefs))
;(sssetfirst nil xrefs)
;(command "._Pselect" xrefs "")
)
;(command "Select" xrefs "")
)
))
(setq first nil)
)
(if xrefs (progn
;(command "AI_DESELECT")
;(command "._select" xrefs "")
))
xrefs
)
(defun GetClipBoundary (obj / xdict filter spatial elst ptlst)
(if (= (type obj) 'ENAME)
(setq obj (vlax-ename->vla-object obj))
)
(setq elst
(vl-catch-all-apply
'(lambda ()
(setq xdict (vla-getextensiondictionary obj))
(setq filter (vla-getobject xdict "ACAD_FILTER"))
(setq spatial (vla-getobject filter "SPATIAL"))
(entget (vlax-vla-object->ename spatial))
)
)
)
(if (not (vl-catch-all-error-p elst)) (progn
;; if rectangular, 11 holds the origin, still looking for the ucs, somewhere inside the 40 (elements 13, 14 and 15 holds UCS x vector)
(foreach x elst
(if (eq 10 (car x))
(setq ptlst (cons (cdr x) ptlst))
)
)
))
ptlst
) ;end
(defun _XXA (xrefs file / xr vla xclip insertedBlock npl oldPick) ;xrefs file
(command "_.undo" "_begin")
(setq oldPick (getvar "PICKFIRST"))
(setvar "PICKFIRST" 0)
(command "_.UCS" "World")
(while (> (sslength xrefs) 0) (progn
(setq xr (ssname xrefs 0)
vla (vlax-ename->vla-object xr)
xclip (GetClipBoundary vla)
)
(setq insertedBlock (vla-AttachExternalReference
(vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object) ))
file
(vl-filename-base file)
(vlax-3d-point (vlax-get vla 'insertionpoint))
(vlax-get vla 'XScaleFactor)
(vlax-get vla 'YScaleFactor)
(vlax-get vla 'ZScaleFactor)
(vlax-get vla 'rotation)
:vlax-false))
(if (not (null xclip)) (progn
(command "_.xclip" xr "" "_P")
(setq npl (entlast))
(command "_.xclip" (vlax-vla-object->ename insertedBlock) "" "n" "s" npl)
(entdel npl)
(setq npl nil)
))
(ssdel xr xrefs)
)); end while
(command "_.UCS" "Previous")
(setvar "PICKFIRST" oldPick)
(setq oldPick nil)
(command "_.undo" "_end")
(setq xrefs nil
xr nil
vla nil
xclip nil
file nil
insertedBlock nil
npl nil
oldPick nil
)
);enf od _XXA | 3,451 | Common Lisp | .l | 126 | 22.126984 | 137 | 0.599634 | Voulz/Autocad-Scripts | 1 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | c2f9097ddd78539a69aab0b0bbd27a8afa4eed2ebe84feb89fd32d6e32d57661 | 26,401 | [
-1
] |
26,402 | XReload.lsp | Voulz_Autocad-Scripts/LISP/XReload.lsp | (vl-load-com)
;; End Undo - Lee Mac
;; Closes an Undo Group.
(defun LM:endundo ( doc )
(while (= 8 (logand 8 (getvar 'undoctl)))
(vla-endundomark doc)
)
)
(defun C:XReload ( / *error* saveVars restoreVars vars items it _name block err nb)
(princ " :: XReload v0.1.2 - © Voulz\n")
;;;;; Error Handling ;;;;;
(defun *error* ( msg )
(restoreVars vars)
(LM:endundo (vla-get-activedocument (vlax-get-acad-object)))
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\nError: " msg))
)
(princ (strcat "\nError: " msg))
(princ)
);; -- *error* -- ;;
;;;;; Save the given Variables ;;;;;
(defun saveVars ( var / result)
(while (car var)
(setq result (append result (list (cons (strcase (car var)) (getvar (car var)))))
var (cdr var))
)
result
);; -- saveVars -- ;;
;;;;; Restore the given Variables ;;;;;
(defun restoreVars ( vars varname / it)
(if varname ;if we provided a varname, find and reset the one that is matching
(if (and (setq it (assoc (strcase varname) vars))
(cdr it))
(setvar (car it) (cdr it)))
;else reset them all
(while (setq it (car vars))
(if (cdr it) ;if the value is not nil
(setvar (car it) (cdr it)) )
(setq vars (cdr vars))
)
)
);; -- restoreVars -- ;;
;;;;; Actual Reloading
(setq vars (saveVars (list "VISRETAIN"))
nb 0)
(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
(initget "Y N _Yes No")
(if (= "No" (getkword "\n Retain Layer Overrides ? [Yes/No]: <Yes> ")) (setvar "VISRETAIN" 0))
(setq items (ssget "I" '((0 . "INSERT"))))
(while (> (sslength items) 0) (progn
(setq it (ssname items 0)
_name (vla-get-name (vlax-ename->vla-object it))
block (vla-Item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) _name))
(if (= :vlax-true (vla-get-isxref block))
(if (vl-catch-all-error-p (setq err (vl-catch-all-apply 'vla-reload (list block))))
(princ (strcat "\nError reloading XRef '" _name "': " (vl-catch-all-error-message err) ))
(setq nb (1+ nb))
)
)
(ssdel it items)
)); end while
(restoreVars vars nil)
(sssetfirst nil nil)
(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
(princ (strcat "\n " (itoa nb) " XRef" (if (> nb 1) "s" "") " reloaded."))
(princ)
)
(princ "\n >> Loading: XReload v0.1.2 - © Voulz")
| 2,371 | Common Lisp | .l | 68 | 31.602941 | 96 | 0.621503 | Voulz/Autocad-Scripts | 1 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 66a69f0a20733e6ef2039c23ace1841a43491ea8a6d70dadac63fd4a23269845 | 26,402 | [
-1
] |
26,403 | PLClean.lsp | Voulz_Autocad-Scripts/LISP/PLClean.lsp | ;; PLClean.lsp [command name: PLCl to close closed PolyLines and weld overlapping vertices]
;; Voulz, Dec 2015
; DO NOT USE PEDIT, DOESNT OWORK PROPERLY IF NOT VISIBLE ON SCREEN
; (setq coords (vlax-get (vlax-ename->vla-object (ssname (ssget "_A" '((0 . "LWPOLYLINE"))) 0)) 'coordinates))
; (vlax-put obj_vlax 'coordinates coords);replace the coordinate list
; (vlax-put obj_vlax 'closed 1)
; http://adndevblog.typepad.com/autocad/2013/02/change-a-specific-coordinate-in-a-lwpolyline-in-lisp.html
; check entget
; => (setq p (entget (ssname (ssget "I" '((0 . "LWPOLYLINE"))) 0)))
; http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remove-polyline-vertex/td-p/849526
; http://www.theswamp.org/index.php?topic=19865.55;wap2
(defun C:PLClean (/ cmde plset pl plverts start i p1 p2 nb nbtotal nbclosed nbpoly a ncoords change l)
(defun *error*(msg) ; for exitting quietly
(setq *error* nil)
(princ)
)
(princ " ------- Polyline Cleaning -------\n V 1.0 ©Voulz, 2015")
(if (not (setq plset (ssget "I" '((0 . "LWPOLYLINE")) ))) (progn ; if no preselected polylines
(initget "Y N _Yes No")
(if (= (getkword "\n No polyline selected. Run on all the model ? [Yes/No]: <No>")
"Yes") (progn
(setq plset (ssget "_A" '((0 . "LWPOLYLINE"))))
)(progn ; -- else
(princ " --- Please select polylines before running the commnand.")
(exit)
))
)(princ "\n")) ; -- (if (not (setq plset
(princ (strcat " --- Start of Cleaning over " (itoa (sslength plset)) " Polyline(s)...\n"))
(setq cmde (getvar 'cmdecho))
(setvar 'cmdecho 0)
(command "_.undo" "_begin")
(setq nbclosed 0)
(setq nb 0)
(while (> (sslength plset) 0) (progn
(setq pl (ssname plset 0)) ;the actual poly
(setq l (PSimpleUser pl))
(if (= (nth 3 l) T) (setq nbclosed (1+ nbclosed)))
(setq nb (+ nb (nth 2 l)))
;(mapcar '(lambda(x)(print (car x))(princ (cadr x))) (PSimpleUser pl))
(ssdel (ssname plset 0) plset)
)); end while
(command "_.undo" "_end")
(setvar 'cmdecho cmde)
(princ (strcat " --- " (itoa nbclosed) " Polyline(s) closed and " (itoa nb) " Vertice(s) removed ---"))
(princ)
); end defun
;;;=======================[ PSimple.lsp ]=======================
;;; Author: Charles Alan Butler
;;; Version: 1.7 Nov. 24, 2007
;;; Purpose: To remove unnecessary vertex from a pline
;;; Supports arcs and varying widths
;;;=============================================================
;; This version will remove the first vertex if it is colinear
;; and first & last arcs that have the same center
;; command line entry, user selection set pick
(defun c:PSimple () (PSimpleUser nil)(princ))
(defun c:PSimpleV () ; Verbose version
(mapcar '(lambda(x)(print (car x))(princ (cadr x))) (PSimpleUser nil))
(princ)
)
;; User interface Function
;; flag = nil -> user selects a selection set
;; = ENAME -> call the routine
;; = OBJECT -> call the routine
;; = True -> User to select a single entity, repeats
(defun PSimpleUser (flag / ss ent)
(cond
((null flag) ; user selection set pick
(prompt "\n Select polylines to remove extra vertex: ")
(if (setq ss (ssget '((0 . "LWPOLYLINE"))))
(PSimple ss)
)
)
;; next two already have an object so pass to the main routine
((= (type flag) 'ENAME) (PSimple flag))
((= (type flag) 'VLA-object) (PSimple flag))
(t ; user single pick with repeat
(while
(setq ent (car (entsel "\n Select polyline to remove extra vertex: ")))
(if (equal (assoc 0 (entget ent)) '(0 . "LWPOLYLINE"))
(PSimple ent)
(prompt "\nNot a LWPolyline, Try again.")
)
)
)
)
)
;;;=======================[ PSimple.lsp ]=======================
;;; Author: Charles Alan Butler
;;; Version: 1.7 Nov. 23, 2007
;;; Purpose: To remove unnecessary vertex from a pline
;;; Supports arcs and varying widths
;;;=============================================================
;; This version will remove the first vertex if it is colinear
;; and first & last arcs that have the same center
;; Open plines that have the same start & end point will be closed
;; Argument: et
;; may be an ename, Vla-Object, list of enames or
;; a selection set
;; Returns: a list, (ename message)
;; Massage is number of vertex removed or error message string
;; If a list or selection set a list of lists is returned
(defun PSimple (et / doc result Tan Replace BulgeCenter RemoveNlst ps1)
(vl-load-com)
(defun tan (a) (/ (sin a) (cos a)))
(defun replace (lst i itm)
(setq i (1+ i))
(mapcar '(lambda (x) (if (zerop (setq i (1- i))) itm x)) lst)
)
;; CAB 11.16.07
;; Remove based on pointer list
(defun RemoveNlst (nlst lst)
(setq i -1)
(vl-remove-if '(lambda (x) (not (null (vl-position (setq i (1+ i)) nlst)))) lst)
)
(defun BulgeCenter (bulge p1 p2 / delta chord radius center)
(setq delta (* (atan bulge) 4)
chord (distance p1 p2)
radius (/ chord (sin (/ delta 2)) 2)
center (polar p1 (+ (angle p1 p2) (/ (- pi delta) 2)) radius)
)
)
;; Main function to remove vertex
;; ent must be an ename of a LWPolyline
(defun ps1 (ent / aa cpt dir doc elst hlst Remove
idx keep len newb result vlst x closed
d10 d40 d41 d42 hlst p1 p2 p3
plast msg)
;;=====================================================
(setq elst (entget ent)
msg "")
(setq d10 (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) elst)))
(if (> (length d10) 2)
(progn
;; seperate vertex data
(setq d40 (vl-remove-if-not '(lambda (x) (= (car x) 40)) elst))
(setq d41 (vl-remove-if-not '(lambda (x) (= (car x) 41)) elst))
(setq d42 (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 42)) elst)))
;; remove extra vertex from point list
(setq plast (1- (length d10)))
(setq p1 0 p2 1 p3 2)
(if (and (not (setq closed (vlax-curve-isclosed ent)))
(equal (car d10) (last d10) 1e-6))
(progn
(setq Closed t ; close the pline
elst (subst (cons 70 (1+(cdr(assoc 70 elst))))(assoc 70 elst) elst)
msg " Closed and")
(if (and (not(zerop (nth plast d42)))(not(zerop (nth 0 d42))))
(setq d10 (reverse(cdr(reverse d10)))
d40 (reverse(cdr(reverse d40)))
d41 (reverse(cdr(reverse d41)))
d42 (reverse(cdr(reverse d42)))
plast (1- plast)
)
)
)
)
(setq idx -1)
(while (<= (setq idx (1+ idx)) (if closed (+ plast 2) (- plast 2)))
(cond
((and (or (equal (angle (nth p1 d10) (nth p2 d10))
(angle (nth p2 d10) (nth p3 d10)) 1e-6)
(equal (nth p1 d10) (nth p2 d10) 1e-6)
(equal (nth p2 d10) (nth p3 d10) 1e-6))
(zerop (nth p2 d42))
(or (= p1 plast)
(zerop (nth p1 d42)))
)
(setq remove (cons p2 remove)) ; build a pointer list
(setq p2 (if (= p2 plast) 0 (1+ p2))
p3 (if (= p3 plast) 0 (1+ p3))
)
)
((and (not (zerop (nth p2 d42)))
(or closed (/= p1 plast))
(not (zerop (nth p1 d42))) ; got two arcs
(equal
(setq cpt (BulgeCenter (nth p1 d42) (nth p1 d10) (nth p2 d10)))
(BulgeCenter (nth p2 d42) (nth p2 d10) (nth p3 d10))
1e-4)
)
;; combine the arcs
(setq aa (+ (* 4 (atan (abs (nth p1 d42))))(* 4 (atan (abs (nth p2 d42)))))
newb (tan (/ aa 4.0))
)
(if (minusp (nth p1 d42))
(setq newb (- (abs newb)))
(setq newb (abs newb))
)
(setq remove (cons p2 remove)) ; build a pointer list
(setq d42 (replace d42 p1 newb))
(setq p2 (if (= p2 plast) 0 (1+ p2))
p3 (if (= p3 plast) 0 (1+ p3))
)
)
(t
(setq p1 p2
p2 (if (= p2 plast) 0 (1+ p2))
p3 (if (= p3 plast) 0 (1+ p3))
)
)
)
)
(if remove
(progn
(setq count (length d10))
;; Rebuild the vertex data with pt, start & end width, bulge
(setq d10 (RemoveNlst remove d10)
d40 (RemoveNlst remove d40)
d41 (RemoveNlst remove d41)
d42 (RemoveNlst remove d42)
)
(setq result (mapcar '(lambda(w x y z) (list(cons 10 w)
x y
(cons 42 z))) d10 d40 d41 d42)
)
;; rebuild the entity data with new vertex data
(setq hlst (vl-remove-if
'(lambda (x) (vl-position (car x) '(40 41 42 10))) elst)
)
(mapcar '(lambda (x) (setq hlst (append hlst x))) result)
(setq hlst (subst (cons 90 (length result)) (assoc 90 hlst) hlst))
(if (entmod hlst); return ename and number of vertex removed
(list ent (strcat msg " Vertex removed " (itoa(- count (length d10)))) (- count (length d10)) (not (= msg "")) )
(list ent " Error, may be on locked layer." 0 F)
)
)
(list ent "Nothing to remove - no colinear vertex." 0 F)
)
)
(list ent "Nothing to do - Only two vertex." 0 F)
)
)
;; ======== S T A R T H E R E ===========
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(cond
((or (=(type et) 'ENAME)
(and (=(type et) 'VLA-object)
(setq et (vlax-vla-object->ename et))))
(vla-startundomark doc)
(setq result (ps1 et))
(vla-endundomark doc)
)
((= (type et) 'PICKSET)
(vla-startundomark doc)
(setq result (mapcar '(lambda(x) (ps1 x))
(vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))
(vla-endundomark doc)
)
((listp et)
(vla-startundomark doc)
(setq result (mapcar '(lambda(x) (ps1 x)) et))
(vla-endundomark doc)
)
((setq result "PSimple Error - Wrong Data Type."))
)
result
) | 11,109 | Common Lisp | .l | 258 | 32.75969 | 129 | 0.503477 | Voulz/Autocad-Scripts | 1 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 2a13b6bdfc5c891c95b76d53d4cd6668a229bfafa581b1f2760923d31a05bf56 | 26,403 | [
-1
] |
26,404 | LinkScale.lsp | Voulz_Autocad-Scripts/LISP/LinkScale.lsp | (vl-load-com)
(defun C:LinkScale ( / items block vp err atts Choice Done appname attr pref suff new)
(while (not Done)
(setq block nil vp nil err nil)
(if (= 2 (sslength (setq items (ssget)))) (progn
(while (> (sslength items) 0) (progn
(setq new (ssname items 0)) ;the actual poly
(print (cdr (assoc 0 (entget new))))
(cond
((= (cdr (assoc 0 (entget new))) "INSERT")
(print "is insert")
(if (not block)
(setq block new)
(setq err T))
(print block))
((vlax-property-available-p (vlax-ename->vla-object new) 'CustomScale)
(print "has custom scale")
(if (not vp)
(setq vp new)
(setq err T))
(print vp))
)
(ssdel new items)
)); end while
(if err
(print "You need to select a block and a Viewport")
(setq Done T) ;if we have one polyline and one Viewport
)
)(print "You need to select a block and a Viewport"))
);end while
(setq block (vlax-ename->vla-object block)
atts (LM:vl-getattributes block)
appname "Voulz:LinkScale"
attr (getcfg (strcat "AppData/" appname "/Attribute"))
pref (getcfg (strcat "AppData/" appname "/Prefix"))
suff (getcfg (strcat "AppData/" appname "/Suffix"))
Done nil)
(if (or (not attr) (= attr "")) (setq attr "VIEWPORTSCALE"))
(if (not pref) (setq pref ""))
(if (not suff) (setq suff " MTS"))
(print "here")
(while (not Done)
(initget "Attribute pRefix Suffix")
(setq Choice (getkword (strcat "Enter an Option or press Enter to continue "
"{\"" attr "\", \"" pref "\", \"" suff "\"}"
"[Attribute/pRefix/Suffix]: ")))
(cond
((= Choice nil) (setq Done T))
((= Choice "Attribute")
(while (not Done)
(print "Attributes of the block :")(print)
(foreach new atts (princ (strcat " '" (car new) "'")))
(setq new (getstring T (strcat "\nAttribute of the block to set: <" attr "> ")))
(if (or (= new "") (= new " ")) (setq new attr))
(if (not (assoc new atts))
(print (strcat "The block doesn't have an attribute named '" new "'"))
(setq Done T
attr new)
)
)
(setq Done nil)
(setcfg (strcat "AppData/" appname "/Attribute") attr)
)
((= Choice "pRefix")
(setq Done (getvar "DYNPROMPT")) (setvar "DYNPROMPT" 0) ;needed to allow leading and trailing spaces
(setq new (getstring T (strcat "\nPrefix" (if (not (= "" pref)) " (type space to remove the Prefix)" "") ": <" pref "> ")))
(if (= new "") (setq new pref))
(if (= new " ") (setq new ""))
(setq pref new)
(setcfg (strcat "AppData/" appname "/Prefix") pref)
(setvar "DYNPROMPT" Done) (setq Done nil)
)
((= Choice "Suffix")
(setq Done (getvar "DYNPROMPT")) (setvar "DYNPROMPT" 0) ;needed to allow leading and trailing spaces
(setq new (getstring T (strcat "\nSuffix" (if (not (= "" suff)) " (type space to remove the Suffix)" "") ": <" suff "> ")))
(if (= new "") (setq new suff))
(if (= new " ") (setq new ""))
(setq suff new)
(setcfg (strcat "AppData/" appname "/Suffix") suff)
(setvar "DYNPROMPT" Done) (setq Done nil)
)
)
)
(if (not (assoc attr atts))
(print (strcat "The block need to have an attribute named '" attr "' (case sensitive)"))
(progn
(LM:vl-setattributevalue block attr (strcat pref
"%<\\AcObjProp Object(%<\\_ObjId "
(itoa(vla-get-ObjectID (vlax-ename->vla-object vp)))
">%).CustomScale \\f \"1:%lu2%ct1%qf2816\">%"
suff))
(command "REGEN")
(print "--- Scale Linked !")
))
(princ)
)
;; Set Attribute Value - Lee Mac
;; Sets the value of the first attribute with the given tag found within the block, if present.
;; blk - [vla] VLA Block Reference Object
;; tag - [str] Attribute TagString
;; val - [str] Attribute Value
;; Returns: [str] Attribute value if successful, else nil.
(defun LM:vl-setattributevalue ( blk tag val )
(setq tag (strcase tag))
(vl-some
'(lambda ( att )
(if (= tag (strcase (vla-get-tagstring att)))
(progn (vla-put-textstring att val) val)
)
)
(vlax-invoke blk 'getattributes)
)
)
;; Get Attributes - Lee Mac
;; Returns an association list of attributes present in the supplied block.
;; blk - [vla] VLA Block Reference Object
;; Returns: [lst] Association list of ((<Tag> . <Value>) ... )
(defun LM:vl-getattributes ( blk )
(mapcar '(lambda ( att ) (cons (vla-get-tagstring att) (vla-get-textstring att)))
(vlax-invoke blk 'getattributes)
)
)
(print ">> LinkScale loaded.")
| 4,498 | Common Lisp | .l | 123 | 32.227642 | 126 | 0.616284 | Voulz/Autocad-Scripts | 1 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 938903ab75f4b7fd01dea83724f3b32282cc44c2429c410aa1ce92e363c11450 | 26,404 | [
-1
] |
26,405 | Select All Xrefs.lsp | Voulz_Autocad-Scripts/LISP/Select All Xrefs.lsp | (vl-load-com)
(defun C:SelectXRefS (/ xr_blk blk mSS ss)
(setq xr_blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
mSS (ssadd))
(vlax-for blk xr_blk
(if (= (vla-get-IsXRef blk) :vlax-true)(progn
(setq ss (ssget "_X" (list
'(0 . "INSERT")
(cons 2 (vla-get-name blk))
(cons 410
(if (eq 1 (getvar 'CVPORT)) ; Current Space only
(getvar 'CTAB)
"Model"
)
) ))
)
(if (/= nil ss)
(while (> (sslength ss) 0) (progn
(ssadd (ssname ss 0) mSS)
(ssdel (ssname ss 0) ss)
)); end while
)
))
)
(sssetfirst nil mSS)
)
| 657 | Common Lisp | .l | 26 | 19.076923 | 78 | 0.525397 | Voulz/Autocad-Scripts | 1 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 30c5301610e3437e9a0bd2bd1fdc03bfb56adb1827b71e0016f7ba278beb9e13 | 26,405 | [
-1
] |
26,428 | doit.lsp | shepherdjerred-homework_algebraic-simplification/src/doit.lsp |
;This is the file DOIT.LSP - DO NOT CHANGE IT
(load 'tbsimplify)
(load 'r)
(setq term0 '(+ Mary (+ Sue (- Sue))))
(pprint (setq a0 (simplify term0 r)))
(setq term1 '(+ saw (+ (+ had (+ heard (- heard))) (- had))))
(pprint (setq a1 (simplify term1 r)))
(setq term2 '(+ (+ (- (* a b)) (* a b)) a))
(pprint (setq a2 (simplify term2 r)))
(setq term3 '(* big (/ little little)))
(pprint (setq a3 (simplify term3 r)))
(setq term4 '(+ (* 1 (/ 0 (+ ludicrous bright (* invisible dangerous)))) silly))
(pprint (setq a4 (simplify term4 r)))
(setq term5 '(+ (+ (- tempermental) tempermental) (- (- lovable))))
(pprint (setq a5 (simplify term5 r)))
(setq term6 '(+ (- ugly (* (/ big big) ugly)) cute))
(pprint (setq a6 (simplify term6 r)))
(setq term7 '(+ (* (+ (- pig) pig)(- dog))(/ (* pig (+ dog cat))(+ dog cat))))
(pprint (setq a7 (simplify term7 r)))
(pprint (setq ans (list a0 a1 a2 a3 a4 a5 a6 a7)))
| 900 | Common Lisp | .l | 20 | 43.85 | 80 | 0.600912 | shepherdjerred-homework/algebraic-simplification | 1 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 7dd3e0cff07d7edfbb17d881a31341356dbdb73ce3536dd2304d4b844c14f7e8 | 26,428 | [
-1
] |
26,429 | tbsimplify.fas | shepherdjerred-homework_algebraic-simplification/src/tbsimplify.fas | (|SYSTEM|::|VERSION| '(20100806.))
#0Y_ #0Y |CHARSET|::|UTF-8|
#Y(#:|1 1 (LOAD 'MATCH)-1| #15Y(00 00 00 00 00 00 00 00 20 01 DA 2F 01 19 01)
(|COMMON-LISP-USER|::|MATCH| |COMMON-LISP|::|LOAD|)
(|COMMON-LISP|::|T| |COMMON-LISP|::|T| |COMMON-LISP|::|T|))
#Y(#:|3 10 (DEFUN SIMPLIFY (TERM R) ...)-2|
#20Y(00 00 00 00 00 00 00 00 20 01 DA 2F 01 DA DC 32 9C C5 19 01)
(|COMMON-LISP-USER|::|SIMPLIFY| |SYSTEM|::|REMOVE-OLD-DEFINITIONS|
#Y(|COMMON-LISP-USER|::|SIMPLIFY|
#26Y(00 00 00 00 02 00 00 00 26 03 AE AE 70 00 92 00 03 A0 19 04 14 AF
29 02 06 70)
(|COMMON-LISP-USER|::|FINDMATCH|)
(|COMMON-LISP|::|T| |COMMON-LISP|::|T| |COMMON-LISP|::|T|)
(|COMMON-LISP-USER|::|TERM| |COMMON-LISP-USER|::|R|)
|COMMON-LISP|::|NIL| 1))
(|COMMON-LISP|::|T| |COMMON-LISP|::|T| |COMMON-LISP|::|T|))
#Y(#:|12 20 (DEFUN FINDMATCH (TERM R) ...)-3|
#20Y(00 00 00 00 00 00 00 00 20 01 DA 2F 01 DA DC 32 9C C5 19 01)
(|COMMON-LISP-USER|::|FINDMATCH| |SYSTEM|::|REMOVE-OLD-DEFINITIONS|
#Y(|COMMON-LISP-USER|::|FINDMATCH|
#35Y(00 00 00 00 02 00 00 00 26 03 AE 94 02 B0 6E 03 00 93 02 05 93 00
05 19 04 00 19 04 AF 95 03 29 02 06 67)
(|COMMON-LISP-USER|::|FINDMATCH2|)
(|COMMON-LISP|::|T| |COMMON-LISP|::|T| |COMMON-LISP|::|T|)
(|COMMON-LISP-USER|::|TERM| |COMMON-LISP-USER|::|R|)
|COMMON-LISP|::|NIL| 1))
(|COMMON-LISP|::|T| |COMMON-LISP|::|T| |COMMON-LISP|::|T|))
#Y(#:|22 34 (DEFUN FINDMATCH2 (L PATTERN TERM) ...)-4|
#20Y(00 00 00 00 00 00 00 00 20 01 DA 2F 01 DA DC 32 9C C5 19 01)
(|COMMON-LISP-USER|::|FINDMATCH2| |SYSTEM|::|REMOVE-OLD-DEFINITIONS|
#Y(|COMMON-LISP-USER|::|FINDMATCH2|
#58Y(00 00 00 00 03 00 00 00 26 04 AF 94 03 70 00 93 04 06 92 00 06 A1
21 0C 00 19 05 B0 B0 B0 AF 2D 04 01 19 05 A1 5B 20 08 94 04 B0 B0
28 5C 1E 08 95 04 B0 B0 29 03 08 52 19 05)
(|COMMON-LISP-USER|::|MATCH| |COMMON-LISP-USER|::|SBST|)
(|COMMON-LISP|::|T| |COMMON-LISP|::|T| |COMMON-LISP|::|T|)
(|COMMON-LISP-USER|::|L| |COMMON-LISP-USER|::|PATTERN|
|COMMON-LISP-USER|::|TERM|)
|COMMON-LISP|::|NIL| 1))
(|COMMON-LISP|::|T| |COMMON-LISP|::|T| |COMMON-LISP|::|T|))
#Y(#:|36 39 (DEFUN SBST (L PATTERN TERM ...) ...)-5|
#20Y(00 00 00 00 00 00 00 00 20 01 DA 2F 01 DA DC 32 9C C5 19 01)
(|COMMON-LISP-USER|::|SBST| |SYSTEM|::|REMOVE-OLD-DEFINITIONS|
#Y(|COMMON-LISP-USER|::|SBST|
#23Y(00 00 00 00 04 00 00 00 26 05 AD A1 5C 78 70 00 B1 B0 2D 03 01 19
05)
(|COMMON-LISP-USER|::|APPLYSUBST| |COMMON-LISP-USER|::|REPLVAR|)
(|COMMON-LISP|::|T| |COMMON-LISP|::|T| |COMMON-LISP|::|T|)
(|COMMON-LISP-USER|::|L| |COMMON-LISP-USER|::|PATTERN|
|COMMON-LISP-USER|::|TERM| |COMMON-LISP-USER|::|SUBLIST|)
|COMMON-LISP|::|NIL| 1))
(|COMMON-LISP|::|T| |COMMON-LISP|::|T| |COMMON-LISP|::|T|))
#Y(#:|41 46 (DEFUN APPLYSUBST (SUBLIST PATTERN) ...)-6|
#20Y(00 00 00 00 00 00 00 00 20 01 DA 2F 01 DA DC 32 9C C5 19 01)
(|COMMON-LISP-USER|::|APPLYSUBST| |SYSTEM|::|REMOVE-OLD-DEFINITIONS|
#Y(|COMMON-LISP-USER|::|APPLYSUBST|
#35Y(00 00 00 00 02 00 00 00 26 03 92 02 06 9E 19 03 93 02 7A 9F 5B 79
A0 5B 78 95 04 B0 6C 72 2D 03 00 19 03)
(|COMMON-LISP-USER|::|REPLVAR|)
(|COMMON-LISP|::|T| |COMMON-LISP|::|T| |COMMON-LISP|::|T|)
(|COMMON-LISP-USER|::|SUBLIST| |COMMON-LISP-USER|::|PATTERN|)
|COMMON-LISP|::|NIL| 1))
(|COMMON-LISP|::|T| |COMMON-LISP|::|T| |COMMON-LISP|::|T|))
#Y(#:|48 58 (DEFUN REPLVAR (NEW OLD LIST) ...)-7|
#20Y(00 00 00 00 00 00 00 00 20 01 DA 2F 01 DA DC 32 9C C5 19 01)
(|COMMON-LISP-USER|::|REPLVAR| |SYSTEM|::|REMOVE-OLD-DEFINITIONS|
#Y(|COMMON-LISP-USER|::|REPLVAR|
#67Y(00 00 00 00 03 00 00 00 26 04 92 01 17 00 19 04 A0 19 04 9E 19 04
A0 1B 20 AF AF 94 03 28 02 1B 18 93 01 69 AE AE 8E 14 67 9E 20 67
AE 94 02 8E 14 64 94 01 8E 1D 62 9E 5B 14 B0 B0 95 04 28 61 5D 19
04)
() (|COMMON-LISP|::|T| |COMMON-LISP|::|T| |COMMON-LISP|::|T|)
(|COMMON-LISP-USER|::|NEW| |COMMON-LISP-USER|::|OLD|
|COMMON-LISP|::|LIST|)
|COMMON-LISP|::|NIL| 1))
(|COMMON-LISP|::|T| |COMMON-LISP|::|T| |COMMON-LISP|::|T|))
| 4,276 | Common Lisp | .l | 76 | 49.75 | 77 | 0.577143 | shepherdjerred-homework/algebraic-simplification | 1 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 4b257be9806cadd9fe6f7f450b220c4a2984e179f92e36a5fb13db0af2a8d6ff | 26,429 | [
-1
] |
26,447 | test.lisp | m-e-leypold_romulan/test.lisp | ;;; Romulan - Declarative interface to the clingon command line argument parser.
;;; Copyright (C) 2023 M E Leypold
;;;
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation, either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;;
;;; * Options -----------------------------------------------------------------------------------------------|
(declaim (optimize (speed 0) (space 0) (compilation-speed 0) (debug 3) (safety 3)))
;;; * Load system to be tested & the tests ------------------------------------------------------------------|
(asdf:load-system "de.m-e-leypold.romulan/tests")
;;; * define sandbox for tests ------------------------------------------------------------------------------|
(defpackage :de.m-e-leypold.cl-specification/run-tests
(:documentation "Sandbox for testing romulan")
(:use
:common-lisp
:de.m-e-leypold.romulan/tests))
(in-package :de.m-e-leypold.cl-specification/run-tests)
;;; * Actually executing the tests --------------------------------------------------------------------------|
| 1,589 | Common Lisp | .lisp | 28 | 55.107143 | 110 | 0.585319 | m-e-leypold/romulan | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | e5e93a7667d11b06610e08a5e3c575185e1713f78390b0b79faba0ac2a1116e3 | 26,447 | [
-1
] |
26,448 | de.m-e-leypold.romulan.asd | m-e-leypold_romulan/de.m-e-leypold.romulan.asd | ;;; ------------------------------------------------------------------------*- common-lisp -*-|
;;; Romulan - Declarative interface to the clingon command line argument parser.
;;; Copyright (C) 2023 M E Leypold
;;;
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation, either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;;
(defsystem "de.m-e-leypold.romulan"
:description "Declarative interface to clingon"
:author "M E Leypold [elegant-weapons (AT) m-e-leypold (DOT) de]"
:licence "GPL3"
:depends-on ("clingon")
:components ((:file "romulan")))
(defsystem "de.m-e-leypold.romulan/tests"
:description "Tests and specifications for ROMULAN"
:author "M E Leypold [elegant-weapons (AT) m-e-leypold (DOT) de]"
:licence "GPL3"
:depends-on ("de.m-e-leypold.romulan")
:components ((:file "tests")))
(defsystem "de.m-e-leypold.romulan/prerequisites"
:author "M E Leypold [elegant-weapons (AT) m-e-leypold (DOT) de]"
:licence "GPL3"
:depends-on ("clingon")
:description "Just all external prerequisites")
(defsystem "de.m-e-leypold.romulan/load-all"
:author "M E Leypold [elegant-weapons (AT) m-e-leypold (DOT) de]"
:licence "GPL3"
:description "Load all systems in ROMULAN"
:depends-on ("de.m-e-leypold.romulan"))
| 1,805 | Common Lisp | .asd | 39 | 44.205128 | 95 | 0.694886 | m-e-leypold/romulan | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | ce82d923a78c71292538a4e0178e3c60ac6eefe985e13123f1f17fb49e30ebab | 26,448 | [
-1
] |
26,450 | .dir-locals.el | m-e-leypold_romulan/.dir-locals.el | ;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((lisp-mode . ((outshine-startup-folded-p . t)
(comment-empty-lines . t)
(comment-style . 'plain)
(outline-regexp . ";;; [*]\\{1,8\\} ")
(comment-add . 2)
(eval . (progn
(outshine-mode 1)
(column-enforce-mode 1)
(toggle-truncate-lines 1)))
(fill-column . 95)
(column-enforce-column . 110))))
;; Note: outshine-startup-folded-p does not work (even as global
;; variable), perhaps because outshine mode is activated too late
;; (after file loading). I'll have to look for the recommendations in
;; the outshine install instructions and see if this is going to give
;; more joy in this regard.
| 757 | Common Lisp | .l | 18 | 37.166667 | 69 | 0.656716 | m-e-leypold/romulan | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | fb11128fa30e25f396ecf23e60d0e760aa5fb6dfde4807a88de12d9c044cc8a8 | 26,450 | [
-1
] |
26,451 | Makefile | m-e-leypold_romulan/Makefile | # Romulan - Declarative interface to the clingon command line argument parser.
# Copyright (C) 2023 M E Leypold
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# * Targets --------------------------------------------------
all::
install::
live-install::
.PHONY: @always
.ONESHELL:
# * Software name --------------------------------------------
SHORT-NAME ?= $(shell echo "$(notdir $(CURDIR))" | sed 's|_.*||')
# * Installation ---------------------------------------------
# ** Parameters ----------------------------------------------
DEST ?= $(CURDIR)/.stage
PREFIX ?= /usr/local
LISPDIR ?= $(PREFIX)/share/common-lisp/source/$(SHORT-NAME)
BINDIR ?= $(PREFIX)/bin
LISPFILES ?= $(wildcard *.lisp *.asd)
BINFILES ?= $(patsubst ./%,%,\
$(shell find . -maxdepth 1 -mindepth 1 -executable -type f))
LISPFILES := $(strip $(LISPFILES))
BINFILES := $(strip $(BINFILES))
USER-BINDIR ?= $(lastword $(wildcard ~/my/scripts/bin ~/my/bin ~/bin ~/.local/bin))
USER-LISPROOT ?= $(lastword \
$(wildcard ~/share/common-lisp/source ~/my/asdf ~/.asdf))
USER-LISPDIR := $(USER-LISPROOT)/$(SHORT-NAME)
$(info PREFIX = $(PREFIX))
$(info DEST = $(DEST))
$(info BINDIR = $(BINDIR))
$(info LISPDIR = $(LISPDIR))
$(info USER-BINDIR = $(USER-BINDIR))
$(info USER-LISPDIR = $(USER-LISPDIR))
ifneq ($(LISPFILES),)
install:: install-lisp
live-install:: live-install-lisp
endif
ifneq ($(BINFILES),)
install:: install-bin
live-install:: live-install-bin
endif
# ** Staging for packaging (or direct installation) ----------
$(BINFILES:%=.build/bin/%): .build/bin/%: %
set -eu
mkdir -p "$(@D)"
sed < "$<" '/^[#][!]/s|^[#][!].*|#!/usr/bin/sbcl --script|' >$@
install-lisp:
set -eu
mkdir -p $(DEST)$(LISPDIR)
install -m 644 $(LISPFILES) $(DEST)$(LISPDIR)
install-bin: $(BINFILES:%=.build/bin/%)
set -eu
mkdir -p $(DEST)$(BINDIR)
install -m 755 $(BINFILES:%=.build/bin/%) $(DEST)$(BINDIR)/
clean::
rm -rf $(DEST)
# ** Live installation (with links) --------------------------
live-install-lisp:
set -eu
rm -f $(USER-LISPDIR)
ln -s $(CURDIR) $(USER-LISPDIR)
live-install-bin:
set -eu
ln -sf $(BINFILES:%=$(CURDIR)/%) $(USER-BINDIR)/
# * Arch packages --------------------------------------------
VERSION := $(shell git describe --tags)
PKGVER := $(shell echo "$(VERSION)" | sed 's|[-]|+|g' | tr '[A-Z]' '[a-z]')
TARFILE := $(SHORT-NAME)-$(VERSION).tar.gz
PACKAGE := $(SHORT-NAME)-$(PKGVER)-1-any.pkg.tar.zst
$(info VERSION = $(VERSION))
$(info PKGVER = $(PKGVER))
$(info PACKAGE = $(PACKAGE))
$(info TARFILE = $(TARFILE))
.build/arch-package/PKGBUILD.$(VERSION):: PKGBUILD.t
set -eu
mkdir -p "$(@D)"
sed <$< \
's|__PKGVER__|$(PKGVER)|g;s|__PKGNAME__|$(SHORT-NAME)|g;s|__VERSION__|$(VERSION)|' \
>$@
.build/arch-package/PKGBUILD: .build/arch-package/PKGBUILD.$(VERSION)
set -eu
mkdir -p "$(@D)"
cp $< $@
.build/arch-package/$(TARFILE):: .build/arch-package/PKGBUILD.$(VERSION)
set -eu
mkdir -p "$(@D)"
git archive -o "$@" HEAD
.build/arch-package/$(PACKAGE): .build/arch-package/$(TARFILE) .build/arch-package/PKGBUILD
set -eu
cd .build/arch-package/
rm -rf pkg src
makepkg -f
package: .build/arch-package/$(PACKAGE)
clean::
rm -rf .stage .build
# * Project integration --------------------------------------
-include Project/Project.mk
Project:
git clone -b project --single-branch . Project
project-setup: Project
make git-setup
# * Epilog ---------------------------------------------------
$(info )
| 4,160 | Common Lisp | .l | 115 | 33.93913 | 96 | 0.600499 | m-e-leypold/romulan | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | f332b4249a547d00294c1356debffa3dea477d627039d9e5791b740c79fcb12f | 26,451 | [
-1
] |
26,468 | main.lisp | WarrenWilkinson_music-engine/main.lisp | (in-package :cl-user)
(format t "~%Loading 3rd party dependencies with quicklisp...~%")
(ql:quickload "osc") ;; https://github.com/zzkt/osc
(ql:quickload "cffi") ;; https://github.com/zzkt/osc
(ql:quickload "cl-gobject-introspection") ;; https://github.com/andy128k/cl-gobject-introspection
(ql:quickload "cl-cairo2") ;; https://github.com/andy128k/cl-gobject-introspection
(ql:quickload "lparallel") ;; https://github.com/andy128k/cl-gobject-introspection
(format t "~%Loading music engine...")
(asdf:initialize-source-registry
`(:source-registry
(:tree ,*default-pathname-defaults*)
:inherit-configuration))
;; (asdf:load-system "music-engine")
(asdf:load-system :cl-alsa-midi)
;; TODO, it's time to start working on pipewire's session manager.
;; I want some my MIDI to automatically connect to fluidsynth...
;; BUT IF either isn't started, then some LED should be RED.
;; Also, I don't like the "on-click" method of the piano sending the
;; events... that SHOULD be coming from the instrument itself.
;; The gui is flaky... and I'd like to be able to trigger things
;; even if it's not running.
;; (format t "~%Starting up MIDI interface...")
;; ;; Start up the MIDI interface; run `aconnect -lio` to see it.
;; (cl-alsa-midi/midihelper:midihelper-start)
;; This might work, but I found timidy to be less reliable: pw-jack timidity -Oj
;; pw-jack fluidsynth -a jack -g 5 -v
;; qpwgraph
;; sudo apt-get install gir1.2-wp-0.4
(defvar *gobject* (gir:require-namespace "GObject"))
(defvar *glib* (gir:require-namespace "GLib"))
(defvar *wp* (gir:require-namespace "Wp" "0.4")) ;; Wire Plumber
;; Why this not work? It feels like it should, maybe needs wp-0.5.
;; (gir:invoke (*gobject* "type_from_name") "WpDevice")
;; (gir:invoke (*gobject* "g_type_from_name" "WpNode"))
;; Find the structure...
;; (find "WpObjectInterest" (gir:repository-get-infos nil "Wp") :key #'gir:registered-type-info-get-type-name :test #'string-equal)
;;
;; (defvar *wp-node* (gir:nget *wp* "Node"))
#|
;; In order to get the config, I'm finding it's not exposed via the GIR
;; in 0.4:
;; However, it doesn't seem like it should be needed. In 0.4 you don't
;; pass in a configuration file, but a GMainContext -- and it should just grab
;; the default one if it needs it...
(eval-when (:compile-toplevel :load-toplevel :execute)
(cffi:define-foreign-library wp
;;(:darwin "libwp-0.4.dylib")
(:unix "libwireplumber-0.4.so.0")))
(cffi:use-foreign-library wp)
(cffi:defcfun (c/wp-conf-new-open "wp_conf_new_open") :pointer
(path :string)
(out :pointer))
(defun wp-conf-new-open (path)
(cffi:with-foreign-object (error-message ':pointer)
(let ((conf-object (c/wp-conf-new-open path (cffi:make-pointer (cffi:pointer-address error-message)))))
(unless (cffi:null-pointer-p error-message)
(error (cffi:foreign-string-to-lisp (cffi:mem-ref error-message :pointer 8)
:max-chars 128)))
conf-object)))
(wp-conf-new-open "")
|#
;(cffi:defcfun (wp-proxy-get-type "wp_proxy_get_type") :uint)
;; (print "Is my core connected?")
;; (print (gir:invoke (*core* "is_connected")))
;; ;; (print (gir:invoke (*context* "iteration") t))
;; (gir:invoke (*core* "connect"))
;; (print "Is my core connected?")
;; (print (gir:invoke (*core* "is_connected")))
;; (defvar *interest* (gir:invoke (*wp* "ObjectInterest" 'new_type) *wp-node-g-type*))
;; (defvar *object-manager* (gir:invoke (*wp* "ObjectManager" 'new)))
;; (gir:invoke (*object-manager* "add_interest_full") *interest*) ;; this fails if wp_init hasn't been called.
;; (print "My g_main_context is...")
;; (print (gir:invoke (*core* "get_g_main_context")))
;; (print "Is my object manager installed?")
;; (print (gir:invoke (*object-manager* "is_installed")))
;; ;; Maybe I need some properties?
;; ;; AHA ! The problem was my event loop wasn't running, so nothing happens. If I manually run it several times things work well.
;; ;; My next task is to understand this gmaincontext loop stuff and figure out what threads I'll have and how to ensure my
;; ;; gui works without fucking me over.
;; (gir:invoke (*core* "install_object_manager") *object-manager*)
;; (print "Is my object manager installed?")
;; (print (gir:invoke (*object-manager* "is_installed")))
(defparameter *should-quit* nil)
(defvar *output* *standard-output*)
(defvar *wire-plumber-initialized-p* nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Wire Plumber State Management
(defstruct (wire-plumber-state-manager (:conc-name "WPSM-"))
(current-state+updates (cons nil nil) :type cons :read-only nil)
(desired-state nil :type list :read-only nil))
(defun wpsm-apply-updates-to-state (state updates)
;; BOGUS implementation
(append state updates))
(defun wpsm-append-updates (wpsm updates)
"Push a fact into the wire-plumber state manager in a thread safe way. This fact will be included on the next invocation of state-manager-compute-changes."
(tagbody
:try-again
(destructuring-bind (&whole whole state . pending-updates) (wpsm-current-state+updates wpsm)
(if (eq whole (sb-ext:compare-and-swap
(wpsm-current-state+updates wpsm)
whole
(cons state (append pending-updates updates))))
t
(go :try-again)))))
(defun wpsm-current-state (wpsm)
"Returns the current-state of the wire-plumber (in a thread safe way). Any pending 'new updates' will be automatically incorporated."
(tagbody
:try-again
(destructuring-bind (&whole whole state . updates) (wpsm-current-state+updates wpsm)
(if (null updates)
state
(if (eq whole (sb-ext:compare-and-swap
(wpsm-current-state+updates wpsm)
whole
(cons (wpsm-apply-updates-to-state state updates) nil)))
state
(go :try-again))))))
(defun wire-plumber-state-manager-compute-changes (wpsm cancelled-p-callback)
"If cancelled-p-callback returns T, execution will stop."
(let ((state (wpsm-current-state wpsm))
(desired-state (wpsm-desired-state wpsm)))
;; Now that we're done updating, a good time to see if already cancelled!
(loop :repeat 5
:do (funcall cancelled-p-callback)
:do (sleep .1d0))
;; BOGUS implementation
(let ((difference (- (length state) (length desired-state))))
(if (> difference 0)
(make-list difference :initial-element :do-something)
:no-changes-necessary))))
(defun wpsm-clear (wpsm)
"Clear state and updates from the wire-plumber-state-manager, leaving only the desired state."
(let ((new-value (cons nil nil)))
(tagbody
:try-again
(let ((prior (wpsm-current-state+updates wpsm)))
(if (eq prior (sb-ext:compare-and-swap
(wpsm-current-state+updates wpsm)
prior
new-value))
(length prior)
(go :try-again))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Motor Queue tasks
(deftype task-type () '(member :compute-desired-wire-plumber-changes))
(deftype id () '(and (integer 0) fixnum))
(defvar *id-counter* (list 0))
(declaim (inline gen-task-id))
(defun gen-task-id ()
(sb-ext:atomic-incf (car *id-counter*)))
(defstruct task-command)
(defstruct (task-with-id-command (:include task-command))
(id (error "id must be provided") :type id :read-only t))
(defstruct (start-task-command (:include task-with-id-command))
"Request a task should be started."
(task-type nil :type task-type :read-only t)
(arguments nil :type t :read-only t))
(defstruct (cancel-task-command (:include task-with-id-command))
"Specify that a specific task should be cancelled.")
(defstruct (cancel-task-type-command (:include task-command))
"Specify that all tasks of a given type should be cancelled."
(task-type nil :type task-type :read-only t))
(defstruct (complete-task-command (:include task-with-id-command))
"When a task finishes, it should emit this."
(result nil :type t :read-only t))
(defstruct (notice-termination-task-command (:include task-with-id-command))
"When a task notices it has been cancelled, it should emit this.")
(defstruct motor-queue
"Represents parameters to a motor... basically it's a waitqueue.
buffer is where messages come in/out. See motor-queue-pop/push.
waitqueue and mutex are there for it's protection.
message-history stores start/cancel messages. It's a list. Threads
are allowed to look at it because it's non-destructively modified. Tasks,
for example can call motor-queue-task-is-cancelled-p to see if they should abort.
task-start-callbacks is a hashtable mapping task-types to functions of (motor-queue id task-type arguments)
task-complete-callbacks is a hashtable mapping task-types to functions of (motor-queue id task-type arguments results)"
(buffer nil :type list :read-only nil)
(waitqueue (sb-thread:make-waitqueue) :type sb-thread:waitqueue :read-only t)
(mutex (sb-thread:make-mutex :name "motor queue mutex") :type sb-thread:mutex :read-only t)
(message-history nil :type list :read-only nil)
(task-start-callbacks (make-hash-table) :type hash-table :read-only t)
(task-complete-callbacks (make-hash-table) :type hash-table :read-only t))
(defun motor-queue-push (p message)
(check-type p motor-queue)
(check-type message task-command)
(with-slots (buffer waitqueue mutex) p
(sb-thread:with-mutex (mutex)
(push message buffer)
(sb-thread:condition-notify waitqueue))))
(declaim (inline set-motor-queue-start-callback))
(defun set-motor-queue-start-callback (mq task fn)
(setf (gethash task (motor-queue-task-start-callbacks mq)) fn))
(declaim (inline set-motor-queue-complete-callback))
(defun set-motor-queue-complete-callback (mq task fn)
(setf (gethash task (motor-queue-task-complete-callbacks mq)) fn))
(declaim (inline motor-queue-cancel-tasks-of-type))
(defun motor-queue-cancel-tasks-of-type (mq task-type)
(motor-queue-push mq (make-cancel-task-type-command :task-type task-type)))
(declaim (inline motor-queue-start-task))
(defun motor-queue-start-task (mq task-type &optional arguments)
(let ((id (gen-task-id)))
(motor-queue-push mq (make-start-task-command :id id :task-type task-type :arguments arguments))
id))
(defun motor-queue-task-is-cancelled-p (p task-id)
"Returns T if the given task-id is cancelled. Worker threads should poll this at convenient times.
if they notice it, rather than finishing with complete-task-command they should terminate with
notice-termination-task-command."
(check-type p motor-queue)
(check-type task-id id)
(not (null (find-if #'(lambda (message)
(and (typep message 'cancel-task-command)
(= task-id (cancel-task-command-id message))))
(motor-queue-message-history p)))))
(defun motor-queue-pop (p &optional timeout)
(check-type p motor-queue)
(with-slots (buffer waitqueue mutex) p
(sb-thread:with-mutex (mutex)
(loop :until buffer
:do (or (sb-thread:condition-wait waitqueue mutex :timeout timeout)
;; Lock not held, must unwind without touching *data*.
(return-from motor-queue-pop nil)))
(pop buffer))))
(defun motor-handle-message (p message)
(flet ((delete-all-messages-for-id (id)
(check-type id id)
(setf (motor-queue-message-history p)
(remove-if #'(lambda (other-message)
(and (typep other-message 'task-with-id-command)
(= id (task-with-id-command-id other-message))))
(motor-queue-message-history p)))))
(etypecase message
(notice-termination-task-command
;; Since the task is gone, we can remove everything we know about it.
(delete-all-messages-for-id (notice-termination-task-command-id message)))
(complete-task-command
(let* ((id (complete-task-command-id message))
(start-message (find-if #'(lambda (other-message)
(and (typep other-message 'start-task-command)
(= id (start-task-command-id other-message))))
(motor-queue-message-history p))))
(if start-message
(let ((cancel-task-message (find-if #'(lambda (other-message)
(and (typep other-message 'cancel-task-command)
(= id (cancel-task-command-id other-message))))
(motor-queue-message-history p))))
;; If the task was cancelled, we discard it's result.
(unless cancel-task-message
(let* ((task-type (start-task-command-task-type start-message))
(completion-callback (gethash task-type (motor-queue-task-complete-callbacks p))))
(if (typep completion-callback '(or function symbol))
(funcall completion-callback p id task-type (start-task-command-arguments start-message) (complete-task-command-result message))
(warn "Unknown completed task type: ~a" (start-task-command-task-type start-message))))))
(warn "Completed task ~a, but no start message in history!" id))
;; Since the task is done, we can remove everything we know about it.
(delete-all-messages-for-id id)))
(cancel-task-type-command
;; Record a cancellation for request for every started-task with this type.
(let ((target-type (cancel-task-type-command-task-type message)))
;; DEBUG PRINT
(format *output* "~%Cancelling tasks of type ~a" target-type)
(format *output* "~%~s"
(mapcar #'(lambda (start-command)
(make-cancel-task-command :id (start-task-command-id start-command)))
(remove-if-not #'(lambda (other-message)
(and (typep other-message 'start-task-command)
(eq target-type (start-task-command-task-type other-message))))
(motor-queue-message-history p))))
;; DONE DEBUG PRINT
(setf (motor-queue-message-history p)
(nconc
(mapcar #'(lambda (start-command)
(make-cancel-task-command :id (start-task-command-id start-command)))
(remove-if-not #'(lambda (other-message)
(and (typep other-message 'start-task-command)
(eq target-type (start-task-command-task-type other-message))))
(motor-queue-message-history p)))
(motor-queue-message-history p)))))
(cancel-task-command
(push message (motor-queue-message-history p)))
(start-task-command
(let* ((task-type (start-task-command-task-type message))
(start-callback (gethash task-type (motor-queue-task-start-callbacks p))))
(if (typep start-callback '(or function symbol))
(progn (push message (motor-queue-message-history p))
(funcall start-callback p (start-task-command-id message) task-type (start-task-command-arguments message)))
(warn "Unknown started task type: ~a" (start-task-command-task-type message))))))))
(defun motor-iteration (p)
(loop :for message = (motor-queue-pop p 0d0)
:until (null message)
:do (motor-handle-message p message)))
(defun motor-loop (p)
"Should be only one motor-loop per motor queue."
(check-type p motor-queue)
(loop :for message = (motor-queue-pop p)
:when message
:do (motor-handle-message p message)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Main Function
(defun main (motor-queue wpsm)
(check-type motor-queue motor-queue)
(check-type wpsm wire-plumber-state-manager)
;; Initialize WirePlumber
(unless *wire-plumber-initialized-p*
(gir:nget *wp* "InitFlags")
(gir:invoke (*wp* "init") (gir:invoke (*wp* "InitFlags") :all))
(setf *wire-plumber-initialized-p* t))
;; (defvar *wp-node-g-type* (gir:invoke (*gobject* "type_from_name") "WpNode") )
(let* ((main-context (gir:invoke (*glib* "main_context_default")))
(wp-core (gir:invoke (*wp* "Core" 'new) main-context nil)))
;; (defvar *interest* (gir:invoke (*wp* "ObjectInterest" 'new_type) *wp-node-g-type*))
;; (defvar *object-manager* (gir:invoke (*wp* "ObjectManager" 'new)))
;; (gir:invoke (*object-manager* "add_interest_full") *interest*)
;; ;;(defvar *context* )
;; ;; (defvar *core* )
;; ;; ;; (defvar *wp-proxy-g-type* (wp-proxy-get-type))
;; ;;
;; ;; CALLBACKS always called by the thread's context that was in place when the callback was created... interesting.
(gir:connect wp-core "connected"
(lambda (core &rest args)
(declare (ignore args))
(format *output* "~%Core ~s connected." core)
(let* ((node-type (gir:invoke (*gobject* "type_from_name") "WpNode"))
(interest (gir:invoke (*wp* "ObjectInterest" 'new_type) node-type))
(manager (gir:invoke (*wp* "ObjectManager" 'new))))
(gir:invoke (manager "add_interest_full") interest)
;; Okay, so the goal of this wireplumber thing is communication with everything...
;; I want things in a place where I can poke from the REPL... but I also need to
;; build up appropriate data-structures that are really private for managing that
;; communication. Tough design.
;; Okay, so I think what I want here is "crash only programing". So when we switch modes
;; we write a file of the preferences (how things are supposed to be connected and wired up and setup).
;; All the music manager does vis-a-vis wire-plumber is watch for things that are matched and put them
;; in the right state. When music-engine starts up, it loads the preferences file and immediately gets
;; to work.
;; OKAY so I think I need to express my "setup" as a list of nodes, settings, ports and edges.... on the desire
;; side it should be cons of thing and :any. Then I have my current setup, which is a cons of thing and some-identifier.
;;
;; The main loop needs to be able to quickly and locklessly ask "is my pipewire setup complete?" and if not, trigger a task (e.g. via
;; a mutex or broadcast or something) to say -- go and compute a list of pipewire changes necessary. Since this operation takes time
;; it should be run outside the main loop. If the main loop sees any pipewire changes before it completes, it should be able to somehow
;; cancel that job, or at least trigger it's conclusions as invalid so-as not to act upon it. That should be the general pattern for
;; several subsystems.
;;
;; Also an idea -- hook up a TEXT-TO-SPEECH agent so that errors can be voiced. E.g. if some service just isn't running, and I press
;; a button, it should just say "Couldn't fire fluidsynth named XYZ".
;; Okay, how to do cancellable? The worker needs to periodically check if it's cancelled, or needs to be interrupted. Checking is safer.
;; How to communicate that? At atomic GET/SET is one way, but when do things go away from this list? What I'm thinking is MAIN
;; generates a unique ID and says "do the work"... it then creates a thread or task to do that work. Is that a gtask or a lisp side thing?
;; I think Lisp side.. SO a Lisp thread waits until a task is there... a task is either START (id), CANCEL (id) or FINISHED (id, value) It sleeps until
;; a message arrives. If it's FINISHED it pushes the result to another waitqueue or something. Internally it maintains a "status list" so the worker
;; threads it has spawned can determine if they are cancelled or not.
;; Or so messages (START id task-name)
;; (CANCEL id)
;; (FINISHED id value)
(gir:connect manager "installed" (lambda (self)
(format *output* "~%Manager ~a is now installed. I should iterate everything once to ensure wpsm is updated!" self)))
(gir:connect manager "object-added" (lambda (self object)
;; Push changes up...
(wpsm-append-updates wpsm '((:added-node)))
;; These run in reverse FIFO order..
(motor-queue-start-task motor-queue :compute-desired-wire-plumber-changes)
(motor-queue-cancel-tasks-of-type motor-queue :compute-desired-wire-plumber-changes)
(format *output* "~%Manager ~a sees object appear: ~a" self object)))
(gir:connect manager "object-removed" (lambda (self object)
(wpsm-append-updates wpsm '((:deleted-node)))
;; These run in reverse FIFO order..
(motor-queue-start-task motor-queue :compute-desired-wire-plumber-changes)
(motor-queue-cancel-tasks-of-type motor-queue :compute-desired-wire-plumber-changes)
(format *output* "~%Manager ~a sees object disappear: ~a" self object)))
(gir:invoke (core "install_object_manager") manager))))
(gir:connect wp-core "disconnected"
(lambda (core &rest args)
(declare (ignore args))
(format *output* "~%Core ~s disconnected" core)))
;; Connect wire-plumber core
(gir:invoke (wp-core "connect"))
(format *output* "~%Entering main loop.")
;; Do setup stuff, right?
(loop :do (gir:invoke (main-context "iteration") nil)
:do (motor-iteration motor-queue)
;; :do handle other things... midi transport?
:do (sleep .5d0) ;; Remove this later...
;; :do (format *output* "~%core connected: ~s" (gir:invoke (wp-core "is_connected")))
:until *should-quit*)
(format *output* "~%Finished.")))
(defvar *mq* (make-motor-queue))
(defvar *wpsm* (make-wire-plumber-state-manager))
(define-condition cancelled (simple-error) ())
(defvar *kernel* (lparallel:make-kernel 4))
(defun start (&optional (mq *mq*) (wpsm *wpsm*) (kernel *kernel*))
;; Setup the book-keeping agent for storing wire-plumber details necessary for computing the differences.
;; THEN setup motor loop stuff that will let the music-engine create, cancel and respond to results from that subprocess.
(set-motor-queue-start-callback mq :compute-desired-wire-plumber-changes #'(lambda (mq id task arguments)
(declare (ignore arguments))
(format *output* "~%Recomputing wire-plumber state changes (task ~s, id = ~a)" task id)
(let ((lparallel:*kernel* kernel))
(lparallel:future
(handler-case
(motor-queue-push
mq
(make-complete-task-command
:id id
:result
(wire-plumber-state-manager-compute-changes
wpsm
#'(lambda ()
(format *output* "~%Was id = ~a cancelled? ~a" id (motor-queue-task-is-cancelled-p mq id))
(when (motor-queue-task-is-cancelled-p mq id)
(error 'cancelled))))))
(cancelled ()
(motor-queue-push mq (make-notice-termination-task-command :id id))))))))
(set-motor-queue-complete-callback mq :compute-desired-wire-plumber-changes #'(lambda (mq id task arguments results)
(declare (ignore mq arguments))
(format *output* "~%Done task ~s (id = ~a) results = ~a" task id results)))
(wpsm-clear wpsm)
;; Invokes the main loop in a thread so Lisp stays responsive
;; (sb-thread:make-thread #'motor-loop :name "motor-loop" :arguments (list mq))
(sb-thread:make-thread #'main :name "music-engine" :arguments (list mq wpsm)))
;; (sb-posix:setenv "GDK_SYNCHRONIZE" "1" 1)
(break "stop here!")
;; Okay, so wireplumber integration is working better... but still not getting output out yet. Keep trying.
;; If I totally fail I can use pw-dump and pw-link command line tools to do the same effect.
;; Still isn't installed... why?
;; Okay, so I've got wireplumber 0.4.13 (ls /usr/lib/x86_64-linux-gnu/libwir*)
;; The current version is 0.5.56. Need Ubuntu "The Oracular Oriole" to get that!
;; (gir:struct-info-get-methods
;; ;; (slot-value (gir:nget *gtk* "ApplicationWindow") 'gir::info))
;; (gir:list-constructors-desc (gir:nget *wp* "ObjectManager"))
;; (defvar *wp-object-interest-struct* (find "WpObjectInterest" (gir:repository-get-infos nil "Wp") :key #'gir:registered-type-info-get-type-name :test #'string-equal))
;; (gir:struct-info-get-methods *wp-object-interest-struct*)
;; (gir:list-constructors-desc (gir:nget *wp* "ObjectInterest"));*wp-object-interest-struct*)
;; (gir:list-constructors-desc (gir:nget *wp* "ObjectInterest"))
;; (mapcar #'gir:function-info-get-symbol (gir:struct-info-get-methods *wp-object-interest-struct*))
;; ;; (gir:nget *wp* "ObjectManager")
;; (gir:struct-info-get-methods
;; (slot-value (gir:nget *gtk* "ApplicationWindow") 'gir::info))
;; (gir:struct-info-get-methods *wp-object-interest-struct*)
;; The above is probably fine... we're interesting in ANY node...
;; Lets get em!
;; (defvar *wp-node* (gir:nget *wp* "Node"))
;; I think fluidsynth can have the midi port name set... because I think
;; I might want multiple? midi.alsa_seq.id -- Yeah, you can do it.
;; Also it's a library... I can make a program that does all of them..
;; including a router and all kinds of effects... interesting.
;;
;; Okay, so I think I want an object manager.
;; I want to be told if fluidsynth comes on or off, and if my keytar is present or
;; not.
;;
;; So yeah, that's the one... bind that, and see if I can be notified when stuff
;; starts and stops and set an LED based on that.
;;
;; So yeah, as soon as Keytar shows up AND so does fluidsynth, the rule should be
;; to link them. That's the first step. Eventually it'll be a whole stateful beast.
;; WHOAA a soundfont collection is like a gigabyte!
(defvar *gui-redraw-callback* nil
"Set to true when the GUI needs to be redrawn." )
(defun queue-redraw ()
(when *gui-redraw-callback*
(funcall *gui-redraw-callback*)))
;; Okay, divide the problem... EVERY THING draws in a 1x1 box. Not sure about
;; stroke widths... but there you go... wait even this doesn't work exactly...
;; Subdividing is correct --- but things change position, clicks happen, etc...
;; There is definitely "STATE" being passed in... GUI state stuff...
;; For example, an LED has state "ON" or "OFF".
;;
;; It would be bad practice to tie the GUI strongly to the MIDI library...
;; I think I should have a callback handler...
(defstruct cairo-color
(r 0.0d0 :type double-float :read-only t)
(g 0.0d0 :type double-float :read-only t)
(b 0.0d0 :type double-float :read-only t)
(a 1.0d0 :type double-float :read-only t))
(defparameter *black* (make-cairo-color :r 0.0d0 :g 0.0d0 :b 0.0d0))
(defparameter *white* (make-cairo-color :r 1.0d0 :g 1.0d0 :b 1.0d0))
(defparameter *basic-led-red-on* (make-cairo-color :r 0.6d0 :g 0.0d0 :b 0.0d0))
(defparameter *basic-led-red-off* (make-cairo-color :r 0.2d0 :g 0.0d0 :b 0.0d0))
(defparameter *basic-led-red-glow* (make-cairo-color :r 1.0d0 :g 0.1d0 :b 0.3d0 :a 0.3d0))
(defparameter *basic-led-green-on* (make-cairo-color :r 0.0d0 :g 0.6d0 :b 0.0d0))
(defparameter *basic-led-green-off* (make-cairo-color :r 0.0d0 :g 0.2d0 :b 0.0d0))
(defparameter *basic-led-green-glow* (make-cairo-color :r 0.3d0 :g 1.0d0 :b 0.3d0 :a 0.3d0))
(defstruct widget
"Position of the GUI element. Note for development: they can be changed
with slot-value and you can setf *gui-redraw-callback*.
Rotation is in degrees, and a widget can assume that it's initial
scale has x going from 0 to 1, and y from 0 to y/x (and is in terms
of an offset in it's parents space). Ergo a translation of 0.1 is
pretty big."
(translate-x 0d0 :type (double-float 0d0 1d0) :read-only t)
(translate-y 0d0 :type (double-float 0d0 1d0) :read-only t)
(rotation 0d0 :type (double-float 0d0 360d0) :read-only t)
(rotation-origin :top-left :type (member :top-left) :read-only t)
(scale 1d0 :type double-float :read-only t))
(defstruct (grid (:include widget))
(elements nil :type list :read-only t)
(columns 1 :type (and fixnum (integer 1)) :read-only t))
(defstruct (basic-led (:include widget))
(on-color *basic-led-red-on* :type cairo-color :read-only t)
(off-color *basic-led-red-off* :type cairo-color :read-only t)
(glow-color *basic-led-red-glow* :type cairo-color :read-only t)
(stroke-width 0.01d0 :type double-float :read-only t)
(stroke-color *black* :type cairo-color :read-only t)
(on-click nil :type (or null function symbol) :read-only t)
(%illuminated nil :type boolean :read-only nil))
(declaim (inline basic-led-illuminated))
(defun basic-led-illuminated (basic-led)
(basic-led-%illuminated basic-led))
(defun (setf basic-led-illuminated) (new-color basic-led)
(prog1 (setf (basic-led-%illuminated basic-led) new-color)
(queue-redraw)))
(defstruct keytar-key-event
"Stores the MIDI key."
;; middle C is note 60 in the C3 convention
(note 0 :type integer :read-only t)
(event :press :type (member :press :release) :read-only t))
(deftype keytar-event () '(or keytar-key-event))
(defstruct (keytar (:include widget))
(fill-color (make-cairo-color :r 0.3d0 :g 0.3d0 :b 0.4d0) :type cairo-color :read-only t)
(stroke-width 0.1d0 :type double-float :read-only t)
(stroke-color *black* :type cairo-color :read-only t)
(white-key-color *white* :type cairo-color :read-only t)
(white-key-stroke-color (make-cairo-color :r .6d0 :g .6d0 :b .6d0) :type cairo-color :read-only t)
(white-key-pressed-color (make-cairo-color :r .9d0 :g .8d0 :b .8d0) :type cairo-color :read-only t)
(black-key-color (make-cairo-color :r .05d0 :g .05d0 :b .05d0) :type cairo-color :read-only t)
(black-key-pressed-color (make-cairo-color :r .3d0 :g .2d0 :b .2d0) :type cairo-color :read-only t)
(black-key-stroke-color *black* :type cairo-color :read-only t)
(orange-group-color (make-cairo-color :r 1.0d0 :g 0.5d0 :b 0.0d0) :type cairo-color :read-only t)
(green-group-color (make-cairo-color :r 0.0d0 :g 0.9d0 :b 0.0d0) :type cairo-color :read-only t)
(blue-group-color (make-cairo-color :r 0.35d0 :g 0.7d0 :b 0.9d0) :type cairo-color :read-only t)
(yellow-group-color (make-cairo-color :r 0.9d0 :g 0.9d0 :b 0.5d0) :type cairo-color :read-only t)
(red-group-color (make-cairo-color :r 6.0d0 :g 0.2d0 :b 0.2d0) :type cairo-color :read-only t)
(modulation-control-color (make-cairo-color :r 0.2d0 :g 0.1d0 :b 0.1d0) :type cairo-color :read-only t)
(modulation-control-stroke-color *black* :type cairo-color :read-only t)
(overdrive-button-color (make-cairo-color :r 0.22d0 :g 0.1d0 :b 0.1d0) :type cairo-color :read-only t)
(overdrive-button-pressed-color (make-cairo-color :r 0.1d0 :g 0.1d0 :b 0.1d0) :type cairo-color :read-only t)
(led-on-color (make-cairo-color :r 1.0d0 :g 0.2d0 :b 0.2d0) :type cairo-color :read-only t)
(led-off-color (make-cairo-color :r 0.5d0 :g 0.5d0 :b 0.5d0) :type cairo-color :read-only t)
(overdrive-button-stroke-color *black* :type cairo-color :read-only t)
(dpad-stroke-color *black* :type cairo-color :read-only t)
(dpad-base-color (make-cairo-color :r 0.19d0 :g 0.19d0 :b 0.19d0) :type cairo-color :read-only t)
(dpad-highlight-color (make-cairo-color :r 0.4d0 :g 0.4d0 :b 0.4d0) :type cairo-color :read-only t)
(button-base-color (make-cairo-color :r 0.22d0 :g 0.22d0 :b 0.24d0) :type cairo-color :read-only t)
(button-pressed-color (make-cairo-color :r 0.15d0 :g 0.0d0 :b 0.0d0) :type cairo-color :read-only t)
(button-stroke-color *black* :type cairo-color :read-only t)
(green-triangle-color (make-cairo-color :r 0.2d0 :g 0.5d0 :b 0.2d0) :type cairo-color :read-only t)
(green-triangle-pressed-color (make-cairo-color :r 0.1d0 :g 0.3d0 :b 0.0d0) :type cairo-color :read-only t)
(red-circle-color (make-cairo-color :r 0.6d0 :g 0.3d0 :b 0.3d0) :type cairo-color :read-only t)
(red-circle-pressed-color (make-cairo-color :r 0.3d0 :g 0.0d0 :b 0.0d0) :type cairo-color :read-only t)
(pink-square-color (make-cairo-color :r 1.0d0 :g 0.8d0 :b 0.8d0) :type cairo-color :read-only t)
(pink-square-pressed-color (make-cairo-color :r 0.4d0 :g 0.3d0 :b 0.3d0) :type cairo-color :read-only t)
(white-cross-color (make-cairo-color :r 0.8d0 :g 0.8d0 :b 0.8d0) :type cairo-color :read-only t)
(white-cross-pressed-color (make-cairo-color :r 0.35d0 :g 0.3d0 :b 0.3d0) :type cairo-color :read-only t)
(callback #'(lambda (keytar-event) (declare (ignore keytar-event))) :type (or null symbol function) :read-only t)
(%dpad-position nil :type (or null (member :up :down :left :right)) :read-only nil)
(midi-notes (make-array 25 :element-type t :initial-contents
'(60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84))
:type vector :read-only t)
(%depressed (make-array 25 :element-type 'bit :initial-element 0)
:type bit-vector :read-only t)
(%buttons (make-array 7 :element-type 'bit :initial-element 0) :type bit-vector :read-only t)
(%led (make-array 4 :element-type 'bit :initial-element 0)))
(defun keytar-dpad-position (keytar)
(keytar-%dpad-position keytar))
(defun (setf keytar-dpad-position) (np keytar)
(check-type np (or null (member :up :down :left :right)))
(unless (eq np (keytar-%dpad-position keytar))
(setf (keytar-%dpad-position keytar) np)
(queue-redraw))
np)
(defconstant +button-square+ 0)
(defconstant +button-triangle+ 1)
(defconstant +button-circle+ 2)
(defconstant +button-cross+ 3)
(defconstant +button-start+ 4)
(defconstant +button-select+ 5)
(defconstant +button-playstation+ 6)
(defun keytar-button-pressed (keytar index)
(check-type index (integer 0 6))
(= 1 (aref (keytar-%buttons keytar) index)))
(defun (setf keytar-button-pressed) (value keytar index)
(check-type index (integer 0 6))
(check-type value boolean)
(let ((value (if value 1 0)))
(unless (= value (aref (keytar-%buttons keytar) index))
(setf (aref (keytar-%buttons keytar) index) value)
(queue-redraw)))
value)
(defun keytar-key (keytar key-number)
(check-type key-number (integer 0 24))
(= 1 (aref (keytar-%depressed keytar) key-number)))
(defun keytar-midi-note (keytar key-number)
(aref (keytar-midi-notes keytar) key-number))
(defun (setf keytar-key) (value keytar key-number)
(check-type value boolean)
(check-type key-number (integer 0 24))
(let ((value (if value 1 0)))
(unless (= value (aref (keytar-%depressed keytar) key-number))
(setf (aref (keytar-%depressed keytar) key-number) value)
(queue-redraw)))
value)
(defun keytar-led (keytar led-number)
(check-type led-number (integer 0 3))
(= 1 (aref (keytar-%led keytar) led-number)))
(defun (setf keytar-led) (value keytar led-number)
(check-type value boolean)
(check-type led-number (integer 0 3))
(let ((value (if value 1 0)))
(unless (= value (aref (keytar-%led keytar) led-number))
(setf (aref (keytar-%led keytar) led-number) value)
(queue-redraw)))
value)
(defun red-led (&key on-click)
(make-basic-led :on-click on-click))
(defun green-led (&key on-click)
(make-basic-led
:on-color *basic-led-green-on*
:off-color *basic-led-green-off*
:glow-color *basic-led-green-glow*
:on-click on-click))
(defun basic-led-toggle (basic-led)
(setf (basic-led-illuminated basic-led) (not (basic-led-illuminated basic-led))))
(defvar *out* *standard-output*)
(defun handle-keytar-event (keytar-event)
(format *out* "~%Got event ~a" keytar-event)
(check-type keytar-event keytar-key-event)
(cl-alsa-midi/midihelper::fifo-push
cl-alsa-midi/midihelper:*writer-fifo*
(ecase (keytar-key-event-event keytar-event)
(:press
(cl-alsa-midi/midihelper:ev-noteon
1 (keytar-key-event-note keytar-event)
60))
(:release
(cl-alsa-midi/midihelper:ev-noteoff
1 (keytar-key-event-note keytar-event)
0)))))
(defparameter *keytar* (make-keytar :callback 'handle-keytar-event))
(defparameter *gui* *keytar*)
;; ;(dotimes (x 100)
;; (progn
;; (setf (slot-value *keytar* 'scale) 1d0)
;; (format t "~%KEYTAR SCALE IS NOW ~a" (slot-value *keytar* 'scale))
;; (funcall *gui-state-change-callback*))
;; (make-grid
;; :columns 2
;; :elements (list
;; *power-led*
;; (green-led :on-click 'basic-led-toggle))))
;; Okay, so I'm thinking for elements
;; I should have ROT, ORIGIN, OFFSET, SCALE
;; right inside the element.
;;
;; Then draw should be given width and height of the drawing area (in what units?)
;; Part of my thinking is that for some elements 0 to 1 is not best... and some
;; have aspect ratios.. something like (25 wide,10 high) is better...
;;
;; SO, controlling the scaling is something the element should be doing ITSELF.
;; And being able to specify the rotation, translation and scaling on the GUI element
;; itself will make things simpler for me... well maybe... I can't change things
;; dynamically (e.g. with a C-c) without restarting... can I fix that?
;; Having the tree be "lazy" would fix it... but would be irritating because all
;; state would get dropped... unless I split out state again.
;;
;; Okay, so one approach would be to name these elements and have a separate
;; list of coordinates... Another is just to C-c the SETFs... that works.
;;
;; Okay, so even if I have this... what exactly does scale mean? That one works...
;; because it works regardless of current units... and rotation also works...
;; the only one I'm less sure of is translate. If that one was ALWAYS in terms
;; of 0 to 1, then it works....
;; Okay, so for me
(defmethod draw :before (widget)
"Apply the widget properties of scale, rotation, etc.
At the start of a widget call one can expect that X goes from 0 to 1 and Y from 0 to y/x. The offset is
applied to this."
(with-slots (translate-x translate-y rotation scale) widget
(assert (zerop rotation))
(cl-cairo2:translate translate-x translate-y)
;; If scale is .5 we want it to be smaller...
(cl-cairo2:scale (/ scale) (/ scale))))
(defgeneric draw (widget)
(:documentation "Draw the given widget")
(:method ((k keytar))
;; 24 units wide
;; 8 units high.
;; 0,0 is the top left of the first piano key.
(with-slots (fill-color stroke-width stroke-color
white-key-color white-key-stroke-color white-key-pressed-color
black-key-color black-key-stroke-color black-key-pressed-color
orange-group-color green-group-color blue-group-color
yellow-group-color red-group-color
modulation-control-color modulation-control-stroke-color
overdrive-button-color overdrive-button-pressed-color overdrive-button-stroke-color
led-on-color led-off-color
dpad-stroke-color dpad-base-color dpad-highlight-color
button-base-color button-stroke-color button-pressed-color
green-triangle-color green-triangle-pressed-color
red-circle-color red-circle-pressed-color
pink-square-color pink-square-pressed-color
white-cross-color white-cross-pressed-color
) k
(cl-cairo2:scale (/ 24d0) (/ 24d0))
(cl-cairo2:translate 1.1d0 .3d0)
;; Draw and outline the body
(cl-cairo2:move-to -1d0 0d0)
(cl-cairo2:line-to 16d0 0d0)
(cl-cairo2:line-to 22.5d0 2d0)
(cl-cairo2:line-to 22.0d0 3.5d0)
(cl-cairo2:line-to 18.5d0 2.8d0)
(cl-cairo2:line-to 15.5d0 6.5d0)
(cl-cairo2:line-to 0.0d0 7.9d0)
(cl-cairo2:line-to -1.0d0 7.0d0)
(cl-cairo2:line-to -1.0d0 0.0d0)
(cl-cairo2:set-line-width stroke-width)
(with-slots (r g b a) fill-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-preserve)
(with-slots (r g b a) stroke-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:stroke)
;; Draw the white keys
(loop :for x :from 0d0 :by 1d0 :below 15d0
:for key-number :in '(24 23 21 19 17 16 14 12 11 9 7 5 4 2 0)
:for depressed = (keytar-key k key-number)
:for fill-color = (if depressed
white-key-pressed-color
white-key-color)
:do (progn
(cl-cairo2:move-to x 0d0)
(cl-cairo2:rectangle x 0d0 1d0 5.5d0)
(cl-cairo2:set-line-width stroke-width)
(with-slots (r g b a) fill-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-preserve)
(with-slots (r g b a) white-key-stroke-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:stroke)))
;; Draw the black keys
(loop :for x :from .8d0 :by 1d0 :below 15d0
:for key-number :in '(nil 22 20 18 nil 15 13 nil 10 8 6 nil 3 1)
:for depressed = (and key-number (keytar-key k key-number))
:for fill-color = (if depressed
black-key-pressed-color
black-key-color)
:when key-number
:do (progn
(cl-cairo2:move-to x 2d0)
(cl-cairo2:rectangle x 2d0 .4d0 3.5d0)
(cl-cairo2:set-line-width stroke-width)
(with-slots (r g b a) fill-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-preserve)
(with-slots (r g b a) black-key-stroke-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:stroke)))
;; Draw the colored bands...
(cl-cairo2:move-to 0d0 5.5d0)
(cl-cairo2:rectangle 0d0 5.5d0 1d0 .1d0)
(with-slots (r g b a) orange-group-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-path)
(cl-cairo2:move-to 1d0 5.5d0)
(cl-cairo2:rectangle 1d0 5.5d0 4d0 .1d0)
(with-slots (r g b a) green-group-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-path)
(cl-cairo2:move-to 5d0 5.5d0)
(cl-cairo2:rectangle 5d0 5.5d0 3d0 .1d0)
(with-slots (r g b a) blue-group-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-path)
(cl-cairo2:move-to 8d0 5.5d0)
(cl-cairo2:rectangle 8d0 5.5d0 4d0 .1d0)
(with-slots (r g b a) yellow-group-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-path)
(cl-cairo2:move-to 12d0 5.5d0)
(cl-cairo2:rectangle 12d0 5.5d0 3d0 .1d0)
(with-slots (r g b a) red-group-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-path)
;; Modulation control
;; Draw and outline the controller
(cl-cairo2:move-to 20.75d0 2d0)
(cl-cairo2:line-to 22.1d0 2.4d0)
(cl-cairo2:line-to 21.87d0 3.1d0)
(cl-cairo2:line-to 20.45d0 2.7d0)
(cl-cairo2:close-path)
(cl-cairo2:set-line-width stroke-width)
(with-slots (r g b a) modulation-control-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-preserve)
(with-slots (r g b a) modulation-control-stroke-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:stroke)
;; Overdrive Button
;; Draw and outline the button
(cl-cairo2:move-to 20.4d0 1.9d0)
(cl-cairo2:line-to 20.1d0 2.6d0)
(cl-cairo2:line-to 19.2d0 2.3d0)
(cl-cairo2:line-to 19.3d0 2.0d0)
(cl-cairo2:close-path)
(cl-cairo2:set-line-width stroke-width)
(with-slots (r g b a) overdrive-button-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-preserve)
(with-slots (r g b a) overdrive-button-stroke-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:stroke)
;; Draw the 4 leds...
(loop :with y = 6.1d0
:for i :from 0 :below 4
:for x :from 2.8d0 :by .15d0
:for color = (if (keytar-led k i)
led-on-color
led-off-color)
:do (progn
;;(cl-cairo2:move-to 3d0 1.9d0)
(cl-cairo2:arc x y 0.05d0 0.0 (* 2 pi))
(with-slots (r g b a) color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-path)))
;; Draw the dpad
(let ((x 4.95d0)
(y 6.5d0))
(cl-cairo2:arc x y 0.6d0 0.0 (* 2 pi))
(with-slots (r g b a) dpad-base-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-preserve)
(with-slots (r g b a) dpad-stroke-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:stroke)
;; Draw the arc lines... We're going to do dark ones on left, lighter ones
;; on right. But they're positions shift depending on dpad position.
;; Cairo can't do a perspective warp, so I gotta do it by hand probably by
;; just shifting.
(case (keytar-dpad-position k)
(:up (decf y .1d0))
(:down (incf y .1d0))
(:left (decf x .1d0))
(:right (incf x .1d0)))
(let ((r .5d0)
(shift-x .1d0)
(shift-y .1d0))
;; top left
(cl-cairo2:arc (- (- x shift-x) r)
(- (- y shift-y) r)
r (* 1/10 pi) (* 4/10 pi))
(with-slots (r g b a) dpad-stroke-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:stroke)
;; top right
(cl-cairo2:arc (+ (+ x shift-x) r)
(- (- y shift-y) r)
r (* 6/10 pi) (* 9/10 pi))
(with-slots (r g b a) dpad-highlight-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:stroke)
;; bottom right
(cl-cairo2:arc (+ (+ x shift-x) r)
(+ (+ y shift-y) r)
r (* 11/10 pi) (* 14/10 pi))
(with-slots (r g b a) dpad-highlight-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:stroke)
;; bottom left
(cl-cairo2:arc (- (- x shift-x) r)
(+ (+ y shift-y) r)
r (* 16/10 pi) (* 19/10 pi))
(with-slots (r g b a) dpad-stroke-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:stroke)))
;; Draw the triangle, circle, cross and square buttons
(flet ((button (x y i)
(cl-cairo2:arc x y 0.2d0 0.0 (* 2 pi))
(with-slots (r g b a) (if (keytar-button-pressed k i)
button-pressed-color
button-base-color)
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-preserve)
(with-slots (r g b a) button-stroke-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:stroke)))
(button 0.98d0 6.1d0 +button-cross+) ;; 4. White Cross
(button 0.4d0 6.6d0 +button-circle+) ;; 3. Red Circle
(button 1.5d0 6.6d0 +button-square+) ;; 1. Pink Square
(button 0.98d0 7.1d0 +button-triangle+)) ;; 2. Green Triangle
(cl-cairo2:set-line-width (/ stroke-width 2))
;; 1. Pink Square
(with-slots (r g b a) (if (keytar-button-pressed k 0)
pink-square-pressed-color
pink-square-color)
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:rectangle 1.4d0 6.5d0 .2d0 .2d0)
(cl-cairo2:stroke)
;; 2. Green Triagle
(with-slots (r g b a) (if (keytar-button-pressed k 1)
green-triangle-pressed-color
green-triangle-color)
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:move-to 0.98d0 7.18d0)
(cl-cairo2:line-to 1.08d0 7.00d0)
(cl-cairo2:line-to 0.88d0 7.00d0)
(cl-cairo2:close-path)
(cl-cairo2:stroke)
;; 3. Red Circle
(with-slots (r g b a) (if (keytar-button-pressed k 2)
red-circle-pressed-color
red-circle-color)
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:arc 0.4d0 6.6d0 0.12d0 0.0d0 (* 2 pi))
(cl-cairo2:stroke)
;; 4. White Cross
(with-slots (r g b a) (if (keytar-button-pressed k 3)
white-cross-pressed-color
white-cross-color)
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:move-to 1.08d0 6.0d0)
(cl-cairo2:line-to 0.88d0 6.2d0)
(cl-cairo2:stroke)
(cl-cairo2:move-to 0.88d0 6.0d0)
(cl-cairo2:line-to 1.08d0 6.2d0)
(cl-cairo2:stroke)
;; Start and select buttons.
(flet ((button (x y i)
(cl-cairo2:arc x y 0.16d0 0.0 (* 2 pi))
(with-slots (r g b a) (if (keytar-button-pressed k i)
button-pressed-color
button-base-color)
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-preserve)
(with-slots (r g b a) button-stroke-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:stroke)))
(button 2.3d0 6.6d0 +button-start+)
(button 3.7d0 6.6d0 +button-select+)
)))
(:method ((grid grid))
(assert (= (grid-columns grid) 2))
(assert (= 2 (length (grid-elements grid))))
(let ((m (cl-cairo2:get-trans-matrix)))
(cl-cairo2:set-trans-matrix m)
(cl-cairo2:translate 0d0 0d0)
(cl-cairo2:scale 0.5 0.5)
(draw (first (grid-elements grid)))
(cl-cairo2:set-trans-matrix m)
(cl-cairo2:translate 0.5d0 0.0d0)
(cl-cairo2:scale 0.5 0.5)
(draw (second (grid-elements grid)))))
(:method ((element basic-led))
(with-slots (on-color off-color glow-color stroke-width stroke-color (illuminated %illuminated)) element
(cl-cairo2:arc 0.5d0 0.5d0 0.4d0 0.0 (* 2 pi))
(with-slots (r g b a) (if illuminated on-color off-color)
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:fill-path)
(cl-cairo2:set-line-width stroke-width)
(cl-cairo2:arc 0.5d0 0.5d0 0.4d0 0.0 (* 2 pi))
(with-slots (r g b a) stroke-color
(cl-cairo2:set-source-rgba r g b a))
(cl-cairo2:stroke)
(when illuminated
(with-slots (r g b a) glow-color
(dotimes (rev-x 3)
(let* ((x (- 3 rev-x))
(current-a (* (/ x 3) a))
(current-r (+ .4d0 (* (/ x 3) .1d0))))
(cl-cairo2:arc 0.5d0 0.5d0 current-r 0.0 (* 2 pi))
(cl-cairo2:set-source-rgba r g b current-a)
(cl-cairo2:fill-path))))))))
(defgeneric click (element x y)
(:documentation "Click the given element. x and y should be relative to top corner of
the elements range and from 0.0 to 1.0.")
(:method ((k keytar) x y)
;; What's clickable? The white and black keys, the sensor, overdrive button, dpad, etc.
;; At the start, x goes from 0 to 1 and y from 0 to y/x.
;; Scale them up, and translate them.
(let ((mx (- (* x 24d0) 1.1d0))
(my (- (* y 24d0) 0.3d0)))
;; Black key presses
(loop :for x :from .8d0 :by 1d0 :below 15d0
:for key-number :in '(nil 22 20 18 nil 15 13 nil 10 8 6 nil 3 1)
:when (and key-number
(<= x mx (+ x .4d0))
(<= 2d0 my (+ 2d0 3.5d0)))
:do (setf (keytar-key k key-number) (not (keytar-key k key-number)))
:and :do (when (keytar-callback k)
(funcall (keytar-callback k)
(make-keytar-key-event
:note (keytar-midi-note k key-number)
:event (if (keytar-key k key-number)
:press
:release))))
:and :do (return-from click))
;; White key presses
(loop :for x :from 0d0 :by 1d0 :below 15d0
:for key-number :in '(24 23 21 19 17 16 14 12 11 9 7 5 4 2 0)
:when (and (<= x mx (+ x 1d0))
(<= 0d0 my 5.5d0))
:do (setf (keytar-key k key-number) (not (keytar-key k key-number)))
:and :do (when (keytar-callback k)
(funcall (keytar-callback k)
(make-keytar-key-event
:note (keytar-midi-note k key-number)
:event (if (keytar-key k key-number)
:press
:release))))
:and :do (return-from click))
;; Dpad directions
(let ((x 4.95d0)
(y 6.5d0)
(r .6d0))
(let ((clicked-position
(cond ((and (<= (- x r) mx (- x (/ r 6d0)))
(<= (- y (/ r 2d0)) my (+ y (/ r 2d0))))
:left)
((and (<= (+ x (/ r 6d0)) mx (+ x r))
(<= (- y (/ r 2d0)) my (+ y (/ r 2d0))))
:right)
((and (<= (- y r) my (- y (/ r 6d0)))
(<= (- x (/ r 2d0)) mx (+ x (/ r 2d0))))
:up)
((and (<= (+ y (/ r 6d0)) my (+ y r))
(<= (- x (/ r 2d0)) mx (+ x (/ r 2d0))))
:down))))
(when clicked-position
(setf (keytar-dpad-position k) (if (eq (keytar-dpad-position k) clicked-position) nil clicked-position))
(setf (keytar-led k (random 4)) (zerop (random 2)))
(return-from click))))
(flet ((button (x y i)
(when (< (sqrt (+ (expt (- x mx) 2)
(expt (- y my) 2))) 0.2d0)
(setf (keytar-button-pressed k i)
(not (keytar-button-pressed k i)))
(return-from click))))
(button 0.98d0 6.1d0 +button-cross+) ;; 4. White Cross
(button 0.4d0 6.6d0 +button-circle+) ;; 3. Red Circle
(button 1.5d0 6.6d0 +button-square+) ;; 1. Pink Square
(button 0.98d0 7.1d0 +button-triangle+))
(flet ((button (x y i)
(when (< (sqrt (+ (expt (- x mx) 2)
(expt (- y my) 2))) 0.16d0)
(setf (keytar-button-pressed k i)
(not (keytar-button-pressed k i)))
(return-from click))))
(button 2.3d0 6.6d0 +button-start+)
(button 3.7d0 6.6d0 +button-select+))
))
(:method ((grid grid) x y)
(assert (= (grid-columns grid) 2))
(assert (= 2 (length (grid-elements grid))))
(if (< x 0.5d0)
(click (first (grid-elements grid)) (/ x 0.5d0) (/ y 0.5d0))
(click (second (grid-elements grid)) (/ (- x 0.5d0) 0.5d0) (/ y 0.5d0))))
(:method ((element basic-led) x y)
(unless (<= .1 x .9)
(return-from click nil))
(unless (<= .1 y .9)
(return-from click nil))
(let* ((x (- x 0.5))
(y (- y 0.5))
(d (+ (* x x) (* y y))))
(when (< d (* 0.4d0 0.4d0 ))
(funcall (basic-led-on-click element) element)))))
(defun draw-gui (cairo width height)
"Clears the background color and sets up a basic coordinate of (0,0)
to (1,y/x) for the full drawable area."
(let ((cl-cairo2:*context* cairo))
;; Background
(cl-cairo2:rectangle 0 0 width height)
(cl-cairo2:set-source-rgb 0.2 0.2 0.5)
(cl-cairo2:fill-path)
;; Scale so drawing is 0 to 1 in the X axis and 0 to y/x in the Y axis.
(cl-cairo2:scale width width)
(draw *gui*)))
(defun click-gui (x y width height)
"x and y should be in range of (0,0) to (width,hight)"
(check-type x double-float)
(check-type y double-float)
(check-type width fixnum)
(check-type height fixnum)
;; (format t "~%click-gui ~a ~a ~a ~a" x y width height)
(unless (> width 0)
(return-from click-gui nil))
(unless (> height 0)
(return-from click-gui nil))
(unless (<= 0 x width)
(return-from click-gui nil))
(unless (<= 0 y height)
(return-from click-gui nil))
(setf x (coerce (/ x width) 'double-float))
(setf y (coerce (/ y width) 'double-float))
;; (format t "~% -> click ~a ~a" x y)
(click *gui* x y))
(defstruct music-engine
"My thing"
(initialized-p nil :type boolean :read-only nil))
(defun music-engine-startup (me)
(check-type me music-engine)
(setf (music-engine-initialized-p me) t))
(defun music-engine-shutdown (me)
(check-type me music-engine)
(setf (music-engine-initialized-p me) nil))
(defvar *music-engine* (make-music-engine))
(defun test-draw-gui ()
(let* ((width 200)
(height 100)
(surface (cl-cairo2:create-pdf-surface "example.pdf" width height)))
(setf cl-cairo2:*context* (cl-cairo2:create-context surface))
(cl-cairo2:destroy surface)
(draw-gui cl-cairo2:*context* width height)
(cl-cairo2:destroy cl-cairo2:*context*)))
(cffi:defcallback draw-thing :void ((gtk-drawing-area :pointer) (cairo :pointer)
(width :int) (height :int)
(user-data :pointer))
(declare (ignore user-data gtk-drawing-area))
(let (;; (gtk-drawing-area (gir:build-object-ptr (gir:nget-desc *gtk* "DrawingArea") gtk-drawing-area))
(report-error t)
(cairo (make-instance 'cl-cairo2:context
:pixel-based-p t
:height height
:width width
:pointer cairo)))
(handler-case (prog1 (draw-gui cairo width height)
(setf report-error t))
(error (e)
(when report-error
(warn (format nil "~In draw-thing callback, got error: ~a" e)))
(setf report-error nil))))
0)
(cffi:defcallback cleanup-draw-thing :void ((user-data :pointer))
(declare (ignore user-data))
(format t "~%Inside my cleanup-draw-thing callback!")
0)
(declaim (type fixnum *gui-height* *gui-width*))
(defparameter *gui-height* 600)
(defparameter *gui-width* 800)
;; Why is this so unstable? Even recompiling in Lisp causes it to crash.
;; that has NOTHING to do with the drawing code.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar *gio* (gir:require-namespace "Gio"))
(defvar *gtk* (gir:require-namespace "Gtk" "4.0")) ;; GTK 4.0
(defun create-gui ()
"Starts the GUI, which starts up a music engine and displays it."
(let ((app (gir:invoke (*gtk* "Application" 'new)
"org.gtk.example"
(gir:nget *gio* "ApplicationFlags" :default-flags)))
(default-width 800)
(default-height 600))
(gir:connect app "startup"
(lambda (app)
(declare (ignore app))
(format t "~%Application Start-up!")
(music-engine-startup *music-engine*)))
(gir:connect app "shutdown"
(lambda (app)
(declare (ignore app))
(format t "~%Application Shut-down!")
(setf *gui-redraw-callback* nil)
(music-engine-shutdown *music-engine*)
(format t "~%Shutdown complete!")))
(gir:connect app "activate"
(lambda (app)
(format t "~%Application Activate... create a window!")
(let ((window (gir:invoke (*gtk* "ApplicationWindow" 'new) app))
(gesture-click (gir:invoke (*gtk* "GestureClick" 'new)))
(drawing-area (gir:invoke (*gtk* "DrawingArea" 'new))))
;; Add a click handler to the drawing area.
(gir:connect gesture-click "pressed"
(lambda (self button-number x y)
(declare (ignore self button-number))
(let ((report-error t))
(handler-case (prog1 (click-gui x y *gui-width* *gui-height*)
(setf report-error t))
(error (e)
(when report-error
(warn (format nil "In click handler got error ~a" e)))
(setf report-error nil))))))
(setf (gir:property gesture-click "button") 1)
(gir:invoke (drawing-area 'add-controller) gesture-click)
(setf *gui-redraw-callback* #'(lambda ()
(gir:invoke (drawing-area 'queue-draw))))
;; Setup the drawing area's callback
(gir:invoke (drawing-area 'set-draw-func)
(cffi:callback draw-thing)
(cffi:null-pointer) ;; user data
(cffi:callback cleanup-draw-thing))
;; Setup a resize handler. We need to know the size
;; so we can give it to the click handler
(gir:connect drawing-area "resize"
(lambda (self width height)
(declare (ignore self))
(setf *gui-width* width)
(setf *gui-height* height))
:after t)
;; Set some initial properties and values...
(setf (gir:property window "default-width") default-width)
(setf (gir:property window "default-height") default-height)
(setf *gui-width* default-width)
(setf *gui-height* default-height)
(setf (gir:property window "title") "Virtual Warren Controllerist Instrument")
(gir:invoke (window 'set-child) drawing-area)
(gir:invoke (window 'show)))))
(gir:invoke (app 'run) nil)))
(defun start-gui ()
(format t "~%Starting the GUI. The way GTK works though, once~%this window is quit you can't restart it without quitting lisp.~%By this I mean, calling run on a previously quit window is undefined behavior.")
(sb-thread:make-thread #'create-gui :name "gui thread"))
(sb-posix:setenv "GDK_SYNCHRONIZE" "1" 1)
| 58,169 | Common Lisp | .lisp | 1,207 | 43.257664 | 210 | 0.662358 | WarrenWilkinson/music-engine | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 8b1b705399120761dba8328a6a0201e76a930688bf82e0d598241192f92f58f9 | 26,468 | [
-1
] |
26,469 | sim-main.lisp | WarrenWilkinson_music-engine/src/lisp/sim-main.lisp | (in-package :cl-user)
(format t "~%Loading 3rd party dependencies with quicklisp...~%")
(ql:quickload "cffi") ;; https://github.com/zzkt/osc
(format t "~%Loading my code...")
(load "src/lisp/button.lisp")
(load "src/lisp/musicengine.lisp")
(use-package :button)
(use-package :musicengine)
(eval-when (:compile-toplevel :load-toplevel :execute)
(cffi:define-foreign-library button
(t "build/libbuttonloopback.so"))
(cffi:define-foreign-library musicengine
(t "build/libmusicengine.so")))
(init-buttons 'button)
(musicengine-init 'musicengine)
;; Run this, then run `aconnect -lio`
(defvar *seq* (musicengine-open-seq "MusicEngine" :output))
(defvar *port* (musicengine-open-midi-port *seq* "control:out" :output))
(musicengine-register-node-interest "MusicEngine" "Focusrite Scarlett 2i2 Analog Stereo")
(musicengine-get-node-state) ;; Nice, this works a bit.. but need to actually do some C code and register the interests now.
;; (musicengine-close-midi-port *seq* *port*)
;; (musicengine-close-seq *seq*)
;; (musicengine-teardown)
| 1,056 | Common Lisp | .lisp | 23 | 43.913043 | 124 | 0.74364 | WarrenWilkinson/music-engine | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | f3474ab495d7c71beb89310edb7b3232c610a7eb6b9f861d2e7359acf78cd6df | 26,469 | [
-1
] |
26,470 | button.lisp | WarrenWilkinson_music-engine/src/lisp/button.lisp | (defpackage :button
(:documentation "Interface to C code for controlling two-state buttons and two-state
LEDs")
(:use :common-lisp :cffi)
(:export #:button-state
#:init-buttons))
(in-package :button)
(cffi:defcfun (c/button-state "button_state") :int
(button-number :int))
(cffi:defcfun (c/init-buttons "init_buttons") :int)
(cffi:defcfun (c/set-button-state "set_button_state") :int
(button-number :int)
(new-value :int))
(defun button-state (button-number)
"Get the button state of the specific button-number."
(let ((ret-value (c/button-state button-number)))
(when (< ret-value 0)
(error "Error getting button state for button-number ~d" button-number))
(if (zerop ret-value) nil t)))
(defun (setf button-state) (nv button-number)
"Button-state is SETF-able in the simulator only."
(let* ((value (if nv 1 0))
(ret-value (c/set-button-state button-number value)))
(when (< ret-value 0)
(error "Error setting button state for button-number ~d to ~a" button-number value))
(if (zerop ret-value) nil t)))
(defun init-buttons (foreign-library-name)
"Initialize the button subsystem."
(cffi:load-foreign-library foreign-library-name)
(unless (zerop (c/init-buttons))
(error "Error initing buttons!")))
| 1,288 | Common Lisp | .lisp | 31 | 37.709677 | 90 | 0.696486 | WarrenWilkinson/music-engine | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | f509360de227b734a03bafb97c28a23e0af7351a8c3ebfde8c3f51e238dbc8df | 26,470 | [
-1
] |
26,471 | music-engine.asd | WarrenWilkinson_music-engine/modules/music-engine.asd | (defsystem "music-engine"
:description "music-engine: prototype instrument controller"
:version "0.0.1"
:author "Warren Wilkinson <[email protected]>"
:licence "GPLv3"
;; :depends-on ("mcclim" "osc"))
;; :version (:read-file-form "variables" :at (3 2))
;; :components ((:file "package")
;; (:file "variables" :depends-on ("package"))
;; (:module "mod"
;; :depends-on ("package")
;; :serial t
;; :components ((:file "utils")
;; (:file "reader")
;; (:file "cooker")
;; (:static-file "data.raw"))
;; :output-files (compile-op (o c) (list "data.cooked"))
;; :perform (compile-op :after (o c)
;; (cook-data
;; :in (component-pathname (find-component c "data.raw"))
;; :out (first (output-files o c)))))
;; (:file "foo" :depends-on ("mod"))))
| 874 | Common Lisp | .asd | 22 | 36.818182 | 69 | 0.553991 | WarrenWilkinson/music-engine | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 62a50d9104d2ffb2dbacca954863a37f336c2dd118b3f34b1dca96880dbca832 | 26,471 | [
-1
] |
26,473 | Makefile | WarrenWilkinson_music-engine/Makefile | # Okay, at least two libraries...
# one is wireplumber AND asound for a control midi interface.
.PHONY : all clean
all: build/libbuttonloopback.so build/libmusicengine.so
# The music engine is a shim to control wireplumber via LISP
build/libmusicengine.so: src/c/musicengine/alsa.c src/c/musicengine/alsa.h src/c/musicengine/wireplumber.c src/c/musicengine/wireplumber.h src/c/musicengine/musicengine.c
gcc -Wall -shared -o $@ $^ `pkg-config --libs --cflags gobject-2.0 --cflags wireplumber-0.4 --cflags alsa`
build/libbuttonloopback.so: src/c/buttonloopback/buttonloopback.c
gcc -Wall -shared -o $@ $^
# The simulator is a GTK application that pretends to be the hardware
build/libsimulator.so: src/c/simulator/simulator.c
gcc -Wall -shared -o $@ $^ `pkg-config --libs --cflags gtk4 --cflags cairo`
clean:
rm -f build/musicengine.so build/simulator.so
| 863 | Common Lisp | .l | 14 | 59.928571 | 171 | 0.773697 | WarrenWilkinson/music-engine | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 8df612ddfe36d41cbd4b34175b213a00de10e0925287ec0faffc3690cd4f007f | 26,473 | [
-1
] |
26,477 | wireplumber.c | WarrenWilkinson_music-engine/src/c/musicengine/wireplumber.c | /*!****************************************************************************
* @file wireplumber.c
* @brief A shim between Wireplumber and common lisp.
*******************************************************************************/
#include <stdio.h>
#include <string.h>
#include <wp/wp.h>
#include <gobject/gobject.h>
// The way this works is as follows:
// Lisp will tell the shim the NAMES of the nodes it has an interest in.
// The C code will register an interest in nodes and maintain two arrays:
//
// 1. Lisp Name (String) -> int ID (this one done by Lisp telling C)
// 2. int Id -> gpointer or null (this one done by C talking with wireplumber).
//
// In addition, C will maintain a list of ports for these nodes, which
// can be returned to Lisp
// 3. int Id, Port Name (String), int port_id, int is_input
// Finally C will maintain a list of connections which can be returned to Lisp.
//
// 4. int output_port, int input_port
//
// Because of wireplumber this stuff should probably be atomic...
// so Lisp will send down a STRING of names (comma separated) and C will
// update table 1 with a mutex.
//
// C mostly ignores the signals from wireplumber, except that one about changes
// when it gets that it locks the mutex and updates tables 2 3 and 4
//
// When Lisp asks for state, C returns a string of information:
// found_names (comma separated) NEWLINE
// ports name:port_name IN/OUT MIDI/ANALOG (comma separated) NEWLINE
// edges name:port->name:port (comma separated) NEWLINE
#define MAX_NODE_NAME_LEN 64
#define MAX_NODE_NAMES 64
// Remember, actual max length less by 1 to support the null character.
static char node_interests[MAX_NODE_NAMES][MAX_NODE_NAME_LEN];
static int node_interests_len = 0;
static WpObjectManager *wp_object_manager = 0;
static WpCore *wp_core = 0;
void reset_node_interests() {
memset(node_interests, 0, sizeof(char) * MAX_NODE_NAMES * MAX_NODE_NAME_LEN);
node_interests_len = 0;
}
/*!****************************************************************************
* @brief Tell wireplumber the names of nodes we have an interest in.
* C will record these names and work with wireplumber to track them.
* @param names comma separated list of names with null terminating character
* @param out_error_message is set by this function to return a string describing
* problems to Lisp.
* @return returns >= 0 on success or < 0 on error.
*******************************************************************************/
int musicengine_register_node_interest(char* names, char** out_error_message) {
int index = 0;
char* name = strtok(names, ",");
while (name != NULL) {
// Ensure not too many names.
if (index >= MAX_NODE_NAMES) {
*out_error_message = "too many node name interests.";
reset_node_interests();
// reset all other data also...
return -1;
}
// Ensure name isn't too long.
if (strnlen(name, MAX_NODE_NAME_LEN) == MAX_NODE_NAME_LEN) {
*out_error_message = "name was too long;";
reset_node_interests();
// reset all other data also...
return -1;
}
// Ensure no spaces. (Actually spaces are totally fine)
/*
if (strchr(name, ' ') != NULL) {
*out_error_message = "name contains a space";
reset_node_interests();
// reset all other data also...
return -1;
}
*/
// Copy the name in and go to the next
strncpy(node_interests[index], name, MAX_NODE_NAME_LEN);
name = strtok(NULL, ",");
index = index + 1;
}
node_interests_len = index;
// reset all other data also and retrigger updating it.
return 0;
}
/*!****************************************************************************
* @brief Inquire as to the state of nodes and connections
* C will return a three line string that summarizes the state of the nodes that
* had a previous interest registered. The first line is a comma separated
* list of node names. The second line a comma separated list of ports
* in the form <node_name>:<port_name> <midi_or_analog> <in_or_out>.
* The third line is a comma separated list of edges in the form
* <out_name>:<out_port>-><in_name>:<in_port>. The last character written (buffer size permitting) will be
* the null termination character.
* @param buffer A lisp allocated buffer where C can write the results.
* @param buffer_size The size of the lisp allocated buffer.
* @param out_error_message is set by this function to return a string describing
* problems to Lisp.
* @return returns >= 0 on success or < 0 on error.
*******************************************************************************/
int musicengine_get_node_state(char* buffer, int buffer_size, char** out_error_message) {
// Write out all the names (should be right out ONLY the found names).
for (int index = 0; index < node_interests_len; index++) {
char* c = index == (node_interests_len - 1) ? "\n" : ",";
int written = snprintf(buffer, buffer_size, "%s%s", node_interests[index], c);
buffer+=written;
buffer_size-=written;
}
// Write out the ports...
{
int had_data = 0;
WpIterator *i = wp_object_manager_new_iterator(wp_object_manager);
GValue item;// = NULL;
while (wp_iterator_next(i, &item)) {
had_data = 1;
int written = snprintf(buffer, buffer_size, "%p,", &item);
buffer+=written;
buffer_size-=written;
};
if (had_data == 1) {
// backup a character to erase last comma
buffer-=1;
buffer_size+=1;
}
int written = snprintf(buffer, buffer_size, "\n");
buffer+=written;
buffer_size-=written;
}
// Write out the edges...
{
int written = snprintf(buffer, buffer_size, "\n");
buffer+=written;
buffer_size-=written;
}
/* // Write terminating 0 */
/* { */
/* int written = snprintf(buffer, buffer_size, "\0"); */
/* buffer+=written; */
/* buffer_size-=written; */
/* } */
if (buffer_size < 0) {
*out_error_message = "buffer was too small.";
return -1;
}
return 0;
}
/*!****************************************************************************
* @brief Break a wireplumber connection
* C will tell wireplumber to break the connection between the out_port and in_port
* if it exists.
* @param out_port The out port name (<node_name>:<port_name>). null terminated string.
* @param in_port The in port name (<node_name>:<port_name>). null terminated string.
* @param out_error_message is set by this function to return a string describing
* problems to Lisp.
* @return returns >= 0 on success or < 0 on error.
*******************************************************************************/
int musicengine_remove_edge(char* out_port, char* in_port, char** out_error_message) {
return 0;
}
/*!****************************************************************************
* @brief Add a wireplumber connection
* C will tell wireplumber to create a connection between the out_port and in_port
* if possible.
* @param out_port The out port name (<node_name>:<port_name>). null terminated string.
* @param in_port The in port name (<node_name>:<port_name>). null terminated string.
* @param out_error_message is set by this function to return a string describing
* problems to Lisp.
* @return returns >= 0 on success or < 0 on error.
*******************************************************************************/
int musicengine_add_edge(char* out_port, char* in_port, char** out_error_message) {
return 0;
}
/*!****************************************************************************
* @brief Initializes the music engine.
* @param out_error_message is set by this function to return a string describing
* problems to Lisp.
* @return returns >= 0 on success (the slot used) or < 0 on error.
*******************************************************************************/
int musicengine_wireplumber_init(char** out_error_message) {
*out_error_message = "no problems so far.";
memset(node_interests, 0, sizeof(char) * MAX_NODE_NAMES * MAX_NODE_NAME_LEN);
node_interests_len = 0;
wp_init(WP_INIT_ALL);
GType wp_node_gtype = g_type_from_name("WpNode");
if (wp_node_gtype == 0) {
*out_error_message = "Failed to find WpNode gtype!";
return -1;
}
wp_core = wp_core_new(NULL, NULL);
if (wp_core == NULL) {
*out_error_message = "Failed to create wp core object!";
return -1;
}
wp_object_manager = wp_object_manager_new();
if (wp_object_manager == NULL) {
*out_error_message = "Failed to create wp object manager!";
return -1;
}
wp_object_manager_add_interest (wp_object_manager, wp_node_gtype, NULL);
wp_core_install_object_manager(wp_core, wp_object_manager);
return 0;
}
/*!****************************************************************************
* @brief Shutdown the musicengine
* @param out_error_message is set by this function to return a string describing
* problems to Lisp.
* @return returns >= 0 on success (the slot used) or < 0 on error.
*******************************************************************************/
int musicengine_wireplumber_teardown(char** out_error_message) {
*out_error_message = "no problems so far.";
memset(node_interests, 0, sizeof(char) * MAX_NODE_NAMES * MAX_NODE_NAME_LEN);
node_interests_len = 0;
if (wp_core != NULL) {
wp_core_disconnect(wp_core);
wp_core = NULL;
wp_object_manager = NULL;
}
return 0;
}
| 9,612 | Common Lisp | .l | 222 | 40.112613 | 106 | 0.597518 | WarrenWilkinson/music-engine | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 3da41561eb0af1e52d7ba5c81e062c8d0e8d914c5cbeb612f7acd0c499d67313 | 26,477 | [
-1
] |
26,478 | alsa.c | WarrenWilkinson_music-engine/src/c/musicengine/alsa.c | /*!****************************************************************************
* @file musicengine.c
* @brief A shim between Alsa and common lisp.
*******************************************************************************/
#include <alsa/asoundlib.h>
#include <string.h>
#include "alsa.h"
#define MAX_SEQ 2
#define MAX_NAME_LEN 16
#define MAX_MIDI_PORTS 8
static int seq_used[MAX_SEQ];
static char seq_labels[MAX_SEQ][MAX_NAME_LEN];
static snd_seq_t* seq_handles[MAX_SEQ];
static int midi_port_used[MAX_SEQ][MAX_MIDI_PORTS];
static char midi_port_labels[MAX_SEQ][MAX_MIDI_PORTS][MAX_NAME_LEN];
static int midi_port_handles[MAX_SEQ][MAX_MIDI_PORTS];
int find_next_seq_slot(char** out_error_message) {
for (int i = 0; i < MAX_SEQ; i++) {
if (seq_used[i] == 0) {
return i;
}
}
*out_error_message = "No more seq slots available.";
return -1;
}
int check_seq_number(int seq_number, char** out_error_message) {
if (seq_number < 0) {
*out_error_message = "seq_number was negative!";
return -1;
}
if (seq_number >= MAX_SEQ) {
*out_error_message = "seq_number was too large!";
return -1;
}
if (seq_used[seq_number] == 0) {
*out_error_message = "seq_number is not in use!";
return -1;
}
return 0;
}
int check_midi_port_number(int seq_number, int midi_port_number, char** out_error_message) {
int return_value = check_seq_number(seq_number, out_error_message);
if (return_value < 0) {
return -1;
}
if (midi_port_number < 0) {
*out_error_message = "midi_port_number was negative!";
return -1;
}
if (midi_port_number >= MAX_MIDI_PORTS) {
*out_error_message = "midi_port_number was too large!";
return -1;
}
if (midi_port_used[seq_number][midi_port_number] == 0) {
*out_error_message = "midi_port_number was not in used!";
return -1;
}
return 0;
}
int find_next_midi_port_slot(int seq_number, char** out_error_message) {
int return_value = check_seq_number(seq_number, out_error_message);
if (return_value < 0) {
return -1;
}
for (int i = 0; i < MAX_MIDI_PORTS; i++) {
if (midi_port_used[seq_number][i] == 0) {
return i;
}
}
*out_error_message = "No more midi port slots available.";
return -1;
}
int check_name(char* name, char** out_error_message) {
if (name == 0) {
*out_error_message = "name was nil.";
return -1;
}
if (strnlen(name, MAX_NAME_LEN - 1) == MAX_NAME_LEN - 1) {
*out_error_message = "name was too long.";
return -1;
}
return 0;
}
/*!****************************************************************************
* @brief Creates a alsa seq device with a given name.
* This function creates (and stores internally) an alsa sequencer and returns
* identifying number (corresponding to the slot in which we stored it).
* @param name the name of the sequencer (will be shown to users)
* @param output set to 1 if this sequencer will output things
* @param input set to 1 if this sequencer will input things
* @param out_error_message is set by this function to return a string describing
* problems to Lisp.
* @return returns >= 0 on success (the slot used) or < 0 on error.
*******************************************************************************/
int musicengine_open_seq(char* name, int output, int input, char** out_error_message) {
*out_error_message = "no problems so far.";
int return_value = check_name(name, out_error_message);
if (return_value < 0) {
return -1;
}
int rw_mode = 0;
if (input != 0 && output != 0) {
rw_mode = SND_SEQ_OPEN_DUPLEX;
} else if (input != 0) {
rw_mode = SND_SEQ_OPEN_INPUT;
} else if (output != 0) {
rw_mode = SND_SEQ_OPEN_OUTPUT;
} else {
*out_error_message = "Both output and input are false";
return -1;
}
int seq_number = find_next_seq_slot(out_error_message);
if (seq_number < 0) {
return -1;
}
return_value = snd_seq_open(&seq_handles[seq_number],
"default", rw_mode, 0);
if (return_value < 0) {
*out_error_message = "Failure in snd_seq_open.";
seq_handles[seq_number] = 0;
seq_used[seq_number] = 0;
memset(seq_labels[seq_number], 0, MAX_NAME_LEN);
return -1;
}
// Mark the slot as used, keep a copy of the name, and set the name.
seq_used[seq_number] = 1;
strncpy(seq_labels[seq_number], name, MAX_NAME_LEN);
return_value = snd_seq_set_client_name((snd_seq_t*)seq_handles[seq_number], seq_labels[seq_number]);
if (return_value < 0) {
*out_error_message = "Failure in snd_seq_set_client_name.";
snd_seq_close((snd_seq_t*)seq_handles[seq_number]);
seq_handles[seq_number] = 0;
seq_used[seq_number] = 0;
memset(seq_labels[seq_number], 0, MAX_NAME_LEN);
return -1;
}
return seq_number;
}
int musicengine_open_midi_port(int seq_number, char* name, int output, int input, char** out_error_message) {
*out_error_message = "no problems so far.";
int return_value = check_seq_number(seq_number, out_error_message);
if (return_value < 0) {
return -1;
}
return_value = check_name(name, out_error_message);
if (return_value < 0) {
return -1;
}
if (input == 0 && output == 0) {
*out_error_message = "Both output and input are false";
return -1;
}
int flags = 0;
if (input != 0) {
flags |= SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE;
}
if (output != 0) {
flags |= SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_SUBS_READ;
}
int port_number = find_next_midi_port_slot(seq_number, out_error_message);
if (port_number < 0) {
return -1;
}
midi_port_used[seq_number][port_number] = 1;
strncpy(midi_port_labels[seq_number][port_number], name, MAX_NAME_LEN);
midi_port_handles[seq_number][port_number] =
snd_seq_create_simple_port((snd_seq_t*)seq_handles[seq_number],
midi_port_labels[seq_number][port_number],
flags,
SND_SEQ_PORT_TYPE_APPLICATION);
if (midi_port_handles[seq_number][port_number] < 0) {
*out_error_message = "Failure in snd_seq_create_simple_port.";
midi_port_handles[seq_number][port_number] = 0;
midi_port_used[seq_number][port_number] = 1;
memset(midi_port_labels[seq_number][port_number], 0, MAX_NAME_LEN);
return -1;
}
return port_number;
}
/*!****************************************************************************
* @brief Closes an alsa midi port.
* This function closes an alsa midi_port.
* @param seq_number
* @param midi_number
* @param out_error_message is set by this function to return a string describing
* problems to Lisp.
* @return returns >= 0 on success (the slot used) or < 0 on error.
*******************************************************************************/
int musicengine_close_midi_port(int seq_number, int midi_number, char** out_error_message) {
*out_error_message = "no problems so far.";
int return_value = check_midi_port_number(seq_number, midi_number, out_error_message);
if (return_value < 0) {
return -1;
}
return_value = snd_seq_delete_simple_port((snd_seq_t*)seq_handles[seq_number],
midi_port_handles[seq_number][midi_number]);
midi_port_handles[seq_number][midi_number] = 0;
midi_port_used[seq_number][midi_number] = 0;
memset(midi_port_labels[seq_number][midi_number], 0, MAX_NAME_LEN);
return return_value;
}
/*!****************************************************************************
* @brief Closes the alsa seq in the given slot. Closes open midi ports
* This function closes the alsa sequencer; it'll also close any open midi ports.
* @param seq_number
* @param out_error_message is set by this function to return a string describing
* problems to Lisp.
* @return returns >= 0 on success (the slot used) or < 0 on error.
*******************************************************************************/
int musicengine_close_seq(int seq_number, char** out_error_message) {
*out_error_message = "no problems so far.";
int return_value = check_seq_number(seq_number, out_error_message);
if (return_value < 0) {
return -1;
}
// Close any open MIDI ports.
for (int i = 0; i < MAX_MIDI_PORTS; i++) {
if (midi_port_used[seq_number][i] != 0) {
musicengine_close_midi_port(seq_number, i, out_error_message);
}
}
return_value = snd_seq_close((snd_seq_t*)seq_handles[seq_number]);
seq_handles[seq_number] = 0;
seq_used[seq_number] = 0;
memset(seq_labels[seq_number], 0, MAX_NAME_LEN);
return return_value;
}
/*!****************************************************************************
* @brief Initializes the music engine.
* @param out_error_message is set by this function to return a string describing
* problems to Lisp.
* @return returns >= 0 on success (the slot used) or < 0 on error.
*******************************************************************************/
int musicengine_alsa_init(char** out_error_message) {
*out_error_message = "no problems so far.";
// Zero out all the static structures.
for (int i = 0; i < MAX_SEQ; i++) {
seq_used[i] = 0;
memset(seq_labels[i], 0, MAX_NAME_LEN);
seq_handles[i] = 0;
for (int j = 0; j < MAX_MIDI_PORTS; j++) {
midi_port_used[i][j] = 0;
memset(midi_port_labels[i][j], 0, MAX_NAME_LEN);
midi_port_handles[i][j] = 0;
}
}
return 0;
}
/*!****************************************************************************
* @brief Shutdown the musicengine
* @param out_error_message is set by this function to return a string describing
* problems to Lisp.
* @return returns >= 0 on success (the slot used) or < 0 on error.
*******************************************************************************/
int musicengine_alsa_teardown(char** out_error_message) {
*out_error_message = "no problems so far.";
// Release all the resources
for (int i = 0; i < MAX_SEQ; i++) {
if (seq_used[i] != 0) {
musicengine_close_seq(i, out_error_message);
}
}
return 0;
}
| 10,650 | Common Lisp | .l | 264 | 34.712121 | 109 | 0.560999 | WarrenWilkinson/music-engine | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | d34fefd7cc8641423aebf997255e3e7dce4e0c03605158352d98664356886801 | 26,478 | [
-1
] |
26,479 | buttonloopback.c | WarrenWilkinson_music-engine/src/c/buttonloopback/buttonloopback.c | // This is the simulated version of button_state. A real
// implementation would real each button via GPIO.
#include <stdbool.h>
#define MAX_BUTTON 60 /* number of buttons */
static bool button_states[MAX_BUTTON]; /* storage for state */
int button_state(int button_number) {
if (button_number < 0 || button_number >= MAX_BUTTON) {
return -1;
} else {
return button_states[MAX_BUTTON];
}
}
int set_button_state(int button_number, int new_value) {
if (button_number < 0 || button_number >= MAX_BUTTON) {
return -1;
} else if (new_value < 0 || new_value > 1) {
return -2;
} else {
button_states[MAX_BUTTON] = (new_value == 1);
return new_value;
}
}
int init_buttons() {
for (int i = 0; i < MAX_BUTTON; i++) {
button_states[i] = false;
}
return 0;
}
| 804 | Common Lisp | .l | 28 | 25.75 | 64 | 0.652796 | WarrenWilkinson/music-engine | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | d24004f8e9503dbcdbc896c9c802c5d1c96658e54d20e6c43a0080a29e8c1da4 | 26,479 | [
-1
] |
26,494 | package.lisp | drewt_Aleph/package.lisp | ;;
;; Copyright 2016 Drew Thoreson
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, version 2 of the
;; License.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
;;
(in-package :cl-user)
(defpackage :config
(:use :cl)
(:export :merge-config :load-from-file :get-value))
;; Data store, type definitions
(defpackage :feed-store
(:use :cl)
(:import-from :postmodern
:with-transaction
:insert-dao
:select-dao
:save-dao
:update-dao
:query-dao
:query
:execute)
(:import-from :s-sql :sql :sql-compile)
(:import-from :simple-date :universal-time-to-timestamp)
(:export :with-connection
:initialize
:feed
:feed-id
:feed-name
:feed-fetcher
:feed-parser
:feed-source
:feed-added
:feed-updated
:feed-new-items
:feed-schedule
:feed-schedule-parameter
:feed-unread
:feed-tags
:feed-metadata
:item
:item-id
:item-feed
:item-added
:item-read
:item-tags
:item-metadata
:tag
:metadata
+metadata-element+
+metadata-attribute+
:delete-metadata
:element
:element-name
:element-text
:element-children
:element-attributes
:attribute
:attribute-name
:attribute-value
:object-id
:object-type
:object-metadata
:add-feed
:save-feed
:save-metadata
:rm-feed
:get-feeds
:get-feed
:mark-item-read
:mark-feed-read
:mark-all-read
:add-items
:add-item
:get-items
:get-item
:query-items
:query-feeds
:update-feed-unread
:count-feed-unread))
;; Fetchers
(defpackage :feed-source
(:use :cl)
(:export :fetch))
;; Parser meta-package
(defpackage :feed-parser
(:use :cl)
(:export :parse
:get-parser
:register-parser))
(defpackage :curator
(:use :cl)
(:export :curate))
;; Feed update logic and etc.
(defpackage :controller
(:use :cl)
(:export :add-feed
:update-feed
:update-all))
;; Feed update scheduling
(defpackage :scheduler
(:use :cl :split-sequence)
(:export :schedule-feed
:schedule-all
:register-schedule))
;; HTTP server with RESTful API
(defpackage :http-server
(:use :cl :hunchentoot)
(:shadow :start :stop)
(:export :start :stop))
| 3,246 | Common Lisp | .lisp | 120 | 18.816667 | 71 | 0.568292 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 6cba5dc87aeaa9ba7d3c6cca94fb16bae51b264215294f669821b5ebd5749c8e | 26,494 | [
-1
] |
26,495 | curator.lisp | drewt_Aleph/curator.lisp | ;;
;; Copyright 2016 Drew Thoreson
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, version 2 of the
;; License.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
;;
;; curator.lisp
;;
;; This package implements a "curator" for feeds/items. It is responsible for
;; providing a clean and consistent set of metadata for clients.
(in-package :curator)
(defun keep-text (element name)
(list (cons name (feed-store:element-text element))))
(defun strip-html (element name)
"Remove HTML tags from an element's text."
`((,name . ,(string-trim '(#\space #\tab #\newline)
(sanitize:clean (feed-store:element-text element)
sanitize:+restricted+)))))
(defun strip-scripts (element name)
; TODO: remove <script> tags (iframes?)
(keep-text element name))
(defun parse-time (element name)
"Compute a UNIX timestamp from an element storing a universal time."
`((,name . ,(max 0
(- (parse-integer (feed-store:element-text element)
:junk-allowed t)
2208988800)))))
(defun element->attributes-alist (element)
"Return the attributes of ELEMENT as an association list."
(mapcar (lambda (attr)
(cons (feed-store:attribute-name attr)
(feed-store:attribute-value attr)))
(feed-store:element-attributes element)))
(defun parse-media-data (data)
(loop for datum in data
when (let ((name (feed-store:element-name datum)))
(cond
((string= name "media:title")
`("title" . ,(feed-store:element-text datum)))
((string= name "media:content")
`("content" . ,(element->attributes-alist datum)))
((string= name "media:thumbnail")
`("thumbnail" . ,(element->attributes-alist datum)))
(t nil)))
collect it))
(defun parse-media-content (element name)
"Parse a top-level media:content tag into a media metadata object."
`((,name ("content" . ,(element->attributes-alist element))
,@(parse-media-data (feed-store:element-children element)))))
(defun parse-media-group (element name)
"Parse a media:group tag into a media metadata object."
`((,name ,@(parse-media-data (feed-store:element-children element)))))
(defun curate-datum (datum handlers)
"Compute an association list of metadata from the element DATUM, using
curator spec HANDLERS."
(let ((handler (assoc (feed-store:element-name datum) handlers :test #'string=)))
(if handler
(apply (third handler) datum (nthcdr 3 handler))
nil)))
(defun handler-default (handler data curated-data)
"Compute the default value for the datum specified by HANDLER."
(if (functionp (second handler))
(funcall (second handler) data curated-data)
(second handler)))
(defun curate-metadata (object handlers)
"Curate OBJECT's metadata by applying the curator spec HANDLERS to its root
metadata elements."
(let ((data (loop for datum in (feed-store:object-metadata object)
when (curate-datum datum handlers) append it)))
; add defaults
(append data
(loop for handler in handlers
unless (assoc (fourth handler) data :test #'string=)
collect (cons (fourth handler)
(handler-default handler
(feed-store:object-metadata object)
data))))))
(defun find-element (list name)
(find-if (lambda (x)
(string= (feed-store:element-name x) name))
list))
(defun default-published (data curated-data)
(declare (ignore curated-data))
(let ((dc-date (find-element data "dc:date"))
(updated (find-element data "updated")))
(if (or dc-date updated)
(- (cl-date-time-parser:parse-date-time
(feed-store:element-text (or dc-date updated)))
2208988800)
0)))
;; Bring order to the chaos of feed/item metadata. Returns a simple alist.
;; TODO: "ext" option to turn on curator extensions E.g., "ext=mrss" instructs
;; the curator to include MRSS data.
(defgeneric curate (object))
(defmethod curate ((feed feed-store:feed))
"Curate metadata for FEED."
(append
`(("id" . ,(feed-store:feed-id feed))
("name" . ,(feed-store:feed-name feed))
("fetcher" . ,(feed-store:feed-fetcher feed))
("parser" . ,(feed-store:feed-parser feed))
("source" . ,(feed-store:feed-source feed))
("added" . ,(feed-store:feed-added feed))
("unread" . ,(feed-store:feed-unread feed))
("tags" . ,(feed-store:feed-tags feed)))
(curate-metadata feed
; Element Name Default Handler Metadata Name
`(("title" ,(feed-store:feed-name feed) ,#'strip-html "title")
("link" nil ,#'keep-text "link")
("description" "" ,#'strip-html "description")
("published" ,#'default-published ,#'parse-time "published")
("updated" 0 ,#'parse-time "updated")
))))
(defmethod curate ((item feed-store:item))
"Curate metadata for ITEM."
(labels ((default-content (data curated-data)
(declare (ignore curated-data))
(let ((desc (find-element data "description")))
(if desc
(feed-store:element-text desc)
""))))
(append
`(("id" . ,(feed-store:item-id item))
("feed" . ,(feed-store:item-feed item))
("added" . ,(feed-store:item-added item))
("read" . ,(feed-store:item-read item))
("tags" . ,(feed-store:item-tags item)))
(curate-metadata item
; Element Name Default Handler Metadata Name
`(("title" "Untitled" ,#'strip-html "title")
("link" nil ,#'keep-text "link")
("dc:creator" nil ,#'keep-text "creator")
("description" "" ,#'strip-html "description")
("category" nil ,#'keep-text "category")
("content" ,#'default-content ,#'strip-scripts "content")
("published" ,#'default-published ,#'parse-time "published")
("updated" 0 ,#'parse-time "updated")
; Media RSS
("media:content" nil ,#'parse-media-content "media")
("media:group" nil ,#'parse-media-group "media")
)))))
| 7,195 | Common Lisp | .lisp | 151 | 39.483444 | 84 | 0.587164 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 525d0f182ac413871a00d0e4e5326710423be4fee04668a45af411a7a703b40d | 26,495 | [
-1
] |
26,496 | scheduler.lisp | drewt_Aleph/scheduler.lisp | ;;
;; Copyright 2016 Drew Thoreson
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, version 2 of the
;; License.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
;;
;; scheduler.lisp
;;
;; This package implements feed update scheduling policies.
(in-package :scheduler)
;; TODO: use portable libraries for timers/locks
(defvar *scheduled-updates-lock* (sb-thread:make-mutex :name "*scheduled-updates*"))
(defparameter *scheduled-updates* (make-hash-table))
(defparameter *schedules* nil)
(defun get-schedule (name)
"Retrieve the scheduler with the name NAME."
(assoc name *schedules* :test #'string=))
(defun register-schedule (name schedule validate)
"Register a new scheduler with the name NAME."
(push (list name schedule validate) *schedules*))
(defun schedule-feed (feed)
"Schedule an update for the feed FEED. The feed's scheduler is invoked to
determine when the update should occur."
(let ((schedule (get-schedule (feed-store:feed-schedule feed))))
(if schedule
(schedule-update feed (funcall (second schedule)
feed
(feed-store:feed-schedule-parameter feed)))
(warn "Unknown schedule for feed ~a (~a): ~a"
(feed-store:feed-id feed)
(feed-store:feed-name feed)
(feed-store:feed-schedule feed))))
feed)
(defun schedule-update (feed seconds)
"Schedule an update for FEED after SECONDS seconds."
(let* ((id (feed-store:feed-id feed))
(timer (sb-ext:make-timer
(lambda ()
(feed-store:with-connection
(let ((feed (feed-store:get-feed id)))
(sb-thread:with-mutex (*scheduled-updates-lock*)
(remhash id *scheduled-updates*))
; A condition may be signalled during the fetch or parse;
; for now, just emit a warning and reschedule.
(handler-case (controller:update-feed feed)
((not warning) (c)
(warn "Condition signalled during update of ~a: ~a" id c)))
; If update feed signalled a condition before setting this,
; schedule-feed could schedule an update immediately; so we
; set it again.
(setf (feed-store:feed-updated feed)
(simple-date:universal-time-to-timestamp (get-universal-time)))
(schedule-feed feed))))
:thread t
:name (format nil "update-~a" id))))
(sb-thread:with-mutex (*scheduled-updates-lock*)
(setf (gethash id *scheduled-updates*) timer))
(sb-ext:schedule-timer timer seconds)))
(defun schedule-all ()
"Schedule updates for all feeds."
(dolist (feed (feed-store:get-feeds))
(unless (gethash (feed-store:feed-id feed) *scheduled-updates*)
(schedule-feed feed))))
(defun elapsed-since-update (feed)
"Compute the number of seconds elapsed since FEED was last updated."
(max 0 (- (get-universal-time)
(simple-date:timestamp-to-universal-time
(feed-store:feed-updated feed)))))
(defun elapsed-since-new-items (feed)
"Compute the number of seconds elapsed since new items were found for FEED."
(max 0 (- (get-universal-time)
(simple-date:timestamp-to-universal-time
(feed-store:feed-new-items feed)))))
(defun seconds-after-last-update (feed seconds)
"Compute the number of seconds until SECONDS seconds will have elapsed since
FEED was last updated."
(max 0 (- seconds (elapsed-since-update feed))))
;;
;; Validator helpers
;;
(defun positive-integer-p (string)
"Return T if STRING contains only positive integers."
(loop for char across string
always (digit-char-p char)))
(defun *parse-time-part (part)
"Parse PART, which should be a part of a time string (e.g. \"3d\") into a
number and a unit (e.g. '(\"3\" \"d\"))."
(list (subseq part 0 (1- (length part)))
(subseq part (1- (length part)))))
(defun time-valid-p (string)
"Return T if STRING is a valid time string (e.g. \"3d,4h,15m\")."
(labels ((unit-valid-p (unit)
(member (char unit 0) '(#\s #\m #\h #\d)))
(time-part-valid-p (part)
(and (> (length part) 1)
(destructuring-bind (n unit) (*parse-time-part part)
(and (positive-integer-p n)
(unit-valid-p unit))))))
(loop for val in (split-sequence #\, string)
always (time-part-valid-p val))))
(defun minutes-or-time-p (string)
"Return T if STRING is either a time string, or a positive integer."
(or (positive-integer-p string)
(time-valid-p string)))
;;
;; Parameter parsing
;;
(defun parse-params (string)
(split-sequence #\; string))
(defun parse-time-part (part)
"Parse PART, which should be a part of a time string (e.g. \"3d\") into a
number and a unit (e.g. '(3 #\d))."
(destructuring-bind (n unit) (*parse-time-part part)
(list (parse-integer n)
(char unit 0))))
(defun parse-time (string)
"Parse a time string (e.g. \"3d,4h,15m\"), returning the time as a number
of seconds."
(loop for val in (split-sequence #\, string)
with time = 0
finally (return time)
do
(destructuring-bind (n unit) (parse-time-part val)
(case unit
((#\s) (setf time (+ time n)))
((#\m) (setf time (+ time (* 60 n))))
((#\h) (setf time (+ time (* 60 60 n))))
((#\d) (setf time (+ time (* 24 60 60 n))))
(otherwise
(warn "Unknown unit int time string: ~a" (string unit)))))))
(defun parse-minutes-or-time (param)
"Parse PARAM, which should be either a time string or a positive integer,
returning a number of seconds."
(if (positive-integer-p param)
(* 60 (parse-integer param))
(parse-time param)))
;;
;; Scheduling policies
;;
(defun schedule-periodic (feed param)
"Schedule an update after a fixed number of minutes."
(seconds-after-last-update feed (parse-minutes-or-time param)))
(defun schedule-threshold (feed param)
"Schedule an update for one of two fixed numbers of minutes. If less than
THRESHOLD minutes have passed since the feed received new items, then the
update is scheduled for BEFORE minutes; otherwise it is scheduled for
AFTER minutes."
(destructuring-bind (threshold before after) (parse-params param)
(let ((elapsed (elapsed-since-new-items feed)))
(if (>= elapsed (parse-minutes-or-time threshold))
(seconds-after-last-update feed (parse-minutes-or-time after))
(seconds-after-last-update feed (parse-minutes-or-time before))))))
(defun threshold-param-valid-p (param)
"Return T if PARAM is a list of three values, separated by semicolons, and
each value is either a time string or a positive integer."
(let ((params (parse-params param)))
(if (= (length params) 3)
(destructuring-bind (threshold before after) params
(and (minutes-or-time-p threshold)
(minutes-or-time-p before)
(minutes-or-time-p after)))
nil)))
(register-schedule "periodic" #'schedule-periodic #'minutes-or-time-p)
(register-schedule "threshold" #'schedule-threshold #'threshold-param-valid-p)
| 7,854 | Common Lisp | .lisp | 174 | 37.908046 | 93 | 0.641448 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 5ca8d4669a707d004a43a85f1c7d4b469a78f16dcfd07d3a90c2af1b72ed7c17 | 26,496 | [
-1
] |
26,497 | config.lisp | drewt_Aleph/config.lisp | ;;
;; Copyright 2016 Drew Thoreson
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, version 2 of the
;; License.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
;;
;; config.lisp
;;
;; This package handles loading, storing and retrieving configuration settings.
(in-package :config)
(defparameter *config*
`((:database
(:name . "aleph")
(:user . "aleph")
(:pass . "aleph")
(:host . "localhost"))
(:server
(:port . 8080)
(:document-root . "www/")
(:show-lisp-errors . :false)
(:access-log-file . :default)
(:message-log-file . :default))))
;; Merge the given configuration alist with *config*. Settings not specified
;; in the given alist remain unchanged in *config*.
(defun merge-config (config)
(labels ((*merge-config (new old)
(dolist (new-pair new)
(let ((old-pair (assoc (car new-pair) old)))
(cond
((not old-pair)
; append new config value
(nconc old (list new-pair)))
((not (eq (listp (cdr old-pair))
(listp (cdr new-pair))))
(warn (format nil "Skipping config entry '~a': type mismatch"
(car new-pair))))
((listp (cdr old-pair))
(*merge-config (cdr new-pair) (cdr old-pair)))
(t
(setf (cdr old-pair) (cdr new-pair))))))))
(*merge-config config *config*)))
;; Update *config* with values read from a file.
(defun load-from-file (filename)
(with-open-file (stream filename :if-does-not-exist nil)
(if stream
(merge-config (read stream))
(warn (format nil "Configuration file '~a' does not exist" filename)))))
;; Get the value of a configuration setting. 'Name' should be a list of
;; keywords identifying the setting, such as '(:database :name).
(defun get-value (name)
(labels ((*get-value (name val)
(if name
(let ((next (assoc (car name) val)))
(if next
(*get-value (cdr name) (cdr next))
nil))
val)))
(*get-value name *config*)))
(load-from-file "rc.lisp")
| 2,752 | Common Lisp | .lisp | 69 | 31.797101 | 82 | 0.585202 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 9c435d0a744506f8edb66e45c03f75a99ed5961aa5cbea56972837c29032ec90 | 26,497 | [
-1
] |
26,498 | run.lisp | drewt_Aleph/run.lisp | ;;
;; Copyright 2016 Drew Thoreson
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, version 2 of the
;; License.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
;;
(ql:quickload "cl-date-time-parser")
(ql:quickload "cl-json")
(ql:quickload "cxml")
(ql:quickload "drakma")
(ql:quickload "hunchentoot")
(ql:quickload "postmodern")
(ql:quickload "puri")
(ql:quickload "simple-date")
(ql:quickload "sanitize")
(ql:quickload "split-sequence")
;; Configure Drakma to use a proxy if the http_proxy environment variable is
;; set. Unfortunately Drakma only supports HTTP proxies, so in order to use a
;; SOCKS proxy (e.g. Tor) it is necessary to tunnel through an HTTP proxy first
;; (e.g. Privoxy).
(let ((proxy (sb-ext:posix-getenv "http_proxy")))
(when proxy
(let ((uri (puri:parse-uri proxy)))
(if (and (puri:uri-scheme uri)
(not (eql (puri:uri-scheme uri) :HTTP)))
(warn (format nil "Ignoring proxy: ~a; only HTTP proxies are supported" proxy))
(setf drakma:*default-http-proxy*
(if (puri:uri-port uri)
(list (puri:uri-host uri)
(puri:uri-port uri))
(puri:uri-host uri)))))))
(load "package.lisp")
(load "config.lisp")
(load "feed-store.lisp")
(load "feed-source.lisp")
(load "feed-parser.lisp")
(load "curator.lisp")
(load "controller.lisp")
(load "scheduler.lisp")
(load "http-server.lisp")
; Load plugins
(loop for f in (directory "plugins/*.lisp") do
(load f))
(feed-store:initialize)
(scheduler:schedule-all)
(http-server:start)
| 2,010 | Common Lisp | .lisp | 56 | 33.071429 | 87 | 0.704977 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 2a48423e5d8015036b554a49aa6a994825a0bf5b05ccd907ae8085082a88c891 | 26,498 | [
-1
] |
26,499 | http-server.lisp | drewt_Aleph/http-server.lisp | ;;
;; Copyright 2016 Drew Thoreson
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, version 2 of the
;; License.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
;;
;; http-server.lisp
;;
;; This package defines the HTTP API for interacting with the aggregator.
(in-package :http-server)
(defparameter *port* (config:get-value '(:server :port)))
(defparameter *document-root* (config:get-value '(:server :document-root)))
(defvar server (make-instance 'hunchentoot:easy-acceptor
:port *port*
:document-root *document-root*))
(let ((show-errors (config:get-value '(:server :show-lisp-errors)))
(access-log (config:get-value '(:server :access-log-file)))
(message-log (config:get-value '(:server :message-log-file))))
(when (eq :true show-errors)
(setf *show-lisp-errors-p* t))
(unless (eq :default access-log)
(setf (acceptor-access-log-destination server) access-log))
(unless (eq :default message-log)
(setf (acceptor-message-log-destination server) message-log)))
;; Hunchentoot apparently doesn't provide any way to check this, so we keep
;; track of it ourselves.
(defvar server-started nil)
(defun start ()
"Start the Aleph HTTP server."
(if server-started
(warn "Server already running")
(progn
(hunchentoot:start server)
(setf server-started t))))
(defun stop ()
"Stop the Aleph HTTP server."
(if server-started
(progn
(hunchentoot:stop server)
(setf server-started nil))
(warn "Server is not started")))
(defun make-response (obj)
"Respond to a request by sending OBJ to the client, encoded as JSON."
(setf (content-type*) "application/json; charset=utf-8")
(json:encode-json-to-string obj))
(defun not-found ()
"Respond with HTTP code 404."
(setf (return-code*) +HTTP-NOT-FOUND+)
nil)
(defmacro method-case (&body cases)
`(case (request-method*)
,@cases
(otherwise
(setf (return-code*) +HTTP-METHOD-NOT-ALLOWED+)
nil)))
(define-easy-handler (feeds :uri "/feeds")
((since :parameter-type 'integer))
(feed-store:with-connection
(make-response
(or (feed-store:query-feeds
:since (cond
((not since) nil)
; SINCE is a (negative) number of seconds in the past
((< since 0) (+ (get-universal-time) since))
; SINCE is a UNIX timestamp
(t (+ since 2208988800))))
; XXX: we pass an empty vector, since nil is encoded as the null
; JSON value.
#()))))
(define-easy-handler (items :uri "/items")
((limit :init-form 100
:parameter-type 'integer)
(feed :parameter-type 'integer)
(unread :parameter-type 'boolean)
format)
(feed-store:with-connection
(let ((items (feed-store:query-items :limit limit :feed feed :unread unread)))
(make-response (cond ((string= format "raw") items)
(t (mapcar #'curator:curate items)))))))
(define-easy-handler (add-feed :uri "/add-feed")
((name :init-form "Untitled")
(fetcher :init-form "http")
(parser :init-form "auto")
(schedule :init-form "periodic")
(scheduleparameter :init-form "30")
source
(tags :init-form '()))
(feed-store:with-connection
(let ((feed (controller:add-feed name source
:loc-type fetcher
:feed-type parser
:schedule schedule
:schedule-parameter scheduleparameter
:tags tags)))
; TODO: update synchronously
(redirect (format nil "/feeds/~a" (feed-store:feed-id feed))))))
;; TODO: refactor to consolidate code for extracting and validating ID from URL
(defun feed-handler ()
"Serve the feed at /feeds/<id>."
(feed-store:with-connection
(let* ((id (parse-integer (subseq (request-uri*) 7)
:junk-allowed t))
(feed (feed-store:get-feed id))
(fmt (get-parameter "format")))
(if feed
(method-case
((:GET)
(make-response (cond ((string= fmt "raw") feed)
(t (curator:curate feed)))))
((:DELETE)
(feed-store:rm-feed (feed-store:feed-id feed))
nil))
(not-found)))))
(defun feed-items-handler ()
"Serve items for the feed at /feeds/<id>."
(feed-store:with-connection
(let* ((id (parse-integer (subseq (request-uri*) 7)
:junk-allowed t))
(fmt (get-parameter "format"))
(unread (get-parameter "unread")))
(if (feed-store:get-feed id)
(let ((items (feed-store:query-items :feed id :unread unread)))
(method-case
((:GET)
(make-response (cond ((string= fmt "raw") items)
(t (mapcar #'curator:curate items)))))
((:DELETE)
;TODO
nil)))
(not-found)))))
(defun feed-update-handler ()
"Update the feed at /feeds/<id>"
(feed-store:with-connection
(let ((id (parse-integer (subseq (request-uri*) 7)
:junk-allowed t)))
(if (feed-store:get-feed id)
(method-case
((:POST)
(make-response (controller:update-feed id))))
(not-found)))))
(defun feed-mark-read-handler ()
"Mark all items read for the feed at /feeds/<id>."
(feed-store:with-connection
(let ((id (parse-integer (subseq (request-uri*) 7)
:junk-allowed t)))
(if (feed-store:get-feed id)
(method-case
((:POST)
(feed-store:mark-feed-read id)
nil))
(not-found)))))
(defun mark-all-read-handler ()
"Mark all items read."
(feed-store:with-connection
(method-case
((:POST)
(feed-store:mark-all-read)
nil))))
(defun update-all-handler ()
"Update all feeds."
(feed-store:with-connection
(controller:update-all)))
(defun item-mark-read-handler ()
"Mark the item read at /items/<id>."
(feed-store:with-connection
(let ((id (parse-integer (subseq (request-uri*) 7)
:junk-allowed t)))
(if (feed-store:get-item id)
(method-case
((:POST)
(feed-store:mark-item-read id)
nil))
(not-found)))))
(defun item-handler ()
"Serve the item at /items/<id>."
(feed-store:with-connection
(let* ((id (parse-integer (subseq (request-uri*) 7)
:junk-allowed t))
(item (feed-store:get-item id)))
(if item
(method-case
((:GET)
(setf (content-type*) "application/json; charset=utf-8")
(json:encode-json-to-string item)))
(not-found)))))
(defun index-handler ()
"Serve <path>/index.html when <path>/ is requested."
(handle-static-file
; FIXME: join pathnames portably
(format nil "~a~aindex.html"
*document-root*
(puri:uri-path (puri:parse-uri (request-uri*))))))
(defun no-extension-handler ()
"Serve <page>.html when <page> is requested."
(handle-static-file
; FIXME: join pathnames portably
(format nil "~a~a.html"
*document-root*
(puri:uri-path (puri:parse-uri (request-uri*))))))
(setf *dispatch-table*
(list (create-regex-dispatcher "^/feeds/\\d+/items/?$" #'feed-items-handler)
(create-regex-dispatcher "^/feeds/\\d+/update/?$" #'feed-update-handler)
(create-regex-dispatcher "^/feeds/\\d+/mark-read/?$" #'feed-mark-read-handler)
(create-regex-dispatcher "^/feeds/\\d+/?$" #'feed-handler)
(create-regex-dispatcher "^/feeds/mark-read/?$" #'mark-all-read-handler)
(create-regex-dispatcher "^/feeds/update/?$" #'update-all-handler)
(create-regex-dispatcher "^/items/\\d+/mark-read/?$" #'item-mark-read-handler)
(create-regex-dispatcher "^/items/\\d+/?$" #'item-handler)
(create-regex-dispatcher "^/items/mark-read/?$" #'mark-all-read-handler)
'hunchentoot:dispatch-easy-handlers
(create-regex-dispatcher "/$" #'index-handler)
(create-regex-dispatcher "/[^\\./]*$" #'no-extension-handler)))
| 9,203 | Common Lisp | .lisp | 222 | 31.972973 | 90 | 0.570567 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 0b783301b086e3eaf3c0a787dc54cf1778061a0fa500a483b293b162aa7a4bf7 | 26,499 | [
-1
] |
26,500 | feed-source.lisp | drewt_Aleph/feed-source.lisp | ;;
;; Copyright 2016 Drew Thoreson
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, version 2 of the
;; License.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
;;
;; feed-source.lisp
;;
;; This package implements the fetchers for different types of source
;; locations (HTTP(S), file, command).
(in-package :feed-source)
;; Fetcher for HTTP resources.
(defun fetch-http (source)
"Return a stream for the HTTP resource identified by the URI SOURCE."
(drakma:http-request source :want-stream t))
;; Fetcher for local files.
(defun fetch-file (source)
"Return a stream for the file identified by the path SOURCE."
(open source))
;; This fetcher will run source as a shell command and return the output
;; stream.
;; TODO: option to prevent command feeds from being added remotely.
;; TODO: option to disable command feeds altogether
(defun fetch-command (source)
"Return a stream for the output of the shell command SOURCE."
(sb-ext:run-program "sh" (list "-c" source) :output :stream :wait nil))
(defparameter *fetchers*
(list (cons "http" #'fetch-http)
(cons "file" #'fetch-file)
(cons "command" #'fetch-command)))
(defun get-fetcher (name)
"Return the fetcher with the name NAME."
(let ((fetcher (assoc name *fetchers* :test #'string=)))
(if fetcher
(cdr fetcher)
nil)))
(defun register-fetcher (name fetcher)
"Register FETCHER as a fetcher with the name NAME."
(setf *fetchers* (acons name fetcher *fetchers*)))
(defun fetch (fetcher-name source)
"Return a stream for SOURCE using the fetcher named by FETCHER-NAME."
(let ((fetcher (get-fetcher fetcher-name)))
(if fetcher
(funcall fetcher source)
; TODO: error
nil)))
| 2,185 | Common Lisp | .lisp | 56 | 36.446429 | 73 | 0.729373 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 0243b38b5c2bbdb8589250621065f0121ca7b7596e3bd26197b8169f8fb1b882 | 26,500 | [
-1
] |
26,501 | controller.lisp | drewt_Aleph/controller.lisp | ;;
;; Copyright 2016 Drew Thoreson
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, version 2 of the
;; License.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
;;
;; controller.lisp
;;
;; This package includes feed update logic.
(in-package :controller)
(defun add-feed (name source &key (loc-type "http")
(feed-type "auto")
(schedule "periodic")
(schedule-parameter "30")
(tags '()))
"Add a feed to the database."
(scheduler:schedule-feed
(feed-store:add-feed
(make-instance 'feed-store:feed
:name name
:source source
:fetcher loc-type
:parser feed-type
:schedule schedule
:schedule-parameter schedule-parameter
:tags tags))))
(defun *update-feed (feed)
"Fetch and parse a feed."
(feed-parser:parse (feed-store:feed-parser feed)
(feed-source:fetch (feed-store:feed-fetcher feed)
(feed-store:feed-source feed))))
;; Returns the (hopefully) globally-unique identifier for an item. If the
;; feed publisher had any sense, they provided this themselves in the guid or
;; atom:id tags; otherwise we use the link, title or description tag. The
;; Feed ID is always prepended to the guid to further prevent collisions.
(defun get-guid (feed item-metadata)
"Compute a GUID from an item's metadata."
(format nil "~a-~a"
(feed-store:object-id feed)
(fourth
(cond
((assoc "guid" item-metadata :test #'string=))
((assoc "atom:id" item-metadata :test #'string=))
((assoc "link" item-metadata :test #'string=))
((assoc "title" item-metadata :test #'string=))
((assoc "description" item-metadata :test #'string=))
; XXX
(t
(warn (format nil "Unable to find GUID for item in feed ~a: ~a"
(feed-store:feed-id feed)
item-metadata))
'("fake-guid" nil nil (format nil "~a" (get-universal-time))))))))
(defun save-metadata (metadata object)
"Save METADATA as metadata for OBJECT."
(labels ((do-save-metadata (datum parent-id)
(let ((datum-obj (make-instance 'feed-store:metadata
:object-id (feed-store:object-id object)
:object-type (feed-store:object-type object)
:key (first datum)
:value (fourth datum)
:parent parent-id
)))
(feed-store:save-metadata datum-obj)
; save attributes
(dolist (attr (second datum))
(feed-store:save-metadata
(make-instance 'feed-store:metadata
:object-id (feed-store:object-id object)
:object-type (feed-store:object-type object)
:key (car attr)
:value (cdr attr)
:type feed-store:+metadata-attribute+
:parent (feed-store:object-id datum-obj))))
; save child metadata recursively
(dolist (child (third datum))
(do-save-metadata child (feed-store:object-id datum-obj))))))
(feed-store:delete-metadata object)
; Save the root metadata
(dolist (datum metadata)
(do-save-metadata datum -1))))
(defun update-item (item item-metadata)
"Update an item that is already saved in the database if it has changed."
; TODO: compare 'updated' date and replace metadata if newer
(declare (ignore item-metadata))
item)
(defun get-published (item)
"Compute the value of the 'published' field for an item."
(let ((published (assoc "published" item :test #'string=)))
(simple-date:universal-time-to-timestamp
(if published
(parse-integer (fourth published))
(get-universal-time)))))
(defgeneric update-feed (feed))
(defmethod update-feed ((feed feed-store:feed))
"Update FEED, storing new items in the database."
(let ((found-new-items nil)) ; FIXME: yuck
(multiple-value-bind (feed-data items) (*update-feed feed)
(save-metadata feed-data feed)
(dolist (item-metadata items)
(let* ((guid (get-guid feed item-metadata))
(item (feed-store:get-item guid)))
(if item
(update-item item item-metadata)
(let ((item (make-instance 'feed-store:item
:feed (feed-store:object-id feed)
:guid guid
:published (get-published item-metadata))))
(feed-store:add-item item)
(save-metadata item-metadata item)
(setf found-new-items t)))))
; update timestamps and save feed object
(let ((now (simple-date:universal-time-to-timestamp (get-universal-time))))
(setf (feed-store:feed-updated feed) now)
(when found-new-items
(setf (feed-store:feed-new-items feed) now)
(setf (feed-store:feed-unread feed)
(feed-store:count-feed-unread (feed-store:feed-id feed)))))
(feed-store:save-feed feed)
feed)))
(defmethod update-feed ((id integer))
"Update the feed identified by ID, storing new items in the database."
(let ((feed (feed-store:get-feed id)))
(if feed
(update-feed feed)
; TODO: error
nil)))
(defun update-all ()
"Update all feeds."
(dolist (feed (feed-store:get-feeds))
(update-feed feed)))
(defun schedule-all (minutes)
"Schedule updates for all feeds."
(dolist (feed (feed-store:get-feeds))
(sb-ext:schedule-timer
(sb-ext:make-timer (lambda ()
(format t "UPDATING ~a" (feed-store:feed-id feed))
(terpri)
(update-feed feed)
; TODO: reschedule update
)
:name (format nil "update-~a" (feed-store:feed-id feed)))
(* minutes 60))))
| 6,910 | Common Lisp | .lisp | 152 | 33.105263 | 89 | 0.562111 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | caf65d0effc7665d58092a7c09af1f25ed8e46556f750e00109ff7e3f7e86150 | 26,501 | [
-1
] |
26,511 | aleph.js | drewt_Aleph/www/aleph.js | /*
* Copyright (c) 2016 Drew Thoreson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
/*
* Aleph JS API.
*/
var Aleph = (function() {
/*
* Do an HTTP GET request for @url, calling @cb with the result as text and
* the HTTP status code.
*/
function AJAXGet(url, cb) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4)
cb(xhttp.responseText, xhttp.status);
};
xhttp.open("GET", url, !!cb);
xhttp.send();
}
function AJAXPostForm(url, form, cb) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4)
cb(xhttp.responseText, xhttp.status);
};
xhttp.open("POST", url, !!cb);
xhttp.send(form);
}
function AJAXPost(url, params, cb) {
// put the params into a FormData object
var form = new FormData();
for (var name in params) {
form.append(name, params[name]);
}
AJAXPostForm(url, form, cb);
}
return {
getFeeds: function(cb) {
AJAXGet("/feeds", function(text, code) {
cb(code >= 400 ? [] : JSON.parse(text), code)
});
},
getFeed: function(id, cb) {
AJAXGet("/feeds/" + id, function(text, code) {
cb(code >= 400 ? null : JSON.parse(text), code);
});
},
getItems: function(id, cb) {
AJAXGet("/feeds/" + id + "/items", function(text, code) {
cb(code >= 400 ? [] : JSON.parse(text), code);
});
},
updateFeed: function(id, cb) {
AJAXPost("/feeds/" + id + "/update", [], function(text, code) {
cb(code);
});
},
markFeedRead: function(id) {
AJAXPost("/feeds/" + id + "/mark-read", [], function(text, code) {});
},
addFeed: function(form, cb) {
AJAXPostForm("/add-feed", form, function(text, code) {
cb(code >= 400 ? null : JSON.parse(text), code);
});
},
}
})();
| 2,962 | Common Lisp | .l | 86 | 29.930233 | 79 | 0.646813 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 6f1afeadcf299d320ab47d91f5b6e0baf1ede184dc2d991010d1c46716a72e2d | 26,511 | [
-1
] |
26,512 | style.css | drewt_Aleph/www/client/style.css | /*
* General Styling
*/
body {
background-color: white;
font-family: arial, sans-serif;
font-size: 14px;
margin: 0px;
padding: 0px;
}
h2 {
font-family: 'Times New Roman', serif;
}
a {
text-decoration: none;
}
form, fieldset {
border: none;
}
/*
* Context Menus
*/
ul.menu {
position: absolute;
list-style-type: none;
background-color: white;
box-shadow: 0 0 5px rgba(0, 0, 0, .15);
border: 1px solid rgba(0, 0, 0, .15);
top: 0;
left: 0;
margin: 0;
padding: 0;
}
ul.menu li {
border-bottom: 1px solid rgba(0, 0, 0, .05);
margin: 5px;
padding: 5px;
cursor: pointer;
position: relative;
transition: background-color .25s;
overflow: hidden;
font-size: 12px;
}
ul.menu li:hover {
background-color: rgba(0, 0, 0, .15);
}
ul.menu li a {
color: black;
}
/*
* Tool Bar
*/
.tool-bar {
background-color: #F2F2F2;
padding: 10px;
}
.tool-bar a {
padding: 10px 10px;
transition: background-color .25s;
}
.tool-bar a:hover {
background-color: rgba(0, 0, 0, .15);
}
.tool-bar a:visited {
color: blue;
}
/*
* Feed List
*/
div#feeds {
width: 20%;
float: left;
}
table.feed-table {
table-layout: fixed;
width: 100%;
border-collapse: collapse;
}
td.feed-name {
padding-left: 10px;
}
td.feed-unread {
text-align: right;
width: 30px;
}
td.feed-mark-read {
text-align: right;
width: 15px;
}
td.feed-update {
text-align: right;
width: 15px;
}
table.feed-table td {
white-space: nowrap;
overflow: hidden;
}
table.feed-table tr:nth-child(even) {
background-color: #F2F2F2;
}
.feed-table a:visited {
color: blue;
}
/*
* Item List
*/
div#items {
margin-left: 20%;
padding: 0 10px;
}
.item-published {
margin: 10px 0;
}
.item-content {
margin-bottom: 15px;
}
.item-published {
font-size: 12px;
}
.item-author {
font-weight: bold;
}
| 1,798 | Common Lisp | .l | 122 | 12.959016 | 45 | 0.694411 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 39b1a1c075d9c8a0a326c1170fdde5968537f8c787c8871f85e37611a3d185db | 26,512 | [
-1
] |
26,513 | index.html | drewt_Aleph/www/client/index.html | <!doctype html>
<html lang="en" ng-app="alephApp">
<head>
<meta charset="utf-8">
<title>Feeds - λleph</title>
<link rel="stylesheet" href="style.css" />
<script src="app/angular.js"></script>
<script src="app/angular-route.js"></script>
<script src="app/angular-sanitize.js"></script>
<script src="app/ng-contextmenu.js"></script>
<script src="app/app.module.js"></script>
<script src="app/app.config.js"></script>
<script src="app/tool-bar/tool-bar.module.js"></script>
<script src="app/tool-bar/tool-bar.component.js"></script>
<script src="app/feed-list/feed-list.module.js"></script>
<script src="app/feed-list/feed-list.component.js"></script>
<script src="app/item-list/item-list.module.js"></script>
<script src="app/item-list/item-list.component.js"></script>
<script src="app/add-feed/add-feed.module.js"></script>
<script src="app/add-feed/add-feed.component.js"></script>
</head>
<body>
<div id="page">
<tool-bar></tool-bar>
<feed-list></feed-list>
<div ng-view></div>
</div>
</body>
</html>
| 1,106 | Common Lisp | .l | 29 | 33.62069 | 64 | 0.647168 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 2821b4382e1e6c42a2858fe0c02ab82a80bb9088cecbb1a3cc1313516b7325dd | 26,513 | [
-1
] |
26,514 | angular.js | drewt_Aleph/www/client/app/angular.js | /*
AngularJS v1.5.6
(c) 2010-2016 Google, Inc. http://angularjs.org
License: MIT
*/
(function(F){'use strict';function O(a){return function(){var b=arguments[0],d;d="["+(a?a+":":"")+b+"] http://errors.angularjs.org/1.5.6/"+(a?a+"/":"")+b;for(b=1;b<arguments.length;b++){d=d+(1==b?"?":"&")+"p"+(b-1)+"=";var c=encodeURIComponent,e;e=arguments[b];e="function"==typeof e?e.toString().replace(/ \{[\s\S]*$/,""):"undefined"==typeof e?"undefined":"string"!=typeof e?JSON.stringify(e):e;d+=c(e)}return Error(d)}}function xa(a){if(null==a||Wa(a))return!1;if(K(a)||I(a)||G&&a instanceof G)return!0;
var b="length"in Object(a)&&a.length;return Q(b)&&(0<=b&&(b-1 in a||a instanceof Array)||"function"==typeof a.item)}function q(a,b,d){var c,e;if(a)if(E(a))for(c in a)"prototype"==c||"length"==c||"name"==c||a.hasOwnProperty&&!a.hasOwnProperty(c)||b.call(d,a[c],c,a);else if(K(a)||xa(a)){var f="object"!==typeof a;c=0;for(e=a.length;c<e;c++)(f||c in a)&&b.call(d,a[c],c,a)}else if(a.forEach&&a.forEach!==q)a.forEach(b,d,a);else if(rc(a))for(c in a)b.call(d,a[c],c,a);else if("function"===typeof a.hasOwnProperty)for(c in a)a.hasOwnProperty(c)&&
b.call(d,a[c],c,a);else for(c in a)sa.call(a,c)&&b.call(d,a[c],c,a);return a}function sc(a,b,d){for(var c=Object.keys(a).sort(),e=0;e<c.length;e++)b.call(d,a[c[e]],c[e]);return c}function tc(a){return function(b,d){a(d,b)}}function Yd(){return++pb}function Qb(a,b,d){for(var c=a.$$hashKey,e=0,f=b.length;e<f;++e){var g=b[e];if(J(g)||E(g))for(var h=Object.keys(g),k=0,l=h.length;k<l;k++){var m=h[k],n=g[m];d&&J(n)?ha(n)?a[m]=new Date(n.valueOf()):Xa(n)?a[m]=new RegExp(n):n.nodeName?a[m]=n.cloneNode(!0):
Rb(n)?a[m]=n.clone():(J(a[m])||(a[m]=K(n)?[]:{}),Qb(a[m],[n],!0)):a[m]=n}}c?a.$$hashKey=c:delete a.$$hashKey;return a}function P(a){return Qb(a,ya.call(arguments,1),!1)}function Zd(a){return Qb(a,ya.call(arguments,1),!0)}function $(a){return parseInt(a,10)}function Sb(a,b){return P(Object.create(a),b)}function C(){}function Ya(a){return a}function ca(a){return function(){return a}}function uc(a){return E(a.toString)&&a.toString!==ja}function y(a){return"undefined"===typeof a}function v(a){return"undefined"!==
typeof a}function J(a){return null!==a&&"object"===typeof a}function rc(a){return null!==a&&"object"===typeof a&&!vc(a)}function I(a){return"string"===typeof a}function Q(a){return"number"===typeof a}function ha(a){return"[object Date]"===ja.call(a)}function E(a){return"function"===typeof a}function Xa(a){return"[object RegExp]"===ja.call(a)}function Wa(a){return a&&a.window===a}function Za(a){return a&&a.$evalAsync&&a.$watch}function Ea(a){return"boolean"===typeof a}function $d(a){return a&&Q(a.length)&&
ae.test(ja.call(a))}function Rb(a){return!(!a||!(a.nodeName||a.prop&&a.attr&&a.find))}function be(a){var b={};a=a.split(",");var d;for(d=0;d<a.length;d++)b[a[d]]=!0;return b}function ta(a){return L(a.nodeName||a[0]&&a[0].nodeName)}function $a(a,b){var d=a.indexOf(b);0<=d&&a.splice(d,1);return d}function oa(a,b){function d(a,b){var d=b.$$hashKey,e;if(K(a)){e=0;for(var f=a.length;e<f;e++)b.push(c(a[e]))}else if(rc(a))for(e in a)b[e]=c(a[e]);else if(a&&"function"===typeof a.hasOwnProperty)for(e in a)a.hasOwnProperty(e)&&
(b[e]=c(a[e]));else for(e in a)sa.call(a,e)&&(b[e]=c(a[e]));d?b.$$hashKey=d:delete b.$$hashKey;return b}function c(a){if(!J(a))return a;var b=f.indexOf(a);if(-1!==b)return g[b];if(Wa(a)||Za(a))throw za("cpws");var b=!1,c=e(a);void 0===c&&(c=K(a)?[]:Object.create(vc(a)),b=!0);f.push(a);g.push(c);return b?d(a,c):c}function e(a){switch(ja.call(a)){case "[object Int8Array]":case "[object Int16Array]":case "[object Int32Array]":case "[object Float32Array]":case "[object Float64Array]":case "[object Uint8Array]":case "[object Uint8ClampedArray]":case "[object Uint16Array]":case "[object Uint32Array]":return new a.constructor(c(a.buffer));
case "[object ArrayBuffer]":if(!a.slice){var b=new ArrayBuffer(a.byteLength);(new Uint8Array(b)).set(new Uint8Array(a));return b}return a.slice(0);case "[object Boolean]":case "[object Number]":case "[object String]":case "[object Date]":return new a.constructor(a.valueOf());case "[object RegExp]":return b=new RegExp(a.source,a.toString().match(/[^\/]*$/)[0]),b.lastIndex=a.lastIndex,b;case "[object Blob]":return new a.constructor([a],{type:a.type})}if(E(a.cloneNode))return a.cloneNode(!0)}var f=[],
g=[];if(b){if($d(b)||"[object ArrayBuffer]"===ja.call(b))throw za("cpta");if(a===b)throw za("cpi");K(b)?b.length=0:q(b,function(a,d){"$$hashKey"!==d&&delete b[d]});f.push(a);g.push(b);return d(a,b)}return c(a)}function fa(a,b){if(K(a)){b=b||[];for(var d=0,c=a.length;d<c;d++)b[d]=a[d]}else if(J(a))for(d in b=b||{},a)if("$"!==d.charAt(0)||"$"!==d.charAt(1))b[d]=a[d];return b||a}function na(a,b){if(a===b)return!0;if(null===a||null===b)return!1;if(a!==a&&b!==b)return!0;var d=typeof a,c;if(d==typeof b&&
"object"==d)if(K(a)){if(!K(b))return!1;if((d=a.length)==b.length){for(c=0;c<d;c++)if(!na(a[c],b[c]))return!1;return!0}}else{if(ha(a))return ha(b)?na(a.getTime(),b.getTime()):!1;if(Xa(a))return Xa(b)?a.toString()==b.toString():!1;if(Za(a)||Za(b)||Wa(a)||Wa(b)||K(b)||ha(b)||Xa(b))return!1;d=S();for(c in a)if("$"!==c.charAt(0)&&!E(a[c])){if(!na(a[c],b[c]))return!1;d[c]=!0}for(c in b)if(!(c in d)&&"$"!==c.charAt(0)&&v(b[c])&&!E(b[c]))return!1;return!0}return!1}function ab(a,b,d){return a.concat(ya.call(b,
d))}function bb(a,b){var d=2<arguments.length?ya.call(arguments,2):[];return!E(b)||b instanceof RegExp?b:d.length?function(){return arguments.length?b.apply(a,ab(d,arguments,0)):b.apply(a,d)}:function(){return arguments.length?b.apply(a,arguments):b.call(a)}}function ce(a,b){var d=b;"string"===typeof a&&"$"===a.charAt(0)&&"$"===a.charAt(1)?d=void 0:Wa(b)?d="$WINDOW":b&&F.document===b?d="$DOCUMENT":Za(b)&&(d="$SCOPE");return d}function cb(a,b){if(!y(a))return Q(b)||(b=b?2:null),JSON.stringify(a,ce,
b)}function wc(a){return I(a)?JSON.parse(a):a}function xc(a,b){a=a.replace(de,"");var d=Date.parse("Jan 01, 1970 00:00:00 "+a)/6E4;return isNaN(d)?b:d}function Tb(a,b,d){d=d?-1:1;var c=a.getTimezoneOffset();b=xc(b,c);d*=b-c;a=new Date(a.getTime());a.setMinutes(a.getMinutes()+d);return a}function ua(a){a=G(a).clone();try{a.empty()}catch(b){}var d=G("<div>").append(a).html();try{return a[0].nodeType===Na?L(d):d.match(/^(<[^>]+>)/)[1].replace(/^<([\w\-]+)/,function(a,b){return"<"+L(b)})}catch(c){return L(d)}}
function yc(a){try{return decodeURIComponent(a)}catch(b){}}function zc(a){var b={};q((a||"").split("&"),function(a){var c,e,f;a&&(e=a=a.replace(/\+/g,"%20"),c=a.indexOf("="),-1!==c&&(e=a.substring(0,c),f=a.substring(c+1)),e=yc(e),v(e)&&(f=v(f)?yc(f):!0,sa.call(b,e)?K(b[e])?b[e].push(f):b[e]=[b[e],f]:b[e]=f))});return b}function Ub(a){var b=[];q(a,function(a,c){K(a)?q(a,function(a){b.push(ia(c,!0)+(!0===a?"":"="+ia(a,!0)))}):b.push(ia(c,!0)+(!0===a?"":"="+ia(a,!0)))});return b.length?b.join("&"):""}
function qb(a){return ia(a,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+")}function ia(a,b){return encodeURIComponent(a).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%3B/gi,";").replace(/%20/g,b?"%20":"+")}function ee(a,b){var d,c,e=Oa.length;for(c=0;c<e;++c)if(d=Oa[c]+b,I(d=a.getAttribute(d)))return d;return null}function fe(a,b){var d,c,e={};q(Oa,function(b){b+="app";!d&&a.hasAttribute&&a.hasAttribute(b)&&(d=a,c=a.getAttribute(b))});
q(Oa,function(b){b+="app";var e;!d&&(e=a.querySelector("["+b.replace(":","\\:")+"]"))&&(d=e,c=e.getAttribute(b))});d&&(e.strictDi=null!==ee(d,"strict-di"),b(d,c?[c]:[],e))}function Ac(a,b,d){J(d)||(d={});d=P({strictDi:!1},d);var c=function(){a=G(a);if(a.injector()){var c=a[0]===F.document?"document":ua(a);throw za("btstrpd",c.replace(/</,"<").replace(/>/,">"));}b=b||[];b.unshift(["$provide",function(b){b.value("$rootElement",a)}]);d.debugInfoEnabled&&b.push(["$compileProvider",function(a){a.debugInfoEnabled(!0)}]);
b.unshift("ng");c=db(b,d.strictDi);c.invoke(["$rootScope","$rootElement","$compile","$injector",function(a,b,c,d){a.$apply(function(){b.data("$injector",d);c(b)(a)})}]);return c},e=/^NG_ENABLE_DEBUG_INFO!/,f=/^NG_DEFER_BOOTSTRAP!/;F&&e.test(F.name)&&(d.debugInfoEnabled=!0,F.name=F.name.replace(e,""));if(F&&!f.test(F.name))return c();F.name=F.name.replace(f,"");da.resumeBootstrap=function(a){q(a,function(a){b.push(a)});return c()};E(da.resumeDeferredBootstrap)&&da.resumeDeferredBootstrap()}function ge(){F.name=
"NG_ENABLE_DEBUG_INFO!"+F.name;F.location.reload()}function he(a){a=da.element(a).injector();if(!a)throw za("test");return a.get("$$testability")}function Bc(a,b){b=b||"_";return a.replace(ie,function(a,c){return(c?b:"")+a.toLowerCase()})}function je(){var a;if(!Cc){var b=rb();(Y=y(b)?F.jQuery:b?F[b]:void 0)&&Y.fn.on?(G=Y,P(Y.fn,{scope:Pa.scope,isolateScope:Pa.isolateScope,controller:Pa.controller,injector:Pa.injector,inheritedData:Pa.inheritedData}),a=Y.cleanData,Y.cleanData=function(b){for(var c,
e=0,f;null!=(f=b[e]);e++)(c=Y._data(f,"events"))&&c.$destroy&&Y(f).triggerHandler("$destroy");a(b)}):G=T;da.element=G;Cc=!0}}function sb(a,b,d){if(!a)throw za("areq",b||"?",d||"required");return a}function Qa(a,b,d){d&&K(a)&&(a=a[a.length-1]);sb(E(a),b,"not a function, got "+(a&&"object"===typeof a?a.constructor.name||"Object":typeof a));return a}function Ra(a,b){if("hasOwnProperty"===a)throw za("badname",b);}function Dc(a,b,d){if(!b)return a;b=b.split(".");for(var c,e=a,f=b.length,g=0;g<f;g++)c=
b[g],a&&(a=(e=a)[c]);return!d&&E(a)?bb(e,a):a}function tb(a){for(var b=a[0],d=a[a.length-1],c,e=1;b!==d&&(b=b.nextSibling);e++)if(c||a[e]!==b)c||(c=G(ya.call(a,0,e))),c.push(b);return c||a}function S(){return Object.create(null)}function ke(a){function b(a,b,c){return a[b]||(a[b]=c())}var d=O("$injector"),c=O("ng");a=b(a,"angular",Object);a.$$minErr=a.$$minErr||O;return b(a,"module",function(){var a={};return function(f,g,h){if("hasOwnProperty"===f)throw c("badname","module");g&&a.hasOwnProperty(f)&&
(a[f]=null);return b(a,f,function(){function a(b,d,e,f){f||(f=c);return function(){f[e||"push"]([b,d,arguments]);return U}}function b(a,d){return function(b,e){e&&E(e)&&(e.$$moduleName=f);c.push([a,d,arguments]);return U}}if(!g)throw d("nomod",f);var c=[],e=[],p=[],x=a("$injector","invoke","push",e),U={_invokeQueue:c,_configBlocks:e,_runBlocks:p,requires:g,name:f,provider:b("$provide","provider"),factory:b("$provide","factory"),service:b("$provide","service"),value:a("$provide","value"),constant:a("$provide",
"constant","unshift"),decorator:b("$provide","decorator"),animation:b("$animateProvider","register"),filter:b("$filterProvider","register"),controller:b("$controllerProvider","register"),directive:b("$compileProvider","directive"),component:b("$compileProvider","component"),config:x,run:function(a){p.push(a);return this}};h&&x(h);return U})}})}function le(a){P(a,{bootstrap:Ac,copy:oa,extend:P,merge:Zd,equals:na,element:G,forEach:q,injector:db,noop:C,bind:bb,toJson:cb,fromJson:wc,identity:Ya,isUndefined:y,
isDefined:v,isString:I,isFunction:E,isObject:J,isNumber:Q,isElement:Rb,isArray:K,version:me,isDate:ha,lowercase:L,uppercase:ub,callbacks:{counter:0},getTestability:he,$$minErr:O,$$csp:Fa,reloadWithDebugInfo:ge});Vb=ke(F);Vb("ng",["ngLocale"],["$provide",function(a){a.provider({$$sanitizeUri:ne});a.provider("$compile",Ec).directive({a:oe,input:Fc,textarea:Fc,form:pe,script:qe,select:re,style:se,option:te,ngBind:ue,ngBindHtml:ve,ngBindTemplate:we,ngClass:xe,ngClassEven:ye,ngClassOdd:ze,ngCloak:Ae,ngController:Be,
ngForm:Ce,ngHide:De,ngIf:Ee,ngInclude:Fe,ngInit:Ge,ngNonBindable:He,ngPluralize:Ie,ngRepeat:Je,ngShow:Ke,ngStyle:Le,ngSwitch:Me,ngSwitchWhen:Ne,ngSwitchDefault:Oe,ngOptions:Pe,ngTransclude:Qe,ngModel:Re,ngList:Se,ngChange:Te,pattern:Gc,ngPattern:Gc,required:Hc,ngRequired:Hc,minlength:Ic,ngMinlength:Ic,maxlength:Jc,ngMaxlength:Jc,ngValue:Ue,ngModelOptions:Ve}).directive({ngInclude:We}).directive(vb).directive(Kc);a.provider({$anchorScroll:Xe,$animate:Ye,$animateCss:Ze,$$animateJs:$e,$$animateQueue:af,
$$AnimateRunner:bf,$$animateAsyncRun:cf,$browser:df,$cacheFactory:ef,$controller:ff,$document:gf,$exceptionHandler:hf,$filter:Lc,$$forceReflow:jf,$interpolate:kf,$interval:lf,$http:mf,$httpParamSerializer:nf,$httpParamSerializerJQLike:of,$httpBackend:pf,$xhrFactory:qf,$location:rf,$log:sf,$parse:tf,$rootScope:uf,$q:vf,$$q:wf,$sce:xf,$sceDelegate:yf,$sniffer:zf,$templateCache:Af,$templateRequest:Bf,$$testability:Cf,$timeout:Df,$window:Ef,$$rAF:Ff,$$jqLite:Gf,$$HashMap:Hf,$$cookieReader:If})}])}function eb(a){return a.replace(Jf,
function(a,d,c,e){return e?c.toUpperCase():c}).replace(Kf,"Moz$1")}function Mc(a){a=a.nodeType;return 1===a||!a||9===a}function Nc(a,b){var d,c,e=b.createDocumentFragment(),f=[];if(Wb.test(a)){d=d||e.appendChild(b.createElement("div"));c=(Lf.exec(a)||["",""])[1].toLowerCase();c=ga[c]||ga._default;d.innerHTML=c[1]+a.replace(Mf,"<$1></$2>")+c[2];for(c=c[0];c--;)d=d.lastChild;f=ab(f,d.childNodes);d=e.firstChild;d.textContent=""}else f.push(b.createTextNode(a));e.textContent="";e.innerHTML="";q(f,function(a){e.appendChild(a)});
return e}function Oc(a,b){var d=a.parentNode;d&&d.replaceChild(b,a);b.appendChild(a)}function T(a){if(a instanceof T)return a;var b;I(a)&&(a=V(a),b=!0);if(!(this instanceof T)){if(b&&"<"!=a.charAt(0))throw Xb("nosel");return new T(a)}if(b){b=F.document;var d;a=(d=Nf.exec(a))?[b.createElement(d[1])]:(d=Nc(a,b))?d.childNodes:[]}Pc(this,a)}function Yb(a){return a.cloneNode(!0)}function wb(a,b){b||fb(a);if(a.querySelectorAll)for(var d=a.querySelectorAll("*"),c=0,e=d.length;c<e;c++)fb(d[c])}function Qc(a,
b,d,c){if(v(c))throw Xb("offargs");var e=(c=xb(a))&&c.events,f=c&&c.handle;if(f)if(b){var g=function(b){var c=e[b];v(d)&&$a(c||[],d);v(d)&&c&&0<c.length||(a.removeEventListener(b,f,!1),delete e[b])};q(b.split(" "),function(a){g(a);yb[a]&&g(yb[a])})}else for(b in e)"$destroy"!==b&&a.removeEventListener(b,f,!1),delete e[b]}function fb(a,b){var d=a.ng339,c=d&&gb[d];c&&(b?delete c.data[b]:(c.handle&&(c.events.$destroy&&c.handle({},"$destroy"),Qc(a)),delete gb[d],a.ng339=void 0))}function xb(a,b){var d=
a.ng339,d=d&&gb[d];b&&!d&&(a.ng339=d=++Of,d=gb[d]={events:{},data:{},handle:void 0});return d}function Zb(a,b,d){if(Mc(a)){var c=v(d),e=!c&&b&&!J(b),f=!b;a=(a=xb(a,!e))&&a.data;if(c)a[b]=d;else{if(f)return a;if(e)return a&&a[b];P(a,b)}}}function zb(a,b){return a.getAttribute?-1<(" "+(a.getAttribute("class")||"")+" ").replace(/[\n\t]/g," ").indexOf(" "+b+" "):!1}function Ab(a,b){b&&a.setAttribute&&q(b.split(" "),function(b){a.setAttribute("class",V((" "+(a.getAttribute("class")||"")+" ").replace(/[\n\t]/g,
" ").replace(" "+V(b)+" "," ")))})}function Bb(a,b){if(b&&a.setAttribute){var d=(" "+(a.getAttribute("class")||"")+" ").replace(/[\n\t]/g," ");q(b.split(" "),function(a){a=V(a);-1===d.indexOf(" "+a+" ")&&(d+=a+" ")});a.setAttribute("class",V(d))}}function Pc(a,b){if(b)if(b.nodeType)a[a.length++]=b;else{var d=b.length;if("number"===typeof d&&b.window!==b){if(d)for(var c=0;c<d;c++)a[a.length++]=b[c]}else a[a.length++]=b}}function Rc(a,b){return Cb(a,"$"+(b||"ngController")+"Controller")}function Cb(a,
b,d){9==a.nodeType&&(a=a.documentElement);for(b=K(b)?b:[b];a;){for(var c=0,e=b.length;c<e;c++)if(v(d=G.data(a,b[c])))return d;a=a.parentNode||11===a.nodeType&&a.host}}function Sc(a){for(wb(a,!0);a.firstChild;)a.removeChild(a.firstChild)}function Db(a,b){b||wb(a);var d=a.parentNode;d&&d.removeChild(a)}function Pf(a,b){b=b||F;if("complete"===b.document.readyState)b.setTimeout(a);else G(b).on("load",a)}function Tc(a,b){var d=Eb[b.toLowerCase()];return d&&Uc[ta(a)]&&d}function Qf(a,b){var d=function(c,
d){c.isDefaultPrevented=function(){return c.defaultPrevented};var f=b[d||c.type],g=f?f.length:0;if(g){if(y(c.immediatePropagationStopped)){var h=c.stopImmediatePropagation;c.stopImmediatePropagation=function(){c.immediatePropagationStopped=!0;c.stopPropagation&&c.stopPropagation();h&&h.call(c)}}c.isImmediatePropagationStopped=function(){return!0===c.immediatePropagationStopped};var k=f.specialHandlerWrapper||Rf;1<g&&(f=fa(f));for(var l=0;l<g;l++)c.isImmediatePropagationStopped()||k(a,c,f[l])}};d.elem=
a;return d}function Rf(a,b,d){d.call(a,b)}function Sf(a,b,d){var c=b.relatedTarget;c&&(c===a||Tf.call(a,c))||d.call(a,b)}function Gf(){this.$get=function(){return P(T,{hasClass:function(a,b){a.attr&&(a=a[0]);return zb(a,b)},addClass:function(a,b){a.attr&&(a=a[0]);return Bb(a,b)},removeClass:function(a,b){a.attr&&(a=a[0]);return Ab(a,b)}})}}function Ga(a,b){var d=a&&a.$$hashKey;if(d)return"function"===typeof d&&(d=a.$$hashKey()),d;d=typeof a;return d="function"==d||"object"==d&&null!==a?a.$$hashKey=
d+":"+(b||Yd)():d+":"+a}function Sa(a,b){if(b){var d=0;this.nextUid=function(){return++d}}q(a,this.put,this)}function Vc(a){a=(Function.prototype.toString.call(a)+" ").replace(Uf,"");return a.match(Vf)||a.match(Wf)}function Xf(a){return(a=Vc(a))?"function("+(a[1]||"").replace(/[\s\r\n]+/," ")+")":"fn"}function db(a,b){function d(a){return function(b,c){if(J(b))q(b,tc(a));else return a(b,c)}}function c(a,b){Ra(a,"service");if(E(b)||K(b))b=p.instantiate(b);if(!b.$get)throw Ha("pget",a);return n[a+"Provider"]=
b}function e(a,b){return function(){var c=z.invoke(b,this);if(y(c))throw Ha("undef",a);return c}}function f(a,b,d){return c(a,{$get:!1!==d?e(a,b):b})}function g(a){sb(y(a)||K(a),"modulesToLoad","not an array");var b=[],c;q(a,function(a){function d(a){var b,c;b=0;for(c=a.length;b<c;b++){var e=a[b],f=p.get(e[0]);f[e[1]].apply(f,e[2])}}if(!m.get(a)){m.put(a,!0);try{I(a)?(c=Vb(a),b=b.concat(g(c.requires)).concat(c._runBlocks),d(c._invokeQueue),d(c._configBlocks)):E(a)?b.push(p.invoke(a)):K(a)?b.push(p.invoke(a)):
Qa(a,"module")}catch(e){throw K(a)&&(a=a[a.length-1]),e.message&&e.stack&&-1==e.stack.indexOf(e.message)&&(e=e.message+"\n"+e.stack),Ha("modulerr",a,e.stack||e.message||e);}}});return b}function h(a,c){function d(b,e){if(a.hasOwnProperty(b)){if(a[b]===k)throw Ha("cdep",b+" <- "+l.join(" <- "));return a[b]}try{return l.unshift(b),a[b]=k,a[b]=c(b,e)}catch(f){throw a[b]===k&&delete a[b],f;}finally{l.shift()}}function e(a,c,f){var g=[];a=db.$$annotate(a,b,f);for(var h=0,k=a.length;h<k;h++){var l=a[h];
if("string"!==typeof l)throw Ha("itkn",l);g.push(c&&c.hasOwnProperty(l)?c[l]:d(l,f))}return g}return{invoke:function(a,b,c,d){"string"===typeof c&&(d=c,c=null);c=e(a,c,d);K(a)&&(a=a[a.length-1]);d=11>=Ba?!1:"function"===typeof a&&/^(?:class\s|constructor\()/.test(Function.prototype.toString.call(a)+" ");return d?(c.unshift(null),new (Function.prototype.bind.apply(a,c))):a.apply(b,c)},instantiate:function(a,b,c){var d=K(a)?a[a.length-1]:a;a=e(a,b,c);a.unshift(null);return new (Function.prototype.bind.apply(d,
a))},get:d,annotate:db.$$annotate,has:function(b){return n.hasOwnProperty(b+"Provider")||a.hasOwnProperty(b)}}}b=!0===b;var k={},l=[],m=new Sa([],!0),n={$provide:{provider:d(c),factory:d(f),service:d(function(a,b){return f(a,["$injector",function(a){return a.instantiate(b)}])}),value:d(function(a,b){return f(a,ca(b),!1)}),constant:d(function(a,b){Ra(a,"constant");n[a]=b;x[a]=b}),decorator:function(a,b){var c=p.get(a+"Provider"),d=c.$get;c.$get=function(){var a=z.invoke(d,c);return z.invoke(b,null,
{$delegate:a})}}}},p=n.$injector=h(n,function(a,b){da.isString(b)&&l.push(b);throw Ha("unpr",l.join(" <- "));}),x={},U=h(x,function(a,b){var c=p.get(a+"Provider",b);return z.invoke(c.$get,c,void 0,a)}),z=U;n.$injectorProvider={$get:ca(U)};var r=g(a),z=U.get("$injector");z.strictDi=b;q(r,function(a){a&&z.invoke(a)});return z}function Xe(){var a=!0;this.disableAutoScrolling=function(){a=!1};this.$get=["$window","$location","$rootScope",function(b,d,c){function e(a){var b=null;Array.prototype.some.call(a,
function(a){if("a"===ta(a))return b=a,!0});return b}function f(a){if(a){a.scrollIntoView();var c;c=g.yOffset;E(c)?c=c():Rb(c)?(c=c[0],c="fixed"!==b.getComputedStyle(c).position?0:c.getBoundingClientRect().bottom):Q(c)||(c=0);c&&(a=a.getBoundingClientRect().top,b.scrollBy(0,a-c))}else b.scrollTo(0,0)}function g(a){a=I(a)?a:d.hash();var b;a?(b=h.getElementById(a))?f(b):(b=e(h.getElementsByName(a)))?f(b):"top"===a&&f(null):f(null)}var h=b.document;a&&c.$watch(function(){return d.hash()},function(a,b){a===
b&&""===a||Pf(function(){c.$evalAsync(g)})});return g}]}function hb(a,b){if(!a&&!b)return"";if(!a)return b;if(!b)return a;K(a)&&(a=a.join(" "));K(b)&&(b=b.join(" "));return a+" "+b}function Yf(a){I(a)&&(a=a.split(" "));var b=S();q(a,function(a){a.length&&(b[a]=!0)});return b}function Ia(a){return J(a)?a:{}}function Zf(a,b,d,c){function e(a){try{a.apply(null,ya.call(arguments,1))}finally{if(U--,0===U)for(;z.length;)try{z.pop()()}catch(b){d.error(b)}}}function f(){w=null;g();h()}function g(){r=ka();
r=y(r)?null:r;na(r,H)&&(r=H);H=r}function h(){if(u!==k.url()||D!==r)u=k.url(),D=r,q(B,function(a){a(k.url(),r)})}var k=this,l=a.location,m=a.history,n=a.setTimeout,p=a.clearTimeout,x={};k.isMock=!1;var U=0,z=[];k.$$completeOutstandingRequest=e;k.$$incOutstandingRequestCount=function(){U++};k.notifyWhenNoOutstandingRequests=function(a){0===U?a():z.push(a)};var r,D,u=l.href,t=b.find("base"),w=null,ka=c.history?function(){try{return m.state}catch(a){}}:C;g();D=r;k.url=function(b,d,e){y(e)&&(e=null);
l!==a.location&&(l=a.location);m!==a.history&&(m=a.history);if(b){var f=D===e;if(u===b&&(!c.history||f))return k;var h=u&&Ja(u)===Ja(b);u=b;D=e;!c.history||h&&f?(h||(w=b),d?l.replace(b):h?(d=l,e=b.indexOf("#"),e=-1===e?"":b.substr(e),d.hash=e):l.href=b,l.href!==b&&(w=b)):(m[d?"replaceState":"pushState"](e,"",b),g(),D=r);w&&(w=b);return k}return w||l.href.replace(/%27/g,"'")};k.state=function(){return r};var B=[],A=!1,H=null;k.onUrlChange=function(b){if(!A){if(c.history)G(a).on("popstate",f);G(a).on("hashchange",
f);A=!0}B.push(b);return b};k.$$applicationDestroyed=function(){G(a).off("hashchange popstate",f)};k.$$checkUrlChange=h;k.baseHref=function(){var a=t.attr("href");return a?a.replace(/^(https?\:)?\/\/[^\/]*/,""):""};k.defer=function(a,b){var c;U++;c=n(function(){delete x[c];e(a)},b||0);x[c]=!0;return c};k.defer.cancel=function(a){return x[a]?(delete x[a],p(a),e(C),!0):!1}}function df(){this.$get=["$window","$log","$sniffer","$document",function(a,b,d,c){return new Zf(a,c,b,d)}]}function ef(){this.$get=
function(){function a(a,c){function e(a){a!=n&&(p?p==a&&(p=a.n):p=a,f(a.n,a.p),f(a,n),n=a,n.n=null)}function f(a,b){a!=b&&(a&&(a.p=b),b&&(b.n=a))}if(a in b)throw O("$cacheFactory")("iid",a);var g=0,h=P({},c,{id:a}),k=S(),l=c&&c.capacity||Number.MAX_VALUE,m=S(),n=null,p=null;return b[a]={put:function(a,b){if(!y(b)){if(l<Number.MAX_VALUE){var c=m[a]||(m[a]={key:a});e(c)}a in k||g++;k[a]=b;g>l&&this.remove(p.key);return b}},get:function(a){if(l<Number.MAX_VALUE){var b=m[a];if(!b)return;e(b)}return k[a]},
remove:function(a){if(l<Number.MAX_VALUE){var b=m[a];if(!b)return;b==n&&(n=b.p);b==p&&(p=b.n);f(b.n,b.p);delete m[a]}a in k&&(delete k[a],g--)},removeAll:function(){k=S();g=0;m=S();n=p=null},destroy:function(){m=h=k=null;delete b[a]},info:function(){return P({},h,{size:g})}}}var b={};a.info=function(){var a={};q(b,function(b,e){a[e]=b.info()});return a};a.get=function(a){return b[a]};return a}}function Af(){this.$get=["$cacheFactory",function(a){return a("templates")}]}function Ec(a,b){function d(a,
b,c){var d=/^\s*([@&<]|=(\*?))(\??)\s*(\w*)\s*$/,e=S();q(a,function(a,f){if(a in n)e[f]=n[a];else{var g=a.match(d);if(!g)throw ea("iscp",b,f,a,c?"controller bindings definition":"isolate scope definition");e[f]={mode:g[1][0],collection:"*"===g[2],optional:"?"===g[3],attrName:g[4]||f};g[4]&&(n[a]=e[f])}});return e}function c(a){var b=a.charAt(0);if(!b||b!==L(b))throw ea("baddir",a);if(a!==a.trim())throw ea("baddir",a);}function e(a){var b=a.require||a.controller&&a.name;!K(b)&&J(b)&&q(b,function(a,
c){var d=a.match(l);a.substring(d[0].length)||(b[c]=d[0]+c)});return b}var f={},g=/^\s*directive\:\s*([\w\-]+)\s+(.*)$/,h=/(([\w\-]+)(?:\:([^;]+))?;?)/,k=be("ngSrc,ngSrcset,src,srcset"),l=/^(?:(\^\^?)?(\?)?(\^\^?)?)?/,m=/^(on[a-z]+|formaction)$/,n=S();this.directive=function z(b,d){Ra(b,"directive");I(b)?(c(b),sb(d,"directiveFactory"),f.hasOwnProperty(b)||(f[b]=[],a.factory(b+"Directive",["$injector","$exceptionHandler",function(a,c){var d=[];q(f[b],function(f,g){try{var h=a.invoke(f);E(h)?h={compile:ca(h)}:
!h.compile&&h.link&&(h.compile=ca(h.link));h.priority=h.priority||0;h.index=g;h.name=h.name||b;h.require=e(h);h.restrict=h.restrict||"EA";h.$$moduleName=f.$$moduleName;d.push(h)}catch(k){c(k)}});return d}])),f[b].push(d)):q(b,tc(z));return this};this.component=function(a,b){function c(a){function e(b){return E(b)||K(b)?function(c,d){return a.invoke(b,this,{$element:c,$attrs:d})}:b}var f=b.template||b.templateUrl?b.template:"",g={controller:d,controllerAs:Wc(b.controller)||b.controllerAs||"$ctrl",
template:e(f),templateUrl:e(b.templateUrl),transclude:b.transclude,scope:{},bindToController:b.bindings||{},restrict:"E",require:b.require};q(b,function(a,b){"$"===b.charAt(0)&&(g[b]=a)});return g}var d=b.controller||function(){};q(b,function(a,b){"$"===b.charAt(0)&&(c[b]=a,E(d)&&(d[b]=a))});c.$inject=["$injector"];return this.directive(a,c)};this.aHrefSanitizationWhitelist=function(a){return v(a)?(b.aHrefSanitizationWhitelist(a),this):b.aHrefSanitizationWhitelist()};this.imgSrcSanitizationWhitelist=
function(a){return v(a)?(b.imgSrcSanitizationWhitelist(a),this):b.imgSrcSanitizationWhitelist()};var p=!0;this.debugInfoEnabled=function(a){return v(a)?(p=a,this):p};var x=10;this.onChangesTtl=function(a){return arguments.length?(x=a,this):x};this.$get=["$injector","$interpolate","$exceptionHandler","$templateRequest","$parse","$controller","$rootScope","$sce","$animate","$$sanitizeUri",function(a,b,c,e,n,w,ka,B,A,H){function M(){try{if(!--oa)throw Y=void 0,ea("infchng",x);ka.$apply(function(){for(var a=
0,b=Y.length;a<b;++a)Y[a]();Y=void 0})}finally{oa++}}function Aa(a,b){if(b){var c=Object.keys(b),d,e,f;d=0;for(e=c.length;d<e;d++)f=c[d],this[f]=b[f]}else this.$attr={};this.$$element=a}function R(a,b,c){la.innerHTML="<span "+b+">";b=la.firstChild.attributes;var d=b[0];b.removeNamedItem(d.name);d.value=c;a.attributes.setNamedItem(d)}function N(a,b){try{a.addClass(b)}catch(c){}}function aa(a,b,c,d,e){a instanceof G||(a=G(a));for(var f=/\S+/,g=0,h=a.length;g<h;g++){var k=a[g];k.nodeType===Na&&k.nodeValue.match(f)&&
Oc(k,a[g]=F.document.createElement("span"))}var l=s(a,b,a,c,d,e);aa.$$addScopeClass(a);var m=null;return function(b,c,d){sb(b,"scope");e&&e.needsNewScope&&(b=b.$parent.$new());d=d||{};var f=d.parentBoundTranscludeFn,g=d.transcludeControllers;d=d.futureParentElement;f&&f.$$boundTransclude&&(f=f.$$boundTransclude);m||(m=(d=d&&d[0])?"foreignobject"!==ta(d)&&ja.call(d).match(/SVG/)?"svg":"html":"html");d="html"!==m?G(ba(m,G("<div>").append(a).html())):c?Pa.clone.call(a):a;if(g)for(var h in g)d.data("$"+
h+"Controller",g[h].instance);aa.$$addScopeInfo(d,b);c&&c(d,b);l&&l(b,d,d,f);return d}}function s(a,b,c,d,e,f){function g(a,c,d,e){var f,k,l,m,n,u,r;if(p)for(r=Array(c.length),m=0;m<h.length;m+=3)f=h[m],r[f]=c[f];else r=c;m=0;for(n=h.length;m<n;)k=r[h[m++]],c=h[m++],f=h[m++],c?(c.scope?(l=a.$new(),aa.$$addScopeInfo(G(k),l)):l=a,u=c.transcludeOnThisElement?va(a,c.transclude,e):!c.templateOnThisElement&&e?e:!e&&b?va(a,b):null,c(f,l,k,d,u)):f&&f(a,k.childNodes,void 0,e)}for(var h=[],k,l,m,n,p,u=0;u<
a.length;u++){k=new Aa;l=$b(a[u],[],k,0===u?d:void 0,e);(f=l.length?Ta(l,a[u],k,b,c,null,[],[],f):null)&&f.scope&&aa.$$addScopeClass(k.$$element);k=f&&f.terminal||!(m=a[u].childNodes)||!m.length?null:s(m,f?(f.transcludeOnThisElement||!f.templateOnThisElement)&&f.transclude:b);if(f||k)h.push(u,f,k),n=!0,p=p||f;f=null}return n?g:null}function va(a,b,c){function d(e,f,g,h,k){e||(e=a.$new(!1,k),e.$$transcluded=!0);return b(e,f,{parentBoundTranscludeFn:c,transcludeControllers:g,futureParentElement:h})}
var e=d.$$slots=S(),f;for(f in b.$$slots)e[f]=b.$$slots[f]?va(a,b.$$slots[f],c):null;return d}function $b(a,b,c,d,e){var f=c.$attr,k;switch(a.nodeType){case 1:Da(b,wa(ta(a)),"E",d,e);for(var l,m,n,p=a.attributes,u=0,r=p&&p.length;u<r;u++){var B=!1,x=!1;l=p[u];k=l.name;m=V(l.value);l=wa(k);if(n=xa.test(l))k=k.replace(Xc,"").substr(8).replace(/_(.)/g,function(a,b){return b.toUpperCase()});(l=l.match(za))&&Q(l[1])&&(B=k,x=k.substr(0,k.length-5)+"end",k=k.substr(0,k.length-6));l=wa(k.toLowerCase());f[l]=
k;if(n||!c.hasOwnProperty(l))c[l]=m,Tc(a,l)&&(c[l]=!0);ha(a,b,m,l,n);Da(b,l,"A",d,e,B,x)}a=a.className;J(a)&&(a=a.animVal);if(I(a)&&""!==a)for(;k=h.exec(a);)l=wa(k[2]),Da(b,l,"C",d,e)&&(c[l]=V(k[3])),a=a.substr(k.index+k[0].length);break;case Na:if(11===Ba)for(;a.parentNode&&a.nextSibling&&a.nextSibling.nodeType===Na;)a.nodeValue+=a.nextSibling.nodeValue,a.parentNode.removeChild(a.nextSibling);$(b,a.nodeValue);break;case 8:try{if(k=g.exec(a.nodeValue))l=wa(k[1]),Da(b,l,"M",d,e)&&(c[l]=V(k[2]))}catch(A){}}b.sort(X);
return b}function Yc(a,b,c){var d=[],e=0;if(b&&a.hasAttribute&&a.hasAttribute(b)){do{if(!a)throw ea("uterdir",b,c);1==a.nodeType&&(a.hasAttribute(b)&&e++,a.hasAttribute(c)&&e--);d.push(a);a=a.nextSibling}while(0<e)}else d.push(a);return G(d)}function O(a,b,c){return function(d,e,f,g,h){e=Yc(e[0],b,c);return a(d,e,f,g,h)}}function ac(a,b,c,d,e,f){var g;return a?aa(b,c,d,e,f):function(){g||(g=aa(b,c,d,e,f),b=c=f=null);return g.apply(this,arguments)}}function Ta(a,b,d,e,f,g,h,k,l){function m(a,b,c,d){if(a){c&&
(a=O(a,c,d));a.require=t.require;a.directiveName=M;if(B===t||t.$$isolateScope)a=fa(a,{isolateScope:!0});h.push(a)}if(b){c&&(b=O(b,c,d));b.require=t.require;b.directiveName=M;if(B===t||t.$$isolateScope)b=fa(b,{isolateScope:!0});k.push(b)}}function n(a,c,e,f,g){function l(a,b,c,d){var e;Za(a)||(d=c,c=b,b=a,a=void 0);w&&(e=z);c||(c=w?D.parent():D);if(d){var f=g.$$slots[d];if(f)return f(a,b,e,c,Fb);if(y(f))throw ea("noslot",d,ua(D));}else return g(a,b,e,c,Fb)}var m,p,A,t,H,z,N,D;b===e?(f=d,D=d.$$element):
(D=G(e),f=new Aa(D,d));H=c;B?t=c.$new(!0):u&&(H=c.$parent);g&&(N=l,N.$$boundTransclude=g,N.isSlotFilled=function(a){return!!g.$$slots[a]});r&&(z=$f(D,f,N,r,t,c,B));B&&(aa.$$addScopeInfo(D,t,!0,!(x&&(x===B||x===B.$$originalDirective))),aa.$$addScopeClass(D,!0),t.$$isolateBindings=B.$$isolateBindings,p=ga(c,f,t,t.$$isolateBindings,B),p.removeWatches&&t.$on("$destroy",p.removeWatches));for(m in z){p=r[m];A=z[m];var R=p.$$bindings.bindToController;A.bindingInfo=A.identifier&&R?ga(H,f,A.instance,R,p):
{};var M=A();M!==A.instance&&(A.instance=M,D.data("$"+p.name+"Controller",M),A.bindingInfo.removeWatches&&A.bindingInfo.removeWatches(),A.bindingInfo=ga(H,f,A.instance,R,p))}q(r,function(a,b){var c=a.require;a.bindToController&&!K(c)&&J(c)&&P(z[b].instance,ib(b,c,D,z))});q(z,function(a){var b=a.instance;E(b.$onChanges)&&b.$onChanges(a.bindingInfo.initialChanges);E(b.$onInit)&&b.$onInit();E(b.$onDestroy)&&H.$on("$destroy",function(){b.$onDestroy()})});m=0;for(p=h.length;m<p;m++)A=h[m],ia(A,A.isolateScope?
t:c,D,f,A.require&&ib(A.directiveName,A.require,D,z),N);var Fb=c;B&&(B.template||null===B.templateUrl)&&(Fb=t);a&&a(Fb,e.childNodes,void 0,g);for(m=k.length-1;0<=m;m--)A=k[m],ia(A,A.isolateScope?t:c,D,f,A.require&&ib(A.directiveName,A.require,D,z),N);q(z,function(a){a=a.instance;E(a.$postLink)&&a.$postLink()})}l=l||{};for(var p=-Number.MAX_VALUE,u=l.newScopeDirective,r=l.controllerDirectives,B=l.newIsolateScopeDirective,x=l.templateDirective,A=l.nonTlbTranscludeDirective,H=!1,z=!1,w=l.hasElementTranscludeDirective,
N=d.$$element=G(b),t,M,R,ka=e,s,Ca=!1,va=!1,v,C=0,F=a.length;C<F;C++){t=a[C];var I=t.$$start,Ta=t.$$end;I&&(N=Yc(b,I,Ta));R=void 0;if(p>t.priority)break;if(v=t.scope)t.templateUrl||(J(v)?(W("new/isolated scope",B||u,t,N),B=t):W("new/isolated scope",B,t,N)),u=u||t;M=t.name;if(!Ca&&(t.replace&&(t.templateUrl||t.template)||t.transclude&&!t.$$tlb)){for(v=C+1;Ca=a[v++];)if(Ca.transclude&&!Ca.$$tlb||Ca.replace&&(Ca.templateUrl||Ca.template)){va=!0;break}Ca=!0}!t.templateUrl&&t.controller&&(v=t.controller,
r=r||S(),W("'"+M+"' controller",r[M],t,N),r[M]=t);if(v=t.transclude)if(H=!0,t.$$tlb||(W("transclusion",A,t,N),A=t),"element"==v)w=!0,p=t.priority,R=N,N=d.$$element=G(aa.$$createComment(M,d[M])),b=N[0],ca(f,ya.call(R,0),b),R[0].$$parentNode=R[0].parentNode,ka=ac(va,R,e,p,g&&g.name,{nonTlbTranscludeDirective:A});else{var L=S();R=G(Yb(b)).contents();if(J(v)){R=[];var Q=S(),Da=S();q(v,function(a,b){var c="?"===a.charAt(0);a=c?a.substring(1):a;Q[a]=b;L[b]=null;Da[b]=c});q(N.contents(),function(a){var b=
Q[wa(ta(a))];b?(Da[b]=!0,L[b]=L[b]||[],L[b].push(a)):R.push(a)});q(Da,function(a,b){if(!a)throw ea("reqslot",b);});for(var X in L)L[X]&&(L[X]=ac(va,L[X],e))}N.empty();ka=ac(va,R,e,void 0,void 0,{needsNewScope:t.$$isolateScope||t.$$newScope});ka.$$slots=L}if(t.template)if(z=!0,W("template",x,t,N),x=t,v=E(t.template)?t.template(N,d):t.template,v=ra(v),t.replace){g=t;R=Wb.test(v)?Zc(ba(t.templateNamespace,V(v))):[];b=R[0];if(1!=R.length||1!==b.nodeType)throw ea("tplrt",M,"");ca(f,N,b);F={$attr:{}};v=
$b(b,[],F);var $=a.splice(C+1,a.length-(C+1));(B||u)&&$c(v,B,u);a=a.concat(v).concat($);T(d,F);F=a.length}else N.html(v);if(t.templateUrl)z=!0,W("template",x,t,N),x=t,t.replace&&(g=t),n=Z(a.splice(C,a.length-C),N,d,f,H&&ka,h,k,{controllerDirectives:r,newScopeDirective:u!==t&&u,newIsolateScopeDirective:B,templateDirective:x,nonTlbTranscludeDirective:A}),F=a.length;else if(t.compile)try{s=t.compile(N,d,ka);var Y=t.$$originalDirective||t;E(s)?m(null,bb(Y,s),I,Ta):s&&m(bb(Y,s.pre),bb(Y,s.post),I,Ta)}catch(da){c(da,
ua(N))}t.terminal&&(n.terminal=!0,p=Math.max(p,t.priority))}n.scope=u&&!0===u.scope;n.transcludeOnThisElement=H;n.templateOnThisElement=z;n.transclude=ka;l.hasElementTranscludeDirective=w;return n}function ib(a,b,c,d){var e;if(I(b)){var f=b.match(l);b=b.substring(f[0].length);var g=f[1]||f[3],f="?"===f[2];"^^"===g?c=c.parent():e=(e=d&&d[b])&&e.instance;if(!e){var h="$"+b+"Controller";e=g?c.inheritedData(h):c.data(h)}if(!e&&!f)throw ea("ctreq",b,a);}else if(K(b))for(e=[],g=0,f=b.length;g<f;g++)e[g]=
ib(a,b[g],c,d);else J(b)&&(e={},q(b,function(b,f){e[f]=ib(a,b,c,d)}));return e||null}function $f(a,b,c,d,e,f,g){var h=S(),k;for(k in d){var l=d[k],m={$scope:l===g||l.$$isolateScope?e:f,$element:a,$attrs:b,$transclude:c},n=l.controller;"@"==n&&(n=b[l.name]);m=w(n,m,!0,l.controllerAs);h[l.name]=m;a.data("$"+l.name+"Controller",m.instance)}return h}function $c(a,b,c){for(var d=0,e=a.length;d<e;d++)a[d]=Sb(a[d],{$$isolateScope:b,$$newScope:c})}function Da(b,e,g,h,k,l,m){if(e===k)return null;k=null;if(f.hasOwnProperty(e)){var n;
e=a.get(e+"Directive");for(var p=0,u=e.length;p<u;p++)try{if(n=e[p],(y(h)||h>n.priority)&&-1!=n.restrict.indexOf(g)){l&&(n=Sb(n,{$$start:l,$$end:m}));if(!n.$$bindings){var r=n,B=n,A=n.name,x={isolateScope:null,bindToController:null};J(B.scope)&&(!0===B.bindToController?(x.bindToController=d(B.scope,A,!0),x.isolateScope={}):x.isolateScope=d(B.scope,A,!1));J(B.bindToController)&&(x.bindToController=d(B.bindToController,A,!0));if(J(x.bindToController)){var t=B.controller,H=B.controllerAs;if(!t)throw ea("noctrl",
A);if(!Wc(t,H))throw ea("noident",A);}var N=r.$$bindings=x;J(N.isolateScope)&&(n.$$isolateBindings=N.isolateScope)}b.push(n);k=n}}catch(w){c(w)}}return k}function Q(b){if(f.hasOwnProperty(b))for(var c=a.get(b+"Directive"),d=0,e=c.length;d<e;d++)if(b=c[d],b.multiElement)return!0;return!1}function T(a,b){var c=b.$attr,d=a.$attr,e=a.$$element;q(a,function(d,e){"$"!=e.charAt(0)&&(b[e]&&b[e]!==d&&(d+=("style"===e?";":" ")+b[e]),a.$set(e,d,!0,c[e]))});q(b,function(b,f){"class"==f?(N(e,b),a["class"]=(a["class"]?
a["class"]+" ":"")+b):"style"==f?(e.attr("style",e.attr("style")+";"+b),a.style=(a.style?a.style+";":"")+b):"$"==f.charAt(0)||a.hasOwnProperty(f)||(a[f]=b,d[f]=c[f])})}function Z(a,b,c,d,f,g,h,k){var l=[],m,n,p=b[0],B=a.shift(),r=Sb(B,{templateUrl:null,transclude:null,replace:null,$$originalDirective:B}),A=E(B.templateUrl)?B.templateUrl(b,c):B.templateUrl,x=B.templateNamespace;b.empty();e(A).then(function(e){var u,t;e=ra(e);if(B.replace){e=Wb.test(e)?Zc(ba(x,V(e))):[];u=e[0];if(1!=e.length||1!==u.nodeType)throw ea("tplrt",
B.name,A);e={$attr:{}};ca(d,b,u);var H=$b(u,[],e);J(B.scope)&&$c(H,!0);a=H.concat(a);T(c,e)}else u=p,b.html(e);a.unshift(r);m=Ta(a,u,c,f,b,B,g,h,k);q(d,function(a,c){a==u&&(d[c]=b[0])});for(n=s(b[0].childNodes,f);l.length;){e=l.shift();t=l.shift();var z=l.shift(),D=l.shift(),H=b[0];if(!e.$$destroyed){if(t!==p){var w=t.className;k.hasElementTranscludeDirective&&B.replace||(H=Yb(u));ca(z,G(t),H);N(G(H),w)}t=m.transcludeOnThisElement?va(e,m.transclude,D):D;m(n,e,H,d,t)}}l=null});return function(a,b,
c,d,e){a=e;b.$$destroyed||(l?l.push(b,c,d,a):(m.transcludeOnThisElement&&(a=va(b,m.transclude,e)),m(n,b,c,d,a)))}}function X(a,b){var c=b.priority-a.priority;return 0!==c?c:a.name!==b.name?a.name<b.name?-1:1:a.index-b.index}function W(a,b,c,d){function e(a){return a?" (module: "+a+")":""}if(b)throw ea("multidir",b.name,e(b.$$moduleName),c.name,e(c.$$moduleName),a,ua(d));}function $(a,c){var d=b(c,!0);d&&a.push({priority:0,compile:function(a){a=a.parent();var b=!!a.length;b&&aa.$$addBindingClass(a);
return function(a,c){var e=c.parent();b||aa.$$addBindingClass(e);aa.$$addBindingInfo(e,d.expressions);a.$watch(d,function(a){c[0].nodeValue=a})}}})}function ba(a,b){a=L(a||"html");switch(a){case "svg":case "math":var c=F.document.createElement("div");c.innerHTML="<"+a+">"+b+"</"+a+">";return c.childNodes[0].childNodes;default:return b}}function da(a,b){if("srcdoc"==b)return B.HTML;var c=ta(a);if("xlinkHref"==b||"form"==c&&"action"==b||"img"!=c&&("src"==b||"ngSrc"==b))return B.RESOURCE_URL}function ha(a,
c,d,e,f){var g=da(a,e);f=k[e]||f;var h=b(d,!0,g,f);if(h){if("multiple"===e&&"select"===ta(a))throw ea("selmulti",ua(a));c.push({priority:100,compile:function(){return{pre:function(a,c,k){c=k.$$observers||(k.$$observers=S());if(m.test(e))throw ea("nodomevents");var l=k[e];l!==d&&(h=l&&b(l,!0,g,f),d=l);h&&(k[e]=h(a),(c[e]||(c[e]=[])).$$inter=!0,(k.$$observers&&k.$$observers[e].$$scope||a).$watch(h,function(a,b){"class"===e&&a!=b?k.$updateClass(a,b):k.$set(e,a)}))}}}})}}function ca(a,b,c){var d=b[0],
e=b.length,f=d.parentNode,g,h;if(a)for(g=0,h=a.length;g<h;g++)if(a[g]==d){a[g++]=c;h=g+e-1;for(var k=a.length;g<k;g++,h++)h<k?a[g]=a[h]:delete a[g];a.length-=e-1;a.context===d&&(a.context=c);break}f&&f.replaceChild(c,d);a=F.document.createDocumentFragment();for(g=0;g<e;g++)a.appendChild(b[g]);G.hasData(d)&&(G.data(c,G.data(d)),G(d).off("$destroy"));G.cleanData(a.querySelectorAll("*"));for(g=1;g<e;g++)delete b[g];b[0]=c;b.length=1}function fa(a,b){return P(function(){return a.apply(null,arguments)},
a,b)}function ia(a,b,d,e,f,g){try{a(b,d,e,f,g)}catch(h){c(h,ua(d))}}function ga(a,c,d,e,f){function g(b,c,e){E(d.$onChanges)&&c!==e&&(Y||(a.$$postDigest(M),Y=[]),m||(m={},Y.push(h)),m[b]&&(e=m[b].previousValue),m[b]=new Gb(e,c))}function h(){d.$onChanges(m);m=void 0}var k=[],l={},m;q(e,function(e,h){var m=e.attrName,p=e.optional,u,B,A,x;switch(e.mode){case "@":p||sa.call(c,m)||(d[h]=c[m]=void 0);c.$observe(m,function(a){if(I(a)||Ea(a))g(h,a,d[h]),d[h]=a});c.$$observers[m].$$scope=a;u=c[m];I(u)?d[h]=
b(u)(a):Ea(u)&&(d[h]=u);l[h]=new Gb(bc,d[h]);break;case "=":if(!sa.call(c,m)){if(p)break;c[m]=void 0}if(p&&!c[m])break;B=n(c[m]);x=B.literal?na:function(a,b){return a===b||a!==a&&b!==b};A=B.assign||function(){u=d[h]=B(a);throw ea("nonassign",c[m],m,f.name);};u=d[h]=B(a);p=function(b){x(b,d[h])||(x(b,u)?A(a,b=d[h]):d[h]=b);return u=b};p.$stateful=!0;p=e.collection?a.$watchCollection(c[m],p):a.$watch(n(c[m],p),null,B.literal);k.push(p);break;case "<":if(!sa.call(c,m)){if(p)break;c[m]=void 0}if(p&&!c[m])break;
B=n(c[m]);var H=d[h]=B(a);l[h]=new Gb(bc,d[h]);p=a.$watch(B,function(a,b){if(b===a){if(b===H)return;b=H}g(h,a,b);d[h]=a},B.literal);k.push(p);break;case "&":B=c.hasOwnProperty(m)?n(c[m]):C;if(B===C&&p)break;d[h]=function(b){return B(a,b)}}});return{initialChanges:l,removeWatches:k.length&&function(){for(var a=0,b=k.length;a<b;++a)k[a]()}}}var ma=/^\w/,la=F.document.createElement("div"),oa=x,Y;Aa.prototype={$normalize:wa,$addClass:function(a){a&&0<a.length&&A.addClass(this.$$element,a)},$removeClass:function(a){a&&
0<a.length&&A.removeClass(this.$$element,a)},$updateClass:function(a,b){var c=ad(a,b);c&&c.length&&A.addClass(this.$$element,c);(c=ad(b,a))&&c.length&&A.removeClass(this.$$element,c)},$set:function(a,b,d,e){var f=Tc(this.$$element[0],a),g=bd[a],h=a;f?(this.$$element.prop(a,b),e=f):g&&(this[g]=b,h=g);this[a]=b;e?this.$attr[a]=e:(e=this.$attr[a])||(this.$attr[a]=e=Bc(a,"-"));f=ta(this.$$element);if("a"===f&&("href"===a||"xlinkHref"===a)||"img"===f&&"src"===a)this[a]=b=H(b,"src"===a);else if("img"===
f&&"srcset"===a&&v(b)){for(var f="",g=V(b),k=/(\s+\d+x\s*,|\s+\d+w\s*,|\s+,|,\s+)/,k=/\s/.test(g)?k:/(,)/,g=g.split(k),k=Math.floor(g.length/2),l=0;l<k;l++)var m=2*l,f=f+H(V(g[m]),!0),f=f+(" "+V(g[m+1]));g=V(g[2*l]).split(/\s/);f+=H(V(g[0]),!0);2===g.length&&(f+=" "+V(g[1]));this[a]=b=f}!1!==d&&(null===b||y(b)?this.$$element.removeAttr(e):ma.test(e)?this.$$element.attr(e,b):R(this.$$element[0],e,b));(a=this.$$observers)&&q(a[h],function(a){try{a(b)}catch(d){c(d)}})},$observe:function(a,b){var c=this,
d=c.$$observers||(c.$$observers=S()),e=d[a]||(d[a]=[]);e.push(b);ka.$evalAsync(function(){e.$$inter||!c.hasOwnProperty(a)||y(c[a])||b(c[a])});return function(){$a(e,b)}}};var pa=b.startSymbol(),qa=b.endSymbol(),ra="{{"==pa&&"}}"==qa?Ya:function(a){return a.replace(/\{\{/g,pa).replace(/}}/g,qa)},xa=/^ngAttr[A-Z]/,za=/^(.+)Start$/;aa.$$addBindingInfo=p?function(a,b){var c=a.data("$binding")||[];K(b)?c=c.concat(b):c.push(b);a.data("$binding",c)}:C;aa.$$addBindingClass=p?function(a){N(a,"ng-binding")}:
C;aa.$$addScopeInfo=p?function(a,b,c,d){a.data(c?d?"$isolateScopeNoTemplate":"$isolateScope":"$scope",b)}:C;aa.$$addScopeClass=p?function(a,b){N(a,b?"ng-isolate-scope":"ng-scope")}:C;aa.$$createComment=function(a,b){var c="";p&&(c=" "+(a||"")+": ",b&&(c+=b+" "));return F.document.createComment(c)};return aa}]}function Gb(a,b){this.previousValue=a;this.currentValue=b}function wa(a){return eb(a.replace(Xc,""))}function ad(a,b){var d="",c=a.split(/\s+/),e=b.split(/\s+/),f=0;a:for(;f<c.length;f++){for(var g=
c[f],h=0;h<e.length;h++)if(g==e[h])continue a;d+=(0<d.length?" ":"")+g}return d}function Zc(a){a=G(a);var b=a.length;if(1>=b)return a;for(;b--;)8===a[b].nodeType&&ag.call(a,b,1);return a}function Wc(a,b){if(b&&I(b))return b;if(I(a)){var d=cd.exec(a);if(d)return d[3]}}function ff(){var a={},b=!1;this.has=function(b){return a.hasOwnProperty(b)};this.register=function(b,c){Ra(b,"controller");J(b)?P(a,b):a[b]=c};this.allowGlobals=function(){b=!0};this.$get=["$injector","$window",function(d,c){function e(a,
b,c,d){if(!a||!J(a.$scope))throw O("$controller")("noscp",d,b);a.$scope[b]=c}return function(f,g,h,k){var l,m,n;h=!0===h;k&&I(k)&&(n=k);if(I(f)){k=f.match(cd);if(!k)throw bg("ctrlfmt",f);m=k[1];n=n||k[3];f=a.hasOwnProperty(m)?a[m]:Dc(g.$scope,m,!0)||(b?Dc(c,m,!0):void 0);Qa(f,m,!0)}if(h)return h=(K(f)?f[f.length-1]:f).prototype,l=Object.create(h||null),n&&e(g,n,l,m||f.name),P(function(){var a=d.invoke(f,l,g,m);a!==l&&(J(a)||E(a))&&(l=a,n&&e(g,n,l,m||f.name));return l},{instance:l,identifier:n});l=
d.instantiate(f,g,m);n&&e(g,n,l,m||f.name);return l}}]}function gf(){this.$get=["$window",function(a){return G(a.document)}]}function hf(){this.$get=["$log",function(a){return function(b,d){a.error.apply(a,arguments)}}]}function cc(a){return J(a)?ha(a)?a.toISOString():cb(a):a}function nf(){this.$get=function(){return function(a){if(!a)return"";var b=[];sc(a,function(a,c){null===a||y(a)||(K(a)?q(a,function(a){b.push(ia(c)+"="+ia(cc(a)))}):b.push(ia(c)+"="+ia(cc(a))))});return b.join("&")}}}function of(){this.$get=
function(){return function(a){function b(a,e,f){null===a||y(a)||(K(a)?q(a,function(a,c){b(a,e+"["+(J(a)?c:"")+"]")}):J(a)&&!ha(a)?sc(a,function(a,c){b(a,e+(f?"":"[")+c+(f?"":"]"))}):d.push(ia(e)+"="+ia(cc(a))))}if(!a)return"";var d=[];b(a,"",!0);return d.join("&")}}}function dc(a,b){if(I(a)){var d=a.replace(cg,"").trim();if(d){var c=b("Content-Type");(c=c&&0===c.indexOf(dd))||(c=(c=d.match(dg))&&eg[c[0]].test(d));c&&(a=wc(d))}}return a}function ed(a){var b=S(),d;I(a)?q(a.split("\n"),function(a){d=
a.indexOf(":");var e=L(V(a.substr(0,d)));a=V(a.substr(d+1));e&&(b[e]=b[e]?b[e]+", "+a:a)}):J(a)&&q(a,function(a,d){var f=L(d),g=V(a);f&&(b[f]=b[f]?b[f]+", "+g:g)});return b}function fd(a){var b;return function(d){b||(b=ed(a));return d?(d=b[L(d)],void 0===d&&(d=null),d):b}}function gd(a,b,d,c){if(E(c))return c(a,b,d);q(c,function(c){a=c(a,b,d)});return a}function mf(){var a=this.defaults={transformResponse:[dc],transformRequest:[function(a){return J(a)&&"[object File]"!==ja.call(a)&&"[object Blob]"!==
ja.call(a)&&"[object FormData]"!==ja.call(a)?cb(a):a}],headers:{common:{Accept:"application/json, text/plain, */*"},post:fa(ec),put:fa(ec),patch:fa(ec)},xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",paramSerializer:"$httpParamSerializer"},b=!1;this.useApplyAsync=function(a){return v(a)?(b=!!a,this):b};var d=!0;this.useLegacyPromiseExtensions=function(a){return v(a)?(d=!!a,this):d};var c=this.interceptors=[];this.$get=["$httpBackend","$$cookieReader","$cacheFactory","$rootScope","$q","$injector",
function(e,f,g,h,k,l){function m(b){function c(a){var b=P({},a);b.data=gd(a.data,a.headers,a.status,f.transformResponse);a=a.status;return 200<=a&&300>a?b:k.reject(b)}function e(a,b){var c,d={};q(a,function(a,e){E(a)?(c=a(b),null!=c&&(d[e]=c)):d[e]=a});return d}if(!J(b))throw O("$http")("badreq",b);if(!I(b.url))throw O("$http")("badreq",b.url);var f=P({method:"get",transformRequest:a.transformRequest,transformResponse:a.transformResponse,paramSerializer:a.paramSerializer},b);f.headers=function(b){var c=
a.headers,d=P({},b.headers),f,g,h,c=P({},c.common,c[L(b.method)]);a:for(f in c){g=L(f);for(h in d)if(L(h)===g)continue a;d[f]=c[f]}return e(d,fa(b))}(b);f.method=ub(f.method);f.paramSerializer=I(f.paramSerializer)?l.get(f.paramSerializer):f.paramSerializer;var g=[function(b){var d=b.headers,e=gd(b.data,fd(d),void 0,b.transformRequest);y(e)&&q(d,function(a,b){"content-type"===L(b)&&delete d[b]});y(b.withCredentials)&&!y(a.withCredentials)&&(b.withCredentials=a.withCredentials);return n(b,e).then(c,
c)},void 0],h=k.when(f);for(q(U,function(a){(a.request||a.requestError)&&g.unshift(a.request,a.requestError);(a.response||a.responseError)&&g.push(a.response,a.responseError)});g.length;){b=g.shift();var m=g.shift(),h=h.then(b,m)}d?(h.success=function(a){Qa(a,"fn");h.then(function(b){a(b.data,b.status,b.headers,f)});return h},h.error=function(a){Qa(a,"fn");h.then(null,function(b){a(b.data,b.status,b.headers,f)});return h}):(h.success=hd("success"),h.error=hd("error"));return h}function n(c,d){function g(a){if(a){var c=
{};q(a,function(a,d){c[d]=function(c){function d(){a(c)}b?h.$applyAsync(d):h.$$phase?d():h.$apply(d)}});return c}}function l(a,c,d,e){function f(){n(c,a,d,e)}H&&(200<=a&&300>a?H.put(R,[a,c,ed(d),e]):H.remove(R));b?h.$applyAsync(f):(f(),h.$$phase||h.$apply())}function n(a,b,d,e){b=-1<=b?b:0;(200<=b&&300>b?B.resolve:B.reject)({data:a,status:b,headers:fd(d),config:c,statusText:e})}function w(a){n(a.data,a.status,fa(a.headers()),a.statusText)}function U(){var a=m.pendingRequests.indexOf(c);-1!==a&&m.pendingRequests.splice(a,
1)}var B=k.defer(),A=B.promise,H,M,Aa=c.headers,R=p(c.url,c.paramSerializer(c.params));m.pendingRequests.push(c);A.then(U,U);!c.cache&&!a.cache||!1===c.cache||"GET"!==c.method&&"JSONP"!==c.method||(H=J(c.cache)?c.cache:J(a.cache)?a.cache:x);H&&(M=H.get(R),v(M)?M&&E(M.then)?M.then(w,w):K(M)?n(M[1],M[0],fa(M[2]),M[3]):n(M,200,{},"OK"):H.put(R,A));y(M)&&((M=id(c.url)?f()[c.xsrfCookieName||a.xsrfCookieName]:void 0)&&(Aa[c.xsrfHeaderName||a.xsrfHeaderName]=M),e(c.method,R,d,l,Aa,c.timeout,c.withCredentials,
c.responseType,g(c.eventHandlers),g(c.uploadEventHandlers)));return A}function p(a,b){0<b.length&&(a+=(-1==a.indexOf("?")?"?":"&")+b);return a}var x=g("$http");a.paramSerializer=I(a.paramSerializer)?l.get(a.paramSerializer):a.paramSerializer;var U=[];q(c,function(a){U.unshift(I(a)?l.get(a):l.invoke(a))});m.pendingRequests=[];(function(a){q(arguments,function(a){m[a]=function(b,c){return m(P({},c||{},{method:a,url:b}))}})})("get","delete","head","jsonp");(function(a){q(arguments,function(a){m[a]=function(b,
c,d){return m(P({},d||{},{method:a,url:b,data:c}))}})})("post","put","patch");m.defaults=a;return m}]}function qf(){this.$get=function(){return function(){return new F.XMLHttpRequest}}}function pf(){this.$get=["$browser","$window","$document","$xhrFactory",function(a,b,d,c){return fg(a,c,a.defer,b.angular.callbacks,d[0])}]}function fg(a,b,d,c,e){function f(a,b,d){var f=e.createElement("script"),m=null;f.type="text/javascript";f.src=a;f.async=!0;m=function(a){f.removeEventListener("load",m,!1);f.removeEventListener("error",
m,!1);e.body.removeChild(f);f=null;var g=-1,x="unknown";a&&("load"!==a.type||c[b].called||(a={type:"error"}),x=a.type,g="error"===a.type?404:200);d&&d(g,x)};f.addEventListener("load",m,!1);f.addEventListener("error",m,!1);e.body.appendChild(f);return m}return function(e,h,k,l,m,n,p,x,U,z){function r(){t&&t();w&&w.abort()}function D(b,c,e,f,g){v(B)&&d.cancel(B);t=w=null;b(c,e,f,g);a.$$completeOutstandingRequest(C)}a.$$incOutstandingRequestCount();h=h||a.url();if("jsonp"==L(e)){var u="_"+(c.counter++).toString(36);
c[u]=function(a){c[u].data=a;c[u].called=!0};var t=f(h.replace("JSON_CALLBACK","angular.callbacks."+u),u,function(a,b){D(l,a,c[u].data,"",b);c[u]=C})}else{var w=b(e,h);w.open(e,h,!0);q(m,function(a,b){v(a)&&w.setRequestHeader(b,a)});w.onload=function(){var a=w.statusText||"",b="response"in w?w.response:w.responseText,c=1223===w.status?204:w.status;0===c&&(c=b?200:"file"==pa(h).protocol?404:0);D(l,c,b,w.getAllResponseHeaders(),a)};e=function(){D(l,-1,null,null,"")};w.onerror=e;w.onabort=e;q(U,function(a,
b){w.addEventListener(b,a)});q(z,function(a,b){w.upload.addEventListener(b,a)});p&&(w.withCredentials=!0);if(x)try{w.responseType=x}catch(ka){if("json"!==x)throw ka;}w.send(y(k)?null:k)}if(0<n)var B=d(r,n);else n&&E(n.then)&&n.then(r)}}function kf(){var a="{{",b="}}";this.startSymbol=function(b){return b?(a=b,this):a};this.endSymbol=function(a){return a?(b=a,this):b};this.$get=["$parse","$exceptionHandler","$sce",function(d,c,e){function f(a){return"\\\\\\"+a}function g(c){return c.replace(n,a).replace(p,
b)}function h(a,b,c,d){var e;return e=a.$watch(function(a){e();return d(a)},b,c)}function k(f,k,n,p){function D(a){try{var b=a;a=n?e.getTrusted(n,b):e.valueOf(b);var d;if(p&&!v(a))d=a;else if(null==a)d="";else{switch(typeof a){case "string":break;case "number":a=""+a;break;default:a=cb(a)}d=a}return d}catch(g){c(Ka.interr(f,g))}}if(!f.length||-1===f.indexOf(a)){var u;k||(k=g(f),u=ca(k),u.exp=f,u.expressions=[],u.$$watchDelegate=h);return u}p=!!p;var t,w,q=0,B=[],A=[];u=f.length;for(var H=[],M=[];q<
u;)if(-1!=(t=f.indexOf(a,q))&&-1!=(w=f.indexOf(b,t+l)))q!==t&&H.push(g(f.substring(q,t))),q=f.substring(t+l,w),B.push(q),A.push(d(q,D)),q=w+m,M.push(H.length),H.push("");else{q!==u&&H.push(g(f.substring(q)));break}n&&1<H.length&&Ka.throwNoconcat(f);if(!k||B.length){var Aa=function(a){for(var b=0,c=B.length;b<c;b++){if(p&&y(a[b]))return;H[M[b]]=a[b]}return H.join("")};return P(function(a){var b=0,d=B.length,e=Array(d);try{for(;b<d;b++)e[b]=A[b](a);return Aa(e)}catch(g){c(Ka.interr(f,g))}},{exp:f,expressions:B,
$$watchDelegate:function(a,b){var c;return a.$watchGroup(A,function(d,e){var f=Aa(d);E(b)&&b.call(this,f,d!==e?c:f,a);c=f})}})}}var l=a.length,m=b.length,n=new RegExp(a.replace(/./g,f),"g"),p=new RegExp(b.replace(/./g,f),"g");k.startSymbol=function(){return a};k.endSymbol=function(){return b};return k}]}function lf(){this.$get=["$rootScope","$window","$q","$$q","$browser",function(a,b,d,c,e){function f(f,k,l,m){function n(){p?f.apply(null,x):f(r)}var p=4<arguments.length,x=p?ya.call(arguments,4):
[],q=b.setInterval,z=b.clearInterval,r=0,D=v(m)&&!m,u=(D?c:d).defer(),t=u.promise;l=v(l)?l:0;t.$$intervalId=q(function(){D?e.defer(n):a.$evalAsync(n);u.notify(r++);0<l&&r>=l&&(u.resolve(r),z(t.$$intervalId),delete g[t.$$intervalId]);D||a.$apply()},k);g[t.$$intervalId]=u;return t}var g={};f.cancel=function(a){return a&&a.$$intervalId in g?(g[a.$$intervalId].reject("canceled"),b.clearInterval(a.$$intervalId),delete g[a.$$intervalId],!0):!1};return f}]}function fc(a){a=a.split("/");for(var b=a.length;b--;)a[b]=
qb(a[b]);return a.join("/")}function jd(a,b){var d=pa(a);b.$$protocol=d.protocol;b.$$host=d.hostname;b.$$port=$(d.port)||gg[d.protocol]||null}function kd(a,b){var d="/"!==a.charAt(0);d&&(a="/"+a);var c=pa(a);b.$$path=decodeURIComponent(d&&"/"===c.pathname.charAt(0)?c.pathname.substring(1):c.pathname);b.$$search=zc(c.search);b.$$hash=decodeURIComponent(c.hash);b.$$path&&"/"!=b.$$path.charAt(0)&&(b.$$path="/"+b.$$path)}function la(a,b){if(0===b.lastIndexOf(a,0))return b.substr(a.length)}function Ja(a){var b=
a.indexOf("#");return-1==b?a:a.substr(0,b)}function jb(a){return a.replace(/(#.+)|#$/,"$1")}function gc(a,b,d){this.$$html5=!0;d=d||"";jd(a,this);this.$$parse=function(a){var d=la(b,a);if(!I(d))throw Hb("ipthprfx",a,b);kd(d,this);this.$$path||(this.$$path="/");this.$$compose()};this.$$compose=function(){var a=Ub(this.$$search),d=this.$$hash?"#"+qb(this.$$hash):"";this.$$url=fc(this.$$path)+(a?"?"+a:"")+d;this.$$absUrl=b+this.$$url.substr(1)};this.$$parseLinkUrl=function(c,e){if(e&&"#"===e[0])return this.hash(e.slice(1)),
!0;var f,g;v(f=la(a,c))?(g=f,g=v(f=la(d,f))?b+(la("/",f)||f):a+g):v(f=la(b,c))?g=b+f:b==c+"/"&&(g=b);g&&this.$$parse(g);return!!g}}function hc(a,b,d){jd(a,this);this.$$parse=function(c){var e=la(a,c)||la(b,c),f;y(e)||"#"!==e.charAt(0)?this.$$html5?f=e:(f="",y(e)&&(a=c,this.replace())):(f=la(d,e),y(f)&&(f=e));kd(f,this);c=this.$$path;var e=a,g=/^\/[A-Z]:(\/.*)/;0===f.lastIndexOf(e,0)&&(f=f.replace(e,""));g.exec(f)||(c=(f=g.exec(c))?f[1]:c);this.$$path=c;this.$$compose()};this.$$compose=function(){var b=
Ub(this.$$search),e=this.$$hash?"#"+qb(this.$$hash):"";this.$$url=fc(this.$$path)+(b?"?"+b:"")+e;this.$$absUrl=a+(this.$$url?d+this.$$url:"")};this.$$parseLinkUrl=function(b,d){return Ja(a)==Ja(b)?(this.$$parse(b),!0):!1}}function ld(a,b,d){this.$$html5=!0;hc.apply(this,arguments);this.$$parseLinkUrl=function(c,e){if(e&&"#"===e[0])return this.hash(e.slice(1)),!0;var f,g;a==Ja(c)?f=c:(g=la(b,c))?f=a+d+g:b===c+"/"&&(f=b);f&&this.$$parse(f);return!!f};this.$$compose=function(){var b=Ub(this.$$search),
e=this.$$hash?"#"+qb(this.$$hash):"";this.$$url=fc(this.$$path)+(b?"?"+b:"")+e;this.$$absUrl=a+d+this.$$url}}function Ib(a){return function(){return this[a]}}function md(a,b){return function(d){if(y(d))return this[a];this[a]=b(d);this.$$compose();return this}}function rf(){var a="",b={enabled:!1,requireBase:!0,rewriteLinks:!0};this.hashPrefix=function(b){return v(b)?(a=b,this):a};this.html5Mode=function(a){return Ea(a)?(b.enabled=a,this):J(a)?(Ea(a.enabled)&&(b.enabled=a.enabled),Ea(a.requireBase)&&
(b.requireBase=a.requireBase),Ea(a.rewriteLinks)&&(b.rewriteLinks=a.rewriteLinks),this):b};this.$get=["$rootScope","$browser","$sniffer","$rootElement","$window",function(d,c,e,f,g){function h(a,b,d){var e=l.url(),f=l.$$state;try{c.url(a,b,d),l.$$state=c.state()}catch(g){throw l.url(e),l.$$state=f,g;}}function k(a,b){d.$broadcast("$locationChangeSuccess",l.absUrl(),a,l.$$state,b)}var l,m;m=c.baseHref();var n=c.url(),p;if(b.enabled){if(!m&&b.requireBase)throw Hb("nobase");p=n.substring(0,n.indexOf("/",
n.indexOf("//")+2))+(m||"/");m=e.history?gc:ld}else p=Ja(n),m=hc;var x=p.substr(0,Ja(p).lastIndexOf("/")+1);l=new m(p,x,"#"+a);l.$$parseLinkUrl(n,n);l.$$state=c.state();var q=/^\s*(javascript|mailto):/i;f.on("click",function(a){if(b.rewriteLinks&&!a.ctrlKey&&!a.metaKey&&!a.shiftKey&&2!=a.which&&2!=a.button){for(var e=G(a.target);"a"!==ta(e[0]);)if(e[0]===f[0]||!(e=e.parent())[0])return;var h=e.prop("href"),k=e.attr("href")||e.attr("xlink:href");J(h)&&"[object SVGAnimatedString]"===h.toString()&&(h=
pa(h.animVal).href);q.test(h)||!h||e.attr("target")||a.isDefaultPrevented()||!l.$$parseLinkUrl(h,k)||(a.preventDefault(),l.absUrl()!=c.url()&&(d.$apply(),g.angular["ff-684208-preventDefault"]=!0))}});jb(l.absUrl())!=jb(n)&&c.url(l.absUrl(),!0);var z=!0;c.onUrlChange(function(a,b){y(la(x,a))?g.location.href=a:(d.$evalAsync(function(){var c=l.absUrl(),e=l.$$state,f;a=jb(a);l.$$parse(a);l.$$state=b;f=d.$broadcast("$locationChangeStart",a,c,b,e).defaultPrevented;l.absUrl()===a&&(f?(l.$$parse(c),l.$$state=
e,h(c,!1,e)):(z=!1,k(c,e)))}),d.$$phase||d.$digest())});d.$watch(function(){var a=jb(c.url()),b=jb(l.absUrl()),f=c.state(),g=l.$$replace,m=a!==b||l.$$html5&&e.history&&f!==l.$$state;if(z||m)z=!1,d.$evalAsync(function(){var b=l.absUrl(),c=d.$broadcast("$locationChangeStart",b,a,l.$$state,f).defaultPrevented;l.absUrl()===b&&(c?(l.$$parse(a),l.$$state=f):(m&&h(b,g,f===l.$$state?null:l.$$state),k(a,f)))});l.$$replace=!1});return l}]}function sf(){var a=!0,b=this;this.debugEnabled=function(b){return v(b)?
(a=b,this):a};this.$get=["$window",function(d){function c(a){a instanceof Error&&(a.stack?a=a.message&&-1===a.stack.indexOf(a.message)?"Error: "+a.message+"\n"+a.stack:a.stack:a.sourceURL&&(a=a.message+"\n"+a.sourceURL+":"+a.line));return a}function e(a){var b=d.console||{},e=b[a]||b.log||C;a=!1;try{a=!!e.apply}catch(k){}return a?function(){var a=[];q(arguments,function(b){a.push(c(b))});return e.apply(b,a)}:function(a,b){e(a,null==b?"":b)}}return{log:e("log"),info:e("info"),warn:e("warn"),error:e("error"),
debug:function(){var c=e("debug");return function(){a&&c.apply(b,arguments)}}()}}]}function Ua(a,b){if("__defineGetter__"===a||"__defineSetter__"===a||"__lookupGetter__"===a||"__lookupSetter__"===a||"__proto__"===a)throw ba("isecfld",b);return a}function hg(a){return a+""}function qa(a,b){if(a){if(a.constructor===a)throw ba("isecfn",b);if(a.window===a)throw ba("isecwindow",b);if(a.children&&(a.nodeName||a.prop&&a.attr&&a.find))throw ba("isecdom",b);if(a===Object)throw ba("isecobj",b);}return a}function nd(a,
b){if(a){if(a.constructor===a)throw ba("isecfn",b);if(a===ig||a===jg||a===kg)throw ba("isecff",b);}}function Jb(a,b){if(a&&(a===(0).constructor||a===(!1).constructor||a==="".constructor||a==={}.constructor||a===[].constructor||a===Function.constructor))throw ba("isecaf",b);}function lg(a,b){return"undefined"!==typeof a?a:b}function od(a,b){return"undefined"===typeof a?b:"undefined"===typeof b?a:a+b}function Z(a,b){var d,c;switch(a.type){case s.Program:d=!0;q(a.body,function(a){Z(a.expression,b);d=
d&&a.expression.constant});a.constant=d;break;case s.Literal:a.constant=!0;a.toWatch=[];break;case s.UnaryExpression:Z(a.argument,b);a.constant=a.argument.constant;a.toWatch=a.argument.toWatch;break;case s.BinaryExpression:Z(a.left,b);Z(a.right,b);a.constant=a.left.constant&&a.right.constant;a.toWatch=a.left.toWatch.concat(a.right.toWatch);break;case s.LogicalExpression:Z(a.left,b);Z(a.right,b);a.constant=a.left.constant&&a.right.constant;a.toWatch=a.constant?[]:[a];break;case s.ConditionalExpression:Z(a.test,
b);Z(a.alternate,b);Z(a.consequent,b);a.constant=a.test.constant&&a.alternate.constant&&a.consequent.constant;a.toWatch=a.constant?[]:[a];break;case s.Identifier:a.constant=!1;a.toWatch=[a];break;case s.MemberExpression:Z(a.object,b);a.computed&&Z(a.property,b);a.constant=a.object.constant&&(!a.computed||a.property.constant);a.toWatch=[a];break;case s.CallExpression:d=a.filter?!b(a.callee.name).$stateful:!1;c=[];q(a.arguments,function(a){Z(a,b);d=d&&a.constant;a.constant||c.push.apply(c,a.toWatch)});
a.constant=d;a.toWatch=a.filter&&!b(a.callee.name).$stateful?c:[a];break;case s.AssignmentExpression:Z(a.left,b);Z(a.right,b);a.constant=a.left.constant&&a.right.constant;a.toWatch=[a];break;case s.ArrayExpression:d=!0;c=[];q(a.elements,function(a){Z(a,b);d=d&&a.constant;a.constant||c.push.apply(c,a.toWatch)});a.constant=d;a.toWatch=c;break;case s.ObjectExpression:d=!0;c=[];q(a.properties,function(a){Z(a.value,b);d=d&&a.value.constant&&!a.computed;a.value.constant||c.push.apply(c,a.value.toWatch)});
a.constant=d;a.toWatch=c;break;case s.ThisExpression:a.constant=!1;a.toWatch=[];break;case s.LocalsExpression:a.constant=!1,a.toWatch=[]}}function pd(a){if(1==a.length){a=a[0].expression;var b=a.toWatch;return 1!==b.length?b:b[0]!==a?b:void 0}}function qd(a){return a.type===s.Identifier||a.type===s.MemberExpression}function rd(a){if(1===a.body.length&&qd(a.body[0].expression))return{type:s.AssignmentExpression,left:a.body[0].expression,right:{type:s.NGValueParameter},operator:"="}}function sd(a){return 0===
a.body.length||1===a.body.length&&(a.body[0].expression.type===s.Literal||a.body[0].expression.type===s.ArrayExpression||a.body[0].expression.type===s.ObjectExpression)}function td(a,b){this.astBuilder=a;this.$filter=b}function ud(a,b){this.astBuilder=a;this.$filter=b}function Kb(a){return"constructor"==a}function ic(a){return E(a.valueOf)?a.valueOf():mg.call(a)}function tf(){var a=S(),b=S(),d={"true":!0,"false":!1,"null":null,undefined:void 0},c,e;this.addLiteral=function(a,b){d[a]=b};this.setIdentifierFns=
function(a,b){c=a;e=b;return this};this.$get=["$filter",function(f){function g(c,d,e){var g,k,A;e=e||D;switch(typeof c){case "string":A=c=c.trim();var H=e?b:a;g=H[A];if(!g){":"===c.charAt(0)&&":"===c.charAt(1)&&(k=!0,c=c.substring(2));g=e?r:z;var q=new jc(g);g=(new kc(q,f,g)).parse(c);g.constant?g.$$watchDelegate=p:k?g.$$watchDelegate=g.literal?n:m:g.inputs&&(g.$$watchDelegate=l);e&&(g=h(g));H[A]=g}return x(g,d);case "function":return x(c,d);default:return x(C,d)}}function h(a){function b(c,d,e,f){var g=
D;D=!0;try{return a(c,d,e,f)}finally{D=g}}if(!a)return a;b.$$watchDelegate=a.$$watchDelegate;b.assign=h(a.assign);b.constant=a.constant;b.literal=a.literal;for(var c=0;a.inputs&&c<a.inputs.length;++c)a.inputs[c]=h(a.inputs[c]);b.inputs=a.inputs;return b}function k(a,b){return null==a||null==b?a===b:"object"===typeof a&&(a=ic(a),"object"===typeof a)?!1:a===b||a!==a&&b!==b}function l(a,b,c,d,e){var f=d.inputs,g;if(1===f.length){var h=k,f=f[0];return a.$watch(function(a){var b=f(a);k(b,h)||(g=d(a,void 0,
void 0,[b]),h=b&&ic(b));return g},b,c,e)}for(var l=[],m=[],n=0,p=f.length;n<p;n++)l[n]=k,m[n]=null;return a.$watch(function(a){for(var b=!1,c=0,e=f.length;c<e;c++){var h=f[c](a);if(b||(b=!k(h,l[c])))m[c]=h,l[c]=h&&ic(h)}b&&(g=d(a,void 0,void 0,m));return g},b,c,e)}function m(a,b,c,d){var e,f;return e=a.$watch(function(a){return d(a)},function(a,c,d){f=a;E(b)&&b.apply(this,arguments);v(a)&&d.$$postDigest(function(){v(f)&&e()})},c)}function n(a,b,c,d){function e(a){var b=!0;q(a,function(a){v(a)||(b=
!1)});return b}var f,g;return f=a.$watch(function(a){return d(a)},function(a,c,d){g=a;E(b)&&b.call(this,a,c,d);e(a)&&d.$$postDigest(function(){e(g)&&f()})},c)}function p(a,b,c,d){var e;return e=a.$watch(function(a){e();return d(a)},b,c)}function x(a,b){if(!b)return a;var c=a.$$watchDelegate,d=!1,c=c!==n&&c!==m?function(c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return b(f,c,e)}:function(c,d,e,f){e=a(c,d,e,f);c=b(e,c,d);return v(e)?c:e};a.$$watchDelegate&&a.$$watchDelegate!==l?c.$$watchDelegate=a.$$watchDelegate:
b.$stateful||(c.$$watchDelegate=l,d=!a.inputs,c.inputs=a.inputs?a.inputs:[a]);return c}var U=Fa().noUnsafeEval,z={csp:U,expensiveChecks:!1,literals:oa(d),isIdentifierStart:E(c)&&c,isIdentifierContinue:E(e)&&e},r={csp:U,expensiveChecks:!0,literals:oa(d),isIdentifierStart:E(c)&&c,isIdentifierContinue:E(e)&&e},D=!1;g.$$runningExpensiveChecks=function(){return D};return g}]}function vf(){this.$get=["$rootScope","$exceptionHandler",function(a,b){return vd(function(b){a.$evalAsync(b)},b)}]}function wf(){this.$get=
["$browser","$exceptionHandler",function(a,b){return vd(function(b){a.defer(b)},b)}]}function vd(a,b){function d(){this.$$state={status:0}}function c(a,b){return function(c){b.call(a,c)}}function e(c){!c.processScheduled&&c.pending&&(c.processScheduled=!0,a(function(){var a,d,e;e=c.pending;c.processScheduled=!1;c.pending=void 0;for(var f=0,g=e.length;f<g;++f){d=e[f][0];a=e[f][c.status];try{E(a)?d.resolve(a(c.value)):1===c.status?d.resolve(c.value):d.reject(c.value)}catch(h){d.reject(h),b(h)}}}))}
function f(){this.promise=new d}var g=O("$q",TypeError);P(d.prototype,{then:function(a,b,c){if(y(a)&&y(b)&&y(c))return this;var d=new f;this.$$state.pending=this.$$state.pending||[];this.$$state.pending.push([d,a,b,c]);0<this.$$state.status&&e(this.$$state);return d.promise},"catch":function(a){return this.then(null,a)},"finally":function(a,b){return this.then(function(b){return k(b,!0,a)},function(b){return k(b,!1,a)},b)}});P(f.prototype,{resolve:function(a){this.promise.$$state.status||(a===this.promise?
this.$$reject(g("qcycle",a)):this.$$resolve(a))},$$resolve:function(a){function d(a){k||(k=!0,h.$$resolve(a))}function f(a){k||(k=!0,h.$$reject(a))}var g,h=this,k=!1;try{if(J(a)||E(a))g=a&&a.then;E(g)?(this.promise.$$state.status=-1,g.call(a,d,f,c(this,this.notify))):(this.promise.$$state.value=a,this.promise.$$state.status=1,e(this.promise.$$state))}catch(l){f(l),b(l)}},reject:function(a){this.promise.$$state.status||this.$$reject(a)},$$reject:function(a){this.promise.$$state.value=a;this.promise.$$state.status=
2;e(this.promise.$$state)},notify:function(c){var d=this.promise.$$state.pending;0>=this.promise.$$state.status&&d&&d.length&&a(function(){for(var a,e,f=0,g=d.length;f<g;f++){e=d[f][0];a=d[f][3];try{e.notify(E(a)?a(c):c)}catch(h){b(h)}}})}});var h=function(a,b){var c=new f;b?c.resolve(a):c.reject(a);return c.promise},k=function(a,b,c){var d=null;try{E(c)&&(d=c())}catch(e){return h(e,!1)}return d&&E(d.then)?d.then(function(){return h(a,b)},function(a){return h(a,!1)}):h(a,b)},l=function(a,b,c,d){var e=
new f;e.resolve(a);return e.promise.then(b,c,d)},m=function(a){if(!E(a))throw g("norslvr",a);var b=new f;a(function(a){b.resolve(a)},function(a){b.reject(a)});return b.promise};m.prototype=d.prototype;m.defer=function(){var a=new f;a.resolve=c(a,a.resolve);a.reject=c(a,a.reject);a.notify=c(a,a.notify);return a};m.reject=function(a){var b=new f;b.reject(a);return b.promise};m.when=l;m.resolve=l;m.all=function(a){var b=new f,c=0,d=K(a)?[]:{};q(a,function(a,e){c++;l(a).then(function(a){d.hasOwnProperty(e)||
(d[e]=a,--c||b.resolve(d))},function(a){d.hasOwnProperty(e)||b.reject(a)})});0===c&&b.resolve(d);return b.promise};return m}function Ff(){this.$get=["$window","$timeout",function(a,b){var d=a.requestAnimationFrame||a.webkitRequestAnimationFrame,c=a.cancelAnimationFrame||a.webkitCancelAnimationFrame||a.webkitCancelRequestAnimationFrame,e=!!d,f=e?function(a){var b=d(a);return function(){c(b)}}:function(a){var c=b(a,16.66,!1);return function(){b.cancel(c)}};f.supported=e;return f}]}function uf(){function a(a){function b(){this.$$watchers=
this.$$nextSibling=this.$$childHead=this.$$childTail=null;this.$$listeners={};this.$$listenerCount={};this.$$watchersCount=0;this.$id=++pb;this.$$ChildScope=null}b.prototype=a;return b}var b=10,d=O("$rootScope"),c=null,e=null;this.digestTtl=function(a){arguments.length&&(b=a);return b};this.$get=["$exceptionHandler","$parse","$browser",function(f,g,h){function k(a){a.currentScope.$$destroyed=!0}function l(a){9===Ba&&(a.$$childHead&&l(a.$$childHead),a.$$nextSibling&&l(a.$$nextSibling));a.$parent=a.$$nextSibling=
a.$$prevSibling=a.$$childHead=a.$$childTail=a.$root=a.$$watchers=null}function m(){this.$id=++pb;this.$$phase=this.$parent=this.$$watchers=this.$$nextSibling=this.$$prevSibling=this.$$childHead=this.$$childTail=null;this.$root=this;this.$$destroyed=!1;this.$$listeners={};this.$$listenerCount={};this.$$watchersCount=0;this.$$isolateBindings=null}function n(a){if(D.$$phase)throw d("inprog",D.$$phase);D.$$phase=a}function p(a,b){do a.$$watchersCount+=b;while(a=a.$parent)}function x(a,b,c){do a.$$listenerCount[c]-=
b,0===a.$$listenerCount[c]&&delete a.$$listenerCount[c];while(a=a.$parent)}function s(){}function z(){for(;w.length;)try{w.shift()()}catch(a){f(a)}e=null}function r(){null===e&&(e=h.defer(function(){D.$apply(z)}))}m.prototype={constructor:m,$new:function(b,c){var d;c=c||this;b?(d=new m,d.$root=this.$root):(this.$$ChildScope||(this.$$ChildScope=a(this)),d=new this.$$ChildScope);d.$parent=c;d.$$prevSibling=c.$$childTail;c.$$childHead?(c.$$childTail.$$nextSibling=d,c.$$childTail=d):c.$$childHead=c.$$childTail=
d;(b||c!=this)&&d.$on("$destroy",k);return d},$watch:function(a,b,d,e){var f=g(a);if(f.$$watchDelegate)return f.$$watchDelegate(this,b,d,f,a);var h=this,k=h.$$watchers,l={fn:b,last:s,get:f,exp:e||a,eq:!!d};c=null;E(b)||(l.fn=C);k||(k=h.$$watchers=[]);k.unshift(l);p(this,1);return function(){0<=$a(k,l)&&p(h,-1);c=null}},$watchGroup:function(a,b){function c(){h=!1;k?(k=!1,b(e,e,g)):b(e,d,g)}var d=Array(a.length),e=Array(a.length),f=[],g=this,h=!1,k=!0;if(!a.length){var l=!0;g.$evalAsync(function(){l&&
b(e,e,g)});return function(){l=!1}}if(1===a.length)return this.$watch(a[0],function(a,c,f){e[0]=a;d[0]=c;b(e,a===c?e:d,f)});q(a,function(a,b){var k=g.$watch(a,function(a,f){e[b]=a;d[b]=f;h||(h=!0,g.$evalAsync(c))});f.push(k)});return function(){for(;f.length;)f.shift()()}},$watchCollection:function(a,b){function c(a){e=a;var b,d,g,h;if(!y(e)){if(J(e))if(xa(e))for(f!==n&&(f=n,u=f.length=0,l++),a=e.length,u!==a&&(l++,f.length=u=a),b=0;b<a;b++)h=f[b],g=e[b],d=h!==h&&g!==g,d||h===g||(l++,f[b]=g);else{f!==
p&&(f=p={},u=0,l++);a=0;for(b in e)sa.call(e,b)&&(a++,g=e[b],h=f[b],b in f?(d=h!==h&&g!==g,d||h===g||(l++,f[b]=g)):(u++,f[b]=g,l++));if(u>a)for(b in l++,f)sa.call(e,b)||(u--,delete f[b])}else f!==e&&(f=e,l++);return l}}c.$stateful=!0;var d=this,e,f,h,k=1<b.length,l=0,m=g(a,c),n=[],p={},r=!0,u=0;return this.$watch(m,function(){r?(r=!1,b(e,e,d)):b(e,h,d);if(k)if(J(e))if(xa(e)){h=Array(e.length);for(var a=0;a<e.length;a++)h[a]=e[a]}else for(a in h={},e)sa.call(e,a)&&(h[a]=e[a]);else h=e})},$digest:function(){var a,
g,k,l,m,p,r,x,q=b,w,y=[],C,F;n("$digest");h.$$checkUrlChange();this===D&&null!==e&&(h.defer.cancel(e),z());c=null;do{x=!1;w=this;for(p=0;p<u.length;p++){try{F=u[p],F.scope.$eval(F.expression,F.locals)}catch(G){f(G)}c=null}u.length=0;a:do{if(p=w.$$watchers)for(r=p.length;r--;)try{if(a=p[r])if(m=a.get,(g=m(w))!==(k=a.last)&&!(a.eq?na(g,k):"number"===typeof g&&"number"===typeof k&&isNaN(g)&&isNaN(k)))x=!0,c=a,a.last=a.eq?oa(g,null):g,l=a.fn,l(g,k===s?g:k,w),5>q&&(C=4-q,y[C]||(y[C]=[]),y[C].push({msg:E(a.exp)?
"fn: "+(a.exp.name||a.exp.toString()):a.exp,newVal:g,oldVal:k}));else if(a===c){x=!1;break a}}catch(I){f(I)}if(!(p=w.$$watchersCount&&w.$$childHead||w!==this&&w.$$nextSibling))for(;w!==this&&!(p=w.$$nextSibling);)w=w.$parent}while(w=p);if((x||u.length)&&!q--)throw D.$$phase=null,d("infdig",b,y);}while(x||u.length);for(D.$$phase=null;v<t.length;)try{t[v++]()}catch(J){f(J)}t.length=v=0},$destroy:function(){if(!this.$$destroyed){var a=this.$parent;this.$broadcast("$destroy");this.$$destroyed=!0;this===
D&&h.$$applicationDestroyed();p(this,-this.$$watchersCount);for(var b in this.$$listenerCount)x(this,this.$$listenerCount[b],b);a&&a.$$childHead==this&&(a.$$childHead=this.$$nextSibling);a&&a.$$childTail==this&&(a.$$childTail=this.$$prevSibling);this.$$prevSibling&&(this.$$prevSibling.$$nextSibling=this.$$nextSibling);this.$$nextSibling&&(this.$$nextSibling.$$prevSibling=this.$$prevSibling);this.$destroy=this.$digest=this.$apply=this.$evalAsync=this.$applyAsync=C;this.$on=this.$watch=this.$watchGroup=
function(){return C};this.$$listeners={};this.$$nextSibling=null;l(this)}},$eval:function(a,b){return g(a)(this,b)},$evalAsync:function(a,b){D.$$phase||u.length||h.defer(function(){u.length&&D.$digest()});u.push({scope:this,expression:g(a),locals:b})},$$postDigest:function(a){t.push(a)},$apply:function(a){try{n("$apply");try{return this.$eval(a)}finally{D.$$phase=null}}catch(b){f(b)}finally{try{D.$digest()}catch(c){throw f(c),c;}}},$applyAsync:function(a){function b(){c.$eval(a)}var c=this;a&&w.push(b);
a=g(a);r()},$on:function(a,b){var c=this.$$listeners[a];c||(this.$$listeners[a]=c=[]);c.push(b);var d=this;do d.$$listenerCount[a]||(d.$$listenerCount[a]=0),d.$$listenerCount[a]++;while(d=d.$parent);var e=this;return function(){var d=c.indexOf(b);-1!==d&&(c[d]=null,x(e,1,a))}},$emit:function(a,b){var c=[],d,e=this,g=!1,h={name:a,targetScope:e,stopPropagation:function(){g=!0},preventDefault:function(){h.defaultPrevented=!0},defaultPrevented:!1},k=ab([h],arguments,1),l,m;do{d=e.$$listeners[a]||c;h.currentScope=
e;l=0;for(m=d.length;l<m;l++)if(d[l])try{d[l].apply(null,k)}catch(n){f(n)}else d.splice(l,1),l--,m--;if(g)return h.currentScope=null,h;e=e.$parent}while(e);h.currentScope=null;return h},$broadcast:function(a,b){var c=this,d=this,e={name:a,targetScope:this,preventDefault:function(){e.defaultPrevented=!0},defaultPrevented:!1};if(!this.$$listenerCount[a])return e;for(var g=ab([e],arguments,1),h,k;c=d;){e.currentScope=c;d=c.$$listeners[a]||[];h=0;for(k=d.length;h<k;h++)if(d[h])try{d[h].apply(null,g)}catch(l){f(l)}else d.splice(h,
1),h--,k--;if(!(d=c.$$listenerCount[a]&&c.$$childHead||c!==this&&c.$$nextSibling))for(;c!==this&&!(d=c.$$nextSibling);)c=c.$parent}e.currentScope=null;return e}};var D=new m,u=D.$$asyncQueue=[],t=D.$$postDigestQueue=[],w=D.$$applyAsyncQueue=[],v=0;return D}]}function ne(){var a=/^\s*(https?|ftp|mailto|tel|file):/,b=/^\s*((https?|ftp|file|blob):|data:image\/)/;this.aHrefSanitizationWhitelist=function(b){return v(b)?(a=b,this):a};this.imgSrcSanitizationWhitelist=function(a){return v(a)?(b=a,this):b};
this.$get=function(){return function(d,c){var e=c?b:a,f;f=pa(d).href;return""===f||f.match(e)?d:"unsafe:"+f}}}function ng(a){if("self"===a)return a;if(I(a)){if(-1<a.indexOf("***"))throw ra("iwcard",a);a=wd(a).replace("\\*\\*",".*").replace("\\*","[^:/.?&;]*");return new RegExp("^"+a+"$")}if(Xa(a))return new RegExp("^"+a.source+"$");throw ra("imatcher");}function xd(a){var b=[];v(a)&&q(a,function(a){b.push(ng(a))});return b}function yf(){this.SCE_CONTEXTS=ma;var a=["self"],b=[];this.resourceUrlWhitelist=
function(b){arguments.length&&(a=xd(b));return a};this.resourceUrlBlacklist=function(a){arguments.length&&(b=xd(a));return b};this.$get=["$injector",function(d){function c(a,b){return"self"===a?id(b):!!a.exec(b.href)}function e(a){var b=function(a){this.$$unwrapTrustedValue=function(){return a}};a&&(b.prototype=new a);b.prototype.valueOf=function(){return this.$$unwrapTrustedValue()};b.prototype.toString=function(){return this.$$unwrapTrustedValue().toString()};return b}var f=function(a){throw ra("unsafe");
};d.has("$sanitize")&&(f=d.get("$sanitize"));var g=e(),h={};h[ma.HTML]=e(g);h[ma.CSS]=e(g);h[ma.URL]=e(g);h[ma.JS]=e(g);h[ma.RESOURCE_URL]=e(h[ma.URL]);return{trustAs:function(a,b){var c=h.hasOwnProperty(a)?h[a]:null;if(!c)throw ra("icontext",a,b);if(null===b||y(b)||""===b)return b;if("string"!==typeof b)throw ra("itype",a);return new c(b)},getTrusted:function(d,e){if(null===e||y(e)||""===e)return e;var g=h.hasOwnProperty(d)?h[d]:null;if(g&&e instanceof g)return e.$$unwrapTrustedValue();if(d===ma.RESOURCE_URL){var g=
pa(e.toString()),n,p,x=!1;n=0;for(p=a.length;n<p;n++)if(c(a[n],g)){x=!0;break}if(x)for(n=0,p=b.length;n<p;n++)if(c(b[n],g)){x=!1;break}if(x)return e;throw ra("insecurl",e.toString());}if(d===ma.HTML)return f(e);throw ra("unsafe");},valueOf:function(a){return a instanceof g?a.$$unwrapTrustedValue():a}}}]}function xf(){var a=!0;this.enabled=function(b){arguments.length&&(a=!!b);return a};this.$get=["$parse","$sceDelegate",function(b,d){if(a&&8>Ba)throw ra("iequirks");var c=fa(ma);c.isEnabled=function(){return a};
c.trustAs=d.trustAs;c.getTrusted=d.getTrusted;c.valueOf=d.valueOf;a||(c.trustAs=c.getTrusted=function(a,b){return b},c.valueOf=Ya);c.parseAs=function(a,d){var e=b(d);return e.literal&&e.constant?e:b(d,function(b){return c.getTrusted(a,b)})};var e=c.parseAs,f=c.getTrusted,g=c.trustAs;q(ma,function(a,b){var d=L(b);c[eb("parse_as_"+d)]=function(b){return e(a,b)};c[eb("get_trusted_"+d)]=function(b){return f(a,b)};c[eb("trust_as_"+d)]=function(b){return g(a,b)}});return c}]}function zf(){this.$get=["$window",
"$document",function(a,b){var d={},c=!(a.chrome&&a.chrome.app&&a.chrome.app.runtime)&&a.history&&a.history.pushState,e=$((/android (\d+)/.exec(L((a.navigator||{}).userAgent))||[])[1]),f=/Boxee/i.test((a.navigator||{}).userAgent),g=b[0]||{},h,k=/^(Moz|webkit|ms)(?=[A-Z])/,l=g.body&&g.body.style,m=!1,n=!1;if(l){for(var p in l)if(m=k.exec(p)){h=m[0];h=h[0].toUpperCase()+h.substr(1);break}h||(h="WebkitOpacity"in l&&"webkit");m=!!("transition"in l||h+"Transition"in l);n=!!("animation"in l||h+"Animation"in
l);!e||m&&n||(m=I(l.webkitTransition),n=I(l.webkitAnimation))}return{history:!(!c||4>e||f),hasEvent:function(a){if("input"===a&&11>=Ba)return!1;if(y(d[a])){var b=g.createElement("div");d[a]="on"+a in b}return d[a]},csp:Fa(),vendorPrefix:h,transitions:m,animations:n,android:e}}]}function Bf(){var a;this.httpOptions=function(b){return b?(a=b,this):a};this.$get=["$templateCache","$http","$q","$sce",function(b,d,c,e){function f(g,h){f.totalPendingRequests++;if(!I(g)||y(b.get(g)))g=e.getTrustedResourceUrl(g);
var k=d.defaults&&d.defaults.transformResponse;K(k)?k=k.filter(function(a){return a!==dc}):k===dc&&(k=null);return d.get(g,P({cache:b,transformResponse:k},a))["finally"](function(){f.totalPendingRequests--}).then(function(a){b.put(g,a.data);return a.data},function(a){if(!h)throw og("tpload",g,a.status,a.statusText);return c.reject(a)})}f.totalPendingRequests=0;return f}]}function Cf(){this.$get=["$rootScope","$browser","$location",function(a,b,d){return{findBindings:function(a,b,d){a=a.getElementsByClassName("ng-binding");
var g=[];q(a,function(a){var c=da.element(a).data("$binding");c&&q(c,function(c){d?(new RegExp("(^|\\s)"+wd(b)+"(\\s|\\||$)")).test(c)&&g.push(a):-1!=c.indexOf(b)&&g.push(a)})});return g},findModels:function(a,b,d){for(var g=["ng-","data-ng-","ng\\:"],h=0;h<g.length;++h){var k=a.querySelectorAll("["+g[h]+"model"+(d?"=":"*=")+'"'+b+'"]');if(k.length)return k}},getLocation:function(){return d.url()},setLocation:function(b){b!==d.url()&&(d.url(b),a.$digest())},whenStable:function(a){b.notifyWhenNoOutstandingRequests(a)}}}]}
function Df(){this.$get=["$rootScope","$browser","$q","$$q","$exceptionHandler",function(a,b,d,c,e){function f(f,k,l){E(f)||(l=k,k=f,f=C);var m=ya.call(arguments,3),n=v(l)&&!l,p=(n?c:d).defer(),x=p.promise,q;q=b.defer(function(){try{p.resolve(f.apply(null,m))}catch(b){p.reject(b),e(b)}finally{delete g[x.$$timeoutId]}n||a.$apply()},k);x.$$timeoutId=q;g[q]=p;return x}var g={};f.cancel=function(a){return a&&a.$$timeoutId in g?(g[a.$$timeoutId].reject("canceled"),delete g[a.$$timeoutId],b.defer.cancel(a.$$timeoutId)):
!1};return f}]}function pa(a){Ba&&(X.setAttribute("href",a),a=X.href);X.setAttribute("href",a);return{href:X.href,protocol:X.protocol?X.protocol.replace(/:$/,""):"",host:X.host,search:X.search?X.search.replace(/^\?/,""):"",hash:X.hash?X.hash.replace(/^#/,""):"",hostname:X.hostname,port:X.port,pathname:"/"===X.pathname.charAt(0)?X.pathname:"/"+X.pathname}}function id(a){a=I(a)?pa(a):a;return a.protocol===yd.protocol&&a.host===yd.host}function Ef(){this.$get=ca(F)}function zd(a){function b(a){try{return decodeURIComponent(a)}catch(b){return a}}
var d=a[0]||{},c={},e="";return function(){var a,g,h,k,l;a=d.cookie||"";if(a!==e)for(e=a,a=e.split("; "),c={},h=0;h<a.length;h++)g=a[h],k=g.indexOf("="),0<k&&(l=b(g.substring(0,k)),y(c[l])&&(c[l]=b(g.substring(k+1))));return c}}function If(){this.$get=zd}function Lc(a){function b(d,c){if(J(d)){var e={};q(d,function(a,c){e[c]=b(c,a)});return e}return a.factory(d+"Filter",c)}this.register=b;this.$get=["$injector",function(a){return function(b){return a.get(b+"Filter")}}];b("currency",Ad);b("date",Bd);
b("filter",pg);b("json",qg);b("limitTo",rg);b("lowercase",sg);b("number",Cd);b("orderBy",Dd);b("uppercase",tg)}function pg(){return function(a,b,d){if(!xa(a)){if(null==a)return a;throw O("filter")("notarray",a);}var c;switch(lc(b)){case "function":break;case "boolean":case "null":case "number":case "string":c=!0;case "object":b=ug(b,d,c);break;default:return a}return Array.prototype.filter.call(a,b)}}function ug(a,b,d){var c=J(a)&&"$"in a;!0===b?b=na:E(b)||(b=function(a,b){if(y(a))return!1;if(null===
a||null===b)return a===b;if(J(b)||J(a)&&!uc(a))return!1;a=L(""+a);b=L(""+b);return-1!==a.indexOf(b)});return function(e){return c&&!J(e)?La(e,a.$,b,!1):La(e,a,b,d)}}function La(a,b,d,c,e){var f=lc(a),g=lc(b);if("string"===g&&"!"===b.charAt(0))return!La(a,b.substring(1),d,c);if(K(a))return a.some(function(a){return La(a,b,d,c)});switch(f){case "object":var h;if(c){for(h in a)if("$"!==h.charAt(0)&&La(a[h],b,d,!0))return!0;return e?!1:La(a,b,d,!1)}if("object"===g){for(h in b)if(e=b[h],!E(e)&&!y(e)&&
(f="$"===h,!La(f?a:a[h],e,d,f,f)))return!1;return!0}return d(a,b);case "function":return!1;default:return d(a,b)}}function lc(a){return null===a?"null":typeof a}function Ad(a){var b=a.NUMBER_FORMATS;return function(a,c,e){y(c)&&(c=b.CURRENCY_SYM);y(e)&&(e=b.PATTERNS[1].maxFrac);return null==a?a:Ed(a,b.PATTERNS[1],b.GROUP_SEP,b.DECIMAL_SEP,e).replace(/\u00A4/g,c)}}function Cd(a){var b=a.NUMBER_FORMATS;return function(a,c){return null==a?a:Ed(a,b.PATTERNS[0],b.GROUP_SEP,b.DECIMAL_SEP,c)}}function vg(a){var b=
0,d,c,e,f,g;-1<(c=a.indexOf(Fd))&&(a=a.replace(Fd,""));0<(e=a.search(/e/i))?(0>c&&(c=e),c+=+a.slice(e+1),a=a.substring(0,e)):0>c&&(c=a.length);for(e=0;a.charAt(e)==mc;e++);if(e==(g=a.length))d=[0],c=1;else{for(g--;a.charAt(g)==mc;)g--;c-=e;d=[];for(f=0;e<=g;e++,f++)d[f]=+a.charAt(e)}c>Gd&&(d=d.splice(0,Gd-1),b=c-1,c=1);return{d:d,e:b,i:c}}function wg(a,b,d,c){var e=a.d,f=e.length-a.i;b=y(b)?Math.min(Math.max(d,f),c):+b;d=b+a.i;c=e[d];if(0<d){e.splice(Math.max(a.i,d));for(var g=d;g<e.length;g++)e[g]=
0}else for(f=Math.max(0,f),a.i=1,e.length=Math.max(1,d=b+1),e[0]=0,g=1;g<d;g++)e[g]=0;if(5<=c)if(0>d-1){for(c=0;c>d;c--)e.unshift(0),a.i++;e.unshift(1);a.i++}else e[d-1]++;for(;f<Math.max(0,b);f++)e.push(0);if(b=e.reduceRight(function(a,b,c,d){b+=a;d[c]=b%10;return Math.floor(b/10)},0))e.unshift(b),a.i++}function Ed(a,b,d,c,e){if(!I(a)&&!Q(a)||isNaN(a))return"";var f=!isFinite(a),g=!1,h=Math.abs(a)+"",k="";if(f)k="\u221e";else{g=vg(h);wg(g,e,b.minFrac,b.maxFrac);k=g.d;h=g.i;e=g.e;f=[];for(g=k.reduce(function(a,
b){return a&&!b},!0);0>h;)k.unshift(0),h++;0<h?f=k.splice(h,k.length):(f=k,k=[0]);h=[];for(k.length>=b.lgSize&&h.unshift(k.splice(-b.lgSize,k.length).join(""));k.length>b.gSize;)h.unshift(k.splice(-b.gSize,k.length).join(""));k.length&&h.unshift(k.join(""));k=h.join(d);f.length&&(k+=c+f.join(""));e&&(k+="e+"+e)}return 0>a&&!g?b.negPre+k+b.negSuf:b.posPre+k+b.posSuf}function Lb(a,b,d,c){var e="";if(0>a||c&&0>=a)c?a=-a+1:(a=-a,e="-");for(a=""+a;a.length<b;)a=mc+a;d&&(a=a.substr(a.length-b));return e+
a}function W(a,b,d,c,e){d=d||0;return function(f){f=f["get"+a]();if(0<d||f>-d)f+=d;0===f&&-12==d&&(f=12);return Lb(f,b,c,e)}}function kb(a,b,d){return function(c,e){var f=c["get"+a](),g=ub((d?"STANDALONE":"")+(b?"SHORT":"")+a);return e[g][f]}}function Hd(a){var b=(new Date(a,0,1)).getDay();return new Date(a,0,(4>=b?5:12)-b)}function Id(a){return function(b){var d=Hd(b.getFullYear());b=+new Date(b.getFullYear(),b.getMonth(),b.getDate()+(4-b.getDay()))-+d;b=1+Math.round(b/6048E5);return Lb(b,a)}}function nc(a,
b){return 0>=a.getFullYear()?b.ERAS[0]:b.ERAS[1]}function Bd(a){function b(a){var b;if(b=a.match(d)){a=new Date(0);var f=0,g=0,h=b[8]?a.setUTCFullYear:a.setFullYear,k=b[8]?a.setUTCHours:a.setHours;b[9]&&(f=$(b[9]+b[10]),g=$(b[9]+b[11]));h.call(a,$(b[1]),$(b[2])-1,$(b[3]));f=$(b[4]||0)-f;g=$(b[5]||0)-g;h=$(b[6]||0);b=Math.round(1E3*parseFloat("0."+(b[7]||0)));k.call(a,f,g,h,b)}return a}var d=/^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;return function(c,
d,f){var g="",h=[],k,l;d=d||"mediumDate";d=a.DATETIME_FORMATS[d]||d;I(c)&&(c=xg.test(c)?$(c):b(c));Q(c)&&(c=new Date(c));if(!ha(c)||!isFinite(c.getTime()))return c;for(;d;)(l=yg.exec(d))?(h=ab(h,l,1),d=h.pop()):(h.push(d),d=null);var m=c.getTimezoneOffset();f&&(m=xc(f,m),c=Tb(c,f,!0));q(h,function(b){k=zg[b];g+=k?k(c,a.DATETIME_FORMATS,m):"''"===b?"'":b.replace(/(^'|'$)/g,"").replace(/''/g,"'")});return g}}function qg(){return function(a,b){y(b)&&(b=2);return cb(a,b)}}function rg(){return function(a,
b,d){b=Infinity===Math.abs(Number(b))?Number(b):$(b);if(isNaN(b))return a;Q(a)&&(a=a.toString());if(!K(a)&&!I(a))return a;d=!d||isNaN(d)?0:$(d);d=0>d?Math.max(0,a.length+d):d;return 0<=b?a.slice(d,d+b):0===d?a.slice(b,a.length):a.slice(Math.max(0,d+b),d)}}function Dd(a){function b(b,d){d=d?-1:1;return b.map(function(b){var c=1,h=Ya;if(E(b))h=b;else if(I(b)){if("+"==b.charAt(0)||"-"==b.charAt(0))c="-"==b.charAt(0)?-1:1,b=b.substring(1);if(""!==b&&(h=a(b),h.constant))var k=h(),h=function(a){return a[k]}}return{get:h,
descending:c*d}})}function d(a){switch(typeof a){case "number":case "boolean":case "string":return!0;default:return!1}}return function(a,e,f){if(null==a)return a;if(!xa(a))throw O("orderBy")("notarray",a);K(e)||(e=[e]);0===e.length&&(e=["+"]);var g=b(e,f);g.push({get:function(){return{}},descending:f?-1:1});a=Array.prototype.map.call(a,function(a,b){return{value:a,predicateValues:g.map(function(c){var e=c.get(a);c=typeof e;if(null===e)c="string",e="null";else if("string"===c)e=e.toLowerCase();else if("object"===
c)a:{if("function"===typeof e.valueOf&&(e=e.valueOf(),d(e)))break a;if(uc(e)&&(e=e.toString(),d(e)))break a;e=b}return{value:e,type:c}})}});a.sort(function(a,b){for(var c=0,d=0,e=g.length;d<e;++d){var c=a.predicateValues[d],f=b.predicateValues[d],x=0;c.type===f.type?c.value!==f.value&&(x=c.value<f.value?-1:1):x=c.type<f.type?-1:1;if(c=x*g[d].descending)break}return c});return a=a.map(function(a){return a.value})}}function Ma(a){E(a)&&(a={link:a});a.restrict=a.restrict||"AC";return ca(a)}function Jd(a,
b,d,c,e){var f=this,g=[];f.$error={};f.$$success={};f.$pending=void 0;f.$name=e(b.name||b.ngForm||"")(d);f.$dirty=!1;f.$pristine=!0;f.$valid=!0;f.$invalid=!1;f.$submitted=!1;f.$$parentForm=Mb;f.$rollbackViewValue=function(){q(g,function(a){a.$rollbackViewValue()})};f.$commitViewValue=function(){q(g,function(a){a.$commitViewValue()})};f.$addControl=function(a){Ra(a.$name,"input");g.push(a);a.$name&&(f[a.$name]=a);a.$$parentForm=f};f.$$renameControl=function(a,b){var c=a.$name;f[c]===a&&delete f[c];
f[b]=a;a.$name=b};f.$removeControl=function(a){a.$name&&f[a.$name]===a&&delete f[a.$name];q(f.$pending,function(b,c){f.$setValidity(c,null,a)});q(f.$error,function(b,c){f.$setValidity(c,null,a)});q(f.$$success,function(b,c){f.$setValidity(c,null,a)});$a(g,a);a.$$parentForm=Mb};Kd({ctrl:this,$element:a,set:function(a,b,c){var d=a[b];d?-1===d.indexOf(c)&&d.push(c):a[b]=[c]},unset:function(a,b,c){var d=a[b];d&&($a(d,c),0===d.length&&delete a[b])},$animate:c});f.$setDirty=function(){c.removeClass(a,Va);
c.addClass(a,Nb);f.$dirty=!0;f.$pristine=!1;f.$$parentForm.$setDirty()};f.$setPristine=function(){c.setClass(a,Va,Nb+" ng-submitted");f.$dirty=!1;f.$pristine=!0;f.$submitted=!1;q(g,function(a){a.$setPristine()})};f.$setUntouched=function(){q(g,function(a){a.$setUntouched()})};f.$setSubmitted=function(){c.addClass(a,"ng-submitted");f.$submitted=!0;f.$$parentForm.$setSubmitted()}}function oc(a){a.$formatters.push(function(b){return a.$isEmpty(b)?b:b.toString()})}function lb(a,b,d,c,e,f){var g=L(b[0].type);
if(!e.android){var h=!1;b.on("compositionstart",function(){h=!0});b.on("compositionend",function(){h=!1;l()})}var k,l=function(a){k&&(f.defer.cancel(k),k=null);if(!h){var e=b.val();a=a&&a.type;"password"===g||d.ngTrim&&"false"===d.ngTrim||(e=V(e));(c.$viewValue!==e||""===e&&c.$$hasNativeValidators)&&c.$setViewValue(e,a)}};if(e.hasEvent("input"))b.on("input",l);else{var m=function(a,b,c){k||(k=f.defer(function(){k=null;b&&b.value===c||l(a)}))};b.on("keydown",function(a){var b=a.keyCode;91===b||15<
b&&19>b||37<=b&&40>=b||m(a,this,this.value)});if(e.hasEvent("paste"))b.on("paste cut",m)}b.on("change",l);if(Ld[g]&&c.$$hasNativeValidators&&g===d.type)b.on("keydown wheel mousedown",function(a){if(!k){var b=this.validity,c=b.badInput,d=b.typeMismatch;k=f.defer(function(){k=null;b.badInput===c&&b.typeMismatch===d||l(a)})}});c.$render=function(){var a=c.$isEmpty(c.$viewValue)?"":c.$viewValue;b.val()!==a&&b.val(a)}}function Ob(a,b){return function(d,c){var e,f;if(ha(d))return d;if(I(d)){'"'==d.charAt(0)&&
'"'==d.charAt(d.length-1)&&(d=d.substring(1,d.length-1));if(Ag.test(d))return new Date(d);a.lastIndex=0;if(e=a.exec(d))return e.shift(),f=c?{yyyy:c.getFullYear(),MM:c.getMonth()+1,dd:c.getDate(),HH:c.getHours(),mm:c.getMinutes(),ss:c.getSeconds(),sss:c.getMilliseconds()/1E3}:{yyyy:1970,MM:1,dd:1,HH:0,mm:0,ss:0,sss:0},q(e,function(a,c){c<b.length&&(f[b[c]]=+a)}),new Date(f.yyyy,f.MM-1,f.dd,f.HH,f.mm,f.ss||0,1E3*f.sss||0)}return NaN}}function mb(a,b,d,c){return function(e,f,g,h,k,l,m){function n(a){return a&&
!(a.getTime&&a.getTime()!==a.getTime())}function p(a){return v(a)&&!ha(a)?d(a)||void 0:a}Md(e,f,g,h);lb(e,f,g,h,k,l);var q=h&&h.$options&&h.$options.timezone,s;h.$$parserName=a;h.$parsers.push(function(a){if(h.$isEmpty(a))return null;if(b.test(a))return a=d(a,s),q&&(a=Tb(a,q)),a});h.$formatters.push(function(a){if(a&&!ha(a))throw nb("datefmt",a);if(n(a))return(s=a)&&q&&(s=Tb(s,q,!0)),m("date")(a,c,q);s=null;return""});if(v(g.min)||g.ngMin){var z;h.$validators.min=function(a){return!n(a)||y(z)||d(a)>=
z};g.$observe("min",function(a){z=p(a);h.$validate()})}if(v(g.max)||g.ngMax){var r;h.$validators.max=function(a){return!n(a)||y(r)||d(a)<=r};g.$observe("max",function(a){r=p(a);h.$validate()})}}}function Md(a,b,d,c){(c.$$hasNativeValidators=J(b[0].validity))&&c.$parsers.push(function(a){var c=b.prop("validity")||{};return c.badInput||c.typeMismatch?void 0:a})}function Nd(a,b,d,c,e){if(v(c)){a=a(c);if(!a.constant)throw nb("constexpr",d,c);return a(b)}return e}function pc(a,b){a="ngClass"+a;return["$animate",
function(d){function c(a,b){var c=[],d=0;a:for(;d<a.length;d++){for(var e=a[d],m=0;m<b.length;m++)if(e==b[m])continue a;c.push(e)}return c}function e(a){var b=[];return K(a)?(q(a,function(a){b=b.concat(e(a))}),b):I(a)?a.split(" "):J(a)?(q(a,function(a,c){a&&(b=b.concat(c.split(" ")))}),b):a}return{restrict:"AC",link:function(f,g,h){function k(a){a=l(a,1);h.$addClass(a)}function l(a,b){var c=g.data("$classCounts")||S(),d=[];q(a,function(a){if(0<b||c[a])c[a]=(c[a]||0)+b,c[a]===+(0<b)&&d.push(a)});g.data("$classCounts",
c);return d.join(" ")}function m(a,b){var e=c(b,a),f=c(a,b),e=l(e,1),f=l(f,-1);e&&e.length&&d.addClass(g,e);f&&f.length&&d.removeClass(g,f)}function n(a){if(!0===b||(f.$index&1)===b){var c=e(a||[]);if(!p)k(c);else if(!na(a,p)){var d=e(p);m(d,c)}}p=K(a)?a.map(function(a){return fa(a)}):fa(a)}var p;f.$watch(h[a],n,!0);h.$observe("class",function(b){n(f.$eval(h[a]))});"ngClass"!==a&&f.$watch("$index",function(c,d){var g=c&1;if(g!==(d&1)){var m=e(f.$eval(h[a]));g===b?k(m):(g=l(m,-1),h.$removeClass(g))}})}}}]}
function Kd(a){function b(a,b){b&&!f[a]?(k.addClass(e,a),f[a]=!0):!b&&f[a]&&(k.removeClass(e,a),f[a]=!1)}function d(a,c){a=a?"-"+Bc(a,"-"):"";b(ob+a,!0===c);b(Od+a,!1===c)}var c=a.ctrl,e=a.$element,f={},g=a.set,h=a.unset,k=a.$animate;f[Od]=!(f[ob]=e.hasClass(ob));c.$setValidity=function(a,e,f){y(e)?(c.$pending||(c.$pending={}),g(c.$pending,a,f)):(c.$pending&&h(c.$pending,a,f),Pd(c.$pending)&&(c.$pending=void 0));Ea(e)?e?(h(c.$error,a,f),g(c.$$success,a,f)):(g(c.$error,a,f),h(c.$$success,a,f)):(h(c.$error,
a,f),h(c.$$success,a,f));c.$pending?(b(Qd,!0),c.$valid=c.$invalid=void 0,d("",null)):(b(Qd,!1),c.$valid=Pd(c.$error),c.$invalid=!c.$valid,d("",c.$valid));e=c.$pending&&c.$pending[a]?void 0:c.$error[a]?!1:c.$$success[a]?!0:null;d(a,e);c.$$parentForm.$setValidity(a,e,c)}}function Pd(a){if(a)for(var b in a)if(a.hasOwnProperty(b))return!1;return!0}var Bg=/^\/(.+)\/([a-z]*)$/,sa=Object.prototype.hasOwnProperty,L=function(a){return I(a)?a.toLowerCase():a},ub=function(a){return I(a)?a.toUpperCase():a},Ba,
G,Y,ya=[].slice,ag=[].splice,Cg=[].push,ja=Object.prototype.toString,vc=Object.getPrototypeOf,za=O("ng"),da=F.angular||(F.angular={}),Vb,pb=0;Ba=F.document.documentMode;C.$inject=[];Ya.$inject=[];var K=Array.isArray,ae=/^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\]$/,V=function(a){return I(a)?a.trim():a},wd=function(a){return a.replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g,"\\$1").replace(/\x08/g,"\\x08")},Fa=function(){if(!v(Fa.rules)){var a=F.document.querySelector("[ng-csp]")||
F.document.querySelector("[data-ng-csp]");if(a){var b=a.getAttribute("ng-csp")||a.getAttribute("data-ng-csp");Fa.rules={noUnsafeEval:!b||-1!==b.indexOf("no-unsafe-eval"),noInlineStyle:!b||-1!==b.indexOf("no-inline-style")}}else{a=Fa;try{new Function(""),b=!1}catch(d){b=!0}a.rules={noUnsafeEval:b,noInlineStyle:!1}}}return Fa.rules},rb=function(){if(v(rb.name_))return rb.name_;var a,b,d=Oa.length,c,e;for(b=0;b<d;++b)if(c=Oa[b],a=F.document.querySelector("["+c.replace(":","\\:")+"jq]")){e=a.getAttribute(c+
"jq");break}return rb.name_=e},de=/:/g,Oa=["ng-","data-ng-","ng:","x-ng-"],ie=/[A-Z]/g,Cc=!1,Na=3,me={full:"1.5.6",major:1,minor:5,dot:6,codeName:"arrow-stringification"};T.expando="ng339";var gb=T.cache={},Of=1;T._data=function(a){return this.cache[a[this.expando]]||{}};var Jf=/([\:\-\_]+(.))/g,Kf=/^moz([A-Z])/,yb={mouseleave:"mouseout",mouseenter:"mouseover"},Xb=O("jqLite"),Nf=/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/,Wb=/<|&#?\w+;/,Lf=/<([\w:-]+)/,Mf=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
ga={option:[1,'<select multiple="multiple">',"</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ga.optgroup=ga.option;ga.tbody=ga.tfoot=ga.colgroup=ga.caption=ga.thead;ga.th=ga.td;var Tf=F.Node.prototype.contains||function(a){return!!(this.compareDocumentPosition(a)&16)},Pa=T.prototype={ready:function(a){function b(){d||(d=!0,a())}var d=!1;"complete"===
F.document.readyState?F.setTimeout(b):(this.on("DOMContentLoaded",b),T(F).on("load",b))},toString:function(){var a=[];q(this,function(b){a.push(""+b)});return"["+a.join(", ")+"]"},eq:function(a){return 0<=a?G(this[a]):G(this[this.length+a])},length:0,push:Cg,sort:[].sort,splice:[].splice},Eb={};q("multiple selected checked disabled readOnly required open".split(" "),function(a){Eb[L(a)]=a});var Uc={};q("input select option textarea button form details".split(" "),function(a){Uc[a]=!0});var bd={ngMinlength:"minlength",
ngMaxlength:"maxlength",ngMin:"min",ngMax:"max",ngPattern:"pattern"};q({data:Zb,removeData:fb,hasData:function(a){for(var b in gb[a.ng339])return!0;return!1},cleanData:function(a){for(var b=0,d=a.length;b<d;b++)fb(a[b])}},function(a,b){T[b]=a});q({data:Zb,inheritedData:Cb,scope:function(a){return G.data(a,"$scope")||Cb(a.parentNode||a,["$isolateScope","$scope"])},isolateScope:function(a){return G.data(a,"$isolateScope")||G.data(a,"$isolateScopeNoTemplate")},controller:Rc,injector:function(a){return Cb(a,
"$injector")},removeAttr:function(a,b){a.removeAttribute(b)},hasClass:zb,css:function(a,b,d){b=eb(b);if(v(d))a.style[b]=d;else return a.style[b]},attr:function(a,b,d){var c=a.nodeType;if(c!==Na&&2!==c&&8!==c)if(c=L(b),Eb[c])if(v(d))d?(a[b]=!0,a.setAttribute(b,c)):(a[b]=!1,a.removeAttribute(c));else return a[b]||(a.attributes.getNamedItem(b)||C).specified?c:void 0;else if(v(d))a.setAttribute(b,d);else if(a.getAttribute)return a=a.getAttribute(b,2),null===a?void 0:a},prop:function(a,b,d){if(v(d))a[b]=
d;else return a[b]},text:function(){function a(a,d){if(y(d)){var c=a.nodeType;return 1===c||c===Na?a.textContent:""}a.textContent=d}a.$dv="";return a}(),val:function(a,b){if(y(b)){if(a.multiple&&"select"===ta(a)){var d=[];q(a.options,function(a){a.selected&&d.push(a.value||a.text)});return 0===d.length?null:d}return a.value}a.value=b},html:function(a,b){if(y(b))return a.innerHTML;wb(a,!0);a.innerHTML=b},empty:Sc},function(a,b){T.prototype[b]=function(b,c){var e,f,g=this.length;if(a!==Sc&&y(2==a.length&&
a!==zb&&a!==Rc?b:c)){if(J(b)){for(e=0;e<g;e++)if(a===Zb)a(this[e],b);else for(f in b)a(this[e],f,b[f]);return this}e=a.$dv;g=y(e)?Math.min(g,1):g;for(f=0;f<g;f++){var h=a(this[f],b,c);e=e?e+h:h}return e}for(e=0;e<g;e++)a(this[e],b,c);return this}});q({removeData:fb,on:function(a,b,d,c){if(v(c))throw Xb("onargs");if(Mc(a)){c=xb(a,!0);var e=c.events,f=c.handle;f||(f=c.handle=Qf(a,e));c=0<=b.indexOf(" ")?b.split(" "):[b];for(var g=c.length,h=function(b,c,g){var h=e[b];h||(h=e[b]=[],h.specialHandlerWrapper=
c,"$destroy"===b||g||a.addEventListener(b,f,!1));h.push(d)};g--;)b=c[g],yb[b]?(h(yb[b],Sf),h(b,void 0,!0)):h(b)}},off:Qc,one:function(a,b,d){a=G(a);a.on(b,function e(){a.off(b,d);a.off(b,e)});a.on(b,d)},replaceWith:function(a,b){var d,c=a.parentNode;wb(a);q(new T(b),function(b){d?c.insertBefore(b,d.nextSibling):c.replaceChild(b,a);d=b})},children:function(a){var b=[];q(a.childNodes,function(a){1===a.nodeType&&b.push(a)});return b},contents:function(a){return a.contentDocument||a.childNodes||[]},append:function(a,
b){var d=a.nodeType;if(1===d||11===d){b=new T(b);for(var d=0,c=b.length;d<c;d++)a.appendChild(b[d])}},prepend:function(a,b){if(1===a.nodeType){var d=a.firstChild;q(new T(b),function(b){a.insertBefore(b,d)})}},wrap:function(a,b){Oc(a,G(b).eq(0).clone()[0])},remove:Db,detach:function(a){Db(a,!0)},after:function(a,b){var d=a,c=a.parentNode;b=new T(b);for(var e=0,f=b.length;e<f;e++){var g=b[e];c.insertBefore(g,d.nextSibling);d=g}},addClass:Bb,removeClass:Ab,toggleClass:function(a,b,d){b&&q(b.split(" "),
function(b){var e=d;y(e)&&(e=!zb(a,b));(e?Bb:Ab)(a,b)})},parent:function(a){return(a=a.parentNode)&&11!==a.nodeType?a:null},next:function(a){return a.nextElementSibling},find:function(a,b){return a.getElementsByTagName?a.getElementsByTagName(b):[]},clone:Yb,triggerHandler:function(a,b,d){var c,e,f=b.type||b,g=xb(a);if(g=(g=g&&g.events)&&g[f])c={preventDefault:function(){this.defaultPrevented=!0},isDefaultPrevented:function(){return!0===this.defaultPrevented},stopImmediatePropagation:function(){this.immediatePropagationStopped=
!0},isImmediatePropagationStopped:function(){return!0===this.immediatePropagationStopped},stopPropagation:C,type:f,target:a},b.type&&(c=P(c,b)),b=fa(g),e=d?[c].concat(d):[c],q(b,function(b){c.isImmediatePropagationStopped()||b.apply(a,e)})}},function(a,b){T.prototype[b]=function(b,c,e){for(var f,g=0,h=this.length;g<h;g++)y(f)?(f=a(this[g],b,c,e),v(f)&&(f=G(f))):Pc(f,a(this[g],b,c,e));return v(f)?f:this};T.prototype.bind=T.prototype.on;T.prototype.unbind=T.prototype.off});Sa.prototype={put:function(a,
b){this[Ga(a,this.nextUid)]=b},get:function(a){return this[Ga(a,this.nextUid)]},remove:function(a){var b=this[a=Ga(a,this.nextUid)];delete this[a];return b}};var Hf=[function(){this.$get=[function(){return Sa}]}],Vf=/^([^\(]+?)=>/,Wf=/^[^\(]*\(\s*([^\)]*)\)/m,Dg=/,/,Eg=/^\s*(_?)(\S+?)\1\s*$/,Uf=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg,Ha=O("$injector");db.$$annotate=function(a,b,d){var c;if("function"===typeof a){if(!(c=a.$inject)){c=[];if(a.length){if(b)throw I(d)&&d||(d=a.name||Xf(a)),Ha("strictdi",d);
b=Vc(a);q(b[1].split(Dg),function(a){a.replace(Eg,function(a,b,d){c.push(d)})})}a.$inject=c}}else K(a)?(b=a.length-1,Qa(a[b],"fn"),c=a.slice(0,b)):Qa(a,"fn",!0);return c};var Rd=O("$animate"),$e=function(){this.$get=C},af=function(){var a=new Sa,b=[];this.$get=["$$AnimateRunner","$rootScope",function(d,c){function e(a,b,c){var d=!1;b&&(b=I(b)?b.split(" "):K(b)?b:[],q(b,function(b){b&&(d=!0,a[b]=c)}));return d}function f(){q(b,function(b){var c=a.get(b);if(c){var d=Yf(b.attr("class")),e="",f="";q(c,
function(a,b){a!==!!d[b]&&(a?e+=(e.length?" ":"")+b:f+=(f.length?" ":"")+b)});q(b,function(a){e&&Bb(a,e);f&&Ab(a,f)});a.remove(b)}});b.length=0}return{enabled:C,on:C,off:C,pin:C,push:function(g,h,k,l){l&&l();k=k||{};k.from&&g.css(k.from);k.to&&g.css(k.to);if(k.addClass||k.removeClass)if(h=k.addClass,l=k.removeClass,k=a.get(g)||{},h=e(k,h,!0),l=e(k,l,!1),h||l)a.put(g,k),b.push(g),1===b.length&&c.$$postDigest(f);g=new d;g.complete();return g}}}]},Ye=["$provide",function(a){var b=this;this.$$registeredAnimations=
Object.create(null);this.register=function(d,c){if(d&&"."!==d.charAt(0))throw Rd("notcsel",d);var e=d+"-animation";b.$$registeredAnimations[d.substr(1)]=e;a.factory(e,c)};this.classNameFilter=function(a){if(1===arguments.length&&(this.$$classNameFilter=a instanceof RegExp?a:null)&&/(\s+|\/)ng-animate(\s+|\/)/.test(this.$$classNameFilter.toString()))throw Rd("nongcls","ng-animate");return this.$$classNameFilter};this.$get=["$$animateQueue",function(a){function b(a,c,d){if(d){var h;a:{for(h=0;h<d.length;h++){var k=
d[h];if(1===k.nodeType){h=k;break a}}h=void 0}!h||h.parentNode||h.previousElementSibling||(d=null)}d?d.after(a):c.prepend(a)}return{on:a.on,off:a.off,pin:a.pin,enabled:a.enabled,cancel:function(a){a.end&&a.end()},enter:function(e,f,g,h){f=f&&G(f);g=g&&G(g);f=f||g.parent();b(e,f,g);return a.push(e,"enter",Ia(h))},move:function(e,f,g,h){f=f&&G(f);g=g&&G(g);f=f||g.parent();b(e,f,g);return a.push(e,"move",Ia(h))},leave:function(b,c){return a.push(b,"leave",Ia(c),function(){b.remove()})},addClass:function(b,
c,g){g=Ia(g);g.addClass=hb(g.addclass,c);return a.push(b,"addClass",g)},removeClass:function(b,c,g){g=Ia(g);g.removeClass=hb(g.removeClass,c);return a.push(b,"removeClass",g)},setClass:function(b,c,g,h){h=Ia(h);h.addClass=hb(h.addClass,c);h.removeClass=hb(h.removeClass,g);return a.push(b,"setClass",h)},animate:function(b,c,g,h,k){k=Ia(k);k.from=k.from?P(k.from,c):c;k.to=k.to?P(k.to,g):g;k.tempClasses=hb(k.tempClasses,h||"ng-inline-animate");return a.push(b,"animate",k)}}}]}],cf=function(){this.$get=
["$$rAF",function(a){function b(b){d.push(b);1<d.length||a(function(){for(var a=0;a<d.length;a++)d[a]();d=[]})}var d=[];return function(){var a=!1;b(function(){a=!0});return function(d){a?d():b(d)}}}]},bf=function(){this.$get=["$q","$sniffer","$$animateAsyncRun","$document","$timeout",function(a,b,d,c,e){function f(a){this.setHost(a);var b=d();this._doneCallbacks=[];this._tick=function(a){var d=c[0];d&&d.hidden?e(a,0,!1):b(a)};this._state=0}f.chain=function(a,b){function c(){if(d===a.length)b(!0);
else a[d](function(a){!1===a?b(!1):(d++,c())})}var d=0;c()};f.all=function(a,b){function c(f){e=e&&f;++d===a.length&&b(e)}var d=0,e=!0;q(a,function(a){a.done(c)})};f.prototype={setHost:function(a){this.host=a||{}},done:function(a){2===this._state?a():this._doneCallbacks.push(a)},progress:C,getPromise:function(){if(!this.promise){var b=this;this.promise=a(function(a,c){b.done(function(b){!1===b?c():a()})})}return this.promise},then:function(a,b){return this.getPromise().then(a,b)},"catch":function(a){return this.getPromise()["catch"](a)},
"finally":function(a){return this.getPromise()["finally"](a)},pause:function(){this.host.pause&&this.host.pause()},resume:function(){this.host.resume&&this.host.resume()},end:function(){this.host.end&&this.host.end();this._resolve(!0)},cancel:function(){this.host.cancel&&this.host.cancel();this._resolve(!1)},complete:function(a){var b=this;0===b._state&&(b._state=1,b._tick(function(){b._resolve(a)}))},_resolve:function(a){2!==this._state&&(q(this._doneCallbacks,function(b){b(a)}),this._doneCallbacks.length=
0,this._state=2)}};return f}]},Ze=function(){this.$get=["$$rAF","$q","$$AnimateRunner",function(a,b,d){return function(b,e){function f(){a(function(){g.addClass&&(b.addClass(g.addClass),g.addClass=null);g.removeClass&&(b.removeClass(g.removeClass),g.removeClass=null);g.to&&(b.css(g.to),g.to=null);h||k.complete();h=!0});return k}var g=e||{};g.$$prepared||(g=oa(g));g.cleanupStyles&&(g.from=g.to=null);g.from&&(b.css(g.from),g.from=null);var h,k=new d;return{start:f,end:f}}}]},ea=O("$compile"),bc=new function(){};
Ec.$inject=["$provide","$$sanitizeUriProvider"];Gb.prototype.isFirstChange=function(){return this.previousValue===bc};var Xc=/^((?:x|data)[\:\-_])/i,bg=O("$controller"),cd=/^(\S+)(\s+as\s+([\w$]+))?$/,jf=function(){this.$get=["$document",function(a){return function(b){b?!b.nodeType&&b instanceof G&&(b=b[0]):b=a[0].body;return b.offsetWidth+1}}]},dd="application/json",ec={"Content-Type":dd+";charset=utf-8"},dg=/^\[|^\{(?!\{)/,eg={"[":/]$/,"{":/}$/},cg=/^\)\]\}',?\n/,Fg=O("$http"),hd=function(a){return function(){throw Fg("legacy",
a);}},Ka=da.$interpolateMinErr=O("$interpolate");Ka.throwNoconcat=function(a){throw Ka("noconcat",a);};Ka.interr=function(a,b){return Ka("interr",a,b.toString())};var Gg=/^([^\?#]*)(\?([^#]*))?(#(.*))?$/,gg={http:80,https:443,ftp:21},Hb=O("$location"),Hg={$$html5:!1,$$replace:!1,absUrl:Ib("$$absUrl"),url:function(a){if(y(a))return this.$$url;var b=Gg.exec(a);(b[1]||""===a)&&this.path(decodeURIComponent(b[1]));(b[2]||b[1]||""===a)&&this.search(b[3]||"");this.hash(b[5]||"");return this},protocol:Ib("$$protocol"),
host:Ib("$$host"),port:Ib("$$port"),path:md("$$path",function(a){a=null!==a?a.toString():"";return"/"==a.charAt(0)?a:"/"+a}),search:function(a,b){switch(arguments.length){case 0:return this.$$search;case 1:if(I(a)||Q(a))a=a.toString(),this.$$search=zc(a);else if(J(a))a=oa(a,{}),q(a,function(b,c){null==b&&delete a[c]}),this.$$search=a;else throw Hb("isrcharg");break;default:y(b)||null===b?delete this.$$search[a]:this.$$search[a]=b}this.$$compose();return this},hash:md("$$hash",function(a){return null!==
a?a.toString():""}),replace:function(){this.$$replace=!0;return this}};q([ld,hc,gc],function(a){a.prototype=Object.create(Hg);a.prototype.state=function(b){if(!arguments.length)return this.$$state;if(a!==gc||!this.$$html5)throw Hb("nostate");this.$$state=y(b)?null:b;return this}});var ba=O("$parse"),ig=Function.prototype.call,jg=Function.prototype.apply,kg=Function.prototype.bind,Pb=S();q("+ - * / % === !== == != < > <= >= && || ! = |".split(" "),function(a){Pb[a]=!0});var Ig={n:"\n",f:"\f",r:"\r",
t:"\t",v:"\v","'":"'",'"':'"'},jc=function(a){this.options=a};jc.prototype={constructor:jc,lex:function(a){this.text=a;this.index=0;for(this.tokens=[];this.index<this.text.length;)if(a=this.text.charAt(this.index),'"'===a||"'"===a)this.readString(a);else if(this.isNumber(a)||"."===a&&this.isNumber(this.peek()))this.readNumber();else if(this.isIdentifierStart(this.peekMultichar()))this.readIdent();else if(this.is(a,"(){}[].,;:?"))this.tokens.push({index:this.index,text:a}),this.index++;else if(this.isWhitespace(a))this.index++;
else{var b=a+this.peek(),d=b+this.peek(2),c=Pb[b],e=Pb[d];Pb[a]||c||e?(a=e?d:c?b:a,this.tokens.push({index:this.index,text:a,operator:!0}),this.index+=a.length):this.throwError("Unexpected next character ",this.index,this.index+1)}return this.tokens},is:function(a,b){return-1!==b.indexOf(a)},peek:function(a){a=a||1;return this.index+a<this.text.length?this.text.charAt(this.index+a):!1},isNumber:function(a){return"0"<=a&&"9">=a&&"string"===typeof a},isWhitespace:function(a){return" "===a||"\r"===a||
"\t"===a||"\n"===a||"\v"===a||"\u00a0"===a},isIdentifierStart:function(a){return this.options.isIdentifierStart?this.options.isIdentifierStart(a,this.codePointAt(a)):this.isValidIdentifierStart(a)},isValidIdentifierStart:function(a){return"a"<=a&&"z">=a||"A"<=a&&"Z">=a||"_"===a||"$"===a},isIdentifierContinue:function(a){return this.options.isIdentifierContinue?this.options.isIdentifierContinue(a,this.codePointAt(a)):this.isValidIdentifierContinue(a)},isValidIdentifierContinue:function(a,b){return this.isValidIdentifierStart(a,
b)||this.isNumber(a)},codePointAt:function(a){return 1===a.length?a.charCodeAt(0):(a.charCodeAt(0)<<10)+a.charCodeAt(1)-56613888},peekMultichar:function(){var a=this.text.charAt(this.index),b=this.peek();if(!b)return a;var d=a.charCodeAt(0),c=b.charCodeAt(0);return 55296<=d&&56319>=d&&56320<=c&&57343>=c?a+b:a},isExpOperator:function(a){return"-"===a||"+"===a||this.isNumber(a)},throwError:function(a,b,d){d=d||this.index;b=v(b)?"s "+b+"-"+this.index+" ["+this.text.substring(b,d)+"]":" "+d;throw ba("lexerr",
a,b,this.text);},readNumber:function(){for(var a="",b=this.index;this.index<this.text.length;){var d=L(this.text.charAt(this.index));if("."==d||this.isNumber(d))a+=d;else{var c=this.peek();if("e"==d&&this.isExpOperator(c))a+=d;else if(this.isExpOperator(d)&&c&&this.isNumber(c)&&"e"==a.charAt(a.length-1))a+=d;else if(!this.isExpOperator(d)||c&&this.isNumber(c)||"e"!=a.charAt(a.length-1))break;else this.throwError("Invalid exponent")}this.index++}this.tokens.push({index:b,text:a,constant:!0,value:Number(a)})},
readIdent:function(){var a=this.index;for(this.index+=this.peekMultichar().length;this.index<this.text.length;){var b=this.peekMultichar();if(!this.isIdentifierContinue(b))break;this.index+=b.length}this.tokens.push({index:a,text:this.text.slice(a,this.index),identifier:!0})},readString:function(a){var b=this.index;this.index++;for(var d="",c=a,e=!1;this.index<this.text.length;){var f=this.text.charAt(this.index),c=c+f;if(e)"u"===f?(e=this.text.substring(this.index+1,this.index+5),e.match(/[\da-f]{4}/i)||
this.throwError("Invalid unicode escape [\\u"+e+"]"),this.index+=4,d+=String.fromCharCode(parseInt(e,16))):d+=Ig[f]||f,e=!1;else if("\\"===f)e=!0;else{if(f===a){this.index++;this.tokens.push({index:b,text:c,constant:!0,value:d});return}d+=f}this.index++}this.throwError("Unterminated quote",b)}};var s=function(a,b){this.lexer=a;this.options=b};s.Program="Program";s.ExpressionStatement="ExpressionStatement";s.AssignmentExpression="AssignmentExpression";s.ConditionalExpression="ConditionalExpression";
s.LogicalExpression="LogicalExpression";s.BinaryExpression="BinaryExpression";s.UnaryExpression="UnaryExpression";s.CallExpression="CallExpression";s.MemberExpression="MemberExpression";s.Identifier="Identifier";s.Literal="Literal";s.ArrayExpression="ArrayExpression";s.Property="Property";s.ObjectExpression="ObjectExpression";s.ThisExpression="ThisExpression";s.LocalsExpression="LocalsExpression";s.NGValueParameter="NGValueParameter";s.prototype={ast:function(a){this.text=a;this.tokens=this.lexer.lex(a);
a=this.program();0!==this.tokens.length&&this.throwError("is an unexpected token",this.tokens[0]);return a},program:function(){for(var a=[];;)if(0<this.tokens.length&&!this.peek("}",")",";","]")&&a.push(this.expressionStatement()),!this.expect(";"))return{type:s.Program,body:a}},expressionStatement:function(){return{type:s.ExpressionStatement,expression:this.filterChain()}},filterChain:function(){for(var a=this.expression();this.expect("|");)a=this.filter(a);return a},expression:function(){return this.assignment()},
assignment:function(){var a=this.ternary();this.expect("=")&&(a={type:s.AssignmentExpression,left:a,right:this.assignment(),operator:"="});return a},ternary:function(){var a=this.logicalOR(),b,d;return this.expect("?")&&(b=this.expression(),this.consume(":"))?(d=this.expression(),{type:s.ConditionalExpression,test:a,alternate:b,consequent:d}):a},logicalOR:function(){for(var a=this.logicalAND();this.expect("||");)a={type:s.LogicalExpression,operator:"||",left:a,right:this.logicalAND()};return a},logicalAND:function(){for(var a=
this.equality();this.expect("&&");)a={type:s.LogicalExpression,operator:"&&",left:a,right:this.equality()};return a},equality:function(){for(var a=this.relational(),b;b=this.expect("==","!=","===","!==");)a={type:s.BinaryExpression,operator:b.text,left:a,right:this.relational()};return a},relational:function(){for(var a=this.additive(),b;b=this.expect("<",">","<=",">=");)a={type:s.BinaryExpression,operator:b.text,left:a,right:this.additive()};return a},additive:function(){for(var a=this.multiplicative(),
b;b=this.expect("+","-");)a={type:s.BinaryExpression,operator:b.text,left:a,right:this.multiplicative()};return a},multiplicative:function(){for(var a=this.unary(),b;b=this.expect("*","/","%");)a={type:s.BinaryExpression,operator:b.text,left:a,right:this.unary()};return a},unary:function(){var a;return(a=this.expect("+","-","!"))?{type:s.UnaryExpression,operator:a.text,prefix:!0,argument:this.unary()}:this.primary()},primary:function(){var a;this.expect("(")?(a=this.filterChain(),this.consume(")")):
this.expect("[")?a=this.arrayDeclaration():this.expect("{")?a=this.object():this.selfReferential.hasOwnProperty(this.peek().text)?a=oa(this.selfReferential[this.consume().text]):this.options.literals.hasOwnProperty(this.peek().text)?a={type:s.Literal,value:this.options.literals[this.consume().text]}:this.peek().identifier?a=this.identifier():this.peek().constant?a=this.constant():this.throwError("not a primary expression",this.peek());for(var b;b=this.expect("(","[",".");)"("===b.text?(a={type:s.CallExpression,
callee:a,arguments:this.parseArguments()},this.consume(")")):"["===b.text?(a={type:s.MemberExpression,object:a,property:this.expression(),computed:!0},this.consume("]")):"."===b.text?a={type:s.MemberExpression,object:a,property:this.identifier(),computed:!1}:this.throwError("IMPOSSIBLE");return a},filter:function(a){a=[a];for(var b={type:s.CallExpression,callee:this.identifier(),arguments:a,filter:!0};this.expect(":");)a.push(this.expression());return b},parseArguments:function(){var a=[];if(")"!==
this.peekToken().text){do a.push(this.expression());while(this.expect(","))}return a},identifier:function(){var a=this.consume();a.identifier||this.throwError("is not a valid identifier",a);return{type:s.Identifier,name:a.text}},constant:function(){return{type:s.Literal,value:this.consume().value}},arrayDeclaration:function(){var a=[];if("]"!==this.peekToken().text){do{if(this.peek("]"))break;a.push(this.expression())}while(this.expect(","))}this.consume("]");return{type:s.ArrayExpression,elements:a}},
object:function(){var a=[],b;if("}"!==this.peekToken().text){do{if(this.peek("}"))break;b={type:s.Property,kind:"init"};this.peek().constant?(b.key=this.constant(),b.computed=!1,this.consume(":"),b.value=this.expression()):this.peek().identifier?(b.key=this.identifier(),b.computed=!1,this.peek(":")?(this.consume(":"),b.value=this.expression()):b.value=b.key):this.peek("[")?(this.consume("["),b.key=this.expression(),this.consume("]"),b.computed=!0,this.consume(":"),b.value=this.expression()):this.throwError("invalid key",
this.peek());a.push(b)}while(this.expect(","))}this.consume("}");return{type:s.ObjectExpression,properties:a}},throwError:function(a,b){throw ba("syntax",b.text,a,b.index+1,this.text,this.text.substring(b.index));},consume:function(a){if(0===this.tokens.length)throw ba("ueoe",this.text);var b=this.expect(a);b||this.throwError("is unexpected, expecting ["+a+"]",this.peek());return b},peekToken:function(){if(0===this.tokens.length)throw ba("ueoe",this.text);return this.tokens[0]},peek:function(a,b,
d,c){return this.peekAhead(0,a,b,d,c)},peekAhead:function(a,b,d,c,e){if(this.tokens.length>a){a=this.tokens[a];var f=a.text;if(f===b||f===d||f===c||f===e||!(b||d||c||e))return a}return!1},expect:function(a,b,d,c){return(a=this.peek(a,b,d,c))?(this.tokens.shift(),a):!1},selfReferential:{"this":{type:s.ThisExpression},$locals:{type:s.LocalsExpression}}};td.prototype={compile:function(a,b){var d=this,c=this.astBuilder.ast(a);this.state={nextId:0,filters:{},expensiveChecks:b,fn:{vars:[],body:[],own:{}},
assign:{vars:[],body:[],own:{}},inputs:[]};Z(c,d.$filter);var e="",f;this.stage="assign";if(f=rd(c))this.state.computing="assign",e=this.nextId(),this.recurse(f,e),this.return_(e),e="fn.assign="+this.generateFunction("assign","s,v,l");f=pd(c.body);d.stage="inputs";q(f,function(a,b){var c="fn"+b;d.state[c]={vars:[],body:[],own:{}};d.state.computing=c;var e=d.nextId();d.recurse(a,e);d.return_(e);d.state.inputs.push(c);a.watchId=b});this.state.computing="fn";this.stage="main";this.recurse(c);e='"'+this.USE+
" "+this.STRICT+'";\n'+this.filterPrefix()+"var fn="+this.generateFunction("fn","s,l,a,i")+e+this.watchFns()+"return fn;";e=(new Function("$filter","ensureSafeMemberName","ensureSafeObject","ensureSafeFunction","getStringValue","ensureSafeAssignContext","ifDefined","plus","text",e))(this.$filter,Ua,qa,nd,hg,Jb,lg,od,a);this.state=this.stage=void 0;e.literal=sd(c);e.constant=c.constant;return e},USE:"use",STRICT:"strict",watchFns:function(){var a=[],b=this.state.inputs,d=this;q(b,function(b){a.push("var "+
b+"="+d.generateFunction(b,"s"))});b.length&&a.push("fn.inputs=["+b.join(",")+"];");return a.join("")},generateFunction:function(a,b){return"function("+b+"){"+this.varsPrefix(a)+this.body(a)+"};"},filterPrefix:function(){var a=[],b=this;q(this.state.filters,function(d,c){a.push(d+"=$filter("+b.escape(c)+")")});return a.length?"var "+a.join(",")+";":""},varsPrefix:function(a){return this.state[a].vars.length?"var "+this.state[a].vars.join(",")+";":""},body:function(a){return this.state[a].body.join("")},
recurse:function(a,b,d,c,e,f){var g,h,k=this,l,m,n;c=c||C;if(!f&&v(a.watchId))b=b||this.nextId(),this.if_("i",this.lazyAssign(b,this.computedMember("i",a.watchId)),this.lazyRecurse(a,b,d,c,e,!0));else switch(a.type){case s.Program:q(a.body,function(b,c){k.recurse(b.expression,void 0,void 0,function(a){h=a});c!==a.body.length-1?k.current().body.push(h,";"):k.return_(h)});break;case s.Literal:m=this.escape(a.value);this.assign(b,m);c(m);break;case s.UnaryExpression:this.recurse(a.argument,void 0,void 0,
function(a){h=a});m=a.operator+"("+this.ifDefined(h,0)+")";this.assign(b,m);c(m);break;case s.BinaryExpression:this.recurse(a.left,void 0,void 0,function(a){g=a});this.recurse(a.right,void 0,void 0,function(a){h=a});m="+"===a.operator?this.plus(g,h):"-"===a.operator?this.ifDefined(g,0)+a.operator+this.ifDefined(h,0):"("+g+")"+a.operator+"("+h+")";this.assign(b,m);c(m);break;case s.LogicalExpression:b=b||this.nextId();k.recurse(a.left,b);k.if_("&&"===a.operator?b:k.not(b),k.lazyRecurse(a.right,b));
c(b);break;case s.ConditionalExpression:b=b||this.nextId();k.recurse(a.test,b);k.if_(b,k.lazyRecurse(a.alternate,b),k.lazyRecurse(a.consequent,b));c(b);break;case s.Identifier:b=b||this.nextId();d&&(d.context="inputs"===k.stage?"s":this.assign(this.nextId(),this.getHasOwnProperty("l",a.name)+"?l:s"),d.computed=!1,d.name=a.name);Ua(a.name);k.if_("inputs"===k.stage||k.not(k.getHasOwnProperty("l",a.name)),function(){k.if_("inputs"===k.stage||"s",function(){e&&1!==e&&k.if_(k.not(k.nonComputedMember("s",
a.name)),k.lazyAssign(k.nonComputedMember("s",a.name),"{}"));k.assign(b,k.nonComputedMember("s",a.name))})},b&&k.lazyAssign(b,k.nonComputedMember("l",a.name)));(k.state.expensiveChecks||Kb(a.name))&&k.addEnsureSafeObject(b);c(b);break;case s.MemberExpression:g=d&&(d.context=this.nextId())||this.nextId();b=b||this.nextId();k.recurse(a.object,g,void 0,function(){k.if_(k.notNull(g),function(){e&&1!==e&&k.addEnsureSafeAssignContext(g);if(a.computed)h=k.nextId(),k.recurse(a.property,h),k.getStringValue(h),
k.addEnsureSafeMemberName(h),e&&1!==e&&k.if_(k.not(k.computedMember(g,h)),k.lazyAssign(k.computedMember(g,h),"{}")),m=k.ensureSafeObject(k.computedMember(g,h)),k.assign(b,m),d&&(d.computed=!0,d.name=h);else{Ua(a.property.name);e&&1!==e&&k.if_(k.not(k.nonComputedMember(g,a.property.name)),k.lazyAssign(k.nonComputedMember(g,a.property.name),"{}"));m=k.nonComputedMember(g,a.property.name);if(k.state.expensiveChecks||Kb(a.property.name))m=k.ensureSafeObject(m);k.assign(b,m);d&&(d.computed=!1,d.name=a.property.name)}},
function(){k.assign(b,"undefined")});c(b)},!!e);break;case s.CallExpression:b=b||this.nextId();a.filter?(h=k.filter(a.callee.name),l=[],q(a.arguments,function(a){var b=k.nextId();k.recurse(a,b);l.push(b)}),m=h+"("+l.join(",")+")",k.assign(b,m),c(b)):(h=k.nextId(),g={},l=[],k.recurse(a.callee,h,g,function(){k.if_(k.notNull(h),function(){k.addEnsureSafeFunction(h);q(a.arguments,function(a){k.recurse(a,k.nextId(),void 0,function(a){l.push(k.ensureSafeObject(a))})});g.name?(k.state.expensiveChecks||k.addEnsureSafeObject(g.context),
m=k.member(g.context,g.name,g.computed)+"("+l.join(",")+")"):m=h+"("+l.join(",")+")";m=k.ensureSafeObject(m);k.assign(b,m)},function(){k.assign(b,"undefined")});c(b)}));break;case s.AssignmentExpression:h=this.nextId();g={};if(!qd(a.left))throw ba("lval");this.recurse(a.left,void 0,g,function(){k.if_(k.notNull(g.context),function(){k.recurse(a.right,h);k.addEnsureSafeObject(k.member(g.context,g.name,g.computed));k.addEnsureSafeAssignContext(g.context);m=k.member(g.context,g.name,g.computed)+a.operator+
h;k.assign(b,m);c(b||m)})},1);break;case s.ArrayExpression:l=[];q(a.elements,function(a){k.recurse(a,k.nextId(),void 0,function(a){l.push(a)})});m="["+l.join(",")+"]";this.assign(b,m);c(m);break;case s.ObjectExpression:l=[];n=!1;q(a.properties,function(a){a.computed&&(n=!0)});n?(b=b||this.nextId(),this.assign(b,"{}"),q(a.properties,function(a){a.computed?(g=k.nextId(),k.recurse(a.key,g)):g=a.key.type===s.Identifier?a.key.name:""+a.key.value;h=k.nextId();k.recurse(a.value,h);k.assign(k.member(b,g,
a.computed),h)})):(q(a.properties,function(b){k.recurse(b.value,a.constant?void 0:k.nextId(),void 0,function(a){l.push(k.escape(b.key.type===s.Identifier?b.key.name:""+b.key.value)+":"+a)})}),m="{"+l.join(",")+"}",this.assign(b,m));c(b||m);break;case s.ThisExpression:this.assign(b,"s");c("s");break;case s.LocalsExpression:this.assign(b,"l");c("l");break;case s.NGValueParameter:this.assign(b,"v"),c("v")}},getHasOwnProperty:function(a,b){var d=a+"."+b,c=this.current().own;c.hasOwnProperty(d)||(c[d]=
this.nextId(!1,a+"&&("+this.escape(b)+" in "+a+")"));return c[d]},assign:function(a,b){if(a)return this.current().body.push(a,"=",b,";"),a},filter:function(a){this.state.filters.hasOwnProperty(a)||(this.state.filters[a]=this.nextId(!0));return this.state.filters[a]},ifDefined:function(a,b){return"ifDefined("+a+","+this.escape(b)+")"},plus:function(a,b){return"plus("+a+","+b+")"},return_:function(a){this.current().body.push("return ",a,";")},if_:function(a,b,d){if(!0===a)b();else{var c=this.current().body;
c.push("if(",a,"){");b();c.push("}");d&&(c.push("else{"),d(),c.push("}"))}},not:function(a){return"!("+a+")"},notNull:function(a){return a+"!=null"},nonComputedMember:function(a,b){var d=/[^$_a-zA-Z0-9]/g;return/[$_a-zA-Z][$_a-zA-Z0-9]*/.test(b)?a+"."+b:a+'["'+b.replace(d,this.stringEscapeFn)+'"]'},computedMember:function(a,b){return a+"["+b+"]"},member:function(a,b,d){return d?this.computedMember(a,b):this.nonComputedMember(a,b)},addEnsureSafeObject:function(a){this.current().body.push(this.ensureSafeObject(a),
";")},addEnsureSafeMemberName:function(a){this.current().body.push(this.ensureSafeMemberName(a),";")},addEnsureSafeFunction:function(a){this.current().body.push(this.ensureSafeFunction(a),";")},addEnsureSafeAssignContext:function(a){this.current().body.push(this.ensureSafeAssignContext(a),";")},ensureSafeObject:function(a){return"ensureSafeObject("+a+",text)"},ensureSafeMemberName:function(a){return"ensureSafeMemberName("+a+",text)"},ensureSafeFunction:function(a){return"ensureSafeFunction("+a+",text)"},
getStringValue:function(a){this.assign(a,"getStringValue("+a+")")},ensureSafeAssignContext:function(a){return"ensureSafeAssignContext("+a+",text)"},lazyRecurse:function(a,b,d,c,e,f){var g=this;return function(){g.recurse(a,b,d,c,e,f)}},lazyAssign:function(a,b){var d=this;return function(){d.assign(a,b)}},stringEscapeRegex:/[^ a-zA-Z0-9]/g,stringEscapeFn:function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)},escape:function(a){if(I(a))return"'"+a.replace(this.stringEscapeRegex,this.stringEscapeFn)+
"'";if(Q(a))return a.toString();if(!0===a)return"true";if(!1===a)return"false";if(null===a)return"null";if("undefined"===typeof a)return"undefined";throw ba("esc");},nextId:function(a,b){var d="v"+this.state.nextId++;a||this.current().vars.push(d+(b?"="+b:""));return d},current:function(){return this.state[this.state.computing]}};ud.prototype={compile:function(a,b){var d=this,c=this.astBuilder.ast(a);this.expression=a;this.expensiveChecks=b;Z(c,d.$filter);var e,f;if(e=rd(c))f=this.recurse(e);e=pd(c.body);
var g;e&&(g=[],q(e,function(a,b){var c=d.recurse(a);a.input=c;g.push(c);a.watchId=b}));var h=[];q(c.body,function(a){h.push(d.recurse(a.expression))});e=0===c.body.length?C:1===c.body.length?h[0]:function(a,b){var c;q(h,function(d){c=d(a,b)});return c};f&&(e.assign=function(a,b,c){return f(a,c,b)});g&&(e.inputs=g);e.literal=sd(c);e.constant=c.constant;return e},recurse:function(a,b,d){var c,e,f=this,g;if(a.input)return this.inputs(a.input,a.watchId);switch(a.type){case s.Literal:return this.value(a.value,
b);case s.UnaryExpression:return e=this.recurse(a.argument),this["unary"+a.operator](e,b);case s.BinaryExpression:return c=this.recurse(a.left),e=this.recurse(a.right),this["binary"+a.operator](c,e,b);case s.LogicalExpression:return c=this.recurse(a.left),e=this.recurse(a.right),this["binary"+a.operator](c,e,b);case s.ConditionalExpression:return this["ternary?:"](this.recurse(a.test),this.recurse(a.alternate),this.recurse(a.consequent),b);case s.Identifier:return Ua(a.name,f.expression),f.identifier(a.name,
f.expensiveChecks||Kb(a.name),b,d,f.expression);case s.MemberExpression:return c=this.recurse(a.object,!1,!!d),a.computed||(Ua(a.property.name,f.expression),e=a.property.name),a.computed&&(e=this.recurse(a.property)),a.computed?this.computedMember(c,e,b,d,f.expression):this.nonComputedMember(c,e,f.expensiveChecks,b,d,f.expression);case s.CallExpression:return g=[],q(a.arguments,function(a){g.push(f.recurse(a))}),a.filter&&(e=this.$filter(a.callee.name)),a.filter||(e=this.recurse(a.callee,!0)),a.filter?
function(a,c,d,f){for(var n=[],p=0;p<g.length;++p)n.push(g[p](a,c,d,f));a=e.apply(void 0,n,f);return b?{context:void 0,name:void 0,value:a}:a}:function(a,c,d,m){var n=e(a,c,d,m),p;if(null!=n.value){qa(n.context,f.expression);nd(n.value,f.expression);p=[];for(var q=0;q<g.length;++q)p.push(qa(g[q](a,c,d,m),f.expression));p=qa(n.value.apply(n.context,p),f.expression)}return b?{value:p}:p};case s.AssignmentExpression:return c=this.recurse(a.left,!0,1),e=this.recurse(a.right),function(a,d,g,m){var n=c(a,
d,g,m);a=e(a,d,g,m);qa(n.value,f.expression);Jb(n.context);n.context[n.name]=a;return b?{value:a}:a};case s.ArrayExpression:return g=[],q(a.elements,function(a){g.push(f.recurse(a))}),function(a,c,d,e){for(var f=[],p=0;p<g.length;++p)f.push(g[p](a,c,d,e));return b?{value:f}:f};case s.ObjectExpression:return g=[],q(a.properties,function(a){a.computed?g.push({key:f.recurse(a.key),computed:!0,value:f.recurse(a.value)}):g.push({key:a.key.type===s.Identifier?a.key.name:""+a.key.value,computed:!1,value:f.recurse(a.value)})}),
function(a,c,d,e){for(var f={},p=0;p<g.length;++p)g[p].computed?f[g[p].key(a,c,d,e)]=g[p].value(a,c,d,e):f[g[p].key]=g[p].value(a,c,d,e);return b?{value:f}:f};case s.ThisExpression:return function(a){return b?{value:a}:a};case s.LocalsExpression:return function(a,c){return b?{value:c}:c};case s.NGValueParameter:return function(a,c,d){return b?{value:d}:d}}},"unary+":function(a,b){return function(d,c,e,f){d=a(d,c,e,f);d=v(d)?+d:0;return b?{value:d}:d}},"unary-":function(a,b){return function(d,c,e,
f){d=a(d,c,e,f);d=v(d)?-d:0;return b?{value:d}:d}},"unary!":function(a,b){return function(d,c,e,f){d=!a(d,c,e,f);return b?{value:d}:d}},"binary+":function(a,b,d){return function(c,e,f,g){var h=a(c,e,f,g);c=b(c,e,f,g);h=od(h,c);return d?{value:h}:h}},"binary-":function(a,b,d){return function(c,e,f,g){var h=a(c,e,f,g);c=b(c,e,f,g);h=(v(h)?h:0)-(v(c)?c:0);return d?{value:h}:h}},"binary*":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)*b(c,e,f,g);return d?{value:c}:c}},"binary/":function(a,b,d){return function(c,
e,f,g){c=a(c,e,f,g)/b(c,e,f,g);return d?{value:c}:c}},"binary%":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)%b(c,e,f,g);return d?{value:c}:c}},"binary===":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)===b(c,e,f,g);return d?{value:c}:c}},"binary!==":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)!==b(c,e,f,g);return d?{value:c}:c}},"binary==":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)==b(c,e,f,g);return d?{value:c}:c}},"binary!=":function(a,b,d){return function(c,
e,f,g){c=a(c,e,f,g)!=b(c,e,f,g);return d?{value:c}:c}},"binary<":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)<b(c,e,f,g);return d?{value:c}:c}},"binary>":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)>b(c,e,f,g);return d?{value:c}:c}},"binary<=":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)<=b(c,e,f,g);return d?{value:c}:c}},"binary>=":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)>=b(c,e,f,g);return d?{value:c}:c}},"binary&&":function(a,b,d){return function(c,e,f,g){c=
a(c,e,f,g)&&b(c,e,f,g);return d?{value:c}:c}},"binary||":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)||b(c,e,f,g);return d?{value:c}:c}},"ternary?:":function(a,b,d,c){return function(e,f,g,h){e=a(e,f,g,h)?b(e,f,g,h):d(e,f,g,h);return c?{value:e}:e}},value:function(a,b){return function(){return b?{context:void 0,name:void 0,value:a}:a}},identifier:function(a,b,d,c,e){return function(f,g,h,k){f=g&&a in g?g:f;c&&1!==c&&f&&!f[a]&&(f[a]={});g=f?f[a]:void 0;b&&qa(g,e);return d?{context:f,name:a,
value:g}:g}},computedMember:function(a,b,d,c,e){return function(f,g,h,k){var l=a(f,g,h,k),m,n;null!=l&&(m=b(f,g,h,k),m+="",Ua(m,e),c&&1!==c&&(Jb(l),l&&!l[m]&&(l[m]={})),n=l[m],qa(n,e));return d?{context:l,name:m,value:n}:n}},nonComputedMember:function(a,b,d,c,e,f){return function(g,h,k,l){g=a(g,h,k,l);e&&1!==e&&(Jb(g),g&&!g[b]&&(g[b]={}));h=null!=g?g[b]:void 0;(d||Kb(b))&&qa(h,f);return c?{context:g,name:b,value:h}:h}},inputs:function(a,b){return function(d,c,e,f){return f?f[b]:a(d,c,e)}}};var kc=
function(a,b,d){this.lexer=a;this.$filter=b;this.options=d;this.ast=new s(a,d);this.astCompiler=d.csp?new ud(this.ast,b):new td(this.ast,b)};kc.prototype={constructor:kc,parse:function(a){return this.astCompiler.compile(a,this.options.expensiveChecks)}};var mg=Object.prototype.valueOf,ra=O("$sce"),ma={HTML:"html",CSS:"css",URL:"url",RESOURCE_URL:"resourceUrl",JS:"js"},og=O("$compile"),X=F.document.createElement("a"),yd=pa(F.location.href);zd.$inject=["$document"];Lc.$inject=["$provide"];var Gd=22,
Fd=".",mc="0";Ad.$inject=["$locale"];Cd.$inject=["$locale"];var zg={yyyy:W("FullYear",4,0,!1,!0),yy:W("FullYear",2,0,!0,!0),y:W("FullYear",1,0,!1,!0),MMMM:kb("Month"),MMM:kb("Month",!0),MM:W("Month",2,1),M:W("Month",1,1),LLLL:kb("Month",!1,!0),dd:W("Date",2),d:W("Date",1),HH:W("Hours",2),H:W("Hours",1),hh:W("Hours",2,-12),h:W("Hours",1,-12),mm:W("Minutes",2),m:W("Minutes",1),ss:W("Seconds",2),s:W("Seconds",1),sss:W("Milliseconds",3),EEEE:kb("Day"),EEE:kb("Day",!0),a:function(a,b){return 12>a.getHours()?
b.AMPMS[0]:b.AMPMS[1]},Z:function(a,b,d){a=-1*d;return a=(0<=a?"+":"")+(Lb(Math[0<a?"floor":"ceil"](a/60),2)+Lb(Math.abs(a%60),2))},ww:Id(2),w:Id(1),G:nc,GG:nc,GGG:nc,GGGG:function(a,b){return 0>=a.getFullYear()?b.ERANAMES[0]:b.ERANAMES[1]}},yg=/((?:[^yMLdHhmsaZEwG']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|m+|s+|a|Z|G+|w+))(.*)/,xg=/^\-?\d+$/;Bd.$inject=["$locale"];var sg=ca(L),tg=ca(ub);Dd.$inject=["$parse"];var oe=ca({restrict:"E",compile:function(a,b){if(!b.href&&!b.xlinkHref)return function(a,
b){if("a"===b[0].nodeName.toLowerCase()){var e="[object SVGAnimatedString]"===ja.call(b.prop("href"))?"xlink:href":"href";b.on("click",function(a){b.attr(e)||a.preventDefault()})}}}}),vb={};q(Eb,function(a,b){function d(a,d,e){a.$watch(e[c],function(a){e.$set(b,!!a)})}if("multiple"!=a){var c=wa("ng-"+b),e=d;"checked"===a&&(e=function(a,b,e){e.ngModel!==e[c]&&d(a,b,e)});vb[c]=function(){return{restrict:"A",priority:100,link:e}}}});q(bd,function(a,b){vb[b]=function(){return{priority:100,link:function(a,
c,e){if("ngPattern"===b&&"/"==e.ngPattern.charAt(0)&&(c=e.ngPattern.match(Bg))){e.$set("ngPattern",new RegExp(c[1],c[2]));return}a.$watch(e[b],function(a){e.$set(b,a)})}}}});q(["src","srcset","href"],function(a){var b=wa("ng-"+a);vb[b]=function(){return{priority:99,link:function(d,c,e){var f=a,g=a;"href"===a&&"[object SVGAnimatedString]"===ja.call(c.prop("href"))&&(g="xlinkHref",e.$attr[g]="xlink:href",f=null);e.$observe(b,function(b){b?(e.$set(g,b),Ba&&f&&c.prop(f,e[g])):"href"===a&&e.$set(g,null)})}}}});
var Mb={$addControl:C,$$renameControl:function(a,b){a.$name=b},$removeControl:C,$setValidity:C,$setDirty:C,$setPristine:C,$setSubmitted:C};Jd.$inject=["$element","$attrs","$scope","$animate","$interpolate"];var Sd=function(a){return["$timeout","$parse",function(b,d){function c(a){return""===a?d('this[""]').assign:d(a).assign||C}return{name:"form",restrict:a?"EAC":"E",require:["form","^^?form"],controller:Jd,compile:function(d,f){d.addClass(Va).addClass(ob);var g=f.name?"name":a&&f.ngForm?"ngForm":
!1;return{pre:function(a,d,e,f){var n=f[0];if(!("action"in e)){var p=function(b){a.$apply(function(){n.$commitViewValue();n.$setSubmitted()});b.preventDefault()};d[0].addEventListener("submit",p,!1);d.on("$destroy",function(){b(function(){d[0].removeEventListener("submit",p,!1)},0,!1)})}(f[1]||n.$$parentForm).$addControl(n);var q=g?c(n.$name):C;g&&(q(a,n),e.$observe(g,function(b){n.$name!==b&&(q(a,void 0),n.$$parentForm.$$renameControl(n,b),q=c(n.$name),q(a,n))}));d.on("$destroy",function(){n.$$parentForm.$removeControl(n);
q(a,void 0);P(n,Mb)})}}}}}]},pe=Sd(),Ce=Sd(!0),Ag=/^\d{4,}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+(?:[+-][0-2]\d:[0-5]\d|Z)$/,Jg=/^[a-z][a-z\d.+-]*:\/*(?:[^:@]+(?::[^@]+)?@)?(?:[^\s:/?#]+|\[[a-f\d:]+\])(?::\d+)?(?:\/[^?#]*)?(?:\?[^#]*)?(?:#.*)?$/i,Kg=/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,Lg=/^\s*(\-|\+)?(\d+|(\d*(\.\d*)))([eE][+-]?\d+)?\s*$/,Td=/^(\d{4,})-(\d{2})-(\d{2})$/,Ud=/^(\d{4,})-(\d\d)-(\d\d)T(\d\d):(\d\d)(?::(\d\d)(\.\d{1,3})?)?$/,
qc=/^(\d{4,})-W(\d\d)$/,Vd=/^(\d{4,})-(\d\d)$/,Wd=/^(\d\d):(\d\d)(?::(\d\d)(\.\d{1,3})?)?$/,Ld=S();q(["date","datetime-local","month","time","week"],function(a){Ld[a]=!0});var Xd={text:function(a,b,d,c,e,f){lb(a,b,d,c,e,f);oc(c)},date:mb("date",Td,Ob(Td,["yyyy","MM","dd"]),"yyyy-MM-dd"),"datetime-local":mb("datetimelocal",Ud,Ob(Ud,"yyyy MM dd HH mm ss sss".split(" ")),"yyyy-MM-ddTHH:mm:ss.sss"),time:mb("time",Wd,Ob(Wd,["HH","mm","ss","sss"]),"HH:mm:ss.sss"),week:mb("week",qc,function(a,b){if(ha(a))return a;
if(I(a)){qc.lastIndex=0;var d=qc.exec(a);if(d){var c=+d[1],e=+d[2],f=d=0,g=0,h=0,k=Hd(c),e=7*(e-1);b&&(d=b.getHours(),f=b.getMinutes(),g=b.getSeconds(),h=b.getMilliseconds());return new Date(c,0,k.getDate()+e,d,f,g,h)}}return NaN},"yyyy-Www"),month:mb("month",Vd,Ob(Vd,["yyyy","MM"]),"yyyy-MM"),number:function(a,b,d,c,e,f){Md(a,b,d,c);lb(a,b,d,c,e,f);c.$$parserName="number";c.$parsers.push(function(a){if(c.$isEmpty(a))return null;if(Lg.test(a))return parseFloat(a)});c.$formatters.push(function(a){if(!c.$isEmpty(a)){if(!Q(a))throw nb("numfmt",
a);a=a.toString()}return a});if(v(d.min)||d.ngMin){var g;c.$validators.min=function(a){return c.$isEmpty(a)||y(g)||a>=g};d.$observe("min",function(a){v(a)&&!Q(a)&&(a=parseFloat(a,10));g=Q(a)&&!isNaN(a)?a:void 0;c.$validate()})}if(v(d.max)||d.ngMax){var h;c.$validators.max=function(a){return c.$isEmpty(a)||y(h)||a<=h};d.$observe("max",function(a){v(a)&&!Q(a)&&(a=parseFloat(a,10));h=Q(a)&&!isNaN(a)?a:void 0;c.$validate()})}},url:function(a,b,d,c,e,f){lb(a,b,d,c,e,f);oc(c);c.$$parserName="url";c.$validators.url=
function(a,b){var d=a||b;return c.$isEmpty(d)||Jg.test(d)}},email:function(a,b,d,c,e,f){lb(a,b,d,c,e,f);oc(c);c.$$parserName="email";c.$validators.email=function(a,b){var d=a||b;return c.$isEmpty(d)||Kg.test(d)}},radio:function(a,b,d,c){y(d.name)&&b.attr("name",++pb);b.on("click",function(a){b[0].checked&&c.$setViewValue(d.value,a&&a.type)});c.$render=function(){b[0].checked=d.value==c.$viewValue};d.$observe("value",c.$render)},checkbox:function(a,b,d,c,e,f,g,h){var k=Nd(h,a,"ngTrueValue",d.ngTrueValue,
!0),l=Nd(h,a,"ngFalseValue",d.ngFalseValue,!1);b.on("click",function(a){c.$setViewValue(b[0].checked,a&&a.type)});c.$render=function(){b[0].checked=c.$viewValue};c.$isEmpty=function(a){return!1===a};c.$formatters.push(function(a){return na(a,k)});c.$parsers.push(function(a){return a?k:l})},hidden:C,button:C,submit:C,reset:C,file:C},Fc=["$browser","$sniffer","$filter","$parse",function(a,b,d,c){return{restrict:"E",require:["?ngModel"],link:{pre:function(e,f,g,h){h[0]&&(Xd[L(g.type)]||Xd.text)(e,f,
g,h[0],b,a,d,c)}}}}],Mg=/^(true|false|\d+)$/,Ue=function(){return{restrict:"A",priority:100,compile:function(a,b){return Mg.test(b.ngValue)?function(a,b,e){e.$set("value",a.$eval(e.ngValue))}:function(a,b,e){a.$watch(e.ngValue,function(a){e.$set("value",a)})}}}},ue=["$compile",function(a){return{restrict:"AC",compile:function(b){a.$$addBindingClass(b);return function(b,c,e){a.$$addBindingInfo(c,e.ngBind);c=c[0];b.$watch(e.ngBind,function(a){c.textContent=y(a)?"":a})}}}}],we=["$interpolate","$compile",
function(a,b){return{compile:function(d){b.$$addBindingClass(d);return function(c,d,f){c=a(d.attr(f.$attr.ngBindTemplate));b.$$addBindingInfo(d,c.expressions);d=d[0];f.$observe("ngBindTemplate",function(a){d.textContent=y(a)?"":a})}}}}],ve=["$sce","$parse","$compile",function(a,b,d){return{restrict:"A",compile:function(c,e){var f=b(e.ngBindHtml),g=b(e.ngBindHtml,function(b){return a.valueOf(b)});d.$$addBindingClass(c);return function(b,c,e){d.$$addBindingInfo(c,e.ngBindHtml);b.$watch(g,function(){var d=
f(b);c.html(a.getTrustedHtml(d)||"")})}}}}],Te=ca({restrict:"A",require:"ngModel",link:function(a,b,d,c){c.$viewChangeListeners.push(function(){a.$eval(d.ngChange)})}}),xe=pc("",!0),ze=pc("Odd",0),ye=pc("Even",1),Ae=Ma({compile:function(a,b){b.$set("ngCloak",void 0);a.removeClass("ng-cloak")}}),Be=[function(){return{restrict:"A",scope:!0,controller:"@",priority:500}}],Kc={},Ng={blur:!0,focus:!0};q("click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress submit focus blur copy cut paste".split(" "),
function(a){var b=wa("ng-"+a);Kc[b]=["$parse","$rootScope",function(d,c){return{restrict:"A",compile:function(e,f){var g=d(f[b],null,!0);return function(b,d){d.on(a,function(d){var e=function(){g(b,{$event:d})};Ng[a]&&c.$$phase?b.$evalAsync(e):b.$apply(e)})}}}}]});var Ee=["$animate","$compile",function(a,b){return{multiElement:!0,transclude:"element",priority:600,terminal:!0,restrict:"A",$$tlb:!0,link:function(d,c,e,f,g){var h,k,l;d.$watch(e.ngIf,function(d){d?k||g(function(d,f){k=f;d[d.length++]=
b.$$createComment("end ngIf",e.ngIf);h={clone:d};a.enter(d,c.parent(),c)}):(l&&(l.remove(),l=null),k&&(k.$destroy(),k=null),h&&(l=tb(h.clone),a.leave(l).then(function(){l=null}),h=null))})}}}],Fe=["$templateRequest","$anchorScroll","$animate",function(a,b,d){return{restrict:"ECA",priority:400,terminal:!0,transclude:"element",controller:da.noop,compile:function(c,e){var f=e.ngInclude||e.src,g=e.onload||"",h=e.autoscroll;return function(c,e,m,n,p){var q=0,s,z,r,D=function(){z&&(z.remove(),z=null);s&&
(s.$destroy(),s=null);r&&(d.leave(r).then(function(){z=null}),z=r,r=null)};c.$watch(f,function(f){var m=function(){!v(h)||h&&!c.$eval(h)||b()},w=++q;f?(a(f,!0).then(function(a){if(!c.$$destroyed&&w===q){var b=c.$new();n.template=a;a=p(b,function(a){D();d.enter(a,null,e).then(m)});s=b;r=a;s.$emit("$includeContentLoaded",f);c.$eval(g)}},function(){c.$$destroyed||w!==q||(D(),c.$emit("$includeContentError",f))}),c.$emit("$includeContentRequested",f)):(D(),n.template=null)})}}}}],We=["$compile",function(a){return{restrict:"ECA",
priority:-400,require:"ngInclude",link:function(b,d,c,e){ja.call(d[0]).match(/SVG/)?(d.empty(),a(Nc(e.template,F.document).childNodes)(b,function(a){d.append(a)},{futureParentElement:d})):(d.html(e.template),a(d.contents())(b))}}}],Ge=Ma({priority:450,compile:function(){return{pre:function(a,b,d){a.$eval(d.ngInit)}}}}),Se=function(){return{restrict:"A",priority:100,require:"ngModel",link:function(a,b,d,c){var e=b.attr(d.$attr.ngList)||", ",f="false"!==d.ngTrim,g=f?V(e):e;c.$parsers.push(function(a){if(!y(a)){var b=
[];a&&q(a.split(g),function(a){a&&b.push(f?V(a):a)});return b}});c.$formatters.push(function(a){if(K(a))return a.join(e)});c.$isEmpty=function(a){return!a||!a.length}}}},ob="ng-valid",Od="ng-invalid",Va="ng-pristine",Nb="ng-dirty",Qd="ng-pending",nb=O("ngModel"),Og=["$scope","$exceptionHandler","$attrs","$element","$parse","$animate","$timeout","$rootScope","$q","$interpolate",function(a,b,d,c,e,f,g,h,k,l){this.$modelValue=this.$viewValue=Number.NaN;this.$$rawModelValue=void 0;this.$validators={};
this.$asyncValidators={};this.$parsers=[];this.$formatters=[];this.$viewChangeListeners=[];this.$untouched=!0;this.$touched=!1;this.$pristine=!0;this.$dirty=!1;this.$valid=!0;this.$invalid=!1;this.$error={};this.$$success={};this.$pending=void 0;this.$name=l(d.name||"",!1)(a);this.$$parentForm=Mb;var m=e(d.ngModel),n=m.assign,p=m,s=n,F=null,z,r=this;this.$$setOptions=function(a){if((r.$options=a)&&a.getterSetter){var b=e(d.ngModel+"()"),f=e(d.ngModel+"($$$p)");p=function(a){var c=m(a);E(c)&&(c=b(a));
return c};s=function(a,b){E(m(a))?f(a,{$$$p:b}):n(a,b)}}else if(!m.assign)throw nb("nonassign",d.ngModel,ua(c));};this.$render=C;this.$isEmpty=function(a){return y(a)||""===a||null===a||a!==a};this.$$updateEmptyClasses=function(a){r.$isEmpty(a)?(f.removeClass(c,"ng-not-empty"),f.addClass(c,"ng-empty")):(f.removeClass(c,"ng-empty"),f.addClass(c,"ng-not-empty"))};var D=0;Kd({ctrl:this,$element:c,set:function(a,b){a[b]=!0},unset:function(a,b){delete a[b]},$animate:f});this.$setPristine=function(){r.$dirty=
!1;r.$pristine=!0;f.removeClass(c,Nb);f.addClass(c,Va)};this.$setDirty=function(){r.$dirty=!0;r.$pristine=!1;f.removeClass(c,Va);f.addClass(c,Nb);r.$$parentForm.$setDirty()};this.$setUntouched=function(){r.$touched=!1;r.$untouched=!0;f.setClass(c,"ng-untouched","ng-touched")};this.$setTouched=function(){r.$touched=!0;r.$untouched=!1;f.setClass(c,"ng-touched","ng-untouched")};this.$rollbackViewValue=function(){g.cancel(F);r.$viewValue=r.$$lastCommittedViewValue;r.$render()};this.$validate=function(){if(!Q(r.$modelValue)||
!isNaN(r.$modelValue)){var a=r.$$rawModelValue,b=r.$valid,c=r.$modelValue,d=r.$options&&r.$options.allowInvalid;r.$$runValidators(a,r.$$lastCommittedViewValue,function(e){d||b===e||(r.$modelValue=e?a:void 0,r.$modelValue!==c&&r.$$writeModelToScope())})}};this.$$runValidators=function(a,b,c){function d(){var c=!0;q(r.$validators,function(d,e){var g=d(a,b);c=c&&g;f(e,g)});return c?!0:(q(r.$asyncValidators,function(a,b){f(b,null)}),!1)}function e(){var c=[],d=!0;q(r.$asyncValidators,function(e,g){var h=
e(a,b);if(!h||!E(h.then))throw nb("nopromise",h);f(g,void 0);c.push(h.then(function(){f(g,!0)},function(){d=!1;f(g,!1)}))});c.length?k.all(c).then(function(){g(d)},C):g(!0)}function f(a,b){h===D&&r.$setValidity(a,b)}function g(a){h===D&&c(a)}D++;var h=D;(function(){var a=r.$$parserName||"parse";if(y(z))f(a,null);else return z||(q(r.$validators,function(a,b){f(b,null)}),q(r.$asyncValidators,function(a,b){f(b,null)})),f(a,z),z;return!0})()?d()?e():g(!1):g(!1)};this.$commitViewValue=function(){var a=
r.$viewValue;g.cancel(F);if(r.$$lastCommittedViewValue!==a||""===a&&r.$$hasNativeValidators)r.$$updateEmptyClasses(a),r.$$lastCommittedViewValue=a,r.$pristine&&this.$setDirty(),this.$$parseAndValidate()};this.$$parseAndValidate=function(){var b=r.$$lastCommittedViewValue;if(z=y(b)?void 0:!0)for(var c=0;c<r.$parsers.length;c++)if(b=r.$parsers[c](b),y(b)){z=!1;break}Q(r.$modelValue)&&isNaN(r.$modelValue)&&(r.$modelValue=p(a));var d=r.$modelValue,e=r.$options&&r.$options.allowInvalid;r.$$rawModelValue=
b;e&&(r.$modelValue=b,r.$modelValue!==d&&r.$$writeModelToScope());r.$$runValidators(b,r.$$lastCommittedViewValue,function(a){e||(r.$modelValue=a?b:void 0,r.$modelValue!==d&&r.$$writeModelToScope())})};this.$$writeModelToScope=function(){s(a,r.$modelValue);q(r.$viewChangeListeners,function(a){try{a()}catch(c){b(c)}})};this.$setViewValue=function(a,b){r.$viewValue=a;r.$options&&!r.$options.updateOnDefault||r.$$debounceViewValueCommit(b)};this.$$debounceViewValueCommit=function(b){var c=0,d=r.$options;
d&&v(d.debounce)&&(d=d.debounce,Q(d)?c=d:Q(d[b])?c=d[b]:Q(d["default"])&&(c=d["default"]));g.cancel(F);c?F=g(function(){r.$commitViewValue()},c):h.$$phase?r.$commitViewValue():a.$apply(function(){r.$commitViewValue()})};a.$watch(function(){var b=p(a);if(b!==r.$modelValue&&(r.$modelValue===r.$modelValue||b===b)){r.$modelValue=r.$$rawModelValue=b;z=void 0;for(var c=r.$formatters,d=c.length,e=b;d--;)e=c[d](e);r.$viewValue!==e&&(r.$$updateEmptyClasses(e),r.$viewValue=r.$$lastCommittedViewValue=e,r.$render(),
r.$$runValidators(b,e,C))}return b})}],Re=["$rootScope",function(a){return{restrict:"A",require:["ngModel","^?form","^?ngModelOptions"],controller:Og,priority:1,compile:function(b){b.addClass(Va).addClass("ng-untouched").addClass(ob);return{pre:function(a,b,e,f){var g=f[0];b=f[1]||g.$$parentForm;g.$$setOptions(f[2]&&f[2].$options);b.$addControl(g);e.$observe("name",function(a){g.$name!==a&&g.$$parentForm.$$renameControl(g,a)});a.$on("$destroy",function(){g.$$parentForm.$removeControl(g)})},post:function(b,
c,e,f){var g=f[0];if(g.$options&&g.$options.updateOn)c.on(g.$options.updateOn,function(a){g.$$debounceViewValueCommit(a&&a.type)});c.on("blur",function(){g.$touched||(a.$$phase?b.$evalAsync(g.$setTouched):b.$apply(g.$setTouched))})}}}}}],Pg=/(\s+|^)default(\s+|$)/,Ve=function(){return{restrict:"A",controller:["$scope","$attrs",function(a,b){var d=this;this.$options=oa(a.$eval(b.ngModelOptions));v(this.$options.updateOn)?(this.$options.updateOnDefault=!1,this.$options.updateOn=V(this.$options.updateOn.replace(Pg,
function(){d.$options.updateOnDefault=!0;return" "}))):this.$options.updateOnDefault=!0}]}},He=Ma({terminal:!0,priority:1E3}),Qg=O("ngOptions"),Rg=/^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+group\s+by\s+([\s\S]+?))?(?:\s+disable\s+when\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?$/,Pe=["$compile","$document","$parse",function(a,b,d){function c(a,b,c){function e(a,b,c,d,f){this.selectValue=a;this.viewValue=
b;this.label=c;this.group=d;this.disabled=f}function f(a){var b;if(!q&&xa(a))b=a;else{b=[];for(var c in a)a.hasOwnProperty(c)&&"$"!==c.charAt(0)&&b.push(c)}return b}var n=a.match(Rg);if(!n)throw Qg("iexp",a,ua(b));var p=n[5]||n[7],q=n[6];a=/ as /.test(n[0])&&n[1];var s=n[9];b=d(n[2]?n[1]:p);var z=a&&d(a)||b,r=s&&d(s),v=s?function(a,b){return r(c,b)}:function(a){return Ga(a)},u=function(a,b){return v(a,H(a,b))},t=d(n[2]||n[1]),w=d(n[3]||""),y=d(n[4]||""),B=d(n[8]),A={},H=q?function(a,b){A[q]=b;A[p]=
a;return A}:function(a){A[p]=a;return A};return{trackBy:s,getTrackByValue:u,getWatchables:d(B,function(a){var b=[];a=a||[];for(var d=f(a),e=d.length,g=0;g<e;g++){var h=a===d?g:d[g],l=a[h],h=H(l,h),l=v(l,h);b.push(l);if(n[2]||n[1])l=t(c,h),b.push(l);n[4]&&(h=y(c,h),b.push(h))}return b}),getOptions:function(){for(var a=[],b={},d=B(c)||[],g=f(d),h=g.length,n=0;n<h;n++){var p=d===g?n:g[n],q=H(d[p],p),r=z(c,q),p=v(r,q),x=t(c,q),A=w(c,q),q=y(c,q),r=new e(p,r,x,A,q);a.push(r);b[p]=r}return{items:a,selectValueMap:b,
getOptionFromViewValue:function(a){return b[u(a)]},getViewValueFromOption:function(a){return s?da.copy(a.viewValue):a.viewValue}}}}}var e=F.document.createElement("option"),f=F.document.createElement("optgroup");return{restrict:"A",terminal:!0,require:["select","ngModel"],link:{pre:function(a,b,c,d){d[0].registerOption=C},post:function(d,h,k,l){function m(a,b){a.element=b;b.disabled=a.disabled;a.label!==b.label&&(b.label=a.label,b.textContent=a.label);a.value!==b.value&&(b.value=a.selectValue)}function n(){var a=
w&&p.readValue();if(w)for(var b=w.items.length-1;0<=b;b--){var c=w.items[b];c.group?Db(c.element.parentNode):Db(c.element)}w=C.getOptions();var d={};u&&h.prepend(z);w.items.forEach(function(a){var b;if(v(a.group)){b=d[a.group];b||(b=f.cloneNode(!1),B.appendChild(b),b.label=a.group,d[a.group]=b);var c=e.cloneNode(!1)}else b=B,c=e.cloneNode(!1);b.appendChild(c);m(a,c)});h[0].appendChild(B);s.$render();s.$isEmpty(a)||(b=p.readValue(),(C.trackBy||y?na(a,b):a===b)||(s.$setViewValue(b),s.$render()))}var p=
l[0],s=l[1],y=k.multiple,z;l=0;for(var r=h.children(),D=r.length;l<D;l++)if(""===r[l].value){z=r.eq(l);break}var u=!!z,t=G(e.cloneNode(!1));t.val("?");var w,C=c(k.ngOptions,h,d),B=b[0].createDocumentFragment();y?(s.$isEmpty=function(a){return!a||0===a.length},p.writeValue=function(a){w.items.forEach(function(a){a.element.selected=!1});a&&a.forEach(function(a){if(a=w.getOptionFromViewValue(a))a.element.selected=!0})},p.readValue=function(){var a=h.val()||[],b=[];q(a,function(a){(a=w.selectValueMap[a])&&
!a.disabled&&b.push(w.getViewValueFromOption(a))});return b},C.trackBy&&d.$watchCollection(function(){if(K(s.$viewValue))return s.$viewValue.map(function(a){return C.getTrackByValue(a)})},function(){s.$render()})):(p.writeValue=function(a){var b=w.getOptionFromViewValue(a);b?(h[0].value!==b.selectValue&&(t.remove(),u||z.remove(),h[0].value=b.selectValue,b.element.selected=!0),b.element.setAttribute("selected","selected")):null===a||u?(t.remove(),u||h.prepend(z),h.val(""),z.prop("selected",!0),z.attr("selected",
!0)):(u||z.remove(),h.prepend(t),h.val("?"),t.prop("selected",!0),t.attr("selected",!0))},p.readValue=function(){var a=w.selectValueMap[h.val()];return a&&!a.disabled?(u||z.remove(),t.remove(),w.getViewValueFromOption(a)):null},C.trackBy&&d.$watch(function(){return C.getTrackByValue(s.$viewValue)},function(){s.$render()}));u?(z.remove(),a(z)(d),z.removeClass("ng-scope")):z=G(e.cloneNode(!1));h.empty();n();d.$watchCollection(C.getWatchables,n)}}}}],Ie=["$locale","$interpolate","$log",function(a,b,
d){var c=/{}/g,e=/^when(Minus)?(.+)$/;return{link:function(f,g,h){function k(a){g.text(a||"")}var l=h.count,m=h.$attr.when&&g.attr(h.$attr.when),n=h.offset||0,p=f.$eval(m)||{},s={},v=b.startSymbol(),z=b.endSymbol(),r=v+l+"-"+n+z,D=da.noop,u;q(h,function(a,b){var c=e.exec(b);c&&(c=(c[1]?"-":"")+L(c[2]),p[c]=g.attr(h.$attr[b]))});q(p,function(a,d){s[d]=b(a.replace(c,r))});f.$watch(l,function(b){var c=parseFloat(b),e=isNaN(c);e||c in p||(c=a.pluralCat(c-n));c===u||e&&Q(u)&&isNaN(u)||(D(),e=s[c],y(e)?
(null!=b&&d.debug("ngPluralize: no rule defined for '"+c+"' in "+m),D=C,k()):D=f.$watch(e,k),u=c)})}}}],Je=["$parse","$animate","$compile",function(a,b,d){var c=O("ngRepeat"),e=function(a,b,c,d,e,m,n){a[c]=d;e&&(a[e]=m);a.$index=b;a.$first=0===b;a.$last=b===n-1;a.$middle=!(a.$first||a.$last);a.$odd=!(a.$even=0===(b&1))};return{restrict:"A",multiElement:!0,transclude:"element",priority:1E3,terminal:!0,$$tlb:!0,compile:function(f,g){var h=g.ngRepeat,k=d.$$createComment("end ngRepeat",h),l=h.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);
if(!l)throw c("iexp",h);var m=l[1],n=l[2],p=l[3],s=l[4],l=m.match(/^(?:(\s*[\$\w]+)|\(\s*([\$\w]+)\s*,\s*([\$\w]+)\s*\))$/);if(!l)throw c("iidexp",m);var v=l[3]||l[1],z=l[2];if(p&&(!/^[$a-zA-Z_][$a-zA-Z0-9_]*$/.test(p)||/^(null|undefined|this|\$index|\$first|\$middle|\$last|\$even|\$odd|\$parent|\$root|\$id)$/.test(p)))throw c("badident",p);var r,D,u,t,w={$id:Ga};s?r=a(s):(u=function(a,b){return Ga(b)},t=function(a){return a});return function(a,d,f,g,l){r&&(D=function(b,c,d){z&&(w[z]=b);w[v]=c;w.$index=
d;return r(a,w)});var m=S();a.$watchCollection(n,function(f){var g,n,r=d[0],s,x=S(),w,y,C,A,F,E,G;p&&(a[p]=f);if(xa(f))F=f,n=D||u;else for(G in n=D||t,F=[],f)sa.call(f,G)&&"$"!==G.charAt(0)&&F.push(G);w=F.length;G=Array(w);for(g=0;g<w;g++)if(y=f===F?g:F[g],C=f[y],A=n(y,C,g),m[A])E=m[A],delete m[A],x[A]=E,G[g]=E;else{if(x[A])throw q(G,function(a){a&&a.scope&&(m[a.id]=a)}),c("dupes",h,A,C);G[g]={id:A,scope:void 0,clone:void 0};x[A]=!0}for(s in m){E=m[s];A=tb(E.clone);b.leave(A);if(A[0].parentNode)for(g=
0,n=A.length;g<n;g++)A[g].$$NG_REMOVED=!0;E.scope.$destroy()}for(g=0;g<w;g++)if(y=f===F?g:F[g],C=f[y],E=G[g],E.scope){s=r;do s=s.nextSibling;while(s&&s.$$NG_REMOVED);E.clone[0]!=s&&b.move(tb(E.clone),null,r);r=E.clone[E.clone.length-1];e(E.scope,g,v,C,z,y,w)}else l(function(a,c){E.scope=c;var d=k.cloneNode(!1);a[a.length++]=d;b.enter(a,null,r);r=d;E.clone=a;x[E.id]=E;e(E.scope,g,v,C,z,y,w)});m=x})}}}}],Ke=["$animate",function(a){return{restrict:"A",multiElement:!0,link:function(b,d,c){b.$watch(c.ngShow,
function(b){a[b?"removeClass":"addClass"](d,"ng-hide",{tempClasses:"ng-hide-animate"})})}}}],De=["$animate",function(a){return{restrict:"A",multiElement:!0,link:function(b,d,c){b.$watch(c.ngHide,function(b){a[b?"addClass":"removeClass"](d,"ng-hide",{tempClasses:"ng-hide-animate"})})}}}],Le=Ma(function(a,b,d){a.$watch(d.ngStyle,function(a,d){d&&a!==d&&q(d,function(a,c){b.css(c,"")});a&&b.css(a)},!0)}),Me=["$animate","$compile",function(a,b){return{require:"ngSwitch",controller:["$scope",function(){this.cases=
{}}],link:function(d,c,e,f){var g=[],h=[],k=[],l=[],m=function(a,b){return function(){a.splice(b,1)}};d.$watch(e.ngSwitch||e.on,function(c){var d,e;d=0;for(e=k.length;d<e;++d)a.cancel(k[d]);d=k.length=0;for(e=l.length;d<e;++d){var s=tb(h[d].clone);l[d].$destroy();(k[d]=a.leave(s)).then(m(k,d))}h.length=0;l.length=0;(g=f.cases["!"+c]||f.cases["?"])&&q(g,function(c){c.transclude(function(d,e){l.push(e);var f=c.element;d[d.length++]=b.$$createComment("end ngSwitchWhen");h.push({clone:d});a.enter(d,f.parent(),
f)})})})}}}],Ne=Ma({transclude:"element",priority:1200,require:"^ngSwitch",multiElement:!0,link:function(a,b,d,c,e){c.cases["!"+d.ngSwitchWhen]=c.cases["!"+d.ngSwitchWhen]||[];c.cases["!"+d.ngSwitchWhen].push({transclude:e,element:b})}}),Oe=Ma({transclude:"element",priority:1200,require:"^ngSwitch",multiElement:!0,link:function(a,b,d,c,e){c.cases["?"]=c.cases["?"]||[];c.cases["?"].push({transclude:e,element:b})}}),Sg=O("ngTransclude"),Qe=Ma({restrict:"EAC",link:function(a,b,d,c,e){d.ngTransclude===
d.$attr.ngTransclude&&(d.ngTransclude="");if(!e)throw Sg("orphan",ua(b));e(function(a){a.length&&(b.empty(),b.append(a))},null,d.ngTransclude||d.ngTranscludeSlot)}}),qe=["$templateCache",function(a){return{restrict:"E",terminal:!0,compile:function(b,d){"text/ng-template"==d.type&&a.put(d.id,b[0].text)}}}],Tg={$setViewValue:C,$render:C},Ug=["$element","$scope",function(a,b){var d=this,c=new Sa;d.ngModelCtrl=Tg;d.unknownOption=G(F.document.createElement("option"));d.renderUnknownOption=function(b){b=
"? "+Ga(b)+" ?";d.unknownOption.val(b);a.prepend(d.unknownOption);a.val(b)};b.$on("$destroy",function(){d.renderUnknownOption=C});d.removeUnknownOption=function(){d.unknownOption.parent()&&d.unknownOption.remove()};d.readValue=function(){d.removeUnknownOption();return a.val()};d.writeValue=function(b){d.hasOption(b)?(d.removeUnknownOption(),a.val(b),""===b&&d.emptyOption.prop("selected",!0)):null==b&&d.emptyOption?(d.removeUnknownOption(),a.val("")):d.renderUnknownOption(b)};d.addOption=function(a,
b){if(8!==b[0].nodeType){Ra(a,'"option value"');""===a&&(d.emptyOption=b);var g=c.get(a)||0;c.put(a,g+1);d.ngModelCtrl.$render();b[0].hasAttribute("selected")&&(b[0].selected=!0)}};d.removeOption=function(a){var b=c.get(a);b&&(1===b?(c.remove(a),""===a&&(d.emptyOption=void 0)):c.put(a,b-1))};d.hasOption=function(a){return!!c.get(a)};d.registerOption=function(a,b,c,h,k){if(h){var l;c.$observe("value",function(a){v(l)&&d.removeOption(l);l=a;d.addOption(a,b)})}else k?a.$watch(k,function(a,e){c.$set("value",
a);e!==a&&d.removeOption(e);d.addOption(a,b)}):d.addOption(c.value,b);b.on("$destroy",function(){d.removeOption(c.value);d.ngModelCtrl.$render()})}}],re=function(){return{restrict:"E",require:["select","?ngModel"],controller:Ug,priority:1,link:{pre:function(a,b,d,c){var e=c[1];if(e){var f=c[0];f.ngModelCtrl=e;b.on("change",function(){a.$apply(function(){e.$setViewValue(f.readValue())})});if(d.multiple){f.readValue=function(){var a=[];q(b.find("option"),function(b){b.selected&&a.push(b.value)});return a};
f.writeValue=function(a){var c=new Sa(a);q(b.find("option"),function(a){a.selected=v(c.get(a.value))})};var g,h=NaN;a.$watch(function(){h!==e.$viewValue||na(g,e.$viewValue)||(g=fa(e.$viewValue),e.$render());h=e.$viewValue});e.$isEmpty=function(a){return!a||0===a.length}}}},post:function(a,b,d,c){var e=c[1];if(e){var f=c[0];e.$render=function(){f.writeValue(e.$viewValue)}}}}}},te=["$interpolate",function(a){return{restrict:"E",priority:100,compile:function(b,d){if(v(d.value))var c=a(d.value,!0);else{var e=
a(b.text(),!0);e||d.$set("value",b.text())}return function(a,b,d){var k=b.parent();(k=k.data("$selectController")||k.parent().data("$selectController"))&&k.registerOption(a,b,d,c,e)}}}}],se=ca({restrict:"E",terminal:!1}),Hc=function(){return{restrict:"A",require:"?ngModel",link:function(a,b,d,c){c&&(d.required=!0,c.$validators.required=function(a,b){return!d.required||!c.$isEmpty(b)},d.$observe("required",function(){c.$validate()}))}}},Gc=function(){return{restrict:"A",require:"?ngModel",link:function(a,
b,d,c){if(c){var e,f=d.ngPattern||d.pattern;d.$observe("pattern",function(a){I(a)&&0<a.length&&(a=new RegExp("^"+a+"$"));if(a&&!a.test)throw O("ngPattern")("noregexp",f,a,ua(b));e=a||void 0;c.$validate()});c.$validators.pattern=function(a,b){return c.$isEmpty(b)||y(e)||e.test(b)}}}}},Jc=function(){return{restrict:"A",require:"?ngModel",link:function(a,b,d,c){if(c){var e=-1;d.$observe("maxlength",function(a){a=$(a);e=isNaN(a)?-1:a;c.$validate()});c.$validators.maxlength=function(a,b){return 0>e||c.$isEmpty(b)||
b.length<=e}}}}},Ic=function(){return{restrict:"A",require:"?ngModel",link:function(a,b,d,c){if(c){var e=0;d.$observe("minlength",function(a){e=$(a)||0;c.$validate()});c.$validators.minlength=function(a,b){return c.$isEmpty(b)||b.length>=e}}}}};F.angular.bootstrap?F.console&&console.log("WARNING: Tried to load angular more than once."):(je(),le(da),da.module("ngLocale",[],["$provide",function(a){function b(a){a+="";var b=a.indexOf(".");return-1==b?0:a.length-b-1}a.value("$locale",{DATETIME_FORMATS:{AMPMS:["AM",
"PM"],DAY:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),ERANAMES:["Before Christ","Anno Domini"],ERAS:["BC","AD"],FIRSTDAYOFWEEK:6,MONTH:"January February March April May June July August September October November December".split(" "),SHORTDAY:"Sun Mon Tue Wed Thu Fri Sat".split(" "),SHORTMONTH:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),STANDALONEMONTH:"January February March April May June July August September October November December".split(" "),WEEKENDRANGE:[5,
6],fullDate:"EEEE, MMMM d, y",longDate:"MMMM d, y",medium:"MMM d, y h:mm:ss a",mediumDate:"MMM d, y",mediumTime:"h:mm:ss a","short":"M/d/yy h:mm a",shortDate:"M/d/yy",shortTime:"h:mm a"},NUMBER_FORMATS:{CURRENCY_SYM:"$",DECIMAL_SEP:".",GROUP_SEP:",",PATTERNS:[{gSize:3,lgSize:3,maxFrac:3,minFrac:0,minInt:1,negPre:"-",negSuf:"",posPre:"",posSuf:""},{gSize:3,lgSize:3,maxFrac:2,minFrac:2,minInt:1,negPre:"-\u00a4",negSuf:"",posPre:"\u00a4",posSuf:""}]},id:"en-us",localeID:"en_US",pluralCat:function(a,
c){var e=a|0,f=c;void 0===f&&(f=Math.min(b(a),3));Math.pow(10,f);return 1==e&&0==f?"one":"other"}})}]),G(F.document).ready(function(){fe(F.document,Ac)}))})(window);!window.angular.$$csp().noInlineStyle&&window.angular.element(document.head).prepend('<style type="text/css">@charset "UTF-8";[ng\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none !important;}ng\\:form{display:block;}.ng-animate-shim{visibility:hidden;}.ng-anchor{position:absolute;}</style>');
//# sourceMappingURL=angular.min.js.map
| 158,915 | Common Lisp | .l | 316 | 501.886076 | 640 | 0.65001 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 1dcd21d9978860ba56f53ab63baaf14db850fcecb93246ac1f4c9da917d7c6b9 | 26,514 | [
-1
] |
26,515 | app.module.js | drewt_Aleph/www/client/app/app.module.js | angular.module('alephApp', [
'ngRoute',
'ngSanitize',
'ngContextMenu',
'toolBar',
'feedList',
'itemList',
'addFeed',
]);
| 149 | Common Lisp | .l | 9 | 12.444444 | 28 | 0.578571 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | d1f82723da766df810712f96da1f1ea93a7e2ec80e8e22fcc072795e3443aac6 | 26,515 | [
-1
] |
26,516 | angular-sanitize.js | drewt_Aleph/www/client/app/angular-sanitize.js | /*
AngularJS v1.5.6
(c) 2010-2016 Google, Inc. http://angularjs.org
License: MIT
*/
(function(n,e){'use strict';function B(a){var c=[];w(c,e.noop).chars(a);return c.join("")}function h(a,c){var b={},d=a.split(","),l;for(l=0;l<d.length;l++)b[c?e.lowercase(d[l]):d[l]]=!0;return b}function C(a,c){null===a||void 0===a?a="":"string"!==typeof a&&(a=""+a);g.innerHTML=a;var b=5;do{if(0===b)throw x("uinput");b--;n.document.documentMode&&t(g);a=g.innerHTML;g.innerHTML=a}while(a!==g.innerHTML);for(b=g.firstChild;b;){switch(b.nodeType){case 1:c.start(b.nodeName.toLowerCase(),D(b.attributes));
break;case 3:c.chars(b.textContent)}var d;if(!(d=b.firstChild)&&(1==b.nodeType&&c.end(b.nodeName.toLowerCase()),d=b.nextSibling,!d))for(;null==d;){b=b.parentNode;if(b===g)break;d=b.nextSibling;1==b.nodeType&&c.end(b.nodeName.toLowerCase())}b=d}for(;b=g.firstChild;)g.removeChild(b)}function D(a){for(var c={},b=0,d=a.length;b<d;b++){var l=a[b];c[l.name]=l.value}return c}function y(a){return a.replace(/&/g,"&").replace(E,function(a){var b=a.charCodeAt(0);a=a.charCodeAt(1);return"&#"+(1024*(b-55296)+
(a-56320)+65536)+";"}).replace(F,function(a){return"&#"+a.charCodeAt(0)+";"}).replace(/</g,"<").replace(/>/g,">")}function w(a,c){var b=!1,d=e.bind(a,a.push);return{start:function(a,f){a=e.lowercase(a);!b&&G[a]&&(b=a);b||!0!==u[a]||(d("<"),d(a),e.forEach(f,function(b,f){var g=e.lowercase(f),h="img"===a&&"src"===g||"background"===g;!0!==H[g]||!0===z[g]&&!c(b,h)||(d(" "),d(f),d('="'),d(y(b)),d('"'))}),d(">"))},end:function(a){a=e.lowercase(a);b||!0!==u[a]||!0===A[a]||(d("</"),d(a),d(">"));a==
b&&(b=!1)},chars:function(a){b||d(y(a))}}}function t(a){if(a.nodeType===n.Node.ELEMENT_NODE)for(var c=a.attributes,b=0,d=c.length;b<d;b++){var e=c[b],f=e.name.toLowerCase();if("xmlns:ns1"===f||0===f.lastIndexOf("ns1:",0))a.removeAttributeNode(e),b--,d--}(c=a.firstChild)&&t(c);(c=a.nextSibling)&&t(c)}var x=e.$$minErr("$sanitize"),E=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,F=/([^\#-~ |!])/g,A=h("area,br,col,hr,img,wbr"),q=h("colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr"),k=h("rp,rt"),v=e.extend({},k,q),
q=e.extend({},q,h("address,article,aside,blockquote,caption,center,del,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5,h6,header,hgroup,hr,ins,map,menu,nav,ol,pre,section,table,ul")),k=e.extend({},k,h("a,abbr,acronym,b,bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,q,ruby,rp,rt,s,samp,small,span,strike,strong,sub,sup,time,tt,u,var")),I=h("circle,defs,desc,ellipse,font-face,font-face-name,font-face-src,g,glyph,hkern,image,linearGradient,line,marker,metadata,missing-glyph,mpath,path,polygon,polyline,radialGradient,rect,stop,svg,switch,text,title,tspan"),
G=h("script,style"),u=e.extend({},A,q,k,v),z=h("background,cite,href,longdesc,src,xlink:href"),v=h("abbr,align,alt,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,compact,coords,dir,face,headers,height,hreflang,hspace,ismap,lang,language,nohref,nowrap,rel,rev,rows,rowspan,rules,scope,scrolling,shape,size,span,start,summary,tabindex,target,title,type,valign,value,vspace,width"),k=h("accent-height,accumulate,additive,alphabetic,arabic-form,ascent,baseProfile,bbox,begin,by,calcMode,cap-height,class,color,color-rendering,content,cx,cy,d,dx,dy,descent,display,dur,end,fill,fill-rule,font-family,font-size,font-stretch,font-style,font-variant,font-weight,from,fx,fy,g1,g2,glyph-name,gradientUnits,hanging,height,horiz-adv-x,horiz-origin-x,ideographic,k,keyPoints,keySplines,keyTimes,lang,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mathematical,max,min,offset,opacity,orient,origin,overline-position,overline-thickness,panose-1,path,pathLength,points,preserveAspectRatio,r,refX,refY,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,rotate,rx,ry,slope,stemh,stemv,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,systemLanguage,target,text-anchor,to,transform,type,u1,u2,underline-position,underline-thickness,unicode,unicode-range,units-per-em,values,version,viewBox,visibility,width,widths,x,x-height,x1,x2,xlink:actuate,xlink:arcrole,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,xml:space,xmlns,xmlns:xlink,y,y1,y2,zoomAndPan",
!0),H=e.extend({},z,k,v),g;(function(a){if(a.document&&a.document.implementation)a=a.document.implementation.createHTMLDocument("inert");else throw x("noinert");var c=(a.documentElement||a.getDocumentElement()).getElementsByTagName("body");1===c.length?g=c[0]:(c=a.createElement("html"),g=a.createElement("body"),c.appendChild(g),a.appendChild(c))})(n);e.module("ngSanitize",[]).provider("$sanitize",function(){var a=!1;this.$get=["$$sanitizeUri",function(c){a&&e.extend(u,I);return function(a){var d=
[];C(a,w(d,function(a,b){return!/^unsafe:/.test(c(a,b))}));return d.join("")}}];this.enableSvg=function(c){return e.isDefined(c)?(a=c,this):a}});e.module("ngSanitize").filter("linky",["$sanitize",function(a){var c=/((ftp|https?):\/\/|(www\.)|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"\u201d\u2019]/i,b=/^mailto:/i,d=e.$$minErr("linky"),g=e.isString;return function(f,h,m){function k(a){a&&p.push(B(a))}function q(a,b){var c;p.push("<a ");e.isFunction(m)&&(m=m(a));if(e.isObject(m))for(c in m)p.push(c+
'="'+m[c]+'" ');else m={};!e.isDefined(h)||"target"in m||p.push('target="',h,'" ');p.push('href="',a.replace(/"/g,"""),'">');k(b);p.push("</a>")}if(null==f||""===f)return f;if(!g(f))throw d("notstring",f);for(var r=f,p=[],s,n;f=r.match(c);)s=f[0],f[2]||f[4]||(s=(f[3]?"http://":"mailto:")+s),n=f.index,k(r.substr(0,n)),q(s,f[0].replace(b,"")),r=r.substring(n+f[0].length);k(r);return a(p.join(""))}}])})(window,window.angular);
//# sourceMappingURL=angular-sanitize.min.js.map
| 5,837 | Common Lisp | .l | 15 | 387.933333 | 1,660 | 0.696496 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 4681940e7707e27be2ac28fbda1be5719b6f1269742f1733c6651faab682e51e | 26,516 | [
-1
] |
26,517 | angular-route.js | drewt_Aleph/www/client/app/angular-route.js | /*
AngularJS v1.5.6
(c) 2010-2016 Google, Inc. http://angularjs.org
License: MIT
*/
(function(C,d){'use strict';function w(s,h,f){return{restrict:"ECA",terminal:!0,priority:400,transclude:"element",link:function(a,e,b,g,y){function k(){n&&(f.cancel(n),n=null);l&&(l.$destroy(),l=null);m&&(n=f.leave(m),n.then(function(){n=null}),m=null)}function z(){var b=s.current&&s.current.locals;if(d.isDefined(b&&b.$template)){var b=a.$new(),g=s.current;m=y(b,function(b){f.enter(b,null,m||e).then(function(){!d.isDefined(u)||u&&!a.$eval(u)||h()});k()});l=g.scope=b;l.$emit("$viewContentLoaded");
l.$eval(r)}else k()}var l,m,n,u=b.autoscroll,r=b.onload||"";a.$on("$routeChangeSuccess",z);z()}}}function v(d,h,f){return{restrict:"ECA",priority:-400,link:function(a,e){var b=f.current,g=b.locals;e.html(g.$template);var y=d(e.contents());if(b.controller){g.$scope=a;var k=h(b.controller,g);b.controllerAs&&(a[b.controllerAs]=k);e.data("$ngControllerController",k);e.children().data("$ngControllerController",k)}a[b.resolveAs||"$resolve"]=g;y(a)}}}var r=d.module("ngRoute",["ng"]).provider("$route",function(){function s(a,
e){return d.extend(Object.create(a),e)}function h(a,d){var b=d.caseInsensitiveMatch,g={originalPath:a,regexp:a},f=g.keys=[];a=a.replace(/([().])/g,"\\$1").replace(/(\/)?:(\w+)(\*\?|[\?\*])?/g,function(a,d,b,e){a="?"===e||"*?"===e?"?":null;e="*"===e||"*?"===e?"*":null;f.push({name:b,optional:!!a});d=d||"";return""+(a?"":d)+"(?:"+(a?d:"")+(e&&"(.+?)"||"([^/]+)")+(a||"")+")"+(a||"")}).replace(/([\/$\*])/g,"\\$1");g.regexp=new RegExp("^"+a+"$",b?"i":"");return g}var f={};this.when=function(a,e){var b=
d.copy(e);d.isUndefined(b.reloadOnSearch)&&(b.reloadOnSearch=!0);d.isUndefined(b.caseInsensitiveMatch)&&(b.caseInsensitiveMatch=this.caseInsensitiveMatch);f[a]=d.extend(b,a&&h(a,b));if(a){var g="/"==a[a.length-1]?a.substr(0,a.length-1):a+"/";f[g]=d.extend({redirectTo:a},h(g,b))}return this};this.caseInsensitiveMatch=!1;this.otherwise=function(a){"string"===typeof a&&(a={redirectTo:a});this.when(null,a);return this};this.$get=["$rootScope","$location","$routeParams","$q","$injector","$templateRequest",
"$sce",function(a,e,b,g,h,k,r){function l(q){var c=t.current;(A=(p=w())&&c&&p.$$route===c.$$route&&d.equals(p.pathParams,c.pathParams)&&!p.reloadOnSearch&&!x)||!c&&!p||a.$broadcast("$routeChangeStart",p,c).defaultPrevented&&q&&q.preventDefault()}function m(){var q=t.current,c=p;if(A)q.params=c.params,d.copy(q.params,b),a.$broadcast("$routeUpdate",q);else if(c||q)x=!1,(t.current=c)&&c.redirectTo&&(d.isString(c.redirectTo)?e.path(v(c.redirectTo,c.params)).search(c.params).replace():e.url(c.redirectTo(c.pathParams,
e.path(),e.search())).replace()),g.when(c).then(n).then(function(e){c==t.current&&(c&&(c.locals=e,d.copy(c.params,b)),a.$broadcast("$routeChangeSuccess",c,q))},function(d){c==t.current&&a.$broadcast("$routeChangeError",c,q,d)})}function n(a){if(a){var c=d.extend({},a.resolve);d.forEach(c,function(a,b){c[b]=d.isString(a)?h.get(a):h.invoke(a,null,null,b)});a=u(a);d.isDefined(a)&&(c.$template=a);return g.all(c)}}function u(a){var c,b;d.isDefined(c=a.template)?d.isFunction(c)&&(c=c(a.params)):d.isDefined(b=
a.templateUrl)&&(d.isFunction(b)&&(b=b(a.params)),d.isDefined(b)&&(a.loadedTemplateUrl=r.valueOf(b),c=k(b)));return c}function w(){var a,c;d.forEach(f,function(b,g){var f;if(f=!c){var h=e.path();f=b.keys;var l={};if(b.regexp)if(h=b.regexp.exec(h)){for(var k=1,n=h.length;k<n;++k){var m=f[k-1],p=h[k];m&&p&&(l[m.name]=p)}f=l}else f=null;else f=null;f=a=f}f&&(c=s(b,{params:d.extend({},e.search(),a),pathParams:a}),c.$$route=b)});return c||f[null]&&s(f[null],{params:{},pathParams:{}})}function v(a,b){var e=
[];d.forEach((a||"").split(":"),function(a,d){if(0===d)e.push(a);else{var f=a.match(/(\w+)(?:[?*])?(.*)/),g=f[1];e.push(b[g]);e.push(f[2]||"");delete b[g]}});return e.join("")}var x=!1,p,A,t={routes:f,reload:function(){x=!0;var b={defaultPrevented:!1,preventDefault:function(){this.defaultPrevented=!0;x=!1}};a.$evalAsync(function(){l(b);b.defaultPrevented||m()})},updateParams:function(a){if(this.current&&this.current.$$route)a=d.extend({},this.current.params,a),e.path(v(this.current.$$route.originalPath,
a)),e.search(a);else throw B("norout");}};a.$on("$locationChangeStart",l);a.$on("$locationChangeSuccess",m);return t}]}),B=d.$$minErr("ngRoute");r.provider("$routeParams",function(){this.$get=function(){return{}}});r.directive("ngView",w);r.directive("ngView",v);w.$inject=["$route","$anchorScroll","$animate"];v.$inject=["$compile","$controller","$route"]})(window,window.angular);
//# sourceMappingURL=angular-route.min.js.map
| 4,595 | Common Lisp | .l | 15 | 305.133333 | 523 | 0.651092 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 19b2cd3803dfa2da619007335a0d154991094b5384e02b0e93dc5fc647b50197 | 26,517 | [
-1
] |
26,518 | tool-bar.component.js | drewt_Aleph/www/client/app/tool-bar/tool-bar.component.js | angular.
module('toolBar').
component('toolBar', {
templateUrl: 'app/tool-bar/tool-bar.template.html',
controller: function ToolBarController($http, $rootScope) {
var self = this;
this.refresh = function() {
$rootScope.$broadcast('refresh-feeds');
};
this.markAllRead = function() {
$http.post('/feeds/mark-read');
$rootScope.$broadcast('mark-all-read');
};
this.updateAll = function() {
$http.post('/feeds/update');
};
}
});
| 519 | Common Lisp | .l | 18 | 22.666667 | 63 | 0.594 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 8ddef8e3085f740638720adbb82c7cda7e0a44b435832184efc48b2669122d83 | 26,518 | [
-1
] |
26,519 | tool-bar.template.html | drewt_Aleph/www/client/app/tool-bar/tool-bar.template.html | <div class="tool-bar">
<a ng-click="$ctrl.refresh()" href="javascript:void(0)">↻</a><a href="#!/add-feed">Add feed</a><a ng-click="$ctrl.markAllRead()" href="javascript:void(0)">Mark all read</a><a ng-click="$ctrl.updateAll()" href="javascript:void(0)">Update all</a>
</div>
| 282 | Common Lisp | .l | 3 | 92.333333 | 251 | 0.663082 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 9670dedfe50cfd2b76977bae24854ae8ddb411fe2f83c026a4f847f280f7ea7e | 26,519 | [
-1
] |
26,520 | feed-list.component.js | drewt_Aleph/www/client/app/feed-list/feed-list.component.js | function doNotifySend(message) {
var n = new Notification(message);
setTimeout(n.close.bind(n), 5000);
}
function notifySend(message) {
// if the browser doesn't support notification, log the message instead
if (!("Notification" in window)) {
console.log('Notification: ' + message);
}
// if permission was already granted, send the notification
else if (Notification.permission === 'granted') {
doNotifySend(message);
}
// ask for permission if it hasn't been denied
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function(permission) {
if (permission === 'granted')
doNotifySend(message);
else
console.log('Notification: ' + message);
});
}
}
angular.
module('feedList').
component('feedList', {
templateUrl: 'app/feed-list/feed-list.template.html',
controller: function FeedListController($scope, $http, $interval) {
var self = this;
this.mergeFeeds = function(feeds) {
// FIXME: there HAS to be a better way of doing this
for (var newi = 0; newi < feeds.length; newi++) {
var newFeed = feeds[newi];
for (var oldi = 0; oldi < self.feeds.length; oldi++) {
var oldFeed = self.feeds[oldi];
if (oldFeed.id == newFeed.id) {
if (oldFeed.unread < newFeed.unread) {
notifySend(feeds[newi].name + ' updated (' + feeds[newi].unread + ' unread)');
}
if (oldFeed.unread != newFeed.unread) {
self.unread = Math.max(self.unread + (newFeed.unread - oldFeed.unread), 0);
}
self.feeds[oldi] = newFeed;
}
}
}
};
this.update = function(id) {
$http.post('/feeds/' + id + '/update').then(function(response) {
self.mergeFeeds([response.data]);
});
};
this.markRead = function(id) {
$http.post('/feeds/' + id + '/mark-read');
for (i = 0; i < self.feeds.length; i++) {
if (self.feeds[i].id == id && self.feeds[i].unread > 0) {
self.unread = Math.max(self.unread - self.feeds[i].unread, 0);
self.feeds[i].unread = 0;
}
}
};
this.deleteFeed = function(id) {
$http.delete('/feeds/' + id);
};
this.refresh = function() {
$http.get('/feeds').then(function(response) {
self.feeds = response.data;
var count = 0;
for (i = 0; i < self.feeds.length; i++) {
count += self.feeds[i].unread;
}
self.unread = count;
});
};
// Get initial feed list.
this.refresh();
// Schdule update every 60 seconds
this.timer = $interval(function refreshFeeds() {
// XXX: 65 = 60 seconds inverval + 5 seconds headroom for RTT
$http.get('/feeds?since=-65').then(function(response) {
self.mergeFeeds(response.data);
});
}, 60000)
$scope.$on("$destroy", function(event) {
$interval.cancel(self.timer);
});
$scope.$on('refresh-feeds', function(event) {
self.refresh();
});
$scope.$on('mark-all-read', function(event) {
for (i = 0; i < self.feeds.length; i++) {
self.feeds[i].unread = 0;
}
self.unread = 0;
});
}
});
| 3,374 | Common Lisp | .l | 97 | 26.783505 | 94 | 0.558104 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 104919ac18ae5ed2480406cdb8fadf2cbb886abf259b2b45b0b7bc45024590e3 | 26,520 | [
-1
] |
26,521 | feed-list.menu.html | drewt_Aleph/www/client/app/feed-list/feed-list.menu.html | <ul class="menu">
<li><a ng-click="$ctrl.update(id)" href="javascript:void(0)">Update</a></li>
<li><a ng-click="$ctrl.markRead(id)" href="javascript:void(0)">Mark as read</a></li>
<li><a ng-click="$ctrl.deleteFeed(id)" href="javascript:void(0)">Delete</a></li>
</ul>
| 273 | Common Lisp | .l | 5 | 52.4 | 86 | 0.645522 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 8b7c3eb3be881e99aaa88ccd2fb80d4cc9e39343c8383195c3a7d386bd672a3b | 26,521 | [
-1
] |
26,522 | feed-list.template.html | drewt_Aleph/www/client/app/feed-list/feed-list.template.html | <div id="feeds">
<table class="feed-table">
<tbody>
<tr>
<td class="feed-name"><a class="feed-link" href="#!/feeds">All</a></td>
<td class="feed-unread">
<a href="#!/feeds/unread">{{$ctrl.unread > 0 ? $ctrl.unread : ''}}</a>
</td>
<td class="feed-update"></td>
<td class="feed-mark-read"></td>
</tr>
<tr ng-repeat="feed in $ctrl.feeds" data-context-menu="app/feed-list/feed-list.menu.html" ng-model="feed">
<td class="feed-name"><a class="feed-link" ng-href="#!/feeds/{{feed.id}}">{{feed.name}}</a></td>
<td class="feed-unread">
<a ng-href="#!/feeds/{{feed.id}}/unread">{{feed.unread ? feed.unread : ''}}</a>
</td>
<td class="feed-update">
<a ng-click="$ctrl.update(feed.id)" href="javascript:void(0)">↻</a>
</td>
<td class="feed-mark-read">
<a ng-click="$ctrl.markRead(feed.id)" href="javascript:void(0)">✓</a>
</td>
</tr>
</tbody>
</table>
</div>
| 1,032 | Common Lisp | .l | 26 | 32.076923 | 112 | 0.528827 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 84ba9a471ed878f5443e4a982bd1f724d469f02aa8016d6564d60446c3ff1120 | 26,522 | [
-1
] |
26,523 | item-list.component.js | drewt_Aleph/www/client/app/item-list/item-list.component.js | angular.
module('itemList').
component('itemList', {
templateUrl: 'app/item-list/item-list.template.html',
controller: ['$routeParams', '$http',
function ItemListController($routeParams, $http) {
var self = this;
var url = '/items';
if ($routeParams.feedId === 'unread') {
url += '?unread=true';
}
else if ($routeParams.feedId) {
url = '/feeds/' + $routeParams.feedId + '/items';
if ($routeParams.modifier) {
switch ($routeParams.modifier) {
case "unread":
url += '?unread=true';
break;
}
}
}
$http.get(url).then(function(response) {
self.items = response.data;
for (i = 0; i < self.items.length; i++) {
self.items[i].published = new Date(self.items[i].published*1000).toUTCString();
}
});
}
]
});
| 944 | Common Lisp | .l | 30 | 22.266667 | 91 | 0.509847 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | baed6a4e01e18b1cf9ade073407ff0b53786b6d51d92c7c00aad50e030d364f8 | 26,523 | [
-1
] |
26,524 | item-list.template.html | drewt_Aleph/www/client/app/item-list/item-list.template.html | <div id="items">
<div class="item" ng-repeat="item in ::$ctrl.items">
<h2 class="item-title"><a ng-href="{{::item.link}}">{{::item.title}}</a></h2>
<div class="item-published">
<span ng-if="::item.creator">By <span class="item-author">{{::item.creator}}</span> - </span>
{{::item.published}}
</div>
<div ng-if="::item.media.thumbnail.url">
<img ng-src="{{::item.media.thumbnail.url}}">
</div>
<div class="item-content" ng-bind-html="::item.content"></div>
</div>
</div>
| 516 | Common Lisp | .l | 13 | 35.153846 | 99 | 0.582505 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 795787f96407f571423f1daa07ae26b066bfdec4cad4041cff492c67a6b96bdb | 26,524 | [
-1
] |
26,525 | add-feed.template.html | drewt_Aleph/www/client/app/add-feed/add-feed.template.html | <form id="submit-form" ng-submit="$ctrl.submitFeed()">
<fieldset>
<table class="add-feed">
<tr>
<td><input type="text" ng-model="$ctrl.name" name="name" placeholder="Name"></td>
</tr>
<tr>
<td><input type="text" ng-model="$ctrl.source" name="source" placeholder="Source"></td>
</tr>
<tr>
<td>
<select name="fetcher" ng-model="$ctrl.fetcher">
<option value="http">HTTP</option>
<option value="file">File</option>
<option value="command">Command</option>
</select>
</td>
</tr>
<tr>
<td>
<select name="parser" ng-model="$ctrl.parser">
<option value="auto">RSS/Atom</option>
<option value="chan">Chan</option>
</select>
</td>
</tr>
<tr>
<td><input type="number" ng-model="$ctrl.interval" name="interval" placeholder="Inverval" min="1" value="30"></td>
</tr>
<tr>
<td><input type="submit" value="Add Feed"></td>
</tr>
</table>
</fieldset>
</form>
| 1,090 | Common Lisp | .l | 35 | 23.057143 | 122 | 0.524171 | drewt/Aleph | 1 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 11cceec16c6ff348aa896a05de06c2f64d97e5b04ea047b0523979ee8f046ef8 | 26,525 | [
-1
] |
26,540 | test-mop.lisp | simoninireland_cl-vhdsl/test/test-mop.lisp | ;; Tests of metaclass for componens
;;
;; Copyright (C) 2023 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/test)
(in-suite cl-vhdsl)
;; ---------- Components ----------
(defclass test-component (hw:component hw:enabled hw:clocked)
((data-bus
:initarg :data-bus
:pins 8
:role :io)
(address-bus
:pins 16
:role :io)
(write-enable
:pins 1
:role :control)
(io
:initarg :io
:pins 2)
(other
:initform 32))
(:metaclass hw:metacomponent))
(defclass test-component-var (hw:component hw:enabled)
((width
:initarg :width)
(bus
:pins width))
(:metaclass hw:metacomponent))
(test test-pins-created
"Test we create pins for the slots on the pin interface"
(let ((tc (make-instance 'test-component)))
(with-slots (data-bus address-bus hw::clock write-enable io other) tc
;; 8-bit data bus, tristated
(is (equal (hw:width data-bus) 8))
(dolist (i (iota 8))
(is (equal (slot-value (elt (hw:pins data-bus) i) 'hw::state) :tristate)))
;; 16-bit address bus, tristated
(is (equal (hw:width address-bus) 16))
(dolist (i (iota 16))
(is (equal (slot-value (elt (hw:pins address-bus) i) 'hw::state) :tristate)))
;; clock pin, triggering
(equal (slot-value (elt (hw:pins hw::clock) 0) 'hw::state) :trigger)
;; write-enable pin, reading
(equal (slot-value (elt (hw:pins write-enable) 0) 'hw::state) :reading)
;; 2 io lines, tristated
(is (equal (hw:width io) 2))
(dolist (i (iota 2))
(is (equal (slot-value (elt (hw:pins io) i) 'hw::state) :tristate)))
;; other left alone
(equal other 32))))
(test test-pin-interface
"Test we can extract the pin interface."
(let* ((tc (make-instance 'test-component))
(slots (hw:pin-interface (class-of tc))))
(is (equal (length slots) 6))
(dolist (s '(data-bus address-bus hw:enable hw::clock hw::enable write-enable io))
(is (member s slots)))))
(test test-pin-interface-p
"Test we can test that a slot is in the pin interface."
(let ((tc (make-instance 'test-component)))
(is (hw:pin-interface-p (class-of tc) 'data-bus))
(is (not (hw:pin-interface-p (class-of tc) 'other)))
;; doesn't distinguish non-slots from non-pin slots
(is (not (hw:pin-interface-p (class-of tc) 'not-a-slot-at-all)))))
(test test-pins-slot
"Test we can extract the pins from slots."
(let ((tc (make-instance 'test-component)))
(is (equal (hw:width (slot-value tc 'data-bus)) 8))
(is (equal (hw:width (slot-value tc 'address-bus)) 16))
(is (equal (hw:width (slot-value tc 'hw:clock)) 1))
(is (equal (hw:width (slot-value tc 'write-enable)) 1))
(is (equal (hw:width (slot-value tc 'io)) 2))))
(test test-pins-from-slot
"Test we can set the number of pins from the value of another slot."
(let ((tc (make-instance 'test-component-var :width 8)))
(is (equal (hw:width (slot-value tc 'bus)) (slot-value tc 'width)))))
;; ---------- :if method combination ----------
(test test-guard-single-unguarded
"Test an guarded method without a guard behaves as standard."
(defgeneric test-unguarded (v)
(:method-combination hw:guarded))
(defmethod test-unguarded ((v integer))
(+ v 12))
(is (equal (test-unguarded 1) 13))
(is (equal (test-unguarded 12) 24)))
(test test-guard-single-primary
"Test we can guard a single primary method."
(defgeneric test-single-primary (v)
(:method-combination hw:guarded))
(defmethod test-single-primary ((v integer))
(+ v 12))
(defmethod test-single-primary :if ((v integer))
(> v 10))
(is (null (test-single-primary 1)))
(is (equal (test-single-primary 12) 24)))
(test test-guard-nested-primary
"Test we can guard a nested primary method."
(defgeneric test-nested-primary (v)
(:method-combination hw:guarded))
(defmethod test-nested-primary ((v integer))
(call-next-method (+ v 12)))
(defmethod test-nested-primary ((v number))
(* v 1.5))
(defmethod test-nested-primary :if ((v integer))
(> v 10))
(is (null (test-nested-primary 1)))
(is (equal (test-nested-primary 12.0) 18.0))
(is (equal (test-nested-primary 12) 36.0)))
(test test-guard-around
"Test we can guard a method with :around methods."
(defgeneric test-around (v)
(:method-combination hw:guarded))
(defmethod test-around ((v integer))
(+ v 12))
(defmethod test-around :around ((v integer))
(call-next-method (* v 10)))
(defmethod test-around :if ((v integer))
(> v 10))
(is (null (test-around 1)))
(is (equal (test-around 12) 132)))
(test test-guard-before-after
"Test we can guard :before and :after methods"
(defparameter test-before-after-b 0)
(defparameter test-before-after-a 0)
(defgeneric test-before-after (v)
(:method-combination hw:guarded))
(defmethod test-before-after ((v integer))
(+ v 12))
(defmethod test-before-after :before ((v integer))
(setq test-before-after-b v))
(defmethod test-before-after :after ((v integer))
(setq test-before-after-a v))
(defmethod test-before-after :if ((v integer))
(> v 10))
(is (null (test-before-after 1)))
(is (= test-before-after-b 0))
(is (= test-before-after-a 0))
(is (equal (test-before-after 12) 24))
(is (= test-before-after-b 12))
(is (= test-before-after-a 12)))
(test test-guard-before-after-around
"Test we can compose :around with :before and :after"
(defparameter test-before-after-around-b 0)
(defparameter test-before-after-around-a 0)
(defgeneric test-before-after-around (v)
(:method-combination hw:guarded))
(defmethod test-before-after-around ((v integer))
(+ v 12))
(defmethod test-before-after-around :before ((v integer))
(setq test-before-after-around-b v))
(defmethod test-before-after-around :after ((v integer))
(setq test-before-after-around-a v))
(defmethod test-before-after-around :around ((v integer))
(call-next-method (* v 10)))
(defmethod test-before-after-around :if ((v integer))
(> v 10))
(is (null (test-before-after-around 1)))
(is (= test-before-after-around-b 0))
(is (= test-before-after-around-a 0))
(is (equal (test-before-after-around 12) 132))
(is (= test-before-after-around-b 120))
(is (= test-before-after-around-a 120)))
(test test-guarded-several
"Test we can have several guards on the same method."
(defgeneric test-several (v)
(:method-combination hw:guarded))
(defmethod test-several ((v integer))
(+ v 12))
;; methods need to be specialised against different types,
;; so this adds two guards that will be selected by an integer
;; value
(defmethod test-several :if ((v integer))
(> v 10))
(defmethod test-several :if ((v number))
(< v 100))
(is (null (test-several 1)))
(is (null (test-several 101)))
(is (equal (test-several 12) 24)))
(test test-guarded-hier
"Test we can acquire :if guards from up and down an inheritance hierarchy."
(defclass test-hier-c ()
((value
:initform 9
:initarg :value)))
(defclass test-hier-c-1 (test-hier-c) ())
(defclass test-hier-c-2 (test-hier-c-1) ())
(defgeneric test-hier (v)
(:method-combination hw:guarded))
(defmethod test-hier ((v test-hier-c))
(slot-value v 'value))
(defmethod test-hier ((v test-hier-c-1))
(+ (call-next-method) 26))
(defmethod test-hier ((v test-hier-c-2))
(+ (call-next-method) 1000))
(defmethod test-hier :if ((v test-hier-c-2))
(< (slot-value v 'value) 100))
(defmethod test-hier :if ((v test-hier-c))
(= (slot-value v 'value) 9))
(is (equal (test-hier (make-instance 'test-hier-c)) 9))
(is (equal (test-hier (make-instance 'test-hier-c-1)) 35))
(is (equal (test-hier (make-instance 'test-hier-c-2)) 1035))
(is (null (test-hier (make-instance 'test-hier-c-2 :value 200))))
(is (null (test-hier (make-instance 'test-hier-c-2 :value 25)))))
| 8,624 | Common Lisp | .lisp | 219 | 35.474886 | 86 | 0.668428 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 2efe49ae7e1cf7db8116fd6577f36393dede0a809cc6ddf0af0074560644a674 | 26,540 | [
-1
] |
26,541 | package.lisp | simoninireland_cl-vhdsl/test/package.lisp | ;; Top-level test package
;;
;; Copyright (C) 2023 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(defpackage cl-vhdsl/test
(:use :cl :alexandria :serapeum :fiveam
:cl-vhdsl)
(:local-nicknames (:ast :clast)
(:def :cl-vhdsl/def)
(:emu :cl-vhdsl/emu)
(:hw :cl-vhdsl/hw)
(:rtl :cl-vhdsl/rtl))
(:import-from :fiveam #:is #:test))
(in-package :cl-vhdsl/test)
(def-suite cl-vhdsl)
| 1,093 | Common Lisp | .lisp | 29 | 35.551724 | 75 | 0.720339 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 0c2153c929453c9ec38ea52e890ddc157c93693f5969ce765d34221a45e7a681 | 26,541 | [
-1
] |
26,542 | test-6502.lisp | simoninireland_cl-vhdsl/test/test-6502.lisp | (assemble (:origin #16r1000)
(.DEFINE SOURCE #16r200)
(.DEFINE DEST #16r300)
(.DEFINE SIZE 25)
(LDX :mode (immediate :value (.FROM SIZE)))
(.LABEL COPY)
(LDA :mode (absolute-indexed :address (.FROM) SOURCE
:index X))
(STA :mode (absolute-indexed :address (.FROM DEST)
:index X))
(DEX)
(BNZ :mode (relative :offset (.FROM COPY))))
(in-package :cl-vhdsl/systems/6502)
(assemble (:origin #16r1000)
(lda :addressing-mode (immediate :value 12))
)
(list
(make-instance 'LDA :addressing-mode (immediate :vlue 100))
)
| 558 | Common Lisp | .lisp | 19 | 25.842105 | 60 | 0.663551 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | e74daacef610d2648ea2f63fb22a68935e1aa307091bb4934242575df7957d76 | 26,542 | [
-1
] |
26,543 | test-microinstructions.lisp | simoninireland_cl-vhdsl/test/test-microinstructions.lisp | ;; Tests of micro-instructions
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/test)
(in-suite cl-vhdsl)
(defclass test-system (hw:component hw:clocked)
((data-bus
:initarg :data-bus
:reader data-bus)
(address-bus
:initarg :address-bus
:reader address-bus)
(reg
:type hw:register
:initarg :register
:accessor register)
(memory
:type hw:ram
:initarg :memory
:accessor memory))
(:metaclass hw:metacomponent))
(defmethod initialize-instance :after ((ts test-system) &rest initargs &key &allow-other-keys)
(declare (ignore initargs))
(let* ((clk (make-instance 'hw:pin :state 0))
(reg-en (make-instance 'hw:pin :state 0))
(reg-wr (make-instance 'hw:pin :state 0))
(ram-en (make-instance 'hw:pin :state 0))
(ram-wr (make-instance 'hw:pin :state 0))
(reg (make-instance 'hw:register :width 8
:clock clk
:enable reg-en
:bus (data-bus ts)
:write-enable reg-wr))
(ram (make-instance 'hw:ram :address-bus-width 16
:data-bus-width 8
:address-bus (address-bus ts)
:data-bus (data-bus ts)
:clock clk
:enable ram-en
:write-enable ram-wr)))
(setf (register ts) reg)
(setf (memory ts) ram)))
;; This code is needed to ensure that the classes exist (and
;; can be examined) even when they're built in the same file.
;; It can be avoided by instanciating an instance, which does
;; fianlisation implicitly -- but we'd be likely to generate
;; a system and then its micro-instructions without necessarily
;; instanciating first, so maybe `defmicroinstruction' should
;; implicitly finalise its base class as well?
(c2mop:ensure-finalized (find-class 'test-system))
(hw:defmicroinstruction tsm (test-system))
(c2mop:ensure-finalized (find-class 'tsm))
(test test-microinstructions
"Test we can derive the micro-instructions for the test system."
;; check the micro-instruction slots all exist (there are other slots too)
(let ((mi-slots (mapcar #'c2mop:slot-definition-name
(c2mop:class-slots (find-class 'tsm)))))
(dolist (mi-slot '(reg/enable reg/write-enable memory/enable memory/write-enable))
(is (member mi-slot mi-slots)))))
(test test-mi-load-register
"Test we can crerate and run a micro-instruction that loads the register from RAM."
(let* ((data-bus (make-instance 'hw:bus :width 8))
(data-bus-connector (map 'vector
(lambda (w)
(make-instance 'hw:pin :wire w))
(hw:bus-wires data-bus)))
(address-bus (make-instance 'hw:bus :width 16))
(address-bus-connector (map 'vector
(lambda (w)
(make-instance 'hw:pin :wire w))
(hw:bus-wires address-bus)))
(ts (make-instance 'test-system :address-bus address-bus
:data-bus data-bus))
(clk (hw:component-clock ts)))
;; create the micro-instuction
(let ((mi (make-instance 'tsm :reg/enable 1
:reg/write-enable 1
:memory/enable 1
:memory/write-enable 0)))
;; put some values into RAM
(setf (aref (hw:ram-elements (memory ts)) #16rFF) 123)
;; put the address onto the address bus
(setf (hw:connect-pins address-bus-connector) #16rFF)
;; clock-cycle the system
(setf (hw:state clk) 0)
(hw:run-microinstruction mi)
(setf (hw:state clk) 1)
;; check we loaded the value
(is (equal (aref (hw:ram-elements (memory ts)) #16rFF) 123))
(is (equal (hw:register-value (register ts)) 123)))))
| 4,196 | Common Lisp | .lisp | 105 | 35.561905 | 94 | 0.688589 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | b5933998776265b6bbdda9b5adf2bce2a938fde3c65cc65d388c75c4b60c9380 | 26,543 | [
-1
] |
26,544 | test-assembler.lisp | simoninireland_cl-vhdsl/test/test-assembler.lisp | ;; Tests of assembler
;;
;; Copyright (C) 2023 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/test)
(in-suite cl-vhdsl)
;; ---------- Regexps for parsing opcodes ----------
(test test-instruction-mnemonics
"Test we can extract mnemoics from instruction objects."
(is (string= (instruction-mnemonic (make-instance 'LDA)) "LDA"))
(is (string= (instruction-mnemonic (make-instance 'LDX)) "LDX")))
(test test-instuction-class-mnemonics
"Test we can extract mnemonics from classes."
(is (string= (instruction-mnemonic 'LDA) "LDA"))
(signals error
(instruction-mnemonic 'ttt)))
(test test-mnemonic-regexp
"Test we can extract the right class from its menmonic."
(let ((clns (list 'LDA 'LDX 'STA)))
(is (string= (assembler-get-mnemonic "LDA" clns) "LDA"))
(is (string= (assembler-get-mnemonic "LDX" clns) "LDX"))
(is (string= (assembler-get-mnemonic "STA" clns) "STA"))
(is (null (assembler-get-mnemonic "TXA" clns)))))
(test test-mnemonic-regexp-pre
"Check we can construct and re-use the regexp."
(let* ((clns (list 'LDA 'LDX 'STA))
(re (assembler-make-mnemonic-regexp clns)))
(is (string= (assembler-get-mnemonic "LDA" clns re) "LDA"))))
;; ---------- Number parsing ----------
(test test-bases
"Test we can parse different number bases."
(is (= (assembler-parse-number "0") 0))
(is (= (assembler-parse-number "1") 1))
(is (= (assembler-parse-number "9") 9))
(is (= (assembler-parse-number "009") 9))
(is (= (assembler-parse-number "10") 10))
(is (= (assembler-parse-number "10B") #2r10))
(is (= (assembler-parse-number "10H") #16r10))
(is (= (assembler-parse-number "10FFH") #16r10FF))
(is (= (assembler-parse-number "-20") (- 20)))
(is (= (assembler-parse-number "-10H") (- #16r10)))
(signals error
(assembler-parse-number "F"))
(signals error
(assembler-parse-number "G"))
(signals error
(assembler-parse-number "2B"))
(signals error
(assembler-parse-number "--1"))
(signals error
(assembler-parse-number "10H0")))
;; ---------- Regexps for parsing addressing modes ----------
(test test-addressing-mode-regexp
"Test we can extract the right addressing mode."
(let ((aclns (list 'immediate 'absolute 'absolute-indexed)))
(is (equalp (assembler-get-addressing-mode "#123" aclns) '(immediate ("123"))))
(is (equalp (assembler-get-addressing-mode "123FH" aclns) '(absolute ("123FH"))))
(is (equalp (assembler-get-addressing-mode "123, X" aclns) '(absolute-indexed ("123" "X"))))))
;; ---------- Instruction parsing ----------
(test test-simple-instruction
"Test we can parse an instruction."
(let ((*assembler-instructions* (list 'LDA 'LDX 'STA 'DEX))
(*assembler-addressing-modes* (list 'immediate 'absolute 'absolute-indexed)))
(assembler-parse-instruction '("LDA" "#123"))
(assembler-parse-instruction '("LDA" "1234H"))
(assembler-parse-instruction '("LDA" "123, X"))
(assembler-parse-instruction '("DEX" ""))
;; missing addressing mode (and doesn't allow implicit addressing)
(signals error
(assembler-parse-instruction '("LDA" "")))
;; incorrect addressing mode
(signals error
(assembler-parse-instruction '("DEX" "#100")))
))
;; ---------- S-exp form ----------
(test test-sexp
"Test the s-expression form of the assembler."
(LDA :addressing-mode (immediate :value 25))
(LDA :addressing-mode (absolute :address #16r200))
(LDA :addressing-mode (absolute-indexed :address #16r200 :index 'X))
;; LDA doesn't allow implicit addressing
(signals error
(LDA))
;; DEX only allows implicit addressing
(DEX)
(signals error
(DEX :mode (immediate :value 25)))
)
| 4,383 | Common Lisp | .lisp | 102 | 39.77451 | 98 | 0.67811 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | c846e28f64751eaa9a5a256528767143e955799a969d7953f3887c92850bee90 | 26,544 | [
-1
] |
26,545 | test-registers.lisp | simoninireland_cl-vhdsl/test/test-registers.lisp | ;; Tests of register operations
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/test)
(in-suite cl-vhdsl)
;; ---------- Registers ----------
(test test-register-load
"Test a register loads values off its bus correctly."
(let* ((data-bus (make-instance 'hw:bus :width 8))
(data-bus-connector (make-instance 'hw:connector
:width 8))
(clk (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(en (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(wr (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(reg (make-instance 'hw:register :width 8
:clock (hw:wire clk)
:enable (hw:wire en)
:bus data-bus
:write-enable (hw:wire wr))))
;; connect the connector
(hw:connect-pins data-bus-connector data-bus)
(hw:ensure-fully-wired reg)
;; put a value on the bus
(setf (hw:pins-value data-bus-connector) #2r1101)
;; enable the register and set its value as writeable from the bus
(setf (hw:state en) 1)
(setf (hw:state wr) 1)
;; clock the register
(setf (hw:state clk) 1)
(setf (hw:state clk) 0)
;; check we loaded the value
(is (equal (hw:register-value reg) #2r1101))))
(test test-register-save
"Test a register puts values onto its bus correctly."
(let* ((data-bus (make-instance 'hw:bus :width 8))
(data-bus-connector (make-instance 'hw:connector :width 8))
(clk (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(en (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(wr (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(reg (make-instance 'hw:register :width 8
:clock (hw:wire clk)
:enable (hw:wire en)
:bus data-bus
:write-enable (hw:wire wr))))
;; connect the connector
(hw:connect-pins data-bus-connector data-bus)
(setf (hw:pin-states data-bus-connector) :reading)
;; put a value into the register
(setf (hw:register-value reg) #2r10110)
;; enable the register and set its value as readable from the bus
(setf (hw:state en) 1)
(setf (hw:state wr) 0)
;; clock the register
(setf (hw:state clk) 1)
;; check we place the value on the bus
(let ((v (hw:register-value reg))
(rv (hw:pins-value data-bus-connector)))
(is (equal v #2r10110))
(is (equal v rv)))))
;; ---------- Latches ----------
(test test-alu-register-load
"Test a latch makes a loaded value visible on its latched bus."
(let* ((data-bus (make-instance 'hw:bus :width 8))
(data-bus-connector (make-instance 'hw:connector
:width 8))
(latched-bus (make-instance 'hw:bus :width 8))
(latched-bus-connector (make-instance 'hw:connector
:width 8
:role :reading))
(clk (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(en (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(wr (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(latch (make-instance 'hw:latch :width 8
:clock (hw:wire clk)
:enable (hw:wire en)
:bus data-bus
:latched-bus latched-bus
:write-enable (hw:wire wr))))
;; connect the connector
(hw:connect-pins data-bus-connector data-bus)
(hw:connect-pins latched-bus-connector latched-bus)
(hw:ensure-fully-wired latch)
;; put a value on the bus
(setf (hw:pins-value data-bus-connector) #2r1101)
;; enable the register and set its value as writeable from the bus
(setf (hw:state en) 1)
(setf (hw:state wr) 1)
;; clock the register
(setf (hw:state clk) 1)
(setf (hw:state clk) 0)
;; check the value is available on the latched bus
(is (equal (hw::register-value latch)
(hw:pins-value latched-bus-connector)))
;; disable the latch and check the value is still visible on the latched bus
(setf (hw:state en) 0)
(is (equal (hw::register-value latch)
(hw:pins-value latched-bus-connector)))))
| 4,786 | Common Lisp | .lisp | 121 | 34.644628 | 80 | 0.659698 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 90d76a8fc89d2a8b5887935c5dd08a4067c636a3f4bace5f462a9ee28d2983a2 | 26,545 | [
-1
] |
26,546 | test-utils.lisp | simoninireland_cl-vhdsl/test/test-utils.lisp | ;; Tests of utility functions
;;
;; Copyright (C) 2023 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/test)
(in-suite cl-vhdsl)
;; ---------- Looking for non-nil elements of lists ----------
(test test-index-non-nil
"Test w can find non-nil elements of lists."
(is (null (index-non-nil '())))
(is (null (index-non-nil '(nil))))
(is (null (index-non-nil '(nil nil nil nil))))
(is (equal (index-non-nil '(1)) 0))
(is (equal (index-non-nil '(1 nil)) 0))
(is (equal (index-non-nil '("str" nil)) 0))
(is (equal (index-non-nil '(nil 1)) 1))
(is (equal (index-non-nil '(1 nil)) 0))
(is (equal (index-non-nil '(nil 1 nil)) 1))
(is (equal (index-non-nil '(nil nil 1 nil)) 2)))
(test test-non-nil-subseq
"Test we can extract non-nil sub-sequences of lists."
(is (null (non-nil-subseq '())))
(is (null (non-nil-subseq '(nil))))
(is (null (non-nil-subseq '(nil nil nil))))
(is (equal (non-nil-subseq '(nil 1 nil)) '(1)))
(is (equal (non-nil-subseq '(nil 1)) '(1)))
(is (equal (non-nil-subseq '(nil 1 2)) '(1 2)))
(is (equal (non-nil-subseq '(nil 1 nil 1 2)) '(1)))
(is (equal (non-nil-subseq '(nil 1 2 3 nil 1 2)) '(1 2 3))))
;; ---------- Changing list depths ----------
(test test-listify
"Test we can increase depth."
(is (null (listify '())))
(is (equal (listify '(1 2 3))
'((1) (2) (3))))
(is (equal (listify '(1 (2 3) 4))
'((1) ((2 3)) (4)))))
(test test-delistify
"Test we can decrease depth."
(is (null (delistify '())))
(is (equal (delistify '((1) (2) (3)))
'(1 2 3)))
(is (equal (delistify '((1) ((2 3)) (4)))
'(1 (2 3) 4))))
;; ---------- Zipping while ignoring nulls ----------
(test test-zip-straight
"Test we can zip lists without nulls."
(is (equal (zip-without-null '(1 2 3) '(4 5 6))
'((1 4) (2 5) (3 6))))
(is (equal (zip-without-null '(1 (2 3) 4) '(5 6 7))
'((1 5) ((2 3) 6) (4 7)))))
(test test-zip-null
"Test we can zip lists with nulls."
(is (equal (zip-without-null '(1 nil 3) '(4 5 6))
'((1 4) (3 6))))
(is (equal (zip-without-null '(1 2 3) '(4 5 nil))
'((1 4) (2 5)))))
(test test-zip-unequal
"Test we can zip unequal-length lists with nulls."
(is (equal (zip-without-null '(1 nil 3) '(4 5 6 7 8))
'((1 4) (3 6)))))
(test test-zip-all-null
"Test we can zip lists that are all nulls"
(is (null (zip-without-null '(nil nil nil) '(1 2 3))))
(is (null (zip-without-null '(1 2 3) '(nil nil nil)))))
(test test-zip-empty
"Test we can zip one empty list."
(is (null (zip-without-null '(1 2 3) nil)))
(is (null (zip-without-null nil '(1 2 3)))))
;; ---------- Predicate combinators ----------
(test test-any
"Test we can construct any-of-p."
;; with predicate symbols
(is (funcall (any-of-p evenp oddp) 2))
(is (not (funcall (any-of-p symbolp numberp) (list 1 2))))
;; with inline function
(is (funcall (any-of-p evenp (lambda (n) (= n 15))) 15))
(is (funcall (any-of-p evenp (lambda (n) (= n 15))) 10))
;; in a map
(is (equal (mapcar (any-of-p evenp oddp) (list 1 2 3))
'(t t t))))
(test test-all
"Test we can construct all-of-p."
;; with predicate symbols
(is (funcall (all-of-p evenp) 2))
;; with inline function
(is (funcall (all-of-p oddp (lambda (n) (= n 15))) 15))
(is (not (funcall (all-of-p evenp (lambda (n) (= n 15))) 10)))
;; in a map
(is (equal (mapcar (all-of-p oddp (lambda (n) (= n 15))) (list 15 15))
'(t t)))
(is (equal (mapcar (all-of-p oddp (lambda (n) (= n 15))) (list 15 14))
'(t nil)))
(is (equal (mapcar (all-of-p evenp (lambda (n) (= n 15))) (list 15 15))
'(nil nil))))
;; ---------- safe-cadr ----------
(test test-safe-cadr
"Test we can safely extract the second element of a pair or list."
(is (equal (safe-cadr (cons 1 2)) 2))
(is (equal (safe-cadr (cons 1 (cons 2 3))) 2))
(is (equal (safe-cadr (list 1 2)) 2))
(is (equal (safe-cadr (list 1 2 3)) 2))
(is (null (safe-cadr (list 1))))
(is (null (safe-cadr (cons 1 nil)))))
;; ---------- Flat maps ----------
(test test-mapappend-as-mapcar
"Test mapappend defaults to working like mapcar"
(let ((l (list 1 2 3 4 5)))
(is (equal (mapcar #'1+ l)
(mapappend #'1+ l)))))
(test test-mapappend-flattens
"Test that mapappend flattens its results."
(let ((l (list 1 2 (list 3 4) 5)))
(is (equal (mapcar #'1+ (flatten l))
(mapappend #'1+ l)))))
(test test-mapappend-flattens-leading-list
"Test that mapappend flattens its results with a leading list."
(let ((l (list (list 1 2) (list 3 4) 5)))
(is (equal (mapcar #'1+ (flatten l))
(mapappend #'1+ l)))))
| 5,345 | Common Lisp | .lisp | 134 | 36.58209 | 75 | 0.599535 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 5fe7dc44b46324463f542f56558b239bd8f9d89c3092a7dba7f4cb320ddacbf3 | 26,546 | [
-1
] |
26,547 | test-wires.lisp | simoninireland_cl-vhdsl/test/test-wires.lisp | ;; Tests of wire and pin operations
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/test)
(in-suite cl-vhdsl)
(test test-new-wire
"Test a new wire is initially floating."
(let ((w (make-instance 'hw:wire)))
(is (equal (hw:state w) :floating))))
(test test-assert-pin-floating
"Test asserting a pin to an initial floating value."
(let* ((w (make-instance 'hw:wire))
(p (make-instance 'hw:pin :wire w)))
(is (eql (hw:wire p) w))
(is (equal (slot-value p 'hw::state) :tristate))
(is (equal (hw:state w) :floating))
(is (hw::wire-pin-asserting-p w p :tristate))))
(test test-add-pin-twice
"Test we can't add a pin again to the same wire."
(let* ((w (make-instance 'hw:wire))
(p (make-instance 'hw:pin :wire w)))
(signals (error)
(setf (hw:wire p) p))))
(test test-assert-pin
"Test asserting a pin to a logic value."
(let* ((w (make-instance 'hw:wire))
(p (make-instance 'hw:pin :wire w)))
(setf (hw:state p) 0)
(is (equal (slot-value p 'hw::state) 0))
(is (equal (hw:state w) 0))))
(test test-assert-pin-same
"Test asserting a pin to the same value again."
(let* ((w (make-instance 'hw:wire))
(p (make-instance 'hw:pin :wire w)))
(setf (hw:state p) 0)
(setf (hw:state p) 0)
(is (equal (slot-value p 'hw::state) 0))
(is (equal (hw:state w) 0))))
(test test-assert-pin-different
"Test asserting a pin to a different value."
(let* ((w (make-instance 'hw:wire))
(p (make-instance 'hw:pin :wire w)))
(setf (hw:state p) 0)
(setf (hw:state p) 1)
(is (equal (slot-value p 'hw::state) 1))
(is (equal (hw:state w) 1))))
(test test-assert-pin-tristate
"Test tri-stating the pin."
(let* ((w (make-instance 'hw:wire))
(p (make-instance 'hw:pin :wire w)))
(setf (hw:state p) 0)
(setf (hw:state p) :tristate)
(is (equal (slot-value p 'hw::state) :tristate))
(is (equal (hw:state w) :floating))))
(test test-assert-pin-reading
"Test setting the pin to reading."
(let* ((w (make-instance 'hw:wire))
(p (make-instance 'hw:pin :wire w)))
(setf (hw:state p) 0)
(setf (hw:state p) :reading)
(is (equal (slot-value p 'hw::state) :reading))
(is (equal (hw:state w) :floating))))
(test test-assert-pins-same
"Test asserting two pins to the same value."
(let* ((w (make-instance 'hw:wire))
(p1 (make-instance 'hw:pin :wire w))
(p2 (make-instance 'hw:pin :wire w)))
(setf (hw:state p1) 0)
(setf (hw:state p2) 0)
(is (equal (slot-value p1 'hw::state) 0))
(is (equal (slot-value p2 'hw::state) 0))
(is (equal (hw:state w) 0))))
(test test-assert-pins-different
"Test asserting two pins to different values."
(let* ((w (make-instance 'hw:wire))
(p1 (make-instance 'hw:pin :wire w))
(p2 (make-instance 'hw:pin :wire w))
(p3 (make-instance 'hw:pin :wire w :state :reading)))
(setf (hw:state p1) 0)
(setf (hw:state p2) 1) ; this send the wire floating
(signals (hw:reading-floating-value)
(hw:state p3))))
(test test-assert-pins-tristated
"Test asserting a pin when the other is tri-stated."
(let* ((w (make-instance 'hw:wire))
(p1 (make-instance 'hw:pin :wire w))
(p2 (make-instance 'hw:pin :wire w)))
(setf (slot-value p1 'hw::state) 1)))
(test test-assert-pins-reading
"Test asserting a pin when the other is reading."
(let* ((w (make-instance 'hw:wire))
(p1 (make-instance 'hw:pin :wire w))
(p2 (make-instance 'hw:pin :wire w)))
(setf (slot-value p1 'hw::state) :reading)
(setf (slot-value p2 'hw::state) 1)))
(test test-pin-read
"Test reading a pin's state."
(let* ((w (make-instance 'hw:wire))
(p1 (make-instance 'hw:pin :wire w))
(p2 (make-instance 'hw:pin :wire w)))
(setf (hw:state p1) 0)
(setf (hw:state p2) :reading)
;; state of the pin is the state of the wire
(is (equal (hw:state p2) 0))))
(test test-pin-not-read
"Test reading the state of a non-reading pin."
(let* ((w (make-instance 'hw:wire))
(p1 (make-instance 'hw:pin :wire w))
(p2 (make-instance 'hw:pin :wire w)))
(setf (hw:state p1) 0)
;; test we can't read a :tristated pin
(setf (hw:state p2) :tristate)
(signals (hw:reading-non-reading-pin)
(hw:state p2))))
(test test-pin-read-floating
"Test reading a pin's state when its wire is floating."
(let* ((w (make-instance 'hw:wire))
(p1 (make-instance 'hw:pin :wire w))
(p2 (make-instance 'hw:pin :wire w)))
(setf (hw:state p2) :reading)
;; test we see the signal
(signals (hw:reading-floating-value)
(hw:state p2))))
(test test-pins-floating
"Test we can determine when any of a set of pins is floating."
(let* ((w1 (make-instance 'hw:wire))
(w2 (make-instance 'hw:wire))
(conn (make-instance 'hw:connector :width 3))
(ps (hw:pins conn)))
(setf (hw:wire (elt ps 0)) w1)
(setf (hw:wire (elt ps 1)) w2)
(setf (hw:wire (elt ps 2)) w2)
(setf (hw:state (elt ps 0)) 1)
(is (hw:floating-p conn))
(setf (hw:state (elt ps 1)) 0)
(setf (hw:state (elt ps 2)) :reading)
(is (null (hw:floating-p conn)))))
| 5,809 | Common Lisp | .lisp | 152 | 34.611842 | 75 | 0.649048 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 2cc1126fed15fdf72545ac8563521cecea3cf32ebf1041cc22d9ac0a06e58afd | 26,547 | [
-1
] |
26,548 | test-wiring.lisp | simoninireland_cl-vhdsl/test/test-wiring.lisp | ;; Tests of wiring components
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/test)
(in-suite cl-vhdsl)
;; ---------- Accessing qualified slots ----------
(defclass test-slotted (hw:component hw:enabled)
((one
:pins 8)
(two
:pins 8
:role :control)
(three
:pins 16
:role :io))
(:metaclass hw:metacomponent))
(defclass test-subcomponents (hw:component hw:enabled)
((four
:pins 8)
(c
:initarg :c
:type test-slotted
:initarg :sub)
(other
:initform 24))
(:metaclass hw:metacomponent))
;; ---------- Sub-components ----------
(test test-subcomponents
"Test we can identify sub-component and non-sub-component slots."
(let ((tc (make-instance 'test-subcomponents)))
(is (hw:subcomponent-p (class-of tc) 'c))
;; test against non-component slots (including pin slots)
(is (not (hw:subcomponent-p (class-of tc) 'other)))
(is (not (hw:subcomponent-p (class-of tc) 'four)))))
(test test-subcomponent-interface
"Test we can extract the sub-component interface."
(let ((tc (make-instance 'test-subcomponents)))
(is (equal (hw:subcomponent-interface (class-of tc))
(list 'c)))))
(test test-empty-subcomponent-interface
"Test we can extract an empty sub-component interface."
(let ((tc (make-instance 'test-slotted)))
(is (null (hw:subcomponent-interface (class-of tc))))))
(test test-subcomponents-of-object
"Test we can extract the sub-components of an object."
(let* ((tc1 (make-instance 'test-slotted))
(tc2 (make-instance 'test-subcomponents :c tc1)))
(is (equal (hw:components tc2)
(list tc1)))
;; test against the sub-component as well
(is (null (hw:components tc1)))))
;; ---------- Wiring connectors and buses ----------
(test test-wire-slots-same-component
"Test we can wire two pin interface slots on the same class together."
(let ((tc (make-instance 'test-slotted))
(b (make-instance 'hw:bus :width 8)))
(hw:connect-pins (slot-value tc 'one) b)
(hw:connect-pins (slot-value tc 'two) b)
;; bus can see the component
(let ((cs (hw:components-seen-by b)))
(is (equal (length cs) 1))
(is (member tc cs)))
;; component doesn't see itself
(is (null (hw:components-seen-by tc)))))
(test test-wire-slots-different-components
"Test we can wire two slots on different components together."
(let ((tc1 (make-instance 'test-slotted ))
(tc2 (make-instance 'test-slotted))
(b (make-instance 'hw:bus :width 8)))
(hw:connect-pins (slot-value tc1 'one) b)
(hw:connect-pins (slot-value tc2 'two) b)
;; bus can see both component
(let ((cs (hw:components-seen-by b)))
(is (equal (length cs) 2))
(is (member tc1 cs))
(is (member tc2 cs)))
;; components see each other, but not themselves
(is (equal (hw:components-seen-by tc1) (list tc2)))
(is (equal (hw:components-seen-by tc2) (list tc1)))))
(test test-wire-incomptible-widths
"Test we can't connect slots with unequal widths."
(let ((tc (make-instance 'test-slotted))
(b (make-instance 'hw:bus :width 8)))
(hw:connect-pins (slot-value tc 'one) b)
(signals (hw:incompatible-pin-widths)
(hw:connect-pins (slot-value tc 'three) b))))
;; ---------- Wiring slots ----------
(test test-wire-slots
"Test we can wire two compatible slots."
(let ((tc (make-instance 'test-slotted)))
(hw:connect-slots tc 'one
tc 'two)
;; component doesn't see itself
(is (null (hw:components-seen-by tc)))))
(test test-wire-slots-sub
"Test we can wire-up slots on sub-components."
(let* ((tc1 (make-instance 'test-slotted ))
(tc2 (make-instance 'test-subcomponents :sub tc1)))
(hw:connect-slots tc1 'one
tc2 (list 'c 'two))))
(test test-wire-slots-super-sub
"Test we can wire-up slots between component and sub-somponent."
(let* ((tc1 (make-instance 'test-slotted ))
(tc2 (make-instance 'test-subcomponents :sub tc1)))
(hw:connect-slots tc2 'four
tc2 (list 'c 'two))))
(test test-wire-slots-widths
"Test we can't wire slots with incompatible widths."
(let ((tc (make-instance 'test-slotted)))
(signals (hw:incompatible-pin-widths)
(hw:connect-slots tc 'one
tc 'three))))
(test test-wire-slots-widths-sub
"Test we can't wire-up slots on sub-components with incompatible widths."
(let* ((tc1 (make-instance 'test-slotted))
(tc2 (make-instance 'test-subcomponents :sub tc1)))
(signals (hw:incompatible-pin-widths)
(hw:connect-slots tc1 'one
tc2 (list 'c 'three)))))
(test test-wire-slots-missing
"Test we can't wire missing slots."
(let ((tc (make-instance 'test-subcomponents)))
(signals (hw:non-pin-interface-slot)
(hw:connect-slots tc 'four
tc 'one))))
(test test-wire-slots-other
"Test we can't wire slots to non-pin-slots."
(let ((tc (make-instance 'test-subcomponents)))
(signals (hw:non-pin-interface-slot)
(hw:connect-slots tc 'four
tc 'other))))
;; ---------- Fully wired ----------
(test test-fully-wired-pin
"Test we can detect a fully-wired pin."
(let* ((w (make-instance 'hw:wire))
(p (make-instance 'hw:pin :wire w)))
(hw:ensure-fully-wired p)))
(test test-non-fully-wired-pin
"Test we can detect an unwired pin."
(let* ((p (make-instance 'hw:pin)))
(signals (hw:not-fully-wired)
(hw:ensure-fully-wired p))))
(test test-fully-wired-connector
"Test we can detect a fully-wired connector."
(let* ((b (make-instance 'hw:bus :width 4))
(conn (make-instance 'hw:connector :width 4)))
(hw:connect-pins conn b)
(hw:ensure-fully-wired conn)))
(test test-non-fully-wired-connector
"Test we can detect an unwired connector."
(let* ( (conn (make-instance 'hw:connector :width 4)))
(signals (hw:not-fully-wired)
(hw:ensure-fully-wired conn))))
(test test-fully-wired-component
"Test we can detect a fully-wired component."
(let* ((db (make-instance 'hw:bus :width 8))
(ab (make-instance 'hw:bus :width 16))
(en (make-instance 'hw:pin :wire (make-instance 'hw:wire)))
(tc (make-instance 'test-slotted
:enable (hw:wire en))))
(hw:connect-pins (slot-value tc 'three) ab)
(hw:connect-pins (slot-value tc 'one) db)
(hw:connect-pins (slot-value tc 'two) db)
(hw:ensure-fully-wired tc)))
(test test-non-fully-wired-component
"Test we can detect an unwired component."
(let* ((db (make-instance 'hw:bus :width 8))
(ab (make-instance 'hw:bus :width 16))
(tc (make-instance 'test-slotted)))
(hw:connect-pins (slot-value tc 'three) ab)
(hw:connect-pins (slot-value tc 'one) db)
(hw:connect-pins (slot-value tc 'two) db)
(signals (hw:not-fully-wired)
(hw:ensure-fully-wired tc))))
(test test-fully-wired-subcomponent
"Test we can detect a fully-wired component with sub-components."
(let* ((db (make-instance 'hw:bus :width 8))
(ab (make-instance 'hw:bus :width 16))
(en (make-instance 'hw:pin :wire (make-instance 'hw:wire)))
(tc1 (make-instance 'test-slotted
:enable (hw:wire en)))
(tc2 (make-instance 'test-subcomponents
:enable (hw:wire en)
:c tc1)))
(hw:connect-pins (slot-value tc1 'three) ab)
(hw:connect-pins (slot-value tc1 'one) db)
(hw:connect-pins (slot-value tc1 'two) db)
(hw:connect-pins (slot-value tc2 'four) db)
(hw:ensure-fully-wired tc2)))
(test test-non-fully-wired-subcomponent
"Test we can detect an unwired sub-component."
(let* ((db (make-instance 'hw:bus :width 8))
(ab (make-instance 'hw:bus :width 16))
(en (make-instance 'hw:pin :wire (make-instance 'hw:wire)))
(tc1 (make-instance 'test-slotted
:enable (hw:wire en)))
(tc2 (make-instance 'test-subcomponents
:c tc1)))
(hw:connect-pins (slot-value tc1 'three) ab)
(hw:connect-pins (slot-value tc1 'one) db)
(hw:connect-pins (slot-value tc1 'two) db)
(hw:connect-pins (slot-value tc2 'four) db)
(signals (hw:not-fully-wired)
(hw:ensure-fully-wired tc2))))
;; ---------- Self-wiring components ----------
(defclass test-selfwired (hw:component hw:enabled)
((tc1
:type test-slotted
:initarg :one)
(tc2
:type test-slotted
:initarg :two)
(three
:pins 16))
(:wiring ((tc1 one) (tc2 one))
((tc1 two) (tc2 two))
(three (tc1 three) (tc2 three))
((tc1 hw:enable) (tc2 hw:enable) hw:enable))
(:metaclass hw:metacomponent))
(test test-self-wired-none
"Test we don't always have to have a wiring diagram."
(let ((c (make-instance 'test-slotted)))
(is (null (hw:wiring-diagram (class-of c))))))
(test test-self-wired-simple
"Test simple self-wiring."
(let ((c (make-instance 'test-selfwired
:one (make-instance 'test-slotted)
:two (make-instance 'test-slotted))))
;; pin interface
(is (null (set-difference (hw:pin-interface (class-of c))
'(three hw:enable))))
;; wiring diagram
(let* ((cl (class-of c))
(wires (hw::ensure-wiring-diagram cl (hw:wiring-diagram cl))))
(is (not (null wires)))
(is (equal (length wires) 4)))))
(test test-self-wired-correctly
"Test that the self-wiring happens correctly and fully."
(let ((c (make-instance 'test-selfwired
:one (make-instance 'test-slotted)
:two (make-instance 'test-slotted))))
(hw:ensure-fully-wired c)))
| 10,038 | Common Lisp | .lisp | 257 | 34.957198 | 75 | 0.668865 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 715b78b71214651b5e36e5cb49c9af27759d6cf8decf04ee7615747ba9e5543a | 26,548 | [
-1
] |
26,549 | test-datapath.lisp | simoninireland_cl-vhdsl/test/test-datapath.lisp | ;; Tests of composed datapaths
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/test)
(in-suite cl-vhdsl)
(test test-read-ram
"Test we can load a register from RAM."
(let* ((data-bus (make-instance 'hw:bus :width 8))
(data-bus-connector (make-instance 'hw:connector :width 8))
(address-bus (make-instance 'hw:bus :width 16))
(address-bus-connector (make-instance 'hw:connector :width 16))
(clk (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(reg-en (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(reg-wr (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(ram-en (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(ram-wr (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(reg (make-instance 'hw:register :width 8
:clock (hw:wire clk)
:enable (hw:wire reg-en)
:bus data-bus
:write-enable (hw:wire reg-wr)))
(ram (make-instance 'hw:ram :address-bus-width 16
:data-bus-width 8
:address-bus address-bus
:data-bus data-bus
:clock (hw:wire clk)
:enable (hw:wire ram-en)
:write-enable (hw:wire ram-wr))))
;; connect the connectors
(hw:connect-pins data-bus-connector data-bus)
(setf (hw:pin-states data-bus-connector) :reading)
(hw:connect-pins address-bus-connector address-bus)
(hw:ensure-fully-wired reg ram)
;; put some values into RAM
(setf (aref (hw:ram-elements ram) #16rFF) 123)
;; set up the register to be written to
(setf (hw:state reg-en) 1)
(setf (hw:state reg-wr) 1)
;; set up the RAM to be read from
(setf (hw:state ram-wr) 0)
(setf (hw:state ram-en) 1)
;; put the address onto the address bus
(setf (hw:pins-value address-bus-connector) #16rFF)
;; clock the system
(setf (hw:state clk) 1)
(setf (hw:state clk) 0)
;; check we loaded the value
(is (equal (aref (hw:ram-elements ram) #16rFF) 123))
(is (equal (hw:register-value reg) 123))))
| 2,785 | Common Lisp | .lisp | 69 | 36.057971 | 75 | 0.676395 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | e5ec4e8687f732eefa6567f8ffbf4cb2c4f8cfa2885aa1ab303cf5eb4ed29205 | 26,549 | [
-1
] |
26,550 | test-debugging.lisp | simoninireland_cl-vhdsl/test/test-debugging.lisp | ;; Tests of the debugging functions
;;
;; Copyright (C) 2023 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/test)
(in-suite cl-vhdsl)
;; ---------- Component visibility ----------
(defclass test-of-wire (hw:component)
((pin
:initarg :pin
:pins 1
:role :io))
(:metaclass hw:metacomponent))
(test test-seen-wire
"Test we can see the components attached to a wire."
(let* ((w (make-instance 'hw:wire))
(p (make-instance 'hw:pin :wire w))
(tw (make-instance 'test-of-wire :pin p)))
(let ((seen (hw:components-seen-by w)))
(is (equal (length seen) 1))
(is (member tw seen)))))
(defclass test-of-bus (hw:component)
((bus
:initarg :bus
:pins t
:role :io))
(:metaclass hw:metacomponent))
(test test-seen-bus
"Test we can see the components attached to a bus."
(let* ((b (make-instance 'hw:bus :width 4))
(p (make-instance 'hw:pin :wire (aref (hw:wires b) 0)))
(tw1 (make-instance 'test-of-bus :bus b))
(tw2 (make-instance 'test-of-bus :bus b)))
;; test what the bus sees
(let ((seen (hw:components-seen-by b)))
(is (equal (length seen) 2))
(is (member tw1 seen))
(is (member tw2 seen)))
;; test the pin sees the same components
(let ((seen (hw:components-seen-by p)))
(is (equal (length seen) 2))
(is (member tw1 seen))
(is (member tw2 seen)))
;; test what the components see
(let ((seen (hw:components-seen-by tw1)))
(is (equal (length seen) 1))
(is (member tw2 seen)))
(let ((seen (hw:components-seen-by tw2)))
(is (equal (length seen) 1))
(is (member tw1 seen)))
))
| 2,339 | Common Lisp | .lisp | 65 | 32.353846 | 75 | 0.661654 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 6106634cfd2f12c24a7c8d4117714d75860a9725005257aba6df87358ab2552e | 26,550 | [
-1
] |
26,551 | test-alu.lisp | simoninireland_cl-vhdsl/test/test-alu.lisp | ;; Tests of latches and an ALU
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/test)
(in-suite cl-vhdsl)
;; ---------- ALU operations ----------
(test test-alu-ops
"Test ALU operations."
(let* ((data-bus (make-instance 'hw:bus :width 8))
(data-bus-connector (make-instance 'hw:connector
:width 8))
(op-bus (make-instance 'hw:bus :width 3))
(op-bus-connector (make-instance 'hw:connector
:width 3))
(clk (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(en-a (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(en-b (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(en-u (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(wr-a (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(wr-b (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(a (make-instance 'hw:latch :width 8
:clock (hw:wire clk)
:enable (hw:wire en-a)
:bus data-bus
:write-enable (hw:wire wr-a)))
(b (make-instance 'hw:latch :width 8
:clock (hw:wire clk)
:enable (hw:wire en-b)
:bus data-bus
:write-enable (hw:wire wr-b)))
(alu (make-instance 'hw:alu :width 8
:enable (hw:wire en-u)
:op-bus op-bus
:c-bus data-bus)))
;; connect the data and ops bus connectors
(hw:connect-pins data-bus-connector data-bus)
(hw:connect-pins op-bus-connector op-bus)
;; wire the latches to the ALU
(hw:connect-slots a 'hw::latched-bus alu 'hw::a-bus)
(hw:connect-slots b 'hw::latched-bus alu 'hw::b-bus)
;; sanity check
(hw:ensure-fully-wired alu)
;; place some data into the registers
(setf (hw:pins-value data-bus-connector) #2r101101)
(setf (hw:state en-a) 1)
(setf (hw:state wr-a) 1)
(setf (hw:state clk) 1)
(setf (hw:state clk) 0)
(setf (hw:state en-a) 0)
(setf (hw:pins-value data-bus-connector) #2r100100)
(setf (hw:state en-b) 1)
(setf (hw:state wr-b) 1)
(setf (hw:state clk) 1)
(setf (hw:state clk) 0)
(setf (hw:state en-b) 0)
;; check we put the values onto the latches
(is (equal (hw:register-value a)
(hw:pins-value (hw::alu-a-bus alu))))
(is (equal (hw:register-value a) #2r101101))
(is (equal (hw:register-value b)
(hw:pins-value (hw::alu-b-bus alu))))
(is (equal (hw:register-value b) #2r100100))
;; run the operations
(setf (hw:pins-value op-bus-connector) #2r000) ;; avoid floating inputs for ops
(setf (hw:state en-u) 1)
(let ((a (hw:pins-value (hw::alu-a-bus alu)))
(b (hw:pins-value (hw::alu-b-bus alu))))
;; pass-through a
(setf (hw:pins-value op-bus-connector) #2r000)
(is (equal (hw:pins-value (hw::alu-c-bus alu)) a))
;; a and b
(setf (hw:pins-value op-bus-connector) #2r001)
(is (equal (hw:pins-value (hw::alu-c-bus alu)) (logand a b)))
;; a or b
(setf (hw:pins-value op-bus-connector) #2r010)
(is (equal (hw:pins-value (hw::alu-c-bus alu)) (logior a b)))
;; not a
(setf (hw:pins-value op-bus-connector) #2r011)
;; need to keep within 8 bits
(let ((8-bit-mask (round (1- (ash 1 8)))))
(is (equal (hw:pins-value (hw::alu-c-bus alu)) (logand (lognot a)
8-bit-mask))))
;; a + b
(setf (hw:pins-value op-bus-connector) #2r100)
(is (equal (hw:pins-value (hw::alu-c-bus alu)) (+ a b)))
;; a - b
(setf (hw:pins-value op-bus-connector) #2r101)
(is (equal (hw:pins-value (hw::alu-c-bus alu)) (- a b)))
;; a + 1
(setf (hw:pins-value op-bus-connector) #2r110)
(is (equal (hw:pins-value (hw::alu-c-bus alu)) (1+ a)))
;; a - 1
(setf (hw:pins-value op-bus-connector) #2r111)
(let ((r (hw:pins-value (hw::alu-c-bus alu))))
(is (equal r (1- a)))
;; value remains on output when ALU disabled
(setf (hw:state en-u) 0)
(is (equal (hw:pins-value (hw::alu-c-bus alu)) r))
;; value doesn't change when ALU disabled
(setf (hw:pins-value op-bus-connector) #2r100)
(is (equal (hw:pins-value (hw::alu-c-bus alu)) r))))))
| 4,907 | Common Lisp | .lisp | 122 | 34.92623 | 83 | 0.620907 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 8913b5756f9ad7a133abde0d2a2abf1ebfbd59aba8734b109ccb4c4dea6a5c56 | 26,551 | [
-1
] |
26,552 | test-ring-counters.lisp | simoninireland_cl-vhdsl/test/test-ring-counters.lisp | ;; Tests of ring counters
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/test)
(in-suite cl-vhdsl)
(test test-rc-initial
"Test the initial state of the counter."
(let* ((bus (make-instance 'hw:bus :width 4))
(bus-connector (make-instance 'hw:connector :width 4))
(rc (make-instance 'hw:ring-counter :width 4
:bus bus)))
;; connect the connector
(hw:connect-pins bus-connector bus)
(setf (hw:pin-states bus-connector) :reading)
(is (equal (hw:pins-value bus-connector) #2r0001))))
(test test-rc-inc
"Test the counter increments correctly."
(let* ((bus (make-instance 'hw:bus :width 4))
(bus-connector (make-instance 'hw:connector :width 4))
(en (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(clk (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(rc (make-instance 'hw:ring-counter :width 4
:bus bus
:clock (hw:wire clk)
:enable (hw:wire en))))
;; connect the connector
(hw:connect-pins bus-connector bus)
(setf (hw:pin-states bus-connector) :reading)
;; clock the counter twice
(setf (hw:state en) 1)
(dotimes (i 2)
(setf (hw:state clk) 1)
(setf (hw:state clk) 0))
(is (equal (hw:pins-value bus-connector) #2r0100))))
(test test-rc-inc-disabled
"Test the counter doesn't increment when disabled."
(let* ((bus (make-instance 'hw:bus :width 4))
(bus-connector (make-instance 'hw:connector :width 4))
(en (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(clk (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(rc (make-instance 'hw:ring-counter :width 4
:bus bus
:clock (hw:wire clk)
:enable (hw:wire en))))
;; connect the connector
(hw:connect-pins bus-connector bus)
(setf (hw:pin-states bus-connector) :reading)
;; clock the counter twice
;; don't enable
(dotimes (i 2)
(setf (hw:state clk) 1)
(setf (hw:state clk) 0))
(is (equal (hw:pins-value bus-connector) #2r0001))))
(test test-rc-wrap
"Test the counter wraps-around."
(let* ((bus (make-instance 'hw:bus :width 4))
(bus-connector (make-instance 'hw:connector :width 4))
(clk (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(en (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(rc (make-instance 'hw:ring-counter :width 4
:bus bus
:clock (hw:wire clk)
:enable (hw:wire en))))
;; connect the connector
(hw:connect-pins bus-connector bus)
(setf (hw:pin-states bus-connector) :reading)
;; clock the counter four times
(setf (hw:state en) 1)
(dotimes (i 4)
(setf (hw:state clk) 1)
(setf (hw:state clk) 0))
(is (equal (hw:pins-value bus-connector) #2r0001))))
(test test-rc-bounded
"Test the counter can't be set too high."
(let* ((bus (make-instance 'hw:bus :width 4))
(bus-connector (make-instance 'hw:connector :width 4))
(clk (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(en (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(rc (make-instance 'hw:ring-counter :width 4
:bus bus
:clock (hw:wire clk)
:enable (hw:wire en))))
;; connect the connector
(hw:connect-pins bus-connector bus)
(setf (hw:pin-states bus-connector) :reading)
(setf (hw::ring-counter-count rc) 9)
(is (equal (hw:pins-value bus-connector) #2r0001))))
(test test-rc-reset
"Test the counter resets correctly."
(let* ((bus (make-instance 'hw:bus :width 4))
(bus-connector (make-instance 'hw:connector :width 4))
(clk (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(en (make-instance 'hw:pin :state 0
:wire (make-instance 'hw:wire)))
(rc (make-instance 'hw:ring-counter :width 4
:bus bus
:clock (hw:wire clk)
:enable (hw:wire en))))
;; connect the connector
(hw:connect-pins bus-connector bus)
(setf (hw:pin-states bus-connector) :reading)
;; clock the counter twice
(setf (hw:state en) 1)
(is (equal (hw:pins-value bus-connector) #2r0001))
(dotimes (i 2)
(setf (hw:state clk) 1)
(setf (hw:state clk) 0))
(is (equal (hw:pins-value bus-connector) #2r0100))
;; then reset
(hw::ring-counter-reset rc)
(is (equal (hw:pins-value bus-connector) #2r0001))))
| 5,201 | Common Lisp | .lisp | 135 | 33.466667 | 75 | 0.651993 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 7abc4bc880318f1bd93325bdc3a065f8987da94ae8827f86b10e2ff2a9d77696 | 26,552 | [
-1
] |
26,553 | test-rtl.lisp | simoninireland_cl-vhdsl/test/test-rtl.lisp | ;; Tests of synthesisable fragment parsing
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/test)
(in-suite cl-vhdsl)
;; ---------- Basic features ----------
(test test-constants
"Test we can recognise constants."
(is (rtl::constant-p (ast:parse 1)))
(is (rtl::constant-p (ast:parse '(+ 1 2)))))
(test test-operators
"Test we can recognise (non)-operators."
;; (Free variables to avoid being eliminated as constants)
;; arithmetic operators
(is (rtl::operator-p (ast:parse '(+ 1 a))))
(is (rtl::operator-p (ast:parse '(- 1 a))))
(is (rtl::operator-p (ast:parse '(* 1 a))))
(is (rtl::operator-p (ast:parse '(/ 1 a))))
(is (rtl::operator-p (ast:parse '(mod 1 a))))
(is (rtl::operator-p (ast:parse '(ash a -1))))
;; bitwise operators
(is (rtl::operator-p (ast:parse '(lognot a))))
(is (rtl::operator-p (ast:parse '(logand 45 a))))
(is (rtl::operator-p (ast:parse '(logior 56 a))))
(is (rtl::operator-p (ast:parse '(logxor 345 a))))
;; logical operators
;; (note that and and or are macros that expand to conditionals)
(is (rtl::operator-p (ast:parse '(not a))))
(is (rtl::operator-p (ast:parse '(= a 12))))
(is (rtl::operator-p (ast:parse '(/= a 12 b))))
(is (rtl::if-p (ast:parse (macroexpand '(and t a b)))))
(is (rtl::constant-p (ast:parse (macroexpand '(and nil a b))))) ;; short-circuiting
(is (rtl::let-p (ast:parse (macroexpand '(or b nil a)))))
;; non-operators
(is (not (rtl::operator-p (ast:parse '(~ 1 a))))) ;; not an operator
(is (rtl::operator-p (ast:parse '(ash a -1 45))))) ;; too many arguments
(test test-if
"Test we can recognise valid and invalid if- and cond--forms."
;; (Free variables to avoid being eliminated as constants)
(is (rtl::if-p (ast:parse '(if b a))))
(is (rtl::if-p (ast:parse '(if b a (+ a 1)))))
(is (rtl::if-p (ast:parse '(cond ((evenp a) a)
((oddp (+ a 1))))))))
(test test-assignment
"Test we can do assignments."
;; (Free variables to avoid being eliminated as constants)
(is (rtl::setf-p (ast:parse'(setf A (+ 1 2 3 a))))))
;; ---------- Fragments ----------
(test test-simple
"Test simple fragments."
(rtl:validate '(let ((var (+ 24 2)))
(setf var (1+ var)))))
(test test-free
"Test a fragment for free variables."
;; closed in environment
(rtl:validate '(let ((val (+ A (ash B 8))))
(setf A val))
'(A B))
(rtl:validate '(let ((val (+ A (ash B 8))))
(setf A val))
'(A B C D)) ;; make sure the subsetp is the right way round....
;; unhandled free variable
(signals rtl:unknown-variable
(rtl:validate '(let ((val (+ A (ash B 8))))
(setf A val))
'(A))))
| 3,386 | Common Lisp | .lisp | 81 | 38.901235 | 85 | 0.641159 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | ad1b5ae1e7ba6de31330e019770f3accc658aaf3f5b658278fbf03cdea6e7f52 | 26,553 | [
-1
] |
26,554 | package.lisp | simoninireland_cl-vhdsl/src/package.lisp | ;; Package definition
;;
;; Copyright (C) 2023 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :common-lisp-user)
(defpackage cl-vhdsl
(:use :cl :alexandria :serapeum)
(:export
;; list utilities
#:index-non-nil
#:non-nil-subseq
#:uniquify
#:listify
#:delistify
#:zip-without-null
;; predicate combinators
#:any-of-p
#:all-of-p
;; data structure manipulations
#:safe-cadr
#:mapappend
))
| 1,132 | Common Lisp | .lisp | 36 | 29.055556 | 75 | 0.728022 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 94b59c42172c484628be4d5dcf8944de6058edcf3788c834c72de3e4f793cace | 26,554 | [
-1
] |
26,555 | utils.lisp | simoninireland_cl-vhdsl/src/utils.lisp | ;; Helper functions and macros
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl)
;; ---------- Searching lists for non-nil ----------
(defun index-non-nil (l)
"Return the index (0-based) of the first non-nil element of sequnce L."
(dolist (i (iota (length l)))
(if (not (null (elt l i)))
(return i))))
(defun non-nil-subseq (l)
"Return the non-nil sub-sequence of L.
This will extract the first such sub-sequence, beginning from the index
extracted by `index-not-nil' and containing all elements up to the
next nil element of the end of the sequence."
(when-let ((i (index-non-nil l)))
(dolist (j (iota (- (length l) (1+ i)) :start 1))
(if (null (elt l (+ i j)))
(return-from non-nil-subseq (subseq l i (+ i j)))))
;; if we get here, the rest of the list is non-nil
(subseq l i)))
;; ---------- Remove duplicates and nil values from a sequence ----------
(defun uniquify (s)
"Remove duplicates and nils from sequence S."
(remove-if #'null (remove-duplicates s)))
;; ---------- Increasing and decreasing list nesting ----------
(defun listify (l)
"Wrap each element of L in a singleton list."
(mapcar #'list l))
(defun delistify (l)
"Remove a level of nesting from each element of L."
(mapcar #'car l))
;; ---------- Zipping in the presence of null ----------
(defun zip-without-null (xs ys)
"Zip lists XS and YS when elements are not null.
If either element is null, the pair is omitted."
(when (not (or (null xs)
(null ys)))
(if (or (null (car xs))
(null (car ys)))
(zip-without-null (cdr xs) (cdr ys))
(cons (list (car xs) (car ys))
(zip-without-null (cdr xs) (cdr ys))))))
;; ---------- Predicate combinators ----------
(defun generate-predicate-clause (p c)
"Geerate the predicate clause P testing variable C."
(cond ((symbolp p)
`(,p ,c))
((consp p)
(equal (symbol-name (car p)) "lambda")
`(funcall ,p ,c))
(t
(error "Can't parser disjunct ~a" p))))
(defun generate-predicate-clauses (preds c)
"Generate clauses for PREDS testing variable C."
(mapcar #'(lambda (p)
(generate-predicate-clause p c))
preds))
(defmacro any-of-p (&rest preds)
"Generate an inline lambda predicate matching any of PREDS.
Each element of PREDS can be a symbol representing a function (predicate)
or an inline function (lambda-expression)."
(with-gensyms (c)
(let ((pred-clauses (generate-predicate-clauses preds c)))
`#'(lambda (,c)
(or ,@pred-clauses)))))
(defmacro all-of-p (&rest preds)
"Generate an inline lambda predicate matching all of PREDS.
Each element of PREDS can be a symbol representing a function (predicate)
or an inline function (lambda-expression)."
(with-gensyms (c)
(let ((pred-clauses (generate-predicate-clauses preds c)))
`#'(lambda (,c)
(and ,@pred-clauses)))))
;; ---------- Second element of pair or list ----------
;; Neither of `elt' or `cadr' ar safe when applied to pairs.
(defun safe-cadr (l)
"Return the second element of L.
L can be a list or a pair."
(if (consp (cdr l))
(cadr l)
(cdr l)))
;; ---------- Flat maps----------
(defun mapappend (f &rest ls)
"Apply F to all elements of lists LS at whatever depth, returning a flat list of results."
(flatten (mapcar f (flatten ls))))
| 4,021 | Common Lisp | .lisp | 101 | 36.891089 | 92 | 0.671734 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 019d2cf6d5321517e22b2563ce37150116a895a8c032f018127ed90562f4dbc6 | 26,555 | [
-1
] |
26,556 | package.lisp | simoninireland_cl-vhdsl/src/emu/package.lisp | ;; Package definition for the emulation package
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :common-lisp-user)
(defpackage cl-vhdsl/emu
(:use :cl :alexandria)
(:local-nicknames (:def :cl-vhdsl/def))
(:export
;; memory
#:memory
#:memory-initialise
#:memory-size
#:memory-locations
#:memory-location
#:cached-memory
#:memory-instruction
;; registers
#:register
#:register-value
#:flag
#:flag-value
;; cores
#:core
#:core-add-register
#:core-register
#:core-pc
#:core-pc-value
#:core-register-value
#:core-add-flag
#:core-flag
#:core-flag-value
#:core-memory
#:core-memory-location
;; construction
#:make-core
#:load-instruction
#:load-program
;; execution
#:run-instruction
#:run-program
#:core-end-program
;; conditions
#:illegal-memory-access
#:illegal-register-access
))
| 1,621 | Common Lisp | .lisp | 60 | 23.95 | 75 | 0.709138 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | f689c84b3940e3694b0201b7852363261714dbc4352e582fb33bb2e331bc8b41 | 26,556 | [
-1
] |
26,557 | conditions.lisp | simoninireland_cl-vhdsl/src/emu/conditions.lisp | ;; Conditions for fully-software-emulated architectures
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/emu)
(define-condition illegal-memory-access (error)
((address
:documentation "Memory address accessed."
:initarg :address))
(:report (lambda (c str)
(format str "Illegal memory access: ~xH" (slot-value c 'address))))
(:documentation "Signalled when an illegal memory address is accessed.
This can happen if the address is outside the valif range of
the memory, or if the location is unreadable or unwriteable
for some other reason."))
(define-condition illegal-register-access (error)
((register
:documentation "The register causing the condition.")
(value
:documentation "The value beign written."))
(:report (lambda (c str)
(format str "Illegal access to register ~s (writing ~a)"
(slot-value c 'register)
(slot-value c 'value))))
(:documentation "Condition signalled when a register is accessed illegally.
This typically means that the register is receiving a value
that's too wide to it."))
| 1,794 | Common Lisp | .lisp | 41 | 41.219512 | 77 | 0.747567 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 29aba4e09e02f04a71b5a1eb1636b558cfedee4b41606327c5cd18cec855f7c2 | 26,557 | [
-1
] |
26,558 | emu.lisp | simoninireland_cl-vhdsl/src/emu/emu.lisp | ;; Constructing emulations
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/emu)
;; ---------- Core emulation ----------
(defun make-core (core)
"Build an emulation of CORE.
CORE is a description of a core, for which we construct a
software emulation."
(let ((c (make-instance 'core)))
;; add registers
(maphash #'(lambda (rname reg)
(let ((r (make-instance 'register
:name rname
:width (def:register-width reg))))
;; add the register
(core-add-register c r)
;; if it is a program counter, capture it
(if (typep reg 'def:program-counter)
(if (null (slot-value c 'pc))
(setf (slot-value c 'pc) r)
(error "Duplicate progam counter defined for core")))))
(def:core-registers core))
;; check we did get a program counter
(if (null (slot-value c 'pc))
(error "No program counter defined for core"))
;; add flags
(maphash #'(lambda (fname f)
(core-add-flag c (make-instance 'flag
:name fname
:register (core-register (def:flag-register f) c)
:bit (def:flag-bit f))))
(def:core-flags core))
;; return the created core
c))
(defun load-instruction (ins mem addr)
"Load INS at address ADDR of MEM, returning the new PC."
(let* ((bs (def:instruction-bytes ins))
(n (length bs)))
(dolist (i (iota n))
(setf (memory-location mem (+ addr i)) (elt bs i)))
(setf (memory-instruction mem addr)
(lambda (c)
(incf (core-pc-value c) n)
(def:instruction-behaviour ins c)))
(+ addr n)))
(defun load-program (p mem &key (initial #16r300))
"Load P into memory MEM."
(let ((pc initial))
(dolist (ins p)
(setq pc (load-instruction ins mem pc)))))
(defun run-instruction (c mem addr)
"Run the instruction stored at ADDR of MEM on core C."
(let ((ins (memory-instruction mem addr)))
(funcall ins c)))
(defun run-program (c mem &key (initial #16r300))
"Run the program loaded into MEM on core C, starting from the INITIAL address."
(setf (core-memory c) mem)
(setf (core-pc-value c) initial)
(catch *END-PROGRAM*
(loop (run-instruction c mem (core-pc-value c)))))
| 2,882 | Common Lisp | .lisp | 76 | 34.078947 | 81 | 0.673477 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 17fa40b08749de3488fe14b0dbcd0d8f359417609d4dd4aae16d4c22c09c80f0 | 26,558 | [
-1
] |
26,559 | cached-memory.lisp | simoninireland_cl-vhdsl/src/emu/cached-memory.lisp | ;; Memory with cached pre-decoded instructions
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/emu)
(defclass cached-memory (memory)
()
(:documentation "A memory with pre-decoded instruction cache.
Each location contains a byte of \"real\" content and an optional
function that holds the behaviour of the location based at that location.
This saves decoding at run-time."))
;; We re-define the access functions to access the car of the pair
;; at each location, and add `memory-instruction' as an accessor
;; for the cdr.
;;
;; As an alternative to making the instructions setf-able like this
;; we could specialise `memory-location' to set depending on the
;; type of its value argument (byte or function), and add a
;; different method for accessing the cached instruction.
(defmethod memory-initialise ((mem cached-memory))
(setf (memory-locations mem)
(make-array (list (memory-size mem))))
(let ((locs (memory-locations mem)))
(dolist (addr (iota (memory-size mem)))
(let ((cell (cons 0 nil)))
(setf (aref locs addr) cell)))))
(defmethod memory-location ((mem cached-memory) addr)
(car (aref (memory-locations mem) addr)))
(defmethod (setf memory-location) (v (mem cached-memory) addr)
(setf (car (aref (memory-locations mem) addr)) v))
(defgeneric memory-instruction (mem addr)
(:documentation "Return the instruction cached at location ADDR in MEM."))
(defmethod memory-instruction ((mem cached-memory) addr)
(cdr (aref (memory-locations mem) addr)))
(defmethod (setf memory-instruction) (v (mem cached-memory) addr)
(setf (cdr (aref (memory-locations mem) addr)) v))
| 2,353 | Common Lisp | .lisp | 50 | 45.12 | 76 | 0.748469 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 380f93e4091a396e9c215bbdd3268570bc288ef4af581605833707f95fd2a2c2 | 26,559 | [
-1
] |
26,560 | register.lisp | simoninireland_cl-vhdsl/src/emu/register.lisp | ;; Fully-software-emulated registers
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/emu)
(defclass register ()
((value
:documentation "Register current value."
:initform 0
:accessor register-value)
(print-name
:documentation "Register print name."
:initarg :name
:reader register-name)
(width
:documentation "Width of the register in bytes."
:initform 8
:initarg :width
:reader register-width))
(:documentation "A register held as a variable."))
(defmethod (setf register-value) (v (r register))
;; check that the proposed value fits into the register
(if (>= v (floor (expt 2 (register-width r))))
(error (make-instance 'register-overflow :register r :value v))
(setf (slot-value r 'value) v)))
(defclass flag ()
((register
:documentation "The register containing the flag."
:initarg :register
:reader flag-register)
(print-name
:documentation "Flag print name."
:initarg :name
:reader register-name)
(bit
:documentation "The bit within the register."
:initarg :bit
:accessor flag-bit))
(:documentation "A single-bit flag within a register."))
(defmethod flag-bit ((f flag))
(logand 1 (ash (register-value (flag-register f)) (- (flag-bit f)))))
(defmethod (setf flag-bit) (b (f flag))
(setf (ldb (flag-bit f) (register-value (flag-register f))) b))
| 2,108 | Common Lisp | .lisp | 57 | 33.77193 | 75 | 0.711906 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 9a1c9f143207b289f7445fd37c454303e2abb09e0259eb892ba0f65e3f6affb3 | 26,560 | [
-1
] |
26,561 | arch.lisp | simoninireland_cl-vhdsl/src/emu/arch.lisp | ;; Fully-software-emulated architectural components
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/emu)
;;---------- Memory ----------
(defclass memory ()
((size
:documentation "Size of memory."
:initarg :size
:reader memory-size)
(locations
:documentation "The locations in the memory."
:accessor memory-locations))
(:documentation "A memory represented by an in-memory array.
Memory locations can hold values of any type -- typically bytes, of
course, and this is the default. But older processors often have
word-addressable memory, and there are applications requiring more
sophisticated structures."))
(defgeneric memory-initialise(mem)
(:documentation "Initialise the initial value of all locations in MEM.
This will typically involve calling `make-array' to create the storage
and then initialising each value. The default creates a byte array
initialised with zeros."))
(defmethod memory-initialise ((mem memory))
(setf (memory-locations mem)
(make-array (list (memory-size mem))
:element-type 'unsigned-byte
:initial-element 0)))
(defgeneric memory-location (mem addr)
(:documentation "Return address ADDR in MEM."))
(defmethod memory-location ((mem memory) addr)
(aref (slot-value mem 'locations) addr))
(defmethod (setf memory-location) (v (mem memory) addr)
(setf (aref (slot-value mem 'locations) addr) v))
;; ---------- Registers ----------
(defclass register ()
((print-name
:documentation "The register's print name."
:initarg :name
:reader register-name)
(value
:documentation "The register's value."
:initform 0
:initarg :initial-value
:accessor register-value)
(width
:documentation "The register's width in bits."
:initform 8
:initarg :width
:reader register-width))
(:documentation "An emulated register.
Registers provide sanity checks on the sizes of values written."))
(defmethod (setf register-value) (v (reg register))
(if (>= (abs v) (floor (expt 2 (register-width reg))))
(error 'illegal-register-access :register reg :value v)
(setf (slot-value reg 'value) v)))
;; ---------- Flags ----------
(defclass flag ()
((print-name
:documentation "The register's print name."
:initarg :name
:reader flag-name)
(register
:documentation "The register containing the flag."
:initarg :register
:reader flag-register)
(bit
:documentation "The bit within the register."
:initarg :bit
:reader flag-bit))
(:documentation "A one-bit flag within an emulated register."))
(defgeneric flag-value (f)
(:documentation "The value of the flag F."))
(defmethod flag-value ((f flag))
(logand 1 (ash (register-value (flag-register f)) (- (flag-bit f)))))
(defmethod (setf flag-value) (b (f flag))
(let ((v (register-value (flag-register f)))
(mask (ash 1 (flag-bit f))))
(setf (register-value (flag-register f))
(if b
(logior v mask)
(logand v (lognot mask))))))
;; ---------- Cores ----------
(defparameter *END-PROGRAM* (gensym)
"Catch tag for ending program execution on a core.")
(defclass core ()
((register-table
:documentation "Hash table mapping register names to emulated registers."
:initform (make-hash-table)
:reader core-registers)
(pc
:documentation "The designated program counter register."
:initform nil
:reader core-pc)
(mem
:documentation "The memory the core is attached to."
:initarg :memory
:accessor core-memory)
(flag-table
:documentation "Hash table mapping flag names to emulated registers."
:initform (make-hash-table)
:reader core-flags))
(:documentation "An emulated core."))
(defgeneric core-add-register (c r)
(:documentation "Add register R to core."))
(defmethod core-add-register ((c core) r)
(setf (gethash (register-name r) (core-registers c)) r))
(defgeneric core-add-flag (c f)
(:documentation "Add lag F to core ."))
(defmethod core-add-flag ((c core) f)
(setf (gethash (flag-name f) (core-flags c)) f))
(defgeneric core-register (rname c)
(:documentation "Return the register RNAME on core C"))
(defmethod core-register (rname (c core))
(gethash rname (core-registers c)))
(defgeneric core-pc-value (c)
(:documentation "Return the value of the program counter on core C"))
(defmethod core-pc-value ((c core))
(register-value (core-pc c)))
(defmethod (setf core-pc-value) (addr (c core))
(setf (register-value (core-pc c)) addr))
(defgeneric core-register-value (rname c)
(:documentation "Return the value of register RNAME on core C"))
(defmethod core-register-value (rname (c core))
(register-value (core-register rname c)))
(defmethod (setf core-register-value) (v rname (c core))
(setf (register-value (core-register rname c)) v))
(defgeneric core-flag (fname c)
(:documentation "Return the flag FNAME on core C"))
(defmethod core-flag (fname (c core))
(gethash fname (core-flags c)))
(defgeneric core-flag-value (fname c)
(:documentation "Return the value of flag FNAME on core C"))
(defmethod core-flag-value (fname (c core))
(flag-value (core-flag fname c)))
(defmethod (setf core-flag-value) (v fname (c core))
(setf (flag-value (core-flag fname c)) v))
(defgeneric core-memory-location (addr c)
(:documentation "Return the value stord at memory address ADDR on core C"))
(defmethod core-memory-location (addr (c core))
(memory-location (core-memory c) addr))
(defmethod (setf core-memory-location) (v addr (c core))
(setf (memory-location (core-memory c) addr) v))
(defgeneric core-end-program (c)
(:documentation "End execution of a program on C"))
(defmethod core-end-program ((c core))
(throw *END-PROGRAM* t))
| 6,475 | Common Lisp | .lisp | 162 | 36.635802 | 77 | 0.712544 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | ee9f8af5247ba08683a7fa2e868276cdfc67dadf481ca8fd7f23428424facebe | 26,561 | [
-1
] |
26,562 | package.lisp | simoninireland_cl-vhdsl/src/def/package.lisp | ;; Package definition for the component definition package
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :common-lisp-user)
(defpackage cl-vhdsl/def
(:use :cl :cl-bitfields :cl-vhdsl :cl-ppcre)
(:export
;; data types and type construtors
#:unsigned-bitfield
#:signed-bitfield
#:unsigned-8
#:signed-8
#:unsigned-16
#:signed-16
#:list-of-addressing-modes
;; Constants
#:KB
#:MB
;; registers
#:register
#:register-name
#:register-width
#:data-register
#:address-register
#:index-register
#:special-register
#:program-counter
#:flag
#:flag-name
#:flag-register
#:flag-bit
;; addressing modes
#:addressing-mode
#:addressing-mode-parse
#:addressing-mode-regexp
#:addressing-mode-bytes
#:addressing-mode-behaviour
#:implicit
;; instructions
#:abstract-instruction
#:instruction
#:instruction-mnemonic
#:instruction-addressing-mode
#:instruction-addressing-modes
#:instruction-opcode
#:instruction-check
#:instruction-addressing-mode-bytes
#:instruction-bytes
#:instruction-assemble
#:instruction-add-class-for-mnemonic
#:instruction-class-for-mnemonic
#:instruction-behaviour
#:instruction-argument
;; assembler
#:assembler-get-mnemonic
#:assembler-make-mnemonic-regexp
#:assembler-get-addressing-mode
#:assembler-make-addressing-modes-regexp
;; architecture description
#:architecture
#:component
#:architecture-components
;; cores
#:core
#:core-registers
#:core-flags
#:core-instruction-set
;; memory
#:memory
#:memory-size
;; buses
#:bus
#:bus-connections
;; conditions
#:bad-addressing-mode
#:unknown-mnemonic
))
| 2,459 | Common Lisp | .lisp | 92 | 23.271739 | 75 | 0.72017 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | a7a5f7efa14fbe6bb57f1e5135bc8383445f41cd1eb7da164ce5656c3b75090a | 26,562 | [
-1
] |
26,563 | types.lisp | simoninireland_cl-vhdsl/src/def/types.lisp | ;; Data types
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/def)
;; ---------- Type constructors ----------
(defun unsigned-bitfield (width)
"The type specifier of unsigned bitfields of WIDTH bits."
(let ((maxval (1- (floor (expt 2 width)))))
`(integer 0 ,maxval)))
(defun signed-bitfield (width)
"The type specifier of signed bitfields of WIDTH bits."
(let* ((half (floor (expt 2 (1- width))))
(minval (- half))
(maxval (1- half)))
`(integer ,minval ,maxval)))
;; ---------- Common types ----------
(deftype unsigned-8 () (unsigned-bitfield 8))
(deftype signed-8 () (signed-bitfield 8))
(deftype unsigned-16 () (unsigned-bitfield 16))
(deftype signed-16 () (signed-bitfield 16))
| 1,441 | Common Lisp | .lisp | 35 | 39.371429 | 75 | 0.704578 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | f6978130077ede56f3a532a8663c49b7f3b370eef09d5e44e8b30bdeb6d62f12 | 26,563 | [
-1
] |
26,564 | conditions.lisp | simoninireland_cl-vhdsl/src/def/conditions.lisp | ;; Conditions
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/def)
;; ---------- Instruction and addressing mode conditions ----------
(define-condition bad-addressing-mode (error)
((ins
:documentation "The instruction."
:type abstract-instruction
:initarg :instruction)
(mode
:documentation "The addressing mode."
:type addressing-mode
:initarg :addressing-mode))
(:report (lambda (c str)
(format str "Instruction ~s does not accept mode ~s"
(slot-value c 'ins)
(slot-value c 'mode))))
(:documentation "Error signalled when an instruction is passed an addressing mode it can't use."))
(define-condition unknown-mnemonic (error)
((mnemonic
:documentation "The mnemonic."
:initarg :mnemonic))
(:report (lambda (c str)
(format str "Unkown instruction mnemonic ~s"
(slot-value c 'moemonic))))
(:documentation "Error signalled when an unrecognised instruction mnemonic is encountered."))
| 1,701 | Common Lisp | .lisp | 42 | 37.452381 | 100 | 0.722928 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 256d2b87df2ccf97924e39c6159c3d968ba1136e873707e2cf98c35439d99830 | 26,564 | [
-1
] |
26,565 | register.lisp | simoninireland_cl-vhdsl/src/def/register.lisp | ;; Register definitions
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/def)
;; ---------- Registers ----------
(defclass register ()
((print-name
:documentation "The print name of the register."
:type string
:initarg :name
:reader register-name)
(bit-width
:documentation "The width of the register in bits."
:type integer
:initarg :width
:reader register-width)
(description
:documentation "Description of the register."
:type string
:initarg :documentation))
(:documentation "A register with a fixed bit-width."))
(defclass data-register (register)
()
(:documentation "A register holding general-purpose data."))
(defclass index-register (register)
()
(:documentation "A register holding offsets for addressing."))
(defclass address-register (register)
()
(:documentation "A register holding addresses."))
(defclass special-register (register)
()
(:documentation "A register used internally by the processor and offering bitwise access."))
(defclass program-counter (special-register)
()
(:documentation "A program counter regiser used to track the current instruction."))
;; ---------- Flags within registers ----------
(defclass flag ()
((print-name
:documentation "The print name of the flag."
:type string
:initarg :name
:reader flag-name)
(register
:documentation "The register holding the flag."
:type special-register
:initarg :register
:reader flag-register)
(bit
:documentation "The bit within the register."
:type integer
:initarg :bit
:reader flag-bit)
(description
:documentation "Description of the flag."
:type string
:initarg :documentation))
(:documentation "A one-bit flag within a register."))
| 2,509 | Common Lisp | .lisp | 73 | 31.136986 | 94 | 0.719835 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 4aaeb5953eb7d5a494327cbe8ef89008981b8f92f8cae47d0cddcaa2839f354f | 26,565 | [
-1
] |
26,566 | arch.lisp | simoninireland_cl-vhdsl/src/def/arch.lisp | ;; Architectural description and components
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/def)
;; ---------- Architecture ----------
(defclass architecture ()
((components-plist
:documentation "The components of the architecture."
:initform '()
:accessor architecture-components))
(:documentation "The description of a machine."))
;; ---------- Components ----------
(defclass component ()
()
(:documentation "A component within an architecture.
A component represents a piece of hardware, that is to be enumalted
or synthesised in the final system."))
;; ---------- Cores ----------
(defclass core (component)
((registers
:documentation "The registers defined in the core."
:initform (make-hash-table)
:accessor core-registers)
(flags
:documentation "The status flags defined in the core."
:initform (make-hash-table)
:accessor core-flags)
(instruction-set
:documentation "The instruction set of the core."
:initform '()
:accessor core-instruction-set))
(:documentation "A processor core."))
;; ---------- Memory ----------
(defclass memory (component)
((size
:documentation "Number of locations in the memory."
:initarg :size
:initform (* 64 KB) ;; 64Klocs by default
:reader memory-size))
(:documentation "A linear location-addressable RAM."))
;; ---------- Buses ----------
(defclass bus (component)
((connections-plist
:documentation "Components on this bus."
:initform '()
:initarg :connections
:reader bus-connections))
(:documentation "A bus connecting several other components."))
| 2,377 | Common Lisp | .lisp | 63 | 34.793651 | 77 | 0.692776 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | c873a87993d8eb65fc4a9e5819aa6edda5514dc0d215b8d11d9dfa9c3df75a80 | 26,566 | [
-1
] |
26,567 | constants.lisp | simoninireland_cl-vhdsl/src/def/constants.lisp | ;; Constants
;;
;; Copyright (C) 2024 Simon Dobson
;;
;; This file is part of cl-vhdsl, a Common Lisp DSL for hardware design
;;
;; cl-vhdsl is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; cl-vhdsl is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with cl-vhdsl. If not, see <http://www.gnu.org/licenses/gpl.html>.
(in-package :cl-vhdsl/def)
;; ---------- Memory sizes ----------
(defvar KB (floor (expt 2 10))
"A kilobyte in bytes.")
(defvar MB (* 1024 KB)
"A megabyte in bytes.")
| 944 | Common Lisp | .lisp | 24 | 38.041667 | 75 | 0.725191 | simoninireland/cl-vhdsl | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 8898746278faa978c02c8927d21cb26b2a629b3e25d34599405a6ed046432c21 | 26,567 | [
-1
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.