[plt-scheme] syntax-rules version of this...
Ed Cavazos wrote:
> I have this macro called 'define-c-const' that is shorthand for doing
> the extraction:
>
> ;; Macro: (define-c-const FOO)
You might have a look at
http://www.cs.uvm.edu/~dvanhorn/c-syntax.ss
http://www.cs.uvm.edu/~dvanhorn/c-syntax-transformer.ss
Basically, I have a function that maps a scheme symbol to a C enum symbol
(just upcase the symbol and replace hyphens with underscores) and a macro
`c-enum' built on top of that.
Eg.
(c-enum foo-bar) ~> ((c-lambda () int "___result = FOO_BAR;"))
And then some convenience macros are provided like:
(define-c-enums
foo-bar
bar-baz
...)
~>
(define foo-bar ((c-lambda () int "___result = FOO_BAR;")))
(define bar-baz ((c-lambda () int "___result = BAR_BAZ;")))
...
If you'd like to change the naming convention, simply replace the
scheme-symbol->c-enum-symbol function in c-syntax-transformer.ss.
I would appreciate any feedback you might have, Ed.
HTH
-d