From 90f7504a769fd1af3238fd1b5551698dbe237a43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Wed, 21 Jul 2010 09:39:49 +0100 Subject: [PATCH] make swi-yap io interface a structure. --- include/SWI-Prolog.h | 14 +++++++++----- library/yap2swi/yap2swi.c | 10 +++++----- packages/PLStream/pl-file.c | 9 ++++++++- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/include/SWI-Prolog.h b/include/SWI-Prolog.h index f9a05d7a4..9f7155b8a 100755 --- a/include/SWI-Prolog.h +++ b/include/SWI-Prolog.h @@ -663,13 +663,17 @@ PL_EXPORT(int) PL_foreign_control(control_t); PL_EXPORT(intptr_t) PL_foreign_context(control_t); PL_EXPORT(void *) PL_foreign_context_address(control_t); +typedef struct SWI_IO { + functor_t f; + void *get_c; + void *put_c; + void *get_w; + void *put_w; + void *close_s; +} swi_io_struct; /* SWI stream info */ -PL_EXPORT(void) PL_YAP_InitSWIIO(functor_t f, - void *gc, - void *pc, - void *cc); - +PL_EXPORT(void) PL_YAP_InitSWIIO(struct SWI_IO *swio); #ifdef __cplusplus } diff --git a/library/yap2swi/yap2swi.c b/library/yap2swi/yap2swi.c index 1eb95ec46..abfbbd486 100755 --- a/library/yap2swi/yap2swi.c +++ b/library/yap2swi/yap2swi.c @@ -3092,12 +3092,12 @@ PL_blob_data(term_t ts, size_t *len, PL_blob_t **type) /* glue function to connect back PLStream to YAP IO */ X_API void -PL_YAP_InitSWIIO(functor_t f, void * gc, void * pc, void* cc) +PL_YAP_InitSWIIO(struct SWI_IO *swio) { - FSWIStream = SWIFunctorToFunctor(f); - SWIGetc = gc; - SWIPutc = pc; - SWIClose = cc; + FSWIStream = SWIFunctorToFunctor(swio->f); + SWIGetc = swio->get_c; + SWIPutc = swio->put_c; + SWIClose = swio->close_s; } diff --git a/packages/PLStream/pl-file.c b/packages/PLStream/pl-file.c index 9b75d69bc..58ab98b3b 100755 --- a/packages/PLStream/pl-file.c +++ b/packages/PLStream/pl-file.c @@ -4315,7 +4315,14 @@ static pl_Sgetc(IOSTREAM *s) static void init_yap_extras() { - PL_YAP_InitSWIIO(FUNCTOR_dstream1, pl_Sgetc, Sputc, Sclose); + swi_io_struct swiio; + swiio.f = FUNCTOR_dstream1; + swiio.get_c = pl_Sgetc; + swiio.put_c = Sputc; + swiio.get_w = Sgetcode; + swiio.put_w = Sputcode; + swiio.close_s = Sclose; + PL_YAP_InitSWIIO(&swiio); initCharTypes(); initFiles(); initGlob();