Skip to content

Commit

Permalink
Added method indexer at the end to distinguish clashing methods
Browse files Browse the repository at this point in the history
  • Loading branch information
masesdevelopers committed Oct 18, 2023
1 parent d56c5b4 commit 1d950c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/net/JNetReflector/InternalMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using System.Reflection;

namespace MASES.JNetReflector
{
Expand Down Expand Up @@ -1426,7 +1427,7 @@ static string AnalyzeMethods(this Class classDefinition, IEnumerable<Class> clas
else
{
methodCounter[methodNameOrigin] = ++methodIndexer;
eventHandlerName += paramCount;
eventHandlerName = methodIndexer == 0 ? eventHandlerName : (methodIndexer == 1 ? eventHandlerName + paramCount : eventHandlerName + paramCount + $"_{methodIndexer}");
}

List<string> genericArguments = new List<string>();
Expand Down Expand Up @@ -1780,7 +1781,7 @@ static string AnalyzeMethods(this Class classDefinition, IEnumerable<Class> clas
string CLRListenerEventArgsType = string.Empty;
string executionPropertyParams = string.Empty;
string listenerHandlerType = string.Empty;
string baseHandlerName = methodIndexer == 0 ? methodName : methodName + paramCount;
string baseHandlerName = methodIndexer == 0 ? methodName : (methodIndexer == 1 ? methodName + paramCount : methodName + paramCount + $"_{methodIndexer}");
if (forListener)
{
executionStub = isVoidMethod ? string.Empty : "return default;";
Expand Down Expand Up @@ -1922,7 +1923,7 @@ static string AnalyzeJavaMethods(this Class classDefinition, bool isGeneric)
else
{
methodCounter[methodNameOrigin] = ++methodIndexer;
eventHandlerName += paramCount;
eventHandlerName = methodIndexer == 0 ? eventHandlerName : (methodIndexer == 1 ? eventHandlerName + paramCount : eventHandlerName + paramCount + $"_{methodIndexer}");
}

string returnType = method.GenericReturnType.TypeName;
Expand Down
2 changes: 1 addition & 1 deletion src/net/JNetReflector/Templates/Templates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public class MethodStub
public const string LISTENER_HANDLER_EXECUTION = "METHOD_STUB_LISTENER_HANDLER_EXECUTION_PLACEHOLDER";
public const string LISTENER_HANDLER_NAME = "METHOD_STUB_LISTENER_HANDLER_NAME_PLACEHOLDER";
public const string LISTENER_FIRST_PARAMETER = "METHOD_STUB_LISTENER_FIRST_PARAMETER_PLACEHOLDER";
public const string SINGLE_LISTENER_HANDLER_FORMAT = " AddEventHandler(\"{0}\", new System.EventHandler<CLRListenerEventArgs<CLREventDataMETHOD_STUB_LISTENER_FIRST_PARAMETER_PLACEHOLDER>>(METHOD_STUB_LISTENER_HANDLER_NAME_PLACEHOLDEREventHandler)); OnMETHOD_STUB_METHOD_NAME_PLACEHOLDER = METHOD_STUB_METHOD_NAME_PLACEHOLDER;";
public const string SINGLE_LISTENER_HANDLER_FORMAT = " AddEventHandler(\"{0}\", new System.EventHandler<CLRListenerEventArgs<CLREventDataMETHOD_STUB_LISTENER_FIRST_PARAMETER_PLACEHOLDER>>(METHOD_STUB_LISTENER_HANDLER_NAME_PLACEHOLDEREventHandler)); OnMETHOD_STUB_LISTENER_HANDLER_NAME_PLACEHOLDER = METHOD_STUB_METHOD_NAME_PLACEHOLDER;";
public const string EXECUTION_FORMAT = "{0}{1}{2}(\"{3}\"{4});";
public const string SINGLE_ARRAY_EXECUTION_FORMAT = "new object[] {{ {0} }}";
public const string STATIC_EXECUTION_FORMAT = "{0}{1}{2}(LocalBridgeClazz, \"{3}\"{4});";
Expand Down

0 comments on commit 1d950c2

Please sign in to comment.