Commit graph

2,675 commits

Author SHA1 Message Date
William S Fulton
01fa85bda7 Add %feature("csdirectordelegatemodifiers") for C#
Enable customization of the delegate access modifiers generated in director classes.
Fixes https://github.com/swig/swig/issues/748
2016-12-24 17:14:36 +00:00
Joseph Wang
14a5f9e11d Merge pull request #839 from richardbeare/RsetMethods
Corrected generation of "set" methods for R.
2016-12-21 21:52:27 +08:00
Olly Betts
7a3cfdb013 Fix GCC 7 warnings
From -Wimplicit-fallthrough which is now enabled by -W.
2016-12-21 13:05:20 +13:00
Olly Betts
f474577d5b Fix "set but not used" warning 2016-12-13 13:58:51 +13:00
Olly Betts
2b4c1cdd5e Fix "set but not used" warning 2016-12-13 11:40:45 +13:00
Olly Betts
2aa2219f28 Fix reference example under PHP 7.1
PHP 7.1 no longer supports calling methods with fewer parameters
than declared, so we need to generate __construct() with default
values for all but the first parameter.
2016-12-06 11:01:55 +13:00
William S Fulton
2d8ce2a5d7 Slight tweak to empty lines generated in python proxy file 2016-12-03 15:56:09 +00:00
William S Fulton
bed5e5c105 Fix previous commit adding moduleimports option 2016-12-03 15:28:18 +00:00
William S Fulton
2a42031b08 Custom Python module importing code
Add optional moduleimport attribute to %module so that the
default module import code can be overridden. See the
"Searching for the wrapper module" documentation in Python.html.
Example:

  %module(moduleimport="import _foo") foo

$module also expands to the low-level C/C++ module name, so
the following is the same as above

  %module(moduleimport="import $module") foo

Issue https://github.com/swig/swig/issues/769
2016-12-01 18:59:33 +00:00
Olly Betts
da1dd2ffd2 [PHP] Pick a default dtor which can't collide 2016-12-01 15:09:53 +13:00
Olly Betts
76a98b0b1a [PHP] Emit at most one copy of the default dtor
Can reduce the wrapper source size significantly, though at least
with recent GCC the stripped compiled size seems unchanged.
2016-12-01 14:21:29 +13:00
Olly Betts
659116a1b2 Fix memory leaks introduced by previous commit 2016-12-01 14:04:10 +13:00
Olly Betts
4993991d28 [PHP] Only emit one copy of each distinct arginfo
Previously we emitted a separate one for every wrapped function,
but typically many functions have the same number of parameters
and combinations of parameters passed by reference or not.

