Commit graph

22 commits

Author SHA1 Message Date
William S Fulton
b56d7c0539 Python builtin C++11 STL fixes
Compilation fixes for std::multimap, std::unordered_map and
std::unordered_multimap.
2017-06-19 20:32:32 +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
80f8d1d922 Fix for missing C++ code in std::multimap wrappers.
%template for a std::multimap generated uncompilable code unless a
%template for a std::map of the same template types was also coded up.

This patch is needed in conjunction with previous commit - 5f1fff1849

Closes #64
Closes #65
2013-08-06 07:02:49 +01: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
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
William S Fulton
521059242c gcc-4.2 warning fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10186 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-12-09 22:27:38 +00:00
William S Fulton
79eea19382 string handling mods to keep gcc-4.2 happy
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10088 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-11-04 20:35:59 +00:00
Marcelo Matus
b319720cf1 fix bug #1480074
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9085 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-05-04 05:48:55 +00:00
Marcelo Matus
0926a5da0f add fragment warning and fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8647 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-01-30 22:33:06 +00:00
Marcelo Matus
679d147937 update as std::map
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8294 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-01-08 07:48:47 +00:00
Marcelo Matus
0fd2fe23cf add thread support based in proposal #398495 by Joseph Winston
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7929 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-06 06:39:24 +00:00
William S Fulton
4fea1d827a Various fixes for Visual C++ 7.1 and Sun Studio 10
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7255 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-06-03 20:52:16 +00:00
Marcelo Matus
a2f5af9ddd fix #1188207 and uniform the error/null/none handling
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7225 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-05-26 20:43:33 +00:00
Marcelo Matus
5b74ab97a7 more fixes for security and warnings
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7009 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-02-26 20:25:10 +00:00
Marcelo Matus
9537f69323 fix empty map bug
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6980 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-02-22 19:52:43 +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
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
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
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