Commit graph

31 commits

Author SHA1 Message Date
William S Fulton
67a38589a8 Minor code refactor in Python traits_asptr::asptr 2020-02-13 19:32:13 +00:00
Davy Durham
af97d8f29d fixing memleak of shared_ptr objects in python with creating a [wrapped] vector<shared_ptr<Foo>> from a list of shared_ptr<Bar> where Bar is derived from Foo. 2019-04-10 05:26:53 +00:00
Mike Romberg
b229d92f9b remove bool from as() (it now always throws).
catch std::invalid_argument (what is expected) instread of std::exception.
2017-07-03 12:49:30 -06:00
Mike Romberg
bfaafde020 traits_as<Type,...>::as() ignores throw_error and always throws. 2017-07-03 12:25:04 -06:00
Mike Romberg
6c0885ff67 Use the Type() ctor and avoid:
- clang warning about memset overwrite of vtable
  - memory leak
  - Undefined behavior in Type copy/move operations and dtor.
2017-07-01 17:58:59 -06:00
Mike Romberg
74345c92e4 supress clang warning about vtable ptr overwrite.
Use calloc to zero memory just once.
Document memory leak.
2017-07-01 17:38:48 -06:00
William S Fulton
82969b0755 Fix warning in generated code - traits_asptr.
Visual Studio 2015 debug builds:
error C4703: potentially uninitialized local pointer variable 'p' used
2017-06-13 19:02:59 +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
bd5c340062 Add <string> fragment
Removes <string> include specifically for clang
Cuts down on duplicate #include <string> in general
2014-02-15 23:30:14 +00:00
William S Fulton
e805d5f925 Merge branch 'master' into gsoc2009-matevz
parser.y still to be fixed up

Conflicts:
	Doc/Devel/engineering.html
	Examples/Makefile.in
	Lib/allegrocl/allegrocl.swg
	Lib/csharp/csharp.swg
	Lib/csharp/enums.swg
	Lib/csharp/enumsimple.swg
	Lib/csharp/enumtypesafe.swg
	Lib/java/java.swg
	Lib/python/pydocs.swg
	Lib/r/rtype.swg
	Source/Include/swigwarn.h
	Source/Modules/octave.cxx
	Source/Modules/python.cxx
	Source/Modules/ruby.cxx
	Source/Swig/scanner.c
	Source/Swig/stype.c
	Source/Swig/swig.h
	configure.ac
2013-01-28 07:01:37 +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
Matevz Jekovec
94e94dce02 Added partial support for unordered_ STL types.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@11451 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-07-25 19:14:17 +00:00
William S Fulton
93f0390322 UTL - Fix some incorrect acceptance of types in the STL, eg a double * element passed into a vector<int *> constructor would be accepted, but the ensuing behaviour was undefined. Now the type conversion correctly raises an exception
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10958 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-11-28 23:35:46 +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
Marcelo Matus
553c551fef fix std::vector<const int*>, reported by tagna@gaia.ecs.csus.edu
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9084 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-05-04 05:24:41 +00:00
Marcelo Matus
957a405574 fix problem with containers reported by John Koleszar
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8262 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-01-06 21:37:59 +00:00
Marcelo Matus
7223672e09 securing the call to SWIG_IsOK, which is a macro
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8131 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-30 01:14:24 +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
6bf5187168 add castmode in python and cleaning the castdispatch mechanism
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8051 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-23 09:22:17 +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
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
ba3efb0917 finishing the first stage of the typemap unification scheme, fixing issues with gcc and valgrind
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7692 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-10-20 09:47:56 +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
b2ec22090d fix memory leak reported by Bo Peng
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7026 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-03-06 06:41:43 +00:00
William S Fulton
849bfe284f Fix bool performance warning for Visual C++
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7011 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-02-28 22:24:22 +00:00
Marcelo Matus
192e00615d More fix for warnings, and add some of the ideas of the Bill's 'labels' patch
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6998 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-02-24 23:48:20 +00:00
Marcelo Matus
0d9df55066 add back support for specialize_std_vector/list/etc
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6741 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-11-15 22:59:47 +00:00
Marcelo Matus
09608bc2c5 more docs/split and cleaning
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6421 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-10-18 00:31:24 +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