unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Joshua Datko <jbdatko@gmail.com>
Cc: guile-user@gnu.org
Subject: Re: Creating a new port in C for use in guile
Date: Thu, 04 Sep 2014 13:00:39 +0200	[thread overview]
Message-ID: <874mwnirag.fsf@gnu.org> (raw)
In-Reply-To: <m01trtveqr.fsf@deepthought.datko.lan> (Joshua Datko's message of "Tue, 02 Sep 2014 16:28:44 -0600")

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’.



      reply	other threads:[~2014-09-04 11:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=874mwnirag.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-user@gnu.org \
    --cc=jbdatko@gmail.com \
    /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).