Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JNetReflector creates the Direct class which extends standard listeners #395

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/net/JNetReflector/InternalConst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public static string VersionPlaceHolder()
public const string PropertySuffix = "Property";
public const string MethodSuffix = "Method";
public const string DefaultMethodSuffix = "Default";
public const string DirectMethodSuffix = "Direct";
public const string NamespaceSuffix = "Ns";
public const string MainClassPlaceHolder = ", MASES.JCOBridge.C2JBridge.IJVMBridgeMain";
public const string JVMBridgeException = "MASES.JCOBridge.C2JBridge.JVMBridgeException";
Expand Down
26 changes: 17 additions & 9 deletions src/net/JNetReflector/InternalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public static bool CollapseWithClassOrNestedClass(this string entry, int nesting
{
if (classDefinition.JVMNestingLevels() == nestingLevel) // same level of requester
{
collpase = entry == classDefinition.JVMNestedClassName(nestingLevel, null, false);
collpase = entry == classDefinition.JVMNestedClassName(nestingLevel, null, false, false);
}
else if (classDefinition.JVMNestingLevels() > nestingLevel) // more levels then requester
{
collpase = entry == classDefinition.JVMNestedClassName(nestingLevel + 1, null, false);
collpase = entry == classDefinition.JVMNestedClassName(nestingLevel + 1, null, false, false);
}
}
else
Expand Down Expand Up @@ -1079,12 +1079,13 @@ public static bool IsJVMClass(this Class entry)
return false;
}

public static string JVMClassName(this Class entry, IList<KeyValuePair<string, string>> genClause, bool usedInGenerics)
public static string JVMClassName(this Class entry, IList<KeyValuePair<string, string>> genClause, bool usedInGenerics, bool isDirect)
{
if (entry.IsJVMNestedClass()) return entry.JVMNestedClassName(entry.JVMNestingLevels(), genClause, usedInGenerics);
if (entry.IsJVMNestedClass()) return entry.JVMNestedClassName(entry.JVMNestingLevels(), genClause, usedInGenerics, isDirect);
var cName = entry.SimpleName;
cName = cName.Contains(SpecialNames.NestedClassSeparator) ? cName.Substring(0, cName.LastIndexOf(SpecialNames.NestedClassSeparator)) : cName;
cName = cName.ConvertClassesInConflict();
if (isDirect) cName += SpecialNames.DirectMethodSuffix;
if (usedInGenerics) cName = entry.ApplyGenerics(genClause, usedInGenerics, cName);
return cName;
}
Expand All @@ -1095,7 +1096,7 @@ public static string JVMMainClassName(this Class entry)
return cName.Contains(SpecialNames.NestedClassSeparator) ? cName.Substring(0, cName.IndexOf(SpecialNames.NestedClassSeparator)) : cName;
}

static string JVMNestedClassName(this Class entry, int nestingLevel, IList<KeyValuePair<string, string>> genClause, bool usedInGenerics, bool onlyName = false)
static string JVMNestedClassName(this Class entry, int nestingLevel, IList<KeyValuePair<string, string>> genClause, bool usedInGenerics, bool isDirect, bool onlyName = false)
{
var cName = entry.TypeName;
if (cName.Contains(SpecialNames.NestedClassSeparator))
Expand All @@ -1104,6 +1105,7 @@ static string JVMNestedClassName(this Class entry, int nestingLevel, IList<KeyVa
cName = names[nestingLevel];
}
cName = cName.ConvertClassesInConflict();
if (isDirect) cName += SpecialNames.DirectMethodSuffix;
if (!onlyName) cName = entry.ApplyGenerics(genClause, usedInGenerics, cName);
return cName;
}
Expand Down Expand Up @@ -1374,7 +1376,7 @@ public static string JVMBaseClassName(this Class entry, bool usedInGenerics, boo
}
else
{
string innerName = entry.JVMClassName(null, usedInGenerics);
string innerName = entry.JVMClassName(null, usedInGenerics, false);
return string.Format("MASES.JCOBridge.C2JBridge.JVMBridgeBase<{0}>", innerName);
}
}
Expand All @@ -1386,7 +1388,7 @@ public static string JVMBaseClassName(this Class entry, bool usedInGenerics, boo
}
catch
{
string className = entry.JVMClassName(null, usedInGenerics);
string className = entry.JVMClassName(null, usedInGenerics, false);
return string.Format("MASES.JCOBridge.C2JBridge.JVMBridgeBase<{0}>", className);
}
}
Expand All @@ -1401,7 +1403,7 @@ public static string JVMBaseInterfaceName(this Class entry, bool usedInGenerics,

public static string JVMInterfaceName(this Class entry, IList<KeyValuePair<string, string>> genClause, bool usedInGenerics, bool fullyQualified)
{
var cName = entry.JVMClassName(genClause, usedInGenerics);
var cName = entry.JVMClassName(genClause, usedInGenerics, false);
cName = "I" + cName;
if (fullyQualified)
{
Expand Down Expand Up @@ -1531,7 +1533,7 @@ public static bool IsSpecialClass(this Class entry)
return true;
}

string className = entry.JVMNestedClassName(entry.JVMNestingLevels(), null, true);
string className = entry.JVMNestedClassName(entry.JVMNestingLevels(), null, true, false);

if (entry.IsJVMNestedClass()
&& SpecialNames.SpecialNumberedNames.Any((o) => className.StartsWith(o))) return true;
Expand Down Expand Up @@ -2311,6 +2313,12 @@ public static bool IsReturnTypeAnException(this Method entry)
return entry.ReturnType.IsJVMException();
}

public static bool IsReturnTypeAListener(this Method entry)
{
if (entry == null) throw new ArgumentNullException(nameof(entry));
return entry.ReturnType.IsJVMListenerClass();
}

public static string ReturnType(this Method entry, IList<string> genArguments, IList<KeyValuePair<string, string>> genClauses, string prefix, bool usedInGenerics, bool camel)
{
if (entry == null) throw new ArgumentNullException(nameof(entry));
Expand Down
Loading