Commit graph

62 commits

Author SHA1 Message Date
Olly Betts
a89a4d9e84 [Python] Fix warning when compiling generated code with MSVC.
Fixes https://sourceforge.net/p/swig/patches/351/ reported by Mateusz
Szymański).
2015-05-19 15:48:25 +12:00
William S Fulton
1db561cf08 Improve Python builtin and %constant structs
Tweak to previous commit from issue #250 for C compatibility.
Set self to zero too.
2014-12-18 07:01:08 +00:00
Paweł Tomulik
0ad384bb28 fixed python global object constants
Fix for Python and -builtin
Fix from Github issue #250
2014-12-18 07:01:08 +00:00
William S Fulton
7a96fba836 Correct exception thrown attempting to access a non-existent C/C++ global variable on the 'cvar' object.
The exception thrown used to be a NameError. However, as this access is
via a primary, an AttributeError is more correct and so the exception
thrown now is an AttributeError. Reference:
http://docs.python.org/2/reference/expressions.html#attribute-references

SF Patch #346.
2014-03-02 01:31:36 +00:00
Jens Krüger
da44064d6c 'swig_varlink_getattr' throws a wrong exception
If the attribute of a python object could not found a AttributeException
should be thrown instead of a NameException.
2014-03-02 00:24:23 +00:00
William S Fulton
0e54a51c10 Add missing #include <stddef.h> for offsetof when using -builtin.
Fixes SF #1345
2013-10-17 19:56:18 +01:00
William S Fulton
3b8bc08be7 Suppress -Werror=unused-but-set-variable gcc warning in Python wrappers
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13571 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-08 22:24:46 +00:00
William S Fulton
63f21af8d0 PyVarObject_HEAD_INIT to conform to C standard - pointers cannot be used in static initializers
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12660 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-05-12 20:20:36 +00:00
Stefan Zager
a52612f845 Fixed PyGetSetDescr for python3.2.
Fixed memory management in special_variable_macros test.

Don't define asdict() for multimap.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12659 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-05-08 06:54:21 +00:00
Stefan Zager
7a0726c8b6 Fix ISO C90 errors.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12619 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-09 04:59:16 +00:00
William S Fulton
070893434b Cosmetic formatting in generated code
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12610 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-05 20:59:24 +00:00
William S Fulton
b2b9e2eb91 Python builtin - warning suppression/fixes for 'gcc -Wall' and cosmetic changes in generated code.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12609 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-05 20:39:44 +00:00
William S Fulton
5f6389ab31 Cosmetic Python changes and replace DOH types
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12608 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-04 20:13:14 +00:00
Stefan Zager
96ec495858 Fix compiler warnings about uninitialized members.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12607 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-04 07:11:02 +00:00
Stefan Zager
cd7fc2047b Factored some #ifdef noise out of the initialization function by adding
SwigPyBuiltin_SetMetaType.

For %import statements, move the runtime import out of SWIG_init and into the
.py file.  The reason for this is that the import must be executed within the
python execution frame of the module, which is true in the .py file, but *not*
true in the initialization function.  Had to re-order the .py file slightly
to put the 'import' statements at the top; that's necessary to make sure base
types from an imported module are initialized first.  If -builtin isn't used,
then the .py code is not re-ordered.

Added an explanation and workaround for the limitation that wrapped types are
not raise-able.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12585 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-01 19:35:30 +00:00
William S Fulton
960b503a72 Python warning fixes for gcc -Wall -Wextra
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12584 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-01 06:46:14 +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
William S Fulton
908c37cef8 Coding style fixes for Python builtin changes added on the szager-builtin branch
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12515 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-03 19:34:18 +00:00
Stefan Zager
288c37f5bf Regressions pass! With a few tweaks for unsupported features, primarily:
- Throwing wrapped types as exceptions is unsupported.
- Reverse comparison operators (e.g., __radd__) aren't supported.

Rationalized destructors.

Finished std::map implementation.  Required fixes to typecheck for
SWIGTYPE* const&.

