Joshua Datko <[email protected]> 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’.