This change significantly reduces both the size of the generated
wrapper, and of the compiled PHP extension module (e.g. by ~6% for
the stripped extension module for Xapian's PHP7 bindings).
2016-12-01 13:05:41 +13:00
Olly Betts
75a00cd15e [PHP7] Make default C++ extension .cxx
This is SWIG's default for every language except PHP, and now is a
good time to make this change so that once we drop PHP5 support, we'll
have the same default everywhere.  It's easy to override the default
with -cppext cxx to get the PHP5 behaviour.
2016-11-30 13:27:13 +13:00
Olly Betts
1169874f59 [PHP] Add support for PHP7.
PHP5's C extension API has changed substantially so you need to use
-php7 to specify you want PHP7 compatible wrappers.
Fixes https://github.com/swig/swig/issues/571
2016-11-30 13:05:59 +13:00
Richard Beare
52bec200f7 Corrected generation of "set" methods for R.
The function "OutputClassMemberTable" tags methods generated
for a class so that R wrapper code supporting syntax like:

WrappedClass$VarName <- value

The comments in the function indicate that it is looking for
method names ending in "_set", but in fact it was searching for
methods ending in just "set", This was resulting in class methods
ending in set (names like GetOffset, SetOffset etc) being placed
in the wrong accessor functions and thus not being available in
the normal way.

There is probably a more appropriate way to tag the _set functions
when they are being created, which is a future step. This
patch makes the behaviour conform to the original intention.
2016-11-23 20:28:08 +11:00
Richard Beare
c90239bce6 Corrected generation of "set" methods for R.
The function "OutputClassMemberTable" tags methods generated
for a class so that R wrapper code supporting syntax like:

WrappedClass$VarName <- value

The comments in the function indicate that it is looking for
method names ending in "_set", but in fact it was searching for
methods ending in just "set", This was resulting in class methods
ending in set (names like GetOffset, SetOffset etc) being placed
in the wrong accessor functions and thus not being available in
the normal way.

There is probably a more appropriate way to tag the _set functions
when they are being created, which is a future step. This
patch makes the behaviour conform to the original intention.
2016-11-23 17:13:27 +11:00
Joseph C Wang
bff182d556 fix #697 - miscounting comma in member lists
fix method for counting comma in member list
2016-11-12 00:23:41 +08:00
William S Fulton
c74397bfd0 Merge branch 'liorgold-alias-template'
* liorgold-alias-template:
  Warning header cosmetics
  Fix decl attribute in C++11 alias templates
  Add C++11 alias templates
2016-11-02 09:10:59 +00:00
William S Fulton
f89b8836dd Merge branch 'jiulongw-master'
* jiulongw-master:
  Fix go wrapper compilation error
  Fix missing semicolon in golang wrapper
  Fix extra quote escape in golang
  Fix #define error when value contains char in compound expression
  Add more test case for char const expression in enum
  Revert "Add enum test cases with const char in compound expression"
  Add runtime tests for char in compound expression patch
  Add enum test cases with const char in compound expression
  Fix enum error when value contains char in compound expression
2016-10-23 10:32:48 +01:00
William S Fulton
87bede9a99 Return to Python builtin tp_new initialization in init function. 2016-10-15 22:43:42 +01:00
William S Fulton
d29fc38d1c Fix Python builtin binaryfunc slots when using -O
Code did not compile - recent regression due to 848628
2016-10-14 07:30:44 +01:00
Jiulong Wang
9b85318d77 Fix go wrapper compilation error 2016-10-11 10:49:43 -07:00
Jiulong Wang
b9de6f1bf2 Fix missing semicolon in golang wrapper 2016-10-10 22:42:36 -07:00
Jiulong Wang
b4b4c0a25e Fix extra quote escape in golang 2016-10-10 21:34:19 -07:00
William S Fulton
08688d7d9d Add support for "ret" typemap where missing and improve documentation on it. 2016-09-29 08:07:26 +01:00
ahmed-usman
2d871655e3 Update xml.cxx to return typenames (#777)
Typenames were being returned wrong, so add a condition to handle templateparms correctly.
2016-09-27 15:15:47 +13:00
Li Shengqiu
bac85d5b1a [Go] Fix argument names in inherited functions #795 (#797)
* [Go] Fix argument names in inherited functions #795

This commit fixes a wrong argument name replacement in the inherited functions as well as a memory leak.

* Add testcase for #795

* Move variable_replacement testcase into common

* Move variable_replacement testcase into common
2016-09-27 15:08:47 +13:00
William S Fulton
848628ae91 More flexible python builtin slots
The closure names used for builtin slots are mangled with their functype so
 that overloaded C++ method names can be used for multiple slots.
For example:
%feature("python:slot", "mp_subscript", functype="binaryfunc") SimpleArray::__getitem__;
%feature("python:slot", "sq_item", functype="ssizeargfunc") SimpleArray::__getitem__(Py_ssize_t n);
will generate closures:
  SWIGPY_SSIZEARGFUNC_CLOSURE(_wrap_SimpleArray___getitem__) /* defines _wrap_SimpleArray___getitem___ssizeargfunc_closure */
  SWIGPY_BINARYFUNC_CLOSURE(_wrap_SimpleArray___getitem__) /* defines _wrap_SimpleArray___getitem___binaryfunc_closure */
2016-09-25 14:15:38 +01:00
Olly Betts
1adfe2f537 [PHP] Fix code generated for feature("director:except")
Previously the return value of call_user_function() was ignored and we
checked an uninitialised value instead.  Fixes #627.  Based on patch
from Sergey Seroshtan.
2016-09-25 14:42:04 +13:00
William S Fulton
0769e9b727 Fix iterators for containers of NULL pointers (or Python None) when using -builtin.
Previously iteration would stop at the first element that had a NULL pointer value.
2016-09-17 17:53:48 +01:00
Olly Betts
26bbc96d58 Arrange to return after calling zend_throw_exception()
Fixes github issue#240.
2016-09-16 17:54:02 +12:00
Olly Betts
849f157efa [Python] Fix import in frozen app for Python 2.6 (#784)
Fix import handling for Python 2.6 to work in a frozen application.
Fixes #145, reported by Thomas Kluyver.
2016-09-12 08:11:47 +12:00
William S Fulton
5b7c08c214 Make Python builtin types hashable by default
Default hash is the underlying C/C++ pointer.
This matches up with testing for equivalence (Py_EQ in SwigPyObject_richcompare)
which compares the pointers.
2016-08-23 19:06:36 +01:00
William S Fulton
1cef6b7440 Merge branch 'builtin-tweaks'
* builtin-tweaks:
  Python builtin minor tweaks
  Cosmetic code formatting corrections
  Further additional Python builtin slots as features for user customization
  Add additional Python builtin slots as features for user customization
  Correct notes on customising Python builtin comparison operators
  Set tp_new statically rather than during initialisation
  Customize slots tp_basicsize tp_methods tp_getset
  Additional Python builtin slot overrides and slightly better formatted Python generated code
  Add Python builtin tp_dealloc override test
  Python getSlot() refactor
  Add Python builtin closure method in comment
  Update Python docs on builtin slots
  Python builtin hashfunc closure fix
2016-08-22 19:37:10 +01:00
William S Fulton
ae32fb4f9a Python builtin minor tweaks
Remove internal Python struct names from generated code
Cosmetic code formatting
2016-08-22 19:28:52 +01:00
William S Fulton
ad452edf3e Cosmetic code formatting corrections 2016-08-22 08:48:04 +01:00
William S Fulton
bf4174d121 Further additional Python builtin slots as features for user customization
Added:
- tp_flags
- was_sq_slice
- was_sq_ass_slice
2016-08-22 08:39:24 +01:00
William S Fulton
e5a09c4141 Add additional Python builtin slots as features for user customization
Added:
- tp_is_gc
- tp_bases
- tp_mro
- tp_cache
- tp_subclasses
- tp_weaklist
- tp_del
- tp_allocs
- tp_frees
- tp_maxalloc
- tp_prev
- tp_next
2016-08-22 07:51:42 +01:00
William S Fulton
3b6f4af15c Set tp_new statically rather than during initialisation 2016-08-21 14:29:27 +01:00
William S Fulton
3744c45082 Customize slots tp_basicsize tp_methods tp_getset 2016-08-19 23:46:50 +01:00
William S Fulton
239785ce7d Additional Python builtin slot overrides and slightly better formatted Python generated code
The following slots can now be overidden by users if they know what they
are doing:
- tp_dictoffset
- tp_init
- tp_new
- tp_as_number
- tp_as_sequence
- tp_as_mapping
- tp_as_buffer
2016-08-19 23:16:32 +01:00
William S Fulton
67ece1d2bf Python getSlot() refactor
getSlot() now takes a default that can override "0" default - simpler
code and for future commits to override some currently non-overridable
slots.
2016-08-19 08:43:40 +01:00
William S Fulton
a3fc743f32 Add Python builtin closure method in comment
For less mystifying code and easier code searching
2016-08-18 08:41:07 +01:00
Olly Betts
a950d1309b [xml] Fix how the output filename is built
Avoid problems when it contains the embedded strings ".c", ".cpp" or ".cxx".
Fixes #540 reported by djack42.
2016-08-05 11:52:35 +12:00
Simon Marchetto
d0a45be1eb scilab: fix issue #746 2016-07-29 16:56:30 +02:00
Simon Marchetto
95a5def328 scilab: fix issue #755 2016-07-29 11:52:26 +02:00
Lior Goldberg
d0fc5b7b5b Add C++11 alias templates 2016-07-06 00:31:04 +03:00
William S Fulton
b24e970a28 Merge branch 'wkalinin-nested-ignore-fix'
* wkalinin-nested-ignore-fix:
  renamed test module, in accordance with other tests
  function body fixed
  added foo() definition to satisfy some test linking fails
  func() renamed to foo() for 'go'
  fixed test-suite/nested_ignore.i
  test for #662
  fix for nested ignored types

Closes #662
2016-06-26 00:33:19 +01:00
William S Fulton
2da7e066b3 Merge branch 'avalluri-leaks'
* avalluri-leaks:
  whitespace fix
  memory leak improvements - delete at end of scope
  CCache: Fix typo in null check
  CCache: Fix memory/file descriptor leaks
  scilab.cxx: Fix memory leaks
  Fix leaked file descriptor
  Lua: Fix possible memory leaks
  go.cxx: Fix use of a freed variable

Closes #710
Closes #712
Closes #713
Closes #715
Closes #716
2016-06-26 00:16:30 +01:00