* Wrapping C++ templates in Guile
@ 2005-03-03 2:33 Mario Storti
2005-03-06 14:03 ` Neil Jerram
0 siblings, 1 reply; 2+ messages in thread
From: Mario Storti @ 2005-03-03 2:33 UTC (permalink / raw)
Hi all!
I have written a vector library, similar to the C++ STL vector<>
library. I want to wrap it to use with Guile. Yes, I know that there
are already components with similar functionality in Guile itself, as
for instance the uniform arrays, and homogeneous vectors
(SRFI-4). However I need them to interface with mi Finite Element
Library (http://www.cimec.org.ar/petscfem). Finally, I think that is a
good exercise to do.
So I already wrapped a subset of the functionality of my `dvector<>'
library and I'm happy with it. However I did the wrapping for a
`dvector<double>', i.e. a particular instantiation of the C++
template. Now I can't figure how to wrap other instantiations (for
instance `dvector<int>' or `dvector<float>') without duplicating
code. For the C++ part (the wrappers to be loaded in Scheme) I had no
problems by using some tricky macros, but the problem is with the
Scheme code that calls the C++ primitives.
To be more specific let's say that I have the C++ primitives mapped
to their Scheme versions `make-dvdbl', `dvdbl-set!', `dvdbl-ref' and
`dvdbl-resize!', and the same for the `dvint' versions. Now I have
some Scheme function `dvdbl-fill-with-proc v proc' that fills the
vector of doubles `v' with a procedure that produces values. How can I
make this more general, i.e. for other instantiations like
`dvint-fill-with-proc v proc', for integers? Should I use OOP and made
it generic, or is this an overkill? Should I use macros? And what about
efficiency?
TIA, Mario
=====
-------------------------
Mario Alberto Storti
Centro Internacional de Metodos Computacionales
en Ingenieria - CIMEC (INTEC/CONICET-UNL)
INTEC, Guemes 3450 - 3000 Santa Fe, Argentina
Tel/Fax: +54-342-4511594, cel: +54-342-156144983
e-mail: mstorti@intec.unl.edu.ar
http://www.cimec.org.ar/mstorti, http://www.cimec.org.ar
-------------------------
_________________________________________________________
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Wrapping C++ templates in Guile
2005-03-03 2:33 Wrapping C++ templates in Guile Mario Storti
@ 2005-03-06 14:03 ` Neil Jerram
0 siblings, 0 replies; 2+ messages in thread
From: Neil Jerram @ 2005-03-06 14:03 UTC (permalink / raw)
Cc: guile-user
Mario Storti wrote:
> Hi all!
>
> I have written a vector library, similar to the C++ STL vector<>
> library. [...] How can I
> make this more general, i.e. for other instantiations like
> `dvint-fill-with-proc v proc', for integers? Should I use OOP and made
> it generic, or is this an overkill? Should I use macros? And what about
> efficiency?
Hi Mario,
I don't think we have enough detail yet to advise you. What precisely
is the signature of the SMOBs and/or procedures that you have exported
from C++ to Scheme? Is a procedure like dvdbl-fill-with-proc one that
is exported directly from C++, or is it coded in Scheme on top of
something more primitive that you have exported from C++?
Regards,
Neil
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-03-06 14:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-03 2:33 Wrapping C++ templates in Guile Mario Storti
2005-03-06 14:03 ` Neil Jerram
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).