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:
William S Fulton 2006-06-02 21:00:26 +00:00
commit 1db0b8a0c0

View file

@ -1585,7 +1585,11 @@ 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, " }\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, " 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, " 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); Printf(proxy_class_code, " bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclassOf(typeof(%s));\n", proxy_class_name);
@ -1610,6 +1614,7 @@ class CSHARP : public Language {
*/ */
Printf(proxy_class_code, " return hasDerivedMethod;\n"); Printf(proxy_class_code, " return hasDerivedMethod;\n");
Printf(proxy_class_code, " }\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);