Commits

Walton Hoops  committed 9debea0

use integers for the appropriate tags

  • Participants
  • Parent commits ea7c616

Comments (0)

Files changed (1)

File cl-taglib.lisp

 (defcfun (file-save "taglib_file_save") :boolean
   (file :pointer))
 
-(defmacro taglib-accessor-for (slot)
+(defmacro taglib-accessor-for (slot type)
   (let ((function-name (intern (concatenate 'string "TAG-" (string slot))))
 	(foreign-name (string-downcase (concatenate 'string "taglib_tag_" (string slot))))
 	(foreign-set-name (string-downcase (concatenate 'string "taglib_tag_set_" (string slot)))))
-    `(progn
-       (defun ,function-name (tag)
-	 (let ((str-ptr (foreign-funcall ,foreign-name :pointer tag :string+ptr)))
-	   (foreign-funcall "taglib_free" :pointer (cadr str-ptr) :void)
-	   (car str-ptr)))
-       (defun (setf ,function-name) (value tag)
-	 (foreign-funcall ,foreign-set-name :pointer tag :string value :void)))))
-
-(taglib-accessor-for :title)
-(taglib-accessor-for :artist)
-(taglib-accessor-for :album)
-(taglib-accessor-for :comment)
-(taglib-accessor-for :genre)
-(taglib-accessor-for :year)
-(taglib-accessor-for :track)
+    (list 'progn
+	  (if (eq type :string)
+	      `(defun ,function-name (tag)
+		(let ((str-ptr (foreign-funcall ,foreign-name :pointer tag :string+ptr)))
+		  (foreign-funcall "taglib_free" :pointer (cadr str-ptr) :void)
+		  (car str-ptr)))
+	      `(defun ,function-name (tag)
+		(foreign-funcall ,foreign-name :pointer tag ,type)))
+	  `(defun (setf ,function-name) (value tag)
+	    (foreign-funcall ,foreign-set-name :pointer tag ,type value :void)))))
+
+(taglib-accessor-for :title :string)
+(taglib-accessor-for :artist :string)
+(taglib-accessor-for :album :string)
+(taglib-accessor-for :comment :string)
+(taglib-accessor-for :genre :string)
+(taglib-accessor-for :year :uint)
+(taglib-accessor-for :track :uint)