summaryrefslogtreecommitdiff
path: root/Source/Modules/csharp.cxx
Commit message (Collapse)AuthorAgeFilesLines
* Minor refactor of D, C#, Java director codeWilliam S Fulton2022-11-121-20/+25
| | | | | for overloaded methods. Fixes regression (crash) in director_ignore D testcase since string mangling names change.
* SwigType * handling correctionsWilliam S Fulton2022-11-091-12/+9
| | | | | | | | | Further corrections to pass SwigType * to methods expecting types instead of passing readable type strings. Required reworking code that adds a fake inheritance for smart pointers using the smartptr feature. Swig_smartptr_upcast() added as a support function for this.
* Cleanup SWIG_VERSION definitionWilliam S Fulton2022-10-131-1/+1
| | | | | | | | | | | | | Add Swig_obligatory_macros which must be called by each target language to define SWIG_VERSION correctly in the generated code, as well as the language specific macro SWIGXXX where XXX is the target language name. Drop the #ifdef SWIGXXX that was previously generated - I can't see the point of this and if users are defining this macro somehow, then users will need to change this Closes #1050
* Use https for swig.org linksOlly Betts2022-10-061-1/+1
|
* Order of interfaces generated for %interface macrosWilliam S Fulton2022-07-201-6/+4
| | | | | Ensure the order of interfaces generated in proxy interfaces for the %interface family of macros is the same as that parsed from the bases in C++.
* Merge branch 'imfunc'William S Fulton2022-05-301-0/+6
|\ | | | | | | | | | | | | | | | | | | | | | | * imfunc: Add special variable imfuncname expansion for C# and D Test and document imfuncname special variable expansion Update docs. Also expose in proxyClassFunctionHandler Expose to javaout typemaps. Conflicts: CHANGES.current
| * Add special variable imfuncname expansion for C# and DWilliam S Fulton2022-05-301-0/+6
| | | | | | | | Same functionality as Java
* | Merge branch 'csharp-strenghten-overload-check'William S Fulton2022-05-261-4/+27
|\ \ | | | | | | | | | | | | | | | * csharp-strenghten-overload-check: Fix expanded director_basic test. Improve correctness of SwigDerivedClassHasMethod() by making sure only methods that have `override` are used connected by director.
| * | Fix expanded director_basic test.Rokas Kupstys2018-09-261-4/+27
| | | | | | | | | | | | 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.
| * | Improve correctness of SwigDerivedClassHasMethod() by making sure only ↵Rokas Kupstys2018-09-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | methods that have `override` are used connected by director. 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(); } } ```
* | | Header file tidyupWilliam S Fulton2022-05-071-1/+1
| | | | | | | | | | | | | | | Fix Visual C++ warning in scilab.cxx: warning C4996: 'strtok': This function or variable may be unsafe.
* | | %interface family of macros no longer add variable wrappersWilliam S Fulton2022-03-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The getter/setter methods used for wrapping methods are no longer added to the interface class. Closes #1524 Also add in testcase for enums.
* | | Use GetFlag instead of Getattr for feature:interfaceWilliam S Fulton2022-03-121-5/+5
| | |
* | | Fix segfault in C# layer handling using declarationsWilliam S Fulton2022-03-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Segfault was actually avoided in previous commit ab23cb29. This commit makes handling more robust in the event of using %ignore just on the derived method, not tested as it is not what one should do with directors, and possibly other cases. Go still segfaults with the new testcase director_using_member_scopes.i. Issue #1441.
* | | Add DOH Exit() and SetExitHandler()Olly Betts2022-03-061-9/+9
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Exit() is a wrapper for exit() by default, but SetExitHandler() allows specifying a function to call instead. This means that failures within DOH (e.g. Malloc() failing due to lack of memory) will now perform cleanup such as removing output files. This commit also cleans up exit statuses so SWIG should now reliably exit with status 0 if the run was successful and status 1 if there was an error (or a warning and -Werror was in effect). Previously in some situations SWIG would try to exit with the status set to the number of errors encountered, but that's problematic - for example if there were 256 errors this would result in exit status 0 on most platforms. Also some error statuses have special meanings e.g. those defined by <sysexits.h>. Also SWIG/Javascript tried to exit with status -1 in a few places (which typically results in exit status 255).
* | Remove support for $source and $targetOlly Betts2021-04-301-10/+0
| | | | | | | | | | | | | | | | These were officially deprecated in 2001, and attempts to use them have resulted in a warning (including a pointer to what to update them to) for most if not all of that time. Fixes #1984
* | Add access modifier support for interface featureWilliam S Fulton2020-09-251-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add ability to change the modifiers for the C# and Java interface generated when using the %interface macros. For C# use the 'csinterfacemodifiers' typemap. For Java use the 'javainterfacemodifiers' typemap. For example: %typemap(csinterfacemodifiers) X "internal interface" Closes #1874
* | Add some comments about shared_ptr upcast codeWilliam S Fulton2020-01-241-0/+1
| |
* | Refactor upcasts codeWilliam S Fulton2020-01-231-25/+27
| | | | | | | | | | | | In preparation for possible improvement in usage of SwigType_typedef_resolve_all - a SwigType* should be used, not a readable name in a String*.
* | Merge branch 'shared-ptr-template-upcast'William S Fulton2020-01-171-5/+6
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * shared-ptr-template-upcast: comments Applying shared_ptr template upcast fix to CSharp, adding CSharp test, and cleanup Adding test case demonstrating issue where SWIG does not generate a correctly typed, upcasted shared_ptr for a template instantiation deriving from a base class WIP - Use the non-encoded type string for upcasting a shared_ptr of a derived type to a shared_ptr of the base type comments Applying shared_ptr template upcast fix to CSharp, adding CSharp test, and cleanup Adding test case demonstrating issue where SWIG does not generate a correctly typed, upcasted shared_ptr for a template instantiation deriving from a base class WIP - Use the non-encoded type string for upcasting a shared_ptr of a derived type to a shared_ptr of the base type
| * | Applying shared_ptr template upcast fix to CSharp, adding CSharp test, and ↵etse2019-05-061-5/+6
| | | | | | | | | | | | cleanup
* | | C# 'out' or 'ref' removal improvements in director typemaps.William S Fulton2019-11-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | - Add support to DOH Replace for not replacing inside C comments - Fix removing 'out' or 'ref' when these are present in C comments in cstype typemaps. Closes #1628
* | | 'out' or 'ref' usage in a cstype typemap in directorsWilliam S Fulton2019-11-261-4/+3
| | | | | | | | | | | | | | | | | | | | | 'out' / 'ref' was not always stripped out in parts of the director code generation. Issue #1628
* | | Fix invalid code generated for "%constant enum EnumType ..." and add a test.Rokas Kupstys2019-08-011-1/+1
| | |
* | | Fix class name for nested classesIsaac Pascual Monells2019-07-081-1/+1
|/ /
* | Fix C# CA1063 warning by implementing the recommended Dispose methods.William S Fulton2019-04-081-19/+55
|/ | | | | | | | | | | | | | | 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
* Fix class having method `Connect()` creating a name collision with ↵Rokas Kupstys2018-09-061-2/+2
| | | | | | `SwigDirectorConnect()`. Issue is fixed by prepending director methods with `SwigDirectorMethod` instead of `SwigDirector`.
* Misc. typosluz.paz2018-05-171-2/+2
| | | found via `codespell` and `grep`
* Fix lookup of csconstruct, dconstructor and javaconstruct typemapsWilliam S Fulton2018-05-151-1/+2
| | | | The C++ namespace was previously ignored in the lookup type
* C#, D, Java methodmodifiers on destructorsWilliam S Fulton2018-05-111-3/+13
| | | | | | | | | | | 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*/";
* Consistent spacing in generated exception specificationsWilliam S Fulton2018-05-061-2/+2
|
* Correct C# warning for missing cstype typemapWilliam S Fulton2018-03-091-1/+1
|
* Add director typemaps for pointer const ref typesWilliam S Fulton2017-10-241-9/+11
|
* Generation of director method declarations fixesWilliam S Fulton2017-10-231-4/+4
| | | | | | | - 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.
* Enhancements for directorin typemapsWilliam S Fulton2017-10-161-1/+1
| | | | | | | | | 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.
* Remove undocumented features used in directorsWilliam S Fulton2017-05-211-31/+0
| | | | | The jsdowncast and csdowncast features are not documented and I think these are a relic of something that was never finished.
* Remove unnecessary dynamic_cast in C#/D/Java directorsWilliam S Fulton2017-05-211-7/+3
| | | | Also revert the removal of dynamic_cast in the csdowncast feature.
* Merge branch 'Sghirate-master'William S Fulton2017-05-211-3/+3
|\ | | | | | | | | * Sghirate-master: [C#] static_cast for native directors
| * [C#] static_cast for native directorsFrederick Parotat2015-06-271-3/+3
| | | | | | 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).
* | Add missing return for pure virtual director wrappers for D and C#William S Fulton2017-05-131-1/+5
| |
* | Add raise methods for throwing c++ exceptions in C#, Java, DWilliam S Fulton2017-05-131-1/+1
| | | | | | | | | | | | | | | | | | 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.
* | Revert "csharp : noexcept method can't raise Swig::DirectorPureVirtualException"William S Fulton2017-05-131-7/+1
| | | | | | | | This reverts commit 9dcf10138e5053d50a37a7837dc86e58d6b96dae.
* | csharp : noexcept method can't raise Swig::DirectorPureVirtualExceptionChristophe Duvernois2017-04-281-1/+7
| |
* | #526 : propagate c++11 noexcept to director classesChristophe Duvernois2017-04-271-1/+8
| |
* | Fix missing filename in error messages when writing out C# filesWilliam S Fulton2017-01-271-1/+1
| | | | | | | | Closes #882
* | Merge branch 'wkalinin-override_fix'William S Fulton2017-01-161-43/+1
|\ \ | | | | | | | | | | | | | | | * wkalinin-override_fix: test case added for "override" from imported module #733 - wrong "override" calculation in import mode
| * | #733 - wrong "override" calculation in import modeVladimir Kalinin2016-06-271-43/+1
| | |
* | | Add %proxycode directive for adding code into proxy classes for C#, D and JavaWilliam S Fulton2017-01-131-1/+13
| | |
* | | Add %feature("csdirectordelegatemodifiers") for C#William S Fulton2016-12-241-2/+6
| | | | | | | | | | | | | | | Enable customization of the delegate access modifiers generated in director classes. Fixes https://github.com/swig/swig/issues/748
* | | fix for nested ignored typesVladimir Kalinin2016-05-181-2/+6
|/ /