From: dd7acfb4548dc76f1191aa96778f35c0cda80d35 Mon Sep 17 00:00:00 2001
From: David Gobbi <david.gobbi@gmail.com>
From: https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10712
Date: Sat, 18 Nov 2023 15:57:18 -0700
Subject: [PATCH] Fix Java error with integer, enum overloads

The Java wrappers simply cast enum types to 'jint', and do not
distinguish them as individual types that are distinct from 'int'
or 'unsigned int'.  So when a method is overloaded with both 'int'
and an enum type, only one of the overloads can be wrapped.  The
'int' (or 'unsigned int') is the one that is chosen.
--- a/Wrapping/Tools/vtkParseJava.c
+++ b/Wrapping/Tools/vtkParseJava.c
@@ -248,9 +248,10 @@ void return_result_native(FILE* fp)
  * return 0 if the types do not map to the same type */
 static int CheckMatch(unsigned int type1, unsigned int type2, const char* c1, const char* c2)
 {
+  /* VTK_PARSE_UNKNOWN is used for enum types, which are mapped to java's int type */
   static unsigned int byteTypes[] = { VTK_PARSE_UNSIGNED_CHAR, VTK_PARSE_SIGNED_CHAR, 0 };
   static unsigned int shortTypes[] = { VTK_PARSE_UNSIGNED_SHORT, VTK_PARSE_SHORT, 0 };
-  static unsigned int intTypes[] = { VTK_PARSE_UNSIGNED_INT, VTK_PARSE_INT, 0 };
+  static unsigned int intTypes[] = { VTK_PARSE_UNKNOWN, VTK_PARSE_UNSIGNED_INT, VTK_PARSE_INT, 0 };
   static unsigned int longTypes[] = { VTK_PARSE_UNSIGNED_LONG, VTK_PARSE_UNSIGNED_LONG_LONG,
     VTK_PARSE_LONG, VTK_PARSE_LONG_LONG, 0 };
 
--- a/Wrapping/Tools/vtkWrapJava.c
+++ b/Wrapping/Tools/vtkWrapJava.c
@@ -639,9 +639,10 @@ void OutputFunctionResult(FILE* fp)
  * return 0 if the types do not map to the same type */
 static int CheckMatch(unsigned int type1, unsigned int type2, const char* c1, const char* c2)
 {
+  /* VTK_PARSE_UNKNOWN is used for enum types, which are mapped to java's int type */
   static unsigned int byteTypes[] = { VTK_PARSE_UNSIGNED_CHAR, VTK_PARSE_SIGNED_CHAR, 0 };
   static unsigned int shortTypes[] = { VTK_PARSE_UNSIGNED_SHORT, VTK_PARSE_SHORT, 0 };
-  static unsigned int intTypes[] = { VTK_PARSE_UNSIGNED_INT, VTK_PARSE_INT, 0 };
+  static unsigned int intTypes[] = { VTK_PARSE_UNKNOWN, VTK_PARSE_UNSIGNED_INT, VTK_PARSE_INT, 0 };
   static unsigned int longTypes[] = { VTK_PARSE_UNSIGNED_LONG, VTK_PARSE_UNSIGNED_LONG_LONG,
     VTK_PARSE_LONG, VTK_PARSE_LONG_LONG, 0 };
 
-- 
GitLab

