From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.user Subject: Re: Creating a new port in C for use in guile Date: Thu, 04 Sep 2014 13:00:39 +0200 Message-ID: <874mwnirag.fsf@gnu.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1409828467 14590 80.91.229.3 (4 Sep 2014 11:01:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Sep 2014 11:01:07 +0000 (UTC) Cc: guile-user@gnu.org To: Joshua Datko Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Sep 04 13:01:03 2014 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XPUmk-0004dZ-PQ for guile-user@m.gmane.org; Thu, 04 Sep 2014 13:01:02 +0200 Original-Received: from localhost ([::1]:49973 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPUmk-0000yK-G5 for guile-user@m.gmane.org; Thu, 04 Sep 2014 07:01:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPUmX-0000y9-A1 for guile-user@gnu.org; Thu, 04 Sep 2014 07:00:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPUmQ-0001E2-Fm for guile-user@gnu.org; Thu, 04 Sep 2014 07:00:49 -0400 Original-Received: from hera.aquilenet.fr ([2a01:474::1]:58046) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPUmQ-0001Dk-3W for guile-user@gnu.org; Thu, 04 Sep 2014 07:00:42 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 1462A38A0; Thu, 4 Sep 2014 13:00:40 +0200 (CEST) Original-Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TVyRfaBC7Ey6; Thu, 4 Sep 2014 13:00:39 +0200 (CEST) Original-Received: from pluto (pluto.bordeaux.inria.fr [193.50.110.57]) by hera.aquilenet.fr (Postfix) with ESMTPSA id CEB0E3852; Thu, 4 Sep 2014 13:00:39 +0200 (CEST) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 18 Fructidor an 222 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: (Joshua Datko's message of "Tue, 02 Sep 2014 16:28:44 -0600") User-Agent: Gnus/5.130011 (Ma Gnus v0.11) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:474::1 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:11455 Archived-At: Joshua Datko 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. =E2=80=98scm_make_port_type=E2=80=99 returns a number of the =E2=80=98scm_t= _bits=E2=80=99 type. That number identifies the port type internally. Then, to instantiate a port of that type, use =E2=80=98scm_new_port_table_entry=E2=80=99: --8<---------------cut here---------------start------------->8--- scm_t_bits port_type; port_type =3D scm_make_port_type (...); [...] SCM port; port =3D scm_new_port_table_entry (port_type); --8<---------------cut here---------------end--------------->8--- Here=E2=80=99s a couple of examples: http://git.savannah.gnu.org/cgit/guile.git/tree/libguile/r6rs-ports.c#n73 https://gitorious.org/gnutls/gnutls/source/12e50aa449a8f6bb7b2c2fa3c17781= 2e463ea4c7:guile/src/core.c#L923 Hope this helps! Ludo=E2=80=99.