Commit graph

51 commits

Author SHA1 Message Date
Olly Betts
631b41ae7b Use https for swig.org links 2022-10-06 13:16:39 +13:00
William S Fulton
77b08daca7 Add DohSortedKeys function
Returns a list of sorted keys in a DOH Hash.
2022-09-30 22:48:04 +01:00
Olly Betts
6b4d5fe3f0 Remove remaining code to support macos9
This OS has been unsupported for over 20 years.  We stopped providing
macswig builds more than 20 years ago too:

https://sourceforge.net/projects/swig/files/macswig/

The required SIOUX library doesn't seem to be available anywhere
now either.

Closes #2323
2022-07-19 11:22:37 +12:00
Olly Betts
892557e799 Improve #include guard macros
Avoid using reserved identifiers such as `_DOHINT_H` (fixes #1989),
fix cases where the name doesn't match the filename, and make the naming
more consistent and less likely to collide with include guards in other
headers.
2022-07-19 09:35:46 +12:00
Olly Betts
9efcc785ae Re-enable symbol poisoning in a CI job
It seems too brittle to enable by default as we'd have to avoid
including any system headers after doh.h, which is hard to enforce,
but just having it enabled for one CI job should avoid uses of the
poisoned symbols from being accidentally introduced.

See #2223
2022-03-15 11:14:23 +13:00
William S Fulton
77853770bd Disable use of gcc poison pragmas
Needs a rethink to avoid use of poisoned macros in system headers.
I see this on Ubuntu 16.04:

gcc -DHAVE_CONFIG_H   -I../Source/Include -I../Source/CParse
-I../Source/Include -I../Source/DOH -I../Source/CParse
-I../Source/Doxygen -I../Source/Preprocessor -I../Source/Swig
-I../Source/Modules   -g -O2 -Wall -W -pedantic -MT DOH/base.o -MD -MP
-MF $depbase.Tpo -c -o DOH/base.o DOH/base.c &&\
mv -f $depbase.Tpo $depbase.Po
In file included from /usr/include/string.h:630:0,
                 from DOH/dohint.h:21,
                 from DOH/base.c:15:
/usr/include/x86_64-linux-gnu/bits/string2.h:1282:19: error: attempt to
use poisoned "calloc"
        ? (char *) calloc ((size_t) 1, (size_t) 1)        \
                   ^
/usr/include/x86_64-linux-gnu/bits/string2.h:1284:32: error: attempt to
use poisoned "malloc"
      char *__retval = (char *) malloc (__len);       \
                                ^
/usr/include/x86_64-linux-gnu/bits/string2.h:1302:19: error: attempt to
use poisoned "calloc"
        ? (char *) calloc ((size_t) 1, (size_t) 1)        \
                   ^
/usr/include/x86_64-linux-gnu/bits/string2.h:1308:26: error: attempt to
use poisoned "malloc"
      __retval = (char *) malloc (__len);        \
                          ^
2022-03-12 23:04:24 +00:00
Olly Betts
747a51f095 Try to prevent direct use of exit(), malloc(), etc
Use `#pragma GCC poison` (supported since GCC 3, maybe earlier) when
compiling with GCC to help prevent direct uses being introduced for
functions which DOH provides a wrapper for.
2022-03-06 15:36:42 +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
e38847f7e1 Fail cleanly on allocation failures
Previously code in the SWIG tool didn't handle allocation failures
well.  Most places didn't check for NULL return from
malloc()/realloc()/calloc() at all, typically resulting in undefined
behaviour, and some places used assert() to check for a NULL return
(which is a misuse of assert() and such checks disappear if built with
NDEBUG defined leaving us back with undefined behaviour).

All C allocations are now done via wrapper functions (Malloc(),
Realloc() and Calloc()) which emit and error and exit with non-zero
status on failure, so a non-NULL return can be relied upon.

Fixes #1901.
2022-03-04 11:47:49 +13:00
Olly Betts
4c7febfb80 Make DOH Char macro more robust
For example, `Char(foo)[0]` now works to get the first character
of DOH String `foo`.

Previously this gave a confusing error because it expanded to
`(char *) Data(foo)[0]` and the `[0]` binds more tightly
than the `(char *)`.
2021-12-13 09:33:26 +13:00
William S Fulton
18b2dcd222 C# 'out' or 'ref' removal improvements in director typemaps.
- Add support to DOH Replace for not replacing inside C comments
- Fix removing 'out' or 'ref' when these are present in C comments
  in cstype typemaps.

Closes #1628
2019-11-26 19:39:28 +00:00
William S Fulton
b36ae64185 Remove all generated files on error.
Previously generated files were not removed,
potentially breaking Makefiles using file dependencies, especially when
-Werror (warnings as errors) was used.
2019-07-31 00:08:49 +01:00
William S Fulton
98f29f8ad9 Remove deprecated DohClose in DOH 2019-07-31 00:08:49 +01:00
Vadim Zeitlin
a1fe8a6501 Fix gcc strict aliasing warnings with function pointers too.
The commit 40bf877 fixed warnings about converting between function and object
pointers but introduced warnings about breaking strict-aliasing rules which
appear with -Wstrict-aliasing which is implicitly enabled by -O2.

Avoid these warnings as well by using an intermediate union for conversion
instead of casts trickery.
2014-02-01 15:00:15 +01:00
William S Fulton
dac89e16d4 const char * correctness fixes (in C code)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13939 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-26 20:30:37 +00:00
William S Fulton
5a1e82a2f4 Remove DohClose (Close) and replace with calls to DohDelete (Delete) to fix some minor memory leaks in most uses of NewFile.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13885 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-14 22:16:07 +00:00
William S Fulton
6d922f2ddd Fix #3433541 %typemap(in, numinputs=0) with 10+ arguments.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12849 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-11-28 19:35:44 +00:00
William S Fulton
9a0f7ed06c Some more constness added to DOH and code comment consistency changes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12356 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-12-23 20:30:41 +00:00
William S Fulton
d1e6643161 Expand the family of debug print functions for displaying DOH types. Provide gdb support for calling these. Document improved debugging experience.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12221 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-09-15 20:17:11 +00:00
Vadim Zeitlin
ac5ddb0315 Make argument of DohWrite() const.
Writing a buffer to a DOH object doesn't modify so it should be const.

This allows the code using const pointers to pass them to DohWrite() without
neither the casts nor gcc warnings.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12167 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-07-22 16:59:29 +00:00
William S Fulton
cb64f65bae SWIG license change - Source moves to GPLv3
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11876 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-02-27 23:53:33 +00:00
Haoyu Bai
47b4825168 Merged revisions 11085-11086,11088-11089 via svnmerge from
https://swig.svn.sourceforge.net/svnroot/swig/branches/swig-2.0

........
  r11085 | bhy | 2009-01-25 00:21:55 +0800 (Sun, 25 Jan 2009) | 2 lines
  
  Fix const-correctness.
........
  r11086 | bhy | 2009-01-25 02:08:50 +0800 (Sun, 25 Jan 2009) | 2 lines
  
  Correct some function definition in header files, which implementation changed in previous commit caused mismatch.
........
  r11088 | bhy | 2009-01-25 02:38:32 +0800 (Sun, 25 Jan 2009) | 1 line
  
  minor fix and now SWIG is alive again
........
  r11089 | bhy | 2009-01-25 06:07:07 +0800 (Sun, 25 Jan 2009) | 1 line
  
  Correct some bug introduced in previous commits. Now SWIG is pretty good with C++ compiler.
........


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11097 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-01-30 10:27:37 +00:00
Haoyu Bai
6d2aef67d9 Replaced all [const] String_or_char * to const_String_or_char_ptr, by the following command:
sed -i "s/\(const \)\?String_or_char \*/const_String_or_char_ptr /g" CParse/* Include/* Modules/* Preprocessor/* Swig/*

This is a preparation for moving to new DOH, since for strong typed objects we need the const_String_or_char_ptr class to implicit convert to and from String * or const char *.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11080 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-01-24 13:15:51 +00:00
William S Fulton
61001d958f add parameter list (or void) to all C functions
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10926 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-11-11 22:17:40 +00:00
William S Fulton
6fb0f48935 customised ccache support: read the CCACHE_OUTFILES env variable and if exists, the names of all generated files are written to the filename specified in the env variable
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10898 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-11-03 12:51:45 +00:00
Dave Beazley
c12550e4ad API cleanup. Documentation
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9631 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-01-03 05:23:20 +00:00
Dave Beazley
264b7dff90 API cleanup. Documentation.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9629 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-12-30 18:27:47 +00:00
Dave Beazley
fc10a97b23 Changed Header keyword to Id
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9607 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-12-05 22:11:40 +00:00
William S Fulton
aa04c4c057 beautify/format source code with gnu indent
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9505 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-11-01 23:54:54 +00:00
Olly Betts
4739599460 Fix String_delslice() to update s->sp and s->lines correctly.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9345 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-09-24 17:09:31 +00:00
William S Fulton
6b6147f03b Deal with Microsofts attempt at deprecating C standard runtime functions for proprietary ones in Visual Studio 2005
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8847 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-19 22:16:56 +00:00
Marcelo Matus
51548d5d39 use const in HashGetAttr
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8168 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-01-02 04:19:43 +00:00
Marcelo Matus
f714a2615d remove many memory leaks and cleanup
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7898 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-29 01:47:10 +00:00
Marcelo Matus
628dc6b32b add NewStringEmpty, use more StringEuqual and less Strcmp
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7897 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-28 17:32:56 +00:00
Marcelo Matus
ba9b1ec591 add direct methods StringLen and HashGetAttr
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7890 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-28 02:36:26 +00:00
Marcelo Matus
72469f2d26 add direct HashCheckAttr
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7889 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-27 09:58:26 +00:00
Marcelo Matus
bc6339d844 add the Equal method to the DOH objects and other speed ups
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7883 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-27 02:38:44 +00:00
Marcelo Matus
dd523372b9 improve cpp performance
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7862 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-23 03:10:00 +00:00
Marcelo Matus
deba68d4da add GetFlagAttr/SetFlagAttr to deal with flag attributes as callbak and ref/unref
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7603 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-10-07 13:16:21 +00:00
William S Fulton
0c71a1f3ba New functions GetFlag and SetFlag
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7561 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-09-30 21:34:01 +00:00
William S Fulton
bed81d66d3 Better error message displayed when file cannot be opened
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7416 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-09-08 22:31:21 +00:00
William S Fulton
ae10ce8207 const warning fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6945 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-02-15 21:00:52 +00:00
John Lenz
c3338b1a16 - Improve the runtime type sytesm
- Update all languages to new type system
- Add DohSortList function
- Fix mzscheme Examples/Makefile


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6930 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-02-01 00:08:24 +00:00
Dave Beazley
a8f60cccf6 [ 829317 ] Adds DohSplitLines function
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5214 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-10-31 17:36:37 +00:00
Dave Beazley
8ae4c60d39 Major refactoring of DOH List/Hash iterators. See CHANGES
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5101 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-09-11 20:26:57 +00:00
Dave Beazley
f133111e79 Warning cleanup. Etc.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5003 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-08-15 19:37:27 +00:00
Dave Beazley
1aefd191bf Memory diagnostics. Huge memory leak cleanup related to templates
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4639 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-03-27 23:17:27 +00:00
Dave Beazley
cdd2efd7f6 Missing declaration
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4636 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-03-27 17:28:35 +00:00
Dave Beazley
b02f748627 String enhancements. Slice deletion
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4629 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-03-26 03:28:00 +00:00
Dave Beazley
c320b09704 String replacement enhancements to help with preprocessor fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4298 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-02-11 21:31:41 +00:00