* [ANN] nyacc-2.01.3 released
@ 2024-11-03 21:03 Matt Wette
0 siblings, 0 replies; only message in thread
From: Matt Wette @ 2024-11-03 21:03 UTC (permalink / raw)
To: Guile User
This release extends the capability to provide guile procedures
directly to functions which take callback arguments. More explanation
below.
NYACC, for Not Yet Another Compiler Compiler, is set of guile modules for
generating parsers and lexical analyzers. It also provides sample parsers
and pretty-printers using SXML trees as an intermediate representation.
It provides a decent C parser and a `FFI Helper' tool to help create
Guile Scheme bindings for C-based libraries.
It provides (partially implemented) compilers based on above mentioned
parsers to allow execution with Guile as extension languages.
NEWS
* ffi-helper: cover more cases where passing procedure (e.g.,
callback) to functions works; was only function-ptr typedefs
* for forward ref structs, unions which are never elaborated,
don't generate a definition
* update some documentation for nyacc-fh-ug and cdata
A little more detail on the fix. Consider the following functions
with callback argument `cb'. With nyacc-2.01.2 `f1' would accept a
guile procedure directly (i.e., without user translating via
procedure->pointer), but `f2' and `f3' would not. With nyacc-2.01.3,
all three work.
(define-ffi-module (ffi dbug)
#:api-code "
typedef void (*t1)(int);
typedef void (t2)(int);
int f1(int, t1 cb);
int f2(int, t2 *cb);
int f3(int, void (*cb)(int));")
Expanded code appears below.
NYACC maturity is production/stable level.
NYACC is free software; the full source distribution is available through
* the tarball repository:
https://download.savannah.gnu.org/releases/nyacc/
* the git repository:
git://git.savannah.nongnu.org/nyacc.git
home page, project page and user's guides:
* https://www.nongnu.org/nyacc
* https://savannah.nongnu.org/projects/nyacc
* https://www.nongnu.org/nyacc/nyacc-ug.html
* https://www.nongnu.org/nyacc/ffi-help.html
Report bugs:
* https://savannah.nongnu.org/bugs/?group=nyacc
Get support:
* https://savannah.nongnu.org/support/?group=nyacc
Copyright (C) 2017-2024 Matthew Wette
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without any warranty.
Copyright (C) 2017-2024 Matthew Wette
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without any warranty.
============================================
nyacc v2.01.2
;; int f1(int, t1 cb);
(define-public f1
(let ((~proc (delay (ffi:pointer->procedure
ffi:int
(foreign-pointer-search "f1")
(list ffi:int '*)))))
(lambda (arg0 cb)
(let ((arg0 (unwrap-number arg0))
(cb (unwrap-pointer cb t1)))
((force ~proc) arg0 cb)))))
;; int f2(int, t2 *cb);
(define-public f2
(let ((~proc (delay (ffi:pointer->procedure
ffi:int
(foreign-pointer-search "f2")
(list ffi:int '*)))))
(lambda (arg0 cb)
(let ((arg0 (unwrap-number arg0))
(cb (unwrap-pointer cb)))
((force ~proc) arg0 cb)))))
;; int f3(int, void (*cb)(int));
(define-public f3
(let ((~proc (delay (ffi:pointer->procedure
ffi:int
(foreign-pointer-search "f3")
(list ffi:int '*)))))
(lambda (arg0 cb)
(let ((arg0 (unwrap-number arg0))
(cb (unwrap-pointer cb)))
((force ~proc) arg0 cb)))))
============================================
nyacc v2.01.3
;; int f1(int, t1 cb);
(define-public f1
(let ((~proc (delay (ffi:pointer->procedure
ffi:int
(foreign-pointer-search "f1")
(list ffi:int '*)))))
(lambda (arg0 cb)
(let ((arg0 (unwrap-number arg0))
(cb (unwrap-pointer cb t1)))
((force ~proc) arg0 cb)))))
;; int f2(int, t2 *cb);
(define-public f2
(let ((~proc (delay (ffi:pointer->procedure
ffi:int
(foreign-pointer-search "f2")
(list ffi:int '*)))))
(lambda (arg0 cb)
(let ((arg0 (unwrap-number arg0))
(cb (unwrap-pointer cb t2*)))
((force ~proc) arg0 cb)))))
;; int f3(int, void (*cb)(int));
(define-public f3
(let ((~proc (delay (ffi:pointer->procedure
ffi:int
(foreign-pointer-search "f3")
(list ffi:int '*)))))
(lambda (arg0 cb)
(let ((arg0 (unwrap-number arg0))
(cb (unwrap-pointer
cb
(cpointer
(cfunction
(lambda (~proc)
(ffi:procedure->pointer
ffi:void
(lambda (arg0) (~proc arg0))
(list ffi:int)))
(lambda (p) 'unused))))))
((force ~proc) arg0 cb)))))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-11-03 21:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-03 21:03 [ANN] nyacc-2.01.3 released Matt Wette
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).