On Sat, 2008-04-26 at 15:43 -0400, Joseph Wang wrote:
> On Saturday 26 April 2008 04:57:26 am Soeren Sonnenburg wrote:
> > What about the other two problems I am seeing? Why can't we get rid of
> > the scorecein typemap in rtype.swg at all? I mean it is bad if things
> > get converted to numeric (or so) although there is a magic (user
> > written!) typemap doing the work. I still don't understand why ther
> > should be any conversion at all...
>
> A lot of R-Swig was written with trial and error. I just removed the
> scorecein typemaps for integers and floats, and the regression tests ran fine
> as did my quantlib scripts. So I just commented them out.
Why not remove them completely, also the as($input, ...) scoerecein?
Because now on swig-svn still any matrix is converted to a vector due to
these scoerecein typemaps. I just removed them (see attached patch) and
the tests still run through and now also in my project ( shogun )
copy_matrix / get_fm (matrix in/out) work.
> > Also what about the dispatcher? Any ideas on how to better check if two
> > types are compatible (extends seems not be the right thing for numeric
> > types)...
>
> No ideas, but I'm interested in anything anyone else can think of.....
We could make an exception for the numeric type, like instead of asking
for extends(x,'numeric') we ask is.numeric(x) ?
That would be sufficient...
Soeren
[rtype.diff]
Index: Lib/r/rtype.swg
===================================================================
--- Lib/r/rtype.swg (revision 10394)
+++ Lib/r/rtype.swg (working copy)
@@ -36,6 +36,7 @@
*/
+/*
%typemap(scoercein) int, int *, int &
%{ $input = as($input, "integer"); %}
%typemap(scoercein) ptrdiff_t, ptrdiff_t *, ptrdiff_t &
@@ -78,11 +79,9 @@
%}
-/* **************************************************************** */
%typemap(scoercein) bool, bool *, bool &
"$input = as.logical($input) ";
-/*
%typemap(scoercein) int,
int *,
int &,
@@ -119,11 +118,11 @@
long*,
long long *
%{ $input = as.numeric($input) %}
-*/
%typemap(scoercein) char *, string, std::string,
string &, std::string &
%{ $input = as($input, "character") %}
+*/
%typemap(scoerceout) enum SWIGTYPE
%{ $result = enumFromInteger($result, "$R_class") %}
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user