Commits

llibra committed 7529f57

Changed required arguments for step into keyword arguments.

INCOMPATIBLE CHANGE. For convenience. APIs don't step by default.

  • Participants
  • Parent commits e8b40f0

Comments (0)

Files changed (2)

File src/cur.lisp

                       (values it (mem-aref value-len 'size_t))
                       (error cur msg))))))
   (declare (inline body))
-  (defun get-key (cur step)
+  (defun get-key (cur &key step)
     (body #'kccurgetkey "Can't get the key of the current record."
           cur step))
-  (defun get-value (cur step)
+  (defun get-value (cur &key step)
     (body #'kccurgetvalue "Can't get the value of the current record."
           cur step)))
 
-(defun get (cur step)
+(defun get (cur &key step)
   (let ((step (convert-to-foreign step :boolean)))
     (with-foreign-objects ((key-len 'size_t)
                            (value-buf :pointer)
 (in-package :kc.cur)
 
 (flet ((body (fn cur step as)
-         (multiple-value-bind (value-ptr value-len) (funcall fn cur step)
+         (multiple-value-bind (value-ptr value-len) (funcall fn cur :step step)
            (with-kcmalloced-pointer (value-ptr value-ptr)
              (foreign-string->x as value-ptr value-len)))))
   (declare (inline body))
-  (defun get-key (cur step &key (as :string))
+  (defun get-key (cur &key step (as :string))
     (body #'kc.cur.base:get-key cur step as))
-  (defun get-value (cur step &key (as :string))
+  (defun get-value (cur &key step (as :string))
     (body #'kc.cur.base:get-value cur step as)))
 
-(defun get (cur step &key (as :string))
+(defun get (cur &key step (as :string))
   (let ((as (if (consp as) as (cons as as))))
     (multiple-value-bind (key-buf key-len value-buf value-len)
-        (kc.cur.base:get cur step)
+        (kc.cur.base:get cur :step step)
       (with-kcmalloced-pointers ((key-buf key-buf)
                                  (value-buf value-buf))
         (values (foreign-string->x (car as) key-buf key-len)
          (with-new-db (db)
            (kc.db:set db key value)
            (kc.cur:with-cursor (cur db)
-             (multiple-value-bind (ptr len) (funcall fn cur t)
+             (multiple-value-bind (ptr len) (funcall fn cur)
                (kc.util:with-kcmalloced-pointer (ptr ptr)
                  (let ((s (cffi:foreign-string-to-lisp ptr)))
                    (5am:is (funcall value-pred s))))
            (kc.cur:with-cursor (cur db)
              (5am:is (funcall pred (funcall fn cur)))))))
   (5am:test (get-key/value :compile-at :definition-time)
-    (body "x" "1"
-          (lambda (c) (kc.cur:get-key c nil))
-          (lambda (v) (equal "x" v))))
+    (body "x" "1" #'kc.cur:get-key (lambda (v) (equal "x" v))))
   (5am:test (get-value/value :compile-at :definition-time)
-    (body "x" "1"
-          (lambda (c) (kc.cur:get-value c nil))
-          (lambda (v) (equal "1" v)))))
+    (body "x" "1" #'kc.cur:get-value (lambda (v) (equal "1" v)))))
 
 (5am:test get/low/value
   (with-new-db (db)
     (kc.db:set db "x" "1")
     (kc.cur:with-cursor (cur db)
       (multiple-value-bind (key-buf key-len value-buf value-len)
-          (kc.cur.low:get cur nil)
+          (kc.cur.low:get cur)
         (kc.util:with-kcmalloced-pointers ((key-buf key-buf)
                                            (value-buf value-buf))
           (flet ((->string (buf len)
   (with-new-db (db)
     (kc.db:set db "x" "1")
     (kc.cur:with-cursor (cur db)
-      (multiple-value-bind (key value) (kc.cur:get cur nil)
+      (multiple-value-bind (key value) (kc.cur:get cur)
         (5am:is (equal "x" key))
         (5am:is (equal "1" value))))))
 
                                :writable nil :step step))))
   (5am:test (get-key/low/step :compile-at :definition-time)
     (body (lambda (cur step)
-            (kc.ffi:kcfree (kc.cur.low:get-key cur step)))))
+            (kc.ffi:kcfree (kc.cur.low:get-key cur :step step)))))
   (5am:test (get-value/low/step :compile-at :definition-time)
     (body (lambda (cur step)
-            (kc.ffi:kcfree (kc.cur.low:get-value cur step)))))
+            (kc.ffi:kcfree (kc.cur.low:get-value cur :step step)))))
   (5am:test (get/low/step :compile-at :definition-time)
     (body (lambda (cur step)
-            (multiple-value-bind (kb kl vb vl) (kc.cur.low:get cur step)
+            (multiple-value-bind (kb kl vb vl) (kc.cur.low:get cur :step step)
               (declare (ignore kl vl))
               (kc.ffi:kcfree kb)
               (kc.ffi:kcfree vb)))))
   (5am:test (get-key/step :compile-at :definition-time)
-    (body #'kc.cur:get-key))
+    (body (lambda (cur step)
+            (kc.cur:get-key cur :step step))))
   (5am:test (get-value/step :compile-at :definition-time)
-    (body #'kc.cur:get-value))
+    (body (lambda (cur step)
+            (kc.cur:get-value cur :step step))))
   (5am:test (get/step :compile-at :definition-time)
-    (body #'kc.cur:get)))
+    (body (lambda (cur step)
+            (kc.cur:get cur :step step)))))