Skip to content
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: 0 additions & 1 deletion src/documentation/articles/usageReflector.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ _jnetreflector_ accepts the following command-line switch:
* **DoNotCamel**: Does not use camelized names in methods, class and so on
* **TraceLevel**: The level of traces to be reported: 0 - Critical ... 5 - Verbose
* **TraceTo**: The file name where traces will be write, default write to console
* **AlwaysUseIDisposablePattern**: The generator do not use the JCOBridge base class without IDisposable (JVMBridgeCore) and fallback to previous class JVMBridgeBase

## JNet reflected classes

Expand Down
14 changes: 1 addition & 13 deletions src/net/JNet/Specific/Extensions/JNetCoreExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ namespace MASES.JNet.Specific.Extensions
/// </summary>
public static class JNetCoreExtensions
{
/// <summary>
/// Converts any instance of <see cref="JVMBridgeCore"/> in <paramref name="bridge"/> to an <see cref="IDisposable"/>
/// </summary>
/// <param name="bridge">The <see cref="JVMBridgeCore"/> instance to convert</param>
/// <returns>The <see cref="IDisposable"/> instance</returns>
/// <remarks>The method check if <paramref name="bridge"/> implements <see cref="IDisposable"/> and returns that instance, otherwise wraps <paramref name="bridge"/> into an <see cref="JVMBridgeCoreDisposable"/></remarks>
public static IDisposable ToDisposable(this JVMBridgeCore bridge)
{
if (bridge is IDisposable disposable) return disposable;
return JVMBridgeCoreDisposable.Create(bridge);
}

/// <summary>
/// Builds a new var-arg result starting from fixed parameters stored in <paramref name="fixedParameters"/> and the <see langword="params"/> argument available in <paramref name="varArg"/>
/// </summary>
Expand Down Expand Up @@ -87,7 +75,7 @@ public static Java.Lang.Class<TClass> Class<TClass>(this TClass _) where TClass
public static TWrap DirectBufferWithWrap<TData, TWrap>(this TData[] data, bool useMemoryControlBlock = true, bool arrangeCapacity = true, int timeToLive = System.Threading.Timeout.Infinite, Func<ByteBuffer, TWrap> converter = null) where TWrap : IJVMBridgeBase
{
var buf = JCOBridge.C2JBridge.JCOBridge.Global.JVM.NewDirectBuffer(data, useMemoryControlBlock, arrangeCapacity, timeToLive);
if (data is byte[]) return JVMBridgeCore.WrapsDirect<TWrap>(buf.DisableCleanupAndReturn());
if (data is byte[]) return JVMBridgeBase.WrapsDirect<TWrap>(buf.DisableCleanupAndReturn());
else
{
IJVMBridgeBase ibb;
Expand Down
1 change: 0 additions & 1 deletion src/net/JNetReflector/InternalConst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class CLIParam : MASES.JNet.CLIParam
public const string DoNotCamel = "DoNotCamel";
public const string TraceLevel = "TraceLevel";
public const string TraceTo = "TraceTo";
public const string AlwaysUseIDisposablePattern = "AlwaysUseIDisposablePattern";
}

public static class SpecialNames
Expand Down
18 changes: 6 additions & 12 deletions src/net/JNetReflector/InternalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ public static bool HasJVMBaseClassName(this Class entry, bool usedInGenerics, bo
}
}

public static string JVMBaseClassName(this Class entry, bool isClassCloseable, bool usedInGenerics, bool isListener, bool camel, out bool baseClassIsJVMBridgeBase)
public static string JVMBaseClassName(this Class entry, bool usedInGenerics, bool isListener, bool camel, out bool baseClassIsJVMBridgeBase)
{
baseClassIsJVMBridgeBase = false;
if (isListener)
Expand All @@ -1436,9 +1436,7 @@ public static string JVMBaseClassName(this Class entry, bool isClassCloseable, b
{
baseClassIsJVMBridgeBase = true;
string className = entry.JVMClassName(null, usedInGenerics, false);
return JNetReflectorCore.AlwaysUseIDisposablePattern
|| isClassCloseable ? $"MASES.JCOBridge.C2JBridge.JVMBridgeBase<{className}>"
: $"MASES.JCOBridge.C2JBridge.JVMBridgeCore<{className}>";
return $"MASES.JCOBridge.C2JBridge.JVMBridgeBase<{className}>";
}
try
{
Expand Down Expand Up @@ -1515,9 +1513,7 @@ public static string JVMBaseClassName(this Class entry, bool isClassCloseable, b
{
baseClassIsJVMBridgeBase = true;
string innerName = entry.JVMClassName(null, usedInGenerics, false);
return JNetReflectorCore.AlwaysUseIDisposablePattern
|| isClassCloseable ? $"MASES.JCOBridge.C2JBridge.JVMBridgeBase<{innerName}>"
: $"MASES.JCOBridge.C2JBridge.JVMBridgeCore<{innerName}>";
return $"MASES.JCOBridge.C2JBridge.JVMBridgeBase<{innerName}>";
}
}
else if ((usedInGenerics || !entry.IsJVMGenericClass()) && superCls.IsJVMGenericClass())
Expand All @@ -1530,17 +1526,15 @@ public static string JVMBaseClassName(this Class entry, bool isClassCloseable, b
{
baseClassIsJVMBridgeBase = true;
string className = entry.JVMClassName(null, usedInGenerics, false);
return JNetReflectorCore.AlwaysUseIDisposablePattern
|| isClassCloseable ? $"MASES.JCOBridge.C2JBridge.JVMBridgeBase<{className}>"
: $"MASES.JCOBridge.C2JBridge.JVMBridgeCore<{className}>";
return $"MASES.JCOBridge.C2JBridge.JVMBridgeBase<{className}>";
}
}

public static string JVMBaseInterfaceName(this Class entry, bool isClassCloseable, bool usedInGenerics, bool isListener, bool camel)
public static string JVMBaseInterfaceName(this Class entry, bool usedInGenerics, bool isListener, bool camel)
{
if (!entry.HasJVMBaseClassName(usedInGenerics, isListener, camel)) return string.Empty;

var fName = entry.JVMBaseClassName(isClassCloseable, usedInGenerics, isListener, camel, out _);
var fName = entry.JVMBaseClassName(usedInGenerics, isListener, camel, out _);
return ToFullQualifiedInterfaceName(fName, camel);
}

Expand Down
6 changes: 3 additions & 3 deletions src/net/JNetReflector/InternalMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ static void PrepareSingleClass(this Class jClass, IEnumerable<Class> classDefini
.Replace(AllPackageClasses.ClassStub.SIMPLECLASS, jClass.JVMClassName(null, false, false))
.Replace(AllPackageClasses.ClassStub.CLASS, jClass.JVMClassName(null, isGeneric, false))
.Replace(AllPackageClasses.ClassStub.HELP, jClass.JavadocHrefUrl(JNetReflectorCore.UseCamel))
.Replace(AllPackageClasses.ClassStub.BASECLASS, jClass.JVMBaseClassName(isClassCloseable, isGeneric, false, JNetReflectorCore.UseCamel, out _))
.Replace(AllPackageClasses.ClassStub.BASECLASS, jClass.JVMBaseClassName(isGeneric, false, JNetReflectorCore.UseCamel, out _))
.Replace(AllPackageClasses.ClassStub.WHERECLAUSES, string.Empty);
}
else
Expand All @@ -779,7 +779,7 @@ static void PrepareSingleClass(this Class jClass, IEnumerable<Class> classDefini
.Replace(AllPackageClasses.ClassStub.CLASS, jClass.JVMClassName(new List<KeyValuePair<string, string>>(), isGeneric, false))
.Replace(AllPackageClasses.ClassStub.CLASS_DIRECT, jClass.JVMClassName(new List<KeyValuePair<string, string>>(), isGeneric, true))
.Replace(AllPackageClasses.ClassStub.HELP, jClass.JavadocHrefUrl(JNetReflectorCore.UseCamel))
.Replace(AllPackageClasses.ClassStub.BASECLASS, jClass.JVMBaseClassName(isClassCloseable, isGeneric, jClassIsListener, JNetReflectorCore.UseCamel, out bool baseClassIsJVMBridgeBase) + (isMainClass ? SpecialNames.MainClassPlaceHolder : string.Empty))
.Replace(AllPackageClasses.ClassStub.BASECLASS, jClass.JVMBaseClassName(isGeneric, jClassIsListener, JNetReflectorCore.UseCamel, out bool baseClassIsJVMBridgeBase) + (isMainClass ? SpecialNames.MainClassPlaceHolder : string.Empty))
.Replace(AllPackageClasses.ClassStub.WHERECLAUSES, jClass.WhereClauses(isGeneric, JNetReflectorCore.UseCamel))
.Replace(AllPackageClasses.ClassStub.ISABSTRACT, isClassAbstract ? "true" : "false")
.Replace(AllPackageClasses.ClassStub.ISCLOSEABLE, isClassCloseable ? "true" : "false")
Expand Down Expand Up @@ -819,7 +819,7 @@ static void PrepareSingleClass(this Class jClass, IEnumerable<Class> classDefini
singleInterfaceStr = string.Empty;
if (createInterfaceData)
{
string baseInterface = jClass.JVMBaseInterfaceName(isClassCloseable, isGeneric, jClassIsListener, JNetReflectorCore.UseCamel);
string baseInterface = jClass.JVMBaseInterfaceName(isGeneric, jClassIsListener, JNetReflectorCore.UseCamel);
if (!string.IsNullOrWhiteSpace(baseInterface))
{
baseInterface = " : " + baseInterface;
Expand Down
6 changes: 0 additions & 6 deletions src/net/JNetReflector/JNetReflectorCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ public JVMOption(string optionName, string optionValue)
public int TraceLevel { get; set; }

public string TraceTo { get; set; }

public bool AlwaysUseIDisposablePattern { get; set; }
}

#region Initialization
Expand Down Expand Up @@ -601,9 +599,6 @@ public JNetReflectorCore()
static string _TraceTo;
public static string TraceTo => _TraceTo ?? _ConfigurationFromFile.TraceTo;

static bool? _AlwaysUseIDisposablePattern;
public static bool AlwaysUseIDisposablePattern => _AlwaysUseIDisposablePattern ?? _ConfigurationFromFile.AlwaysUseIDisposablePattern;

/// <inheritdoc cref="JNetCoreBase{T}.ProcessCommandLine"/>
protected override string[] ProcessCommandLine()
{
Expand Down Expand Up @@ -836,7 +831,6 @@ protected override string[] ProcessCommandLine()
if (ParsedArgs.Exist(CLIParam.AvoidParallelBuild)) _AvoidParallelBuild = true;
if (ParsedArgs.Exist(CLIParam.DryRun)) _DryRun = true;
if (ParsedArgs.Exist(CLIParam.DoNotCamel)) _UseCamel = false;
if (ParsedArgs.Exist(CLIParam.AlwaysUseIDisposablePattern)) _AlwaysUseIDisposablePattern = true;
_TraceLevel = ParsedArgs.Get<int>(CLIParam.TraceLevel);
_TraceTo = ParsedArgs.Get<string>(CLIParam.TraceTo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class ALLPACKAGE_CLASSES_STUB_CLASS_PLACEHOLDER : ALLPACKAGE_CLAS
public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(params object[] args) : base(args) { }

private static readonly global::System.Exception _LocalBridgeClazzException = null;
private static readonly MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType _LocalBridgeClazz = JVMBridgeCore.ClazzOf(_bridgeClassName, out _LocalBridgeClazzException, false);
private static readonly MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType _LocalBridgeClazz = JVMBridgeBase.ClazzOf(_bridgeClassName, out _LocalBridgeClazzException, false);
private static MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType LocalBridgeClazz => _LocalBridgeClazz ?? throw _LocalBridgeClazzException ?? new global::System.InvalidOperationException($"Class {_bridgeClassName} was not found.");

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class ALLPACKAGE_CLASSES_STUB_CLASS_PLACEHOLDER : ALLPACKAGE_CLAS
public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(params object[] args) : base(args) { }

private static readonly global::System.Exception _LocalBridgeClazzException = null;
private static readonly MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType _LocalBridgeClazz = JVMBridgeCore.ClazzOf(_bridgeClassName, out _LocalBridgeClazzException, false);
private static readonly MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType _LocalBridgeClazz = JVMBridgeBase.ClazzOf(_bridgeClassName, out _LocalBridgeClazzException, false);
private static MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType LocalBridgeClazz => _LocalBridgeClazz ?? throw _LocalBridgeClazzException ?? new global::System.InvalidOperationException($"Class {_bridgeClassName} was not found.");

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public partial class ALLPACKAGE_CLASSES_STUB_CLASS_DIRECT_PLACEHOLDER : ALLPACKA

const string _bridgeClassName = "ALLPACKAGE_CLASSES_STUB_JAVACLASS_DIRECT_PLACEHOLDER";
private static readonly global::System.Exception _LocalBridgeClazzException = null;
private static readonly MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType _LocalBridgeClazz = JVMBridgeCore.ClazzOf(_bridgeClassName, out _LocalBridgeClazzException, false);
private static readonly MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType _LocalBridgeClazz = JVMBridgeBase.ClazzOf(_bridgeClassName, out _LocalBridgeClazzException, false);
private static MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType LocalBridgeClazz => _LocalBridgeClazz ?? throw _LocalBridgeClazzException ?? new global::System.InvalidOperationException($"Class {_bridgeClassName} was not found.");

/// <inheritdoc/>
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 @@ -160,7 +160,7 @@ public class ClassStub

public static string LISTENER_CLASS_BLOCK = " const string _bridgeClassName = \"ALLPACKAGE_CLASSES_STUB_JAVACLASS_PLACEHOLDER\";" + Environment.NewLine
+ " private static readonly global::System.Exception _LocalBridgeClazzException = null;" + Environment.NewLine
+ " private static readonly MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType _LocalBridgeClazz = JVMBridgeCore.ClazzOf(_bridgeClassName, out _LocalBridgeClazzException, false);" + Environment.NewLine
+ " private static readonly MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType _LocalBridgeClazz = JVMBridgeBase.ClazzOf(_bridgeClassName, out _LocalBridgeClazzException, false);" + Environment.NewLine
+ " private static MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType LocalBridgeClazz => _LocalBridgeClazz ?? throw _LocalBridgeClazzException ?? new global::System.InvalidOperationException($\"Class {_bridgeClassName} was not found.\");" + Environment.NewLine
+ " " + Environment.NewLine
+ " /// <inheritdoc />" + Environment.NewLine
Expand Down
Loading