Only generate C# SwigDerivedClassHasMethod() if there are director methods in the class
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9140 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
47d40141be
commit
1db0b8a0c0
1 changed files with 29 additions and 24 deletions
|
|
@ -1585,32 +1585,37 @@ class CSHARP : public Language {
|
||||||
Printf(proxy_class_code, ", swigDelegate%s", methid);
|
Printf(proxy_class_code, ", swigDelegate%s", methid);
|
||||||
}
|
}
|
||||||
Printf(proxy_class_code, ");\n");
|
Printf(proxy_class_code, ");\n");
|
||||||
Printf(proxy_class_code, " }\n\n");
|
|
||||||
Printf(proxy_class_code, " private bool SwigDerivedClassHasMethod(string methodName, Type[] methodTypes) {\n");
|
|
||||||
Printf(proxy_class_code, " System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, methodTypes);\n");
|
|
||||||
Printf(proxy_class_code, " bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclassOf(typeof(%s));\n", proxy_class_name);
|
|
||||||
/* Could add this code to cover corner case where the GetMethod() returns a method which allows type
|
|
||||||
* promotion, eg it will return foo(double), if looking for foo(int).
|
|
||||||
if (hasDerivedMethod) {
|
|
||||||
hasDerivedMethod = false;
|
|
||||||
if (methodInfo != null)
|
|
||||||
{
|
|
||||||
hasDerivedMethod = true;
|
|
||||||
ParameterInfo[] parameterArray1 = methodInfo.GetParameters();
|
|
||||||
for (int i=0; i<methodTypes.Length; i++)
|
|
||||||
{
|
|
||||||
if (parameterArray1[0].ParameterType != methodTypes[0])
|
|
||||||
{
|
|
||||||
hasDerivedMethod = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
Printf(proxy_class_code, " return hasDerivedMethod;\n");
|
|
||||||
Printf(proxy_class_code, " }\n");
|
Printf(proxy_class_code, " }\n");
|
||||||
|
|
||||||
|
if (first_class_dmethod < curr_class_dmethod) {
|
||||||
|
// Only emit if there is at least one director method
|
||||||
|
Printf(proxy_class_code, "\n");
|
||||||
|
Printf(proxy_class_code, " private bool SwigDerivedClassHasMethod(string methodName, Type[] methodTypes) {\n");
|
||||||
|
Printf(proxy_class_code, " System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, methodTypes);\n");
|
||||||
|
Printf(proxy_class_code, " bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclassOf(typeof(%s));\n", proxy_class_name);
|
||||||
|
/* Could add this code to cover corner case where the GetMethod() returns a method which allows type
|
||||||
|
* promotion, eg it will return foo(double), if looking for foo(int).
|
||||||
|
if (hasDerivedMethod) {
|
||||||
|
hasDerivedMethod = false;
|
||||||
|
if (methodInfo != null)
|
||||||
|
{
|
||||||
|
hasDerivedMethod = true;
|
||||||
|
ParameterInfo[] parameterArray1 = methodInfo.GetParameters();
|
||||||
|
for (int i=0; i<methodTypes.Length; i++)
|
||||||
|
{
|
||||||
|
if (parameterArray1[0].ParameterType != methodTypes[0])
|
||||||
|
{
|
||||||
|
hasDerivedMethod = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
Printf(proxy_class_code, " return hasDerivedMethod;\n");
|
||||||
|
Printf(proxy_class_code, " }\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (Len(director_delegate_callback) > 0)
|
if (Len(director_delegate_callback) > 0)
|
||||||
Printv(proxy_class_code, director_delegate_callback, NIL);
|
Printv(proxy_class_code, director_delegate_callback, NIL);
|
||||||
if (Len(director_delegate_definitions) > 0)
|
if (Len(director_delegate_definitions) > 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue