Commit graph

37 commits

Author SHA1 Message Date
Daniel Emminizer
9fc57f47bd Fix error in generated code for Python in MSVC 2019.
Visual Studio 2019 release builds:
error C4703: potentially uninitialized local pointer variable 'p' used
2019-08-29 09:10:41 -04:00
William S Fulton
364fa82499 Replicate Python memory leak fix in std::pair for Octave and Ruby
https://github.com/swig/swig/pull/851
2016-12-18 20:00:40 +00:00
Robert Langlois
631f0c34cc Fix memory leak in std::pair Python binding 2016-12-17 13:27:25 -08: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
Olly Betts
c8a7322a4d Use %{ %} instead of { } after %pythoncode
Simpler and safer change to address PR#357.
2015-03-20 13:45:19 +13:00
Julien Schueller
6fe71da9fa Fixed remaining pep8 errors 2014-06-07 13:09:15 +02:00
Stefan Zager
90fe22acf7 Fix for METH_O and -compactdefaultargs, in two parts:
- Don't mark a method as METH_O if it has compactdefaultargs
  - In SWIG_Python_UnpackTuple, allow for a non-tuple 'args'.

Added compatibility for python versions 2.3 and 2.4.  These are only
partially supported; inheriting from wrapped types looks problematic.
Versions older that 2.3 are unlikely ever to work.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12590 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-02 21:40:00 +00:00
Stefan Zager
3d444101d1 A slew of changes based on William Fulton's code review.
- Fixed naming conventions; SwigPyBuiltin is used a lot
- Removed use of std::vector
- builtin.swg isn't included if -builtin isn't specified
- Changed many feature names to use a "python:" prefix
- Eliminated static vars in std_pair.i
- Eliminated C++-style comments (//)
- Enabled autodoc and docstring with -builtin
- Fixed non-ansi generated C code
- Detect and complain if two incompatible swig modules are loaded
- Removed argcargvtest_runme3.py, and fixed argcargvtest_runme.py
  so that 2to3 handles it better
- Removed anonymous namespaces
- Eliminated builtin_init typemaps; consolidated functionality into
  SWIG_Python_NewPointerObj
- Eliminate printf warnings from %U conversion character by switching
  to %S, which works just as well
- Fixed li_std_set_runme.py for python3, which returns set members in
  a different order from python2





git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12562 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-29 06:57:02 +00:00
Stefan Zager
b77b64944b Static member variables are working.
Fixed some corner cases with protected members of director classes.

Now dying in director_finalizer.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12371 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-01-05 08:35:28 +00:00
Stefan Zager
dd465f9588 Finished std::pair and std::map support.
li_std_pair_extra test fails, because the _runme.py uses the
secret 'this' member variable, which doesn't exist when the
-builtin option is used.  Seems like a flaw in the test.

Test suite now fails on li_std_string_extra, because static
member variables are not fully implemented.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12351 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-12-15 23:04:20 +00:00
Haoyu Bai
8f84447860 Commited SF#2158938: change all SWIG symbols start with Py to a new name.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10961 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-12-03 18:43:44 +00:00
Gonzalo Garramuno
1992714551 Fixed a problem of an incorrect check-in with
fprintf line.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9749 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-05-02 05:22:44 +00:00
Gonzalo Garramuno
806d9040c5 Updated CHANGES.current.
Fixed problems with insert() and unshift() functions in std::vector for ruby.
Updated Ruby documentation.
Improved swig_assert.rb.
Added "second" singleton to std_pair in ruby.
Modified two tests to follow the new STL stuff.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9721 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-04-30 09:45:10 +00:00
Marcelo Matus
a66fa50a8c cosmetic for generated python code
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8850 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-20 07:33:18 +00:00
Marcelo Matus
0e4b388ec9 add implicitconv support and cosmetics for cast rank
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8095 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-27 22:06:26 +00:00
Marcelo Matus
007b7688ce add SWIG_STD_PAIR_ASVAL
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8002 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-18 00:14:23 +00:00
Marcelo Matus
56a0905b18 add faster pair typemap
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7994 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-16 18:38:19 +00:00
Marcelo Matus
11b237dddd put the swig::PyObject_var and swig::PyObject_ptr in the pyclass.swg file, to use them in more places
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7824 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-08 15:58:08 +00:00
Marcelo Matus
02b14340c0 avoid to write the pointer on failure
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7813 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-05 15:45:28 +00:00
Marcelo Matus
3c65cea431 Perl added to the Unified typemap library, cleaner way to use the library, and 'normalized' macro names
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7707 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-10-24 14:59:05 +00:00
Marcelo Matus
aadff06f45 more typemaps unification and fixes for valgrind
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7684 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-10-19 10:52:50 +00:00
Marcelo Matus
7e5e4fd1f9 massive typemap unification
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7676 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-10-18 13:24:15 +00:00
Marcelo Matus
d2139b5b59 more fixes for python 1.5.2
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7302 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-06-17 19:23:16 +00:00
Marcelo Matus
dc4409a1f1 isolate language independent STD/STL/C++ code + more documentation + cleaning
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6382 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-10-10 06:42:15 +00:00
Marcelo Matus
349e6bc6ee using <> when including lib files, fix char{ANY], add char FIXSIZE[ANY], fix pyfragments.swg, fixing *.swg and *.i names
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6250 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-09-17 06:17:35 +00:00
Marcelo Matus
49a09a63fb more fixes for pointer
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5824 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-04-03 08:36:08 +00:00
Marcelo Matus
ab44291de8 we better disable the comparison method generation by default.
reasons:

- before they were not generated, so, nobody will miss them,
  and still they can be activated back using SWIG_STD_EXTEND_COMPARISON,

- the performance penalty is quite visible, and the solution is not
  general, ie, for user types, still they need to be generated by hand.


Marcelo


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5822 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-04-02 02:34:19 +00:00
Marcelo Matus
b85f90a6ed fix pair for ptrs, and add SWIG_STD_NOEXTEND_COMPARISON to reduce swig times
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5820 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-04-01 18:51:30 +00:00
Marcelo Matus
efed557610 added more especial methods for python
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5817 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-04-01 05:12:23 +00:00
Marcelo Matus
0c8f4b34bf added support for const, like std::pair<const int, int>
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5815 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-04-01 04:07:27 +00:00
Marcelo Matus
29a30e2dcc - better support for classes with no default constructor, equal or
comparison methods.

  you will be able to do

    struct Foo {
     Foo(int) {}
    };

    %std_nodefconst_type(Foo); // Says Foo has no def. constructor

    %template(vector_Foo) std::vector<Foo>;

  and the conflicting vector/list/deque methods will not be generated.


more cosmetic, and a note about the relation between std::map and
std::pair.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5810 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-03-31 11:27:53 +00:00
Marcelo Matus
f896efa6dd fixes for strings and cosmetics
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5792 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-03-28 13:34:16 +00:00
Marcelo Matus
7afe6bc139 normalizing the inout typemaps and other cosmetic fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5782 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-03-21 23:26:18 +00:00
Marcelo Matus
2537ee1c34 fix old std_pair version
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5760 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-03-17 10:45:19 +00:00
Marcelo Matus
1d5529bcfc better STL support, see CHANGES.current
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5755 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-03-17 09:41:19 +00:00
Dave Beazley
057c2d5dd1 Fixed compilation problems, missing exception.i library.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5417 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-11-26 19:30:38 +00:00
Luigi Ballabio
dcb94e7d4a std::pair added (but not very much tested)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4959 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-07-10 12:42:42 +00:00