Add the 'notderived' attribute to the javabase and csbase typemaps

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11196 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-04-29 17:58:32 +00:00
commit 7e8d19cec0
4 changed files with 25 additions and 3 deletions

View file

@ -1,6 +1,12 @@
Version 1.3.40 (in progress)
============================
2009-04-29: wsfulton
[Java, C#] Add the 'notderived' attribute to the javabase and csbase typemaps.
When this attribute is set, the typemap will not apply to classes that are derived
from a C++ base class, eg
%typemap(csbase, notderived="1") SWIGTYPE "CommonBase"
2009-04-29: olly
[Python] Don't attempt to acquire the GIL in situations where we
know that it will already be locked. This avoids some dead-locks
@ -9,6 +15,7 @@ Version 1.3.40 (in progress)
run a little faster (in tests with Xapian on x86-64 Ubuntu 9.04,
the stripped wrapper library was 11% smaller and ran 2.7% faster).
>>>>>>> .r11195
2009-04-21: wsfulton
[C#] Fix #2753469 - bool &OUTPUT and bool *OUTPUT typemaps initialisation.

View file

@ -5302,6 +5302,9 @@ base (extends) for Java class: empty default
Note that this typemap accepts a <tt>replace</tt> attribute as an optional flag. When set to "1", it will replace/override any C++ base classes
that might have been parsed. If this flag is not specified and there are C++ base classes, then a multiple inheritance warning
is issued and the code in the typemap is ignored.
The typemap also accepts a <tt>notderived</tt> attribute as an optional flag. When set to "1", it will not apply to classes that
are derived from a C++ base.
When used with the SWIGTYPE type, it is useful for giving a common base for all proxy classes, that is, providing a base class that sits in between all proxy classes and the Java base class <tt>Object</tt> for example: <tt>%typemap(javabase, notderived="1") SWIGTYPE "CommonBase"</tt>.
</div>
<p><tt>%typemap(javabody)</tt></p>

View file

@ -1497,6 +1497,7 @@ public:
Node *attributes = NewHash();
const String *pure_baseclass = typemapLookup("csbase", typemap_lookup_type, WARN_NONE, attributes);
bool purebase_replace = GetFlag(attributes, "tmap:csbase:replace") ? true : false;
bool purebase_notderived = GetFlag(attributes, "tmap:csbase:notderived") ? true : false;
Delete(attributes);
// C++ inheritance
@ -1529,17 +1530,22 @@ public:
}
}
const String *wanted_base = baseclass ? baseclass : pure_baseclass;
bool derived = baseclass && getProxyName(c_baseclassname);
if (derived && purebase_notderived)
pure_baseclass = empty_string;
const String *wanted_base = baseclass ? baseclass : pure_baseclass;
if (purebase_replace) {
wanted_base = pure_baseclass;
derived = false;
Delete(baseclass);
baseclass = NULL;
if (purebase_notderived)
Swig_error(input_file, line_number, "The csbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, input_file, line_number,
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#. Perhaps you need the replace attribute in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#. "
"Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
}
// Pure C# interfaces

View file

@ -1567,6 +1567,7 @@ public:
Node *attributes = NewHash();
const String *pure_baseclass = typemapLookup("javabase", typemap_lookup_type, WARN_NONE, attributes);
bool purebase_replace = GetFlag(attributes, "tmap:javabase:replace") ? true : false;
bool purebase_notderived = GetFlag(attributes, "tmap:javabase:notderived") ? true : false;
Delete(attributes);
// C++ inheritance
@ -1600,6 +1601,8 @@ public:
}
bool derived = baseclass && getProxyName(c_baseclassname);
if (derived && purebase_notderived)
pure_baseclass = empty_string;
const String *wanted_base = baseclass ? baseclass : pure_baseclass;
if (purebase_replace) {
@ -1607,9 +1610,12 @@ public:
derived = false;
Delete(baseclass);
baseclass = NULL;
if (purebase_notderived)
Swig_error(input_file, line_number, "The javabase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number,
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. Perhaps you need the replace attribute in the javabase typemap?\n", typemap_lookup_type, pure_baseclass);
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. "
"Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
}
// Pure Java interfaces