[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/25] Improve deriving c symbol name from scheme one
From: |
KAction |
Subject: |
[PATCH 12/25] Improve deriving c symbol name from scheme one |
Date: |
Mon, 18 Jul 2016 18:17:35 +0300 |
From: Dmitry Bogatov <address@hidden>
---
module/system/foreign/declarative.scm | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/module/system/foreign/declarative.scm
b/module/system/foreign/declarative.scm
index b0c31a0..62d40b8 100644
--- a/module/system/foreign/declarative.scm
+++ b/module/system/foreign/declarative.scm
@@ -132,9 +132,18 @@
(define (make-c-function-name symbol)
(define function-name (symbol->string symbol))
+ (define (replace-hyphen c)
+ (if (eqv? c #\-)
+ #\_
+ c))
+ (define (c-identifier-char? c)
+ (or (char-alphabetic? c)
+ (char-numeric? c)
+ (eqv? c #\_)))
(when (string-prefix? "c-" function-name)
(set! function-name (string-drop function-name 2)))
- function-name)
+ (string-map! replace-hyphen function-name)
+ (string-filter c-identifier-char? function-name))
(define *validate-function-name* (make-parameter #f))
(define *validate-argument-name* (make-parameter #f))
--
I may be not subscribed. Please, keep me in carbon copy.
- [PATCH 03/25] Mirror types from system/foreign as <foreign-type>, (continued)
- [PATCH 03/25] Mirror types from system/foreign as <foreign-type>, KAction, 2016/07/18
- [PATCH 04/25] Write boilerplate for primitive types, KAction, 2016/07/18
- [PATCH 05/25] Fix bug in `default' macro, KAction, 2016/07/18
- [PATCH 06/25] Basic implementation of `define-foreign-function', KAction, 2016/07/18
- [PATCH 07/25] Introduce foreign-type predicates, KAction, 2016/07/18
- [PATCH 08/25] Add keywords for `define-foreign-function' macro, KAction, 2016/07/18
- [PATCH 10/25] Refactor type validation in `define-foreign-function', KAction, 2016/07/18
- [PATCH 09/25] system/foreign/declarative: rename `predicate' to `validate', KAction, 2016/07/18
- [PATCH 11/25] system/foreign/declarative: new macro, KAction, 2016/07/18
- [PATCH 13/25] system/foreign/declarative.scm: export string foreign type, KAction, 2016/07/18
- [PATCH 12/25] Improve deriving c symbol name from scheme one,
KAction <=
- [PATCH 14/25] foreign/declarative: mirror more primitive types, KAction, 2016/07/18
- [PATCH 15/25] New macro: with-pointer, KAction, 2016/07/18
- [PATCH 16/25] Configure emacs file-local indention, KAction, 2016/07/18
- [PATCH 17/25] system/foreign/declarative: unexport internal macro, KAction, 2016/07/18
- [PATCH 18/25] write documentation for (system foreign declarative), KAction, 2016/07/18
[PATCH 20/25] Document with-pointer macro, KAction, 2016/07/18