Commit graph

118 commits

Author SHA1 Message Date
William S Fulton
00190c484f Javascript, Octave, R - Improve exceptions for %catches
and exception specifications for native types.

Now the raised exception contains the string value as the exception
message instead of just the C/C++ type of the exception.

R exceptions were completely swallowed beforehand
2022-09-19 09:09:29 +01:00
William S Fulton
dad7c93ca0 Provide SWIGTYPE MOVE typemaps in swigmove.i
For implementing full move semantics when passing parameters by value.
Based on SWIGTYPE && and std::unique_ptr typemaps which implement move
semantics.

Added for all languages, but untested for: Go, Ocaml, R, Scilab (and
unlikely to be fully functional for same reasons as for std::unique_ptr
support).

Issue #999
2022-09-16 08:36:25 +01:00
William S Fulton
c10a84c775 Cosmetic stray semi-colon removal after %typemap using quotes 2022-08-31 19:40:13 +01:00
William S Fulton
319442a8c4 More move semantics improvements
More removal of casts in the out typemaps when copying objects to enable
C++ compilers to possibly make use of move semantics.
2022-07-04 11:19:50 +01:00
William S Fulton
71cd6a38fe Performance optimisation for directors for classes passed by value
The directorin typemaps in the director methods now use std::move on the
input parameter when copying the object from the stack to the heap prior
to the callback into the target language, thereby taking advantage of
move semantics if available.
2022-07-04 11:19:29 +01:00
Seth R Johnson
de78b80de9 Renames performed by %namewarn with rename= are printed in warning message
This is necessary for regex-like renames (where you can't use the #define trick
as is done in many of the %keywordwarn directives). It's now unnecessary to print
the "renaming to '`x`'" code explicitly by the kw.swg files.
2022-02-06 13:51:37 -05:00
khoran
d58041606e fixed some missing semicolons. Each one caused a compile error in generated code 2020-03-25 11:01:12 -07:00
William S Fulton
a0d4218543 Minor refactor of R error handling code 2020-01-31 08:58:09 +00:00
Arnaud Barré
3fa5c8c652 Fix R memory leak on exception
There is a possible memory leak in case the SWIG_exception_fail macro
is called. The problem is related to its definition that call the
function Rf_warning. This function (as well as Rf_error) involves
a longjmp over C++ destructors on the stack. Thus, all the objects
allocated on the heap are not freed.

Closes #914
2020-01-30 20:43:39 +00:00
William S Fulton
39e3c3b9d7 Fix R return by C++11 const ref enum classes 2019-03-18 17:49:24 +00:00
Richard Beare
43af20ab3b FIX: references to enums now functioning
There is some consolidation work to be done. The
core of the change is getRClassName2, which will
probably eventually replace getRClassName.

getRClassName seems to be in a funny state, with
a middle argument that is commented out and never
used.

My next step is to verify whether the new version
can replace it.
2019-03-08 21:56:36 +11:00
Richard Beare
e9b39797cc Setting enum values with calls to the C code. 2019-03-08 21:56:36 +11:00
William S Fulton
68e86614ff Create a consistent stl.i library file
Same file now for all languages except R which is still missing std_map.i.
Recent Java changes adding in std_set.i removed.
2019-02-12 18:46:05 +00:00
William S Fulton
f181d20dd1 Fix overloading for non-pointers and NULL - R 2018-12-30 13:46:51 +00:00
William S Fulton
3ce3ce0683 Add std_shared_ptr.i for Scilab and R as boost_shared_ptr.i is already available 2018-03-09 06:58:08 +00:00
Joseph C Wang
4e8c515d36 add new tests and coercion files for null fix #1124 2017-11-26 03:43:39 +08:00
Joseph C Wang
9c32a1e722 fix null changes to work with C90 compilers 2017-11-26 03:42:32 +08:00
Joseph C Wang
0b97170f1d fix #1124 - return R_NilValue for null pointer objects
This fixes #1124 and returns R_NilValue for null pointer objects
2017-11-24 23:43:02 +08:00
William S Fulton
3f8b8fe734 Enhancements for directorin typemaps
The directorin typemaps will now generate a temporary variable
(specified after the type), such as:
%typemap(directorin) MyType (MyType *temp) { ... use temp ... }