Need a little special handling of the swig_type_info for SwigPyObject
when multiple modules are loaded.

Fall back to SwigPyObject_richcompare if there's no operator overload.

"memberget" and "memberset" attrs are applied strangely; work around
them.

Added 'this' attribute.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12415 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-01-30 03:17:28 +00:00
Stefan Zager
8ac54d1d5e Director issues should be mostly clean now.
Refactored some type initialization out of SWIG_init.

Use __all__ attribute of module to define public interface.
This is necessary to make available symbols starting with '_'.

Now dying on li_boost_shared_ptr.  Looks like it's gonna be ugly.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12373 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-01-06 00:09:25 +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
3a86f2068f Added support for multiple inheritance. Not as hard as I feared.
Apply operator features to both the operator name, and the renamed
"__*__" method.  That's the only way to hit all corners.

Added support for %pythonnondynamic.  I believe this implementation
is more correct than the existing implementation, but I'm still
waiting for an adjudication on the behavior of the python_nondynamic
test.

Current list of unsupported features that require minor tweaks
to the test suite:

- 'this' member variable is obsolete.

- No support for reversible operator overloads (e.g., __radd__).  You
can still support this:

a = MyString("foo")
b = "bar"
c = a + b

... but you can't do this:

a = "foo"
b = MyString("bar")
c = a + b

With the tweaks, the test suite now fails on python_nondynamic.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12353 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-12-20 23:35:18 +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
70e8072612 [Python] Fix potential memory leak in initialisation code for the generated
module.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11717 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-11-02 06:31:45 +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
Haoyu Bai
a863d31e81 Fix the memory leak related to Python 3 unicode and char * conversion.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11160 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-03-19 15:26:57 +00:00
Haoyu Bai
c74c467a09 Fix SF#2637352, move declaration of SWIG_module before the call of SWIG_Python_FixMethods, since some C compiler don't allow declaration in middle of function body.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11140 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-02-28 14:02:02 +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
William S Fulton
ff1bd7a80d Vladimir Menshakov patch for compiling wrappers with python-2.5 alpha.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9158 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-06-13 19:24:54 +00:00
Marcelo Matus
02d5dbe049 fix prototype warnings, as reported by Max Browsher
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9034 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-03-26 07:09:22 +00:00
Marcelo Matus
97ab6a3e8f remove unused var
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8685 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-02 23:48:56 +00:00
Marcelo Matus
51f7ea18f6 add the 'str' method to cvar
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8572 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-01-27 16:28:43 +00:00
Marcelo Matus
8b7fb37a59 more threads cleaning
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7944 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-07 22:25:05 +00:00
Marcelo Matus
07c115102a more portability tricks
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7934 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-06 20:14:55 +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
Marcelo Matus
922d58ac19 don't use Py_None directly nor &PyType_Type
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7925 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-04 08:50:00 +00:00
Marcelo Matus
a5d45ae01f try to fix borland error
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7923 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-04 05:07:57 +00:00
Marcelo Matus
3955965739 more memory leaks fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7921 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-04 01:16:57 +00:00
Marcelo Matus
63fdb3d2a0 fix for older python versions
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7919 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-02 19:36:13 +00:00
Marcelo Matus
6d57482864 add SWIGUNUSEDPARM
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7917 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-02 08:42:41 +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
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
327bbc06ac more fixes for python 1.5 +gcc2.96
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7301 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-06-17 19:12:21 +00:00
William S Fulton
815355b964 Uniform handling of SWIGEXPORT across SWIG.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7234 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-05-27 22:40:58 +00:00
Marcelo Matus
7ee5f85b5a fix prototype warning
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7082 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-03-19 19:35:42 +00:00
Marcelo Matus
ca7159f7e7 add better director+exception support
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7038 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-03-07 20:47:55 +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
e38ce2b2c3 more warning fixes, cosmetics, and uniformity changes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7006 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-02-26 08:47:17 +00:00
Marcelo Matus
4c873ffb8d finishing change from 'static' to 'SWIGINTERN'
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7001 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-02-25 07:40:41 +00:00