Debian Codegraph @

cairo/vector-types.scm

raw symbols SCIP
1 ;; guile-cairo
2 ;; Copyright (C) 2007, 2011 Andy Wingo <wingo at pobox dot com>
3
4 ;; This program is free software; you can redistribute it and/or modify
5 ;; it under the terms of the GNU Lesser General Public License as
6 ;; published by the Free Software Foundation; either version 3 of the
7 ;; License, or (at your option) any later version.
8 ;;
9 ;; This program is distributed in the hope that it will be useful, but
10 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ;; Lesser General Public License for more details.
13 ;;
14 ;; You should have received a copy of the GNU Lesser General Public
15 ;; License along with this program; if not, see
16 ;; <http://www.gnu.org/licenses/>.
17
18 ;;; Commentary:
19 ;;
20 ;; Constructors and accessors for (cairo) vector types.
21 ;;
22 ;;; Code:
23
24 (define-module (cairo vector-types))
25
26 (define-macro (define-accessors type accessor . fields)
27 `(begin
28 ,@(map (lambda (field)
29 ;; can't have : as a symbol
30 `(define-public (,(string->symbol
31 (string-append
32 (symbol->string type) ":" (symbol->string field)))
33 obj)
34 (,accessor obj ,(list-index fields field))))
35 fields)))
36
37 (define-macro (define-vector-type module type constructor . fields)
38 `(begin
39 (define-public (,(symbol-append module '-make- type) ,@fields)
40 (,constructor ,@fields))
41 (define-accessors ,(symbol-append module '- type)
42 ,(symbol-append constructor '-ref)
43 ,@fields)))
44
45 (define-vector-type cairo rectangle f64vector
46 x y width height)
47
48 (define-vector-type cairo rectangle-int s32vector
49 x y width height)
50
51 (define-vector-type cairo glyph vector
52 index x y)
53
54 (define-vector-type cairo text-extents f64vector
55 x-bearing y-bearing width height x-advance y-advance)
56
57 (define-vector-type cairo font-extents f64vector
58 ascent descent height max-x-advance max-y-advance)