]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
Generic function for unwrapping foreign records
authorJavier Sancho <jsf@jsancho.org>
Tue, 31 Dec 2019 15:18:54 +0000 (16:18 +0100)
committerJavier Sancho <jsf@jsancho.org>
Tue, 31 Dec 2019 15:18:54 +0000 (16:18 +0100)
irrlicht/device.scm
irrlicht/dimension2d.scm
irrlicht/gui.scm
irrlicht/rect.scm
irrlicht/util.scm

index 051cddddada3942b0ec3072172f9d38d6900035b..c773dbc99d96af6fc5fc027c06dbe32788057228 100644 (file)
@@ -52,7 +52,7 @@
                        ('opengl ffi-video:EDT_OPENGL)
                        ('count ffi-video:EDT_COUNT))))
     (let ((device (ffi:create-device driver
-                                     (dimension2d->pointer window-size)
+                                     (foreign-record->pointer window-size)
                                      bits
                                      (bool->integer fullscreen)
                                      (bool->integer stencilbuffer)
index 6b03cd0e824e3b52c2c47e2a69572e85ff5b87eb..7eb8cfd63231ddec2c2d029532ef52daead3e28d 100644 (file)
@@ -24,7 +24,6 @@
   #:export (dimension2d
             make-dimension2d
             dimension2d?
-            dimension2d->pointer
             dimension2d-width
             dimension2d-height))
 
@@ -32,6 +31,5 @@
 (define-foreign-record-type dimension2d
   (make-dimension2d width height)
   dimension2d?
-  dimension2d->pointer
   (width uint32 dimension2d-width)
   (height uint32 dimension2d-height))
index 495a9c748e05905a643005bfb1ce3fb3d9592c20..bd5eedee204e0d8e1030956390b1770165ccdebc 100644 (file)
@@ -23,7 +23,6 @@
   #:use-module (system foreign)
   #:use-module ((irrlicht bindings core) #:prefix ffi-core:)
   #:use-module ((irrlicht bindings gui) #:prefix ffi-gui:)
-  #:use-module (irrlicht rect)
   #:use-module (irrlicht util)
   #:export (add-static-text!
             gui-draw-all
@@ -38,7 +37,7 @@
                            (fill-background #f))
   (ffi-gui:add-static-text gui-env
                            (string->pointer text)
-                           (rect->pointer rectangle)
+                           (foreign-record->pointer rectangle)
                            (bool->integer border)
                            (bool->integer word-wrap)
                            parent
index f481a7c4d53b9d84be937ee77a043b785afbc45c..b73f32dac0c26c3100ff90ad1476639f32f8d050 100644 (file)
@@ -24,7 +24,6 @@
   #:export (rect
             make-rect
             rect?
-            rect->pointer
             rect-x
             rect-y
             rect-x2
@@ -34,7 +33,6 @@
 (define-foreign-record-type rect
   (make-rect x y x2 y2)
   rect?
-  rect->pointer
   (x int32 rect-x)
   (y int32 rect-y)
   (x2 int32 rect-x2)
index e7c8641026b23a9b93dd95d55f6751ff546de9dd..efa5ba7fbe2c7547fa7f0cf217b459cd73259d5d 100644 (file)
@@ -25,7 +25,8 @@
   #:export (bool->integer
             integer->bool
             define-foreign
-            define-foreign-record-type))
+            define-foreign-record-type
+            foreign-record->pointer))
 
 (define (bool->integer var)
   (if var 1 0))
@@ -79,7 +80,7 @@
                   (iota (length field-specs))))
 
     (syntax-case x ()
-      ((_ name (make-name make-arg ...) predicate? unwrap-record field-spec ...)
+      ((_ name (make-name make-arg ...) predicate? field-spec ...)
        (with-syntax (((type-id ...) (field-types #'(field-spec ...)))
                      ((field-name ...) (field-names #'(field-spec ...)))
                      (((getter getter-id) ...) (field-getters #'(field-spec ...)))
            (else #f))))
     (if procedure
         (apply procedure bv 0 value '()))))
+
+(define (foreign-record->pointer record)
+  (struct-ref record 0))