Mercurial > hg > audiodb
changeset 646:368c8c72e723
Implement sb-adb:liszt in sb-alien bindings
Don't forget to export the symbol from the package!
Fixes audioDB Trac ticket #33
author | mas01cr |
---|---|
date | Tue, 13 Oct 2009 14:26:28 +0000 |
parents | 397e94f6db44 |
children | 7e7ba87b5466 |
files | bindings/sb-alien/interface.lisp bindings/sb-alien/library.lisp bindings/sb-alien/package.lisp |
diffstat | 3 files changed, 30 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/bindings/sb-alien/interface.lisp Tue Oct 13 14:26:27 2009 +0000 +++ b/bindings/sb-alien/interface.lisp Tue Oct 13 14:26:28 2009 +0000 @@ -325,6 +325,16 @@ (setf (slot qdatum 'power) (sb-sys:vector-sap (sb-ext:array-storage-vector (datum-times datum)))) (setf (slot qdatum 'power) nil)))) +(defgeneric liszt (adb)) +(defmethod liszt ((db adb)) + (let ((results (%liszt (slot-value db 'alien)))) + (unwind-protect + (loop for i below (slot results 'nresults) + with entries = (slot results 'entries) + for entry = (deref entries i) + collect (cons (slot entry 'key) (slot entry 'nvectors))) + (%free-liszt-results (slot-value db 'alien) results)))) + #+test (sb-adb:with-adb (db "/home/csr21/tmp/omras2-workshop/9.adb") (sb-adb:query "KSA_CHARM_337" db :exhaustivep t :sequence-length 30
--- a/bindings/sb-alien/library.lisp Tue Oct 13 14:26:27 2009 +0000 +++ b/bindings/sb-alien/library.lisp Tue Oct 13 14:26:28 2009 +0000 @@ -137,5 +137,24 @@ (define-int-checking-function %free-query-results (adb spec results) %%free-query-results) +(define-alien-type adb-track-entry-t + (struct adbtrackentry + (nvectors (unsigned 32)) + (key c-string))) + +(define-alien-type adb-liszt-results-t + (struct adblisztresults + (nresults (unsigned 32)) + (entries (* adb-track-entry-t)))) + +(define-alien-routine ("audiodb_liszt" %%liszt) (* adb-liszt-results-t) + (adb (* adb-t))) +(define-pointer-checking-function %liszt (adb) %%liszt) +(define-alien-routine ("audiodb_liszt_free_results" %%free-liszt-results) int + (adb (* adb-t)) + (results (* adb-liszt-results-t))) +(define-int-checking-function %free-liszt-results (adb results) + %%free-liszt-results) + (define-alien-routine ("audiodb_close" %close) void (adb (* adb-t)))
--- a/bindings/sb-alien/package.lisp Tue Oct 13 14:26:27 2009 +0000 +++ b/bindings/sb-alien/package.lisp Tue Oct 13 14:26:28 2009 +0000 @@ -7,5 +7,5 @@ "RESULT" "RESULT-KEY" "RESULT-DISTANCE" "RESULT-QPOS" "RESULT-IPOS" "RESULTS" ;; functions - "OPEN" "CLOSE" "INSERT" "RETRIEVE" "QUERY" ) + "OPEN" "CLOSE" "INSERT" "RETRIEVE" "QUERY" "LISZT") (:shadow "OPEN" "CLOSE"))