* Creating a new port in C for use in guile
@ 2014-09-02 22:28 Joshua Datko
2014-09-04 11:00 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Joshua Datko @ 2014-09-02 22:28 UTC (permalink / raw)
To: guile-user
I want to make a new Port. I would like to write the port implementation
in C and use that port in scheme.
I'm a bit confused on how to proceed though. From reading the docs, it
seems I have to create a C function, in the form of an extension, that
calls scm_make_port_type.
However, the manual states [1] that the return value from
scm_make_port_type is a scm_ptob_descriptor. I'm confused on how I
instantiate this new port type to get a scm_port.
What am I missing?
Thanks,
Josh
[1] https://www.gnu.org/software/guile/manual/guile.html#Port-Implementation
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Creating a new port in C for use in guile
2014-09-02 22:28 Creating a new port in C for use in guile Joshua Datko
@ 2014-09-04 11:00 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2014-09-04 11:00 UTC (permalink / raw)
To: Joshua Datko; +Cc: guile-user
Joshua Datko <jbdatko@gmail.com> skribis:
> I want to make a new Port. I would like to write the port implementation
> in C and use that port in scheme.
>
> I'm a bit confused on how to proceed though. From reading the docs, it
> seems I have to create a C function, in the form of an extension, that
> calls scm_make_port_type.
>
> However, the manual states [1] that the return value from
> scm_make_port_type is a scm_ptob_descriptor. I'm confused on how I
> instantiate this new port type to get a scm_port.
‘scm_make_port_type’ returns a number of the ‘scm_t_bits’ type. That
number identifies the port type internally.
Then, to instantiate a port of that type, use
‘scm_new_port_table_entry’:
--8<---------------cut here---------------start------------->8---
scm_t_bits port_type;
port_type = scm_make_port_type (...);
[...]
SCM port;
port = scm_new_port_table_entry (port_type);
--8<---------------cut here---------------end--------------->8---
Here’s a couple of examples:
http://git.savannah.gnu.org/cgit/guile.git/tree/libguile/r6rs-ports.c#n73
https://gitorious.org/gnutls/gnutls/source/12e50aa449a8f6bb7b2c2fa3c177812e463ea4c7:guile/src/core.c#L923
Hope this helps!
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-04 11:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-02 22:28 Creating a new port in C for use in guile Joshua Datko
2014-09-04 11:00 ` Ludovic Courtès
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).