Commit graph

89 commits

Author SHA1 Message Date
William S Fulton
bdda0a0829 Python - fix compilation error when using -extranative and -builtin.
Closes #816
2016-11-02 22:00:54 +00:00
William S Fulton
5abb3e8008 More efficient Python slicing
Call reserve for container types that support it to avoid repeated
memory reallocations for new slices or slices that grow in size.
2016-09-01 23:49:30 +01:00
William S Fulton
5ebf1cfa5d Slight simplification of Python slicing 2016-09-01 23:49:30 +01: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
c5322a9ecb Python use Py_ssize_t instead of int for better portability 2015-12-05 09:00:04 +00:00
William S Fulton
327b59a574 size_type correction for SwigPySequence_Cont 2015-12-05 09:00:04 +00:00
William S Fulton
55bbf68512 Add std::array container wrappers for Python
These work much like any of the other STL containers except Python slicing
is somewhat limited because the array is a fixed size. Only slices of
the full size are supported.
2015-11-17 07:27:48 +00: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
William S Fulton
a89a892843 Fixes when using python -builtin and STL container wrappers.
Deletion of single elements previously failed.
Test case li_std_containers_int now works.
2014-10-07 20:58:40 +01:00
Julien Schueller
f4fffbf668 Fixed another E701 2014-06-06 15:13:23 +02:00
William S Fulton
0d9a8721f4 Move some header file includes into fragments for UTL languages 2014-02-21 19:02:14 +00:00
William S Fulton
38b2b95c30 Fix some invalid iterator usage in Python when deleting/inserting slices from/into containers 2013-03-26 21:38:45 +00:00
William S Fulton
7eda619741 Fix invalid iterators used with -ve ranges - Python
Fixes li_std_containers_int testcase.
Valgrind reports no more problems for this testcase.
2013-03-26 21:38:44 +00:00
William S Fulton
52fe61820a More for Mac OSX STL fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13020 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-04-28 14:27:55 +00:00
William S Fulton
c13131986e Warning fix in python STL wrappers
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13019 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-04-28 11:39:13 +00:00
William S Fulton
e39322cd01 Fix STL wrapper compilation errors on Mac OSX 64bit
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13018 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-04-28 11:18:10 +00:00
William S Fulton
a6219a855e signed unsigned fix
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12997 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-04-16 19:55:33 +00:00
William S Fulton
347f2782d2 Fix missing stddef.h when %import of STL containers. Was causing compile failures witht g++-4.6.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12939 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-03-20 20:07:56 +00:00
William S Fulton
7c58a044d2 Add support for negative steps in Python slices on the STL containers
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12903 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-01-24 23:41:40 +00:00
William S Fulton
1b47ddf8f0 Add support for slicing steps to Python STL wrappers (positive step only atm - these work the same as other Python sequences such as list)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12898 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-01-20 21:14:03 +00:00
Stefan Zager
bdc9b61dc2 Fix for bug 3447426: memory leak in vector.__getitem__
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12855 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-12-01 20:59:19 +00:00
Stefan Zager
17af467132 Fix for bug #3057804: migrate PyCObject to PyCapsule.
Other misc. fixes for python3.2, mostly dealing with changed
interfaces to python functions.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12620 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-09 22:07:22 +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
62fef1bf99 python3 support; passes all regressions.
Adding argcargvtest_runme3.py, because 2to3 can't handle it.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12425 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-03 07:21:37 +00:00
Stefan Zager
d4b8048e9a Stopped using template class SwigPyBuiltin, because it caused problems
when two typedef-equivalent types are wrapped as separate classes.

Now failing on refcount.cpptest.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12392 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-01-12 00:43:01 +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
Stefan Zager
8a7ad756d0 Added sequence and mapping support for builtin types.
Fixed object ownership in %pyswigbinoperator.

Test suite now fails on li_std_vector_extra.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12346 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-12-14 21:11:02 +00:00
Stefan Zager
ee3a6623da First cut. Works for wrapping OpenAccess, but there's plenty
left to do.

Currently, the test suite hurls at director_stl.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12332 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-12-07 21:50:00 +00:00
Olly Betts
28e277f8c5 Fix typo "the the" -> "the"
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12285 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-10-19 06:31:31 +00:00
William S Fulton
4308dd03cf SWIG license change - The Examples and Lib move to a very permissive license in the LICENSE file, removing the BSD license restrictions as agreed by committers since it was inadvertently introduced. Remove some examples where the impact of the license change is not clear.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11874 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-02-27 23:26:02 +00:00
Olly Betts
6d8ea4f7fa Fix comment typos
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11193 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-04-29 12:00:38 +00:00
William S Fulton
e8e8527642 vc++ warning fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11152 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-03-16 17:42:30 +00:00
Haoyu Bai
caa6f2b9fa Fixes to support Python 3.0.1 and higher.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11143 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-03-02 17:56:29 +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
Haoyu Bai
3d8ddfc442 Merged the Python 3.0 support branch. The merging progress is not so smooth, so hope this commit won't make anything broken.
This is the (incomplemete) log produced by svnmerge.py:

Merged revisions 10405-10409,10420-10422,10426,10438,10445,10451,10454-10465,10467,10473-10475,10485,10488-10489,10493-10495,10497,10509-10510,10513-10514,10517,10520,10525,10528-10529,10533-10535,10554-10557,10570,10573,10593,10614,10666-10669,10673,10678,10687,10690,10704-10706,10731,10744,10750-10752,10755,10759,10770,10775-10776,10813,10819 via svnmerge from 
https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10834 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-09-11 17:18:07 +00:00
Haoyu Bai
1dfb0d7fad Fixed SF #1971977: typo in pycontainer.swg (related to -extranative option)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10504 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-05-28 17:27:48 +00:00
William S Fulton
da8791792b STL fixes when using %import rather than %include and the Solaris Workshop compiler
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10424 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-05-07 21:33:19 +00:00
Olly Betts
85f02c4ba4 [Python] Fix generated code for IBM's C++ compiler on AIX (patch
from Goeran Uddeborg in SF#1928048).


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10387 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-04-24 12:26:29 +00:00
Olly Betts
b2375fd6e6 [Python] Apply GCC 4.3 warnings patch from Philipp Thomas (SF#1925122).
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10321 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-03-26 08:52:57 +00:00
William S Fulton
76229dbab8 Restore containers accepting NULL pointers when used in overloaded methods - problem reported by Josh Cherry
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10217 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-01-22 23:33:59 +00:00
William S Fulton
cb9d191276 Remove conversion from one STL container to another
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10214 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-01-21 21:59:02 +00:00
William S Fulton
c8e1d09cff Warning fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10041 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-10-25 22:36:23 +00:00
William S Fulton
c74b246a95 Common template for head of each file detailing licence, distribution and authors information
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8975 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-03-07 00:35:17 +00:00
Marcelo Matus
9bcf5507df update iterator typemap
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8897 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-25 09:23:49 +00:00
Marcelo Matus
6e67122508 update iterator typemap
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8896 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-25 09:22:42 +00:00
Marcelo Matus
c1683603c1 add '= 0' to avoid warnings in icc
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8893 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-25 08:07:36 +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
b9c30d7738 more fixes for old Solaris compiler
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8839 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-18 08:17:23 +00:00
Marcelo Matus
555ffa5fb4 fix warning reported by Nitro in VC7
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8837 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-18 01:27:30 +00:00
Marcelo Matus
3b89804a9b fix bug #1420757
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8683 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-02 23:13:54 +00:00