The shared_ptr director typemaps have been fixed for use in functions
that take more than one parameter.
2017-10-16 19:28:27 +01:00
William S Fulton
6470fe8c36 Director shared_ptr typemaps for scripting languages
Modify the Python and Ruby director shared_ptr typemaps to be language neutral.
Port the director modifications to other scripting languages that
have shared_ptr support - Octave, R and Scilab. Scilab shared_ptr
support is not fully working and needs work though.
2017-10-13 07:34:38 +01:00
William S Fulton
fcd7ecd9e2 R memory handling standardisation
Replace R_SWIG_EXTERNAL and R_SWIG_OWNER with the standard equivalent
macros. I can't see where these were actually used, but in case they are,
equivalent backwards compatibility can be obtained using:

  #define R_SWIG_EXTERNAL 0
  #define R_SWIG_OWNER SWIG_POINTER_OWN

SWIG_MakePtr does not seem to be used within the R SWIG code base so I
havn't added the above as backwards compatibility macros.
There seems to be no memory management in R. I've made this change
to fit in with the rest of SWIG though in preparation for an upcoming
commit to use the same shared_ptr macros as is used elsewhere.
2017-10-13 07:34:38 +01:00
William S Fulton
114fab31a1 Scilab, R and Octave shared_ptr typemaps null fix
Merge changes from Python/Ruby equivalent files to obtain a fix
for NULL handling of T*const& typemaps.
2017-10-11 18:08:32 +01:00
William S Fulton
a674edebf5 Octave and R shared_ptr typemaps update
Synchronize typemaps with other identical typemaps in Scilab/Ruby.
Adds some missing $disown support.
2017-10-11 08:33:02 +01:00
William S Fulton
ed4b84f4d3 Fix overloading of shared_ptr method overloading
Add 'equivalent' attribute to typecheck typemap.
Closes #1098.
2017-09-23 15:19:34 +01:00
Olly Betts
90f9117e10 Fix various comment and documentation typos 2017-08-13 18:04:33 +12:00
Mike Romberg
a2e3cc0709 as() no longer uses memset and always throws. 2017-07-20 13:07:59 -06:00
William S Fulton
82969b0755 Fix warning in generated code - traits_asptr.
Visual Studio 2015 debug builds:
error C4703: potentially uninitialized local pointer variable 'p' used
2017-06-13 19:02:59 +01:00
William S Fulton
ab1e9f5bd9 Consistent whitespace amongst all the shared_ptr and intrusive_ptr typemaps
[skip ci]
2017-04-20 19:21:47 +01:00
William S Fulton
94e7482e48 Remove illegal operator overload names in R
https://github.com/swig/swig/pull/853
2016-12-22 19:59:58 +00:00
William S Fulton
f9158e525f Revert "Merge pull request #853 from ivannp/underscores"
This reverts commit a964098754, reversing
changes made to bda3a11f9e.

SWIG should only provide default operator names that provide special
standard or conventional meaning in the target language.
2016-12-22 19:47:54 +00:00
Ivan Popivanov
5ec5266284 Renamed all operators beginning with underscore. 2016-12-17 16:26:10 -08:00
Joseph C Wang
377f756f49 Fix #555 - Add stdio.h
This corrects for compilers that need stdio.h
2016-11-12 00:28:39 +08:00
Richard Beare
c334efd36b Writing R extensions says:
Most R header files can be included within C++ programs but they should
not be included within an extern "C" block (as they include system headers).

This patch moves the Rdefines.h and Rversion.h outside the extern block.
2016-08-05 15:46:14 +10:00
William S Fulton
91aba9f719 UTL STL container descriptor checks
The vector of pointers (just fixed) were not working correctly because the
descriptors returned from swig::type_info() were sometimes returning
zero. Zero should only be used for void * as the subsequent call to
SWIG_ConvertPtr will blindly cast the pointer without checking
descriptor.

