Skip to content

Commit

Permalink
Revert r13601 as it breaks older versions of R
Browse files Browse the repository at this point in the history
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13713 626c5289-ae23-0410-ae9c-e8d60b6d4f22
  • Loading branch information
wsfulton committed Aug 20, 2012
1 parent 9da9df9 commit be1c4d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 35 deletions.
46 changes: 16 additions & 30 deletions Lib/r/rtype.swg
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
%apply int {unsigned int}
%apply int {short}
%apply int {unsigned short}
%apply int {signed char}
%apply int {unsigned char}

%typemap("rtype") long, long *, long & "integer";
%apply long {long long}
Expand All @@ -38,9 +36,10 @@
%typemap("rtype") SWIGTYPE & "$R_class";
%typemap("rtype") SWIGTYPE "$&R_class";

%typemap("rtypecheck") int, int &, long, long &
%typemap("rtypecheck") int, int &, long, long &,
unsigned char, unsigned char &
%{ (is.integer($arg) || is.numeric($arg)) && length($arg) == 1 %}
%typemap("rtypecheck") int *, long *
%typemap("rtypecheck") int *, long *, unsigned char *
%{ is.integer($arg) || is.numeric($arg) %}


Expand Down Expand Up @@ -108,8 +107,9 @@
%typemap(scoercein) enum SWIGTYPE *const
%{ $input = enumToInteger($input, "$R_class"); %}


%typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &
%{ if (.hasSlot($input, "ref")) $input = slot($input,"ref") %}
%{ %}

/*
%typemap(scoercein) SWIGTYPE *, SWIGTYPE *const
Expand Down Expand Up @@ -141,7 +141,7 @@
long *,
long &,
long[ANY]
"$input = as.integer($input);";
"$input = as.integer($input); ";

%typemap(scoercein) char *, string, std::string,
string &, std::string &
Expand All @@ -159,30 +159,18 @@ string &, std::string &
%typemap(scoerceout) enum SWIGTYPE *const
%{ $result = enumToInteger($result, "$R_class"); %}

#%typemap(scoerceout) SWIGTYPE
# %{ class($result) <- "$&R_class"; %}

#%typemap(scoerceout) SWIGTYPE &
# %{ class($result) <- "$R_class"; %}

#%typemap(scoerceout) SWIGTYPE *
# %{ class($result) <- "$R_class"; %}
%typemap(scoerceout) SWIGTYPE
%{ class($result) <- "$&R_class"; %}

#%typemap(scoerceout) SWIGTYPE *const
# %{ class($result) <- "$R_class"; %}
%typemap(scoerceout) SWIGTYPE &
%{ class($result) <- "$R_class"; %}

%typemap(scoerceout) SWIGTYPE
%{ $result <- new("$&R_class", ref=$result); %}

%typemap(scoerceout) SWIGTYPE &
%{ $result <- new("$R_class", ref=$result) ; %}

%typemap(scoerceout) SWIGTYPE *
%{ $result <- new("$R_class", ref=$result) ; %}

%typemap(scoerceout) SWIGTYPE *const
%{ $result <- new("$R_class", ref=$result) ; %}
%typemap(scoerceout) SWIGTYPE *
%{ class($result) <- "$R_class"; %}

%typemap(scoerceout) SWIGTYPE *const
%{ class($result) <- "$R_class"; %}

/* Override the SWIGTYPE * above. */
%typemap(scoerceout) char,
Expand Down Expand Up @@ -220,10 +208,8 @@ string &, std::string &
signed long &,
unsigned long,
unsigned long &,
signed char,
signed char &,
unsigned char,
unsigned char &
unsigned char *,
unsigned char &
%{ %}

#if 0
Expand Down
6 changes: 1 addition & 5 deletions Source/Modules/r.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1891,9 +1891,6 @@ int R::functionWrapper(Node *n) {
if(nargs == -1)
nargs = getFunctionPointerNumArgs(p, tt);

Printv(sfun->code, "if (.hasSlot(", name, ", \"ref\")) {\n",
name, " = slot(", name, ", \"ref\");\n",
"}\n", NIL);
String *snargs = NewStringf("%d", nargs);
Printv(sfun->code, "if(is.function(", name, ")) {", "\n",
"assert('...' %in% names(formals(", name,
Expand Down Expand Up @@ -2115,8 +2112,7 @@ int R::functionWrapper(Node *n) {
{
String *finalizer = NewString(iname);
Replace(finalizer, "new_", "", DOH_REPLACE_FIRST);
Printf(sfun->code, "if (.hasSlot(ans, \"ref\")) {\n"
"reg.finalizer(ans@ref, delete_%s); }\n", finalizer);
Printf(sfun->code, "reg.finalizer(ans, delete_%s)\n", finalizer);
}
Printf(sfun->code, "ans\n");
}
Expand Down

0 comments on commit be1c4d2

Please sign in to comment.