Explorar o código

redefined defconstant to shut SBCL up

Mark VandenBrink %!s(int64=12) %!d(string=hai) anos
pai
achega
0022d4dd85
Modificáronse 5 ficheiros con 99 adicións e 94 borrados
  1. 7 7
      flac-frame.lisp
  2. 61 61
      mp4-atom.lisp
  3. 25 25
      mpeg.lisp
  4. 1 1
      packages.lisp
  5. 5 0
      utils.lisp

+ 7 - 7
flac-frame.lisp

@@ -3,13 +3,13 @@
 (in-package #:flac-frame)
 
 ;;; FLAC header types
-(defconstant +metadata-streaminfo+  0)
-(defconstant +metadata-padding+     1)
-(defconstant +metadata-application+ 2)
-(defconstant +metadata-seektable+   3)
-(defconstant +metadata-comment+     4)
-(defconstant +metadata-cuesheet+    5)
-(defconstant +metadata-picture+     6)
+(defconstant* +metadata-streaminfo+  0)
+(defconstant* +metadata-padding+     1)
+(defconstant* +metadata-application+ 2)
+(defconstant* +metadata-seektable+   3)
+(defconstant* +metadata-comment+     4)
+(defconstant* +metadata-cuesheet+    5)
+(defconstant* +metadata-picture+     6)
 
 (defclass flac-header ()
   ((pos         :accessor pos         :initarg :pos

+ 61 - 61
mp4-atom.lisp

@@ -43,48 +43,48 @@
        (write-char (code-char ,(as-octet l3)) s)
        (write-char (code-char ,(as-octet l4)) s))))
 
-(defconstant +root+                  (mk-mp4-atom-type #\R #\O #\O #\T)  "fake root for tree")
-(defconstant +itunes-album+          (mk-mp4-atom-type #xa9 #\a #\l #\b) "text: album name")
-(defconstant +itunes-album-artist+   (mk-mp4-atom-type #\a  #\A #\R #\T) "text: album artist")
-(defconstant +itunes-artist+         (mk-mp4-atom-type #xa9 #\A #\R #\T) "text: artist name")
-(defconstant +itunes-comment+        (mk-mp4-atom-type #xa9 #\c #\m #\t) "text: comment, commonly used by iTunes for sound info, etc")
-(defconstant +itunes-compilation+    (mk-mp4-atom-type #\c  #\p #\i #\l) "byte/boolean: is this file part of a compilation?")
-(defconstant +itunes-composer+       (mk-mp4-atom-type #xa9 #\c #\o #\m) "text: composer name")
-(defconstant +itunes-copyright+      (mk-mp4-atom-type #\c  #\p #\r #\t) "text: copyright info")
-(defconstant +itunes-cover-art+      (mk-mp4-atom-type #\c  #\o #\v #\r) "octets: cover art, PNG, etc")
-(defconstant +itunes-disk+           (mk-mp4-atom-type #\d  #\i #\s #\k) "octets: disk number, can be n of N")
-(defconstant +itunes-encoder+        (mk-mp4-atom-type #xa9 #\e #\n #\c) "text: who encoded")
-(defconstant +itunes-genre+          (mk-mp4-atom-type #\g  #\n #\r #\e) "octets: genre of file")
-(defconstant +itunes-genre-x+        (mk-mp4-atom-type #xa9 #\g #\e #\n) "text: yet another genre atom")
-(defconstant +itunes-groups+         (mk-mp4-atom-type #xa9 #\g #\r #\p) "text: ???")
-(defconstant +itunes-lyrics+         (mk-mp4-atom-type #xa9 #\l #\y #\r) "text: lyrics tag")
-(defconstant +itunes-purchased-date+ (mk-mp4-atom-type #\p  #\u #\r #\d) "text: when song was purchased")
-(defconstant +itunes-tempo+          (mk-mp4-atom-type #\t  #\m #\p #\o) "octet: tempo of song")
-(defconstant +itunes-title+          (mk-mp4-atom-type #xa9 #\n #\a #\m) "text: title of song")
-(defconstant +itunes-tool+           (mk-mp4-atom-type #xa9 #\t #\o #\o) "text: what tool encoded this file")
-(defconstant +itunes-track+          (mk-mp4-atom-type #xa9 #\t #\r #\k) "octet: track number")
-(defconstant +itunes-track-n+        (mk-mp4-atom-type #\t  #\r #\k #\n) "octet: yet another track number")
-(defconstant +itunes-writer+         (mk-mp4-atom-type #xa9 #\w #\r #\t) "text: who wrote the song")
-(defconstant +itunes-year+           (mk-mp4-atom-type #xa9 #\d #\a #\y) "text: year album was released")
-(defconstant +itunes-ilst-data+      (mk-mp4-atom-type #\d #\a #\t #\a)  "carries the actual data under an ilst atom")
-
-(defconstant +m4-ftyp+               (mk-mp4-atom-type #\f #\t #\y #\p) "This should be the first atom type found in file")
-
-(defconstant +mp4-atom-hdlr+         (mk-mp4-atom-type #\h #\d #\l #\r) "Found under trak.mdia and tells what kind of handler it is")
-
-(defconstant +audioprop-mdhd+        (mk-mp4-atom-type #\m #\d #\h #\d) "Found under trak.mdia and holds data to calculate length of audio")
-(defconstant +audioprop-stsd+        (mk-mp4-atom-type #\s #\t #\s #\d) "Container atom: found under trak.mdia.minf.stbl and holds bit-rate, etc")
-(defconstant +audioprop-mp4a+        (mk-mp4-atom-type #\m #\p #\4 #\a) "Found under trak.mdia.minf.stbl")
-(defconstant +audioprop-esds+        (mk-mp4-atom-type #\e #\s #\d #\s) "Found under trak.mdia.minf.stbl.mp4a")
-
-(defconstant +mp4-atom-ilst+         (mk-mp4-atom-type #\i #\l #\s #\t))
-(defconstant +mp4-atom-mdia+         (mk-mp4-atom-type #\m #\d #\i #\a))
-(defconstant +mp4-atom-meta+         (mk-mp4-atom-type #\m #\e #\t #\a))
-(defconstant +mp4-atom-minf+         (mk-mp4-atom-type #\m #\i #\n #\f))
-(defconstant +mp4-atom-moov+         (mk-mp4-atom-type #\m #\o #\o #\v))
-(defconstant +mp4-atom-stbl+         (mk-mp4-atom-type #\s #\t #\b #\l))
-(defconstant +mp4-atom-trak+         (mk-mp4-atom-type #\t #\r #\a #\k))
-(defconstant +mp4-atom-udta+         (mk-mp4-atom-type #\u #\d #\t #\a))
+(defconstant* +root+                  (mk-mp4-atom-type #\R #\O #\O #\T)  "fake root for tree")
+(defconstant* +itunes-album+          (mk-mp4-atom-type #xa9 #\a #\l #\b) "text: album name")
+(defconstant* +itunes-album-artist+   (mk-mp4-atom-type #\a  #\A #\R #\T) "text: album artist")
+(defconstant* +itunes-artist+         (mk-mp4-atom-type #xa9 #\A #\R #\T) "text: artist name")
+(defconstant* +itunes-comment+        (mk-mp4-atom-type #xa9 #\c #\m #\t) "text: comment, commonly used by iTunes for sound info, etc")
+(defconstant* +itunes-compilation+    (mk-mp4-atom-type #\c  #\p #\i #\l) "byte/boolean: is this file part of a compilation?")
+(defconstant* +itunes-composer+       (mk-mp4-atom-type #xa9 #\c #\o #\m) "text: composer name")
+(defconstant* +itunes-copyright+      (mk-mp4-atom-type #\c  #\p #\r #\t) "text: copyright info")
+(defconstant* +itunes-cover-art+      (mk-mp4-atom-type #\c  #\o #\v #\r) "octets: cover art, PNG, etc")
+(defconstant* +itunes-disk+           (mk-mp4-atom-type #\d  #\i #\s #\k) "octets: disk number, can be n of N")
+(defconstant* +itunes-encoder+        (mk-mp4-atom-type #xa9 #\e #\n #\c) "text: who encoded")
+(defconstant* +itunes-genre+          (mk-mp4-atom-type #\g  #\n #\r #\e) "octets: genre of file")
+(defconstant* +itunes-genre-x+        (mk-mp4-atom-type #xa9 #\g #\e #\n) "text: yet another genre atom")
+(defconstant* +itunes-groups+         (mk-mp4-atom-type #xa9 #\g #\r #\p) "text: ???")
+(defconstant* +itunes-lyrics+         (mk-mp4-atom-type #xa9 #\l #\y #\r) "text: lyrics tag")
+(defconstant* +itunes-purchased-date+ (mk-mp4-atom-type #\p  #\u #\r #\d) "text: when song was purchased")
+(defconstant* +itunes-tempo+          (mk-mp4-atom-type #\t  #\m #\p #\o) "octet: tempo of song")
+(defconstant* +itunes-title+          (mk-mp4-atom-type #xa9 #\n #\a #\m) "text: title of song")
+(defconstant* +itunes-tool+           (mk-mp4-atom-type #xa9 #\t #\o #\o) "text: what tool encoded this file")
+(defconstant* +itunes-track+          (mk-mp4-atom-type #xa9 #\t #\r #\k) "octet: track number")
+(defconstant* +itunes-track-n+        (mk-mp4-atom-type #\t  #\r #\k #\n) "octet: yet another track number")
+(defconstant* +itunes-writer+         (mk-mp4-atom-type #xa9 #\w #\r #\t) "text: who wrote the song")
+(defconstant* +itunes-year+           (mk-mp4-atom-type #xa9 #\d #\a #\y) "text: year album was released")
+(defconstant* +itunes-ilst-data+      (mk-mp4-atom-type #\d #\a #\t #\a)  "carries the actual data under an ilst atom")
+
+(defconstant* +m4-ftyp+               (mk-mp4-atom-type #\f #\t #\y #\p) "This should be the first atom type found in file")
+
+(defconstant* +mp4-atom-hdlr+         (mk-mp4-atom-type #\h #\d #\l #\r) "Found under trak.mdia and tells what kind of handler it is")
+
+(defconstant* +audioprop-mdhd+        (mk-mp4-atom-type #\m #\d #\h #\d) "Found under trak.mdia and holds data to calculate length of audio")
+(defconstant* +audioprop-stsd+        (mk-mp4-atom-type #\s #\t #\s #\d) "Container atom: found under trak.mdia.minf.stbl and holds bit-rate, etc")
+(defconstant* +audioprop-mp4a+        (mk-mp4-atom-type #\m #\p #\4 #\a) "Found under trak.mdia.minf.stbl")
+(defconstant* +audioprop-esds+        (mk-mp4-atom-type #\e #\s #\d #\s) "Found under trak.mdia.minf.stbl.mp4a")
+
+(defconstant* +mp4-atom-ilst+         (mk-mp4-atom-type #\i #\l #\s #\t))
+(defconstant* +mp4-atom-mdia+         (mk-mp4-atom-type #\m #\d #\i #\a))
+(defconstant* +mp4-atom-meta+         (mk-mp4-atom-type #\m #\e #\t #\a))
+(defconstant* +mp4-atom-minf+         (mk-mp4-atom-type #\m #\i #\n #\f))
+(defconstant* +mp4-atom-moov+         (mk-mp4-atom-type #\m #\o #\o #\v))
+(defconstant* +mp4-atom-stbl+         (mk-mp4-atom-type #\s #\t #\b #\l))
+(defconstant* +mp4-atom-trak+         (mk-mp4-atom-type #\t #\r #\a #\k))
+(defconstant* +mp4-atom-udta+         (mk-mp4-atom-type #\u #\d #\t #\a))
 
 (defvar *in-progress* nil "the node currently being worked upon")
 (defvar *tree*        nil "the root of the atom tree")
@@ -306,25 +306,25 @@ to read the payload of an atom."
     len))
 
 ;;; one-byte descriptor tags
-(defconstant +mp4-odescrtag+               #x01)
-(defconstant +mp4-iodescrtag+              #x02)
-(defconstant +mp4-esdescrtag+              #x03)
-(defconstant +mp4-decconfigdescrtag+       #x04)
-(defconstant +mp4-decspecificdescrtag+     #x05)
-(defconstant +mp4-slconfigdescrtag+        #x06)
-(defconstant +mp4-contentiddescrtag+       #x07)
-(defconstant +mp4-supplcontentiddescrtag+  #x08)
-(defconstant +mp4-ipiptrdescrtag+          #x09)
-(defconstant +mp4-ipmpptrdescrtag+         #x0a)
-(defconstant +mp4-ipmpdescrtag+            #x0b)
-(defconstant +mp4-registrationdescrtag+    #x0d)
-(defconstant +mp4-esidincdescrtag+         #x0e)
-(defconstant +mp4-esidrefdescrtag+         #x0f)
-(defconstant +mp4-fileiodescrtag+          #x10)
-(defconstant +mp4-fileodescrtag+           #x11)
-(defconstant +mp4-extprofileleveldescrtag+ #x13)
-(defconstant +mp4-extdescrtagsstart+       #x80)
-(defconstant +mp4-extdescrtagsend+         #xfe)
+(defconstant* +mp4-odescrtag+               #x01)
+(defconstant* +mp4-iodescrtag+              #x02)
+(defconstant* +mp4-esdescrtag+              #x03)
+(defconstant* +mp4-decconfigdescrtag+       #x04)
+(defconstant* +mp4-decspecificdescrtag+     #x05)
+(defconstant* +mp4-slconfigdescrtag+        #x06)
+(defconstant* +mp4-contentiddescrtag+       #x07)
+(defconstant* +mp4-supplcontentiddescrtag+  #x08)
+(defconstant* +mp4-ipiptrdescrtag+          #x09)
+(defconstant* +mp4-ipmpptrdescrtag+         #x0a)
+(defconstant* +mp4-ipmpdescrtag+            #x0b)
+(defconstant* +mp4-registrationdescrtag+    #x0d)
+(defconstant* +mp4-esidincdescrtag+         #x0e)
+(defconstant* +mp4-esidrefdescrtag+         #x0f)
+(defconstant* +mp4-fileiodescrtag+          #x10)
+(defconstant* +mp4-fileodescrtag+           #x11)
+(defconstant* +mp4-extprofileleveldescrtag+ #x13)
+(defconstant* +mp4-extdescrtagsstart+       #x80)
+(defconstant* +mp4-extdescrtagsend+         #xfe)
 
 (defmethod initialize-instance :after ((me atom-esds) &key mp4-file &allow-other-keys)
   (declare #.utils:*standard-optimize-settings*)

+ 25 - 25
mpeg.lisp

@@ -4,13 +4,13 @@
 ;;; Parsing MPEG audio frames.  See http://www.datavoyage.com/mpgscript/mpeghdr.htm for format of a frame.
 (in-package #:mpeg)
 
-(defconstant +sync-word+  #x7ff "NB: this is 11 bits so as to be able to recognize V2.5")
+(defconstant* +sync-word+  #x7ff "NB: this is 11 bits so as to be able to recognize V2.5")
 
 ;;; the versions
-(defconstant +mpeg-2.5+   0)
-(defconstant +v-reserved+ 1)
-(defconstant +mpeg-2+     2)
-(defconstant +mpeg-1+     3)
+(defconstant* +mpeg-2.5+   0)
+(defconstant* +v-reserved+ 1)
+(defconstant* +mpeg-2+     2)
+(defconstant* +mpeg-1+     3)
 
 (defun valid-version (version)
   (declare #.utils:*standard-optimize-settings*)
@@ -23,10 +23,10 @@
   (nth version '("MPEG 2.5" "Reserved" "MPEG 2" "MPEG 1")))
 
 ;;; the layers
-(defconstant +layer-reserved+  0)
-(defconstant +layer-3+         1)
-(defconstant +layer-2+         2)
-(defconstant +layer-1+         3)
+(defconstant* +layer-reserved+  0)
+(defconstant* +layer-3+         1)
+(defconstant* +layer-2+         2)
+(defconstant* +layer-1+         3)
 
 (defun valid-layer (layer)
   (declare #.utils:*standard-optimize-settings*)
@@ -39,19 +39,19 @@
   (nth layer '("Reserved" "Layer III" "Layer II" "Layer I")))
 
 ;;; the modes
-(defconstant +channel-mode-stereo+ 0)
-(defconstant +channel-mode-joint+  1)
-(defconstant +channel-mode-dual+   2)
-(defconstant +channel-mode-mono+   3)
+(defconstant* +channel-mode-stereo+ 0)
+(defconstant* +channel-mode-joint+  1)
+(defconstant* +channel-mode-dual+   2)
+(defconstant* +channel-mode-mono+   3)
 (defun get-channel-mode-string (mode)
   (declare #.utils:*standard-optimize-settings*)
   (nth mode '("Stereo" "Joint" "Dual" "Mono")))
 
 ;;; the emphases
-(defconstant +emphasis-none+     0)
-(defconstant +emphasis-50-15+    1)
-(defconstant +emphasis-reserved+ 2)
-(defconstant +emphasis-ccit+     3)
+(defconstant* +emphasis-none+     0)
+(defconstant* +emphasis-50-15+    1)
+(defconstant* +emphasis-reserved+ 2)
+(defconstant* +emphasis-ccit+     3)
 
 (defun get-emphasis-string (e)
   (declare #.utils:*standard-optimize-settings*)
@@ -64,10 +64,10 @@
       (= (the fixnum e) (the fixnum +emphasis-ccit+))))
 
 ;;; the modes
-(defconstant +mode-extension-0+ 0)
-(defconstant +mode-extension-1+ 1)
-(defconstant +mode-extension-2+ 2)
-(defconstant +mode-extension-3+ 3)
+(defconstant* +mode-extension-0+ 0)
+(defconstant* +mode-extension-1+ 1)
+(defconstant* +mode-extension-2+ 2)
+(defconstant* +mode-extension-3+ 3)
 (defun get-mode-extension-string (channel-mode layer mode-extension)
   (declare #.utils:*standard-optimize-settings*)
   (if (not (= channel-mode +channel-mode-joint+))
@@ -296,10 +296,10 @@ Bits   1-0 (2  bits): the emphasis"
   `(with-slots (tag flags frames bytes tocs scale) ,instance
      ,@body))
 
-(defconstant +vbr-frames+  1)
-(defconstant +vbr-bytes+   2)
-(defconstant +vbr-tocs+    4)
-(defconstant +vbr-scale+   8)
+(defconstant* +vbr-frames+  1)
+(defconstant* +vbr-bytes+   2)
+(defconstant* +vbr-tocs+    4)
+(defconstant* +vbr-scale+   8)
 
 (defun get-side-info-size (version channel-mode)
   (declare #.utils:*standard-optimize-settings*)

+ 1 - 1
packages.lisp

@@ -8,7 +8,7 @@
   (:use #:common-lisp))
 
 (defpackage #:utils
-  (:export #:octet #:octets #:make-octets
+  (:export #:octet #:octets #:make-octets #:defconstant*
            #:warn-user *break-on-warn-user* #:printable-array #:upto-null
            #:redirect #:memoize #:it #:*standard-optimize-settings*
            #:get-bitfield #:while #:aif #:awhen #:with-gensyms #:make-keyword

+ 5 - 0
utils.lisp

@@ -2,6 +2,11 @@
 ;;; Copyright (c) 2013, Mark VandenBrink. All rights reserved.
 (in-package #:utils)
 
+(defmacro defconstant* (name value &optional doc)
+  "Make sure VALUE is evaluated only once \(to appease SBCL)."
+  `(cl:defconstant ,name (if (boundp ',name) (symbol-value ',name) ,value)
+     ,@(when doc (list doc))))
+
 (eval-when (:compile-toplevel :load-toplevel :execute)
   #+dbg
   (defvar *standard-optimize-settings* '(optimize (debug 3)))