File: gen-keysyms.scm

package info (click to toggle)
gauche-gtk 0.4.1-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,520 kB
  • ctags: 3,230
  • sloc: ansic: 6,655; lisp: 4,159; sh: 2,707; makefile: 344
file content (29 lines) | stat: -rw-r--r-- 819 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
;;
;; Generates gdk/gdkkeysyms.scm from gdk/gdkkeysyms.h
;;

(use gauche.process)
(use srfi-13)

(define (main args)
  (let1 prefix (process-output->string "pkg-config --variable=prefix gtk+-2.0")
    (when (string-null? prefix)
      (error "can't get the gtk+-2.0 install location.  pkg-config problem?"))
    (with-output-to-file "gtk/gdkkeysyms.scm"
      (lambda ()
        (print ";; Automatically generated")
        (print "(select-module gtk)")
        (with-input-from-file #`",|prefix|/include/gtk-2.0/gdk/gdkkeysyms.h"
          (cut port-for-each filter read-line))
        (print "(provide \"gtk/gdkkeysyms\")"))))
  0)

(define (filter line)
  (rxmatch-if (rxmatch #/^#define\s+([\w_]+)\s+0x([\w]+)/ line)
      (#f name value)
    (print #`"(define-constant ,|name| #x,|value|)")
    #f))