Commit graph

142 commits

Author SHA1 Message Date
AndLLA
b15e058a27 typo in comment 2022-10-24 18:20:10 +01:00
AndLLA
a71bb2bc6e fix naming of RClass when template of a shared_ptr 2022-10-24 18:20:10 +01:00
William S Fulton
6370fab025 R - fix $typemap() for R specific typemaps
Add support for special variable replacement in the $typemap()
special variable macro for R specific typemaps (rtype, rtypecheck,
scoercein, scoereout).
2022-10-24 16:27:54 +01:00
William S Fulton
1d73341aa4 Polymorphism in R wrappers fixed for C++ structs 2022-10-24 08:56:55 +01:00
Olly Betts
5f96d15943 [R] Run destructors of local C++ objects on SWIG_fail
Arrange that destructors of local C++ objects in the wrapper function
get run on SWIG_fail (which calls Rf_error() which calls longjmp()).

We achieve this by putting almost everything in the function in its
own block, and end that right before Rf_error() at which point those
destructors will get called.
2022-10-14 14:44:19 +13:00
William S Fulton
46f7501d94 Cleanup SWIG_VERSION definition
Add Swig_obligatory_macros which must be called by each
target language to define SWIG_VERSION correctly
in the generated code, as well as the language specific
macro SWIGXXX where XXX is the target language name.

Drop the #ifdef SWIGXXX that was previously generated -
I can't see the point of this and if users are defining
this macro somehow, then users will need to change this

Closes #1050
2022-10-13 19:47:43 +01:00
Olly Betts
631b41ae7b Use https for swig.org links 2022-10-06 13:16:39 +13:00
luz paz
c8bec18554 Fix various typos
Found via `codespell -q 3 -L ans,anumber,ba,bae,chello,clos,cmo,coo,dout,fo,funktion,goin,inout,methid,nd,nin,nnumber,object,objekt,od,ois,packag,parm,parms,pres,statics,strack,struc,tempdate,te,thru,uint,upto,writen`
2022-04-11 07:59:36 +12:00
William S Fulton
1db04bf322 Improvements to the -debug command line options
The debug command line options that display parse tree nodes
(-debug-module, -debug-top, -debug-symtabs) now display previously hidden
linked list pointers which are useful for debugging parse trees.

Added new command line option -debug-quiet. This suppresses the display
of most linked list pointers and symbol table pointers in the parse tree nodes.

The keys in the parse tree node are now shown in alphabetical order.
2022-03-25 23:34:52 +00:00
Olly Betts
b2c58115d7 Fix previous commit
Revert changes inadvertently included, and fix `=` to `==`.
2022-03-20 19:44:23 +13:00
Olly Betts
029ddab8b5 [ci] Try to fix failing appveyor python builds 2022-03-20 18:42:50 +13:00
Olly Betts
55377bdc08 Add DOH Exit() and SetExitHandler()
Exit() is a wrapper for exit() by default, but SetExitHandler() allows
specifying a function to call instead.

This means that failures within DOH (e.g. Malloc() failing due to lack
of memory) will now perform cleanup such as removing output files.

This commit also cleans up exit statuses so SWIG should now reliably
exit with status 0 if the run was successful and status 1 if there was
an error (or a warning and -Werror was in effect).

Previously in some situations SWIG would try to exit with the status set
to the number of errors encountered, but that's problematic - for
example if there were 256 errors this would result in exit status 0 on
most platforms.  Also some error statuses have special meanings e.g.
those defined by <sysexits.h>.

Also SWIG/Javascript tried to exit with status -1 in a few places (which
typically results in exit status 255).
2022-03-06 12:33:54 +13:00
Olly Betts
7813793511 [R] Fix CopyToR() generated for struct in namespace
Fixes https://sourceforge.net/p/swig/bugs/1147/
2022-01-31 12:05:09 +13:00
Olly Betts
561a1d843d Fix ODR violations
Detected by compiling with GCC flags `-flto -Wodr`.
2021-09-20 15:04:51 +12:00
Olly Betts
9ddc9dceb7 Remove support for $source and $target
These were officially deprecated in 2001, and attempts to use them have
resulted in a warning (including a pointer to what to update them to)
for most if not all of that time.

