make swi-yap io interface a structure.

This commit is contained in:
Vítor Santos Costa 2010-07-21 09:39:49 +01:00
parent 7551f2b12e
commit 90f7504a76
3 changed files with 22 additions and 11 deletions

View File

@ -663,13 +663,17 @@ PL_EXPORT(int) PL_foreign_control(control_t);
PL_EXPORT(intptr_t) PL_foreign_context(control_t); PL_EXPORT(intptr_t) PL_foreign_context(control_t);
PL_EXPORT(void *) PL_foreign_context_address(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 */ /* SWI stream info */
PL_EXPORT(void) PL_YAP_InitSWIIO(functor_t f, PL_EXPORT(void) PL_YAP_InitSWIIO(struct SWI_IO *swio);
void *gc,
void *pc,
void *cc);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -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 */ /* glue function to connect back PLStream to YAP IO */
X_API void 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); FSWIStream = SWIFunctorToFunctor(swio->f);
SWIGetc = gc; SWIGetc = swio->get_c;
SWIPutc = pc; SWIPutc = swio->put_c;
SWIClose = cc; SWIClose = swio->close_s;
} }

View File

@ -4315,7 +4315,14 @@ static pl_Sgetc(IOSTREAM *s)
static void static void
init_yap_extras() 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(); initCharTypes();
initFiles(); initFiles();
initGlob(); initGlob();