From: Zhu Zihao <all_but_last@163.com>
To: guile-user@gnu.org
Subject: Can Dynamic FFI in Guile handle pass by value struct?
Date: Sat, 06 Feb 2021 22:10:14 +0800 [thread overview]
Message-ID: <86h7mp5ltl.fsf@163.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 943 bytes --]
Hi, Guile users!
I'm working on a Guile binding to tree-sitter, an incremental parsing
library. Consider we have something like(actually taken from
tree-sitter's header file)
```
typedef struct {
uint32_t context[4];
const void *id;
const TSTree *tree;
} TSNode;
uint32_t ts_node_end_byte(TSNode);
```
I'd like to write binding like
```
(pointer->procedure uint32 (dynamic-func "ts_node_end_byte" %libtree-sitter) `((,uint32 * *)))
```
As the function defined in header, we need to pass a TSNode struct by
value to ts_node_end_type. But I'm not sure how to do it in Dynamic FFI.
There's make-c-struct in (system foreign), but it'll return a pointer to
the struct.
I check the doc but can't find something useful, Can guile Dynamic FFI
pass a C struct by value or we must do it in static FFI?
--
Retrieve my PGP public key:
gpg --recv-keys D47A9C8B2AE3905B563D9135BE42B352A9F6821F
Zihao
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 255 bytes --]
reply other threads:[~2021-02-06 14:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86h7mp5ltl.fsf@163.com \
--to=all_but_last@163.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).