std::vector<void *> does not work and will require further changes:
specializing traits_info<void *> to return 0 and traits_asptr<void *>.
I tried this and traits_asptr<void> also needs to be added in which
seems odd and requires further investigation...

Lib/python/pystdcommon.swg:
  template <> struct traits_info<void *> {
    static swig_type_info *type_info() {
      static swig_type_info *info = 0;
    }
  };

Lib/std/std_common.i:
  template <>
  struct traits_asptr<void *> {
    static int asptr(PyObject *obj, void ***val) {
      void **p;
      swig_type_info *descriptor = 0;
      int res = SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0);
      if (SWIG_IsOK(res)) {
	if (val) *val = p;
      }
      return res;
    }
  };

  // this is needed, but am not sure this is expected
  template <>
  struct traits_asptr<void> {
    static int asptr(PyObject *obj, void **val) {
      void **p;
      swig_type_info *descriptor = 0;
      int res = SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0);
      if (SWIG_IsOK(res)) {
	if (val) *val = p;
      }
      return res;
    }
  };
2016-07-28 22:51:29 +01:00
William S Fulton
a293ee6a15 Remove unused code in R wrappers 2016-06-05 21:40:03 +01:00
Richard Beare
85f0930f73 cleaned up constants 2016-04-21 18:11:56 +10:00
Richard Beare
3f75b2917d R delete an old trace statement 2016-04-19 14:41:26 +10:00
Richard Beare
1403610518 Missing definitions for vector references 2016-04-19 14:26:37 +10:00
Richard Beare
f7b794a4f3 run test and copying typemaps to std::string 2016-04-05 10:06:42 +10:00
Richard Beare
720c4d3dfc added R string vector to C++ std::vector of strings 2016-04-05 09:39:47 +10:00
joequant
7e3165848b Merge pull request #633 from sbpcs59/master
Suppress unmessage at package load
2016-03-26 13:20:38 +08:00
Richard Beare
0821ec0b45 Support for more numeric types in std::vector for R.
This change allows R to automatically convert std::vectors of
signed and unsigned 8, 16, 32 and 64 bit integer types.

rtype, rtypecheck, scoercein and scoerceout typemaps are copied
across integer types.
2016-03-15 12:03:25 +11:00
sbpcs59
2ea53f2dd1 Suppress message at package load - Creating a generic function for ‘print’ from package ‘base’ in package <some package> 2016-03-10 20:29:15 -08:00
Alec Cooper
4e2fc7d115 Don't use long long if it isn't available
Adds preprocessor checks to avoid defining functions that use long long if it isn't available
Effects the following languages: javascript, octave, perl, python, r, ruby, tcl
2016-01-06 16:52:37 -05:00
William S Fulton
6b4e57245d Fix STL wrappers to not generate <: digraphs.
For example std::vector<::X::Y> was sometimes generated, now
corrected to std::vector< ::X::Y >.
2015-12-12 14:05:46 +00:00
William S Fulton
fcb383b46b shared_ptr typemap error message fix for global variables
$argnum was not being expanded in the generated code
Correct to use the error message from the standard typemaps
2015-09-25 22:57:59 +01:00
Joseph C Wang
fe39ef5fae suppress warning for ExternalReference print 2015-07-04 13:22:55 +08:00
William S Fulton
5fb344e0e6 R - fix duplicate generation of 'self' parameter.
Fixes director_keywords test case.
2015-06-12 20:25:00 +01:00
William S Fulton
1891b82e00 R - Call to SWIG_createNewRef in copyToC was incorrectly named.
Closes #430
2015-06-12 20:23:56 +01:00
William S Fulton
ede1e9544c Fix R Lib files and testcase failing due to new preprocessor checks
Fixes unknown preprocessor directive error introduced in #217
commit 255c929c56
These were probably intended as script comments using # when C/C++
comments using // or /* */ should have been used.
2014-10-29 23:11:09 +00:00