Add support for SWIG2_CSHARP macro to create SWIG 2 backwards compatability mode.
This commit is contained in:
parent
adb93980f2
commit
3720b48847
3 changed files with 68 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ top_builddir = ../@top_builddir@
|
||||||
|
|
||||||
CPP_TEST_CASES = \
|
CPP_TEST_CASES = \
|
||||||
csharp_attributes \
|
csharp_attributes \
|
||||||
|
csharp_swig2_compatability \
|
||||||
csharp_exceptions \
|
csharp_exceptions \
|
||||||
csharp_features \
|
csharp_features \
|
||||||
csharp_lib_arrays \
|
csharp_lib_arrays \
|
||||||
|
|
@ -36,6 +37,7 @@ CSHARPFLAGSSPECIAL =
|
||||||
# Custom tests - tests with additional commandline options
|
# Custom tests - tests with additional commandline options
|
||||||
intermediary_classname.cpptest: SWIGOPT += -dllimport intermediary_classname
|
intermediary_classname.cpptest: SWIGOPT += -dllimport intermediary_classname
|
||||||
csharp_lib_arrays.cpptest: CSHARPFLAGSSPECIAL = -unsafe
|
csharp_lib_arrays.cpptest: CSHARPFLAGSSPECIAL = -unsafe
|
||||||
|
csharp_swig2_compatability.cpptest: SWIGOPT += -DSWIG2_CSHARP
|
||||||
|
|
||||||
# Rules for the different types of tests
|
# Rules for the different types of tests
|
||||||
%.cpptest:
|
%.cpptest:
|
||||||
|
|
|
||||||
48
Examples/test-suite/csharp_swig2_compatability.i
Normal file
48
Examples/test-suite/csharp_swig2_compatability.i
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
%module csharp_swig2_compatability
|
||||||
|
|
||||||
|
%typemap(cscode) Foo %{
|
||||||
|
|
||||||
|
// Without the using directives generated by the
|
||||||
|
// SWIG 2 compatability mode, this code would fail
|
||||||
|
// to build.
|
||||||
|
public void FooBar(string input)
|
||||||
|
{
|
||||||
|
Console.WriteLine(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
%pragma(csharp) imclasscode=%{
|
||||||
|
|
||||||
|
// Without the using directives generated by the
|
||||||
|
// SWIG 2 compatability mode, this code would fail
|
||||||
|
// to build.
|
||||||
|
public void IntermediateClassMethod(string input)
|
||||||
|
{
|
||||||
|
Console.WriteLine(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
%pragma(csharp) modulecode=%{
|
||||||
|
|
||||||
|
// Without the using directives generated by the
|
||||||
|
// SWIG 2 compatability mode, this code would fail
|
||||||
|
// to build.
|
||||||
|
public void ModuleClassMethod(string input)
|
||||||
|
{
|
||||||
|
Console.WriteLine(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
class Foo {
|
||||||
|
public:
|
||||||
|
Foo() {}
|
||||||
|
|
||||||
|
void Bar() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
@ -11,6 +11,24 @@
|
||||||
* The imtype typemap contains the C# type used in the intermediary class.
|
* The imtype typemap contains the C# type used in the intermediary class.
|
||||||
* The cstype typemap contains the C# type used in the C# proxy classes, type wrapper classes and module class. */
|
* The cstype typemap contains the C# type used in the C# proxy classes, type wrapper classes and module class. */
|
||||||
|
|
||||||
|
/* SWIG 3 no longer inserts using directives into generated C# code. For backwards compatability, the SWIG2_CSHARP
|
||||||
|
macro can be defined to have SWIG 3 generate using directives similar to those generated by SWIG 2. */
|
||||||
|
#ifdef SWIG2_CSHARP
|
||||||
|
|
||||||
|
%typemap(csimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "\nusing global::System;\nusing global::System.Runtime.InteropServices;\n"
|
||||||
|
|
||||||
|
%pragma(csharp) moduleimports=%{
|
||||||
|
using global::System;
|
||||||
|
using global::System.Runtime.InteropServices;
|
||||||
|
%}
|
||||||
|
|
||||||
|
%pragma(csharp) imclassimports=%{
|
||||||
|
using global::System;
|
||||||
|
using global::System.Runtime.InteropServices;
|
||||||
|
%}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Fragments */
|
/* Fragments */
|
||||||
%fragment("SWIG_PackData", "header") {
|
%fragment("SWIG_PackData", "header") {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue