[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Passing C pointers through guile
From: |
Kjetil S. Matheussen |
Subject: |
Re: Passing C pointers through guile |
Date: |
Wed, 9 Jul 2008 18:50:51 +0200 (CEST) |
Ludovic Court?s:
> scenes.
>
> > I agree with Maciek that it would at least be mind-comforting to have
> > functions like scm_to_ptr/etc, although not strictly necessary,
> > since using integers works just fine.
>
> `scm_{to,from}_uintptr ()' could be handy (patches welcome!).
>
I gave it a try. Unfortunately, I was completely unable to create
the configure file right now, so the patch is against 1.8.5 (sorry
if this creats trouble against git repository), and
it's also untested, since I couldn't build configure. However,
the patches are trivial, so I think they work anyway. (crossing fingers)
The only thing I'm not too sure about is whether
the new SCM_I_GSC_T_UINTPTR type in configure.in will actually be
optional or not. I just copied the checking code for the optional
SCM_I_GSC_T_UINT64 type though:
"
### Optional type scm_t_uintptr
if test "$scm_stdint_has_uintptr"; then
SCM_I_GSC_T_UINTPTR='"uintptr_t"'
SCM_I_GSC_NEEDS_STDINT_H=1
elif test "$scm_inttypes_has_uintptr"; then
SCM_I_GSC_T_UINTPTR='"uintptr_t"'
SCM_I_GSC_NEEDS_INTTYPES_H=1
else
AC_MSG_ERROR([Can't find appropriate type for scm_t_uintptr.])
fi
AC_SUBST([SCM_I_GSC_T_UINTPTR])
"
Patch for configure.in:
http://www.notam02.no/~kjetism/configure.in.diff
Patch for libguile/Makefile.in, libguile/__scm.h,
libguile/gen-scmconfig.c, libguile/gen-scmconfig.h.in and
libguile/numbers.c:
http://www.notam02.no/~kjetism/libguile.diff
The two patches are also attached.
> That said, using a Scheme integer to represent a pointer wouldn't be
> efficient (pointers would likely translate to bignums).
>
I think cleaner code would usually be more important in this case,
but at least there will be a choice.
libguile.diff
Description: Text document
configure.in.diff
Description: Text document