Previously just the Dispose() method was generated.
Now the Dispose() and Dispose(bool disposing) methods are generated.
Changes are required if custom "csfinalize", "csdestruct" or "csdestruct_derived"
typemaps are being used. Details in #421 on Github. SWIG will error out if one of
the "csfinalize, "csdestruct" or "csdestruct_derived" typemaps are found. Example
error message:
foo.h:60: Error: A deprecated csfinalize typemap was found for Foo, please remove
it and replace all csdestruct, csdestruct_derived and csfinalize typemaps by the
csdispose, csdispose_derived, csdisposing and csdisposing_derived typemaps.
Closes#421
Since we are mixing `new` and `override` a class instance may have multiple methods with the same name. in case of director_basic test one method comes from `MyClassMiddle` (one that participates in dynamic dispatch) and one comes from `MyClassEnd` (one with `new` keyword). Therefore all methods have to be checked.
C# does not treat `virtual` methods of child classes as overriding (ass opposed to c++). In order to override a method it must have `override` specified.
Previous version of this method treated `virtual void foo()` or `void foo()` in a subclass as methods that override virtual method of parent class. This resulted in `SwigDirectorConnect()` creating delegates and connecting them to a native class. Presence of such methods caused needless roundtrip through managed layer while in the end correct native function was called.
This is the old code flow:
```cpp
void SwigDirector_MyClass::nonOverride() {
if (!swig_callbacknonOverride) { // 0. swig_callbacknonOverride is set
MyClass::nonOverride();
return;
} else {
swig_callbacknonOverride(); // 1. this is called because wrapper mistakenly assumes overriding
}
}
SWIGEXPORT void SWIGSTDCALL CSharp_director_basicNamespace_MyClass_nonOverrideSwigExplicitMyClass(void * jarg1) {
MyClass *arg1 = (MyClass *) 0 ;
arg1 = (MyClass *)jarg1;
(arg1)->MyClass::nonOverride(); // 5. Correct method called in the end
}
```
```cs
private void SwigDirectornonOverride() {
nonOverride(); // 2.
}
public virtual void nonOverride() {
if (SwigDerivedClassHasMethod("nonOverride", swigMethodTypes4)) // 3. This returns `true`
director_basicPINVOKE.MyClass_nonOverrideSwigExplicitMyClass(swigCPtr); // 4. Native method of director class called explicitly
else
director_basicPINVOKE.MyClass_nonOverride(swigCPtr);
}
```
This is the new code flow:
```cpp
void SwigDirector_MyClass::nonOverride() {
if (!swig_callbacknonOverride) { // 0. swig_callbacknonOverride is not set
MyClass::nonOverride(); // 1. Calls correct method immediately
return;
} else {
swig_callbacknonOverride();
}
}
```
Add support so that the %csmethodmodifiers, %dmethodmodifiers,
%javamethodmodifiers can modify the method modifiers for the destructor wrappers
in the proxy class: dispose, Dispose, delete. With this feature, it is now possible
to make a C# proxy class sealed, eg when wrapping a class X, the virtual method modifiers
can be removed using:
%typemap(csclassmodifiers) X "public sealed class"
%csmethodmodifiers X::~X "public /*virtual*/";
- Fixes generation of director method declarations containing C++11 ref-qualifiers.
- Fixes generation of director method declarations returning more complex types such
as const ref pointers.
- Rewrite Swig_method_call to use more up to date code in the core.
The directorin typemaps will now generate a temporary variable
(specified after the type), such as:
%typemap(directorin) MyType (MyType *temp) { ... use temp ... }
The shared_ptr director typemaps have been fixed for use in functions
that take more than one parameter.
The director c++ exceptions are thrown in a helper method instead of in
the director overloaded method. This circumvents compiler warnings about
throwing exceptions when the method has an exception specification or
noexcept. If the exception is thrown, abort will still be called!
In Java, the "director:noexcept" typemap can be used to do something
else. This typemap should be ported to the other languages too.
* char-escaping:
Add missing string_constant.i testcase
changes file update for char wrappers
C# char wrappers fixes for enum values, static const member char values and %csconst
D testing added for %dmanifestconst and char constants
Fix wrapping D constants using %dmanifestconst
Php fix for enum value of '\0'
Fix static const char member variables wrappers with %javaconst(1).
Expand char testing in enums and %constant
Java char changes file update
Java enum and static member variable escaping fix for chars
Add tests for enum values and static const member variables chars containing escape sequences
Minor documentation tweak
Conflicts:
CHANGES.current
This is a simple expansion expanding to the name of the interface and is
not qualified like $javainterfacename and $csinterfacename.
Expansion within typemaps is much like $javainterfacename otherwise.
Note that expansion within the pure java code typemap,
'javainterfacecode' and similarly pure C# code typemap,
'csinterfacecode' works like $javaclassname/$csclassname and
$&interfacename should not be used, just $interfacename.
Support expansion of name attribute in: %feature("interface", name="%s")
%s expands to the proxy class name and all the usual %rename functions
can be used (regex, strip, camelcase etc) to derive the interface name
from the proxy class name.
Rename $interfacename family of special variables to $javainterfacename for Java
Rename $interfacename family of special variables to $csinterfacename for C#
This is to free up $interfacename for simple interface name expansion in forthcoming commit
Slightly simplify choosing single base class when handling
multiple inheritance and make consistent across more languages.
Modula3 multiple inheritance warnings now warn for all bases
* interfaces:
Remove unnecessary interfaces for concrete classes
cosmetic code formatting changes
Correct interface name attributes that are internal
interface macro changes to support templates
Test non-virtual method in Derived classes
interface tests for a most derived class inheriting the interfaces further up the chain
Rename GetCPtr/getCPtr to SWIGInterfaceUpcast
interface feature support for const ref pointers (used by the STL)
Interface feature support for arrays
More interface feature testing for return values
interface feature support for passing by value
interface feature support for references
Multiple inheritance parameters as pointers testing
Simplify multiple_inheritance_abstract Java runtime test
Warning fixes
Rename test functions in multiple_inheritance_abstract testcase
Formatting fixes in generated code for interface feature
Cosmetic spacing changes in test case
interface feature typemap corrections to handle NULL pointers
interface test added
javadirectorin fix
interface implementation visibility
interface inheritance (2)
interface inheritance (1)
feature:interface ported to Java
propagate non-abstract "interface" base methods (3)
propagate non-abstract "interface" base methods (2)
propagate non-abstract "interface" base methods (1)
namespace support added GetCPtr now returns HandleRef "feature:interface:name" is now mandatory attribute
interfaces (1)
interfaces (1)
Conflicts:
Source/Modules/csharp.cxx
Source/Modules/java.cxx
When people use the -namespace option, they often intend for the input to swig to wrap a particular namespace in a single module. This option should also have an effect on how C++ wrapper function names are mangled, and not just the C# proxy code.
Replaced dynamic_cast with static_cast. In the case of directors it seems dynamic_cast is not necessary, yet demands compilation of the generated native wrapper code with RTTI flag (which can impact an application's performance).
Added "-csout <path>" parameter. If supplied all generated C# code will
be written to the given file. Makes it easier to integrate SWIG into
automated script based build processes.
Test case is slightly modified from the test case in issue #250
Use of constant objects does not seem to work in Python - the type is
SwigPyObject instead of constant_directive.Type1.
* vadz/py-args:
Allow using enum elements as default values for Python functions.
Don't always use "*args" for all Python wrapper functions.
No real changes, just make PYTHON::check_kwargs() const.
Refactor: move makeParameterName() to common Language base class.
Remove long line wrapping from Python parameter list generation code.
This method was duplicated more or less identically for 4 languages and will
be needed for another one soon, so put it in the base class from which it can
be simply reused instead.
No changes in the program behaviour whatsoever.
C#/Java - Enums which have been ignored via %ignore and are subsequently
used are handled slightly differently. Type wrapper classes are now generated
which are effectively a wrapper of an empty enum. Previously in Java uncompilable
code was generated and in C# an int was used.
For D, this fixes a segfault in SWIG.
Java, C#, D, Go now produce code that compiles, although the definition of the
enum is needed in order to use the enum properly from the target language.
fixed language symbol table nested classes name separator, test added
fixed %feature "flatnested" working with %extend
fixed Swig_offset_string for empty string
added simple template to save/restore values in current scope (readability reasons)
Closes#89
Squash merge branch 'master' of https://github.com/wkalinin/swig into wkalinin-nested
By Vladimir Kalinin
* 'master' of https://github.com/wkalinin/swig:
CPlusPlusOut mode for Octave
nested class illustration
fixed "Abstract" flag for nested classes added an example enabled anonymous nested structs runtime test
porting
warnings disabled
porting fixes
java runtime tests ported
nested class closing bracket offset fixed
removed double nested template (not supported by %template parsing)
template_nested test extended
parent field made public
property access fixed
replaced tabs with spaces
warning W-reorder
deprecated warnings removed, derived_nested runtime test added
optimized string indenting
Nested classes indenting
nested classes docs
fixed the order in which flattened inner classes are added after the outer
Private nested classes were getting into the type table.
Java getProxyName() fix for nested classes fixes the case when nested classes is forward declared
Fix for a case when a nested class inherits from the same base as the outer. (Base class constructor declaration is found first in this case)
merge fix
nested C struct first immediate declaration incorrectly renamed sample fixed
tests updated to reflect nested classes support
Java nested classes support (1)
flattening should remove the link to the outer class
access mode correctly set/restored for nested classes
nested templates should be skipped while flattening (template nodes themselves, not expanded versions) also non-public nested classes should be ignored
If nested classes are not supported, default behaviour is flattening, not ignoring flag "nested" is preserved, so, the nested classes can be ignored by user
nested workaround test updated
template instantiated within a class is marked as nested for ignoring purposes
%ignore not applied to the nested classed, because "nested" flag is set too late
typedef name takes precedence over the real name (reason?)
unnamed structs should be processed for all the languages
nested C struct instances are wrapped as "immutable"
tree building
typedef declaration for unnamed C structures fixed
nested classes "flattening"
fixed %ignoring nested classes
renamed "nested" attribute to "nested:outer" added "nested" flag, to be used with $ignore (it is not removed while flattening) added nestedClassesSupported() function to the Language interface
renamed "nested" attribute to "nested:outer" added "nested" flag, to be used with $ignore (it is not removed while flattening) added nestedClassesSupported() function to the Language interface
tree iteration fix
dirclassname variable names unified memory issue fixed
merge error
ignore unnamed structs for C++
unnamed nested C structs naming & unnesting
class added to classes hash under typedef name
private nested classes skipped
test updated due to nested templates support
anonymous structs with inheritance fixed nested_class test to allow anonymous structs w/o declarator
tests updated: nested workaround removed from namespace_class.i propagated nested template declaration to the C++ file
injected members scope
nested tempplates fixes, nested structures in "C" mode parsing added utility function "appendSibling" (like "appendChild")
nested unnamed structures parsing fixes, access mode restored on nested class end, tdname is properly patched with outer class name prefix
memory management fixes
nested templates (1)
Nested unnamed structs
Nested class support (1)
Nested class support (1)
Add runtime test to the C# test suite's director smartptr test that demonstrates crash in generated code when directors are used with smart pointer types.
Closes#34