From 8a93b3ce695003d07c8d8e4c71153c0130372c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 20 Jul 2020 03:59:10 +0200 Subject: Cleanup for cpp. --- module/c/cpp.scm | 7 +++++-- module/vulgar/termios.scm | 12 ++---------- tests/cpp.scm | 3 +++ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/module/c/cpp.scm b/module/c/cpp.scm index 69e21d27..2fe842c8 100644 --- a/module/c/cpp.scm +++ b/module/c/cpp.scm @@ -114,7 +114,10 @@ (string-append "cpp -dM " header-file)) read-lines))) -(define-macro (include# header-file) +(define-macro (include# header-file . args) + + (define define-form (if (null? args) 'define (car args))) + (define lines (remove (compose private-c-symbol? car) (tokenize-header-file header-file))) @@ -131,7 +134,7 @@ (define graph (add-node graph* (cons '_POSIX_VDISABLE #f) '())) `(begin - ,@(map (lambda (pair) `(define ,(car pair) ,(cdr pair))) + ,@(map (lambda (pair) `(,define-form ,(car pair) ,(cdr pair))) (resolve-dependency-graph graph)))) diff --git a/module/vulgar/termios.scm b/module/vulgar/termios.scm index 3fe82f92..62212122 100644 --- a/module/vulgar/termios.scm +++ b/module/vulgar/termios.scm @@ -7,6 +7,7 @@ :use-module (ice-9 format) :use-module (ice-9 rdelim) :use-module (srfi srfi-9) ; records + :use-module (c cpp) :use-module (util) :export (make-termios copy-termios @@ -14,16 +15,7 @@ -;;; Constants, TODO, auto parse these from -;; /usr/include/bits/termios.h - -(define-public ECHO 0000010) -(define-public ICANON 0000002) - -;; @var{when} values -(define-public TCSANOW 0) -(define-public TCSADRAIN 1) -(define-public TCSAFLUSH 2) +(include# "/usr/include/termios.h" define-public) diff --git a/tests/cpp.scm b/tests/cpp.scm index 1d4e62f3..d83ba554 100644 --- a/tests/cpp.scm +++ b/tests/cpp.scm @@ -1,3 +1,6 @@ +(((c lex) lex) + ((c parse) parse-lexeme-tree)) + (define run (compose parse-lexeme-tree lex)) (test-equal -- cgit v1.2.3