Fixes #1984
2021-04-30 10:20:14 +12:00
William S Fulton
8a21922f1a bool performance warning fix 2021-04-26 22:32:52 +01:00
William S Fulton
6542d848dc Fix further missing semicolons in R code.
Fixes errors in R code when using -small as this option causes lines to be joined.
2020-06-02 10:16:18 +01:00
khoran
d58041606e fixed some missing semicolons. Each one caused a compile error in generated code 2020-03-25 11:01:12 -07: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
b0ce22625b Remove redundant code from r.cxx 2020-01-30 19:04:32 +00:00
William S Fulton
88ef6e0931 Fix display of template classnames in generated R code 2020-01-30 08:34:07 +00:00
Richard Beare
aca44d9d3a Removed some remaining commented sections 2019-08-30 21:23:07 +10:00
Richard Beare
b4c02b3267 moved registration routine and use swig_name_get 2019-04-10 11:24:25 +10:00
Richard Beare
5f865bdc7e calling Swig_name_setget 2019-04-10 11:24:25 +10:00
Richard Beare
7b7e5b0012 Used Swig_name_register so that Swig_name_wrapper produces
the correct name without a separate replace call.
2019-04-10 11:24:25 +10:00
Richard Beare
504ef74948 Removed last instance of using Strcmp to check for a set/get
method. Replaced with check for flag.
2019-04-10 11:24:25 +10:00
Richard Beare
dd24a5dffb Alternative version of using memberlist processing. This clarifies the
logic within OutputMemberReferenceMethod by filtering the lists
into classes, rather than doing it internally. Code isn't any shorter.
2019-04-10 11:24:25 +10:00
Richard Beare
9affb871de commenting out unused code 2019-04-10 11:24:25 +10:00
Richard Beare
c42fb730f4 first pass at removing string comparisons for set/get methods 2019-04-10 11:21:35 +10:00
Richard Beare
5fcb1c138b trial changing member list processing 2019-04-10 11:20:41 +10:00
William S Fulton
f5b53683f0 Remove unused code in r.cxx 2019-03-18 17:40:52 +00:00
Richard Beare
6e3518c9b4 ENH:
Replaced the old getRClassName with the new one that uses the swig
functions for detecting, adding and removing pointers andreferences.
2019-03-11 21:17:03 +11: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
80cd2f5cd7 Reformat comments in R module 2019-03-08 21:56:36 +11:00
Richard Beare
b5af07fd95 Code style changes post review 2019-03-08 21:56:36 +11:00
Richard Beare
06de704938 ENH: R Module: Enumerations with values set by calls to C code, allowing
arbitarily complex value expressions.

R-side initialization of the enumeration structure employs
delayedAssign, which allows the initialization code to be
sourced before loading the shared library, which is the
usual behaviour for code in an R package.
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
f181d20dd1 Fix overloading for non-pointers and NULL - R 2018-12-30 13:46:51 +00:00
William S Fulton
027a38c71c Remove -cppcast and -nocppcast command line options
The -cppcast option is still turned on by default. The -nocppcast option
to turn off the use of c++ casts (const_cast, static_cast etc) has been
removed. However, defining SWIG_NO_CPLUSPLUS_CAST will still generate C casts
instead of C++ casts for C++ wrappers.

This a revert of commit fc79264a48:
"Revert "Remove -cppcast and -nocppcast command line options""

The Scilab and Javascript casting problems are now fixed, so -cppcast
is now switched on as default.
2018-11-13 07:36:09 +00:00
William S Fulton
fc79264a48 Revert "Remove -cppcast and -nocppcast command line options"
This reverts commit c06f2b4497.

More work to be done as it breaks Scilab and Javascript tests.
2018-11-06 17:22:05 +00:00
William S Fulton
c06f2b4497 Remove -cppcast and -nocppcast command line options
The -cppcast option is still turned on by default. The -nocppcast option
to turn off the use of c++ casts (const_cast, static_cast etc) has been
removed. However, defining SWIG_NO_CPLUSPLUS_CAST will still generate C casts
instead of C++ casts for C++ wrappers.
2018-11-06 10:26:06 +00: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
Joseph C Wang
be05daa39a change r to allow logical enums. add change to CHANGES.current 2017-10-10 17:50:58 +08:00
Olly Betts
4236b1ec9e [R] Improve handling of enums
Partial fix for https://github.com/swig/swig/issues/1116 but this needs
more work.
2017-10-07 10:36:07 +13:00
Joseph C Wang
f0acfcfb4b Merge branch 'r_fixes_2' of https://github.com/fschlimb/swig 2017-10-01 09:48:37 +08:00
William S Fulton
6077b808f7 Remove code duplication of Swig_overload_rank
Allegrocl and R versions were also out of date
2017-09-11 23:18:55 +01:00
Frank Schlimbach
1df744e0c3 smart-pointer classes deriving from parent smart-pointers
white-space cleanup
2017-08-31 05:28:48 -05:00
Frank Schlimbach
e6a1a7dbd1 constructors now returning smart pointers (if class declared as such) 2017-08-31 05:24:29 -05:00
Frank Schlimbach
d4989aa7fc fixing smart-pointer and NAMESPACE support 2017-08-31 05:24:03 -05:00
Frank Schlimbach
61c24e9cd1 - allowing R package names with containing dosts ('.')
- allowing mulitple get accessors in R
2017-08-31 04:04:58 -05:00