unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Can Dynamic FFI in Guile handle pass by value struct?
@ 2021-02-06 14:10 Zhu Zihao
  0 siblings, 0 replies; only message in thread
From: Zhu Zihao @ 2021-02-06 14:10 UTC (permalink / raw)
  To: guile-user

[-- 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 --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-06 14:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-06 14:10 Can Dynamic FFI in Guile handle pass by value struct? Zhu Zihao

unofficial mirror of guile-user@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-user/0 guile-user/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-user guile-user/ https://yhetil.org/guile-user \
		guile-user@gnu.org
	public-inbox-index guile-user

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.user
	nntp://news.gmane.io/gmane.lisp.guile.user


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git