diff --git a/Directory.Build.props b/Directory.Build.props index 1f2d69a90..f25811489 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -28,6 +28,10 @@ Project="$(_OutputPath)JdkInfo.props" Condition="Exists('$(_OutputPath)JdkInfo.props')" /> + minVersion != null ? j.Version >= minVersion : true) .Where (j => maxVersion != null ? j.Version <= maxVersion : true) - .Where (j => j.IncludePath.Any ()) + .Where (j => j.IncludePath.Any ()); + + foreach (var x in explicitJdks) { + Log.LogWarning ($"# jonp: Explicit JDK path: {x.HomePath}"); + } + foreach (var x in defaultJdks) { + Log.LogWarning ($"# jonp: Default JDK path: {x.HomePath}"); + } + + var jdk = explicitJdks.Concat (defaultJdks) .FirstOrDefault (); if (jdk == null) { @@ -56,14 +69,31 @@ public override bool Execute () JavaHomePath = jdk.HomePath; Directory.CreateDirectory (Path.GetDirectoryName (PropertyFile.ItemSpec)); - Directory.CreateDirectory (Path.GetDirectoryName (MakeFragmentFile.ItemSpec)); - WritePropertyFile (jdk.JavaPath, jdk.JarPath, jdk.JavacPath, jdk.JdkJvmPath, rtJarPath, jdk.IncludePath); - WriteMakeFragmentFile (jdk.JavaPath, jdk.JarPath, jdk.JavacPath, jdk.JdkJvmPath, rtJarPath, jdk.IncludePath); + + if (MakeFragmentFile != null) { + Directory.CreateDirectory (Path.GetDirectoryName (MakeFragmentFile.ItemSpec)); + WriteMakeFragmentFile (jdk.JavaPath, jdk.JarPath, jdk.JavacPath, jdk.JdkJvmPath, rtJarPath, jdk.IncludePath); + } return !Log.HasLoggedErrors; } + XATInfo[] GetJdkRoots () + { + XATInfo jdk = null; + try { + if (!string.IsNullOrEmpty (JdksRoot)) + jdk = new XATInfo (JdksRoot); + } catch (Exception e) { + Log.LogWarning ($"Could not get information about JdksRoot path `{JdksRoot}`: {e.Message}"); + Log.LogMessage (MessageImportance.Low, e.ToString ()); + } + return jdk == null + ? Array.Empty() + : new[] { jdk }; + } + Version GetVersion (string value) { if (string.IsNullOrEmpty (value)) @@ -97,39 +127,35 @@ Action CreateLogger () void WritePropertyFile (string javaPath, string jarPath, string javacPath, string jdkJvmPath, string rtJarPath, IEnumerable includes) { - var dotnet = string.IsNullOrEmpty (DotnetToolPath) ? "dotnet" : DotnetToolPath; var msbuild = XNamespace.Get ("http://schemas.microsoft.com/developer/msbuild/2003"); + var jdkJvmP = $"JdkJvm{PropertyNameModifier}Path"; var project = new XElement (msbuild + "Project", new XElement (msbuild + "Choose", - new XElement (msbuild + "When", new XAttribute ("Condition", " '$(JdkJvmPath)' == '' "), + new XElement (msbuild + "When", new XAttribute ("Condition", $" '$({jdkJvmP})' == '' "), new XElement (msbuild + "PropertyGroup", - new XElement (msbuild + "JdkJvmPath", jdkJvmPath)), + new XElement (msbuild + jdkJvmP, jdkJvmPath)), new XElement (msbuild + "ItemGroup", - includes.Select (i => new XElement (msbuild + "JdkIncludePath", new XAttribute ("Include", i)))))), + includes.Select (i => new XElement (msbuild + $"Jdk{PropertyNameModifier}IncludePath", new XAttribute ("Include", i)))))), new XElement (msbuild + "PropertyGroup", - new XElement (msbuild + "JavaSdkDirectory", new XAttribute ("Condition", " '$(JavaSdkDirectory)' == '' "), - JavaHomePath), - new XElement (msbuild + "JavaPath", new XAttribute ("Condition", " '$(JavaPath)' == '' "), - javaPath), - new XElement (msbuild + "JavaCPath", new XAttribute ("Condition", " '$(JavaCPath)' == '' "), - javacPath), - new XElement (msbuild + "JarPath", new XAttribute ("Condition", " '$(JarPath)' == '' "), - jarPath), - new XElement (msbuild + "DotnetToolPath", new XAttribute ("Condition", " '$(DotnetToolPath)' == '' "), - dotnet), - CreateJreRtJarPath (msbuild, rtJarPath))); + CreateProperty (msbuild, $"Java{PropertyNameModifier}SdkDirectory", JavaHomePath), + CreateProperty (msbuild, $"Java{PropertyNameModifier}Path", javaPath), + CreateProperty (msbuild, $"JavaC{PropertyNameModifier}Path", javacPath), + CreateProperty (msbuild, $"Jar{PropertyNameModifier}Path", jarPath), + CreateProperty (msbuild, $"Dotnet{PropertyNameModifier}ToolPath", DotnetToolPath), + CreateProperty (msbuild, $"Jre{PropertyNameModifier}RtJarPath", rtJarPath))); project.Save (PropertyFile.ItemSpec); } - static XElement CreateJreRtJarPath (XNamespace msbuild, string rtJarPath) + XElement CreateProperty (XNamespace msbuild, string propertyName, string propertyValue) { - if (rtJarPath == null) + if (string.IsNullOrEmpty (propertyValue)) { return null; - return new XElement (msbuild + "JreRtJarPath", - new XAttribute ("Condition", " '$(JreRtJarPath)' == '' "), - rtJarPath); - } + } + return new XElement (msbuild + propertyName, + new XAttribute ("Condition", $" '$({propertyName})' == '' "), + propertyValue); + } void WriteMakeFragmentFile (string javaPath, string jarPath, string javacPath, string jdkJvmPath, string rtJarPath, IEnumerable includes) { using (var o = new StreamWriter (MakeFragmentFile.ItemSpec)) { diff --git a/build-tools/scripts/Prepare.targets b/build-tools/scripts/Prepare.targets index 5dc688d4c..29b81dd54 100644 --- a/build-tools/scripts/Prepare.targets +++ b/build-tools/scripts/Prepare.targets @@ -22,5 +22,16 @@ PropertyFile="$(_TopDir)\bin\Build$(Configuration)\JdkInfo.props"> + + $(JAVA_HOME_11_X64) + + + + diff --git a/build-tools/scripts/jdk.targets b/build-tools/scripts/jdk.targets index e71f1d921..b1a750995 100644 --- a/build-tools/scripts/jdk.targets +++ b/build-tools/scripts/jdk.targets @@ -10,5 +10,13 @@ PropertyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\JdkInfo.props"> + + + diff --git a/samples/Hello/Hello.csproj b/samples/Hello/Hello.csproj index c008372f3..61ceac50d 100644 --- a/samples/Hello/Hello.csproj +++ b/samples/Hello/Hello.csproj @@ -1,14 +1,10 @@  - net472 + net6.0 Exe - ..\..\bin\Test$(Configuration) true - - - - $(TestOutputFullPath) + enable @@ -18,6 +14,8 @@ + + diff --git a/samples/Hello/Program.cs b/samples/Hello/Program.cs index 6ffacbb41..293b6305e 100644 --- a/samples/Hello/Program.cs +++ b/samples/Hello/Program.cs @@ -1,23 +1,65 @@ using System; using System.Threading; +using Mono.Options; + using Java.Interop; namespace Hello { - class MainClass + class App { - public static unsafe void Main (string[] args) + public static void Main (string[] args) { - Console.WriteLine ("Hello World!"); - try { - var ignore = JniRuntime.CurrentRuntime; - } catch (InvalidOperationException e) { - Console.WriteLine (e); + string? jvmPath = global::Java.InteropTests.TestJVM.GetJvmLibraryPath (); + bool createMultipleVMs = false; + bool showHelp = false; + var options = new OptionSet () { + "Using the JVM from C#!", + "", + "Options:", + { "jvm=", + $"{{PATH}} to JVM to use. Default is:\n {jvmPath}", + v => jvmPath = v }, + { "m", + "Create multiple Java VMs. This will likely creash.", + v => createMultipleVMs = v != null }, + { "h|help", + "Show this message and exit.", + v => showHelp = v != null }, + }; + options.Parse (args); + if (showHelp) { + options.WriteOptionDescriptions (Console.Out); + return; } + Console.WriteLine ("Hello World!"); + var builder = new JreRuntimeOptions () { + JniAddNativeMethodRegistrationAttributePresent = true, + JvmLibraryPath = jvmPath, + }; + builder.AddOption ("-Xcheck:jni"); + var jvm = builder.CreateJreVM (); + Console.WriteLine ($"JniRuntime.CurrentRuntime == jvm? {ReferenceEquals (JniRuntime.CurrentRuntime, jvm)}"); foreach (var h in JniRuntime.GetAvailableInvocationPointers ()) { Console.WriteLine ("PRE: GetCreatedJavaVMHandles: {0}", h); } + + CreateJLO (); + + if (createMultipleVMs) { + CreateAnotherJVM (); + } + } + + static void CreateJLO () + { + var jlo = new Java.Lang.Object (); + Console.WriteLine ($"binding? {jlo.ToString ()}"); + } + + static unsafe void CreateAnotherJVM () + { Console.WriteLine ("Part 2!"); using (var vm = new JreRuntimeOptions ().CreateJreVM ()) { Console.WriteLine ("# JniEnvironment.EnvironmentPointer={0}", JniEnvironment.EnvironmentPointer); diff --git a/src/Java.Base/Java.Base.csproj b/src/Java.Base/Java.Base.csproj new file mode 100644 index 000000000..1336ce660 --- /dev/null +++ b/src/Java.Base/Java.Base.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + true + enable + + + + + + + + + + + diff --git a/src/Java.Base/Java.Base.targets b/src/Java.Base/Java.Base.targets new file mode 100644 index 000000000..2bb3d9ccd --- /dev/null +++ b/src/Java.Base/Java.Base.targets @@ -0,0 +1,78 @@ + + + + $(ToolOutputFullPath)generator.dll + + + + + <_JavaBaseJmod>$(Java11SdkDirectory)/jmods/java.base.jmod + + + + + + + <_ClassParse>"$(ToolOutputFullPath)class-parse.dll" + <_Input>"$(_JavaBaseJmod)" + <_Output>"-o=$(IntermediateOutputPath)/mcw/api.xml" + + + + + + + <_GenerateBindingInputs Include="$(GeneratorPath)" /> + <_GenerateBindingInputs Include="$(MSBuildThisFileFullPath)" /> + <_GenerateBindingInputs Include="Transforms\**" /> + <_GenerateBindingInputs Include="$(IntermediateOutputPath)mcw\api.xml" /> + + + + + + "$(GeneratorPath)" + <_GenFlags>--public + <_Out>-o "$(IntermediateOutputPath)mcw" + <_Codegen>--codegen-target=JavaInterop1 + <_Fixup>--fixup=Transforms/Metadata.xml + <_Enums1>--preserve-enums --enumflags=Transforms/enumflags --enumfields=Transforms/map.csv --enummethods=Transforms/methodmap.csv + <_Enums2>--enummetadata=$(IntermediateOutputPath)mcw/enummetadata + <_Assembly>"--assembly=Java.Base" + <_TypeMap>--type-map-report=$(IntermediateOutputPath)mcw/type-mapping.txt + <_Api>$(IntermediateOutputPath)mcw/api.xml + <_Dirs>--enumdir=$(IntermediateOutputPath)mcw + <_FullIntermediateOutputPath>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)')) + <_LangFeatures>--lang-features=nullable-reference-types,default-interface-methods,nested-interface-types,interface-constants + + + + + + + + + + $(DefineConstants);$([System.String]::Copy('$(_GeneratedDefineConstants)').Replace ('%24(DefineConstants);', '')) + + + + diff --git a/src/Java.Base/Java.Lang/Object.cs b/src/Java.Base/Java.Lang/Object.cs new file mode 100644 index 000000000..4232f179b --- /dev/null +++ b/src/Java.Base/Java.Lang/Object.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using Java.Interop; + +namespace Java.Lang { + + public partial class Object : JavaObject { + + public Object (ref JniObjectReference reference, JniObjectReferenceOptions options) + : base (ref reference, options) + { + } + } +} diff --git a/src/Java.Base/Java.Lang/Throwable.cs b/src/Java.Base/Java.Lang/Throwable.cs new file mode 100644 index 000000000..20f2e07cb --- /dev/null +++ b/src/Java.Base/Java.Lang/Throwable.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using Java.Interop; + +namespace Java.Lang { + + public partial class Throwable : JavaException { + + public Throwable (ref JniObjectReference reference, JniObjectReferenceOptions options) + : base (ref reference, options) + { + } + } +} diff --git a/src/Java.Base/Transforms/Metadata.xml b/src/Java.Base/Transforms/Metadata.xml new file mode 100644 index 000000000..923bded52 --- /dev/null +++ b/src/Java.Base/Transforms/Metadata.xml @@ -0,0 +1,10 @@ + + + + + + + + + JavaFinalize + diff --git a/src/Java.Base/Transforms/enumflags b/src/Java.Base/Transforms/enumflags new file mode 100644 index 000000000..c1b8f3a10 --- /dev/null +++ b/src/Java.Base/Transforms/enumflags @@ -0,0 +1,2 @@ +Java.Net.IDNFlags +Java.Util.FormatFlags diff --git a/src/Java.Base/Transforms/map.csv b/src/Java.Base/Transforms/map.csv new file mode 100644 index 000000000..dcad3d81e --- /dev/null +++ b/src/Java.Base/Transforms/map.csv @@ -0,0 +1,1345 @@ +I,0,I:java/io/ObjectStreamConstants.baseWireHandle,8257536,,,, +E,10,I:java/io/ObjectStreamConstants.PROTOCOL_VERSION_1,1,Java.IO.ObjectStreamProtocol,Version1,remove, +E,10,I:java/io/ObjectStreamConstants.PROTOCOL_VERSION_2,2,Java.IO.ObjectStreamProtocol,Version2,remove, +E,26,I:java/lang/invoke/MethodHandleInfo.REF_getField,1,Java.Lang.Invoke.ReferenceKind,Getfield,remove, +E,26,I:java/lang/invoke/MethodHandleInfo.REF_getStatic,2,Java.Lang.Invoke.ReferenceKind,Getstatic,remove, +E,26,I:java/lang/invoke/MethodHandleInfo.REF_invokeInterface,9,Java.Lang.Invoke.ReferenceKind,Invokeinterface,remove, +E,26,I:java/lang/invoke/MethodHandleInfo.REF_invokeSpecial,7,Java.Lang.Invoke.ReferenceKind,Invokespecial,remove, +E,26,I:java/lang/invoke/MethodHandleInfo.REF_invokeStatic,6,Java.Lang.Invoke.ReferenceKind,Invokestatic,remove, +E,26,I:java/lang/invoke/MethodHandleInfo.REF_invokeVirtual,5,Java.Lang.Invoke.ReferenceKind,Invokevirtual,remove, +E,26,I:java/lang/invoke/MethodHandleInfo.REF_newInvokeSpecial,8,Java.Lang.Invoke.ReferenceKind,Newinvokespecial,remove, +E,26,I:java/lang/invoke/MethodHandleInfo.REF_putField,3,Java.Lang.Invoke.ReferenceKind,Putfield,remove, +E,26,I:java/lang/invoke/MethodHandleInfo.REF_putStatic,4,Java.Lang.Invoke.ReferenceKind,Putstatic,remove, +I,0,I:java/lang/reflect/Member.DECLARED,1,,,, +I,0,I:java/lang/reflect/Member.PUBLIC,0,,,, +E,10,I:java/net/SocketOptions.IP_MULTICAST_IF,16,Java.Net.SocketOption,IpMulticastIf,remove, +E,10,I:java/net/SocketOptions.IP_MULTICAST_IF2,31,Java.Net.SocketOption,IpMulticastIf2,remove, +E,10,I:java/net/SocketOptions.IP_MULTICAST_LOOP,18,Java.Net.SocketOption,IpMulticastLoop,remove, +E,10,I:java/net/SocketOptions.IP_TOS,3,Java.Net.SocketOption,IpTos,remove, +E,10,I:java/net/SocketOptions.SO_BINDADDR,15,Java.Net.SocketOption,SoBindaddr,remove, +E,10,I:java/net/SocketOptions.SO_BROADCAST,32,Java.Net.SocketOption,SoBroadcast,remove, +E,10,I:java/net/SocketOptions.SO_KEEPALIVE,8,Java.Net.SocketOption,SoKeepalive,remove, +E,10,I:java/net/SocketOptions.SO_LINGER,128,Java.Net.SocketOption,SoLinger,remove, +E,10,I:java/net/SocketOptions.SO_OOBINLINE,4099,Java.Net.SocketOption,SoOobinline,remove, +E,10,I:java/net/SocketOptions.SO_RCVBUF,4098,Java.Net.SocketOption,SoRcvbuf,remove, +E,10,I:java/net/SocketOptions.SO_REUSEADDR,4,Java.Net.SocketOption,SoReuseaddr,remove, +E,10,I:java/net/SocketOptions.SO_SNDBUF,4097,Java.Net.SocketOption,SoSndbuf,remove, +E,10,I:java/net/SocketOptions.SO_TIMEOUT,4102,Java.Net.SocketOption,SoTimeout,remove, +E,10,I:java/net/SocketOptions.TCP_NODELAY,1,Java.Net.SocketOption,TcpNodelay,remove, +I,0,I:java/sql/Connection.TRANSACTION_NONE,0,,,, +I,0,I:java/sql/Connection.TRANSACTION_READ_COMMITTED,2,,,, +I,0,I:java/sql/Connection.TRANSACTION_READ_UNCOMMITTED,1,,,, +I,0,I:java/sql/Connection.TRANSACTION_REPEATABLE_READ,4,,,, +I,0,I:java/sql/Connection.TRANSACTION_SERIALIZABLE,8,,,, +I,0,I:java/sql/DatabaseMetaData.bestRowNotPseudo,1,,,, +I,0,I:java/sql/DatabaseMetaData.bestRowPseudo,2,,,, +I,0,I:java/sql/DatabaseMetaData.bestRowSession,2,,,, +I,0,I:java/sql/DatabaseMetaData.bestRowTemporary,0,,,, +I,0,I:java/sql/DatabaseMetaData.bestRowTransaction,1,,,, +I,0,I:java/sql/DatabaseMetaData.bestRowUnknown,0,,,, +I,0,I:java/sql/DatabaseMetaData.columnNoNulls,0,,,, +I,0,I:java/sql/DatabaseMetaData.columnNullable,1,,,, +I,0,I:java/sql/DatabaseMetaData.columnNullableUnknown,2,,,, +I,0,I:java/sql/DatabaseMetaData.functionColumnIn,1,,,, +I,0,I:java/sql/DatabaseMetaData.functionColumnInOut,2,,,, +I,0,I:java/sql/DatabaseMetaData.functionColumnOut,3,,,, +I,0,I:java/sql/DatabaseMetaData.functionColumnResult,5,,,, +I,0,I:java/sql/DatabaseMetaData.functionColumnUnknown,0,,,, +I,0,I:java/sql/DatabaseMetaData.functionNoNulls,0,,,, +I,0,I:java/sql/DatabaseMetaData.functionNoTable,1,,,, +I,0,I:java/sql/DatabaseMetaData.functionNullable,1,,,, +I,0,I:java/sql/DatabaseMetaData.functionNullableUnknown,2,,,, +I,0,I:java/sql/DatabaseMetaData.functionResultUnknown,0,,,, +I,0,I:java/sql/DatabaseMetaData.functionReturn,4,,,, +I,0,I:java/sql/DatabaseMetaData.functionReturnsTable,2,,,, +I,0,I:java/sql/DatabaseMetaData.importedKeyCascade,0,,,, +I,0,I:java/sql/DatabaseMetaData.importedKeyInitiallyDeferred,5,,,, +I,0,I:java/sql/DatabaseMetaData.importedKeyInitiallyImmediate,6,,,, +I,0,I:java/sql/DatabaseMetaData.importedKeyNoAction,3,,,, +I,0,I:java/sql/DatabaseMetaData.importedKeyNotDeferrable,7,,,, +I,0,I:java/sql/DatabaseMetaData.importedKeyRestrict,1,,,, +I,0,I:java/sql/DatabaseMetaData.importedKeySetDefault,4,,,, +I,0,I:java/sql/DatabaseMetaData.importedKeySetNull,2,,,, +I,0,I:java/sql/DatabaseMetaData.procedureColumnIn,1,,,, +I,0,I:java/sql/DatabaseMetaData.procedureColumnInOut,2,,,, +I,0,I:java/sql/DatabaseMetaData.procedureColumnOut,4,,,, +I,0,I:java/sql/DatabaseMetaData.procedureColumnResult,3,,,, +I,0,I:java/sql/DatabaseMetaData.procedureColumnReturn,5,,,, +I,0,I:java/sql/DatabaseMetaData.procedureColumnUnknown,0,,,, +I,0,I:java/sql/DatabaseMetaData.procedureNoNulls,0,,,, +I,0,I:java/sql/DatabaseMetaData.procedureNoResult,1,,,, +I,0,I:java/sql/DatabaseMetaData.procedureNullable,1,,,, +I,0,I:java/sql/DatabaseMetaData.procedureNullableUnknown,2,,,, +I,0,I:java/sql/DatabaseMetaData.procedureResultUnknown,0,,,, +I,0,I:java/sql/DatabaseMetaData.procedureReturnsResult,2,,,, +I,0,I:java/sql/DatabaseMetaData.sqlStateSQL,2,,,, +I,0,I:java/sql/DatabaseMetaData.sqlStateSQL99,2,,,, +I,0,I:java/sql/DatabaseMetaData.sqlStateXOpen,1,,,, +I,0,I:java/sql/DatabaseMetaData.typeNoNulls,0,,,, +I,0,I:java/sql/DatabaseMetaData.typeNullable,1,,,, +I,0,I:java/sql/DatabaseMetaData.typeNullableUnknown,2,,,, +I,0,I:java/sql/DatabaseMetaData.typePredBasic,2,,,, +I,0,I:java/sql/DatabaseMetaData.typePredChar,1,,,, +I,0,I:java/sql/DatabaseMetaData.typePredNone,0,,,, +I,0,I:java/sql/DatabaseMetaData.typeSearchable,3,,,, +I,0,I:java/sql/DatabaseMetaData.versionColumnNotPseudo,1,,,, +I,0,I:java/sql/DatabaseMetaData.versionColumnPseudo,2,,,, +I,0,I:java/sql/DatabaseMetaData.versionColumnUnknown,0,,,, +I,0,I:java/sql/ParameterMetaData.parameterModeIn,1,,,, +I,0,I:java/sql/ParameterMetaData.parameterModeInOut,2,,,, +I,0,I:java/sql/ParameterMetaData.parameterModeOut,4,,,, +I,0,I:java/sql/ParameterMetaData.parameterModeUnknown,0,,,, +I,0,I:java/sql/ParameterMetaData.parameterNoNulls,0,,,, +I,0,I:java/sql/ParameterMetaData.parameterNullable,1,,,, +I,0,I:java/sql/ParameterMetaData.parameterNullableUnknown,2,,,, +I,0,I:java/sql/ResultSet.CLOSE_CURSORS_AT_COMMIT,2,,,, +I,0,I:java/sql/ResultSet.CONCUR_READ_ONLY,1007,,,, +I,0,I:java/sql/ResultSet.CONCUR_UPDATABLE,1008,,,, +I,0,I:java/sql/ResultSet.FETCH_FORWARD,1000,,,, +I,0,I:java/sql/ResultSet.FETCH_REVERSE,1001,,,, +I,0,I:java/sql/ResultSet.FETCH_UNKNOWN,1002,,,, +I,0,I:java/sql/ResultSet.HOLD_CURSORS_OVER_COMMIT,1,,,, +I,0,I:java/sql/ResultSet.TYPE_FORWARD_ONLY,1003,,,, +I,0,I:java/sql/ResultSet.TYPE_SCROLL_INSENSITIVE,1004,,,, +I,0,I:java/sql/ResultSet.TYPE_SCROLL_SENSITIVE,1005,,,, +I,0,I:java/sql/ResultSetMetaData.columnNoNulls,0,,,, +I,0,I:java/sql/ResultSetMetaData.columnNullable,1,,,, +I,0,I:java/sql/ResultSetMetaData.columnNullableUnknown,2,,,, +I,0,I:java/sql/Statement.CLOSE_ALL_RESULTS,3,,,, +I,0,I:java/sql/Statement.CLOSE_CURRENT_RESULT,1,,,, +I,0,I:java/sql/Statement.EXECUTE_FAILED,-3,,,, +I,0,I:java/sql/Statement.KEEP_CURRENT_RESULT,2,,,, +I,0,I:java/sql/Statement.NO_GENERATED_KEYS,2,,,, +I,0,I:java/sql/Statement.RETURN_GENERATED_KEYS,1,,,, +I,0,I:java/sql/Statement.SUCCESS_NO_INFO,-2,,,, +E,24,I:java/util/Spliterator.CONCURRENT,4096,Java.Util.SpliteratorCharacteristics,Concurrent,remove, +E,24,I:java/util/Spliterator.DISTINCT,1,Java.Util.SpliteratorCharacteristics,Distinct,remove, +E,24,I:java/util/Spliterator.IMMUTABLE,1024,Java.Util.SpliteratorCharacteristics,Immutable,remove, +E,24,I:java/util/Spliterator.NONNULL,256,Java.Util.SpliteratorCharacteristics,Nonnull,remove, +E,24,I:java/util/Spliterator.ORDERED,16,Java.Util.SpliteratorCharacteristics,Ordered,remove, +E,24,I:java/util/Spliterator.SIZED,64,Java.Util.SpliteratorCharacteristics,Sized,remove, +E,24,I:java/util/Spliterator.SORTED,4,Java.Util.SpliteratorCharacteristics,Sorted,remove, +E,24,I:java/util/Spliterator.SUBSIZED,16384,Java.Util.SpliteratorCharacteristics,Subsized,remove, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_ALPHA_FORMAT,12424,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_ALPHA_MASK_SIZE,12350,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_ALPHA_SIZE,12321,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_BAD_ACCESS,12290,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_BAD_ALLOC,12291,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_BAD_ATTRIBUTE,12292,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_BAD_CONFIG,12293,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_BAD_CONTEXT,12294,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_BAD_CURRENT_SURFACE,12295,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_BAD_DISPLAY,12296,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_BAD_MATCH,12297,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_BAD_NATIVE_PIXMAP,12298,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_BAD_NATIVE_WINDOW,12299,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_BAD_PARAMETER,12300,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_BAD_SURFACE,12301,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_BLUE_SIZE,12322,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_BUFFER_SIZE,12320,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_COLOR_BUFFER_TYPE,12351,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_COLORSPACE,12423,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_CONFIG_CAVEAT,12327,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_CONFIG_ID,12328,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_CORE_NATIVE_ENGINE,12379,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_DEPTH_SIZE,12325,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_DONT_CARE,-1,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_DRAW,12377,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_EXTENSIONS,12373,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_GREEN_SIZE,12323,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_HEIGHT,12374,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_HORIZONTAL_RESOLUTION,12432,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_LARGEST_PBUFFER,12376,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_LEVEL,12329,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_LUMINANCE_BUFFER,12431,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_LUMINANCE_SIZE,12349,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_MAX_PBUFFER_HEIGHT,12330,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_MAX_PBUFFER_PIXELS,12331,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_MAX_PBUFFER_WIDTH,12332,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_NATIVE_RENDERABLE,12333,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_NATIVE_VISUAL_ID,12334,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_NATIVE_VISUAL_TYPE,12335,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_NON_CONFORMANT_CONFIG,12369,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_NONE,12344,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_NOT_INITIALIZED,12289,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_PBUFFER_BIT,1,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_PIXEL_ASPECT_RATIO,12434,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_PIXMAP_BIT,2,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_READ,12378,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_RED_SIZE,12324,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_RENDER_BUFFER,12422,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_RENDERABLE_TYPE,12352,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_RGB_BUFFER,12430,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_SAMPLE_BUFFERS,12338,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_SAMPLES,12337,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_SINGLE_BUFFER,12421,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_SLOW_CONFIG,12368,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_STENCIL_SIZE,12326,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_SUCCESS,12288,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_SURFACE_TYPE,12339,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_TRANSPARENT_BLUE_VALUE,12341,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_TRANSPARENT_GREEN_VALUE,12342,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_TRANSPARENT_RED_VALUE,12343,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_TRANSPARENT_RGB,12370,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_TRANSPARENT_TYPE,12340,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_VENDOR,12371,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_VERSION,12372,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_VERTICAL_RESOLUTION,12433,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_WIDTH,12375,,,, +I,0,I:javax/microedition/khronos/egl/EGL10.EGL_WINDOW_BIT,4,,,, +I,0,I:javax/microedition/khronos/egl/EGL11.EGL_CONTEXT_LOST,12302,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_ADD,260,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_ALIASED_LINE_WIDTH_RANGE,33902,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_ALIASED_POINT_SIZE_RANGE,33901,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_ALPHA,6406,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_ALPHA_BITS,3413,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_ALPHA_TEST,3008,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_ALWAYS,519,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_AMBIENT,4608,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_AMBIENT_AND_DIFFUSE,5634,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_AND,5377,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_AND_INVERTED,5380,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_AND_REVERSE,5378,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_BACK,1029,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_BLEND,3042,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_BLUE_BITS,3412,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_BYTE,5120,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_CCW,2305,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_CLAMP_TO_EDGE,33071,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_CLEAR,5376,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_COLOR_ARRAY,32886,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_COLOR_BUFFER_BIT,16384,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_COLOR_LOGIC_OP,3058,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_COLOR_MATERIAL,2903,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_COMPRESSED_TEXTURE_FORMATS,34467,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_CONSTANT_ATTENUATION,4615,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_COPY,5379,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_COPY_INVERTED,5388,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_CULL_FACE,2884,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_CW,2304,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_DECAL,8449,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_DECR,7683,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_DEPTH_BITS,3414,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_DEPTH_BUFFER_BIT,256,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_DEPTH_TEST,2929,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_DIFFUSE,4609,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_DITHER,3024,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_DONT_CARE,4352,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_DST_ALPHA,772,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_DST_COLOR,774,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_EMISSION,5632,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_EQUAL,514,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_EQUIV,5385,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_EXP,2048,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_EXP2,2049,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_EXTENSIONS,7939,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_FALSE,0,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_FASTEST,4353,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_FIXED,5132,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_FLAT,7424,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_FLOAT,5126,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_FOG,2912,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_FOG_COLOR,2918,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_FOG_DENSITY,2914,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_FOG_END,2916,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_FOG_HINT,3156,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_FOG_MODE,2917,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_FOG_START,2915,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_FRONT,1028,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_FRONT_AND_BACK,1032,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_GEQUAL,518,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_GREATER,516,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_GREEN_BITS,3411,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES,35739,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_IMPLEMENTATION_COLOR_READ_TYPE_OES,35738,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_INCR,7682,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_INVALID_ENUM,1280,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_INVALID_OPERATION,1282,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_INVALID_VALUE,1281,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_INVERT,5386,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_KEEP,7680,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LEQUAL,515,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LESS,513,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LIGHT_MODEL_AMBIENT,2899,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LIGHT_MODEL_TWO_SIDE,2898,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LIGHT0,16384,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LIGHT1,16385,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LIGHT2,16386,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LIGHT3,16387,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LIGHT4,16388,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LIGHT5,16389,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LIGHT6,16390,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LIGHT7,16391,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LIGHTING,2896,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LINE_LOOP,2,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LINE_SMOOTH,2848,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LINE_SMOOTH_HINT,3154,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LINE_STRIP,3,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LINEAR,9729,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LINEAR_ATTENUATION,4616,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LINEAR_MIPMAP_LINEAR,9987,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LINEAR_MIPMAP_NEAREST,9985,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LINES,1,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LUMINANCE,6409,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_LUMINANCE_ALPHA,6410,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_MAX_ELEMENTS_INDICES,33001,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_MAX_ELEMENTS_VERTICES,33000,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_MAX_LIGHTS,3377,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_MAX_MODELVIEW_STACK_DEPTH,3382,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_MAX_PROJECTION_STACK_DEPTH,3384,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_MAX_TEXTURE_SIZE,3379,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_MAX_TEXTURE_STACK_DEPTH,3385,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_MAX_TEXTURE_UNITS,34018,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_MAX_VIEWPORT_DIMS,3386,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_MODELVIEW,5888,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_MODULATE,8448,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_MULTISAMPLE,32925,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_NAND,5390,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_NEAREST,9728,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_NEAREST_MIPMAP_LINEAR,9986,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_NEAREST_MIPMAP_NEAREST,9984,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_NEVER,512,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_NICEST,4354,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_NO_ERROR,0,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_NOOP,5381,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_NOR,5384,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_NORMAL_ARRAY,32885,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_NORMALIZE,2977,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_NOTEQUAL,517,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_NUM_COMPRESSED_TEXTURE_FORMATS,34466,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_ONE,1,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_ONE_MINUS_DST_ALPHA,773,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_ONE_MINUS_DST_COLOR,775,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_ONE_MINUS_SRC_ALPHA,771,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_ONE_MINUS_SRC_COLOR,769,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_OR,5383,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_OR_INVERTED,5389,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_OR_REVERSE,5387,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_OUT_OF_MEMORY,1285,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_PACK_ALIGNMENT,3333,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_PALETTE4_R5_G6_B5_OES,35730,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_PALETTE4_RGB5_A1_OES,35732,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_PALETTE4_RGB8_OES,35728,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_PALETTE4_RGBA4_OES,35731,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_PALETTE4_RGBA8_OES,35729,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_PALETTE8_R5_G6_B5_OES,35735,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_PALETTE8_RGB5_A1_OES,35737,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_PALETTE8_RGB8_OES,35733,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_PALETTE8_RGBA4_OES,35736,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_PALETTE8_RGBA8_OES,35734,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_PERSPECTIVE_CORRECTION_HINT,3152,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_POINT_FADE_THRESHOLD_SIZE,33064,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_POINT_SIZE,2833,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_POINT_SMOOTH,2832,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_POINT_SMOOTH_HINT,3153,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_POINTS,0,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_POLYGON_OFFSET_FILL,32823,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_POLYGON_SMOOTH_HINT,3155,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_POSITION,4611,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_PROJECTION,5889,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_QUADRATIC_ATTENUATION,4617,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_RED_BITS,3410,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_RENDERER,7937,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_REPEAT,10497,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_REPLACE,7681,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_RESCALE_NORMAL,32826,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_RGB,6407,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_RGBA,6408,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SAMPLE_ALPHA_TO_COVERAGE,32926,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SAMPLE_ALPHA_TO_ONE,32927,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SAMPLE_COVERAGE,32928,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SCISSOR_TEST,3089,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SET,5391,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SHININESS,5633,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SHORT,5122,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SMOOTH,7425,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SMOOTH_LINE_WIDTH_RANGE,2850,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SMOOTH_POINT_SIZE_RANGE,2834,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SPECULAR,4610,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SPOT_CUTOFF,4614,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SPOT_DIRECTION,4612,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SPOT_EXPONENT,4613,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SRC_ALPHA,770,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SRC_ALPHA_SATURATE,776,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SRC_COLOR,768,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_STACK_OVERFLOW,1283,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_STACK_UNDERFLOW,1284,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_STENCIL_BITS,3415,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_STENCIL_BUFFER_BIT,1024,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_STENCIL_TEST,2960,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_SUBPIXEL_BITS,3408,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE,5890,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE_2D,3553,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE_COORD_ARRAY,32888,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE_ENV,8960,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE_ENV_COLOR,8705,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE_ENV_MODE,8704,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE_MAG_FILTER,10240,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE_MIN_FILTER,10241,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE_WRAP_S,10242,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE_WRAP_T,10243,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE0,33984,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE1,33985,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE10,33994,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE11,33995,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE12,33996,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE13,33997,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE14,33998,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE15,33999,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE16,34000,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE17,34001,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE18,34002,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE19,34003,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE2,33986,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE20,34004,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE21,34005,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE22,34006,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE23,34007,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE24,34008,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE25,34009,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE26,34010,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE27,34011,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE28,34012,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE29,34013,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE3,33987,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE30,34014,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE31,34015,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE4,33988,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE5,33989,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE6,33990,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE7,33991,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE8,33992,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TEXTURE9,33993,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TRIANGLE_FAN,6,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TRIANGLE_STRIP,5,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TRIANGLES,4,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_TRUE,1,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_UNPACK_ALIGNMENT,3317,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_UNSIGNED_BYTE,5121,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_UNSIGNED_SHORT,5123,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_UNSIGNED_SHORT_4_4_4_4,32819,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_UNSIGNED_SHORT_5_5_5_1,32820,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_UNSIGNED_SHORT_5_6_5,33635,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_VENDOR,7936,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_VERSION,7938,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_VERTEX_ARRAY,32884,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_XOR,5382,,,, +I,0,I:javax/microedition/khronos/opengles/GL10.GL_ZERO,0,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_ACTIVE_TEXTURE,34016,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_ADD_SIGNED,34164,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_ALPHA_SCALE,3356,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_ALPHA_TEST_FUNC,3009,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_ALPHA_TEST_REF,3010,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_ARRAY_BUFFER,34962,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_ARRAY_BUFFER_BINDING,34964,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_BLEND_DST,3040,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_BLEND_SRC,3041,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_BUFFER_ACCESS,35003,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_BUFFER_SIZE,34660,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_BUFFER_USAGE,34661,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_CLIENT_ACTIVE_TEXTURE,34017,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_CLIP_PLANE0,12288,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_CLIP_PLANE1,12289,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_CLIP_PLANE2,12290,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_CLIP_PLANE3,12291,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_CLIP_PLANE4,12292,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_CLIP_PLANE5,12293,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_COLOR_ARRAY_BUFFER_BINDING,34968,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_COLOR_ARRAY_POINTER,32912,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_COLOR_ARRAY_SIZE,32897,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_COLOR_ARRAY_STRIDE,32899,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_COLOR_ARRAY_TYPE,32898,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_COLOR_CLEAR_VALUE,3106,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_COLOR_WRITEMASK,3107,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_COMBINE,34160,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_COMBINE_ALPHA,34162,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_COMBINE_RGB,34161,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_CONSTANT,34166,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_COORD_REPLACE_OES,34914,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_CULL_FACE_MODE,2885,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_CURRENT_COLOR,2816,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_CURRENT_NORMAL,2818,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_CURRENT_TEXTURE_COORDS,2819,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_DEPTH_CLEAR_VALUE,2931,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_DEPTH_FUNC,2932,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_DEPTH_RANGE,2928,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_DEPTH_WRITEMASK,2930,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_DOT3_RGB,34478,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_DOT3_RGBA,34479,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_DYNAMIC_DRAW,35048,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_ELEMENT_ARRAY_BUFFER,34963,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_ELEMENT_ARRAY_BUFFER_BINDING,34965,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_FRONT_FACE,2886,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_GENERATE_MIPMAP,33169,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_GENERATE_MIPMAP_HINT,33170,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_INTERPOLATE,34165,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_LINE_WIDTH,2849,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_LOGIC_OP_MODE,3056,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_MATRIX_MODE,2976,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_MAX_CLIP_PLANES,3378,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_MODELVIEW_MATRIX,2982,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES,35213,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_MODELVIEW_STACK_DEPTH,2979,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_NORMAL_ARRAY_BUFFER_BINDING,34967,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_NORMAL_ARRAY_POINTER,32911,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_NORMAL_ARRAY_STRIDE,32895,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_NORMAL_ARRAY_TYPE,32894,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_OPERAND0_ALPHA,34200,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_OPERAND0_RGB,34192,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_OPERAND1_ALPHA,34201,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_OPERAND1_RGB,34193,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_OPERAND2_ALPHA,34202,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_OPERAND2_RGB,34194,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_POINT_DISTANCE_ATTENUATION,33065,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_POINT_FADE_THRESHOLD_SIZE,33064,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_POINT_SIZE,2833,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES,35743,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_POINT_SIZE_ARRAY_OES,35740,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_POINT_SIZE_ARRAY_POINTER_OES,35212,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_POINT_SIZE_ARRAY_STRIDE_OES,35211,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_POINT_SIZE_ARRAY_TYPE_OES,35210,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_POINT_SIZE_MAX,33063,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_POINT_SIZE_MIN,33062,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_POINT_SPRITE_OES,34913,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_POLYGON_OFFSET_FACTOR,32824,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_POLYGON_OFFSET_UNITS,10752,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_PREVIOUS,34168,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_PRIMARY_COLOR,34167,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_PROJECTION_MATRIX,2983,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES,35214,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_PROJECTION_STACK_DEPTH,2980,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_RGB_SCALE,34163,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_SAMPLE_BUFFERS,32936,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_SAMPLE_COVERAGE_INVERT,32939,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_SAMPLE_COVERAGE_VALUE,32938,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_SAMPLES,32937,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_SCISSOR_BOX,3088,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_SHADE_MODEL,2900,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_SRC0_ALPHA,34184,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_SRC0_RGB,34176,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_SRC1_ALPHA,34185,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_SRC1_RGB,34177,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_SRC2_ALPHA,34186,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_SRC2_RGB,34178,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_STATIC_DRAW,35044,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_STENCIL_CLEAR_VALUE,2961,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_STENCIL_FAIL,2964,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_STENCIL_FUNC,2962,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_STENCIL_PASS_DEPTH_FAIL,2965,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_STENCIL_PASS_DEPTH_PASS,2966,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_STENCIL_REF,2967,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_STENCIL_VALUE_MASK,2963,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_STENCIL_WRITEMASK,2968,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_SUBTRACT,34023,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_TEXTURE_BINDING_2D,32873,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING,34970,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_TEXTURE_COORD_ARRAY_POINTER,32914,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_TEXTURE_COORD_ARRAY_SIZE,32904,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_TEXTURE_COORD_ARRAY_STRIDE,32906,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_TEXTURE_COORD_ARRAY_TYPE,32905,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_TEXTURE_MATRIX,2984,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES,35215,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_TEXTURE_STACK_DEPTH,2981,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_VERTEX_ARRAY_BUFFER_BINDING,34966,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_VERTEX_ARRAY_POINTER,32910,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_VERTEX_ARRAY_SIZE,32890,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_VERTEX_ARRAY_STRIDE,32892,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_VERTEX_ARRAY_TYPE,32891,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_VIEWPORT,2978,,,, +I,0,I:javax/microedition/khronos/opengles/GL11.GL_WRITE_ONLY,35001,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES,35742,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_MATRIX_INDEX_ARRAY_OES,34884,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_MATRIX_INDEX_ARRAY_POINTER_OES,34889,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_MATRIX_INDEX_ARRAY_SIZE_OES,34886,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_MATRIX_INDEX_ARRAY_STRIDE_OES,34888,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_MATRIX_INDEX_ARRAY_TYPE_OES,34887,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_MATRIX_PALETTE_OES,34880,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_MAX_PALETTE_MATRICES_OES,34882,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_MAX_VERTEX_UNITS_OES,34468,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_TEXTURE_CROP_RECT_OES,35741,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_WEIGHT_ARRAY_BUFFER_BINDING_OES,34974,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_WEIGHT_ARRAY_OES,34477,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_WEIGHT_ARRAY_POINTER_OES,34476,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_WEIGHT_ARRAY_SIZE_OES,34475,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_WEIGHT_ARRAY_STRIDE_OES,34474,,,, +I,0,I:javax/microedition/khronos/opengles/GL11Ext.GL_WEIGHT_ARRAY_TYPE_OES,34473,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_BLEND_DST_ALPHA,32970,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_BLEND_DST_RGB,32968,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_BLEND_EQUATION,32777,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_BLEND_EQUATION_ALPHA,34877,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_BLEND_EQUATION_RGB,32777,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_BLEND_SRC_ALPHA,32971,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_BLEND_SRC_RGB,32969,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT0_OES,36064,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT1_OES,36065,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT10_OES,36074,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT11_OES,36075,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT12_OES,36076,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT13_OES,36077,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT14_OES,36078,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT15_OES,36079,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT2_OES,36066,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT3_OES,36067,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT4_OES,36068,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT5_OES,36069,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT6_OES,36070,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT7_OES,36071,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT8_OES,36072,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_COLOR_ATTACHMENT9_OES,36073,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_DECR_WRAP,34056,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_DEPTH_ATTACHMENT_OES,36096,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_DEPTH_COMPONENT,6402,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_DEPTH_COMPONENT16,33189,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_DEPTH_COMPONENT24,33190,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_DEPTH_COMPONENT32,33191,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES,36049,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES,36048,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES,36051,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES,36050,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FRAMEBUFFER_BINDING_OES,36006,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FRAMEBUFFER_COMPLETE_OES,36053,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES,36054,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES,36057,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES,36059,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES,36058,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES,36055,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES,36060,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FRAMEBUFFER_OES,36160,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FRAMEBUFFER_UNSUPPORTED_OES,36061,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FUNC_ADD,32774,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FUNC_REVERSE_SUBTRACT,32779,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_FUNC_SUBTRACT,32778,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_INCR_WRAP,34055,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_INVALID_FRAMEBUFFER_OPERATION_OES,1286,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_MAX_COLOR_ATTACHMENTS_OES,36063,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_MAX_CUBE_MAP_TEXTURE_SIZE,34076,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_MAX_RENDERBUFFER_SIZE_OES,34024,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_MIRRORED_REPEAT,33648,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_NORMAL_MAP,34065,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_REFLECTION_MAP,34066,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RENDERBUFFER_ALPHA_SIZE_OES,36179,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RENDERBUFFER_BINDING_OES,36007,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RENDERBUFFER_BLUE_SIZE_OES,36178,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RENDERBUFFER_DEPTH_SIZE_OES,36180,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RENDERBUFFER_GREEN_SIZE_OES,36177,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RENDERBUFFER_HEIGHT_OES,36163,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RENDERBUFFER_INTERNAL_FORMAT_OES,36164,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RENDERBUFFER_OES,36161,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RENDERBUFFER_RED_SIZE_OES,36176,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RENDERBUFFER_STENCIL_SIZE_OES,36181,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RENDERBUFFER_WIDTH_OES,36162,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RGB5_A1,32855,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RGB565_OES,36194,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RGB8,32849,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RGBA4,32854,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_RGBA8,32856,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_STENCIL_ATTACHMENT_OES,36128,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_STENCIL_INDEX,6401,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_STENCIL_INDEX1_OES,36166,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_STENCIL_INDEX4_OES,36167,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_STENCIL_INDEX8_OES,36168,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_STR,-1,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_TEXTURE_BINDING_CUBE_MAP,34068,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_TEXTURE_CUBE_MAP,34067,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,34070,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,34072,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,34074,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_TEXTURE_CUBE_MAP_POSITIVE_X,34069,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,34071,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_TEXTURE_CUBE_MAP_POSITIVE_Z,34073,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_TEXTURE_GEN_MODE,9472,,,, +I,0,I:javax/microedition/khronos/opengles/GL11ExtensionPack.GL_TEXTURE_GEN_STR,36192,,,, +I,0,I:org/apache/http/conn/routing/HttpRouteDirector.COMPLETE,0,,,, +I,0,I:org/apache/http/conn/routing/HttpRouteDirector.CONNECT_PROXY,2,,,, +I,0,I:org/apache/http/conn/routing/HttpRouteDirector.CONNECT_TARGET,1,,,, +I,0,I:org/apache/http/conn/routing/HttpRouteDirector.LAYER_PROTOCOL,5,,,, +I,0,I:org/apache/http/conn/routing/HttpRouteDirector.TUNNEL_PROXY,4,,,, +I,0,I:org/apache/http/conn/routing/HttpRouteDirector.TUNNEL_TARGET,3,,,, +I,0,I:org/apache/http/conn/routing/HttpRouteDirector.UNREACHABLE,-1,,,, +I,0,I:org/apache/http/entity/ContentLengthStrategy.CHUNKED,-2,,,, +I,0,I:org/apache/http/entity/ContentLengthStrategy.IDENTITY,-1,,,, +I,0,I:org/apache/http/HttpStatus.SC_ACCEPTED,202,,,, +I,0,I:org/apache/http/HttpStatus.SC_BAD_GATEWAY,502,,,, +I,0,I:org/apache/http/HttpStatus.SC_BAD_REQUEST,400,,,, +I,0,I:org/apache/http/HttpStatus.SC_CONFLICT,409,,,, +I,0,I:org/apache/http/HttpStatus.SC_CONTINUE,100,,,, +I,0,I:org/apache/http/HttpStatus.SC_CREATED,201,,,, +I,0,I:org/apache/http/HttpStatus.SC_EXPECTATION_FAILED,417,,,, +I,0,I:org/apache/http/HttpStatus.SC_FAILED_DEPENDENCY,424,,,, +I,0,I:org/apache/http/HttpStatus.SC_FORBIDDEN,403,,,, +I,0,I:org/apache/http/HttpStatus.SC_GATEWAY_TIMEOUT,504,,,, +I,0,I:org/apache/http/HttpStatus.SC_GONE,410,,,, +I,0,I:org/apache/http/HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED,505,,,, +I,0,I:org/apache/http/HttpStatus.SC_INSUFFICIENT_SPACE_ON_RESOURCE,419,,,, +I,0,I:org/apache/http/HttpStatus.SC_INSUFFICIENT_STORAGE,507,,,, +I,0,I:org/apache/http/HttpStatus.SC_INTERNAL_SERVER_ERROR,500,,,, +I,0,I:org/apache/http/HttpStatus.SC_LENGTH_REQUIRED,411,,,, +I,0,I:org/apache/http/HttpStatus.SC_LOCKED,423,,,, +I,0,I:org/apache/http/HttpStatus.SC_METHOD_FAILURE,420,,,, +I,0,I:org/apache/http/HttpStatus.SC_METHOD_NOT_ALLOWED,405,,,, +I,0,I:org/apache/http/HttpStatus.SC_MOVED_PERMANENTLY,301,,,, +I,0,I:org/apache/http/HttpStatus.SC_MOVED_TEMPORARILY,302,,,, +I,0,I:org/apache/http/HttpStatus.SC_MULTI_STATUS,207,,,, +I,0,I:org/apache/http/HttpStatus.SC_MULTIPLE_CHOICES,300,,,, +I,0,I:org/apache/http/HttpStatus.SC_NO_CONTENT,204,,,, +I,0,I:org/apache/http/HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION,203,,,, +I,0,I:org/apache/http/HttpStatus.SC_NOT_ACCEPTABLE,406,,,, +I,0,I:org/apache/http/HttpStatus.SC_NOT_FOUND,404,,,, +I,0,I:org/apache/http/HttpStatus.SC_NOT_IMPLEMENTED,501,,,, +I,0,I:org/apache/http/HttpStatus.SC_NOT_MODIFIED,304,,,, +I,0,I:org/apache/http/HttpStatus.SC_OK,200,,,, +I,0,I:org/apache/http/HttpStatus.SC_PARTIAL_CONTENT,206,,,, +I,0,I:org/apache/http/HttpStatus.SC_PAYMENT_REQUIRED,402,,,, +I,0,I:org/apache/http/HttpStatus.SC_PRECONDITION_FAILED,412,,,, +I,0,I:org/apache/http/HttpStatus.SC_PROCESSING,102,,,, +I,0,I:org/apache/http/HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED,407,,,, +I,0,I:org/apache/http/HttpStatus.SC_REQUEST_TIMEOUT,408,,,, +I,0,I:org/apache/http/HttpStatus.SC_REQUEST_TOO_LONG,413,,,, +I,0,I:org/apache/http/HttpStatus.SC_REQUEST_URI_TOO_LONG,414,,,, +I,0,I:org/apache/http/HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE,416,,,, +I,0,I:org/apache/http/HttpStatus.SC_RESET_CONTENT,205,,,, +I,0,I:org/apache/http/HttpStatus.SC_SEE_OTHER,303,,,, +I,0,I:org/apache/http/HttpStatus.SC_SERVICE_UNAVAILABLE,503,,,, +I,0,I:org/apache/http/HttpStatus.SC_SWITCHING_PROTOCOLS,101,,,, +I,0,I:org/apache/http/HttpStatus.SC_TEMPORARY_REDIRECT,307,,,, +I,0,I:org/apache/http/HttpStatus.SC_UNAUTHORIZED,401,,,, +I,0,I:org/apache/http/HttpStatus.SC_UNPROCESSABLE_ENTITY,422,,,, +I,0,I:org/apache/http/HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE,415,,,, +I,0,I:org/apache/http/HttpStatus.SC_USE_PROXY,305,,,, +I,0,I:org/w3c/dom/TypeInfo.DERIVATION_EXTENSION,2,,,, +I,0,I:org/w3c/dom/TypeInfo.DERIVATION_LIST,8,,,, +I,0,I:org/w3c/dom/TypeInfo.DERIVATION_RESTRICTION,1,,,, +I,0,I:org/w3c/dom/TypeInfo.DERIVATION_UNION,4,,,, +E,10,I:org/xmlpull/v1/XmlPullParser.CDSECT,5,Org.XmlPull.V1.XmlPullParserNode,Cdsect,keep, +E,10,I:org/xmlpull/v1/XmlPullParser.COMMENT,9,Org.XmlPull.V1.XmlPullParserNode,Comment,keep, +E,10,I:org/xmlpull/v1/XmlPullParser.DOCDECL,10,Org.XmlPull.V1.XmlPullParserNode,Docdecl,keep, +E,10,I:org/xmlpull/v1/XmlPullParser.END_DOCUMENT,1,Org.XmlPull.V1.XmlPullParserNode,EndDocument,keep, +E,10,I:org/xmlpull/v1/XmlPullParser.END_TAG,3,Org.XmlPull.V1.XmlPullParserNode,EndTag,keep, +E,10,I:org/xmlpull/v1/XmlPullParser.ENTITY_REF,6,Org.XmlPull.V1.XmlPullParserNode,EntityRef,keep, +E,10,I:org/xmlpull/v1/XmlPullParser.IGNORABLE_WHITESPACE,7,Org.XmlPull.V1.XmlPullParserNode,IgnorableWhitespace,keep, +E,10,I:org/xmlpull/v1/XmlPullParser.PROCESSING_INSTRUCTION,8,Org.XmlPull.V1.XmlPullParserNode,ProcessingInstruction,keep, +E,10,I:org/xmlpull/v1/XmlPullParser.START_DOCUMENT,0,Org.XmlPull.V1.XmlPullParserNode,StartDocument,keep, +E,10,I:org/xmlpull/v1/XmlPullParser.START_TAG,2,Org.XmlPull.V1.XmlPullParserNode,StartTag,keep, +E,10,I:org/xmlpull/v1/XmlPullParser.TEXT,4,Org.XmlPull.V1.XmlPullParserNode,Text,keep, +E,10,java/awt/font/NumericShaper.ALL_RANGES,524287,Java.Awt.Font.Ranges,AllRanges,remove, +E,10,java/awt/font/NumericShaper.ARABIC,2,Java.Awt.Font.Ranges,Arabic,remove, +E,10,java/awt/font/NumericShaper.BENGALI,16,Java.Awt.Font.Ranges,Bengali,remove, +E,10,java/awt/font/NumericShaper.DEVANAGARI,8,Java.Awt.Font.Ranges,Devanagari,remove, +E,10,java/awt/font/NumericShaper.EASTERN_ARABIC,4,Java.Awt.Font.Ranges,EasternArabic,remove, +E,10,java/awt/font/NumericShaper.ETHIOPIC,65536,Java.Awt.Font.Ranges,Ethiopic,remove, +E,10,java/awt/font/NumericShaper.EUROPEAN,1,Java.Awt.Font.Ranges,European,remove, +E,10,java/awt/font/NumericShaper.GUJARATI,64,Java.Awt.Font.Ranges,Gujarati,remove, +E,10,java/awt/font/NumericShaper.GURMUKHI,32,Java.Awt.Font.Ranges,Gurmukhi,remove, +E,10,java/awt/font/NumericShaper.KANNADA,1024,Java.Awt.Font.Ranges,Kannada,remove, +E,10,java/awt/font/NumericShaper.KHMER,131072,Java.Awt.Font.Ranges,Khmer,remove, +E,10,java/awt/font/NumericShaper.LAO,8192,Java.Awt.Font.Ranges,Lao,remove, +E,10,java/awt/font/NumericShaper.MALAYALAM,2048,Java.Awt.Font.Ranges,Malayalam,remove, +E,10,java/awt/font/NumericShaper.MONGOLIAN,262144,Java.Awt.Font.Ranges,Mongolian,remove, +E,10,java/awt/font/NumericShaper.MYANMAR,32768,Java.Awt.Font.Ranges,Myanmar,remove, +E,10,java/awt/font/NumericShaper.ORIYA,128,Java.Awt.Font.Ranges,Oriya,remove, +E,10,java/awt/font/NumericShaper.TAMIL,256,Java.Awt.Font.Ranges,Tamil,remove, +E,10,java/awt/font/NumericShaper.TELUGU,512,Java.Awt.Font.Ranges,Telugu,remove, +E,10,java/awt/font/NumericShaper.THAI,4096,Java.Awt.Font.Ranges,Thai,remove, +E,10,java/awt/font/NumericShaper.TIBETAN,16384,Java.Awt.Font.Ranges,Tibetan,remove, +I,0,java/io/PipedInputStream.PIPE_SIZE,1024,,,, +E,10,java/io/StreamTokenizer.TT_EOF,-1,Java.IO.TokenType,Eof,remove, +E,10,java/io/StreamTokenizer.TT_EOL,10,Java.IO.TokenType,Eol,remove, +E,10,java/io/StreamTokenizer.TT_NUMBER,-2,Java.IO.TokenType,Number,remove, +E,10,java/io/StreamTokenizer.TT_WORD,-3,Java.IO.TokenType,Word,remove, +I,24,java/lang/Byte.BYTES,1,,,, +I,0,java/lang/Byte.SIZE,8,,,, +I,24,java/lang/Character.BYTES,2,,,, +I,0,java/lang/Character.MAX_CODE_POINT,1114111,,,, +I,0,java/lang/Character.MAX_RADIX,36,,,, +I,0,java/lang/Character.MIN_CODE_POINT,0,,,, +I,0,java/lang/Character.MIN_RADIX,2,,,, +I,0,java/lang/Character.MIN_SUPPLEMENTARY_CODE_POINT,65536,,,, +I,0,java/lang/Character.SIZE,16,,,, +I,24,java/lang/Double.BYTES,8,,,, +I,0,java/lang/Double.MAX_EXPONENT,1023,,,, +I,0,java/lang/Double.MIN_EXPONENT,-1022,,,, +I,0,java/lang/Double.SIZE,64,,,, +I,24,java/lang/Float.BYTES,4,,,, +I,0,java/lang/Float.MAX_EXPONENT,127,,,, +I,0,java/lang/Float.MIN_EXPONENT,-126,,,, +I,0,java/lang/Float.SIZE,32,,,, +I,24,java/lang/Integer.BYTES,4,,,, +I,0,java/lang/Integer.MAX_VALUE,2147483647,,,, +I,0,java/lang/Integer.MIN_VALUE,-2147483648,,,, +I,0,java/lang/Integer.SIZE,32,,,, +E,26,java/lang/invoke/MethodHandles$Lookup.PACKAGE,8,Java.Lang.Invoke.MethodLookupModes,Package,remove, +E,26,java/lang/invoke/MethodHandles$Lookup.PRIVATE,2,Java.Lang.Invoke.MethodLookupModes,Private,remove, +E,26,java/lang/invoke/MethodHandles$Lookup.PROTECTED,4,Java.Lang.Invoke.MethodLookupModes,Protected,remove, +E,26,java/lang/invoke/MethodHandles$Lookup.PUBLIC,1,Java.Lang.Invoke.MethodLookupModes,Public,remove, +I,24,java/lang/Long.BYTES,8,,,, +I,0,java/lang/Long.SIZE,64,,,, +I,0,java/lang/reflect/Modifier.ABSTRACT,1024,,,, +I,0,java/lang/reflect/Modifier.FINAL,16,,,, +I,0,java/lang/reflect/Modifier.INTERFACE,512,,,, +I,0,java/lang/reflect/Modifier.NATIVE,256,,,, +I,0,java/lang/reflect/Modifier.PRIVATE,2,,,, +I,0,java/lang/reflect/Modifier.PROTECTED,4,,,, +I,0,java/lang/reflect/Modifier.PUBLIC,1,,,, +I,0,java/lang/reflect/Modifier.STATIC,8,,,, +I,0,java/lang/reflect/Modifier.STRICT,2048,,,, +I,0,java/lang/reflect/Modifier.SYNCHRONIZED,32,,,, +I,0,java/lang/reflect/Modifier.TRANSIENT,128,,,, +I,0,java/lang/reflect/Modifier.VOLATILE,64,,,, +I,24,java/lang/Short.BYTES,2,,,, +I,0,java/lang/Short.SIZE,16,,,, +I,0,java/lang/Thread.MAX_PRIORITY,10,,,, +I,0,java/lang/Thread.MIN_PRIORITY,1,,,, +I,0,java/lang/Thread.NORM_PRIORITY,5,,,, +E,10,java/math/BigDecimal.ROUND_CEILING,2,Java.Math.RoundOptions,Ceiling,remove, +E,10,java/math/BigDecimal.ROUND_DOWN,1,Java.Math.RoundOptions,Down,remove, +E,10,java/math/BigDecimal.ROUND_FLOOR,3,Java.Math.RoundOptions,Floor,remove, +E,10,java/math/BigDecimal.ROUND_HALF_DOWN,5,Java.Math.RoundOptions,HalfDown,remove, +E,10,java/math/BigDecimal.ROUND_HALF_EVEN,6,Java.Math.RoundOptions,HalfEven,remove, +E,10,java/math/BigDecimal.ROUND_HALF_UP,4,Java.Math.RoundOptions,HalfUp,remove, +E,10,java/math/BigDecimal.ROUND_UNNECESSARY,7,Java.Math.RoundOptions,Unnecessary,remove, +E,10,java/math/BigDecimal.ROUND_UP,0,Java.Math.RoundOptions,Up,remove, +E,10,java/net/HttpURLConnection.HTTP_ACCEPTED,202,Java.Net.HttpStatus,Accepted,remove, +E,10,java/net/HttpURLConnection.HTTP_BAD_GATEWAY,502,Java.Net.HttpStatus,BadGateway,remove, +E,10,java/net/HttpURLConnection.HTTP_BAD_METHOD,405,Java.Net.HttpStatus,BadMethod,remove, +E,10,java/net/HttpURLConnection.HTTP_BAD_REQUEST,400,Java.Net.HttpStatus,BadRequest,remove, +E,10,java/net/HttpURLConnection.HTTP_CLIENT_TIMEOUT,408,Java.Net.HttpStatus,ClientTimeout,remove, +E,10,java/net/HttpURLConnection.HTTP_CONFLICT,409,Java.Net.HttpStatus,Conflict,remove, +E,10,java/net/HttpURLConnection.HTTP_CREATED,201,Java.Net.HttpStatus,Created,remove, +E,10,java/net/HttpURLConnection.HTTP_ENTITY_TOO_LARGE,413,Java.Net.HttpStatus,EntityTooLarge,remove, +E,10,java/net/HttpURLConnection.HTTP_FORBIDDEN,403,Java.Net.HttpStatus,Forbidden,remove, +E,10,java/net/HttpURLConnection.HTTP_GATEWAY_TIMEOUT,504,Java.Net.HttpStatus,GatewayTimeout,remove, +E,10,java/net/HttpURLConnection.HTTP_GONE,410,Java.Net.HttpStatus,Gone,remove, +E,10,java/net/HttpURLConnection.HTTP_INTERNAL_ERROR,500,Java.Net.HttpStatus,InternalError,remove, +E,10,java/net/HttpURLConnection.HTTP_LENGTH_REQUIRED,411,Java.Net.HttpStatus,LengthRequired,remove, +E,10,java/net/HttpURLConnection.HTTP_MOVED_PERM,301,Java.Net.HttpStatus,MovedPerm,remove, +E,10,java/net/HttpURLConnection.HTTP_MOVED_TEMP,302,Java.Net.HttpStatus,MovedTemp,remove, +E,10,java/net/HttpURLConnection.HTTP_MULT_CHOICE,300,Java.Net.HttpStatus,MultChoice,remove, +E,10,java/net/HttpURLConnection.HTTP_NO_CONTENT,204,Java.Net.HttpStatus,NoContent,remove, +E,10,java/net/HttpURLConnection.HTTP_NOT_ACCEPTABLE,406,Java.Net.HttpStatus,NotAcceptable,remove, +E,10,java/net/HttpURLConnection.HTTP_NOT_AUTHORITATIVE,203,Java.Net.HttpStatus,NotAuthoritative,remove, +E,10,java/net/HttpURLConnection.HTTP_NOT_FOUND,404,Java.Net.HttpStatus,NotFound,remove, +E,10,java/net/HttpURLConnection.HTTP_NOT_IMPLEMENTED,501,Java.Net.HttpStatus,NotImplemented,remove, +E,10,java/net/HttpURLConnection.HTTP_NOT_MODIFIED,304,Java.Net.HttpStatus,NotModified,remove, +E,10,java/net/HttpURLConnection.HTTP_OK,200,Java.Net.HttpStatus,Ok,remove, +E,10,java/net/HttpURLConnection.HTTP_PARTIAL,206,Java.Net.HttpStatus,Partial,remove, +E,10,java/net/HttpURLConnection.HTTP_PAYMENT_REQUIRED,402,Java.Net.HttpStatus,PaymentRequired,remove, +E,10,java/net/HttpURLConnection.HTTP_PRECON_FAILED,412,Java.Net.HttpStatus,PreconFailed,remove, +E,10,java/net/HttpURLConnection.HTTP_PROXY_AUTH,407,Java.Net.HttpStatus,ProxyAuth,remove, +E,10,java/net/HttpURLConnection.HTTP_REQ_TOO_LONG,414,Java.Net.HttpStatus,ReqTooLong,remove, +E,10,java/net/HttpURLConnection.HTTP_RESET,205,Java.Net.HttpStatus,Reset,remove, +E,10,java/net/HttpURLConnection.HTTP_SEE_OTHER,303,Java.Net.HttpStatus,SeeOther,remove, +E,10,java/net/HttpURLConnection.HTTP_SERVER_ERROR,500,Java.Net.HttpStatus,ServerError,remove, +E,10,java/net/HttpURLConnection.HTTP_UNAUTHORIZED,401,Java.Net.HttpStatus,Unauthorized,remove, +E,10,java/net/HttpURLConnection.HTTP_UNAVAILABLE,503,Java.Net.HttpStatus,Unavailable,remove, +E,10,java/net/HttpURLConnection.HTTP_UNSUPPORTED_TYPE,415,Java.Net.HttpStatus,UnsupportedType,remove, +E,10,java/net/HttpURLConnection.HTTP_USE_PROXY,305,Java.Net.HttpStatus,UseProxy,remove, +E,10,java/net/HttpURLConnection.HTTP_VERSION,505,Java.Net.HttpStatus,Version,remove, +A,0,,0,Java.Net.IDNFlags,None,remove,flags +E,10,java/net/IDN.ALLOW_UNASSIGNED,1,Java.Net.IDNFlags,AllowUnassigned,remove,flags +E,10,java/net/IDN.USE_STD3_ASCII_RULES,2,Java.Net.IDNFlags,UseStd3AsciiRules,remove,flags +A,0,,0,Java.Nio.Channels.Operations,None,remove, +E,10,java/nio/channels/SelectionKey.OP_ACCEPT,16,Java.Nio.Channels.Operations,Accept,remove, +E,10,java/nio/channels/SelectionKey.OP_CONNECT,8,Java.Nio.Channels.Operations,Connect,remove, +E,10,java/nio/channels/SelectionKey.OP_READ,1,Java.Nio.Channels.Operations,Read,remove, +E,10,java/nio/channels/SelectionKey.OP_WRITE,4,Java.Nio.Channels.Operations,Write,remove, +E,10,java/security/Signature.SIGN,2,Java.Security.SignatureState,Sign,remove, +E,10,java/security/Signature.UNINITIALIZED,0,Java.Security.SignatureState,Uninitialized,remove, +E,10,java/security/Signature.VERIFY,3,Java.Security.SignatureState,Verify,remove, +I,0,java/sql/Types.ARRAY,2003,,,, +I,0,java/sql/Types.BIGINT,-5,,,, +I,0,java/sql/Types.BINARY,-2,,,, +I,0,java/sql/Types.BIT,-7,,,, +I,0,java/sql/Types.BLOB,2004,,,, +I,0,java/sql/Types.BOOLEAN,16,,,, +I,0,java/sql/Types.CHAR,1,,,, +I,0,java/sql/Types.CLOB,2005,,,, +I,0,java/sql/Types.DATALINK,70,,,, +I,0,java/sql/Types.DATE,91,,,, +I,0,java/sql/Types.DECIMAL,3,,,, +I,0,java/sql/Types.DISTINCT,2001,,,, +I,0,java/sql/Types.DOUBLE,8,,,, +I,0,java/sql/Types.FLOAT,6,,,, +I,0,java/sql/Types.INTEGER,4,,,, +I,0,java/sql/Types.JAVA_OBJECT,2000,,,, +I,0,java/sql/Types.LONGNVARCHAR,-16,,,, +I,0,java/sql/Types.LONGVARBINARY,-4,,,, +I,0,java/sql/Types.LONGVARCHAR,-1,,,, +I,0,java/sql/Types.NCHAR,-15,,,, +I,0,java/sql/Types.NCLOB,2011,,,, +I,0,java/sql/Types.NULL,0,,,, +I,0,java/sql/Types.NUMERIC,2,,,, +I,0,java/sql/Types.NVARCHAR,-9,,,, +I,0,java/sql/Types.OTHER,1111,,,, +I,0,java/sql/Types.REAL,7,,,, +I,0,java/sql/Types.REF,2006,,,, +I,0,java/sql/Types.ROWID,-8,,,, +I,0,java/sql/Types.SMALLINT,5,,,, +I,0,java/sql/Types.SQLXML,2009,,,, +I,0,java/sql/Types.STRUCT,2002,,,, +I,0,java/sql/Types.TIME,92,,,, +I,0,java/sql/Types.TIMESTAMP,93,,,, +I,0,java/sql/Types.TINYINT,-6,,,, +I,0,java/sql/Types.VARBINARY,-3,,,, +I,0,java/sql/Types.VARCHAR,12,,,, +I,0,java/text/Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT,-2,,,, +I,0,java/text/Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT,-1,,,, +I,0,java/text/Bidi.DIRECTION_LEFT_TO_RIGHT,0,,,, +I,0,java/text/Bidi.DIRECTION_RIGHT_TO_LEFT,1,,,, +I,0,java/text/BreakIterator.DONE,-1,,,, +I,0,java/text/CollationElementIterator.NULLORDER,-1,,,, +I,0,java/text/Collator.CANONICAL_DECOMPOSITION,1,,,, +I,0,java/text/Collator.FULL_DECOMPOSITION,2,,,, +I,0,java/text/Collator.IDENTICAL,3,,,, +I,0,java/text/Collator.NO_DECOMPOSITION,0,,,, +I,0,java/text/Collator.PRIMARY,0,,,, +I,0,java/text/Collator.SECONDARY,1,,,, +I,0,java/text/Collator.TERTIARY,2,,,, +I,0,java/text/DateFormat.AM_PM_FIELD,14,,,, +I,0,java/text/DateFormat.DATE_FIELD,3,,,, +I,0,java/text/DateFormat.DAY_OF_WEEK_FIELD,9,,,, +I,0,java/text/DateFormat.DAY_OF_WEEK_IN_MONTH_FIELD,11,,,, +I,0,java/text/DateFormat.DAY_OF_YEAR_FIELD,10,,,, +I,0,java/text/DateFormat.DEFAULT,2,,,, +I,0,java/text/DateFormat.ERA_FIELD,0,,,, +I,0,java/text/DateFormat.FULL,0,,,, +I,0,java/text/DateFormat.HOUR_OF_DAY0_FIELD,5,,,, +I,0,java/text/DateFormat.HOUR_OF_DAY1_FIELD,4,,,, +I,0,java/text/DateFormat.HOUR0_FIELD,16,,,, +I,0,java/text/DateFormat.HOUR1_FIELD,15,,,, +I,0,java/text/DateFormat.LONG,1,,,, +I,0,java/text/DateFormat.MEDIUM,2,,,, +I,0,java/text/DateFormat.MILLISECOND_FIELD,8,,,, +I,0,java/text/DateFormat.MINUTE_FIELD,6,,,, +I,0,java/text/DateFormat.MONTH_FIELD,2,,,, +I,0,java/text/DateFormat.SECOND_FIELD,7,,,, +I,0,java/text/DateFormat.SHORT,3,,,, +I,0,java/text/DateFormat.TIMEZONE_FIELD,17,,,, +I,0,java/text/DateFormat.WEEK_OF_MONTH_FIELD,13,,,, +I,0,java/text/DateFormat.WEEK_OF_YEAR_FIELD,12,,,, +I,0,java/text/DateFormat.YEAR_FIELD,1,,,, +I,0,java/text/NumberFormat.FRACTION_FIELD,1,,,, +I,0,java/text/NumberFormat.INTEGER_FIELD,0,,,, +I,26,java/time/Year.MAX_VALUE,999999999,,,, +I,26,java/time/Year.MIN_VALUE,-999999999,,,, +E,10,java/util/Calendar.ALL_STYLES,0,Java.Util.CalendarStyle,AllStyles,remove, +I,0,java/util/Calendar.AM,0,,,, +E,10,java/util/Calendar.AM_PM,9,Java.Util.CalendarField,AmPm,remove, +I,0,java/util/Calendar.APRIL,3,,,, +I,0,java/util/Calendar.AUGUST,7,,,, +E,10,java/util/Calendar.DATE,5,Java.Util.CalendarField,Date,remove, +E,10,java/util/Calendar.DAY_OF_MONTH,5,Java.Util.CalendarField,DayOfMonth,remove, +E,10,java/util/Calendar.DAY_OF_WEEK,7,Java.Util.CalendarField,DayOfWeek,remove, +E,10,java/util/Calendar.DAY_OF_WEEK_IN_MONTH,8,Java.Util.CalendarField,DayOfWeekInMonth,remove, +E,10,java/util/Calendar.DAY_OF_YEAR,6,Java.Util.CalendarField,DayOfYear,remove, +I,0,java/util/Calendar.DECEMBER,11,,,, +E,10,java/util/Calendar.DST_OFFSET,16,Java.Util.CalendarField,DstOffset,remove, +E,10,java/util/Calendar.ERA,0,Java.Util.CalendarField,Era,remove, +I,0,java/util/Calendar.FEBRUARY,1,,,, +I,0,java/util/Calendar.FIELD_COUNT,17,,,, +I,0,java/util/Calendar.FRIDAY,6,,,, +E,10,java/util/Calendar.HOUR,10,Java.Util.CalendarField,Hour,remove, +E,10,java/util/Calendar.HOUR_OF_DAY,11,Java.Util.CalendarField,HourOfDay,remove, +I,0,java/util/Calendar.JANUARY,0,,,, +I,0,java/util/Calendar.JULY,6,,,, +I,0,java/util/Calendar.JUNE,5,,,, +E,10,java/util/Calendar.LONG,2,Java.Util.CalendarStyle,Long,remove, +I,26,java/util/Calendar.LONG_FORMAT,2,,,, +I,26,java/util/Calendar.LONG_STANDALONE,32770,,,, +I,0,java/util/Calendar.MARCH,2,,,, +I,0,java/util/Calendar.MAY,4,,,, +E,10,java/util/Calendar.MILLISECOND,14,Java.Util.CalendarField,Millisecond,remove, +E,10,java/util/Calendar.MINUTE,12,Java.Util.CalendarField,Minute,remove, +I,0,java/util/Calendar.MONDAY,2,,,, +E,10,java/util/Calendar.MONTH,2,Java.Util.CalendarField,Month,remove, +I,26,java/util/Calendar.NARROW_FORMAT,4,,,, +I,26,java/util/Calendar.NARROW_STANDALONE,32772,,,, +I,0,java/util/Calendar.NOVEMBER,10,,,, +I,0,java/util/Calendar.OCTOBER,9,,,, +I,0,java/util/Calendar.PM,1,,,, +I,0,java/util/Calendar.SATURDAY,7,,,, +E,10,java/util/Calendar.SECOND,13,Java.Util.CalendarField,Second,remove, +I,0,java/util/Calendar.SEPTEMBER,8,,,, +E,10,java/util/Calendar.SHORT,1,Java.Util.CalendarStyle,Short,remove, +I,26,java/util/Calendar.SHORT_FORMAT,1,,,, +I,26,java/util/Calendar.SHORT_STANDALONE,32769,,,, +I,0,java/util/Calendar.SUNDAY,1,,,, +I,0,java/util/Calendar.THURSDAY,5,,,, +I,0,java/util/Calendar.TUESDAY,3,,,, +I,0,java/util/Calendar.UNDECIMBER,12,,,, +I,0,java/util/Calendar.WEDNESDAY,4,,,, +E,10,java/util/Calendar.WEEK_OF_MONTH,4,Java.Util.CalendarField,WeekOfMonth,remove, +E,10,java/util/Calendar.WEEK_OF_YEAR,3,Java.Util.CalendarField,WeekOfYear,remove, +E,10,java/util/Calendar.YEAR,1,Java.Util.CalendarField,Year,remove, +E,10,java/util/Calendar.ZONE_OFFSET,15,Java.Util.CalendarField,ZoneOffset,remove, +E,10,java/util/FormattableFlags.ALTERNATE,4,Java.Util.FormatFlags,Alternate,remove,flags +E,10,java/util/FormattableFlags.LEFT_JUSTIFY,1,Java.Util.FormatFlags,LeftJustify,remove,flags +E,10,java/util/FormattableFlags.UPPERCASE,2,Java.Util.FormatFlags,Uppercase,remove,flags +I,0,java/util/GregorianCalendar.AD,1,,,, +I,0,java/util/GregorianCalendar.BC,0,,,, +I,29,java/util/jar/JarEntry.CENATT,36,,,, +I,29,java/util/jar/JarEntry.CENATX,38,,,, +I,29,java/util/jar/JarEntry.CENCOM,32,,,, +I,29,java/util/jar/JarEntry.CENCRC,16,,,, +I,29,java/util/jar/JarEntry.CENDSK,34,,,, +I,29,java/util/jar/JarEntry.CENEXT,30,,,, +I,29,java/util/jar/JarEntry.CENFLG,8,,,, +I,29,java/util/jar/JarEntry.CENHDR,46,,,, +I,29,java/util/jar/JarEntry.CENHOW,10,,,, +I,29,java/util/jar/JarEntry.CENLEN,24,,,, +I,29,java/util/jar/JarEntry.CENNAM,28,,,, +I,29,java/util/jar/JarEntry.CENOFF,42,,,, +I,29,java/util/jar/JarEntry.CENSIZ,20,,,, +I,29,java/util/jar/JarEntry.CENTIM,12,,,, +I,29,java/util/jar/JarEntry.CENVEM,4,,,, +I,29,java/util/jar/JarEntry.CENVER,6,,,, +I,29,java/util/jar/JarEntry.ENDCOM,20,,,, +I,29,java/util/jar/JarEntry.ENDHDR,22,,,, +I,29,java/util/jar/JarEntry.ENDOFF,16,,,, +I,29,java/util/jar/JarEntry.ENDSIZ,12,,,, +I,29,java/util/jar/JarEntry.ENDSUB,8,,,, +I,29,java/util/jar/JarEntry.ENDTOT,10,,,, +I,29,java/util/jar/JarEntry.EXTCRC,4,,,, +I,29,java/util/jar/JarEntry.EXTHDR,16,,,, +I,29,java/util/jar/JarEntry.EXTLEN,12,,,, +I,29,java/util/jar/JarEntry.EXTSIZ,8,,,, +I,29,java/util/jar/JarEntry.LOCCRC,14,,,, +I,29,java/util/jar/JarEntry.LOCEXT,28,,,, +I,29,java/util/jar/JarEntry.LOCFLG,6,,,, +I,29,java/util/jar/JarEntry.LOCHDR,30,,,, +I,29,java/util/jar/JarEntry.LOCHOW,8,,,, +I,29,java/util/jar/JarEntry.LOCLEN,22,,,, +I,29,java/util/jar/JarEntry.LOCNAM,26,,,, +I,29,java/util/jar/JarEntry.LOCSIZ,18,,,, +I,29,java/util/jar/JarEntry.LOCTIM,10,,,, +I,29,java/util/jar/JarEntry.LOCVER,4,,,, +I,29,java/util/jar/JarFile.CENATT,36,,,, +I,29,java/util/jar/JarFile.CENATX,38,,,, +I,29,java/util/jar/JarFile.CENCOM,32,,,, +I,29,java/util/jar/JarFile.CENCRC,16,,,, +I,29,java/util/jar/JarFile.CENDSK,34,,,, +I,29,java/util/jar/JarFile.CENEXT,30,,,, +I,29,java/util/jar/JarFile.CENFLG,8,,,, +I,29,java/util/jar/JarFile.CENHDR,46,,,, +I,29,java/util/jar/JarFile.CENHOW,10,,,, +I,29,java/util/jar/JarFile.CENLEN,24,,,, +I,29,java/util/jar/JarFile.CENNAM,28,,,, +I,29,java/util/jar/JarFile.CENOFF,42,,,, +I,29,java/util/jar/JarFile.CENSIZ,20,,,, +I,29,java/util/jar/JarFile.CENTIM,12,,,, +I,29,java/util/jar/JarFile.CENVEM,4,,,, +I,29,java/util/jar/JarFile.CENVER,6,,,, +I,29,java/util/jar/JarFile.ENDCOM,20,,,, +I,29,java/util/jar/JarFile.ENDHDR,22,,,, +I,29,java/util/jar/JarFile.ENDOFF,16,,,, +I,29,java/util/jar/JarFile.ENDSIZ,12,,,, +I,29,java/util/jar/JarFile.ENDSUB,8,,,, +I,29,java/util/jar/JarFile.ENDTOT,10,,,, +I,29,java/util/jar/JarFile.EXTCRC,4,,,, +I,29,java/util/jar/JarFile.EXTHDR,16,,,, +I,29,java/util/jar/JarFile.EXTLEN,12,,,, +I,29,java/util/jar/JarFile.EXTSIZ,8,,,, +I,29,java/util/jar/JarFile.LOCCRC,14,,,, +I,29,java/util/jar/JarFile.LOCEXT,28,,,, +I,29,java/util/jar/JarFile.LOCFLG,6,,,, +I,29,java/util/jar/JarFile.LOCHDR,30,,,, +I,29,java/util/jar/JarFile.LOCHOW,8,,,, +I,29,java/util/jar/JarFile.LOCLEN,22,,,, +I,29,java/util/jar/JarFile.LOCNAM,26,,,, +I,29,java/util/jar/JarFile.LOCSIZ,18,,,, +I,29,java/util/jar/JarFile.LOCTIM,10,,,, +I,29,java/util/jar/JarFile.LOCVER,4,,,, +I,29,java/util/jar/JarInputStream.CENATT,36,,,, +I,29,java/util/jar/JarInputStream.CENATX,38,,,, +I,29,java/util/jar/JarInputStream.CENCOM,32,,,, +I,29,java/util/jar/JarInputStream.CENCRC,16,,,, +I,29,java/util/jar/JarInputStream.CENDSK,34,,,, +I,29,java/util/jar/JarInputStream.CENEXT,30,,,, +I,29,java/util/jar/JarInputStream.CENFLG,8,,,, +I,29,java/util/jar/JarInputStream.CENHDR,46,,,, +I,29,java/util/jar/JarInputStream.CENHOW,10,,,, +I,29,java/util/jar/JarInputStream.CENLEN,24,,,, +I,29,java/util/jar/JarInputStream.CENNAM,28,,,, +I,29,java/util/jar/JarInputStream.CENOFF,42,,,, +I,29,java/util/jar/JarInputStream.CENSIZ,20,,,, +I,29,java/util/jar/JarInputStream.CENTIM,12,,,, +I,29,java/util/jar/JarInputStream.CENVEM,4,,,, +I,29,java/util/jar/JarInputStream.CENVER,6,,,, +I,29,java/util/jar/JarInputStream.ENDCOM,20,,,, +I,29,java/util/jar/JarInputStream.ENDHDR,22,,,, +I,29,java/util/jar/JarInputStream.ENDOFF,16,,,, +I,29,java/util/jar/JarInputStream.ENDSIZ,12,,,, +I,29,java/util/jar/JarInputStream.ENDSUB,8,,,, +I,29,java/util/jar/JarInputStream.ENDTOT,10,,,, +I,29,java/util/jar/JarInputStream.EXTCRC,4,,,, +I,29,java/util/jar/JarInputStream.EXTHDR,16,,,, +I,29,java/util/jar/JarInputStream.EXTLEN,12,,,, +I,29,java/util/jar/JarInputStream.EXTSIZ,8,,,, +I,29,java/util/jar/JarInputStream.LOCCRC,14,,,, +I,29,java/util/jar/JarInputStream.LOCEXT,28,,,, +I,29,java/util/jar/JarInputStream.LOCFLG,6,,,, +I,29,java/util/jar/JarInputStream.LOCHDR,30,,,, +I,29,java/util/jar/JarInputStream.LOCHOW,8,,,, +I,29,java/util/jar/JarInputStream.LOCLEN,22,,,, +I,29,java/util/jar/JarInputStream.LOCNAM,26,,,, +I,29,java/util/jar/JarInputStream.LOCSIZ,18,,,, +I,29,java/util/jar/JarInputStream.LOCTIM,10,,,, +I,29,java/util/jar/JarInputStream.LOCVER,4,,,, +I,29,java/util/jar/JarOutputStream.CENATT,36,,,, +I,29,java/util/jar/JarOutputStream.CENATX,38,,,, +I,29,java/util/jar/JarOutputStream.CENCOM,32,,,, +I,29,java/util/jar/JarOutputStream.CENCRC,16,,,, +I,29,java/util/jar/JarOutputStream.CENDSK,34,,,, +I,29,java/util/jar/JarOutputStream.CENEXT,30,,,, +I,29,java/util/jar/JarOutputStream.CENFLG,8,,,, +I,29,java/util/jar/JarOutputStream.CENHDR,46,,,, +I,29,java/util/jar/JarOutputStream.CENHOW,10,,,, +I,29,java/util/jar/JarOutputStream.CENLEN,24,,,, +I,29,java/util/jar/JarOutputStream.CENNAM,28,,,, +I,29,java/util/jar/JarOutputStream.CENOFF,42,,,, +I,29,java/util/jar/JarOutputStream.CENSIZ,20,,,, +I,29,java/util/jar/JarOutputStream.CENTIM,12,,,, +I,29,java/util/jar/JarOutputStream.CENVEM,4,,,, +I,29,java/util/jar/JarOutputStream.CENVER,6,,,, +I,29,java/util/jar/JarOutputStream.ENDCOM,20,,,, +I,29,java/util/jar/JarOutputStream.ENDHDR,22,,,, +I,29,java/util/jar/JarOutputStream.ENDOFF,16,,,, +I,29,java/util/jar/JarOutputStream.ENDSIZ,12,,,, +I,29,java/util/jar/JarOutputStream.ENDSUB,8,,,, +I,29,java/util/jar/JarOutputStream.ENDTOT,10,,,, +I,29,java/util/jar/JarOutputStream.EXTCRC,4,,,, +I,29,java/util/jar/JarOutputStream.EXTHDR,16,,,, +I,29,java/util/jar/JarOutputStream.EXTLEN,12,,,, +I,29,java/util/jar/JarOutputStream.EXTSIZ,8,,,, +I,29,java/util/jar/JarOutputStream.LOCCRC,14,,,, +I,29,java/util/jar/JarOutputStream.LOCEXT,28,,,, +I,29,java/util/jar/JarOutputStream.LOCFLG,6,,,, +I,29,java/util/jar/JarOutputStream.LOCHDR,30,,,, +I,29,java/util/jar/JarOutputStream.LOCHOW,8,,,, +I,29,java/util/jar/JarOutputStream.LOCLEN,22,,,, +I,29,java/util/jar/JarOutputStream.LOCNAM,26,,,, +I,29,java/util/jar/JarOutputStream.LOCSIZ,18,,,, +I,29,java/util/jar/JarOutputStream.LOCTIM,10,,,, +I,29,java/util/jar/JarOutputStream.LOCVER,4,,,, +I,0,java/util/logging/ErrorManager.CLOSE_FAILURE,3,,,, +I,0,java/util/logging/ErrorManager.FLUSH_FAILURE,2,,,, +I,0,java/util/logging/ErrorManager.FORMAT_FAILURE,5,,,, +I,0,java/util/logging/ErrorManager.GENERIC_FAILURE,0,,,, +I,0,java/util/logging/ErrorManager.OPEN_FAILURE,4,,,, +I,0,java/util/logging/ErrorManager.WRITE_FAILURE,1,,,, +I,0,java/util/prefs/Preferences.MAX_KEY_LENGTH,80,,,, +I,0,java/util/prefs/Preferences.MAX_NAME_LENGTH,80,,,, +I,0,java/util/prefs/Preferences.MAX_VALUE_LENGTH,8192,,,, +E,10,java/util/regex/Pattern.CANON_EQ,128,Java.Util.Regex.RegexOptions,CanonEq,remove, +E,10,java/util/regex/Pattern.CASE_INSENSITIVE,2,Java.Util.Regex.RegexOptions,CaseInsensitive,remove, +E,10,java/util/regex/Pattern.COMMENTS,4,Java.Util.Regex.RegexOptions,Comments,remove, +E,10,java/util/regex/Pattern.DOTALL,32,Java.Util.Regex.RegexOptions,Dotall,remove, +E,10,java/util/regex/Pattern.LITERAL,16,Java.Util.Regex.RegexOptions,Literal,remove, +E,10,java/util/regex/Pattern.MULTILINE,8,Java.Util.Regex.RegexOptions,Multiline,remove, +E,10,java/util/regex/Pattern.UNICODE_CASE,64,Java.Util.Regex.RegexOptions,UnicodeCase,remove, +E,24,java/util/regex/Pattern.UNICODE_CHARACTER_CLASS,256,Java.Util.Regex.RegexOptions,UnicodeCharacterClass,remove, +E,10,java/util/regex/Pattern.UNIX_LINES,1,Java.Util.Regex.RegexOptions,UnixLines,remove, +E,10,java/util/SimpleTimeZone.STANDARD_TIME,1,Java.Util.TimeZoneKind,StandardTime,remove, +E,10,java/util/SimpleTimeZone.UTC_TIME,2,Java.Util.TimeZoneKind,UtcTime,remove, +E,10,java/util/SimpleTimeZone.WALL_TIME,0,Java.Util.TimeZoneKind,WallTime,remove, +E,10,java/util/TimeZone.LONG,1,Java.Util.TimeZoneStyle,Long,remove, +E,10,java/util/TimeZone.SHORT,0,Java.Util.TimeZoneStyle,Short,remove, +I,0,java/util/zip/Deflater.BEST_COMPRESSION,9,,,, +I,0,java/util/zip/Deflater.BEST_SPEED,1,,,, +I,0,java/util/zip/Deflater.DEFAULT_COMPRESSION,-1,,,, +I,0,java/util/zip/Deflater.DEFAULT_STRATEGY,0,,,, +I,0,java/util/zip/Deflater.DEFLATED,8,,,, +I,0,java/util/zip/Deflater.FILTERED,1,,,, +I,19,java/util/zip/Deflater.FULL_FLUSH,3,,,, +I,0,java/util/zip/Deflater.HUFFMAN_ONLY,2,,,, +I,0,java/util/zip/Deflater.NO_COMPRESSION,0,,,, +I,19,java/util/zip/Deflater.NO_FLUSH,0,,,, +I,19,java/util/zip/Deflater.SYNC_FLUSH,2,,,, +I,0,java/util/zip/GZIPInputStream.GZIP_MAGIC,35615,,,, +I,21,java/util/zip/ZipEntry.CENATT,36,,,, +I,21,java/util/zip/ZipEntry.CENATX,38,,,, +I,21,java/util/zip/ZipEntry.CENCOM,32,,,, +I,21,java/util/zip/ZipEntry.CENCRC,16,,,, +I,21,java/util/zip/ZipEntry.CENDSK,34,,,, +I,21,java/util/zip/ZipEntry.CENEXT,30,,,, +I,21,java/util/zip/ZipEntry.CENFLG,8,,,, +I,21,java/util/zip/ZipEntry.CENHDR,46,,,, +I,21,java/util/zip/ZipEntry.CENHOW,10,,,, +I,21,java/util/zip/ZipEntry.CENLEN,24,,,, +I,21,java/util/zip/ZipEntry.CENNAM,28,,,, +I,21,java/util/zip/ZipEntry.CENOFF,42,,,, +I,21,java/util/zip/ZipEntry.CENSIZ,20,,,, +I,21,java/util/zip/ZipEntry.CENTIM,12,,,, +I,21,java/util/zip/ZipEntry.CENVEM,4,,,, +I,21,java/util/zip/ZipEntry.CENVER,6,,,, +I,0,java/util/zip/ZipEntry.DEFLATED,8,,,, +I,21,java/util/zip/ZipEntry.ENDCOM,20,,,, +I,21,java/util/zip/ZipEntry.ENDHDR,22,,,, +I,21,java/util/zip/ZipEntry.ENDOFF,16,,,, +I,21,java/util/zip/ZipEntry.ENDSIZ,12,,,, +I,21,java/util/zip/ZipEntry.ENDSUB,8,,,, +I,21,java/util/zip/ZipEntry.ENDTOT,10,,,, +I,21,java/util/zip/ZipEntry.EXTCRC,4,,,, +I,21,java/util/zip/ZipEntry.EXTHDR,16,,,, +I,21,java/util/zip/ZipEntry.EXTLEN,12,,,, +I,21,java/util/zip/ZipEntry.EXTSIZ,8,,,, +I,21,java/util/zip/ZipEntry.LOCCRC,14,,,, +I,21,java/util/zip/ZipEntry.LOCEXT,28,,,, +I,21,java/util/zip/ZipEntry.LOCFLG,6,,,, +I,21,java/util/zip/ZipEntry.LOCHDR,30,,,, +I,21,java/util/zip/ZipEntry.LOCHOW,8,,,, +I,21,java/util/zip/ZipEntry.LOCLEN,22,,,, +I,21,java/util/zip/ZipEntry.LOCNAM,26,,,, +I,21,java/util/zip/ZipEntry.LOCSIZ,18,,,, +I,21,java/util/zip/ZipEntry.LOCTIM,10,,,, +I,21,java/util/zip/ZipEntry.LOCVER,4,,,, +I,0,java/util/zip/ZipEntry.STORED,0,,,, +I,21,java/util/zip/ZipFile.CENATT,36,,,, +I,21,java/util/zip/ZipFile.CENATX,38,,,, +I,21,java/util/zip/ZipFile.CENCOM,32,,,, +I,21,java/util/zip/ZipFile.CENCRC,16,,,, +I,21,java/util/zip/ZipFile.CENDSK,34,,,, +I,21,java/util/zip/ZipFile.CENEXT,30,,,, +I,21,java/util/zip/ZipFile.CENFLG,8,,,, +I,21,java/util/zip/ZipFile.CENHDR,46,,,, +I,21,java/util/zip/ZipFile.CENHOW,10,,,, +I,21,java/util/zip/ZipFile.CENLEN,24,,,, +I,21,java/util/zip/ZipFile.CENNAM,28,,,, +I,21,java/util/zip/ZipFile.CENOFF,42,,,, +I,21,java/util/zip/ZipFile.CENSIZ,20,,,, +I,21,java/util/zip/ZipFile.CENTIM,12,,,, +I,21,java/util/zip/ZipFile.CENVEM,4,,,, +I,21,java/util/zip/ZipFile.CENVER,6,,,, +I,21,java/util/zip/ZipFile.ENDCOM,20,,,, +I,21,java/util/zip/ZipFile.ENDHDR,22,,,, +I,21,java/util/zip/ZipFile.ENDOFF,16,,,, +I,21,java/util/zip/ZipFile.ENDSIZ,12,,,, +I,21,java/util/zip/ZipFile.ENDSUB,8,,,, +I,21,java/util/zip/ZipFile.ENDTOT,10,,,, +I,21,java/util/zip/ZipFile.EXTCRC,4,,,, +I,21,java/util/zip/ZipFile.EXTHDR,16,,,, +I,21,java/util/zip/ZipFile.EXTLEN,12,,,, +I,21,java/util/zip/ZipFile.EXTSIZ,8,,,, +I,21,java/util/zip/ZipFile.LOCCRC,14,,,, +I,21,java/util/zip/ZipFile.LOCEXT,28,,,, +I,21,java/util/zip/ZipFile.LOCFLG,6,,,, +I,21,java/util/zip/ZipFile.LOCHDR,30,,,, +I,21,java/util/zip/ZipFile.LOCHOW,8,,,, +I,21,java/util/zip/ZipFile.LOCLEN,22,,,, +I,21,java/util/zip/ZipFile.LOCNAM,26,,,, +I,21,java/util/zip/ZipFile.LOCSIZ,18,,,, +I,21,java/util/zip/ZipFile.LOCTIM,10,,,, +I,21,java/util/zip/ZipFile.LOCVER,4,,,, +I,0,java/util/zip/ZipFile.OPEN_DELETE,4,,,, +I,0,java/util/zip/ZipFile.OPEN_READ,1,,,, +I,21,java/util/zip/ZipInputStream.CENATT,36,,,, +I,21,java/util/zip/ZipInputStream.CENATX,38,,,, +I,21,java/util/zip/ZipInputStream.CENCOM,32,,,, +I,21,java/util/zip/ZipInputStream.CENCRC,16,,,, +I,21,java/util/zip/ZipInputStream.CENDSK,34,,,, +I,21,java/util/zip/ZipInputStream.CENEXT,30,,,, +I,21,java/util/zip/ZipInputStream.CENFLG,8,,,, +I,21,java/util/zip/ZipInputStream.CENHDR,46,,,, +I,21,java/util/zip/ZipInputStream.CENHOW,10,,,, +I,21,java/util/zip/ZipInputStream.CENLEN,24,,,, +I,21,java/util/zip/ZipInputStream.CENNAM,28,,,, +I,21,java/util/zip/ZipInputStream.CENOFF,42,,,, +I,21,java/util/zip/ZipInputStream.CENSIZ,20,,,, +I,21,java/util/zip/ZipInputStream.CENTIM,12,,,, +I,21,java/util/zip/ZipInputStream.CENVEM,4,,,, +I,21,java/util/zip/ZipInputStream.CENVER,6,,,, +I,21,java/util/zip/ZipInputStream.ENDCOM,20,,,, +I,21,java/util/zip/ZipInputStream.ENDHDR,22,,,, +I,21,java/util/zip/ZipInputStream.ENDOFF,16,,,, +I,21,java/util/zip/ZipInputStream.ENDSIZ,12,,,, +I,21,java/util/zip/ZipInputStream.ENDSUB,8,,,, +I,21,java/util/zip/ZipInputStream.ENDTOT,10,,,, +I,21,java/util/zip/ZipInputStream.EXTCRC,4,,,, +I,21,java/util/zip/ZipInputStream.EXTHDR,16,,,, +I,21,java/util/zip/ZipInputStream.EXTLEN,12,,,, +I,21,java/util/zip/ZipInputStream.EXTSIZ,8,,,, +I,21,java/util/zip/ZipInputStream.LOCCRC,14,,,, +I,21,java/util/zip/ZipInputStream.LOCEXT,28,,,, +I,21,java/util/zip/ZipInputStream.LOCFLG,6,,,, +I,21,java/util/zip/ZipInputStream.LOCHDR,30,,,, +I,21,java/util/zip/ZipInputStream.LOCHOW,8,,,, +I,21,java/util/zip/ZipInputStream.LOCLEN,22,,,, +I,21,java/util/zip/ZipInputStream.LOCNAM,26,,,, +I,21,java/util/zip/ZipInputStream.LOCSIZ,18,,,, +I,21,java/util/zip/ZipInputStream.LOCTIM,10,,,, +I,21,java/util/zip/ZipInputStream.LOCVER,4,,,, +I,21,java/util/zip/ZipOutputStream.CENATT,36,,,, +I,21,java/util/zip/ZipOutputStream.CENATX,38,,,, +I,21,java/util/zip/ZipOutputStream.CENCOM,32,,,, +I,21,java/util/zip/ZipOutputStream.CENCRC,16,,,, +I,21,java/util/zip/ZipOutputStream.CENDSK,34,,,, +I,21,java/util/zip/ZipOutputStream.CENEXT,30,,,, +I,21,java/util/zip/ZipOutputStream.CENFLG,8,,,, +I,21,java/util/zip/ZipOutputStream.CENHDR,46,,,, +I,21,java/util/zip/ZipOutputStream.CENHOW,10,,,, +I,21,java/util/zip/ZipOutputStream.CENLEN,24,,,, +I,21,java/util/zip/ZipOutputStream.CENNAM,28,,,, +I,21,java/util/zip/ZipOutputStream.CENOFF,42,,,, +I,21,java/util/zip/ZipOutputStream.CENSIZ,20,,,, +I,21,java/util/zip/ZipOutputStream.CENTIM,12,,,, +I,21,java/util/zip/ZipOutputStream.CENVEM,4,,,, +I,21,java/util/zip/ZipOutputStream.CENVER,6,,,, +I,0,java/util/zip/ZipOutputStream.DEFLATED,8,,,, +I,21,java/util/zip/ZipOutputStream.ENDCOM,20,,,, +I,21,java/util/zip/ZipOutputStream.ENDHDR,22,,,, +I,21,java/util/zip/ZipOutputStream.ENDOFF,16,,,, +I,21,java/util/zip/ZipOutputStream.ENDSIZ,12,,,, +I,21,java/util/zip/ZipOutputStream.ENDSUB,8,,,, +I,21,java/util/zip/ZipOutputStream.ENDTOT,10,,,, +I,21,java/util/zip/ZipOutputStream.EXTCRC,4,,,, +I,21,java/util/zip/ZipOutputStream.EXTHDR,16,,,, +I,21,java/util/zip/ZipOutputStream.EXTLEN,12,,,, +I,21,java/util/zip/ZipOutputStream.EXTSIZ,8,,,, +I,21,java/util/zip/ZipOutputStream.LOCCRC,14,,,, +I,21,java/util/zip/ZipOutputStream.LOCEXT,28,,,, +I,21,java/util/zip/ZipOutputStream.LOCFLG,6,,,, +I,21,java/util/zip/ZipOutputStream.LOCHDR,30,,,, +I,21,java/util/zip/ZipOutputStream.LOCHOW,8,,,, +I,21,java/util/zip/ZipOutputStream.LOCLEN,22,,,, +I,21,java/util/zip/ZipOutputStream.LOCNAM,26,,,, +I,21,java/util/zip/ZipOutputStream.LOCSIZ,18,,,, +I,21,java/util/zip/ZipOutputStream.LOCTIM,10,,,, +I,21,java/util/zip/ZipOutputStream.LOCVER,4,,,, +I,0,java/util/zip/ZipOutputStream.STORED,0,,,, +E,10,javax/crypto/Cipher.DECRYPT_MODE,2,Javax.Crypto.CipherMode,DecryptMode,remove, +E,10,javax/crypto/Cipher.ENCRYPT_MODE,1,Javax.Crypto.CipherMode,EncryptMode,remove, +E,10,javax/crypto/Cipher.PRIVATE_KEY,2,Javax.Crypto.KeyType,PrivateKey,remove, +E,10,javax/crypto/Cipher.PUBLIC_KEY,1,Javax.Crypto.KeyType,PublicKey,remove, +E,10,javax/crypto/Cipher.SECRET_KEY,3,Javax.Crypto.KeyType,SecretKey,remove, +E,10,javax/crypto/Cipher.UNWRAP_MODE,4,Javax.Crypto.CipherMode,UnwrapMode,remove, +E,10,javax/crypto/Cipher.WRAP_MODE,3,Javax.Crypto.CipherMode,WrapMode,remove, +I,0,javax/crypto/spec/DESedeKeySpec.DES_EDE_KEY_LEN,24,,,, +I,0,javax/crypto/spec/DESKeySpec.DES_KEY_LEN,8,,,, +I,24,javax/net/ssl/StandardConstants.SNI_HOST_NAME,0,,,, +I,0,javax/xml/datatype/DatatypeConstants.APRIL,4,,,, +I,0,javax/xml/datatype/DatatypeConstants.AUGUST,8,,,, +I,0,javax/xml/datatype/DatatypeConstants.DECEMBER,12,,,, +I,0,javax/xml/datatype/DatatypeConstants.EQUAL,0,,,, +I,0,javax/xml/datatype/DatatypeConstants.FEBRUARY,2,,,, +I,0,javax/xml/datatype/DatatypeConstants.FIELD_UNDEFINED,-2147483648,,,, +I,0,javax/xml/datatype/DatatypeConstants.GREATER,1,,,, +I,0,javax/xml/datatype/DatatypeConstants.INDETERMINATE,2,,,, +I,0,javax/xml/datatype/DatatypeConstants.JANUARY,1,,,, +I,0,javax/xml/datatype/DatatypeConstants.JULY,7,,,, +I,0,javax/xml/datatype/DatatypeConstants.JUNE,6,,,, +I,0,javax/xml/datatype/DatatypeConstants.LESSER,-1,,,, +I,0,javax/xml/datatype/DatatypeConstants.MARCH,3,,,, +I,0,javax/xml/datatype/DatatypeConstants.MAX_TIMEZONE_OFFSET,-840,,,, +I,0,javax/xml/datatype/DatatypeConstants.MAY,5,,,, +I,0,javax/xml/datatype/DatatypeConstants.MIN_TIMEZONE_OFFSET,840,,,, +I,0,javax/xml/datatype/DatatypeConstants.NOVEMBER,11,,,, +I,0,javax/xml/datatype/DatatypeConstants.OCTOBER,10,,,, +I,0,javax/xml/datatype/DatatypeConstants.SEPTEMBER,9,,,, +I,0,org/apache/http/auth/AuthScope.ANY_PORT,-1,,,, +I,0,org/apache/http/conn/params/ConnManagerParams.DEFAULT_MAX_TOTAL_CONNECTIONS,20,,,, +I,0,org/apache/http/conn/params/ConnPerRouteBean.DEFAULT_MAX_CONNECTIONS_PER_ROUTE,2,,,, +I,0,org/apache/http/protocol/HTTP.CR,13,,,, +I,0,org/apache/http/protocol/HTTP.HT,9,,,, +I,0,org/apache/http/protocol/HTTP.LF,10,,,, +I,0,org/apache/http/protocol/HTTP.SP,32,,,, +I,0,org/apache/http/util/LangUtils.HASH_OFFSET,37,,,, +I,0,org/apache/http/util/LangUtils.HASH_SEED,17,,,, diff --git a/src/Java.Base/Transforms/methodmap.csv b/src/Java.Base/Transforms/methodmap.csv new file mode 100644 index 000000000..cb450affb --- /dev/null +++ b/src/Java.Base/Transforms/methodmap.csv @@ -0,0 +1,332 @@ +// You are almost not supposed to directly edit this file. +// See build-tools/enumification-helpers/README.md there for details. +// +// Each line represents: [API], [pkg], [type], [method], [param], [C#enum] +// API - Platform Name (API Level) Since +// pkg - Java package +// type - Java type (dotted for nested types) +// method - method name (".ctor" for constructors) +// param - method parameter name, or "return" for return value +// C#enum - C# enum type (full name, dotted) +// +// Lines until around 600 are traditional mappings that were not tracked with +// enumification-helpers tools. There are some marker comment lines over there, +// and after those lines they are copy of enumification-helpers/methodmap.ext.csv. + +// CharBuffer is sort of special to treat ICharSequence. +// We need to remap it to CharSequence to have valid overrides. +0, java.nio, CharBuffer, subSequence, return, Java.Lang.ICharSequence + +// darn, the docs changed the parameter name. +// darn, the docs changed the parameter name. +// On Api level 29, the argument audio_source was renamed from audio_source to audioSource +// in API Level 16 it was renamed to rangeType. Stupid. +// This is a mess by api-merge. +// It brings back some totally obsoleted and even disappeared method. +// Then it does not exist in droiddoc. Thus, parameter name retrieval fails. +// Even for that case, we still need enumification, but it does not happen because the "named" parameter here does not exist! +// To fix this issue, add "nameless" version of the method argument description too. + +// lots of Context permission methods (and those in derived types) + +// Context send/start methods +// startIntentSender() int extraFlags parameter is OK + + + + +0, org.xmlpull.v1, [Interface]XmlPullParser, getEventType, return, Org.XmlPull.V1.XmlPullParserNode +0, org.xmlpull.v1, [Interface]XmlPullParser, require, type, Org.XmlPull.V1.XmlPullParserNode +0, org.xmlpull.v1, [Interface]XmlPullParser, next, return, Org.XmlPull.V1.XmlPullParserNode +0, org.xmlpull.v1, [Interface]XmlPullParser, nextTag, return, Org.XmlPull.V1.XmlPullParserNode +0, org.xmlpull.v1, [Interface]XmlPullParser, nextToken, return, Org.XmlPull.V1.XmlPullParserNode + + + + + + + + + + + +// I'm making these changes so far only in this extra mappings. +// Things will change significantly so it had better be done all at once... + +// I don't like this "MatchResults" name and believe it should be renamed... +0, java.io, ObjectOutputStream, useProtocolVersion, version, Java.IO.ObjectStreamProtocol + + + +// I don't like this "Stream" name and believe it should be renamed... + + +// ... ArrowKey and Scrolling override are only in lower API levels :( + + + + + + + +// I had to find out these flags usage from sources, they lack documentation. + + + + + +// for getMetaState return values, they are chaotic, could be either Keycode, or some non-enumerated 0, 1, 2 value, and possibly MetaKeyStates. I can't help it. The API sucks. + +// API Level 17 doc *renamed* some parameters, hence it also needs to be tracked... + + + +// additional mappings + + +// PackageItemInfo does *not* implement Parcelable, but the subclasses *does* implement. +// Since we cannot (should not) predict such derivation when we are processing this +// *base* class, we still leave PackageItemInfo untouched in the automatic upgrade +// process and need this metadata fixup. +// These guys does not implement Parcelable(!) + + +0, java.nio.channels, SelectionKey, interestOps, return, Java.Nio.Channels.Operations +0, java.nio.channels, SelectionKey, readyOps, return, Java.Nio.Channels.Operations +0, java.nio.channels, SelectableChannel, validOps, return, Java.Nio.Channels.Operations +0, java.nio.channels, DatagramChannel, validOps, return, Java.Nio.Channels.Operations +0, java.nio.channels, Pipe.SinkChannel, validOps, return, Java.Nio.Channels.Operations +0, java.nio.channels, Pipe.SourceChannel, validOps, return, Java.Nio.Channels.Operations +0, java.nio.channels, ServerSocketChannel, validOps, return, Java.Nio.Channels.Operations +0, java.nio.channels, SocketChannel, validOps, return, Java.Nio.Channels.Operations +0, java.nio.channels, SelectableChannel, register, operations, Java.Nio.Channels.Operations +0, java.nio.channels, SelectableChannel, register, ops, Java.Nio.Channels.Operations +0, java.nio.channels.spi, AbstractSelectableChannel, register, interestSet, Java.Nio.Channels.Operations + + + +// it somehow fails to retrieve parameter name in API Level 17... +// "Option" sounds too general too... + + + + + + + + + + + + + + + + + +// FIXME: This does *not* implement Spanned, but the derived type (SpannableString) does +// implement it, so this needs to change the return type and this method needs to be +// interpreted as an implementation. A messy factor is, this class is *not* public! + + + + + + + + + + + + + + + + + + + + + + +0, java.awt.font, NumericShaper, getRanges, return, Java.Awt.Font.Ranges +0, java.awt.font, NumericShaper, getContextualShaper, ranges, Java.Awt.Font.Ranges +0, java.awt.font, NumericShaper, getShaper, singleRange, Java.Awt.Font.Ranges + +0, java.io, StreamTokenizer, nextToken, return, Java.IO.TokenType + +0, java.math, RoundingMode, valueOf, mode, Java.Math.RoundOptions + +0, java.net, HttpRetryException, ctor, code, Java.Net.HttpStatus +0, java.net, HttpRetryException, responseCode, return, Java.Net.HttpStatus +0, java.net, HttpURLConnection, getResponseCode, return, Java.Net.HttpStatus +0, java.net, IDN, toASCII, flags, Java.Net.IDNFlags +0, java.net, IDN, toUnicode, flags, Java.Net.IDNFlags +0, java.nio.channels, SelectionKey, interestOps, operations, Java.Nio.Channels.Operations + +0, java.util, Calendar, add, field, Java.Util.CalendarField +0, java.util, Calendar, clear, field, Java.Util.CalendarField +0, java.util, Calendar, get, field, Java.Util.CalendarField +0, java.util, Calendar, getActualMaximum, field, Java.Util.CalendarField +0, java.util, Calendar, getActualMinimum, field, Java.Util.CalendarField +// 0, java.util, Calendar, getDisplayName, field, Java.Util.CalendarField +// 0, java.util, Calendar, getDisplayNames, field, Java.Util.CalendarField +0, java.util, Calendar, getGreatestMinimum, field, Java.Util.CalendarField +0, java.util, Calendar, getLeastMaximum, field, Java.Util.CalendarField +0, java.util, Calendar, getMaximum, field, Java.Util.CalendarField +0, java.util, Calendar, getMinimum, field, Java.Util.CalendarField +0, java.util, Calendar, isSet, field, Java.Util.CalendarField +0, java.util, Calendar, roll, field, Java.Util.CalendarField +0, java.util, Calendar, set, field, Java.Util.CalendarField +0, java.util, GregorianCalendar, add, field, Java.Util.CalendarField +0, java.util, GregorianCalendar, get, field, Java.Util.CalendarField +0, java.util, GregorianCalendar, getActualMaximum, field, Java.Util.CalendarField +0, java.util, GregorianCalendar, getActualMinimum, field, Java.Util.CalendarField +0, java.util, GregorianCalendar, getGreatestMinimum, field, Java.Util.CalendarField +0, java.util, GregorianCalendar, getLeastMaximum, field, Java.Util.CalendarField +0, java.util, GregorianCalendar, getMaximum, field, Java.Util.CalendarField +0, java.util, GregorianCalendar, getMinimum, field, Java.Util.CalendarField +0, java.util, GregorianCalendar, roll, field, Java.Util.CalendarField + +// 0, java.util, Calendar, getDisplayName, style, Java.Util.CalendarStyle +// 0, java.util, Calendar, getDisplayNames, style, Java.Util.CalendarStyle +0, java.util, [Interface]Formattable, formatTo, flags, Java.Util.FormatFlags +0, java.util.regex, Pattern, compile, flags, Java.Util.Regex.RegexOptions +0, java.util.regex, Pattern, flags, return, Java.Util.Regex.RegexOptions +0, java.util, TimeZone, getDisplayName, style, Java.Util.TimeZoneStyle + +0, javax.crypto, Cipher, unwrap, wrappedKeyType, Javax.Crypto.KeyType +0, javax.crypto, Cipher, init, opmode, Javax.Crypto.CipherMode + +// API Level 16 + +// huh, visiblity... + +// API Level 17 + +// API Level 18 +// this caused build error - could we get this override automatically changed to use enum? + +// API Level 19 +// They were added at API Level 16, but did not come up with corresponding error code until API Level 19 (!) + +// API Level 20 + +// API Level 21 + +// API Level 22 + + +// API Level 23 + +// this was required for build + + + + + + + + + + + + + + + + +// API Level 24 + + + + + + + + +// renamed parameters... +24, java.nio.channels, SelectionKey, interestOps, ops, Java.Nio.Channels.Operations +24, java.net, IDN, toASCII, flag, Java.Net.IDNFlags +24, java.net, IDN, toUnicode, flag, Java.Net.IDNFlags + +24, java.util, [Interface]Spliterator, characteristics, return, Java.Util.SpliteratorCharacteristics +24, java.util, Spliterators, spliterator, characteristics, Java.Util.SpliteratorCharacteristics +24, java.util, Spliterators, spliterator, additionalCharacteristics, Java.Util.SpliteratorCharacteristics +24, java.util, Spliterators, spliteratorUnknownSize, characteristics, Java.Util.SpliteratorCharacteristics +24, java.util, Spliterators.AbstractDoubleSpliterator, characteristics, return, Java.Util.SpliteratorCharacteristics +24, java.util, Spliterators.AbstractIntSpliterator, characteristics, return, Java.Util.SpliteratorCharacteristics +24, java.util, Spliterators.AbstractLongSpliterator, characteristics, return, Java.Util.SpliteratorCharacteristics +24, java.util, Spliterators.AbstractSpliterator, characteristics, return, Java.Util.SpliteratorCharacteristics + +// API Level 25 + +// Use of this enum involves some FAKE. The corresponding constants doesn't exist in API Level 24. + +// API Level 26 + +26, java.lang.invoke, [Interface]MethodHandleInfo, getReferenceKind, return, Java.Lang.Invoke.ReferenceKind +26, java.lang.invoke, [Interface]MethodHandleInfo, refKindIsField, refKind, Java.Lang.Invoke.ReferenceKind +26, java.lang.invoke, [Interface]MethodHandleInfo, refKindIsValid, refKind, Java.Lang.Invoke.ReferenceKind +26, java.lang.invoke, [Interface]MethodHandleInfo, refKindName, refKind, Java.Lang.Invoke.ReferenceKind +26, java.lang.invoke, [Interface]MethodHandleInfo, referenceKindToString, referenceKind, Java.Lang.Invoke.ReferenceKind +26, java.lang.invoke, [Interface]MethodHandleInfo, toString, kind, Java.Lang.Invoke.ReferenceKind +26, java.lang.invoke, MethodHandles.Lookup, lookupModes, return, Java.Lang.Invoke.MethodLookupModes + +// We have problem binding getAccountVisibilityForPackage() and getPackagesAndVisibilityForAccount(). They should be Map and Map instead of Map and Map respectively, but they require run-time mapping too... + + + + +// Those enums in TvContract.*Programs are used only with settings columns. +// I assume they are replaced by those consts in each FooBarPrograms class? + + +// The setter brings conflict with setFocusable(boolean) so it cannot be simply +// generated here. The corresponding manual fixup is added to "metadata". + + +// cannot change this at this state. + + +// ScanRecord has different TxPowerLevel context... + + +// MediaCas - the methods lack description so it's impossible to enumify them at this moment. +// ditto for MediaDescrambler. + + +// workaround doc scraper issue - it somehow failed to retrieve parameter names for this. + +26, java.util, Calendar.Builder, set, field, Java.Util.CalendarField + +// It was a bit too late to notice this method, or it was added after our final enumification effort for API Level 26. +// There is AssetInt property (of int) which was removed at API Level 21. We don't/can't enumify it. + + + + +// They were too late to get documented. + +// Cannot change this at this state. +// Cannot change this at this state. +// Cannot change this at this state. +// Cannot change this at this state. +// Cannot change this at this state. +// Cannot change this at this state. +// Cannot change this at this state. +// Cannot change this at this state. +// Cannot change this at this state. +// We can't enumificate DiscoveryStateListener because it will broke the current fields. +// Cannot change this at this state. +// Cannot change this at this state. +// Cannot change this at this state. +// Cannot change this at this state. +// Cannot change this at this state. +// 1, java.sql, Connection, getHoldability, return, Java.Sql.HoldabilityMode +// 1, java.sql, Connection, setHoldability, holdability, Java.Sql.HoldabilityMode +// 1, java.sql, Connection, getTransactionIsolation, return, Java.Sql.TransactionMode +// 1, java.sql, Connection, setTransactionIsolation, level, Java.Sql.TransactionMode +// 9, java.util, Calendar, getDisplayName, style, Java.Util.DisplayNameStyle +// 9, java.util, Calendar, getDisplayNames, style, Java.Util.DisplayNameStyle diff --git a/src/Java.Interop/Java.Interop/JavaArray.cs b/src/Java.Interop/Java.Interop/JavaArray.cs index 7dcaf0b10..d2c69234b 100644 --- a/src/Java.Interop/Java.Interop/JavaArray.cs +++ b/src/Java.Interop/Java.Interop/JavaArray.cs @@ -369,6 +369,15 @@ internal JavaPrimitiveArray (ref JniObjectReference reference, JniObjectReferenc { } + public override void DisposeUnlessReferenced () + { + if (forMarshalCollection) { + Dispose (); + return; + } + base.DisposeUnlessReferenced (); + } + public abstract void CopyTo (int sourceIndex, T[] destinationArray, int destinationIndex, int length); public abstract void CopyFrom (T[] sourceArray, int sourceIndex, int destinationIndex, int length); diff --git a/src/Java.Interop/Java.Interop/JavaObject.cs b/src/Java.Interop/Java.Interop/JavaObject.cs index ef7b06a12..980629b55 100644 --- a/src/Java.Interop/Java.Interop/JavaObject.cs +++ b/src/Java.Interop/Java.Interop/JavaObject.cs @@ -101,7 +101,7 @@ public void Dispose () JniEnvironment.Runtime.ValueManager.DisposePeer (this); } - public void DisposeUnlessReferenced () + public virtual void DisposeUnlessReferenced () { JniEnvironment.Runtime.ValueManager.DisposePeerUnlessReferenced (this); } diff --git a/src/Java.Interop/Java.Interop/JavaObjectArray.cs b/src/Java.Interop/Java.Interop/JavaObjectArray.cs index 7a41a6274..064130791 100644 --- a/src/Java.Interop/Java.Interop/JavaObjectArray.cs +++ b/src/Java.Interop/Java.Interop/JavaObjectArray.cs @@ -11,8 +11,8 @@ public class JavaObjectArray : JavaArray { internal static readonly ValueMarshaler Instance = new ValueMarshaler (); - public JavaObjectArray (ref JniObjectReference handle, JniObjectReferenceOptions transfer) - : base (ref handle, transfer) + public JavaObjectArray (ref JniObjectReference handle, JniObjectReferenceOptions options) + : base (ref handle, options) { } @@ -48,6 +48,29 @@ public JavaObjectArray (IEnumerable value) { } + [SuppressMessage ("Design", "CA1000")] + public static JavaObjectArray? CreateMarshalArray (IEnumerable? value) + { + if (value == null) { + return null; + } + if (value is JavaObjectArray c) { + return c; + } + return new JavaObjectArray (value) { + forMarshalCollection = true, + }; + } + + public override void DisposeUnlessReferenced () + { + if (forMarshalCollection) { + Dispose (); + return; + } + base.DisposeUnlessReferenced (); + } + [MaybeNull] public override T this [int index] { get { diff --git a/src/Java.Interop/Java.Interop/JavaPrimitiveArrays.cs b/src/Java.Interop/Java.Interop/JavaPrimitiveArrays.cs index 2ec1c3cfe..fd9c55b20 100644 --- a/src/Java.Interop/Java.Interop/JavaPrimitiveArrays.cs +++ b/src/Java.Interop/Java.Interop/JavaPrimitiveArrays.cs @@ -3,11 +3,11 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using Java.Interop.Expressions; using System.Linq.Expressions; -using System.Diagnostics.CodeAnalysis; namespace Java.Interop { @@ -157,6 +157,19 @@ public JavaBooleanArray (System.Collections.Generic.IEnumerable value) { } + public static JavaBooleanArray? CreateMarshalArray (System.Collections.Generic.IEnumerable? value) + { + if (value == null) { + return null; + } + if (value is JavaBooleanArray c) { + return c; + } + return new JavaBooleanArray (value) { + forMarshalCollection = true, + }; + } + protected override JniArrayElements CreateElements () { return GetElements (); @@ -264,14 +277,14 @@ public override void DestroyGenericArgumentState ([AllowNull] IList val } public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null) - { - Func m = JavaBooleanArray.CreateMarshaledValue; + { + Func m = JavaBooleanArray.CreateMarshaledValue; - var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); - return targetType == null - ? (Expression) call - : Expression.Convert (call, targetType); - } + var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); + return targetType == null + ? (Expression) call + : Expression.Convert (call, targetType); + } } } @@ -333,6 +346,19 @@ public JavaSByteArray (System.Collections.Generic.IEnumerable value) { } + public static JavaSByteArray? CreateMarshalArray (System.Collections.Generic.IEnumerable? value) + { + if (value == null) { + return null; + } + if (value is JavaSByteArray c) { + return c; + } + return new JavaSByteArray (value) { + forMarshalCollection = true, + }; + } + protected override JniArrayElements CreateElements () { return GetElements (); @@ -440,14 +466,14 @@ public override void DestroyGenericArgumentState ([AllowNull] IList value } public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null) - { - Func m = JavaSByteArray.CreateMarshaledValue; + { + Func m = JavaSByteArray.CreateMarshaledValue; - var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); - return targetType == null - ? (Expression) call - : Expression.Convert (call, targetType); - } + var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); + return targetType == null + ? (Expression) call + : Expression.Convert (call, targetType); + } } } @@ -509,6 +535,19 @@ public JavaCharArray (System.Collections.Generic.IEnumerable value) { } + public static JavaCharArray? CreateMarshalArray (System.Collections.Generic.IEnumerable? value) + { + if (value == null) { + return null; + } + if (value is JavaCharArray c) { + return c; + } + return new JavaCharArray (value) { + forMarshalCollection = true, + }; + } + protected override JniArrayElements CreateElements () { return GetElements (); @@ -616,14 +655,14 @@ public override void DestroyGenericArgumentState ([AllowNull] IList value, } public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null) - { - Func m = JavaCharArray.CreateMarshaledValue; + { + Func m = JavaCharArray.CreateMarshaledValue; - var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); - return targetType == null - ? (Expression) call - : Expression.Convert (call, targetType); - } + var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); + return targetType == null + ? (Expression) call + : Expression.Convert (call, targetType); + } } } @@ -685,6 +724,19 @@ public JavaInt16Array (System.Collections.Generic.IEnumerable value) { } + public static JavaInt16Array? CreateMarshalArray (System.Collections.Generic.IEnumerable? value) + { + if (value == null) { + return null; + } + if (value is JavaInt16Array c) { + return c; + } + return new JavaInt16Array (value) { + forMarshalCollection = true, + }; + } + protected override JniArrayElements CreateElements () { return GetElements (); @@ -792,14 +844,14 @@ public override void DestroyGenericArgumentState ([AllowNull] IList value } public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null) - { - Func m = JavaInt16Array.CreateMarshaledValue; + { + Func m = JavaInt16Array.CreateMarshaledValue; - var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); - return targetType == null - ? (Expression) call - : Expression.Convert (call, targetType); - } + var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); + return targetType == null + ? (Expression) call + : Expression.Convert (call, targetType); + } } } @@ -861,6 +913,19 @@ public JavaInt32Array (System.Collections.Generic.IEnumerable value) { } + public static JavaInt32Array? CreateMarshalArray (System.Collections.Generic.IEnumerable? value) + { + if (value == null) { + return null; + } + if (value is JavaInt32Array c) { + return c; + } + return new JavaInt32Array (value) { + forMarshalCollection = true, + }; + } + protected override JniArrayElements CreateElements () { return GetElements (); @@ -968,14 +1033,14 @@ public override void DestroyGenericArgumentState ([AllowNull] IList value } public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null) - { - Func m = JavaInt32Array.CreateMarshaledValue; + { + Func m = JavaInt32Array.CreateMarshaledValue; - var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); - return targetType == null - ? (Expression) call - : Expression.Convert (call, targetType); - } + var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); + return targetType == null + ? (Expression) call + : Expression.Convert (call, targetType); + } } } @@ -1037,6 +1102,19 @@ public JavaInt64Array (System.Collections.Generic.IEnumerable value) { } + public static JavaInt64Array? CreateMarshalArray (System.Collections.Generic.IEnumerable? value) + { + if (value == null) { + return null; + } + if (value is JavaInt64Array c) { + return c; + } + return new JavaInt64Array (value) { + forMarshalCollection = true, + }; + } + protected override JniArrayElements CreateElements () { return GetElements (); @@ -1144,14 +1222,14 @@ public override void DestroyGenericArgumentState ([AllowNull] IList value } public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null) - { - Func m = JavaInt64Array.CreateMarshaledValue; + { + Func m = JavaInt64Array.CreateMarshaledValue; - var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); - return targetType == null - ? (Expression) call - : Expression.Convert (call, targetType); - } + var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); + return targetType == null + ? (Expression) call + : Expression.Convert (call, targetType); + } } } @@ -1213,6 +1291,19 @@ public JavaSingleArray (System.Collections.Generic.IEnumerable value) { } + public static JavaSingleArray? CreateMarshalArray (System.Collections.Generic.IEnumerable? value) + { + if (value == null) { + return null; + } + if (value is JavaSingleArray c) { + return c; + } + return new JavaSingleArray (value) { + forMarshalCollection = true, + }; + } + protected override JniArrayElements CreateElements () { return GetElements (); @@ -1320,14 +1411,14 @@ public override void DestroyGenericArgumentState ([AllowNull] IList valu } public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null) - { - Func m = JavaSingleArray.CreateMarshaledValue; + { + Func m = JavaSingleArray.CreateMarshaledValue; - var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); - return targetType == null - ? (Expression) call - : Expression.Convert (call, targetType); - } + var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); + return targetType == null + ? (Expression) call + : Expression.Convert (call, targetType); + } } } @@ -1389,6 +1480,19 @@ public JavaDoubleArray (System.Collections.Generic.IEnumerable value) { } + public static JavaDoubleArray? CreateMarshalArray (System.Collections.Generic.IEnumerable? value) + { + if (value == null) { + return null; + } + if (value is JavaDoubleArray c) { + return c; + } + return new JavaDoubleArray (value) { + forMarshalCollection = true, + }; + } + protected override JniArrayElements CreateElements () { return GetElements (); @@ -1496,14 +1600,14 @@ public override void DestroyGenericArgumentState ([AllowNull] IList valu } public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null) - { - Func m = JavaDoubleArray.CreateMarshaledValue; - - var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); - return targetType == null - ? (Expression) call - : Expression.Convert (call, targetType); - } + { + Func m = JavaDoubleArray.CreateMarshaledValue; + + var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); + return targetType == null + ? (Expression) call + : Expression.Convert (call, targetType); + } } } diff --git a/src/Java.Interop/Java.Interop/JavaPrimitiveArrays.tt b/src/Java.Interop/Java.Interop/JavaPrimitiveArrays.tt index 2fea1e333..825073028 100644 --- a/src/Java.Interop/Java.Interop/JavaPrimitiveArrays.tt +++ b/src/Java.Interop/Java.Interop/JavaPrimitiveArrays.tt @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using Java.Interop.Expressions; @@ -131,6 +132,19 @@ namespace Java.Interop { { } + public static Java<#= info.TypeModifier #>Array? CreateMarshalArray (System.Collections.Generic.IEnumerable<<#= info.ManagedType #>>? value) + { + if (value == null) { + return null; + } + if (value is Java<#= info.TypeModifier #>Array c) { + return c; + } + return new Java<#= info.TypeModifier #>Array (value) { + forMarshalCollection = true, + }; + } + protected override JniArrayElements CreateElements () { return GetElements (); @@ -221,7 +235,7 @@ namespace Java.Interop { (ref JniObjectReference h, JniObjectReferenceOptions o) => new Java<#= info.TypeModifier #>Array (ref h, o)); } - public override JniValueMarshalerState CreateGenericObjectReferenceArgumentState (IList<<#= info.TypeModifier #>> value, ParameterAttributes synchronize) + public override JniValueMarshalerState CreateGenericObjectReferenceArgumentState ([MaybeNull] IList<<#= info.TypeModifier #>> value, ParameterAttributes synchronize) { return JavaArray<<#= info.TypeModifier #>>.CreateArgumentState (value, synchronize, (list, copy) => { var a = copy @@ -232,20 +246,20 @@ namespace Java.Interop { }); } - public override void DestroyGenericArgumentState (IList<<#= info.TypeModifier #>> value, ref JniValueMarshalerState state, ParameterAttributes synchronize) + public override void DestroyGenericArgumentState ([AllowNull] IList<<#= info.TypeModifier #>> value, ref JniValueMarshalerState state, ParameterAttributes synchronize) { JavaArray<<#= info.ManagedType #>>.DestroyArgumentStateArray> (value, ref state, synchronize); } public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null) - { - Func m = Java<#= info.TypeModifier #>Array.CreateMarshaledValue; - - var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); - return targetType == null - ? (Expression) call - : Expression.Convert (call, targetType); - } + { + Func m = Java<#= info.TypeModifier #>Array.CreateMarshaledValue; + + var call = Expression.Call (m.GetMethodInfo (), sourceValue, Expression.Constant (targetType, typeof (Type))); + return targetType == null + ? (Expression) call + : Expression.Convert (call, targetType); + } } } diff --git a/src/Java.Interop/Java.Interop/JavaTypeParametersAttribute.cs b/src/Java.Interop/Java.Interop/JavaTypeParametersAttribute.cs new file mode 100644 index 000000000..a482636b1 --- /dev/null +++ b/src/Java.Interop/Java.Interop/JavaTypeParametersAttribute.cs @@ -0,0 +1,16 @@ +using System; + +namespace Java.Interop +{ + [AttributeUsage (AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Method, + AllowMultiple=false)] + public sealed class JavaTypeParametersAttribute : Attribute + { + public JavaTypeParametersAttribute (string [] typeParameters) + { + TypeParameters = typeParameters; + } + + public string [] TypeParameters { get; } + } +} diff --git a/tests/Java.Interop-PerformanceTests/mono_crash.11a67480d0.0.json b/tests/Java.Interop-PerformanceTests/mono_crash.11a67480d0.0.json new file mode 100644 index 000000000..0b32a611c --- /dev/null +++ b/tests/Java.Interop-PerformanceTests/mono_crash.11a67480d0.0.json @@ -0,0 +1,732 @@ +{ + "protocol_version" : "0.0.6", + "configuration" : { + "version" : "(6.12.0.145) (2020-02/c633fe92383)", + "tlc" : "normal", + "sigsgev" : "altstack", + "notifications" : "kqueue", + "architecture" : "amd64", + "disabled_features" : "none", + "smallconfig" : "disabled", + "bigarrays" : "disabled", + "softdebug" : "enabled", + "interpreter" : "enabled", + "llvm_support" : "0", + "suspend" : "hybrid" + }, + "memory" : { + "Resident Size" : "206364672", + "Virtual Size" : "37639200768", + "minor_gc_time" : "411635", + "major_gc_time" : "0", + "minor_gc_count" : "2", + "major_gc_count" : "0", + "major_gc_time_concurrent" : "0" + }, + "threads" : [ + { + "is_managed" : true, + "offset_free_hash" : "0x11a67480d0", + "offset_rich_hash" : "0x11a67485e5", + "crashed" : true, + "native_thread_id" : "0x700012869000", + "thread_info_addr" : "0x7fc85d8a7e00", + "thread_name" : "tid_9003", + "ctx" : { + "IP" : "0x7ff805c01112", + "SP" : "0x700012861b28", + "BP" : "0x700012861b50" + }, + "managed_frames" : [ + { + "is_managed" : "false", + "native_address" : "unregistered" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x00015" + } +, + { + "is_managed" : "true", + "guid" : "AB9A187A-50E5-4F8C-B6A2-692756CA03AC", + "token" : "0x600427f", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x290000", + "timestamp" : "0xf1812e91", + "il_offset" : "0x0026a" + } +, + { + "is_managed" : "true", + "guid" : "AB9A187A-50E5-4F8C-B6A2-692756CA03AC", + "token" : "0x600447f", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x290000", + "timestamp" : "0xf1812e91", + "il_offset" : "0x00043" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x6001ed3", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x00071" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x6001ed1", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x6001ed0", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x0002b" + } +, + { + "is_managed" : "true", + "guid" : "AB9A187A-50E5-4F8C-B6A2-692756CA03AC", + "token" : "0x600427e", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x290000", + "timestamp" : "0xf1812e91", + "il_offset" : "0x00093" + } +, + { + "is_managed" : "true", + "guid" : "AB9A187A-50E5-4F8C-B6A2-692756CA03AC", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x290000", + "timestamp" : "0xf1812e91", + "il_offset" : "0xffffffff" + } +, + { + "is_managed" : "false", + "native_address" : "unregistered" + } +, + { + "is_managed" : "true", + "guid" : "AB9A187A-50E5-4F8C-B6A2-692756CA03AC", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x290000", + "timestamp" : "0xf1812e91", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "AB9A187A-50E5-4F8C-B6A2-692756CA03AC", + "token" : "0x6004477", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x290000", + "timestamp" : "0xf1812e91", + "il_offset" : "0x0003a" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x6001f2b", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x00025" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x6001ed3", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x00071" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x6001ed1", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x6001ed0", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x0002b" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x0002a" + } + + ], + "unmanaged_frames" : [ + { + "is_managed" : "false", + "native_address" : "0x1081ce8e6", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10836a0b5", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10836a72a", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10823b977", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1081d357e", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10823ac6f", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff805c4ce2d", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff805b83d10", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x108427f57", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x108408dbf", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1084283ee", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10842856f", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1084285aa", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10841cd7e", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x108364621", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10836b29d", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x108368f0c", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "AB9A187A-50E5-4F8C-B6A2-692756CA03AC", + "token" : "0x600427f", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x290000", + "timestamp" : "0xf1812e91", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "AB9A187A-50E5-4F8C-B6A2-692756CA03AC", + "token" : "0x600447f", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x290000", + "timestamp" : "0xf1812e91", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x6001ed3", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x6001ed1", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "AB9A187A-50E5-4F8C-B6A2-692756CA03AC", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x290000", + "timestamp" : "0xf1812e91", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff80d307213", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff80d30638e", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff80d306287", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff80d309829", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff805d2be70", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff805cfeffa", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff805cfeed6", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff805cfd54b", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff805cfc52d", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff805d8457e", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10a768fcc", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "AB9A187A-50E5-4F8C-B6A2-692756CA03AC", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x290000", + "timestamp" : "0xf1812e91", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "AB9A187A-50E5-4F8C-B6A2-692756CA03AC", + "token" : "0x6004477", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x290000", + "timestamp" : "0xf1812e91", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x6001f2b", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x6001ed1", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x108130852", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10833fee7", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x108346790", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10836ad3d", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff805c37514", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff805c3302f", + "native_offset" : "0x00000" + } + + ] +}, +{ + "is_managed" : false, + "offset_free_hash" : "0xb38e38d3", + "offset_rich_hash" : "0xb38e38d3", + "crashed" : false, + "native_thread_id" : "0x70000f6d8000", + "thread_info_addr" : "0x7fc868808200", + "thread_name" : "Finalizer", + "ctx" : { + "IP" : "0x7ff805bfaaf6", + "SP" : "0x70000f6d7eb8", + "BP" : "0x70000f6d7f00" + }, + "unmanaged_frames" : [ + { + "is_managed" : "false", + "native_address" : "0x1081ce8e6", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10836a0b5", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x108369de7", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10823a8b0", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff805c4ce2d", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "08F46039-E506-4C62-8BF7-795F9B970B7B", + "token" : "0x600146e", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0xb8fdd928", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10836acfd", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff805c37514", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff805c3302f", + "native_offset" : "0x00000" + } + + ] +}, +{ + "is_managed" : false, + "offset_free_hash" : "0x0", + "offset_rich_hash" : "0x0", + "crashed" : false, + "native_thread_id" : "0x108690600", + "thread_info_addr" : "0x7fc879808200", + "thread_name" : "tid_103", + "ctx" : { + "IP" : "0x7ff805bfd506", + "SP" : "0x7ff7b7de1918", + "BP" : "0x7ff7b7de19c0" + }, + "unmanaged_frames" : [ + { + "is_managed" : "false", + "native_address" : "0x1081ce8e6", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10836a0b5", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x108369de7", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10823a8b0", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff805c4ce2d", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7ff7b7de17a0", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x108404e80", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10841cfb1", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x108366fd4", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x108366dda", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x108193f7a", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x108120138", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10861d4fe", + "native_offset" : "0x00000" + } + + ] +} +] +} \ No newline at end of file diff --git a/tests/TestJVM/TestJVM.cs b/tests/TestJVM/TestJVM.cs index ba039b68b..5ef58d9c4 100644 --- a/tests/TestJVM/TestJVM.cs +++ b/tests/TestJVM/TestJVM.cs @@ -46,7 +46,7 @@ static TextWriter GetLogOutput (string envVar, string prefix, Assembly caller) return new StreamWriter (path, append: false, encoding: new UTF8Encoding (encoderShouldEmitUTF8Identifier: false)); } - static string GetJvmLibraryPath () + public static string GetJvmLibraryPath () { var jdkDir = ReadJavaSdkDirectoryFromJdkInfoProps (); if (jdkDir != null) { diff --git a/tests/TestJVM/TestJVM.csproj b/tests/TestJVM/TestJVM.csproj index a259021a6..b91b4da40 100644 --- a/tests/TestJVM/TestJVM.csproj +++ b/tests/TestJVM/TestJVM.csproj @@ -12,6 +12,7 @@ + diff --git a/tests/generator-Tests/Integration-Tests/Adapters.cs b/tests/generator-Tests/Integration-Tests/Adapters.cs index 9002f3a53..e93e7688f 100644 --- a/tests/generator-Tests/Integration-Tests/Adapters.cs +++ b/tests/generator-Tests/Integration-Tests/Adapters.cs @@ -6,6 +6,8 @@ namespace generatortests [TestFixture] public class Adapters : BaseGeneratorTest { + protected override bool TryJavaInterop1 => false; + [Test] public void GeneratedOK () { diff --git a/tests/generator-Tests/Integration-Tests/Arrays.cs b/tests/generator-Tests/Integration-Tests/Arrays.cs index 73e30baa3..ecdc48e52 100644 --- a/tests/generator-Tests/Integration-Tests/Arrays.cs +++ b/tests/generator-Tests/Integration-Tests/Arrays.cs @@ -6,6 +6,8 @@ namespace generatortests [TestFixture] public class Arrays : BaseGeneratorTest { + protected override bool TryJavaInterop1 => false; + [Test] public void GeneratedOK () { diff --git a/tests/generator-Tests/Integration-Tests/BaseGeneratorTest.cs b/tests/generator-Tests/Integration-Tests/BaseGeneratorTest.cs index 83c6afb5b..d78b9113b 100644 --- a/tests/generator-Tests/Integration-Tests/BaseGeneratorTest.cs +++ b/tests/generator-Tests/Integration-Tests/BaseGeneratorTest.cs @@ -29,9 +29,11 @@ public void Setup () protected CodeGeneratorOptions Options = null; protected Assembly BuiltAssembly = null; - protected List AdditionalSourceDirectories; + List AdditionalSourceDirectories; protected bool AllowWarnings; + protected virtual bool TryJavaInterop1 => true; + public void Execute () { CodeGenerator.Run (Options); @@ -69,7 +71,7 @@ protected void CompareOutputs (string sourceDir, string destinationDir) //Error message for diff in powershell vs bash string message = Environment.OSVersion.Platform == PlatformID.Win32NT ? $"File contents differ; run: diff (cat {fullSource}) `{Environment.NewLine}\t(cat {fullDest})" : - $"File contents differ; run: diff -u {fullSource} \\{Environment.NewLine}\t{fullDest}"; + $"File contents differ; run: git diff --no-index {fullSource} \\{Environment.NewLine}\t{fullDest}"; Assert.Fail (message); } } @@ -122,7 +124,10 @@ private byte[] ReadAllBytesIgnoringLineEndings (string path) protected void RunAllTargets (string outputRelativePath, string apiDescriptionFile, string expectedRelativePath, string[] additionalSupportPaths = null, string enumFieldsMapFile = null, string enumMethodMapFile = null) { Run (CodeGenerationTarget.XamarinAndroid, Path.Combine ("out", outputRelativePath), apiDescriptionFile, Path.Combine ("expected", expectedRelativePath), additionalSupportPaths, enumFieldsMapFile, enumMethodMapFile); - Run (CodeGenerationTarget.JavaInterop1, Path.Combine ("out.ji", outputRelativePath), apiDescriptionFile, Path.Combine ("expected.ji", expectedRelativePath), additionalSupportPaths, enumFieldsMapFile, enumMethodMapFile); + Run (CodeGenerationTarget.XAJavaInterop1, Path.Combine ("out.xaji", outputRelativePath), apiDescriptionFile, Path.Combine ("expected.xaji", expectedRelativePath), additionalSupportPaths, enumFieldsMapFile, enumMethodMapFile); + if (TryJavaInterop1) { + Run (CodeGenerationTarget.JavaInterop1, Path.Combine ("out.ji", outputRelativePath), apiDescriptionFile, Path.Combine ("expected.ji", expectedRelativePath), additionalSupportPaths, enumFieldsMapFile, enumMethodMapFile); + } } protected string FullPath (string path) @@ -134,6 +139,7 @@ protected string FullPath (string path) protected void Run (CodeGenerationTarget target, string outputPath, string apiDescriptionFile, string expectedPath, string[] additionalSupportPaths = null, string enumFieldsMapFile = null, string enumMethodMapFile = null) { Cleanup (outputPath); + AdditionalSourceDirectories.Clear (); Options.CodeGenerationTarget = target; Options.ApiDescriptionFile = FullPath (apiDescriptionFile); diff --git a/tests/generator-Tests/Integration-Tests/Compiler.cs b/tests/generator-Tests/Integration-Tests/Compiler.cs index 883ca47b8..b49f94e3e 100644 --- a/tests/generator-Tests/Integration-Tests/Compiler.cs +++ b/tests/generator-Tests/Integration-Tests/Compiler.cs @@ -8,6 +8,8 @@ using Microsoft.CodeAnalysis.CSharp; using NUnit.Framework; +using CodeGenerationTarget = Xamarin.Android.Binder.CodeGenerationTarget; + namespace generatortests { public static class Compiler @@ -34,25 +36,46 @@ public static Assembly Compile (Xamarin.Android.Binder.CodeGeneratorOptions opti sourceFiles.AddRange (additonal); } + var preprocessorSymbols = new List (); + if (options.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + preprocessorSymbols.Add ("JAVA_INTEROP1"); + } + + var parseOptions = new CSharpParseOptions (preprocessorSymbols:preprocessorSymbols); + + // Parse the source files - var syntax_trees = sourceFiles.Distinct ().Select (s => CSharpSyntaxTree.ParseText (File.ReadAllText (s))).ToArray (); + var syntax_trees = sourceFiles.Distinct () + .Select (s => CSharpSyntaxTree.ParseText (File.ReadAllText (s), options:parseOptions)) + .ToArray (); // Set up the assemblies we need to reference var binDir = Path.GetDirectoryName (typeof (BaseGeneratorTest).Assembly.Location); var facDir = GetFacadesPath (); - var references = new [] { - MetadataReference.CreateFromFile (unitTestFrameworkAssemblyPath), - MetadataReference.CreateFromFile (typeof(object).Assembly.Location), - MetadataReference.CreateFromFile (typeof(Enumerable).Assembly.Location), - MetadataReference.CreateFromFile (typeof(Uri).Assembly.Location), - MetadataReference.CreateFromFile (Path.Combine (binDir, "Java.Interop.dll")), - MetadataReference.CreateFromFile (Path.Combine (facDir, "netstandard.dll")), + var referencePaths = new[]{ + unitTestFrameworkAssemblyPath, + typeof(object).Assembly.Location, + typeof(Enumerable).Assembly.Location, + typeof(Uri).Assembly.Location, + Path.Combine (binDir, "Java.Interop.dll"), + Path.Combine (facDir, "netstandard.dll"), #if NET - MetadataReference.CreateFromFile (Path.Combine (facDir, "System.Runtime.dll")), + Path.Combine (facDir, "System.Runtime.dll"), #endif // NET }; + var references = referencePaths.Select (p => MetadataReference.CreateFromFile (p)).ToArray (); + + string testCommandLine = + $"csc \"-out:{Path.GetFileName (assemblyFileName)}\" " + + $"-unsafe -t:library " + + string.Join (" ", preprocessorSymbols.Select (p => $"\"-define:{p}\"")) + " " + + string.Join (" ", referencePaths.Select (p => $"\"-r:{p}\"")) + " " + + string.Join (" ", sourceFiles) + ; + + Console.WriteLine ($"# Trying to compile: {testCommandLine}"); // Compile! var compilation = CSharpCompilation.Create ( diff --git a/tests/generator-Tests/Integration-Tests/Core_Jar2Xml.cs b/tests/generator-Tests/Integration-Tests/Core_Jar2Xml.cs index ddbc60f73..49d3aa81f 100644 --- a/tests/generator-Tests/Integration-Tests/Core_Jar2Xml.cs +++ b/tests/generator-Tests/Integration-Tests/Core_Jar2Xml.cs @@ -6,6 +6,8 @@ namespace generatortests [TestFixture] public class Core_Jar2Xml : BaseGeneratorTest { + protected override bool TryJavaInterop1 => false; + [Test] public void GeneratedOK () { diff --git a/tests/generator-Tests/Integration-Tests/GenericArguments.cs b/tests/generator-Tests/Integration-Tests/GenericArguments.cs index f701bbd92..87b8f63b4 100644 --- a/tests/generator-Tests/Integration-Tests/GenericArguments.cs +++ b/tests/generator-Tests/Integration-Tests/GenericArguments.cs @@ -6,6 +6,8 @@ namespace generatortests [TestFixture] public class GenericArguments : BaseGeneratorTest { + protected override bool TryJavaInterop1 => false; + [Test] public void GeneratedOK () { diff --git a/tests/generator-Tests/Integration-Tests/Interfaces.cs b/tests/generator-Tests/Integration-Tests/Interfaces.cs index d0c4c6754..06d5f4917 100644 --- a/tests/generator-Tests/Integration-Tests/Interfaces.cs +++ b/tests/generator-Tests/Integration-Tests/Interfaces.cs @@ -6,6 +6,8 @@ namespace generatortests [TestFixture] public class Interfaces : BaseGeneratorTest { + protected override bool TryJavaInterop1 => false; + [Test] public void Generated_OK () { diff --git a/tests/generator-Tests/Integration-Tests/Java_Lang_Enum.cs b/tests/generator-Tests/Integration-Tests/Java_Lang_Enum.cs index 8de599cf4..52467ba64 100644 --- a/tests/generator-Tests/Integration-Tests/Java_Lang_Enum.cs +++ b/tests/generator-Tests/Integration-Tests/Java_Lang_Enum.cs @@ -6,6 +6,8 @@ namespace generatortests [TestFixture] public class Java_Lang_Enum : BaseGeneratorTest { + protected override bool TryJavaInterop1 => false; + [Test] public void Generated_OK () { diff --git a/tests/generator-Tests/Integration-Tests/Java_Util_List.cs b/tests/generator-Tests/Integration-Tests/Java_Util_List.cs index b96f05cac..05fe04fbc 100644 --- a/tests/generator-Tests/Integration-Tests/Java_Util_List.cs +++ b/tests/generator-Tests/Integration-Tests/Java_Util_List.cs @@ -6,6 +6,8 @@ namespace generatortests [TestFixture] public class Java_Util_List : BaseGeneratorTest { + protected override bool TryJavaInterop1 => false; + [Test] public void GeneratedOK () { diff --git a/tests/generator-Tests/Integration-Tests/NestedTypes.cs b/tests/generator-Tests/Integration-Tests/NestedTypes.cs index 0ee4eec61..07c42efb9 100644 --- a/tests/generator-Tests/Integration-Tests/NestedTypes.cs +++ b/tests/generator-Tests/Integration-Tests/NestedTypes.cs @@ -6,6 +6,8 @@ namespace generatortests [TestFixture] public class NestedTypes : BaseGeneratorTest { + protected override bool TryJavaInterop1 => false; + [Test] public void GeneratedOK () { diff --git a/tests/generator-Tests/Integration-Tests/NormalMethods.cs b/tests/generator-Tests/Integration-Tests/NormalMethods.cs index bf9bec07f..5fbd5ed84 100644 --- a/tests/generator-Tests/Integration-Tests/NormalMethods.cs +++ b/tests/generator-Tests/Integration-Tests/NormalMethods.cs @@ -6,6 +6,8 @@ namespace generatortests [TestFixture] public class NormalMethods : BaseGeneratorTest { + protected override bool TryJavaInterop1 => false; + [Test] public void GeneratedOK () { diff --git a/tests/generator-Tests/Integration-Tests/PamareterXPath.cs b/tests/generator-Tests/Integration-Tests/PamareterXPath.cs index 3e32b2a9b..b2cb00282 100644 --- a/tests/generator-Tests/Integration-Tests/PamareterXPath.cs +++ b/tests/generator-Tests/Integration-Tests/PamareterXPath.cs @@ -6,6 +6,8 @@ namespace generatortests [TestFixture] public class ParameterXPath : BaseGeneratorTest { + protected override bool TryJavaInterop1 => false; + [Test] public void GeneratedOK () { diff --git a/tests/generator-Tests/Integration-Tests/Streams.cs b/tests/generator-Tests/Integration-Tests/Streams.cs index 948743cca..d3b30aaaf 100644 --- a/tests/generator-Tests/Integration-Tests/Streams.cs +++ b/tests/generator-Tests/Integration-Tests/Streams.cs @@ -9,6 +9,7 @@ public class Streams : BaseGeneratorTest [Test] public void GeneratedOK () { + Console.Error.WriteLine ($"# jonp: Streams.GenerateOK"); RunAllTargets ( outputRelativePath: "Streams", apiDescriptionFile: "expected/Streams/Streams.xml", diff --git a/tests/generator-Tests/SupportFiles/Android.Text.SpanTypes.cs b/tests/generator-Tests/SupportFiles/Android.Text.SpanTypes.cs index 594b694b4..7ac45bf88 100644 --- a/tests/generator-Tests/SupportFiles/Android.Text.SpanTypes.cs +++ b/tests/generator-Tests/SupportFiles/Android.Text.SpanTypes.cs @@ -1,3 +1,5 @@ +#if !JAVA_INTEROP1 + using System; namespace Android.Text { @@ -6,3 +8,5 @@ public enum SpanTypes { None = 0 } } + +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/Android_Runtime_CharSequence.cs b/tests/generator-Tests/SupportFiles/Android_Runtime_CharSequence.cs index 7485a7df3..4db1ef23e 100644 --- a/tests/generator-Tests/SupportFiles/Android_Runtime_CharSequence.cs +++ b/tests/generator-Tests/SupportFiles/Android_Runtime_CharSequence.cs @@ -1,4 +1,6 @@ -using System; +#if !JAVA_INTEROP1 + +using System; using System.Collections.Generic; namespace Android.Runtime { @@ -31,3 +33,5 @@ public static IntPtr ToLocalJniHandle (IEnumerable value) } } } + +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/GeneratedEnumAttribute.cs b/tests/generator-Tests/SupportFiles/GeneratedEnumAttribute.cs index a972f918b..f3d372755 100644 --- a/tests/generator-Tests/SupportFiles/GeneratedEnumAttribute.cs +++ b/tests/generator-Tests/SupportFiles/GeneratedEnumAttribute.cs @@ -1,7 +1,11 @@ -using System; +#if !JAVA_INTEROP1 + +using System; namespace Android.Runtime { [AttributeUsage (AttributeTargets.ReturnValue | AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] public class GeneratedEnumAttribute : Attribute {} } + +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/IJavaObject.cs b/tests/generator-Tests/SupportFiles/IJavaObject.cs index 3a1154de8..647664ab7 100644 --- a/tests/generator-Tests/SupportFiles/IJavaObject.cs +++ b/tests/generator-Tests/SupportFiles/IJavaObject.cs @@ -1,3 +1,5 @@ +#if !JAVA_INTEROP1 + using System; namespace Android.Runtime { @@ -6,3 +8,5 @@ public interface IJavaObject : IDisposable { IntPtr Handle { get; } } } + +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/JNIEnv.cs b/tests/generator-Tests/SupportFiles/JNIEnv.cs index c02bd7585..d6a9b532d 100644 --- a/tests/generator-Tests/SupportFiles/JNIEnv.cs +++ b/tests/generator-Tests/SupportFiles/JNIEnv.cs @@ -1,3 +1,5 @@ +#if !JAVA_INTEROP1 + #pragma warning disable using System; using System.Collections.Generic; @@ -591,3 +593,4 @@ partial class JniNativeInterfaceInvoker { } #pragma warning restore +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/JNIEnv.g.cs b/tests/generator-Tests/SupportFiles/JNIEnv.g.cs index 0a3e2a531..e476e5733 100644 --- a/tests/generator-Tests/SupportFiles/JNIEnv.g.cs +++ b/tests/generator-Tests/SupportFiles/JNIEnv.g.cs @@ -1,4 +1,6 @@ -// Generated file; DO NOT EDIT! +#if !JAVA_INTEROP1 + +// Generated file; DO NOT EDIT! // // To make changes, edit monodroid/tools/jnienv-gen and rerun #pragma warning disable @@ -2643,3 +2645,5 @@ public JNIEnv.IntPtr_IntPtr_int_Delegate GetObjectRefType { } } #pragma warning restore + +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/JValue.cs b/tests/generator-Tests/SupportFiles/JValue.cs index e588b76e1..a73005888 100644 --- a/tests/generator-Tests/SupportFiles/JValue.cs +++ b/tests/generator-Tests/SupportFiles/JValue.cs @@ -1,3 +1,5 @@ +#if !JAVA_INTEROP1 + #pragma warning disable using System; using System.Runtime.InteropServices; @@ -80,3 +82,5 @@ public JValue (IJavaObject value) } } #pragma warning restore + +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/JavaArray.cs b/tests/generator-Tests/SupportFiles/JavaArray.cs index d41098463..638b1eb72 100644 --- a/tests/generator-Tests/SupportFiles/JavaArray.cs +++ b/tests/generator-Tests/SupportFiles/JavaArray.cs @@ -1,3 +1,4 @@ +#if !JAVA_INTEROP1 using System; using System.Collections; using System.Collections.Generic; @@ -407,3 +408,4 @@ public static IntPtr ToLocalJniHandle (IList value) } } } +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/JavaCollection.cs b/tests/generator-Tests/SupportFiles/JavaCollection.cs index 477205ca4..c12eb759f 100644 --- a/tests/generator-Tests/SupportFiles/JavaCollection.cs +++ b/tests/generator-Tests/SupportFiles/JavaCollection.cs @@ -1,4 +1,6 @@ -using System; +#if !JAVA_INTEROP1 + +using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -115,3 +117,4 @@ public static IntPtr ToLocalJniHandle (ICollection items) } } +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/JavaConvert.cs b/tests/generator-Tests/SupportFiles/JavaConvert.cs index b4fbe4b2b..429cb5008 100644 --- a/tests/generator-Tests/SupportFiles/JavaConvert.cs +++ b/tests/generator-Tests/SupportFiles/JavaConvert.cs @@ -1,4 +1,6 @@ -using System; +#if !JAVA_INTEROP1 + +using System; using System.Collections; using System.Collections.Generic; using System.Reflection; @@ -61,4 +63,4 @@ public static TReturn WithLocalJniHandle(object value, Func dictionary) } } +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/JavaObject.cs b/tests/generator-Tests/SupportFiles/JavaObject.cs index 455650fd6..59c13fda8 100644 --- a/tests/generator-Tests/SupportFiles/JavaObject.cs +++ b/tests/generator-Tests/SupportFiles/JavaObject.cs @@ -1,3 +1,5 @@ +#if !JAVA_INTEROP1 + using System; namespace Android.Runtime { @@ -190,3 +192,5 @@ public int ToArgb () } } } + +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/JavaObjectExtensions.cs b/tests/generator-Tests/SupportFiles/JavaObjectExtensions.cs index b1ab32237..a32d93f41 100644 --- a/tests/generator-Tests/SupportFiles/JavaObjectExtensions.cs +++ b/tests/generator-Tests/SupportFiles/JavaObjectExtensions.cs @@ -1,4 +1,6 @@ -using System; +#if !JAVA_INTEROP1 + +using System; using System.Collections; using System.Collections.Generic; using System.Reflection; @@ -64,3 +66,4 @@ internal static Type GetHelperType (Type type, string suffix) } } +#endif // !JAVA_INTEROP1 \ No newline at end of file diff --git a/tests/generator-Tests/SupportFiles/JavaTypeParametersAttribute.cs b/tests/generator-Tests/SupportFiles/JavaTypeParametersAttribute.cs deleted file mode 100644 index 33eab1aa2..000000000 --- a/tests/generator-Tests/SupportFiles/JavaTypeParametersAttribute.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace Java.Interop -{ - public class JavaTypeParametersAttribute : Attribute - { - public JavaTypeParametersAttribute (string [] typeParameters) - { - TypeParameters = typeParameters; - } - - public string [] TypeParameters { get; set; } - } -} - diff --git a/tests/generator-Tests/SupportFiles/Java_Lang_ICharSequence.cs b/tests/generator-Tests/SupportFiles/Java_Lang_ICharSequence.cs index 5011c3188..f70a64f6a 100644 --- a/tests/generator-Tests/SupportFiles/Java_Lang_ICharSequence.cs +++ b/tests/generator-Tests/SupportFiles/Java_Lang_ICharSequence.cs @@ -1,4 +1,6 @@ -using System; +#if !JAVA_INTEROP1 + +using System; using Android.Runtime; namespace Java.Lang { @@ -11,3 +13,5 @@ public partial interface ICharSequence : IJavaObject string ToString (); } } + +#endif // !JAVA_INTEROP1 \ No newline at end of file diff --git a/tests/generator-Tests/SupportFiles/Java_Lang_Object.cs b/tests/generator-Tests/SupportFiles/Java_Lang_Object.cs index 617db1706..6ab114ad3 100644 --- a/tests/generator-Tests/SupportFiles/Java_Lang_Object.cs +++ b/tests/generator-Tests/SupportFiles/Java_Lang_Object.cs @@ -5,12 +5,29 @@ using Java.Interop; +#if !JAVA_INTEROP1 using Android.Runtime; +#endif // !JAVA_INTEROP1 namespace Java.Lang { - public partial class Object : IDisposable, IJavaObject, IJavaPeerable + public partial class Object : +#if JAVA_INTEROP1 + global::Java.Interop.JavaObject, +#else + IJavaObject, +#endif // JAVA_INTEROP1 + IDisposable, IJavaPeerable { +#if JAVA_INTEROP1 + + public Object (ref JniObjectReference reference, JniObjectReferenceOptions options) + : base (ref reference, options) + { + } + +#else // !JAVA_INTEROP1 + public virtual JniPeerMembers JniPeerMembers { get { return null; } } @@ -279,6 +296,7 @@ public static explicit operator string[] (Java.Lang.Object value) { throw new NotImplementedException (); } +#endif // !JAVA_INTEROP1 } } diff --git a/tests/generator-Tests/SupportFiles/Java_Lang_String.cs b/tests/generator-Tests/SupportFiles/Java_Lang_String.cs index 91bc36268..69aa1d956 100644 --- a/tests/generator-Tests/SupportFiles/Java_Lang_String.cs +++ b/tests/generator-Tests/SupportFiles/Java_Lang_String.cs @@ -1,4 +1,6 @@ -using System; +#if !JAVA_INTEROP1 + +using System; using System.Collections; using System.Collections.Generic; @@ -41,3 +43,5 @@ IEnumerator IEnumerable.GetEnumerator () } } } + +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/Java_Lang_Throwable.cs b/tests/generator-Tests/SupportFiles/Java_Lang_Throwable.cs index 2a7ddaccb..26266a659 100644 --- a/tests/generator-Tests/SupportFiles/Java_Lang_Throwable.cs +++ b/tests/generator-Tests/SupportFiles/Java_Lang_Throwable.cs @@ -9,8 +9,21 @@ namespace Java.Lang { - public partial class Throwable : System.Exception, IJavaPeerable + public partial class Throwable : +#if JAVA_INTEROP1 + JavaException, +#else // !JAVA_INTEROP1 + System.Exception, +#endif // !JAVA_INTEROP1 + IJavaPeerable { +#if JAVA_INTEROP1 + public Throwable (ref JniObjectReference reference, JniObjectReferenceOptions options) + : base (ref reference, options) + { + } +#else // !JAVA_INTEROP1 + public virtual JniPeerMembers JniPeerMembers { get { return null; } } @@ -54,5 +67,6 @@ public void SetJniManagedPeerState (JniManagedPeerStates value) public void SetPeerReference (JniObjectReference value) { } +#endif // !JAVA_INTEROP1 } } diff --git a/tests/generator-Tests/SupportFiles/JniHandleOwnership.cs b/tests/generator-Tests/SupportFiles/JniHandleOwnership.cs index 032814fb4..5a7d7bcae 100644 --- a/tests/generator-Tests/SupportFiles/JniHandleOwnership.cs +++ b/tests/generator-Tests/SupportFiles/JniHandleOwnership.cs @@ -1,3 +1,5 @@ +#if !JAVA_INTEROP1 + using System; namespace Android.Runtime @@ -9,3 +11,4 @@ public enum JniHandleOwnership { } } +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/NamespaceMappingAttribute.cs b/tests/generator-Tests/SupportFiles/NamespaceMappingAttribute.cs index d652e0d1e..2dc9157b3 100644 --- a/tests/generator-Tests/SupportFiles/NamespaceMappingAttribute.cs +++ b/tests/generator-Tests/SupportFiles/NamespaceMappingAttribute.cs @@ -1,3 +1,5 @@ +#if !JAVA_INTEROP1 + using System; namespace Android.Runtime @@ -14,3 +16,4 @@ public NamespaceMappingAttribute () } } +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/PreserveAttribute.cs b/tests/generator-Tests/SupportFiles/PreserveAttribute.cs index 002f090ca..dbf7ee329 100644 --- a/tests/generator-Tests/SupportFiles/PreserveAttribute.cs +++ b/tests/generator-Tests/SupportFiles/PreserveAttribute.cs @@ -1,3 +1,5 @@ +#if !JAVA_INTEROP1 + // // PreserveAttribute.cs // @@ -53,3 +55,5 @@ public PreserveAttribute () } } } + +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/RegisterAttribute.cs b/tests/generator-Tests/SupportFiles/RegisterAttribute.cs index f93571cef..2da73db47 100644 --- a/tests/generator-Tests/SupportFiles/RegisterAttribute.cs +++ b/tests/generator-Tests/SupportFiles/RegisterAttribute.cs @@ -1,3 +1,5 @@ +#if !JAVA_INTEROP1 + using System; namespace Android.Runtime { @@ -35,3 +37,5 @@ public string Signature { public bool DoNotGenerateAcw {get; set;} } } + +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/TypeManager.cs b/tests/generator-Tests/SupportFiles/TypeManager.cs index 905c2071e..7d269f6f5 100644 --- a/tests/generator-Tests/SupportFiles/TypeManager.cs +++ b/tests/generator-Tests/SupportFiles/TypeManager.cs @@ -1,3 +1,5 @@ +#if !JAVA_INTEROP1 + #pragma warning disable using System; using System.Collections.Generic; @@ -110,3 +112,5 @@ public static void RegisterPackages (string[] packages, Converter[ } } #pragma warning restore + +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/SupportFiles/XAPeerMembers.cs b/tests/generator-Tests/SupportFiles/XAPeerMembers.cs new file mode 100644 index 000000000..b6044ed50 --- /dev/null +++ b/tests/generator-Tests/SupportFiles/XAPeerMembers.cs @@ -0,0 +1,41 @@ +#if !JAVA_INTEROP1 + +using System; +using System.Collections.Generic; + +using Java.Interop; + +namespace Android.Runtime { + + public class XAPeerMembers : JniPeerMembers { + + static Dictionary LegacyPeerMembers = new Dictionary (StringComparer.Ordinal); + + public XAPeerMembers (string jniPeerTypeName, Type managedPeerType) + : base (jniPeerTypeName, managedPeerType) + { + } + + public XAPeerMembers (string jniPeerTypeName, Type managedPeerType, bool isInterface) + : base (jniPeerTypeName, managedPeerType, isInterface) + { + } + + protected override bool UsesVirtualDispatch (IJavaPeerable value, Type declaringType) + { + return false; + } + + static Type GetThresholdType (IJavaPeerable value) + { + return null; + } + + static IntPtr GetThresholdClass (IJavaPeerable value) + { + return IntPtr.Zero; + } + } +} + +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteConstSugarInterfaceFields.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteConstSugarInterfaceFields.txt similarity index 100% rename from tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteConstSugarInterfaceFields.txt rename to tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteConstSugarInterfaceFields.txt diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteDuplicateInterfaceEventArgs.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteDuplicateInterfaceEventArgs.txt new file mode 100644 index 000000000..6aa591629 --- /dev/null +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteDuplicateInterfaceEventArgs.txt @@ -0,0 +1,204 @@ +// Metadata.xml XPath interface reference: path="/api/package[@name='java.code']/interface[@name='AnimatorListener']" +[Register ("java/code/AnimatorListener", "", "java.code.AnimatorListenerInvoker")] +public partial interface AnimatorListener : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='java.code']/interface[@name='AnimatorListener']/method[@name='OnAnimationEnd' and count(parameter)=1 and parameter[1][@type='int']]" + [Register ("OnAnimationEnd", "(I)Z", "GetOnAnimationEnd_IHandler:java.code.AnimatorListenerInvoker, ")] + bool OnAnimationEnd (int param1); + + // Metadata.xml XPath method reference: path="/api/package[@name='java.code']/interface[@name='AnimatorListener']/method[@name='OnAnimationEnd' and count(parameter)=2 and parameter[1][@type='int'] and parameter[2][@type='int']]" + [Register ("OnAnimationEnd", "(II)Z", "GetOnAnimationEnd_IIHandler:java.code.AnimatorListenerInvoker, ")] + bool OnAnimationEnd (int param1, int param2); + +} + +[global::Android.Runtime.Register ("java/code/AnimatorListener", DoNotGenerateAcw=true)] +internal partial class AnimatorListenerInvoker : global::Java.Lang.Object, AnimatorListener { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/code/AnimatorListener", typeof (AnimatorListenerInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + IntPtr class_ref; + + public static AnimatorListener GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.AnimatorListener'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public AnimatorListenerInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_OnAnimationEnd_I; +#pragma warning disable 0169 + static Delegate GetOnAnimationEnd_IHandler () + { + if (cb_OnAnimationEnd_I == null) + cb_OnAnimationEnd_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_Z) n_OnAnimationEnd_I); + return cb_OnAnimationEnd_I; + } + + static bool n_OnAnimationEnd_I (IntPtr jnienv, IntPtr native__this, int param1) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return __this.OnAnimationEnd (param1); + } +#pragma warning restore 0169 + + IntPtr id_OnAnimationEnd_I; + public unsafe bool OnAnimationEnd (int param1) + { + if (id_OnAnimationEnd_I == IntPtr.Zero) + id_OnAnimationEnd_I = JNIEnv.GetMethodID (class_ref, "OnAnimationEnd", "(I)Z"); + JValue* __args = stackalloc JValue [1]; + __args [0] = new JValue (param1); + return JNIEnv.CallBooleanMethod (((global::Java.Lang.Object) this).Handle, id_OnAnimationEnd_I, __args); + } + + static Delegate cb_OnAnimationEnd_II; +#pragma warning disable 0169 + static Delegate GetOnAnimationEnd_IIHandler () + { + if (cb_OnAnimationEnd_II == null) + cb_OnAnimationEnd_II = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPII_Z) n_OnAnimationEnd_II); + return cb_OnAnimationEnd_II; + } + + static bool n_OnAnimationEnd_II (IntPtr jnienv, IntPtr native__this, int param1, int param2) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return __this.OnAnimationEnd (param1, param2); + } +#pragma warning restore 0169 + + IntPtr id_OnAnimationEnd_II; + public unsafe bool OnAnimationEnd (int param1, int param2) + { + if (id_OnAnimationEnd_II == IntPtr.Zero) + id_OnAnimationEnd_II = JNIEnv.GetMethodID (class_ref, "OnAnimationEnd", "(II)Z"); + JValue* __args = stackalloc JValue [2]; + __args [0] = new JValue (param1); + __args [1] = new JValue (param2); + return JNIEnv.CallBooleanMethod (((global::Java.Lang.Object) this).Handle, id_OnAnimationEnd_II, __args); + } + +} + +// event args for java.code.AnimatorListener.OnAnimationEnd +public partial class AnimationEndEventArgs : global::System.EventArgs { + bool handled; + + public bool Handled { + get { return handled; } + set { handled = value; } + } + + public AnimationEndEventArgs (bool handled, int param1) + { + this.handled = handled; + this.param1 = param1; + } + + int param1; + + public int Param1 { + get { return param1; } + } + + public AnimationEndEventArgs (bool handled, int param1, int param2) + { + this.handled = handled; + this.param1 = param1; + this.param2 = param2; + } + + int param2; + + public int Param2 { + get { return param2; } + } + +} + +[global::Android.Runtime.Register ("mono/java/code/AnimatorListenerImplementor")] +internal sealed partial class AnimatorListenerImplementor : global::Java.Lang.Object, AnimatorListener { + + object sender; + + public AnimatorListenerImplementor (object sender) : base (global::Android.Runtime.JNIEnv.StartCreateInstance ("mono/java/code/AnimatorListenerImplementor", "()V"), JniHandleOwnership.TransferLocalRef) + { + global::Android.Runtime.JNIEnv.FinishCreateInstance (((global::Java.Lang.Object) this).Handle, "()V"); + this.sender = sender; + } + + #pragma warning disable 0649 + public EventHandler OnAnimationEndHandler; + #pragma warning restore 0649 + + public bool OnAnimationEnd (int param1) + { + var __h = OnAnimationEndHandler; + if (__h == null) + return false; + var __e = new AnimationEndEventArgs (true, param1); + __h (sender, __e); + return __e.Handled; + } + + #pragma warning disable 0649 + public EventHandler OnAnimationEndHandler; + #pragma warning restore 0649 + + public bool OnAnimationEnd (int param1, int param2) + { + var __h = OnAnimationEndHandler; + if (__h == null) + return false; + var __e = new AnimationEndEventArgs (true, param1, param2); + __h (sender, __e); + return __e.Handled; + } + + internal static bool __IsEmpty (AnimatorListenerImplementor value) + { + return value.OnAnimationEndHandler == null && value.OnAnimationEndHandler == null; + } + +} diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteKotlinUnsignedArrayTypeMethodsClass.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteKotlinUnsignedArrayTypeMethodsClass.txt similarity index 97% rename from tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteKotlinUnsignedArrayTypeMethodsClass.txt rename to tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteKotlinUnsignedArrayTypeMethodsClass.txt index 6f69484cd..cbdfcb4f6 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteKotlinUnsignedArrayTypeMethodsClass.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteKotlinUnsignedArrayTypeMethodsClass.txt @@ -1,7 +1,7 @@ // Metadata.xml XPath class reference: path="/api/package[@name='java.code']/class[@name='MyClass']" [global::Android.Runtime.Register ("java/code/MyClass", DoNotGenerateAcw=true)] public partial class MyClass { - static readonly JniPeerMembers _members = new JniPeerMembers ("java/code/MyClass", typeof (MyClass)); + static readonly JniPeerMembers _members = new XAPeerMembers ("java/code/MyClass", typeof (MyClass)); internal static IntPtr class_ref { get { return _members.JniPeerType.PeerReference.Handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteKotlinUnsignedArrayTypePropertiesClass.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteKotlinUnsignedArrayTypePropertiesClass.txt similarity index 98% rename from tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteKotlinUnsignedArrayTypePropertiesClass.txt rename to tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteKotlinUnsignedArrayTypePropertiesClass.txt index b8fd49fed..8736f0eab 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteKotlinUnsignedArrayTypePropertiesClass.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteKotlinUnsignedArrayTypePropertiesClass.txt @@ -1,7 +1,7 @@ // Metadata.xml XPath class reference: path="/api/package[@name='java.code']/class[@name='MyClass']" [global::Android.Runtime.Register ("java/code/MyClass", DoNotGenerateAcw=true)] public partial class MyClass { - static readonly JniPeerMembers _members = new JniPeerMembers ("java/code/MyClass", typeof (MyClass)); + static readonly JniPeerMembers _members = new XAPeerMembers ("java/code/MyClass", typeof (MyClass)); internal static IntPtr class_ref { get { return _members.JniPeerType.PeerReference.Handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteKotlinUnsignedTypeMethodsClass.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteKotlinUnsignedTypeMethodsClass.txt similarity index 96% rename from tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteKotlinUnsignedTypeMethodsClass.txt rename to tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteKotlinUnsignedTypeMethodsClass.txt index e3581a966..3b132be45 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteKotlinUnsignedTypeMethodsClass.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteKotlinUnsignedTypeMethodsClass.txt @@ -1,7 +1,7 @@ // Metadata.xml XPath class reference: path="/api/package[@name='java.code']/class[@name='MyClass']" [global::Android.Runtime.Register ("java/code/MyClass", DoNotGenerateAcw=true)] public partial class MyClass { - static readonly JniPeerMembers _members = new JniPeerMembers ("java/code/MyClass", typeof (MyClass)); + static readonly JniPeerMembers _members = new XAPeerMembers ("java/code/MyClass", typeof (MyClass)); internal static IntPtr class_ref { get { return _members.JniPeerType.PeerReference.Handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteKotlinUnsignedTypePropertiesClass.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteKotlinUnsignedTypePropertiesClass.txt similarity index 97% rename from tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteKotlinUnsignedTypePropertiesClass.txt rename to tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteKotlinUnsignedTypePropertiesClass.txt index 5d2e840f9..7538d9598 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteKotlinUnsignedTypePropertiesClass.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteKotlinUnsignedTypePropertiesClass.txt @@ -1,7 +1,7 @@ // Metadata.xml XPath class reference: path="/api/package[@name='java.code']/class[@name='MyClass']" [global::Android.Runtime.Register ("java/code/MyClass", DoNotGenerateAcw=true)] public partial class MyClass { - static readonly JniPeerMembers _members = new JniPeerMembers ("java/code/MyClass", typeof (MyClass)); + static readonly JniPeerMembers _members = new XAPeerMembers ("java/code/MyClass", typeof (MyClass)); internal static IntPtr class_ref { get { return _members.JniPeerType.PeerReference.Handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorTests.cs b/tests/generator-Tests/Unit-Tests/CodeGeneratorTests.cs index 73d0bb24c..11ff93398 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorTests.cs +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorTests.cs @@ -10,9 +10,9 @@ namespace generatortests { [TestFixture] - class JavaInteropCodeGeneratorTests : CodeGeneratorTests + class XAJavaInteropCodeGeneratorTests : CodeGeneratorTests { - protected override CodeGenerationTarget Target => CodeGenerationTarget.JavaInterop1; + protected override CodeGenerationTarget Target => CodeGenerationTarget.XAJavaInterop1; [Test] public void WriteKotlinUnsignedTypeMethodsClass () @@ -215,7 +215,7 @@ public void WriteDuplicateInterfaceEventArgs () generator.WriteType (iface, string.Empty, new GenerationInfo ("", "", "MyAssembly")); generator.Context.ContextTypes.Pop (); - Assert.AreEqual (GetExpected (nameof (WriteDuplicateInterfaceEventArgs)), writer.ToString ().NormalizeLineEndings ()); + Assert.AreEqual (GetTargetedExpected (nameof (WriteDuplicateInterfaceEventArgs)), writer.ToString ().NormalizeLineEndings ()); } [Test] @@ -229,7 +229,7 @@ public void SupportedOSPlatform () generator.WriteType (klass, string.Empty, new GenerationInfo ("", "", "MyAssembly")); generator.Context.ContextTypes.Pop (); - StringAssert.DoesNotContain ("[global::System.Runtime.Versioning.SupportedOSPlatformAttribute (\"android30.0\")]", builder.ToString (), "Should contain SupportedOSPlatform!"); + StringAssert.Contains ("[global::System.Runtime.Versioning.SupportedOSPlatformAttribute (\"android30.0\")]", builder.ToString (), "Should contain SupportedOSPlatform!"); } [Test] @@ -271,25 +271,6 @@ public void InheritedInterfaceAsClass () } } - [TestFixture] - class XAJavaInteropCodeGeneratorTests : CodeGeneratorTests - { - protected override CodeGenerationTarget Target => CodeGenerationTarget.XAJavaInterop1; - - [Test] - public void SupportedOSPlatform () - { - var klass = SupportTypeBuilder.CreateClass ("java.code.MyClass", options); - klass.ApiAvailableSince = 30; - - generator.Context.ContextTypes.Push (klass); - generator.WriteType (klass, string.Empty, new GenerationInfo ("", "", "MyAssembly")); - generator.Context.ContextTypes.Pop (); - - StringAssert.Contains ("[global::System.Runtime.Versioning.SupportedOSPlatformAttribute (\"android30.0\")]", builder.ToString (), "Should contain SupportedOSPlatform!"); - } - } - [TestFixture] class XamarinAndroidCodeGeneratorTests : CodeGeneratorTests { diff --git a/tests/generator-Tests/Unit-Tests/DefaultInterfaceMethodsTests.cs b/tests/generator-Tests/Unit-Tests/DefaultInterfaceMethodsTests.cs index 86dc423ac..6bb3b039d 100644 --- a/tests/generator-Tests/Unit-Tests/DefaultInterfaceMethodsTests.cs +++ b/tests/generator-Tests/Unit-Tests/DefaultInterfaceMethodsTests.cs @@ -6,11 +6,13 @@ namespace generatortests { +#if TODO_JAVA_INTEROP1 [TestFixture] class JavaInteropDefaultInterfaceMethodsTests : DefaultInterfaceMethodsTests { protected override CodeGenerationTarget Target => CodeGenerationTarget.JavaInterop1; } +#endif // TODO_JAVA_INTEROP1 [TestFixture] class XAJavaInteropDefaultInterfaceMethodsTests : DefaultInterfaceMethodsTests diff --git a/tests/generator-Tests/Unit-Tests/EnumGeneratorTests.cs b/tests/generator-Tests/Unit-Tests/EnumGeneratorTests.cs index 3d0013d5f..c699846a5 100644 --- a/tests/generator-Tests/Unit-Tests/EnumGeneratorTests.cs +++ b/tests/generator-Tests/Unit-Tests/EnumGeneratorTests.cs @@ -31,7 +31,7 @@ public void WriteBasicEnum () var enu = CreateEnum (); enu.Value.FieldsRemoved = true; - generator.WriteEnumeration (enu, null); + generator.WriteEnumeration (new CodeGenerationOptions (), enu, null); Assert.AreEqual (GetExpected (nameof (WriteBasicEnum)), writer.ToString ().NormalizeLineEndings ()); } @@ -43,7 +43,7 @@ public void WriteFlagsEnum () enu.Value.BitField = true; enu.Value.FieldsRemoved = true; - generator.WriteEnumeration (enu, null); + generator.WriteEnumeration (new CodeGenerationOptions (), enu, null); Assert.AreEqual (GetExpected (nameof (WriteFlagsEnum)), writer.ToString ().NormalizeLineEndings ()); } @@ -54,7 +54,7 @@ public void WriteEnumWithGens () var enu = CreateEnum (); var gens = CreateGens (); - generator.WriteEnumeration (enu, gens); + generator.WriteEnumeration (new CodeGenerationOptions (), enu, gens); Assert.AreEqual (GetExpected (nameof (WriteEnumWithGens)), writer.ToString ().NormalizeLineEndings ()); } diff --git a/tests/generator-Tests/Unit-Tests/InterfaceConstantsTests.cs b/tests/generator-Tests/Unit-Tests/InterfaceConstantsTests.cs index ff883a440..c03a818dd 100644 --- a/tests/generator-Tests/Unit-Tests/InterfaceConstantsTests.cs +++ b/tests/generator-Tests/Unit-Tests/InterfaceConstantsTests.cs @@ -5,9 +5,9 @@ namespace generatortests { [TestFixture] - class JavaInteropInterfaceConstantsTests : InterfaceConstantsTests + class XAJavaInteropInterfaceConstantsTests : InterfaceConstantsTests { - protected override Xamarin.Android.Binder.CodeGenerationTarget Target => Xamarin.Android.Binder.CodeGenerationTarget.JavaInterop1; + protected override Xamarin.Android.Binder.CodeGenerationTarget Target => Xamarin.Android.Binder.CodeGenerationTarget.XAJavaInterop1; } [TestFixture] diff --git a/tests/generator-Tests/Unit-Tests/SymbolTableTests.cs b/tests/generator-Tests/Unit-Tests/SymbolTableTests.cs index 58b714bb9..13b7bb880 100644 --- a/tests/generator-Tests/Unit-Tests/SymbolTableTests.cs +++ b/tests/generator-Tests/Unit-Tests/SymbolTableTests.cs @@ -2,6 +2,8 @@ using MonoDroid.Generation; using NUnit.Framework; +using CodeGenerationTarget = Xamarin.Android.Binder.CodeGenerationTarget; + namespace generatortests { [TestFixture] @@ -10,7 +12,7 @@ public class SymbolTableTests [Test] public void FindGenericTypes () { - var table = new SymbolTable (); + var table = new SymbolTable (CodeGenerationTarget.XAJavaInterop1); var list = new InterfaceGen (new GenBaseSupport { Name = "System.Collections.Generic.IList`1", diff --git a/tests/generator-Tests/expected.ji/AccessModifiers/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/AccessModifiers/Java.Lang.Object.cs new file mode 100644 index 000000000..86d0bd17b --- /dev/null +++ b/tests/generator-Tests/expected.ji/AccessModifiers/Java.Lang.Object.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] + public partial class Object { + static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); + + } +} diff --git a/tests/generator-Tests/expected.ji/AccessModifiers/Mono.Android.projitems b/tests/generator-Tests/expected.ji/AccessModifiers/Mono.Android.projitems index 8202bce47..cceaf3aec 100644 --- a/tests/generator-Tests/expected.ji/AccessModifiers/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/AccessModifiers/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.BasePublicClass.cs b/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.BasePublicClass.cs index efda9e527..5a7b398d4 100644 --- a/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.BasePublicClass.cs +++ b/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.BasePublicClass.cs @@ -1,59 +1,25 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='BasePublicClass']" - [global::Android.Runtime.Register ("xamarin/test/BasePublicClass", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/BasePublicClass", GenerateJavaPeer=false)] public partial class BasePublicClass : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/BasePublicClass", typeof (BasePublicClass)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected BasePublicClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - static Delegate cb_baseMethod; -#pragma warning disable 0169 - static Delegate GetBaseMethodHandler () - { - if (cb_baseMethod == null) - cb_baseMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_BaseMethod); - return cb_baseMethod; - } - - static void n_BaseMethod (IntPtr jnienv, IntPtr native__this) + protected BasePublicClass (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.BaseMethod (); } -#pragma warning restore 0169 // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='BasePublicClass']/method[@name='baseMethod' and count(parameter)=0]" - [Register ("baseMethod", "()V", "GetBaseMethodHandler")] public virtual unsafe void BaseMethod () { const string __id = "baseMethod.()V"; diff --git a/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.ExtendPublicClass.cs b/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.ExtendPublicClass.cs index 14e6ba03b..d92029e62 100644 --- a/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.ExtendPublicClass.cs +++ b/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.ExtendPublicClass.cs @@ -1,76 +1,41 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='ExtendPublicClass']" - [global::Android.Runtime.Register ("xamarin/test/ExtendPublicClass", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/ExtendPublicClass", GenerateJavaPeer=false)] public partial class ExtendPublicClass : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/ExtendPublicClass", typeof (ExtendPublicClass)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected ExtendPublicClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected ExtendPublicClass (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='ExtendPublicClass']/constructor[@name='ExtendPublicClass' and count(parameter)=0]" - [Register (".ctor", "()V", "")] - public unsafe ExtendPublicClass () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe ExtendPublicClass () : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "()V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; try { var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { } } - static Delegate cb_foo; -#pragma warning disable 0169 - static Delegate GetFooHandler () - { - if (cb_foo == null) - cb_foo = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Foo); - return cb_foo; - } - - static void n_Foo (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Foo (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='ExtendPublicClass']/method[@name='foo' and count(parameter)=0]" - [Register ("foo", "()V", "GetFooHandler")] public virtual unsafe void Foo () { const string __id = "foo.()V"; diff --git a/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.IExtendedInterface.cs b/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.IExtendedInterface.cs new file mode 100644 index 000000000..0a17ac6e0 --- /dev/null +++ b/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.IExtendedInterface.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath interface reference: path="/api/package[@name='xamarin.test']/interface[@name='ExtendedInterface']" + [global::Java.Interop.JniTypeSignature ("xamarin/test/ExtendedInterface", GenerateJavaPeer=false)] + public partial interface IExtendedInterface : IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='ExtendedInterface']/method[@name='extendedMethod' and count(parameter)=0]" + void ExtendedMethod (); + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='BaseInterface']/method[@name='baseMethod' and count(parameter)=0]" + void BaseMethod (); + + } +} diff --git a/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.PublicClass.cs b/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.PublicClass.cs index 9a482e985..929dbc2f1 100644 --- a/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.PublicClass.cs +++ b/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.PublicClass.cs @@ -1,166 +1,49 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='PublicClass']" - [global::Android.Runtime.Register ("xamarin/test/PublicClass", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/PublicClass", GenerateJavaPeer=false)] public partial class PublicClass : global::Java.Lang.Object { // Metadata.xml XPath interface reference: path="/api/package[@name='xamarin.test']/interface[@name='PublicClass.ProtectedInterface']" - [Register ("xamarin/test/PublicClass$ProtectedInterface", "", "Xamarin.Test.PublicClass/IProtectedInterfaceInvoker")] - protected internal partial interface IProtectedInterface : IJavaObject, IJavaPeerable { + [global::Java.Interop.JniTypeSignature ("xamarin/test/PublicClass$ProtectedInterface", GenerateJavaPeer=false)] + protected internal partial interface IProtectedInterface : IJavaPeerable { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='PublicClass.ProtectedInterface']/method[@name='foo' and count(parameter)=0]" - [Register ("foo", "()V", "GetFooHandler:Xamarin.Test.PublicClass/IProtectedInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] void Foo (); } - [global::Android.Runtime.Register ("xamarin/test/PublicClass$ProtectedInterface", DoNotGenerateAcw=true)] - internal partial class IProtectedInterfaceInvoker : global::Java.Lang.Object, IProtectedInterface { - static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/PublicClass$ProtectedInterface", typeof (IProtectedInterfaceInvoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static IProtectedInterface GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.PublicClass.ProtectedInterface'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public IProtectedInterfaceInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - - static Delegate cb_foo; -#pragma warning disable 0169 - static Delegate GetFooHandler () - { - if (cb_foo == null) - cb_foo = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Foo); - return cb_foo; - } - - static void n_Foo (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Foo (); - } -#pragma warning restore 0169 - - IntPtr id_foo; - public unsafe void Foo () - { - if (id_foo == IntPtr.Zero) - id_foo = JNIEnv.GetMethodID (class_ref, "foo", "()V"); - JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_foo); - } - - } - static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/PublicClass", typeof (PublicClass)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected PublicClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected PublicClass (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='PublicClass']/constructor[@name='PublicClass' and count(parameter)=0]" - [Register (".ctor", "()V", "")] - public unsafe PublicClass () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe PublicClass () : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "()V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; try { var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { } } - static Delegate cb_foo; -#pragma warning disable 0169 - static Delegate GetFooHandler () - { - if (cb_foo == null) - cb_foo = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Foo); - return cb_foo; - } - - static void n_Foo (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Foo (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='PublicClass']/method[@name='foo' and count(parameter)=0]" - [Register ("foo", "()V", "GetFooHandler")] public virtual unsafe void Foo () { const string __id = "foo.()V"; diff --git a/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.PublicFinalClass.cs b/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.PublicFinalClass.cs index 387c3f073..6683b1d57 100644 --- a/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.PublicFinalClass.cs +++ b/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.PublicFinalClass.cs @@ -1,43 +1,25 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='PublicFinalClass']" - [global::Android.Runtime.Register ("xamarin/test/PublicFinalClass", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/PublicFinalClass", GenerateJavaPeer=false)] public sealed partial class PublicFinalClass : global::Xamarin.Test.BasePublicClass { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/PublicFinalClass", typeof (PublicFinalClass)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - internal PublicFinalClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + internal PublicFinalClass (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='PublicFinalClass']/method[@name='publicMethod' and count(parameter)=0]" - [Register ("publicMethod", "()V", "")] public unsafe void PublicMethod () { const string __id = "publicMethod.()V"; @@ -48,7 +30,6 @@ public unsafe void PublicMethod () } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='PackageClassB']/method[@name='packageMethodB' and count(parameter)=0]" - [Register ("packageMethodB", "()V", "")] public unsafe void PackageMethodB () { const string __id = "packageMethodB.()V"; @@ -59,7 +40,6 @@ public unsafe void PackageMethodB () } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='PackageClassA']/method[@name='packageMethodA' and count(parameter)=0]" - [Register ("packageMethodA", "()V", "")] public unsafe void PackageMethodA () { const string __id = "packageMethodA.()V"; diff --git a/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.TestClass.cs b/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.TestClass.cs new file mode 100644 index 000000000..f1a79bc67 --- /dev/null +++ b/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.TestClass.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='TestClass']" + [global::Java.Interop.JniTypeSignature ("xamarin/test/TestClass", GenerateJavaPeer=false)] + public partial class TestClass : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/TestClass", typeof (TestClass)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + protected TestClass (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='TestClass']/constructor[@name='TestClass' and count(parameter)=0]" + public unsafe TestClass () : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) + { + const string __id = "()V"; + + if (PeerReference.IsValid) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='TestClass']/method[@name='baseMethod' and count(parameter)=0]" + public virtual unsafe void BaseMethod () + { + const string __id = "baseMethod.()V"; + try { + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.ji/AccessModifiers/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/AccessModifiers/__NamespaceMapping__.cs new file mode 100644 index 000000000..417caab06 --- /dev/null +++ b/tests/generator-Tests/expected.ji/AccessModifiers/__NamespaceMapping__.cs @@ -0,0 +1,2 @@ +using System; + diff --git a/tests/generator-Tests/expected.ji/AccessModifiers/enumlist b/tests/generator-Tests/expected.ji/AccessModifiers/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/Adapters/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/Adapters/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/Adapters/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/Adapters/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/Adapters/Mono.Android.projitems b/tests/generator-Tests/expected.ji/Adapters/Mono.Android.projitems index 4e6987503..e44fcabbd 100644 --- a/tests/generator-Tests/expected.ji/Adapters/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/Adapters/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AbsSpinner.cs b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AbsSpinner.cs index a8aa324ba..bc042e770 100644 --- a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AbsSpinner.cs +++ b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AbsSpinner.cs @@ -1,92 +1,40 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='AbsSpinner']" - [global::Android.Runtime.Register ("xamarin/test/AbsSpinner", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/AbsSpinner", GenerateJavaPeer=false)] public abstract partial class AbsSpinner : Xamarin.Test.AdapterView { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/AbsSpinner", typeof (AbsSpinner)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected AbsSpinner (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - static Delegate cb_getAdapter; -#pragma warning disable 0169 - static Delegate GetGetAdapterHandler () + protected AbsSpinner (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - if (cb_getAdapter == null) - cb_getAdapter = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetAdapter); - return cb_getAdapter; } - static IntPtr n_GetAdapter (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.ToLocalJniHandle (__this.Adapter); - } -#pragma warning restore 0169 - - static Delegate cb_setAdapter_Lxamarin_test_SpinnerAdapter_; -#pragma warning disable 0169 - static Delegate GetSetAdapter_Lxamarin_test_SpinnerAdapter_Handler () - { - if (cb_setAdapter_Lxamarin_test_SpinnerAdapter_ == null) - cb_setAdapter_Lxamarin_test_SpinnerAdapter_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetAdapter_Lxamarin_test_SpinnerAdapter_); - return cb_setAdapter_Lxamarin_test_SpinnerAdapter_; - } - - static void n_SetAdapter_Lxamarin_test_SpinnerAdapter_ (IntPtr jnienv, IntPtr native__this, IntPtr native_adapter) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var adapter = (global::Xamarin.Test.ISpinnerAdapter)global::Java.Lang.Object.GetObject (native_adapter, JniHandleOwnership.DoNotTransfer); - __this.Adapter = adapter; - } -#pragma warning restore 0169 - public override unsafe global::Xamarin.Test.ISpinnerAdapter Adapter { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AbsSpinner']/method[@name='getAdapter' and count(parameter)=0]" - [Register ("getAdapter", "()Lxamarin/test/SpinnerAdapter;", "GetGetAdapterHandler")] get { const string __id = "getAdapter.()Lxamarin/test/SpinnerAdapter;"; try { var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); - return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AbsSpinner']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='xamarin.test.SpinnerAdapter']]" - [Register ("setAdapter", "(Lxamarin/test/SpinnerAdapter;)V", "GetSetAdapter_Lxamarin_test_SpinnerAdapter_Handler")] set { const string __id = "setAdapter.(Lxamarin/test/SpinnerAdapter;)V"; try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue ((value == null) ? IntPtr.Zero : ((global::Java.Lang.Object) value).Handle); + __args [0] = new JniArgumentValue (value); _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); } finally { global::System.GC.KeepAlive (value); @@ -96,9 +44,9 @@ static void n_SetAdapter_Lxamarin_test_SpinnerAdapter_ (IntPtr jnienv, IntPtr na } - [global::Android.Runtime.Register ("xamarin/test/AbsSpinner", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/AbsSpinner", GenerateJavaPeer=false)] internal partial class AbsSpinnerInvoker : AbsSpinner { - public AbsSpinnerInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + public AbsSpinnerInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } @@ -110,25 +58,17 @@ public AbsSpinnerInvoker (IntPtr handle, JniHandleOwnership transfer) : base (ha get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - protected override unsafe global::Java.Lang.Object RawAdapter { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='getAdapter' and count(parameter)=0]" - [Register ("getAdapter", "()Lxamarin/test/Adapter;", "GetGetAdapterHandler")] get { const string __id = "getAdapter.()Lxamarin/test/Adapter;"; try { var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null); - return (global::Java.Lang.Object) global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='T']]" - [Register ("setAdapter", "(Lxamarin/test/Adapter;)V", "GetSetAdapter_Lxamarin_test_Adapter_Handler")] set { const string __id = "setAdapter.(Lxamarin/test/Adapter;)V"; IntPtr native_value = JNIEnv.ToLocalJniHandle (value); diff --git a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AdapterView.cs b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AdapterView.cs index bd20c02ba..2d51d9e06 100644 --- a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AdapterView.cs +++ b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AdapterView.cs @@ -1,74 +1,24 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']" - [global::Android.Runtime.Register ("xamarin/test/AdapterView", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/AdapterView", GenerateJavaPeer=false)] [global::Java.Interop.JavaTypeParameters (new string [] {"T extends xamarin.test.Adapter"})] public abstract partial class AdapterView : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/AdapterView", typeof (AdapterView)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected AdapterView (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - static Delegate cb_getAdapter; -#pragma warning disable 0169 - static Delegate GetGetAdapterHandler () - { - if (cb_getAdapter == null) - cb_getAdapter = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetAdapter); - return cb_getAdapter; - } - - static IntPtr n_GetAdapter (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.ToLocalJniHandle (__this.RawAdapter); - } -#pragma warning restore 0169 - - static Delegate cb_setAdapter_Lxamarin_test_Adapter_; -#pragma warning disable 0169 - static Delegate GetSetAdapter_Lxamarin_test_Adapter_Handler () - { - if (cb_setAdapter_Lxamarin_test_Adapter_ == null) - cb_setAdapter_Lxamarin_test_Adapter_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetAdapter_Lxamarin_test_Adapter_); - return cb_setAdapter_Lxamarin_test_Adapter_; - } - - static void n_SetAdapter_Lxamarin_test_Adapter_ (IntPtr jnienv, IntPtr native__this, IntPtr native_adapter) + protected AdapterView (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var adapter = global::Java.Lang.Object.GetObject (native_adapter, JniHandleOwnership.DoNotTransfer); - __this.RawAdapter = adapter; } -#pragma warning restore 0169 protected abstract global::Java.Lang.Object RawAdapter { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='getAdapter' and count(parameter)=0]" @@ -82,9 +32,9 @@ static void n_SetAdapter_Lxamarin_test_Adapter_ (IntPtr jnienv, IntPtr native__t } - [global::Android.Runtime.Register ("xamarin/test/AdapterView", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/AdapterView", GenerateJavaPeer=false)] internal partial class AdapterViewInvoker : AdapterView { - public AdapterViewInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + public AdapterViewInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } @@ -96,25 +46,17 @@ public AdapterViewInvoker (IntPtr handle, JniHandleOwnership transfer) : base (h get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - protected override unsafe global::Java.Lang.Object RawAdapter { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='getAdapter' and count(parameter)=0]" - [Register ("getAdapter", "()Lxamarin/test/Adapter;", "GetGetAdapterHandler")] get { const string __id = "getAdapter.()Lxamarin/test/Adapter;"; try { var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null); - return (global::Java.Lang.Object) global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='T']]" - [Register ("setAdapter", "(Lxamarin/test/Adapter;)V", "GetSetAdapter_Lxamarin_test_Adapter_Handler")] set { const string __id = "setAdapter.(Lxamarin/test/Adapter;)V"; IntPtr native_value = JNIEnv.ToLocalJniHandle (value); diff --git a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.GenericReturnObject.cs b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.GenericReturnObject.cs index 51aa2d630..01bdabfaa 100644 --- a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.GenericReturnObject.cs +++ b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.GenericReturnObject.cs @@ -1,65 +1,31 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='GenericReturnObject']" - [global::Android.Runtime.Register ("xamarin/test/GenericReturnObject", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/GenericReturnObject", GenerateJavaPeer=false)] public partial class GenericReturnObject : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/GenericReturnObject", typeof (GenericReturnObject)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected GenericReturnObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - static Delegate cb_GenericReturn; -#pragma warning disable 0169 - static Delegate GetGenericReturnHandler () - { - if (cb_GenericReturn == null) - cb_GenericReturn = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GenericReturn); - return cb_GenericReturn; - } - - static IntPtr n_GenericReturn (IntPtr jnienv, IntPtr native__this) + protected GenericReturnObject (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.ToLocalJniHandle (__this.GenericReturn ()); } -#pragma warning restore 0169 // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='GenericReturnObject']/method[@name='GenericReturn' and count(parameter)=0]" - [Register ("GenericReturn", "()Lxamarin/test/AdapterView;", "GetGenericReturnHandler")] public virtual unsafe global::Xamarin.Test.AdapterView GenericReturn () { const string __id = "GenericReturn.()Lxamarin/test/AdapterView;"; try { var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); - return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } diff --git a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs index 8d197615c..65e5026e1 100644 --- a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs +++ b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs @@ -1,69 +1,11 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath interface reference: path="/api/package[@name='xamarin.test']/interface[@name='Adapter']" - [Register ("xamarin/test/Adapter", "", "Xamarin.Test.IAdapterInvoker")] - public partial interface IAdapter : IJavaObject, IJavaPeerable { - } - - [global::Android.Runtime.Register ("xamarin/test/Adapter", DoNotGenerateAcw=true)] - internal partial class IAdapterInvoker : global::Java.Lang.Object, IAdapter { - static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/Adapter", typeof (IAdapterInvoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static IAdapter GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.Adapter'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public IAdapterInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - + [global::Java.Interop.JniTypeSignature ("xamarin/test/Adapter", GenerateJavaPeer=false)] + public partial interface IAdapter : IJavaPeerable { } } diff --git a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs index 9852897fc..2a63a5060 100644 --- a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs +++ b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs @@ -1,69 +1,11 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath interface reference: path="/api/package[@name='xamarin.test']/interface[@name='SpinnerAdapter']" - [Register ("xamarin/test/SpinnerAdapter", "", "Xamarin.Test.ISpinnerAdapterInvoker")] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SpinnerAdapter", GenerateJavaPeer=false)] public partial interface ISpinnerAdapter : global::Xamarin.Test.IAdapter { } - - [global::Android.Runtime.Register ("xamarin/test/SpinnerAdapter", DoNotGenerateAcw=true)] - internal partial class ISpinnerAdapterInvoker : global::Java.Lang.Object, ISpinnerAdapter { - static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/SpinnerAdapter", typeof (ISpinnerAdapterInvoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static ISpinnerAdapter GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.SpinnerAdapter'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public ISpinnerAdapterInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - - } } diff --git a/tests/generator-Tests/expected.ji/Adapters/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/Adapters/__NamespaceMapping__.cs index 17938559b..417caab06 100644 --- a/tests/generator-Tests/expected.ji/Adapters/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/Adapters/__NamespaceMapping__.cs @@ -1,7 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] - -delegate IntPtr _JniMarshal_PP_L (IntPtr jnienv, IntPtr klass); -delegate void _JniMarshal_PPL_V (IntPtr jnienv, IntPtr klass, IntPtr p0); diff --git a/tests/generator-Tests/expected.ji/Android.Graphics.Color/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/Android.Graphics.Color/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/Android.Graphics.Color/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/Android.Graphics.Color/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/Android.Graphics.Color/Mono.Android.projitems b/tests/generator-Tests/expected.ji/Android.Graphics.Color/Mono.Android.projitems index 066be1dd1..c47692f39 100644 --- a/tests/generator-Tests/expected.ji/Android.Graphics.Color/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/Android.Graphics.Color/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/Android.Graphics.Color/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.ji/Android.Graphics.Color/Xamarin.Test.SomeObject.cs index 074889706..014aae545 100644 --- a/tests/generator-Tests/expected.ji/Android.Graphics.Color/Xamarin.Test.SomeObject.cs +++ b/tests/generator-Tests/expected.ji/Android.Graphics.Color/Xamarin.Test.SomeObject.cs @@ -1,109 +1,29 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" - [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject", GenerateJavaPeer=false)] public abstract partial class SomeObject : global::Java.Lang.Object { - - // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='backColor']" - [Register ("backColor")] - public global::Android.Graphics.Color BackColor { - get { - const string __id = "backColor.I"; - - var __v = _members.InstanceFields.GetInt32Value (__id, this); - return new global::Android.Graphics.Color (__v); - } - set { - const string __id = "backColor.I"; - - try { - _members.InstanceFields.SetValue (__id, this, value.ToArgb ()); - } finally { - } - } - } - static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - static Delegate cb_getSomeColor; -#pragma warning disable 0169 - static Delegate GetGetSomeColorHandler () + protected SomeObject (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - if (cb_getSomeColor == null) - cb_getSomeColor = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_GetSomeColor); - return cb_getSomeColor; - } - - static int n_GetSomeColor (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return __this.SomeColor.ToArgb (); - } -#pragma warning restore 0169 - - static Delegate cb_setSomeColor_I; -#pragma warning disable 0169 - static Delegate GetSetSomeColor_IHandler () - { - if (cb_setSomeColor_I == null) - cb_setSomeColor_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_SetSomeColor_I); - return cb_setSomeColor_I; - } - - static void n_SetSomeColor_I (IntPtr jnienv, IntPtr native__this, int native_newvalue) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var newvalue = new global::Android.Graphics.Color (native_newvalue); - __this.SomeColor = newvalue; - } -#pragma warning restore 0169 - - public abstract global::Android.Graphics.Color SomeColor { - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeColor' and count(parameter)=0]" - [Register ("getSomeColor", "()I", "GetGetSomeColorHandler")] - get; - - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeColor' and count(parameter)=1 and parameter[1][@type='Android.Graphics.Color']]" - [Register ("setSomeColor", "(I)V", "GetSetSomeColor_IHandler")] - set; } } - [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject", GenerateJavaPeer=false)] internal partial class SomeObjectInvoker : SomeObject { - public SomeObjectInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + public SomeObjectInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } @@ -115,35 +35,5 @@ public SomeObjectInvoker (IntPtr handle, JniHandleOwnership transfer) : base (ha get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - public override unsafe global::Android.Graphics.Color SomeColor { - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeColor' and count(parameter)=0]" - [Register ("getSomeColor", "()I", "GetGetSomeColorHandler")] - get { - const string __id = "getSomeColor.()I"; - try { - var __rm = _members.InstanceMethods.InvokeAbstractInt32Method (__id, this, null); - return new global::Android.Graphics.Color (__rm); - } finally { - } - } - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeColor' and count(parameter)=1 and parameter[1][@type='Android.Graphics.Color']]" - [Register ("setSomeColor", "(I)V", "GetSetSomeColor_IHandler")] - set { - const string __id = "setSomeColor.(I)V"; - try { - JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue (value.ToArgb ()); - _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args); - } finally { - } - } - } - } } diff --git a/tests/generator-Tests/expected.ji/Android.Graphics.Color/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/Android.Graphics.Color/__NamespaceMapping__.cs index c5083c6ff..417caab06 100644 --- a/tests/generator-Tests/expected.ji/Android.Graphics.Color/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/Android.Graphics.Color/__NamespaceMapping__.cs @@ -1,7 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] - -delegate int _JniMarshal_PP_I (IntPtr jnienv, IntPtr klass); -delegate void _JniMarshal_PPI_V (IntPtr jnienv, IntPtr klass, int p0); diff --git a/tests/generator-Tests/expected.ji/Arrays/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/Arrays/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/Arrays/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/Arrays/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/Arrays/Mono.Android.projitems b/tests/generator-Tests/expected.ji/Arrays/Mono.Android.projitems index 066be1dd1..c47692f39 100644 --- a/tests/generator-Tests/expected.ji/Arrays/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/Arrays/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/Arrays/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.ji/Arrays/Xamarin.Test.SomeObject.cs index 4936e8226..a2c81f637 100644 --- a/tests/generator-Tests/expected.ji/Arrays/Xamarin.Test.SomeObject.cs +++ b/tests/generator-Tests/expected.ji/Arrays/Xamarin.Test.SomeObject.cs @@ -1,16 +1,14 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" - [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject", GenerateJavaPeer=false)] public partial class SomeObject : global::Java.Lang.Object { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myStrings']" - [Register ("myStrings")] public IList MyStrings { get { const string __id = "myStrings.[Ljava/lang/String;"; @@ -32,7 +30,6 @@ public IList MyStrings { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myInts']" - [Register ("myInts")] public IList MyInts { get { const string __id = "myInts.[I"; @@ -54,7 +51,6 @@ public IList MyInts { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='mybools']" - [Register ("mybools")] public IList Mybools { get { const string __id = "mybools.[Z"; @@ -76,7 +72,6 @@ public IList Mybools { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myObjects']" - [Register ("myObjects")] public IList MyObjects { get { const string __id = "myObjects.[Ljava/lang/Object;"; @@ -98,7 +93,6 @@ public IList MyObjects { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myfloats']" - [Register ("myfloats")] public IList Myfloats { get { const string __id = "myfloats.[F"; @@ -120,7 +114,6 @@ public IList Myfloats { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='mydoubles']" - [Register ("mydoubles")] public IList Mydoubles { get { const string __id = "mydoubles.[D"; @@ -142,7 +135,6 @@ public IList Mydoubles { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='mylongs']" - [Register ("mylongs")] public IList Mylongs { get { const string __id = "mylongs.[J"; @@ -164,29 +156,13 @@ public IList Mylongs { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected SomeObject (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } diff --git a/tests/generator-Tests/expected.ji/Arrays/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/Arrays/__NamespaceMapping__.cs index acb570f6c..417caab06 100644 --- a/tests/generator-Tests/expected.ji/Arrays/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/Arrays/__NamespaceMapping__.cs @@ -1,5 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] - diff --git a/tests/generator-Tests/expected.ji/CSharpKeywords/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/CSharpKeywords/Java.Lang.Object.cs new file mode 100644 index 000000000..86d0bd17b --- /dev/null +++ b/tests/generator-Tests/expected.ji/CSharpKeywords/Java.Lang.Object.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] + public partial class Object { + static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); + + } +} diff --git a/tests/generator-Tests/expected.ji/CSharpKeywords/Java.Lang.Throwable.cs b/tests/generator-Tests/expected.ji/CSharpKeywords/Java.Lang.Throwable.cs new file mode 100644 index 000000000..819a48c13 --- /dev/null +++ b/tests/generator-Tests/expected.ji/CSharpKeywords/Java.Lang.Throwable.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Throwable']" + [global::Java.Interop.JniTypeSignature ("java/lang/Throwable", GenerateJavaPeer=false)] + public partial class Throwable { + static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Throwable", typeof (Throwable)); + + public new virtual unsafe string Message { + // Metadata.xml XPath method reference: path="/api/package[@name='java.lang']/class[@name='Throwable']/method[@name='getMessage' and count(parameter)=0]" + get { + const string __id = "getMessage.()Ljava/lang/String;"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); + return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose); + } finally { + } + } + } + + } +} diff --git a/tests/generator-Tests/expected.ji/CSharpKeywords/Mono.Android.projitems b/tests/generator-Tests/expected.ji/CSharpKeywords/Mono.Android.projitems index 1e80d027f..449fda2e9 100644 --- a/tests/generator-Tests/expected.ji/CSharpKeywords/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/CSharpKeywords/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/CSharpKeywords/Xamarin.Test.CSharpKeywords.cs b/tests/generator-Tests/expected.ji/CSharpKeywords/Xamarin.Test.CSharpKeywords.cs index 754039fbe..e63b2eb74 100644 --- a/tests/generator-Tests/expected.ji/CSharpKeywords/Xamarin.Test.CSharpKeywords.cs +++ b/tests/generator-Tests/expected.ji/CSharpKeywords/Xamarin.Test.CSharpKeywords.cs @@ -1,59 +1,25 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='CSharpKeywords']" - [global::Android.Runtime.Register ("xamarin/test/CSharpKeywords", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/CSharpKeywords", GenerateJavaPeer=false)] public partial class CSharpKeywords : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/CSharpKeywords", typeof (CSharpKeywords)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected CSharpKeywords (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - static Delegate cb_usePartial_I; -#pragma warning disable 0169 - static Delegate GetUsePartial_IHandler () - { - if (cb_usePartial_I == null) - cb_usePartial_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_L) n_UsePartial_I); - return cb_usePartial_I; - } - - static IntPtr n_UsePartial_I (IntPtr jnienv, IntPtr native__this, int partial) + protected CSharpKeywords (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.NewString (__this.UsePartial (partial)); } -#pragma warning restore 0169 // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='CSharpKeywords']/method[@name='usePartial' and count(parameter)=1 and parameter[1][@type='int']]" - [Register ("usePartial", "(I)Ljava/lang/String;", "GetUsePartial_IHandler")] public virtual unsafe string UsePartial (int partial) { const string __id = "usePartial.(I)Ljava/lang/String;"; @@ -61,24 +27,23 @@ public virtual unsafe string UsePartial (int partial) JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (partial); var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, __args); - return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='CSharpKeywords']/method[@name='useThis' and count(parameter)=1 and parameter[1][@type='java.lang.String']]" - [Register ("useThis", "(Ljava/lang/String;)Ljava/lang/String;", "")] public static unsafe string UseThis (string this_) { const string __id = "useThis.(Ljava/lang/String;)Ljava/lang/String;"; - IntPtr native_this = JNIEnv.NewString (this_); + var native_this = global::Java.Interop.JniEnvironment.Strings.NewString (this_); try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (native_this); var __rm = _members.StaticMethods.InvokeObjectMethod (__id, __args); - return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { - JNIEnv.DeleteLocalRef (native_this); + global::Java.Interop.JniObjectReference.Dispose (ref native_this); } } diff --git a/tests/generator-Tests/expected.ji/CSharpKeywords/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/CSharpKeywords/__NamespaceMapping__.cs new file mode 100644 index 000000000..417caab06 --- /dev/null +++ b/tests/generator-Tests/expected.ji/CSharpKeywords/__NamespaceMapping__.cs @@ -0,0 +1,2 @@ +using System; + diff --git a/tests/generator-Tests/expected.ji/CSharpKeywords/enumlist b/tests/generator-Tests/expected.ji/CSharpKeywords/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/Constructors/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/Constructors/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/Constructors/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/Constructors/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/Constructors/Mono.Android.projitems b/tests/generator-Tests/expected.ji/Constructors/Mono.Android.projitems index 82192a590..5f74b81c0 100644 --- a/tests/generator-Tests/expected.ji/Constructors/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/Constructors/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/Constructors/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.ji/Constructors/Xamarin.Test.SomeObject.cs index 46464d5c6..20ad2b2e6 100644 --- a/tests/generator-Tests/expected.ji/Constructors/Xamarin.Test.SomeObject.cs +++ b/tests/generator-Tests/expected.ji/Constructors/Xamarin.Test.SomeObject.cs @@ -1,73 +1,54 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" - [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject", GenerateJavaPeer=false)] public partial class SomeObject : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected SomeObject (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/constructor[@name='SomeObject' and count(parameter)=0]" - [Register (".ctor", "()V", "")] [Obsolete (@"deprecated")] - public unsafe SomeObject () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe SomeObject () : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "()V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; try { var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { } } // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/constructor[@name='SomeObject' and count(parameter)=1 and parameter[1][@type='int']]" - [Register (".ctor", "(I)V", "")] - public unsafe SomeObject (int aint) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe SomeObject (int aint) : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "(I)V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (aint); var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, __args); } finally { } diff --git a/tests/generator-Tests/expected.ji/Constructors/Xamarin.Test.SomeObject2.cs b/tests/generator-Tests/expected.ji/Constructors/Xamarin.Test.SomeObject2.cs new file mode 100644 index 000000000..61fde3751 --- /dev/null +++ b/tests/generator-Tests/expected.ji/Constructors/Xamarin.Test.SomeObject2.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject2']" + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject2", GenerateJavaPeer=false)] + public sealed partial class SomeObject2 : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/SomeObject2", typeof (SomeObject2)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + internal SomeObject2 (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject2']/constructor[@name='SomeObject2' and count(parameter)=1 and parameter[1][@type='int']]" + public unsafe SomeObject2 (int aint) : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) + { + const string __id = "(I)V"; + + if (PeerReference.IsValid) + return; + + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (aint); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); + _members.InstanceMethods.FinishCreateInstance (__id, this, __args); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.ji/Constructors/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/Constructors/__NamespaceMapping__.cs index acb570f6c..417caab06 100644 --- a/tests/generator-Tests/expected.ji/Constructors/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/Constructors/__NamespaceMapping__.cs @@ -1,5 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] - diff --git a/tests/generator-Tests/expected.ji/Core_ClassParse/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/Core_ClassParse/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/Core_ClassParse/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/Core_ClassParse/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/Core_ClassParse/Java.Lang.String.cs b/tests/generator-Tests/expected.ji/Core_ClassParse/Java.Lang.String.cs index ea7f27cf3..f0b531609 100644 --- a/tests/generator-Tests/expected.ji/Core_ClassParse/Java.Lang.String.cs +++ b/tests/generator-Tests/expected.ji/Core_ClassParse/Java.Lang.String.cs @@ -1,38 +1,21 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='String']" - [global::Android.Runtime.Register ("java/lang/String", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/String", GenerateJavaPeer=false)] public partial class String : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/String", typeof (String)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected String (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected String (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } diff --git a/tests/generator-Tests/expected.ji/Core_ClassParse/Mono.Android.projitems b/tests/generator-Tests/expected.ji/Core_ClassParse/Mono.Android.projitems new file mode 100644 index 000000000..e94c83f04 --- /dev/null +++ b/tests/generator-Tests/expected.ji/Core_ClassParse/Mono.Android.projitems @@ -0,0 +1,16 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.ji/Core_ClassParse/Xamarin.Test.Invalidnames.In.cs b/tests/generator-Tests/expected.ji/Core_ClassParse/Xamarin.Test.Invalidnames.In.cs index 5d1d40268..32708d624 100644 --- a/tests/generator-Tests/expected.ji/Core_ClassParse/Xamarin.Test.Invalidnames.In.cs +++ b/tests/generator-Tests/expected.ji/Core_ClassParse/Xamarin.Test.Invalidnames.In.cs @@ -1,38 +1,21 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test.Invalidnames { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test.invalidnames']/class[@name='in']" - [global::Android.Runtime.Register ("xamarin/test/invalidnames/in", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/invalidnames/in", GenerateJavaPeer=false)] public partial class In : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/invalidnames/in", typeof (In)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected In (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected In (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } diff --git a/tests/generator-Tests/expected.ji/Core_ClassParse/Xamarin.Test.Invalidnames.InvalidNameMembers.cs b/tests/generator-Tests/expected.ji/Core_ClassParse/Xamarin.Test.Invalidnames.InvalidNameMembers.cs index a6a44e38b..4d7823993 100644 --- a/tests/generator-Tests/expected.ji/Core_ClassParse/Xamarin.Test.Invalidnames.InvalidNameMembers.cs +++ b/tests/generator-Tests/expected.ji/Core_ClassParse/Xamarin.Test.Invalidnames.InvalidNameMembers.cs @@ -1,38 +1,21 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test.Invalidnames { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test.invalidnames']/class[@name='InvalidNameMembers']" - [global::Android.Runtime.Register ("xamarin/test/invalidnames/InvalidNameMembers", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/invalidnames/InvalidNameMembers", GenerateJavaPeer=false)] public partial class InvalidNameMembers : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/invalidnames/InvalidNameMembers", typeof (InvalidNameMembers)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected InvalidNameMembers (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected InvalidNameMembers (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } diff --git a/tests/generator-Tests/expected.ji/Core_ClassParse/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/Core_ClassParse/__NamespaceMapping__.cs new file mode 100644 index 000000000..417caab06 --- /dev/null +++ b/tests/generator-Tests/expected.ji/Core_ClassParse/__NamespaceMapping__.cs @@ -0,0 +1,2 @@ +using System; + diff --git a/tests/generator-Tests/expected.ji/Core_ClassParse/enumlist b/tests/generator-Tests/expected.ji/Core_ClassParse/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpannable.cs b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpannable.cs index d02344c46..19a6c44f9 100644 --- a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpannable.cs +++ b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpannable.cs @@ -1,98 +1,11 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Android.Text { // Metadata.xml XPath interface reference: path="/api/package[@name='android.text']/interface[@name='Spannable']" - [Register ("android/text/Spannable", "", "Android.Text.ISpannableInvoker")] + [global::Java.Interop.JniTypeSignature ("android/text/Spannable", GenerateJavaPeer=false)] public partial interface ISpannable : global::Android.Text.ISpanned { } - - [global::Android.Runtime.Register ("android/text/Spannable", DoNotGenerateAcw=true)] - internal partial class ISpannableInvoker : global::Java.Lang.Object, ISpannable { - static readonly JniPeerMembers _members = new JniPeerMembers ("android/text/Spannable", typeof (ISpannableInvoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static ISpannable GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'android.text.Spannable'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public ISpannableInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - - static Delegate cb_getSpanFlags_Ljava_lang_Object_; -#pragma warning disable 0169 - static Delegate GetGetSpanFlags_Ljava_lang_Object_Handler () - { - if (cb_getSpanFlags_Ljava_lang_Object_ == null) - cb_getSpanFlags_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetSpanFlags_Ljava_lang_Object_); - return cb_getSpanFlags_Ljava_lang_Object_; - } - - static int n_GetSpanFlags_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_tag) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var tag = global::Java.Lang.Object.GetObject (native_tag, JniHandleOwnership.DoNotTransfer); - int __ret = (int) __this.GetSpanFlags (tag); - return __ret; - } -#pragma warning restore 0169 - - IntPtr id_getSpanFlags_Ljava_lang_Object_; - public unsafe global::Android.Text.SpanTypes GetSpanFlags (global::Java.Lang.Object tag) - { - if (id_getSpanFlags_Ljava_lang_Object_ == IntPtr.Zero) - id_getSpanFlags_Ljava_lang_Object_ = JNIEnv.GetMethodID (class_ref, "getSpanFlags", "(Ljava/lang/Object;)I"); - JValue* __args = stackalloc JValue [1]; - __args [0] = new JValue ((tag == null) ? IntPtr.Zero : ((global::Java.Lang.Object) tag).Handle); - var __ret = (global::Android.Text.SpanTypes) JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_getSpanFlags_Ljava_lang_Object_, __args); - return __ret; - } - - } } diff --git a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpanned.cs b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpanned.cs index d668acb08..590585eb8 100644 --- a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpanned.cs +++ b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpanned.cs @@ -1,103 +1,15 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Android.Text { // Metadata.xml XPath interface reference: path="/api/package[@name='android.text']/interface[@name='Spanned']" - [Register ("android/text/Spanned", "", "Android.Text.ISpannedInvoker")] - public partial interface ISpanned : IJavaObject, IJavaPeerable { + [global::Java.Interop.JniTypeSignature ("android/text/Spanned", GenerateJavaPeer=false)] + public partial interface ISpanned : IJavaPeerable { // Metadata.xml XPath method reference: path="/api/package[@name='android.text']/interface[@name='Spanned']/method[@name='getSpanFlags' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" [return:global::Android.Runtime.GeneratedEnum] - [Register ("getSpanFlags", "(Ljava/lang/Object;)I", "GetGetSpanFlags_Ljava_lang_Object_Handler:Android.Text.ISpannedInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] global::Android.Text.SpanTypes GetSpanFlags (global::Java.Lang.Object tag); } - - [global::Android.Runtime.Register ("android/text/Spanned", DoNotGenerateAcw=true)] - internal partial class ISpannedInvoker : global::Java.Lang.Object, ISpanned { - static readonly JniPeerMembers _members = new JniPeerMembers ("android/text/Spanned", typeof (ISpannedInvoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static ISpanned GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'android.text.Spanned'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public ISpannedInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - - static Delegate cb_getSpanFlags_Ljava_lang_Object_; -#pragma warning disable 0169 - static Delegate GetGetSpanFlags_Ljava_lang_Object_Handler () - { - if (cb_getSpanFlags_Ljava_lang_Object_ == null) - cb_getSpanFlags_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetSpanFlags_Ljava_lang_Object_); - return cb_getSpanFlags_Ljava_lang_Object_; - } - - static int n_GetSpanFlags_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_tag) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var tag = global::Java.Lang.Object.GetObject (native_tag, JniHandleOwnership.DoNotTransfer); - int __ret = (int) __this.GetSpanFlags (tag); - return __ret; - } -#pragma warning restore 0169 - - IntPtr id_getSpanFlags_Ljava_lang_Object_; - public unsafe global::Android.Text.SpanTypes GetSpanFlags (global::Java.Lang.Object tag) - { - if (id_getSpanFlags_Ljava_lang_Object_ == IntPtr.Zero) - id_getSpanFlags_Ljava_lang_Object_ = JNIEnv.GetMethodID (class_ref, "getSpanFlags", "(Ljava/lang/Object;)I"); - JValue* __args = stackalloc JValue [1]; - __args [0] = new JValue ((tag == null) ? IntPtr.Zero : ((global::Java.Lang.Object) tag).Handle); - var __ret = (global::Android.Text.SpanTypes) JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_getSpanFlags_Ljava_lang_Object_, __args); - return __ret; - } - - } } diff --git a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.SpannableString.cs b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.SpannableString.cs index 24196b0ac..d813fff23 100644 --- a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.SpannableString.cs +++ b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.SpannableString.cs @@ -1,48 +1,30 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Android.Text { // Metadata.xml XPath class reference: path="/api/package[@name='android.text']/class[@name='SpannableString']" - [global::Android.Runtime.Register ("android/text/SpannableString", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("android/text/SpannableString", GenerateJavaPeer=false)] public partial class SpannableString : global::Android.Text.SpannableStringInternal, global::Android.Text.ISpannable { static readonly JniPeerMembers _members = new JniPeerMembers ("android/text/SpannableString", typeof (SpannableString)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected SpannableString (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected SpannableString (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath constructor reference: path="/api/package[@name='android.text']/class[@name='SpannableString']/constructor[@name='SpannableString' and count(parameter)=1 and parameter[1][@type='java.lang.CharSequence']]" - [Register (".ctor", "(Ljava/lang/CharSequence;)V", "")] - public unsafe SpannableString (global::Java.Lang.ICharSequence source) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe SpannableString (global::Java.Lang.ICharSequence source) : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "(Ljava/lang/CharSequence;)V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; IntPtr native_source = CharSequence.ToLocalJniHandle (source); @@ -50,7 +32,7 @@ public unsafe SpannableString (global::Java.Lang.ICharSequence source) : base (I JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (native_source); var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, __args); } finally { JNIEnv.DeleteLocalRef (native_source); @@ -58,12 +40,11 @@ public unsafe SpannableString (global::Java.Lang.ICharSequence source) : base (I } } - [Register (".ctor", "(Ljava/lang/CharSequence;)V", "")] - public unsafe SpannableString (string source) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe SpannableString (string source) : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "(Ljava/lang/CharSequence;)V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; IntPtr native_source = CharSequence.ToLocalJniHandle (source); @@ -71,7 +52,7 @@ public unsafe SpannableString (string source) : base (IntPtr.Zero, JniHandleOwne JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (native_source); var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, __args); } finally { JNIEnv.DeleteLocalRef (native_source); @@ -79,32 +60,13 @@ public unsafe SpannableString (string source) : base (IntPtr.Zero, JniHandleOwne } } - static Delegate cb_getSpanFlags_Ljava_lang_Object_; -#pragma warning disable 0169 - static Delegate GetGetSpanFlags_Ljava_lang_Object_Handler () - { - if (cb_getSpanFlags_Ljava_lang_Object_ == null) - cb_getSpanFlags_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetSpanFlags_Ljava_lang_Object_); - return cb_getSpanFlags_Ljava_lang_Object_; - } - - static int n_GetSpanFlags_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_what) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var what = global::Java.Lang.Object.GetObject (native_what, JniHandleOwnership.DoNotTransfer); - int __ret = (int) __this.GetSpanFlags (what); - return __ret; - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='android.text']/class[@name='SpannableString']/method[@name='getSpanFlags' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" - [Register ("getSpanFlags", "(Ljava/lang/Object;)I", "GetGetSpanFlags_Ljava_lang_Object_Handler")] public override unsafe global::Android.Text.SpanTypes GetSpanFlags (global::Java.Lang.Object what) { const string __id = "getSpanFlags.(Ljava/lang/Object;)I"; try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue ((what == null) ? IntPtr.Zero : ((global::Java.Lang.Object) what).Handle); + __args [0] = new JniArgumentValue (what); var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, __args); return (global::Android.Text.SpanTypes) __rm; } finally { diff --git a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.SpannableStringInternal.cs b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.SpannableStringInternal.cs index 3a8cfa38e..625020c9b 100644 --- a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.SpannableStringInternal.cs +++ b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.SpannableStringInternal.cs @@ -1,68 +1,32 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Android.Text { // Metadata.xml XPath class reference: path="/api/package[@name='android.text']/class[@name='SpannableStringInternal']" - [global::Android.Runtime.Register ("android/text/SpannableStringInternal", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("android/text/SpannableStringInternal", GenerateJavaPeer=false)] public abstract partial class SpannableStringInternal : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("android/text/SpannableStringInternal", typeof (SpannableStringInternal)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected SpannableStringInternal (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected SpannableStringInternal (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } - static Delegate cb_getSpanFlags_Ljava_lang_Object_; -#pragma warning disable 0169 - static Delegate GetGetSpanFlags_Ljava_lang_Object_Handler () - { - if (cb_getSpanFlags_Ljava_lang_Object_ == null) - cb_getSpanFlags_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetSpanFlags_Ljava_lang_Object_); - return cb_getSpanFlags_Ljava_lang_Object_; - } - - static int n_GetSpanFlags_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_p0) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var p0 = global::Java.Lang.Object.GetObject (native_p0, JniHandleOwnership.DoNotTransfer); - int __ret = (int) __this.GetSpanFlags (p0); - return __ret; - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='android.text']/class[@name='SpannableStringInternal']/method[@name='getSpanFlags' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" [return:global::Android.Runtime.GeneratedEnum] - [Register ("getSpanFlags", "(Ljava/lang/Object;)I", "GetGetSpanFlags_Ljava_lang_Object_Handler")] public virtual unsafe global::Android.Text.SpanTypes GetSpanFlags (global::Java.Lang.Object p0) { const string __id = "getSpanFlags.(Ljava/lang/Object;)I"; try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue ((p0 == null) ? IntPtr.Zero : ((global::Java.Lang.Object) p0).Handle); + __args [0] = new JniArgumentValue (p0); var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, __args); return (global::Android.Text.SpanTypes) __rm; } finally { @@ -72,9 +36,9 @@ static int n_GetSpanFlags_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this } - [global::Android.Runtime.Register ("android/text/SpannableStringInternal", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("android/text/SpannableStringInternal", GenerateJavaPeer=false)] internal partial class SpannableStringInternalInvoker : SpannableStringInternal { - public SpannableStringInternalInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + public SpannableStringInternalInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } @@ -86,11 +50,5 @@ public SpannableStringInternalInvoker (IntPtr handle, JniHandleOwnership transfe get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - } } diff --git a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Views.View.cs b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Views.View.cs index d1df8da63..6abf1945a 100644 --- a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Views.View.cs +++ b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Views.View.cs @@ -1,111 +1,25 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Android.Views { // Metadata.xml XPath class reference: path="/api/package[@name='android.view']/class[@name='View']" - [global::Android.Runtime.Register ("android/view/View", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("android/view/View", GenerateJavaPeer=false)] public partial class View : global::Java.Lang.Object { // Metadata.xml XPath interface reference: path="/api/package[@name='android.view']/interface[@name='View.OnClickListener']" - [Register ("android/view/View$OnClickListener", "", "Android.Views.View/IOnClickListenerInvoker")] - public partial interface IOnClickListener : IJavaObject, IJavaPeerable { + [global::Java.Interop.JniTypeSignature ("android/view/View$OnClickListener", GenerateJavaPeer=false)] + public partial interface IOnClickListener : IJavaPeerable { // Metadata.xml XPath method reference: path="/api/package[@name='android.view']/interface[@name='View.OnClickListener']/method[@name='onClick' and count(parameter)=1 and parameter[1][@type='android.view.View']]" - [Register ("onClick", "(Landroid/view/View;)V", "GetOnClick_Landroid_view_View_Handler:Android.Views.View/IOnClickListenerInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] void OnClick (global::Android.Views.View v); } - [global::Android.Runtime.Register ("android/view/View$OnClickListener", DoNotGenerateAcw=true)] - internal partial class IOnClickListenerInvoker : global::Java.Lang.Object, IOnClickListener { - static readonly JniPeerMembers _members = new JniPeerMembers ("android/view/View$OnClickListener", typeof (IOnClickListenerInvoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static IOnClickListener GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'android.view.View.OnClickListener'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public IOnClickListenerInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - - static Delegate cb_onClick_Landroid_view_View_; -#pragma warning disable 0169 - static Delegate GetOnClick_Landroid_view_View_Handler () - { - if (cb_onClick_Landroid_view_View_ == null) - cb_onClick_Landroid_view_View_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_OnClick_Landroid_view_View_); - return cb_onClick_Landroid_view_View_; - } - - static void n_OnClick_Landroid_view_View_ (IntPtr jnienv, IntPtr native__this, IntPtr native_v) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var v = global::Java.Lang.Object.GetObject (native_v, JniHandleOwnership.DoNotTransfer); - __this.OnClick (v); - } -#pragma warning restore 0169 - - IntPtr id_onClick_Landroid_view_View_; - public unsafe void OnClick (global::Android.Views.View v) - { - if (id_onClick_Landroid_view_View_ == IntPtr.Zero) - id_onClick_Landroid_view_View_ = JNIEnv.GetMethodID (class_ref, "onClick", "(Landroid/view/View;)V"); - JValue* __args = stackalloc JValue [1]; - __args [0] = new JValue ((v == null) ? IntPtr.Zero : ((global::Java.Lang.Object) v).Handle); - JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_onClick_Landroid_view_View_, __args); - } - - } - [global::Android.Runtime.Register ("mono/android/view/View_OnClickListenerImplementor")] internal sealed partial class IOnClickListenerImplementor : global::Java.Lang.Object, IOnClickListener { public IOnClickListenerImplementor () : base (global::Android.Runtime.JNIEnv.StartCreateInstance ("mono/android/view/View_OnClickListenerImplementor", "()V"), JniHandleOwnership.TransferLocalRef) { - global::Android.Runtime.JNIEnv.FinishCreateInstance (((global::Java.Lang.Object) this).Handle, "()V"); + global::Android.Runtime.JNIEnv.FinishCreateInstance (this.PeerReference, "()V"); } #pragma warning disable 0649 @@ -128,113 +42,43 @@ internal static bool __IsEmpty (IOnClickListenerImplementor value) static readonly JniPeerMembers _members = new JniPeerMembers ("android/view/View", typeof (View)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected View (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - static Delegate cb_setOnClickListener_Landroid_view_View_OnClickListener_; -#pragma warning disable 0169 - static Delegate GetSetOnClickListener_Landroid_view_View_OnClickListener_Handler () + protected View (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - if (cb_setOnClickListener_Landroid_view_View_OnClickListener_ == null) - cb_setOnClickListener_Landroid_view_View_OnClickListener_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetOnClickListener_Landroid_view_View_OnClickListener_); - return cb_setOnClickListener_Landroid_view_View_OnClickListener_; } - static void n_SetOnClickListener_Landroid_view_View_OnClickListener_ (IntPtr jnienv, IntPtr native__this, IntPtr native_l) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var l = (global::Android.Views.View.IOnClickListener)global::Java.Lang.Object.GetObject (native_l, JniHandleOwnership.DoNotTransfer); - __this.SetOnClickListener (l); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='android.view']/class[@name='View']/method[@name='setOnClickListener' and count(parameter)=1 and parameter[1][@type='android.view.View.OnClickListener']]" - [Register ("setOnClickListener", "(Landroid/view/View$OnClickListener;)V", "GetSetOnClickListener_Landroid_view_View_OnClickListener_Handler")] public virtual unsafe void SetOnClickListener (global::Android.Views.View.IOnClickListener l) { const string __id = "setOnClickListener.(Landroid/view/View$OnClickListener;)V"; try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue ((l == null) ? IntPtr.Zero : ((global::Java.Lang.Object) l).Handle); + __args [0] = new JniArgumentValue (l); _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); } finally { global::System.GC.KeepAlive (l); } } - static Delegate cb_setOn123Listener_Landroid_view_View_OnClickListener_; -#pragma warning disable 0169 - static Delegate GetSetOn123Listener_Landroid_view_View_OnClickListener_Handler () - { - if (cb_setOn123Listener_Landroid_view_View_OnClickListener_ == null) - cb_setOn123Listener_Landroid_view_View_OnClickListener_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetOn123Listener_Landroid_view_View_OnClickListener_); - return cb_setOn123Listener_Landroid_view_View_OnClickListener_; - } - - static void n_SetOn123Listener_Landroid_view_View_OnClickListener_ (IntPtr jnienv, IntPtr native__this, IntPtr native_l) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var l = (global::Android.Views.View.IOnClickListener)global::Java.Lang.Object.GetObject (native_l, JniHandleOwnership.DoNotTransfer); - __this.SetOn123Listener (l); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='android.view']/class[@name='View']/method[@name='setOn123Listener' and count(parameter)=1 and parameter[1][@type='android.view.View.OnClickListener']]" - [Register ("setOn123Listener", "(Landroid/view/View$OnClickListener;)V", "GetSetOn123Listener_Landroid_view_View_OnClickListener_Handler")] public virtual unsafe void SetOn123Listener (global::Android.Views.View.IOnClickListener l) { const string __id = "setOn123Listener.(Landroid/view/View$OnClickListener;)V"; try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue ((l == null) ? IntPtr.Zero : ((global::Java.Lang.Object) l).Handle); + __args [0] = new JniArgumentValue (l); _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); } finally { global::System.GC.KeepAlive (l); } } - static Delegate cb_addTouchables_Ljava_util_ArrayList_; -#pragma warning disable 0169 - static Delegate GetAddTouchables_Ljava_util_ArrayList_Handler () - { - if (cb_addTouchables_Ljava_util_ArrayList_ == null) - cb_addTouchables_Ljava_util_ArrayList_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_AddTouchables_Ljava_util_ArrayList_); - return cb_addTouchables_Ljava_util_ArrayList_; - } - - static void n_AddTouchables_Ljava_util_ArrayList_ (IntPtr jnienv, IntPtr native__this, IntPtr native_views) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var views = global::Android.Runtime.JavaList.FromJniHandle (native_views, JniHandleOwnership.DoNotTransfer); - __this.AddTouchables (views); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='android.view']/class[@name='View']/method[@name='addTouchables' and count(parameter)=1 and parameter[1][@type='java.util.ArrayList<android.view.View>']]" - [Register ("addTouchables", "(Ljava/util/ArrayList;)V", "GetAddTouchables_Ljava_util_ArrayList_Handler")] public virtual unsafe void AddTouchables (global::System.Collections.Generic.IList views) { const string __id = "addTouchables.(Ljava/util/ArrayList;)V"; diff --git a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Mono.Android.projitems b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Mono.Android.projitems new file mode 100644 index 000000000..0bd3f3343 --- /dev/null +++ b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Mono.Android.projitems @@ -0,0 +1,20 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.ji/Core_Jar2Xml/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/Core_Jar2Xml/__NamespaceMapping__.cs new file mode 100644 index 000000000..417caab06 --- /dev/null +++ b/tests/generator-Tests/expected.ji/Core_Jar2Xml/__NamespaceMapping__.cs @@ -0,0 +1,2 @@ +using System; + diff --git a/tests/generator-Tests/expected.ji/Core_Jar2Xml/enumlist b/tests/generator-Tests/expected.ji/Core_Jar2Xml/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.FrameworkMediaDrm.cs b/tests/generator-Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.FrameworkMediaDrm.cs index 7c208eb60..dc2f10632 100644 --- a/tests/generator-Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.FrameworkMediaDrm.cs +++ b/tests/generator-Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.FrameworkMediaDrm.cs @@ -1,66 +1,47 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Com.Google.Android.Exoplayer.Drm { // Metadata.xml XPath class reference: path="/api/package[@name='com.google.android.exoplayer.drm']/class[@name='FrameworkMediaDrm']" - [global::Android.Runtime.Register ("com/google/android/exoplayer/drm/FrameworkMediaDrm", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("com/google/android/exoplayer/drm/FrameworkMediaDrm", GenerateJavaPeer=false)] public sealed partial class FrameworkMediaDrm : global::Java.Lang.Object, global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm { static readonly JniPeerMembers _members = new JniPeerMembers ("com/google/android/exoplayer/drm/FrameworkMediaDrm", typeof (FrameworkMediaDrm)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - internal FrameworkMediaDrm (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + internal FrameworkMediaDrm (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath constructor reference: path="/api/package[@name='com.google.android.exoplayer.drm']/class[@name='FrameworkMediaDrm']/constructor[@name='FrameworkMediaDrm' and count(parameter)=0]" - [Register (".ctor", "()V", "")] - public unsafe FrameworkMediaDrm () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe FrameworkMediaDrm () : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "()V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; try { var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { } } // Metadata.xml XPath method reference: path="/api/package[@name='com.google.android.exoplayer.drm']/class[@name='FrameworkMediaDrm']/method[@name='setOnEventListener' and count(parameter)=1 and parameter[1][@type='com.google.android.exoplayer.drm.ExoMediaDrm.OnEventListener<com.google.android.exoplayer.drm.FrameworkMediaCrypto>']]" - [Register ("setOnEventListener", "(Lcom/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener;)V", "")] public unsafe void SetOnEventListener (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrmOnEventListener p0) { const string __id = "setOnEventListener.(Lcom/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener;)V"; try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue ((p0 == null) ? IntPtr.Zero : ((global::Java.Lang.Object) p0).Handle); + __args [0] = new JniArgumentValue (p0); _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args); } finally { global::System.GC.KeepAlive (p0); diff --git a/tests/generator-Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs b/tests/generator-Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs index 4768d16cf..5dd4b571f 100644 --- a/tests/generator-Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs +++ b/tests/generator-Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs @@ -1,127 +1,21 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Com.Google.Android.Exoplayer.Drm { // Metadata.xml XPath interface reference: path="/api/package[@name='com.google.android.exoplayer.drm']/interface[@name='ExoMediaDrm.OnEventListener']" - [Register ("com/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener", "", "Com.Google.Android.Exoplayer.Drm.IExoMediaDrmOnEventListenerInvoker")] + [global::Java.Interop.JniTypeSignature ("com/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener", GenerateJavaPeer=false)] [global::Java.Interop.JavaTypeParameters (new string [] {"T extends com.google.android.exoplayer.drm.ExoMediaCrypto"})] - public partial interface IExoMediaDrmOnEventListener : IJavaObject, IJavaPeerable { + public partial interface IExoMediaDrmOnEventListener : IJavaPeerable { // Metadata.xml XPath method reference: path="/api/package[@name='com.google.android.exoplayer.drm']/interface[@name='ExoMediaDrm.OnEventListener']/method[@name='onEvent' and count(parameter)=5 and parameter[1][@type='com.google.android.exoplayer.drm.ExoMediaDrm<T>'] and parameter[2][@type='byte[]'] and parameter[3][@type='int'] and parameter[4][@type='int'] and parameter[5][@type='byte[]']]" - [Register ("onEvent", "(Lcom/google/android/exoplayer/drm/ExoMediaDrm;[BII[B)V", "GetOnEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayBHandler:Com.Google.Android.Exoplayer.Drm.IExoMediaDrmOnEventListenerInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] - void OnEvent (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm p0, byte[] p1, int p2, int p3, byte[] p4); - - } - - [global::Android.Runtime.Register ("com/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener", DoNotGenerateAcw=true)] - internal partial class IExoMediaDrmOnEventListenerInvoker : global::Java.Lang.Object, IExoMediaDrmOnEventListener { - static readonly JniPeerMembers _members = new JniPeerMembers ("com/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener", typeof (IExoMediaDrmOnEventListenerInvoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static IExoMediaDrmOnEventListener GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.google.android.exoplayer.drm.ExoMediaDrm.OnEventListener'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public IExoMediaDrmOnEventListenerInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - - static Delegate cb_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB; -#pragma warning disable 0169 - static Delegate GetOnEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayBHandler () - { - if (cb_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB == null) - cb_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPLLIIL_V) n_OnEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB); - return cb_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB; - } - - static void n_OnEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB (IntPtr jnienv, IntPtr native__this, IntPtr native_p0, IntPtr native_p1, int p2, int p3, IntPtr native_p4) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var p0 = (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm)global::Java.Lang.Object.GetObject (native_p0, JniHandleOwnership.DoNotTransfer); - var p1 = (byte[]) JNIEnv.GetArray (native_p1, JniHandleOwnership.DoNotTransfer, typeof (byte)); - var p4 = (byte[]) JNIEnv.GetArray (native_p4, JniHandleOwnership.DoNotTransfer, typeof (byte)); - __this.OnEvent (p0, p1, p2, p3, p4); - if (p1 != null) - JNIEnv.CopyArray (p1, native_p1); - if (p4 != null) - JNIEnv.CopyArray (p4, native_p4); - } -#pragma warning restore 0169 - - IntPtr id_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB; - public unsafe void OnEvent (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm p0, byte[] p1, int p2, int p3, byte[] p4) - { - if (id_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB == IntPtr.Zero) - id_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB = JNIEnv.GetMethodID (class_ref, "onEvent", "(Lcom/google/android/exoplayer/drm/ExoMediaDrm;[BII[B)V"); - IntPtr native_p1 = JNIEnv.NewArray (p1); - IntPtr native_p4 = JNIEnv.NewArray (p4); - JValue* __args = stackalloc JValue [5]; - __args [0] = new JValue ((p0 == null) ? IntPtr.Zero : ((global::Java.Lang.Object) p0).Handle); - __args [1] = new JValue (native_p1); - __args [2] = new JValue (p2); - __args [3] = new JValue (p3); - __args [4] = new JValue (native_p4); - JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB, __args); - if (p1 != null) { - JNIEnv.CopyArray (native_p1, p1); - JNIEnv.DeleteLocalRef (native_p1); - } - if (p4 != null) { - JNIEnv.CopyArray (native_p4, p4); - JNIEnv.DeleteLocalRef (native_p4); - } - } + void OnEvent (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm p0, global::Java.Interop.JavaSByteArray p1, int p2, int p3, global::Java.Interop.JavaSByteArray p4); } // event args for com.google.android.exoplayer.drm.ExoMediaDrm.OnEventListener.onEvent public partial class ExoMediaDrmOnEventEventArgs : global::System.EventArgs { - public ExoMediaDrmOnEventEventArgs (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm p0, byte[] p1, int p2, int p3, byte[] p4) + public ExoMediaDrmOnEventEventArgs (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm p0, global::Java.Interop.JavaSByteArray p1, int p2, int p3, global::Java.Interop.JavaSByteArray p4) { this.p0 = p0; this.p1 = p1; @@ -136,9 +30,9 @@ public ExoMediaDrmOnEventEventArgs (global::Com.Google.Android.Exoplayer.Drm.IEx get { return p0; } } - byte[] p1; + global::Java.Interop.JavaSByteArray p1; - public byte[] P1 { + public global::Java.Interop.JavaSByteArray P1 { get { return p1; } } @@ -154,9 +48,9 @@ public int P3 { get { return p3; } } - byte[] p4; + global::Java.Interop.JavaSByteArray p4; - public byte[] P4 { + public global::Java.Interop.JavaSByteArray P4 { get { return p4; } } @@ -169,7 +63,7 @@ internal sealed partial class IExoMediaDrmOnEventListenerImplementor : global::J public IExoMediaDrmOnEventListenerImplementor (object sender) : base (global::Android.Runtime.JNIEnv.StartCreateInstance ("mono/com/google/android/exoplayer/drm/ExoMediaDrm_OnEventListenerImplementor", "()V"), JniHandleOwnership.TransferLocalRef) { - global::Android.Runtime.JNIEnv.FinishCreateInstance (((global::Java.Lang.Object) this).Handle, "()V"); + global::Android.Runtime.JNIEnv.FinishCreateInstance (this.PeerReference, "()V"); this.sender = sender; } @@ -177,7 +71,7 @@ public IExoMediaDrmOnEventListenerImplementor (object sender) : base (global::An public EventHandler Handler; #pragma warning restore 0649 - public void OnEvent (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm p0, byte[] p1, int p2, int p3, byte[] p4) + public void OnEvent (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm p0, global::Java.Interop.JavaSByteArray p1, int p2, int p3, global::Java.Interop.JavaSByteArray p4) { var __h = Handler; if (__h != null) @@ -192,96 +86,11 @@ internal static bool __IsEmpty (IExoMediaDrmOnEventListenerImplementor value) } // Metadata.xml XPath interface reference: path="/api/package[@name='com.google.android.exoplayer.drm']/interface[@name='ExoMediaDrm']" - [Register ("com/google/android/exoplayer/drm/ExoMediaDrm", "", "Com.Google.Android.Exoplayer.Drm.IExoMediaDrmInvoker")] + [global::Java.Interop.JniTypeSignature ("com/google/android/exoplayer/drm/ExoMediaDrm", GenerateJavaPeer=false)] [global::Java.Interop.JavaTypeParameters (new string [] {"T extends com.google.android.exoplayer.drm.ExoMediaCrypto"})] - public partial interface IExoMediaDrm : IJavaObject, IJavaPeerable { + public partial interface IExoMediaDrm : IJavaPeerable { // Metadata.xml XPath method reference: path="/api/package[@name='com.google.android.exoplayer.drm']/interface[@name='ExoMediaDrm']/method[@name='setOnEventListener' and count(parameter)=1 and parameter[1][@type='com.google.android.exoplayer.drm.ExoMediaDrm.OnEventListener<T>']]" - [Register ("setOnEventListener", "(Lcom/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener;)V", "GetSetOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_Handler:Com.Google.Android.Exoplayer.Drm.IExoMediaDrmInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] void SetOnEventListener (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrmOnEventListener p0); } - - [global::Android.Runtime.Register ("com/google/android/exoplayer/drm/ExoMediaDrm", DoNotGenerateAcw=true)] - internal partial class IExoMediaDrmInvoker : global::Java.Lang.Object, IExoMediaDrm { - static readonly JniPeerMembers _members = new JniPeerMembers ("com/google/android/exoplayer/drm/ExoMediaDrm", typeof (IExoMediaDrmInvoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static IExoMediaDrm GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.google.android.exoplayer.drm.ExoMediaDrm'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public IExoMediaDrmInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - - static Delegate cb_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_; -#pragma warning disable 0169 - static Delegate GetSetOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_Handler () - { - if (cb_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_ == null) - cb_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_); - return cb_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_; - } - - static void n_SetOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_ (IntPtr jnienv, IntPtr native__this, IntPtr native_p0) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var p0 = (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrmOnEventListener)global::Java.Lang.Object.GetObject (native_p0, JniHandleOwnership.DoNotTransfer); - __this.SetOnEventListener (p0); - } -#pragma warning restore 0169 - - IntPtr id_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_; - public unsafe void SetOnEventListener (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrmOnEventListener p0) - { - if (id_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_ == IntPtr.Zero) - id_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_ = JNIEnv.GetMethodID (class_ref, "setOnEventListener", "(Lcom/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener;)V"); - JValue* __args = stackalloc JValue [1]; - __args [0] = new JValue ((p0 == null) ? IntPtr.Zero : ((global::Java.Lang.Object) p0).Handle); - JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_, __args); - } - - } } diff --git a/tests/generator-Tests/expected.ji/GenericArguments/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/GenericArguments/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/GenericArguments/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/GenericArguments/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Java.Lang.Object.cs new file mode 100644 index 000000000..86d0bd17b --- /dev/null +++ b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Java.Lang.Object.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] + public partial class Object { + static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); + + } +} diff --git a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Mono.Android.projitems b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Mono.Android.projitems new file mode 100644 index 000000000..a57b6da5d --- /dev/null +++ b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Mono.Android.projitems @@ -0,0 +1,17 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II1.cs b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II1.cs index 75ea1a3c2..84b945702 100644 --- a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II1.cs +++ b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II1.cs @@ -1,97 +1,14 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath interface reference: path="/api/package[@name='xamarin.test']/interface[@name='I1']" - [Register ("xamarin/test/I1", "", "Xamarin.Test.II1Invoker")] - public partial interface II1 : IJavaObject, IJavaPeerable { + [global::Java.Interop.JniTypeSignature ("xamarin/test/I1", GenerateJavaPeer=false)] + public partial interface II1 : IJavaPeerable { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='I1']/method[@name='close' and count(parameter)=0]" - [Register ("close", "()V", "GetCloseHandler:Xamarin.Test.II1Invoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] void Close (); } - - [global::Android.Runtime.Register ("xamarin/test/I1", DoNotGenerateAcw=true)] - internal partial class II1Invoker : global::Java.Lang.Object, II1 { - static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/I1", typeof (II1Invoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static II1 GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.I1'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public II1Invoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - - static Delegate cb_close; -#pragma warning disable 0169 - static Delegate GetCloseHandler () - { - if (cb_close == null) - cb_close = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Close); - return cb_close; - } - - static void n_Close (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Close (); - } -#pragma warning restore 0169 - - IntPtr id_close; - public unsafe void Close () - { - if (id_close == IntPtr.Zero) - id_close = JNIEnv.GetMethodID (class_ref, "close", "()V"); - JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_close); - } - - } } diff --git a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II2.cs b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II2.cs index ac69ad552..fd75eef64 100644 --- a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II2.cs +++ b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II2.cs @@ -1,97 +1,14 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath interface reference: path="/api/package[@name='xamarin.test']/interface[@name='I2']" - [Register ("xamarin/test/I2", "", "Xamarin.Test.II2Invoker")] - public partial interface II2 : IJavaObject, IJavaPeerable { + [global::Java.Interop.JniTypeSignature ("xamarin/test/I2", GenerateJavaPeer=false)] + public partial interface II2 : IJavaPeerable { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='I2']/method[@name='close' and count(parameter)=0]" - [Register ("close", "()V", "GetCloseHandler:Xamarin.Test.II2Invoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] void Close (); } - - [global::Android.Runtime.Register ("xamarin/test/I2", DoNotGenerateAcw=true)] - internal partial class II2Invoker : global::Java.Lang.Object, II2 { - static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/I2", typeof (II2Invoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static II2 GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.I2'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public II2Invoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - - static Delegate cb_close; -#pragma warning disable 0169 - static Delegate GetCloseHandler () - { - if (cb_close == null) - cb_close = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Close); - return cb_close; - } - - static void n_Close (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Close (); - } -#pragma warning restore 0169 - - IntPtr id_close; - public unsafe void Close () - { - if (id_close == IntPtr.Zero) - id_close = JNIEnv.GetMethodID (class_ref, "close", "()V"); - JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_close); - } - - } } diff --git a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.SomeObject.cs index c50850df1..2afa6d339 100644 --- a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.SomeObject.cs +++ b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.SomeObject.cs @@ -1,59 +1,25 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" - [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject", GenerateJavaPeer=false)] public partial class SomeObject : global::Java.Lang.Object, global::Xamarin.Test.II1, global::Xamarin.Test.II2 { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - static Delegate cb_close; -#pragma warning disable 0169 - static Delegate GetCloseHandler () - { - if (cb_close == null) - cb_close = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Close); - return cb_close; - } - - static void n_Close (IntPtr jnienv, IntPtr native__this) + protected SomeObject (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Close (); } -#pragma warning restore 0169 // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='close' and count(parameter)=0]" - [Register ("close", "()V", "GetCloseHandler")] public virtual unsafe void Close () { const string __id = "close.()V"; diff --git a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.SomeObject2.cs b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.SomeObject2.cs index 4d0fa23c5..d10e9ec08 100644 --- a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.SomeObject2.cs +++ b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.SomeObject2.cs @@ -1,59 +1,25 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject2']" - [global::Android.Runtime.Register ("xamarin/test/SomeObject2", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject2", GenerateJavaPeer=false)] public abstract partial class SomeObject2 : global::Java.Lang.Object, global::Xamarin.Test.II1, global::Xamarin.Test.II2 { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/SomeObject2", typeof (SomeObject2)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected SomeObject2 (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - static Delegate cb_irrelevant; -#pragma warning disable 0169 - static Delegate GetIrrelevantHandler () + protected SomeObject2 (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - if (cb_irrelevant == null) - cb_irrelevant = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Irrelevant); - return cb_irrelevant; } - static void n_Irrelevant (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Irrelevant (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject2']/method[@name='irrelevant' and count(parameter)=0]" - [Register ("irrelevant", "()V", "GetIrrelevantHandler")] public virtual unsafe void Irrelevant () { const string __id = "irrelevant.()V"; @@ -63,31 +29,14 @@ public virtual unsafe void Irrelevant () } } - static Delegate cb_close; -#pragma warning disable 0169 - static Delegate GetCloseHandler () - { - if (cb_close == null) - cb_close = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Close); - return cb_close; - } - - static void n_Close (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Close (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='I1']/method[@name='close' and count(parameter)=0]" - [Register ("close", "()V", "GetCloseHandler")] public abstract void Close (); } - [global::Android.Runtime.Register ("xamarin/test/SomeObject2", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject2", GenerateJavaPeer=false)] internal partial class SomeObject2Invoker : SomeObject2 { - public SomeObject2Invoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + public SomeObject2Invoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } @@ -99,14 +48,7 @@ public SomeObject2Invoker (IntPtr handle, JniHandleOwnership transfer) : base (h get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='I1']/method[@name='close' and count(parameter)=0]" - [Register ("close", "()V", "GetCloseHandler")] public override unsafe void Close () { const string __id = "close.()V"; diff --git a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/__NamespaceMapping__.cs index 85c43009a..417caab06 100644 --- a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/__NamespaceMapping__.cs @@ -1,6 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] - -delegate void _JniMarshal_PP_V (IntPtr jnienv, IntPtr klass); diff --git a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/enumlist b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/NestedTypes/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/NestedTypes/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/NestedTypes/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/NestedTypes/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/NestedTypes/Mono.Android.projitems b/tests/generator-Tests/expected.ji/NestedTypes/Mono.Android.projitems index 5e66c0f7f..a5071d7a7 100644 --- a/tests/generator-Tests/expected.ji/NestedTypes/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/NestedTypes/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs b/tests/generator-Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs index 1a9ef663a..e89f846ee 100644 --- a/tests/generator-Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs +++ b/tests/generator-Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs @@ -1,141 +1,40 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='NotificationCompatBase']" - [global::Android.Runtime.Register ("xamarin/test/NotificationCompatBase", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/NotificationCompatBase", GenerateJavaPeer=false)] public partial class NotificationCompatBase : global::Java.Lang.Object { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='NotificationCompatBase.Action']" - [global::Android.Runtime.Register ("xamarin/test/NotificationCompatBase$Action", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/NotificationCompatBase$Action", GenerateJavaPeer=false)] public abstract partial class Action : global::Java.Lang.Object { // Metadata.xml XPath interface reference: path="/api/package[@name='xamarin.test']/interface[@name='NotificationCompatBase.Action.Factory']" - [Register ("xamarin/test/NotificationCompatBase$Action$Factory", "", "Xamarin.Test.NotificationCompatBase/Action/IFactoryInvoker")] - public partial interface IFactory : IJavaObject, IJavaPeerable { + [global::Java.Interop.JniTypeSignature ("xamarin/test/NotificationCompatBase$Action$Factory", GenerateJavaPeer=false)] + public partial interface IFactory : IJavaPeerable { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='NotificationCompatBase.Action.Factory']/method[@name='build' and count(parameter)=1 and parameter[1][@type='int']]" - [Register ("build", "(I)Lxamarin/test/NotificationCompatBase$Action;", "GetBuild_IHandler:Xamarin.Test.NotificationCompatBase/Action/IFactoryInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] global::Xamarin.Test.NotificationCompatBase.Action Build (int p0); } - [global::Android.Runtime.Register ("xamarin/test/NotificationCompatBase$Action$Factory", DoNotGenerateAcw=true)] - internal partial class IFactoryInvoker : global::Java.Lang.Object, IFactory { - static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/NotificationCompatBase$Action$Factory", typeof (IFactoryInvoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static IFactory GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.NotificationCompatBase.Action.Factory'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public IFactoryInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - - static Delegate cb_build_I; -#pragma warning disable 0169 - static Delegate GetBuild_IHandler () - { - if (cb_build_I == null) - cb_build_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_L) n_Build_I); - return cb_build_I; - } - - static IntPtr n_Build_I (IntPtr jnienv, IntPtr native__this, int p0) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.ToLocalJniHandle (__this.Build (p0)); - } -#pragma warning restore 0169 - - IntPtr id_build_I; - public unsafe global::Xamarin.Test.NotificationCompatBase.Action Build (int p0) - { - if (id_build_I == IntPtr.Zero) - id_build_I = JNIEnv.GetMethodID (class_ref, "build", "(I)Lxamarin/test/NotificationCompatBase$Action;"); - JValue* __args = stackalloc JValue [1]; - __args [0] = new JValue (p0); - return global::Java.Lang.Object.GetObject (JNIEnv.CallObjectMethod (((global::Java.Lang.Object) this).Handle, id_build_I, __args), JniHandleOwnership.TransferLocalRef); - } - - } - static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/NotificationCompatBase$Action", typeof (Action)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected Action (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected Action (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } } - [global::Android.Runtime.Register ("xamarin/test/NotificationCompatBase$Action", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/NotificationCompatBase$Action", GenerateJavaPeer=false)] internal partial class ActionInvoker : Action { - public ActionInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + public ActionInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } @@ -147,59 +46,36 @@ public ActionInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - } // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='NotificationCompatBase.InstanceInner']" - [global::Android.Runtime.Register ("xamarin/test/NotificationCompatBase$InstanceInner", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/NotificationCompatBase$InstanceInner", GenerateJavaPeer=false)] public abstract partial class InstanceInner : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/NotificationCompatBase$InstanceInner", typeof (InstanceInner)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected InstanceInner (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected InstanceInner (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='NotificationCompatBase.InstanceInner']/constructor[@name='NotificationCompatBase.InstanceInner' and count(parameter)=1 and parameter[1][@type='xamarin.test.NotificationCompatBase']]" - [Register (".ctor", "(Lxamarin/test/NotificationCompatBase;)V", "")] - public unsafe InstanceInner (global::Xamarin.Test.NotificationCompatBase __self) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe InstanceInner (global::Xamarin.Test.NotificationCompatBase __self) : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { string __id = "(L" + global::Android.Runtime.JNIEnv.GetJniName (GetType ().DeclaringType) + ";)V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue ((__self == null) ? IntPtr.Zero : ((global::Java.Lang.Object) __self).Handle); + __args [0] = new JniArgumentValue (__self); var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, __args); } finally { global::System.GC.KeepAlive (__self); @@ -208,9 +84,9 @@ public unsafe InstanceInner (global::Xamarin.Test.NotificationCompatBase __self) } - [global::Android.Runtime.Register ("xamarin/test/NotificationCompatBase$InstanceInner", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/NotificationCompatBase$InstanceInner", GenerateJavaPeer=false)] internal partial class InstanceInnerInvoker : InstanceInner { - public InstanceInnerInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + public InstanceInnerInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } @@ -222,39 +98,17 @@ public InstanceInnerInvoker (IntPtr handle, JniHandleOwnership transfer) : base get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - } static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/NotificationCompatBase", typeof (NotificationCompatBase)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected NotificationCompatBase (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected NotificationCompatBase (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } diff --git a/tests/generator-Tests/expected.ji/NestedTypes/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/NestedTypes/__NamespaceMapping__.cs index 99e05f492..417caab06 100644 --- a/tests/generator-Tests/expected.ji/NestedTypes/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/NestedTypes/__NamespaceMapping__.cs @@ -1,6 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] - -delegate IntPtr _JniMarshal_PPI_L (IntPtr jnienv, IntPtr klass, int p0); diff --git a/tests/generator-Tests/expected.ji/NonStaticFields/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/NonStaticFields/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/NonStaticFields/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/NonStaticFields/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/NonStaticFields/Mono.Android.projitems b/tests/generator-Tests/expected.ji/NonStaticFields/Mono.Android.projitems index 066be1dd1..c47692f39 100644 --- a/tests/generator-Tests/expected.ji/NonStaticFields/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/NonStaticFields/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/NonStaticFields/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.ji/NonStaticFields/Xamarin.Test.SomeObject.cs index fec391ad7..27d1a3c84 100644 --- a/tests/generator-Tests/expected.ji/NonStaticFields/Xamarin.Test.SomeObject.cs +++ b/tests/generator-Tests/expected.ji/NonStaticFields/Xamarin.Test.SomeObject.cs @@ -1,16 +1,14 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" - [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject", GenerateJavaPeer=false)] public partial class SomeObject : global::Java.Lang.Object { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='Value']" - [Register ("Value")] public int Value { get { const string __id = "Value.I"; @@ -30,29 +28,13 @@ public int Value { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected SomeObject (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } diff --git a/tests/generator-Tests/expected.ji/NonStaticFields/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/NonStaticFields/__NamespaceMapping__.cs index acb570f6c..417caab06 100644 --- a/tests/generator-Tests/expected.ji/NonStaticFields/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/NonStaticFields/__NamespaceMapping__.cs @@ -1,5 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] - diff --git a/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Class.cs b/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Class.cs index 4fba680cf..af92b40a9 100644 --- a/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Class.cs +++ b/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Class.cs @@ -1,39 +1,22 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Class']" - [global::Android.Runtime.Register ("java/lang/Class", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Class", GenerateJavaPeer=false)] [global::Java.Interop.JavaTypeParameters (new string [] {"T"})] public partial class Class : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Class", typeof (Class)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected Class (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected Class (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } diff --git a/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Integer.cs b/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Integer.cs index 166fede0b..6fdb05d03 100644 --- a/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Integer.cs +++ b/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Integer.cs @@ -1,38 +1,21 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Integer']" - [global::Android.Runtime.Register ("java/lang/Integer", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Integer", GenerateJavaPeer=false)] public partial class Integer : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Integer", typeof (Integer)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected Integer (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected Integer (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } diff --git a/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Throwable.cs b/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Throwable.cs index 5ef83f67c..b04ec6d4a 100644 --- a/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Throwable.cs +++ b/tests/generator-Tests/expected.ji/NormalMethods/Java.Lang.Throwable.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Throwable']" - [global::Android.Runtime.Register ("java/lang/Throwable", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Throwable", GenerateJavaPeer=false)] public partial class Throwable { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Throwable", typeof (Throwable)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/NormalMethods/Mono.Android.projitems b/tests/generator-Tests/expected.ji/NormalMethods/Mono.Android.projitems index 98ca90f0d..e1aa69457 100644 --- a/tests/generator-Tests/expected.ji/NormalMethods/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/NormalMethods/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/NormalMethods/Xamarin.Test.A.cs b/tests/generator-Tests/expected.ji/NormalMethods/Xamarin.Test.A.cs index c51d319dd..56dec8d68 100644 --- a/tests/generator-Tests/expected.ji/NormalMethods/Xamarin.Test.A.cs +++ b/tests/generator-Tests/expected.ji/NormalMethods/Xamarin.Test.A.cs @@ -1,63 +1,29 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='A']" - [global::Android.Runtime.Register ("xamarin/test/A", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/A", GenerateJavaPeer=false)] public partial class A : global::Java.Lang.Object { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='A.B']" - [global::Android.Runtime.Register ("xamarin/test/A$B", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/A$B", GenerateJavaPeer=false)] [global::Java.Interop.JavaTypeParameters (new string [] {"T extends xamarin.test.A.B"})] public partial class B : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/A$B", typeof (B)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected B (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - static Delegate cb_setCustomDimension_I; -#pragma warning disable 0169 - static Delegate GetSetCustomDimension_IHandler () - { - if (cb_setCustomDimension_I == null) - cb_setCustomDimension_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_L) n_SetCustomDimension_I); - return cb_setCustomDimension_I; - } - - static IntPtr n_SetCustomDimension_I (IntPtr jnienv, IntPtr native__this, int index) + protected B (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.ToLocalJniHandle (__this.SetCustomDimension (index)); } -#pragma warning restore 0169 // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='A.B']/method[@name='setCustomDimension' and count(parameter)=1 and parameter[1][@type='int']]" - [Register ("setCustomDimension", "(I)Lxamarin/test/A$B;", "GetSetCustomDimension_IHandler")] public virtual unsafe global::Java.Lang.Object SetCustomDimension (int index) { const string __id = "setCustomDimension.(I)Lxamarin/test/A$B;"; @@ -65,7 +31,7 @@ static IntPtr n_SetCustomDimension_I (IntPtr jnienv, IntPtr native__this, int in JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (index); var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, __args); - return (global::Java.Lang.Object) global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } @@ -74,50 +40,17 @@ static IntPtr n_SetCustomDimension_I (IntPtr jnienv, IntPtr native__this, int in static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/A", typeof (A)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected A (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - static Delegate cb_getHandle; -#pragma warning disable 0169 - static Delegate GetGetHandleHandler () - { - if (cb_getHandle == null) - cb_getHandle = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_GetHandle); - return cb_getHandle; - } - - static int n_GetHandle (IntPtr jnienv, IntPtr native__this) + protected A (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return __this.GetHandle (); } -#pragma warning restore 0169 // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='A']/method[@name='getHandle' and count(parameter)=0]" - [Register ("getHandle", "()I", "GetGetHandleHandler")] public virtual unsafe int GetHandle () { const string __id = "getHandle.()I"; diff --git a/tests/generator-Tests/expected.ji/NormalMethods/Xamarin.Test.C.cs b/tests/generator-Tests/expected.ji/NormalMethods/Xamarin.Test.C.cs index dbc0b4e19..7c90fe03f 100644 --- a/tests/generator-Tests/expected.ji/NormalMethods/Xamarin.Test.C.cs +++ b/tests/generator-Tests/expected.ji/NormalMethods/Xamarin.Test.C.cs @@ -1,60 +1,26 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='C']" - [global::Android.Runtime.Register ("xamarin/test/C", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/C", GenerateJavaPeer=false)] [global::Java.Interop.JavaTypeParameters (new string [] {"T extends xamarin.test.C"})] public partial class C : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/C", typeof (C)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected C (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - static Delegate cb_setCustomDimension_I; -#pragma warning disable 0169 - static Delegate GetSetCustomDimension_IHandler () - { - if (cb_setCustomDimension_I == null) - cb_setCustomDimension_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_L) n_SetCustomDimension_I); - return cb_setCustomDimension_I; - } - - static IntPtr n_SetCustomDimension_I (IntPtr jnienv, IntPtr native__this, int index) + protected C (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.ToLocalJniHandle (__this.SetCustomDimension (index)); } -#pragma warning restore 0169 // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='C']/method[@name='setCustomDimension' and count(parameter)=1 and parameter[1][@type='int']]" - [Register ("setCustomDimension", "(I)Lxamarin/test/C;", "GetSetCustomDimension_IHandler")] public virtual unsafe global::Java.Lang.Object SetCustomDimension (int index) { const string __id = "setCustomDimension.(I)Lxamarin/test/C;"; @@ -62,7 +28,7 @@ static IntPtr n_SetCustomDimension_I (IntPtr jnienv, IntPtr native__this, int in JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (index); var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, __args); - return (global::Java.Lang.Object) global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } diff --git a/tests/generator-Tests/expected.ji/NormalMethods/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.ji/NormalMethods/Xamarin.Test.SomeObject.cs index 2d6ee34ac..4ca65bfd1 100644 --- a/tests/generator-Tests/expected.ji/NormalMethods/Xamarin.Test.SomeObject.cs +++ b/tests/generator-Tests/expected.ji/NormalMethods/Xamarin.Test.SomeObject.cs @@ -1,117 +1,62 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" - [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject", GenerateJavaPeer=false)] public partial class SomeObject : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected SomeObject (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/constructor[@name='SomeObject' and count(parameter)=1 and parameter[1][@type='java.lang.Class<? extends xamarin.test.SomeObject>']]" - [Register (".ctor", "(Ljava/lang/Class;)V", "")] - public unsafe SomeObject (global::Java.Lang.Class c) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe SomeObject (global::Java.Lang.Class c) : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "(Ljava/lang/Class;)V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue ((c == null) ? IntPtr.Zero : ((global::Java.Lang.Object) c).Handle); + __args [0] = new JniArgumentValue (c); var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, __args); } finally { global::System.GC.KeepAlive (c); } } - static Delegate cb_getType; -#pragma warning disable 0169 - static Delegate GetGetTypeHandler () - { - if (cb_getType == null) - cb_getType = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetType); - return cb_getType; - } - - static IntPtr n_GetType (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.NewArray (__this.GetType ()); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getType' and count(parameter)=0]" - [Register ("getType", "()[I", "GetGetTypeHandler")] - public new virtual unsafe int[] GetType () + public new virtual unsafe global::Java.Interop.JavaInt32Array GetType () { const string __id = "getType.()[I"; try { var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); - return (int[]) JNIEnv.GetArray (__rm.Handle, JniHandleOwnership.TransferLocalRef, typeof (int)); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue(ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } - static Delegate cb_handle_Ljava_lang_Object_Ljava_lang_Throwable_; -#pragma warning disable 0169 - static Delegate GetHandle_Ljava_lang_Object_Ljava_lang_Throwable_Handler () - { - if (cb_handle_Ljava_lang_Object_Ljava_lang_Throwable_ == null) - cb_handle_Ljava_lang_Object_Ljava_lang_Throwable_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPLL_I) n_Handle_Ljava_lang_Object_Ljava_lang_Throwable_); - return cb_handle_Ljava_lang_Object_Ljava_lang_Throwable_; - } - - static int n_Handle_Ljava_lang_Object_Ljava_lang_Throwable_ (IntPtr jnienv, IntPtr native__this, IntPtr native_o, IntPtr native_t) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var o = global::Java.Lang.Object.GetObject (native_o, JniHandleOwnership.DoNotTransfer); - var t = global::Java.Lang.Object.GetObject (native_t, JniHandleOwnership.DoNotTransfer); - int __ret = __this.Handle (o, t); - return __ret; - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='handle' and count(parameter)=2 and parameter[1][@type='java.lang.Object'] and parameter[2][@type='java.lang.Throwable']]" - [Register ("handle", "(Ljava/lang/Object;Ljava/lang/Throwable;)I", "GetHandle_Ljava_lang_Object_Ljava_lang_Throwable_Handler")] public new virtual unsafe int Handle (global::Java.Lang.Object o, global::Java.Lang.Throwable t) { const string __id = "handle.(Ljava/lang/Object;Ljava/lang/Throwable;)I"; try { JniArgumentValue* __args = stackalloc JniArgumentValue [2]; - __args [0] = new JniArgumentValue ((o == null) ? IntPtr.Zero : ((global::Java.Lang.Object) o).Handle); - __args [1] = new JniArgumentValue ((t == null) ? IntPtr.Zero : ((global::Java.Lang.Throwable) t).Handle); + __args [0] = new JniArgumentValue (o); + __args [1] = new JniArgumentValue (t); var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, __args); return __rm; } finally { @@ -120,24 +65,7 @@ static int n_Handle_Ljava_lang_Object_Ljava_lang_Throwable_ (IntPtr jnienv, IntP } } - static Delegate cb_IntegerMethod; -#pragma warning disable 0169 - static Delegate GetIntegerMethodHandler () - { - if (cb_IntegerMethod == null) - cb_IntegerMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_IntegerMethod); - return cb_IntegerMethod; - } - - static int n_IntegerMethod (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return __this.IntegerMethod (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='IntegerMethod' and count(parameter)=0]" - [Register ("IntegerMethod", "()I", "GetIntegerMethodHandler")] public virtual unsafe int IntegerMethod () { const string __id = "IntegerMethod.()I"; @@ -148,24 +76,7 @@ public virtual unsafe int IntegerMethod () } } - static Delegate cb_VoidMethod; -#pragma warning disable 0169 - static Delegate GetVoidMethodHandler () - { - if (cb_VoidMethod == null) - cb_VoidMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_VoidMethod); - return cb_VoidMethod; - } - - static void n_VoidMethod (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.VoidMethod (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='VoidMethod' and count(parameter)=0]" - [Register ("VoidMethod", "()V", "GetVoidMethodHandler")] public virtual unsafe void VoidMethod () { const string __id = "VoidMethod.()V"; @@ -175,119 +86,47 @@ public virtual unsafe void VoidMethod () } } - static Delegate cb_StringMethod; -#pragma warning disable 0169 - static Delegate GetStringMethodHandler () - { - if (cb_StringMethod == null) - cb_StringMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_StringMethod); - return cb_StringMethod; - } - - static IntPtr n_StringMethod (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.NewString (__this.StringMethod ()); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='StringMethod' and count(parameter)=0]" - [Register ("StringMethod", "()Ljava/lang/String;", "GetStringMethodHandler")] public virtual unsafe string StringMethod () { const string __id = "StringMethod.()Ljava/lang/String;"; try { var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); - return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } - static Delegate cb_ObjectMethod; -#pragma warning disable 0169 - static Delegate GetObjectMethodHandler () - { - if (cb_ObjectMethod == null) - cb_ObjectMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_ObjectMethod); - return cb_ObjectMethod; - } - - static IntPtr n_ObjectMethod (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.ToLocalJniHandle (__this.ObjectMethod ()); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='ObjectMethod' and count(parameter)=0]" - [Register ("ObjectMethod", "()Ljava/lang/Object;", "GetObjectMethodHandler")] public virtual unsafe global::Java.Lang.Object ObjectMethod () { const string __id = "ObjectMethod.()Ljava/lang/Object;"; try { var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); - return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } - static Delegate cb_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_; -#pragma warning disable 0169 - static Delegate GetVoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_Handler () - { - if (cb_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_ == null) - cb_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPLIL_V) n_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_); - return cb_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_; - } - - static void n_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_astring, int anint, IntPtr native_anObject) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var astring = JNIEnv.GetString (native_astring, JniHandleOwnership.DoNotTransfer); - var anObject = global::Java.Lang.Object.GetObject (native_anObject, JniHandleOwnership.DoNotTransfer); - __this.VoidMethodWithParams (astring, anint, anObject); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='VoidMethodWithParams' and count(parameter)=3 and parameter[1][@type='java.lang.String'] and parameter[2][@type='int'] and parameter[3][@type='java.lang.Object']]" - [Register ("VoidMethodWithParams", "(Ljava/lang/String;ILjava/lang/Object;)V", "GetVoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_Handler")] public virtual unsafe void VoidMethodWithParams (string astring, int anint, global::Java.Lang.Object anObject) { const string __id = "VoidMethodWithParams.(Ljava/lang/String;ILjava/lang/Object;)V"; - IntPtr native_astring = JNIEnv.NewString (astring); + var native_astring = global::Java.Interop.JniEnvironment.Strings.NewString (astring); try { JniArgumentValue* __args = stackalloc JniArgumentValue [3]; __args [0] = new JniArgumentValue (native_astring); __args [1] = new JniArgumentValue (anint); - __args [2] = new JniArgumentValue ((anObject == null) ? IntPtr.Zero : ((global::Java.Lang.Object) anObject).Handle); + __args [2] = new JniArgumentValue (anObject); _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); } finally { - JNIEnv.DeleteLocalRef (native_astring); + global::Java.Interop.JniObjectReference.Dispose (ref native_astring); global::System.GC.KeepAlive (anObject); } } - static Delegate cb_ObsoleteMethod; -#pragma warning disable 0169 - [Obsolete] - static Delegate GetObsoleteMethodHandler () - { - if (cb_ObsoleteMethod == null) - cb_ObsoleteMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_ObsoleteMethod); - return cb_ObsoleteMethod; - } - - [Obsolete] - static int n_ObsoleteMethod (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return __this.ObsoleteMethod (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='ObsoleteMethod' and count(parameter)=0]" [Obsolete (@"Deprecated please use IntegerMethod instead")] - [Register ("ObsoleteMethod", "()I", "GetObsoleteMethodHandler")] public virtual unsafe int ObsoleteMethod () { const string __id = "ObsoleteMethod.()I"; @@ -298,25 +137,7 @@ public virtual unsafe int ObsoleteMethod () } } - static Delegate cb_ArrayListTest_Ljava_util_ArrayList_; -#pragma warning disable 0169 - static Delegate GetArrayListTest_Ljava_util_ArrayList_Handler () - { - if (cb_ArrayListTest_Ljava_util_ArrayList_ == null) - cb_ArrayListTest_Ljava_util_ArrayList_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_ArrayListTest_Ljava_util_ArrayList_); - return cb_ArrayListTest_Ljava_util_ArrayList_; - } - - static void n_ArrayListTest_Ljava_util_ArrayList_ (IntPtr jnienv, IntPtr native__this, IntPtr native_p0) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var p0 = global::Android.Runtime.JavaList.FromJniHandle (native_p0, JniHandleOwnership.DoNotTransfer); - __this.ArrayListTest (p0); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='ArrayListTest' and count(parameter)=1 and parameter[1][@type='java.util.ArrayList<java.lang.Integer>']]" - [Register ("ArrayListTest", "(Ljava/util/ArrayList;)V", "GetArrayListTest_Ljava_util_ArrayList_Handler")] public virtual unsafe void ArrayListTest (global::System.Collections.Generic.IList p0) { const string __id = "ArrayListTest.(Ljava/util/ArrayList;)V"; diff --git a/tests/generator-Tests/expected.ji/NormalMethods/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/NormalMethods/__NamespaceMapping__.cs index dea3cf429..417caab06 100644 --- a/tests/generator-Tests/expected.ji/NormalMethods/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/NormalMethods/__NamespaceMapping__.cs @@ -1,12 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] - -delegate int _JniMarshal_PP_I (IntPtr jnienv, IntPtr klass); -delegate IntPtr _JniMarshal_PP_L (IntPtr jnienv, IntPtr klass); -delegate void _JniMarshal_PP_V (IntPtr jnienv, IntPtr klass); -delegate IntPtr _JniMarshal_PPI_L (IntPtr jnienv, IntPtr klass, int p0); -delegate void _JniMarshal_PPL_V (IntPtr jnienv, IntPtr klass, IntPtr p0); -delegate void _JniMarshal_PPLIL_V (IntPtr jnienv, IntPtr klass, IntPtr p0, int p1, IntPtr p2); -delegate int _JniMarshal_PPLL_I (IntPtr jnienv, IntPtr klass, IntPtr p0, IntPtr p1); diff --git a/tests/generator-Tests/expected.ji/NormalProperties/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/NormalProperties/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/NormalProperties/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/NormalProperties/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/NormalProperties/Mono.Android.projitems b/tests/generator-Tests/expected.ji/NormalProperties/Mono.Android.projitems index 066be1dd1..c47692f39 100644 --- a/tests/generator-Tests/expected.ji/NormalProperties/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/NormalProperties/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/NormalProperties/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.ji/NormalProperties/Xamarin.Test.SomeObject.cs index dd336a8a0..a02d7152a 100644 --- a/tests/generator-Tests/expected.ji/NormalProperties/Xamarin.Test.SomeObject.cs +++ b/tests/generator-Tests/expected.ji/NormalProperties/Xamarin.Test.SomeObject.cs @@ -1,174 +1,53 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" - [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject", GenerateJavaPeer=false)] public abstract partial class SomeObject : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - static Delegate cb_getSomeInteger; -#pragma warning disable 0169 - static Delegate GetGetSomeIntegerHandler () + protected SomeObject (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - if (cb_getSomeInteger == null) - cb_getSomeInteger = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_GetSomeInteger); - return cb_getSomeInteger; } - static int n_GetSomeInteger (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return __this.SomeInteger; - } -#pragma warning restore 0169 - - static Delegate cb_setSomeInteger_I; -#pragma warning disable 0169 - static Delegate GetSetSomeInteger_IHandler () - { - if (cb_setSomeInteger_I == null) - cb_setSomeInteger_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_SetSomeInteger_I); - return cb_setSomeInteger_I; - } - - static void n_SetSomeInteger_I (IntPtr jnienv, IntPtr native__this, int newvalue) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.SomeInteger = newvalue; - } -#pragma warning restore 0169 - public abstract int SomeInteger { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeInteger' and count(parameter)=0]" - [Register ("getSomeInteger", "()I", "GetGetSomeIntegerHandler")] get; // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeInteger' and count(parameter)=1 and parameter[1][@type='int']]" - [Register ("setSomeInteger", "(I)V", "GetSetSomeInteger_IHandler")] set; } - static Delegate cb_getSomeObjectProperty; -#pragma warning disable 0169 - static Delegate GetGetSomeObjectPropertyHandler () - { - if (cb_getSomeObjectProperty == null) - cb_getSomeObjectProperty = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetSomeObjectProperty); - return cb_getSomeObjectProperty; - } - - static IntPtr n_GetSomeObjectProperty (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.ToLocalJniHandle (__this.SomeObjectProperty); - } -#pragma warning restore 0169 - - static Delegate cb_setSomeObjectProperty_Ljava_lang_Object_; -#pragma warning disable 0169 - static Delegate GetSetSomeObjectProperty_Ljava_lang_Object_Handler () - { - if (cb_setSomeObjectProperty_Ljava_lang_Object_ == null) - cb_setSomeObjectProperty_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetSomeObjectProperty_Ljava_lang_Object_); - return cb_setSomeObjectProperty_Ljava_lang_Object_; - } - - static void n_SetSomeObjectProperty_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_newvalue) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var newvalue = global::Java.Lang.Object.GetObject (native_newvalue, JniHandleOwnership.DoNotTransfer); - __this.SomeObjectProperty = newvalue; - } -#pragma warning restore 0169 - public abstract global::Java.Lang.Object SomeObjectProperty { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeObjectProperty' and count(parameter)=0]" - [Register ("getSomeObjectProperty", "()Ljava/lang/Object;", "GetGetSomeObjectPropertyHandler")] get; // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeObjectProperty' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" - [Register ("setSomeObjectProperty", "(Ljava/lang/Object;)V", "GetSetSomeObjectProperty_Ljava_lang_Object_Handler")] set; } - static Delegate cb_getSomeString; -#pragma warning disable 0169 - static Delegate GetGetSomeStringHandler () - { - if (cb_getSomeString == null) - cb_getSomeString = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetSomeString); - return cb_getSomeString; - } - - static IntPtr n_GetSomeString (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.NewString (__this.SomeString); - } -#pragma warning restore 0169 - - static Delegate cb_setSomeString_Ljava_lang_String_; -#pragma warning disable 0169 - static Delegate GetSetSomeString_Ljava_lang_String_Handler () - { - if (cb_setSomeString_Ljava_lang_String_ == null) - cb_setSomeString_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetSomeString_Ljava_lang_String_); - return cb_setSomeString_Ljava_lang_String_; - } - - static void n_SetSomeString_Ljava_lang_String_ (IntPtr jnienv, IntPtr native__this, IntPtr native_newvalue) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var newvalue = JNIEnv.GetString (native_newvalue, JniHandleOwnership.DoNotTransfer); - __this.SomeString = newvalue; - } -#pragma warning restore 0169 - public abstract string SomeString { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeString' and count(parameter)=0]" - [Register ("getSomeString", "()Ljava/lang/String;", "GetGetSomeStringHandler")] get; // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeString' and count(parameter)=1 and parameter[1][@type='java.lang.String']]" - [Register ("setSomeString", "(Ljava/lang/String;)V", "GetSetSomeString_Ljava_lang_String_Handler")] set; } } - [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject", GenerateJavaPeer=false)] internal partial class SomeObjectInvoker : SomeObject { - public SomeObjectInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + public SomeObjectInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } @@ -180,15 +59,8 @@ public SomeObjectInvoker (IntPtr handle, JniHandleOwnership transfer) : base (ha get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - public override unsafe int SomeInteger { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeInteger' and count(parameter)=0]" - [Register ("getSomeInteger", "()I", "GetGetSomeIntegerHandler")] get { const string __id = "getSomeInteger.()I"; try { @@ -198,7 +70,6 @@ public override unsafe int SomeInteger { } } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeInteger' and count(parameter)=1 and parameter[1][@type='int']]" - [Register ("setSomeInteger", "(I)V", "GetSetSomeInteger_IHandler")] set { const string __id = "setSomeInteger.(I)V"; try { @@ -212,22 +83,20 @@ public override unsafe int SomeInteger { public override unsafe global::Java.Lang.Object SomeObjectProperty { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeObjectProperty' and count(parameter)=0]" - [Register ("getSomeObjectProperty", "()Ljava/lang/Object;", "GetGetSomeObjectPropertyHandler")] get { const string __id = "getSomeObjectProperty.()Ljava/lang/Object;"; try { var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null); - return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeObjectProperty' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" - [Register ("setSomeObjectProperty", "(Ljava/lang/Object;)V", "GetSetSomeObjectProperty_Ljava_lang_Object_Handler")] set { const string __id = "setSomeObjectProperty.(Ljava/lang/Object;)V"; try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue ((value == null) ? IntPtr.Zero : ((global::Java.Lang.Object) value).Handle); + __args [0] = new JniArgumentValue (value); _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args); } finally { global::System.GC.KeepAlive (value); @@ -237,26 +106,24 @@ public override unsafe int SomeInteger { public override unsafe string SomeString { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeString' and count(parameter)=0]" - [Register ("getSomeString", "()Ljava/lang/String;", "GetGetSomeStringHandler")] get { const string __id = "getSomeString.()Ljava/lang/String;"; try { var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null); - return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeString' and count(parameter)=1 and parameter[1][@type='java.lang.String']]" - [Register ("setSomeString", "(Ljava/lang/String;)V", "GetSetSomeString_Ljava_lang_String_Handler")] set { const string __id = "setSomeString.(Ljava/lang/String;)V"; - IntPtr native_value = JNIEnv.NewString (value); + var native_value = global::Java.Interop.JniEnvironment.Strings.NewString (value); try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (native_value); _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args); } finally { - JNIEnv.DeleteLocalRef (native_value); + global::Java.Interop.JniObjectReference.Dispose (ref native_value); } } } diff --git a/tests/generator-Tests/expected.ji/NormalProperties/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/NormalProperties/__NamespaceMapping__.cs index 223b17256..417caab06 100644 --- a/tests/generator-Tests/expected.ji/NormalProperties/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/NormalProperties/__NamespaceMapping__.cs @@ -1,9 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] - -delegate int _JniMarshal_PP_I (IntPtr jnienv, IntPtr klass); -delegate IntPtr _JniMarshal_PP_L (IntPtr jnienv, IntPtr klass); -delegate void _JniMarshal_PPI_V (IntPtr jnienv, IntPtr klass, int p0); -delegate void _JniMarshal_PPL_V (IntPtr jnienv, IntPtr klass, IntPtr p0); diff --git a/tests/generator-Tests/expected.ji/ParameterXPath/Java.Lang.Integer.cs b/tests/generator-Tests/expected.ji/ParameterXPath/Java.Lang.Integer.cs index 166fede0b..6fdb05d03 100644 --- a/tests/generator-Tests/expected.ji/ParameterXPath/Java.Lang.Integer.cs +++ b/tests/generator-Tests/expected.ji/ParameterXPath/Java.Lang.Integer.cs @@ -1,38 +1,21 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Integer']" - [global::Android.Runtime.Register ("java/lang/Integer", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Integer", GenerateJavaPeer=false)] public partial class Integer : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Integer", typeof (Integer)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected Integer (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected Integer (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } diff --git a/tests/generator-Tests/expected.ji/ParameterXPath/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/ParameterXPath/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/ParameterXPath/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/ParameterXPath/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/ParameterXPath/Mono.Android.projitems b/tests/generator-Tests/expected.ji/ParameterXPath/Mono.Android.projitems index e6f21d31f..5a4bd20a6 100644 --- a/tests/generator-Tests/expected.ji/ParameterXPath/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/ParameterXPath/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/ParameterXPath/Xamarin.Test.A.cs b/tests/generator-Tests/expected.ji/ParameterXPath/Xamarin.Test.A.cs index ab206c2b6..646da9d17 100644 --- a/tests/generator-Tests/expected.ji/ParameterXPath/Xamarin.Test.A.cs +++ b/tests/generator-Tests/expected.ji/ParameterXPath/Xamarin.Test.A.cs @@ -1,61 +1,26 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='A']" - [global::Android.Runtime.Register ("xamarin/test/A", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/A", GenerateJavaPeer=false)] [global::Java.Interop.JavaTypeParameters (new string [] {"T extends java.lang.Object"})] public partial class A : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/A", typeof (A)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected A (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - static Delegate cb_setA_Ljava_lang_Object_; -#pragma warning disable 0169 - static Delegate GetSetA_Ljava_lang_Object_Handler () - { - if (cb_setA_Ljava_lang_Object_ == null) - cb_setA_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetA_Ljava_lang_Object_); - return cb_setA_Ljava_lang_Object_; - } - - static void n_SetA_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_adapter) + protected A (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var adapter = global::Java.Lang.Object.GetObject (native_adapter, JniHandleOwnership.DoNotTransfer); - __this.SetA (adapter); } -#pragma warning restore 0169 // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='A']/method[@name='setA' and count(parameter)=1 and parameter[1][@type='T']]" - [Register ("setA", "(Ljava/lang/Object;)V", "GetSetA_Ljava_lang_Object_Handler")] public virtual unsafe void SetA (global::Java.Lang.Object adapter) { const string __id = "setA.(Ljava/lang/Object;)V"; @@ -70,25 +35,7 @@ public virtual unsafe void SetA (global::Java.Lang.Object adapter) } } - static Delegate cb_listTest_Ljava_util_List_; -#pragma warning disable 0169 - static Delegate GetListTest_Ljava_util_List_Handler () - { - if (cb_listTest_Ljava_util_List_ == null) - cb_listTest_Ljava_util_List_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_ListTest_Ljava_util_List_); - return cb_listTest_Ljava_util_List_; - } - - static void n_ListTest_Ljava_util_List_ (IntPtr jnienv, IntPtr native__this, IntPtr native_p0) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var p0 = global::Android.Runtime.JavaList.FromJniHandle (native_p0, JniHandleOwnership.DoNotTransfer); - __this.ListTest (p0); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='A']/method[@name='listTest' and count(parameter)=1 and parameter[1][@type='java.util.List<java.lang.Integer>']]" - [Register ("listTest", "(Ljava/util/List;)V", "GetListTest_Ljava_util_List_Handler")] public virtual unsafe void ListTest (global::System.Collections.Generic.IList p0) { const string __id = "listTest.(Ljava/util/List;)V"; diff --git a/tests/generator-Tests/expected.ji/ParameterXPath/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/ParameterXPath/__NamespaceMapping__.cs index 5825b394f..417caab06 100644 --- a/tests/generator-Tests/expected.ji/ParameterXPath/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/ParameterXPath/__NamespaceMapping__.cs @@ -1,6 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] - -delegate void _JniMarshal_PPL_V (IntPtr jnienv, IntPtr klass, IntPtr p0); diff --git a/tests/generator-Tests/expected.ji/StaticFields/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/StaticFields/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/StaticFields/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/StaticFields/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/StaticFields/Mono.Android.projitems b/tests/generator-Tests/expected.ji/StaticFields/Mono.Android.projitems index 066be1dd1..c47692f39 100644 --- a/tests/generator-Tests/expected.ji/StaticFields/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/StaticFields/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/StaticFields/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.ji/StaticFields/Xamarin.Test.SomeObject.cs index 0c1b694d1..cb4bfd195 100644 --- a/tests/generator-Tests/expected.ji/StaticFields/Xamarin.Test.SomeObject.cs +++ b/tests/generator-Tests/expected.ji/StaticFields/Xamarin.Test.SomeObject.cs @@ -1,16 +1,14 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" - [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject", GenerateJavaPeer=false)] public partial class SomeObject : global::Java.Lang.Object { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='Value']" - [Register ("Value")] public static int Value { get { const string __id = "Value.I"; @@ -22,7 +20,6 @@ public static int Value { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='Value2']" - [Register ("Value2")] public static int Value2 { get { const string __id = "Value2.I"; @@ -42,29 +39,13 @@ public static int Value2 { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected SomeObject (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } diff --git a/tests/generator-Tests/expected.ji/StaticFields/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/StaticFields/__NamespaceMapping__.cs index acb570f6c..417caab06 100644 --- a/tests/generator-Tests/expected.ji/StaticFields/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/StaticFields/__NamespaceMapping__.cs @@ -1,5 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] - diff --git a/tests/generator-Tests/expected.ji/StaticMethods/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/StaticMethods/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/StaticMethods/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/StaticMethods/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/StaticMethods/Mono.Android.projitems b/tests/generator-Tests/expected.ji/StaticMethods/Mono.Android.projitems index 066be1dd1..c47692f39 100644 --- a/tests/generator-Tests/expected.ji/StaticMethods/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/StaticMethods/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/StaticMethods/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.ji/StaticMethods/Xamarin.Test.SomeObject.cs index 3b156914f..fd171f579 100644 --- a/tests/generator-Tests/expected.ji/StaticMethods/Xamarin.Test.SomeObject.cs +++ b/tests/generator-Tests/expected.ji/StaticMethods/Xamarin.Test.SomeObject.cs @@ -1,43 +1,25 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" - [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject", GenerateJavaPeer=false)] public partial class SomeObject : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected SomeObject (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='methodAsInt' and count(parameter)=0]" - [Register ("methodAsInt", "()I", "")] public static unsafe int MethodAsInt () { const string __id = "methodAsInt.()I"; @@ -49,26 +31,24 @@ public static unsafe int MethodAsInt () } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='methodAsString' and count(parameter)=0]" - [Register ("methodAsString", "()Ljava/lang/String;", "")] public static unsafe string MethodAsString () { const string __id = "methodAsString.()Ljava/lang/String;"; try { var __rm = _members.StaticMethods.InvokeObjectMethod (__id, null); - return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='Obsoletemethod' and count(parameter)=0]" [Obsolete (@"Deprecated please use methodAsString")] - [Register ("Obsoletemethod", "()Ljava/lang/String;", "")] public static unsafe string Obsoletemethod () { const string __id = "Obsoletemethod.()Ljava/lang/String;"; try { var __rm = _members.StaticMethods.InvokeObjectMethod (__id, null); - return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } diff --git a/tests/generator-Tests/expected.ji/StaticMethods/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/StaticMethods/__NamespaceMapping__.cs index acb570f6c..417caab06 100644 --- a/tests/generator-Tests/expected.ji/StaticMethods/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/StaticMethods/__NamespaceMapping__.cs @@ -1,5 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] - diff --git a/tests/generator-Tests/expected.ji/StaticProperties/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/StaticProperties/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/StaticProperties/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/StaticProperties/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/StaticProperties/Mono.Android.projitems b/tests/generator-Tests/expected.ji/StaticProperties/Mono.Android.projitems index 066be1dd1..c47692f39 100644 --- a/tests/generator-Tests/expected.ji/StaticProperties/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/StaticProperties/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/StaticProperties/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.ji/StaticProperties/Xamarin.Test.SomeObject.cs index 663b26d8a..aca478733 100644 --- a/tests/generator-Tests/expected.ji/StaticProperties/Xamarin.Test.SomeObject.cs +++ b/tests/generator-Tests/expected.ji/StaticProperties/Xamarin.Test.SomeObject.cs @@ -1,44 +1,26 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" - [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject", GenerateJavaPeer=false)] public partial class SomeObject : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected SomeObject (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } public static unsafe int SomeInteger { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeInteger' and count(parameter)=0]" - [Register ("getSomeInteger", "()I", "")] get { const string __id = "getSomeInteger.()I"; try { @@ -48,7 +30,6 @@ public static unsafe int SomeInteger { } } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeInteger' and count(parameter)=1 and parameter[1][@type='int']]" - [Register ("setSomeInteger", "(I)V", "")] set { const string __id = "setSomeInteger.(I)V"; try { @@ -62,50 +43,46 @@ public static unsafe int SomeInteger { public static unsafe string SomeString { // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeString' and count(parameter)=0]" - [Register ("getSomeString", "()Ljava/lang/String;", "")] get { const string __id = "getSomeString.()Ljava/lang/String;"; try { var __rm = _members.StaticMethods.InvokeObjectMethod (__id, null); - return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeString' and count(parameter)=1 and parameter[1][@type='java.lang.String']]" - [Register ("setSomeString", "(Ljava/lang/String;)V", "")] set { const string __id = "setSomeString.(Ljava/lang/String;)V"; - IntPtr native_value = JNIEnv.NewString (value); + var native_value = global::Java.Interop.JniEnvironment.Strings.NewString (value); try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (native_value); _members.StaticMethods.InvokeVoidMethod (__id, __args); } finally { - JNIEnv.DeleteLocalRef (native_value); + global::Java.Interop.JniObjectReference.Dispose (ref native_value); } } } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeObject' and count(parameter)=0]" - [Register ("getSomeObject", "()Ljava/lang/Object;", "")] public static unsafe global::Java.Lang.Object GetSomeObject () { const string __id = "getSomeObject.()Ljava/lang/Object;"; try { var __rm = _members.StaticMethods.InvokeObjectMethod (__id, null); - return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeObject' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" - [Register ("setSomeObject", "(Ljava/lang/Object;)V", "")] public static unsafe void SetSomeObject (global::Java.Lang.Object newvalue) { const string __id = "setSomeObject.(Ljava/lang/Object;)V"; try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue ((newvalue == null) ? IntPtr.Zero : ((global::Java.Lang.Object) newvalue).Handle); + __args [0] = new JniArgumentValue (newvalue); _members.StaticMethods.InvokeVoidMethod (__id, __args); } finally { global::System.GC.KeepAlive (newvalue); diff --git a/tests/generator-Tests/expected.ji/StaticProperties/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/StaticProperties/__NamespaceMapping__.cs index acb570f6c..417caab06 100644 --- a/tests/generator-Tests/expected.ji/StaticProperties/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/StaticProperties/__NamespaceMapping__.cs @@ -1,5 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] - diff --git a/tests/generator-Tests/expected.ji/Streams/Java.IO.FilterOutputStream.cs b/tests/generator-Tests/expected.ji/Streams/Java.IO.FilterOutputStream.cs index 342d5e3f6..38056067c 100644 --- a/tests/generator-Tests/expected.ji/Streams/Java.IO.FilterOutputStream.cs +++ b/tests/generator-Tests/expected.ji/Streams/Java.IO.FilterOutputStream.cs @@ -1,81 +1,25 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.IO { // Metadata.xml XPath class reference: path="/api/package[@name='java.io']/class[@name='FilterOutputStream']" - [global::Android.Runtime.Register ("java/io/FilterOutputStream", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/io/FilterOutputStream", GenerateJavaPeer=false)] public partial class FilterOutputStream : global::Java.IO.OutputStream { static readonly JniPeerMembers _members = new JniPeerMembers ("java/io/FilterOutputStream", typeof (FilterOutputStream)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected FilterOutputStream (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) - { - } - - // Metadata.xml XPath constructor reference: path="/api/package[@name='java.io']/class[@name='FilterOutputStream']/constructor[@name='FilterOutputStream' and count(parameter)=1 and parameter[1][@type='java.io.OutputStream']]" - [Register (".ctor", "(Ljava/io/OutputStream;)V", "")] - public unsafe FilterOutputStream (global::System.IO.Stream @out) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) - { - const string __id = "(Ljava/io/OutputStream;)V"; - - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) - return; - - IntPtr native__out = global::Android.Runtime.OutputStreamAdapter.ToLocalJniHandle (@out); - try { - JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue (native__out); - var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); - _members.InstanceMethods.FinishCreateInstance (__id, this, __args); - } finally { - JNIEnv.DeleteLocalRef (native__out); - global::System.GC.KeepAlive (@out); - } - } - - static Delegate cb_write_I; -#pragma warning disable 0169 - static Delegate GetWrite_IHandler () - { - if (cb_write_I == null) - cb_write_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_Write_I); - return cb_write_I; - } - - static void n_Write_I (IntPtr jnienv, IntPtr native__this, int oneByte) + protected FilterOutputStream (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Write (oneByte); } -#pragma warning restore 0169 // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='FilterOutputStream']/method[@name='write' and count(parameter)=1 and parameter[1][@type='int']]" - [Register ("write", "(I)V", "GetWrite_IHandler")] public override unsafe void Write (int oneByte) { const string __id = "write.(I)V"; diff --git a/tests/generator-Tests/expected.ji/Streams/Java.IO.IOException.cs b/tests/generator-Tests/expected.ji/Streams/Java.IO.IOException.cs index a737e468d..a1ca90283 100644 --- a/tests/generator-Tests/expected.ji/Streams/Java.IO.IOException.cs +++ b/tests/generator-Tests/expected.ji/Streams/Java.IO.IOException.cs @@ -1,59 +1,25 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.IO { // Metadata.xml XPath class reference: path="/api/package[@name='java.io']/class[@name='IOException']" - [global::Android.Runtime.Register ("java/io/IOException", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/io/IOException", GenerateJavaPeer=false)] public abstract partial class IOException : global::Java.Lang.Throwable { static readonly JniPeerMembers _members = new JniPeerMembers ("java/io/IOException", typeof (IOException)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected IOException (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected IOException (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } - static Delegate cb_printStackTrace; -#pragma warning disable 0169 - static Delegate GetPrintStackTraceHandler () - { - if (cb_printStackTrace == null) - cb_printStackTrace = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_PrintStackTrace); - return cb_printStackTrace; - } - - static void n_PrintStackTrace (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.PrintStackTrace (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='IOException']/method[@name='printStackTrace' and count(parameter)=0]" - [Register ("printStackTrace", "()V", "GetPrintStackTraceHandler")] public virtual unsafe void PrintStackTrace () { const string __id = "printStackTrace.()V"; @@ -65,9 +31,9 @@ public virtual unsafe void PrintStackTrace () } - [global::Android.Runtime.Register ("java/io/IOException", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/io/IOException", GenerateJavaPeer=false)] internal partial class IOExceptionInvoker : IOException { - public IOExceptionInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + public IOExceptionInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } @@ -79,11 +45,5 @@ public IOExceptionInvoker (IntPtr handle, JniHandleOwnership transfer) : base (h get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - } } diff --git a/tests/generator-Tests/expected.ji/Streams/Java.IO.InputStream.cs b/tests/generator-Tests/expected.ji/Streams/Java.IO.InputStream.cs index e4d83e771..e1bbfb7bb 100644 --- a/tests/generator-Tests/expected.ji/Streams/Java.IO.InputStream.cs +++ b/tests/generator-Tests/expected.ji/Streams/Java.IO.InputStream.cs @@ -1,76 +1,41 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.IO { // Metadata.xml XPath class reference: path="/api/package[@name='java.io']/class[@name='InputStream']" - [global::Android.Runtime.Register ("java/io/InputStream", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/io/InputStream", GenerateJavaPeer=false)] public abstract partial class InputStream : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/io/InputStream", typeof (InputStream)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected InputStream (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected InputStream (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath constructor reference: path="/api/package[@name='java.io']/class[@name='InputStream']/constructor[@name='InputStream' and count(parameter)=0]" - [Register (".ctor", "()V", "")] - public unsafe InputStream () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe InputStream () : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "()V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; try { var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { } } - static Delegate cb_available; -#pragma warning disable 0169 - static Delegate GetAvailableHandler () - { - if (cb_available == null) - cb_available = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_Available); - return cb_available; - } - - static int n_Available (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return __this.Available (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='available' and count(parameter)=0]" - [Register ("available", "()I", "GetAvailableHandler")] public virtual unsafe int Available () { const string __id = "available.()I"; @@ -81,24 +46,7 @@ public virtual unsafe int Available () } } - static Delegate cb_close; -#pragma warning disable 0169 - static Delegate GetCloseHandler () - { - if (cb_close == null) - cb_close = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Close); - return cb_close; - } - - static void n_Close (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Close (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='close' and count(parameter)=0]" - [Register ("close", "()V", "GetCloseHandler")] public virtual unsafe void Close () { const string __id = "close.()V"; @@ -108,24 +56,7 @@ public virtual unsafe void Close () } } - static Delegate cb_mark_I; -#pragma warning disable 0169 - static Delegate GetMark_IHandler () - { - if (cb_mark_I == null) - cb_mark_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_Mark_I); - return cb_mark_I; - } - - static void n_Mark_I (IntPtr jnienv, IntPtr native__this, int readlimit) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Mark (readlimit); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='mark' and count(parameter)=1 and parameter[1][@type='int']]" - [Register ("mark", "(I)V", "GetMark_IHandler")] public virtual unsafe void Mark (int readlimit) { const string __id = "mark.(I)V"; @@ -137,24 +68,7 @@ public virtual unsafe void Mark (int readlimit) } } - static Delegate cb_markSupported; -#pragma warning disable 0169 - static Delegate GetMarkSupportedHandler () - { - if (cb_markSupported == null) - cb_markSupported = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_Z) n_MarkSupported); - return cb_markSupported; - } - - static bool n_MarkSupported (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return __this.MarkSupported (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='markSupported' and count(parameter)=0]" - [Register ("markSupported", "()Z", "GetMarkSupportedHandler")] public virtual unsafe bool MarkSupported () { const string __id = "markSupported.()Z"; @@ -165,52 +79,14 @@ public virtual unsafe bool MarkSupported () } } - static Delegate cb_read; -#pragma warning disable 0169 - static Delegate GetReadHandler () - { - if (cb_read == null) - cb_read = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_Read); - return cb_read; - } - - static int n_Read (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return __this.Read (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='read' and count(parameter)=0]" - [Register ("read", "()I", "GetReadHandler")] public abstract int Read (); - static Delegate cb_read_arrayB; -#pragma warning disable 0169 - static Delegate GetRead_arrayBHandler () - { - if (cb_read_arrayB == null) - cb_read_arrayB = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_Read_arrayB); - return cb_read_arrayB; - } - - static int n_Read_arrayB (IntPtr jnienv, IntPtr native__this, IntPtr native_buffer) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var buffer = (byte[]) JNIEnv.GetArray (native_buffer, JniHandleOwnership.DoNotTransfer, typeof (byte)); - int __ret = __this.Read (buffer); - if (buffer != null) - JNIEnv.CopyArray (buffer, native_buffer); - return __ret; - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='read' and count(parameter)=1 and parameter[1][@type='byte[]']]" - [Register ("read", "([B)I", "GetRead_arrayBHandler")] - public virtual unsafe int Read (byte[] buffer) + public virtual unsafe int Read (global::System.Collections.Generic.IList buffer) { const string __id = "read.([B)I"; - IntPtr native_buffer = JNIEnv.NewArray (buffer); + var native_buffer = global::Java.Interop.JavaSByteArray.CreateMarshalArray (buffer); try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (native_buffer); @@ -218,39 +94,17 @@ public virtual unsafe int Read (byte[] buffer) return __rm; } finally { if (buffer != null) { - JNIEnv.CopyArray (native_buffer, buffer); - JNIEnv.DeleteLocalRef (native_buffer); + native_buffer.DisposeUnlessReferenced (); } global::System.GC.KeepAlive (buffer); } } - static Delegate cb_read_arrayBII; -#pragma warning disable 0169 - static Delegate GetRead_arrayBIIHandler () - { - if (cb_read_arrayBII == null) - cb_read_arrayBII = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPLII_I) n_Read_arrayBII); - return cb_read_arrayBII; - } - - static int n_Read_arrayBII (IntPtr jnienv, IntPtr native__this, IntPtr native_buffer, int byteOffset, int byteCount) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var buffer = (byte[]) JNIEnv.GetArray (native_buffer, JniHandleOwnership.DoNotTransfer, typeof (byte)); - int __ret = __this.Read (buffer, byteOffset, byteCount); - if (buffer != null) - JNIEnv.CopyArray (buffer, native_buffer); - return __ret; - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='read' and count(parameter)=3 and parameter[1][@type='byte[]'] and parameter[2][@type='int'] and parameter[3][@type='int']]" - [Register ("read", "([BII)I", "GetRead_arrayBIIHandler")] - public virtual unsafe int Read (byte[] buffer, int byteOffset, int byteCount) + public virtual unsafe int Read (global::System.Collections.Generic.IList buffer, int byteOffset, int byteCount) { const string __id = "read.([BII)I"; - IntPtr native_buffer = JNIEnv.NewArray (buffer); + var native_buffer = global::Java.Interop.JavaSByteArray.CreateMarshalArray (buffer); try { JniArgumentValue* __args = stackalloc JniArgumentValue [3]; __args [0] = new JniArgumentValue (native_buffer); @@ -260,31 +114,13 @@ public virtual unsafe int Read (byte[] buffer, int byteOffset, int byteCount) return __rm; } finally { if (buffer != null) { - JNIEnv.CopyArray (native_buffer, buffer); - JNIEnv.DeleteLocalRef (native_buffer); + native_buffer.DisposeUnlessReferenced (); } global::System.GC.KeepAlive (buffer); } } - static Delegate cb_reset; -#pragma warning disable 0169 - static Delegate GetResetHandler () - { - if (cb_reset == null) - cb_reset = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Reset); - return cb_reset; - } - - static void n_Reset (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Reset (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='reset' and count(parameter)=0]" - [Register ("reset", "()V", "GetResetHandler")] public virtual unsafe void Reset () { const string __id = "reset.()V"; @@ -294,24 +130,7 @@ public virtual unsafe void Reset () } } - static Delegate cb_skip_J; -#pragma warning disable 0169 - static Delegate GetSkip_JHandler () - { - if (cb_skip_J == null) - cb_skip_J = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPJ_J) n_Skip_J); - return cb_skip_J; - } - - static long n_Skip_J (IntPtr jnienv, IntPtr native__this, long byteCount) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return __this.Skip (byteCount); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='skip' and count(parameter)=1 and parameter[1][@type='long']]" - [Register ("skip", "(J)J", "GetSkip_JHandler")] public virtual unsafe long Skip (long byteCount) { const string __id = "skip.(J)J"; @@ -326,9 +145,9 @@ public virtual unsafe long Skip (long byteCount) } - [global::Android.Runtime.Register ("java/io/InputStream", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/io/InputStream", GenerateJavaPeer=false)] internal partial class InputStreamInvoker : InputStream { - public InputStreamInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + public InputStreamInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } @@ -340,14 +159,7 @@ public InputStreamInvoker (IntPtr handle, JniHandleOwnership transfer) : base (h get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='read' and count(parameter)=0]" - [Register ("read", "()I", "GetReadHandler")] public override unsafe int Read () { const string __id = "read.()I"; diff --git a/tests/generator-Tests/expected.ji/Streams/Java.IO.OutputStream.cs b/tests/generator-Tests/expected.ji/Streams/Java.IO.OutputStream.cs index c0224400d..9f36e2fda 100644 --- a/tests/generator-Tests/expected.ji/Streams/Java.IO.OutputStream.cs +++ b/tests/generator-Tests/expected.ji/Streams/Java.IO.OutputStream.cs @@ -1,76 +1,41 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.IO { // Metadata.xml XPath class reference: path="/api/package[@name='java.io']/class[@name='OutputStream']" - [global::Android.Runtime.Register ("java/io/OutputStream", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/io/OutputStream", GenerateJavaPeer=false)] public abstract partial class OutputStream : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/io/OutputStream", typeof (OutputStream)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected OutputStream (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected OutputStream (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath constructor reference: path="/api/package[@name='java.io']/class[@name='OutputStream']/constructor[@name='OutputStream' and count(parameter)=0]" - [Register (".ctor", "()V", "")] - public unsafe OutputStream () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe OutputStream () : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "()V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; try { var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { } } - static Delegate cb_close; -#pragma warning disable 0169 - static Delegate GetCloseHandler () - { - if (cb_close == null) - cb_close = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Close); - return cb_close; - } - - static void n_Close (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Close (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='OutputStream']/method[@name='close' and count(parameter)=0]" - [Register ("close", "()V", "GetCloseHandler")] public virtual unsafe void Close () { const string __id = "close.()V"; @@ -80,24 +45,7 @@ public virtual unsafe void Close () } } - static Delegate cb_flush; -#pragma warning disable 0169 - static Delegate GetFlushHandler () - { - if (cb_flush == null) - cb_flush = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Flush); - return cb_flush; - } - - static void n_Flush (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Flush (); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='OutputStream']/method[@name='flush' and count(parameter)=0]" - [Register ("flush", "()V", "GetFlushHandler")] public virtual unsafe void Flush () { const string __id = "flush.()V"; @@ -107,69 +55,28 @@ public virtual unsafe void Flush () } } - static Delegate cb_write_arrayB; -#pragma warning disable 0169 - static Delegate GetWrite_arrayBHandler () - { - if (cb_write_arrayB == null) - cb_write_arrayB = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_Write_arrayB); - return cb_write_arrayB; - } - - static void n_Write_arrayB (IntPtr jnienv, IntPtr native__this, IntPtr native_buffer) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var buffer = (byte[]) JNIEnv.GetArray (native_buffer, JniHandleOwnership.DoNotTransfer, typeof (byte)); - __this.Write (buffer); - if (buffer != null) - JNIEnv.CopyArray (buffer, native_buffer); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='OutputStream']/method[@name='write' and count(parameter)=1 and parameter[1][@type='byte[]']]" - [Register ("write", "([B)V", "GetWrite_arrayBHandler")] - public virtual unsafe void Write (byte[] buffer) + public virtual unsafe void Write (global::System.Collections.Generic.IList buffer) { const string __id = "write.([B)V"; - IntPtr native_buffer = JNIEnv.NewArray (buffer); + var native_buffer = global::Java.Interop.JavaSByteArray.CreateMarshalArray (buffer); try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (native_buffer); _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); } finally { if (buffer != null) { - JNIEnv.CopyArray (native_buffer, buffer); - JNIEnv.DeleteLocalRef (native_buffer); + native_buffer.DisposeUnlessReferenced (); } global::System.GC.KeepAlive (buffer); } } - static Delegate cb_write_arrayBII; -#pragma warning disable 0169 - static Delegate GetWrite_arrayBIIHandler () - { - if (cb_write_arrayBII == null) - cb_write_arrayBII = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPLII_V) n_Write_arrayBII); - return cb_write_arrayBII; - } - - static void n_Write_arrayBII (IntPtr jnienv, IntPtr native__this, IntPtr native_buffer, int offset, int count) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var buffer = (byte[]) JNIEnv.GetArray (native_buffer, JniHandleOwnership.DoNotTransfer, typeof (byte)); - __this.Write (buffer, offset, count); - if (buffer != null) - JNIEnv.CopyArray (buffer, native_buffer); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='OutputStream']/method[@name='write' and count(parameter)=3 and parameter[1][@type='byte[]'] and parameter[2][@type='int'] and parameter[3][@type='int']]" - [Register ("write", "([BII)V", "GetWrite_arrayBIIHandler")] - public virtual unsafe void Write (byte[] buffer, int offset, int count) + public virtual unsafe void Write (global::System.Collections.Generic.IList buffer, int offset, int count) { const string __id = "write.([BII)V"; - IntPtr native_buffer = JNIEnv.NewArray (buffer); + var native_buffer = global::Java.Interop.JavaSByteArray.CreateMarshalArray (buffer); try { JniArgumentValue* __args = stackalloc JniArgumentValue [3]; __args [0] = new JniArgumentValue (native_buffer); @@ -178,38 +85,20 @@ public virtual unsafe void Write (byte[] buffer, int offset, int count) _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); } finally { if (buffer != null) { - JNIEnv.CopyArray (native_buffer, buffer); - JNIEnv.DeleteLocalRef (native_buffer); + native_buffer.DisposeUnlessReferenced (); } global::System.GC.KeepAlive (buffer); } } - static Delegate cb_write_I; -#pragma warning disable 0169 - static Delegate GetWrite_IHandler () - { - if (cb_write_I == null) - cb_write_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_Write_I); - return cb_write_I; - } - - static void n_Write_I (IntPtr jnienv, IntPtr native__this, int oneByte) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - __this.Write (oneByte); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='OutputStream']/method[@name='write' and count(parameter)=1 and parameter[1][@type='int']]" - [Register ("write", "(I)V", "GetWrite_IHandler")] public abstract void Write (int oneByte); } - [global::Android.Runtime.Register ("java/io/OutputStream", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/io/OutputStream", GenerateJavaPeer=false)] internal partial class OutputStreamInvoker : OutputStream { - public OutputStreamInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + public OutputStreamInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } @@ -221,14 +110,7 @@ public OutputStreamInvoker (IntPtr handle, JniHandleOwnership transfer) : base ( get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='OutputStream']/method[@name='write' and count(parameter)=1 and parameter[1][@type='int']]" - [Register ("write", "(I)V", "GetWrite_IHandler")] public override unsafe void Write (int oneByte) { const string __id = "write.(I)V"; diff --git a/tests/generator-Tests/expected.ji/Streams/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/Streams/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/Streams/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/Streams/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/Streams/Java.Lang.Throwable.cs b/tests/generator-Tests/expected.ji/Streams/Java.Lang.Throwable.cs index ecbe99e8b..819a48c13 100644 --- a/tests/generator-Tests/expected.ji/Streams/Java.Lang.Throwable.cs +++ b/tests/generator-Tests/expected.ji/Streams/Java.Lang.Throwable.cs @@ -1,43 +1,21 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Throwable']" - [global::Android.Runtime.Register ("java/lang/Throwable", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Throwable", GenerateJavaPeer=false)] public partial class Throwable { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Throwable", typeof (Throwable)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - static Delegate cb_getMessage; -#pragma warning disable 0169 - static Delegate GetGetMessageHandler () - { - if (cb_getMessage == null) - cb_getMessage = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetMessage); - return cb_getMessage; - } - - static IntPtr n_GetMessage (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.NewString (__this.Message); - } -#pragma warning restore 0169 - public new virtual unsafe string Message { // Metadata.xml XPath method reference: path="/api/package[@name='java.lang']/class[@name='Throwable']/method[@name='getMessage' and count(parameter)=0]" - [Register ("getMessage", "()Ljava/lang/String;", "GetGetMessageHandler")] get { const string __id = "getMessage.()Ljava/lang/String;"; try { var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); - return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } diff --git a/tests/generator-Tests/expected.ji/Streams/Mono.Android.projitems b/tests/generator-Tests/expected.ji/Streams/Mono.Android.projitems index 3d19ddac3..835eac214 100644 --- a/tests/generator-Tests/expected.ji/Streams/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/Streams/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/Streams/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/Streams/__NamespaceMapping__.cs index 3df5eaf1a..417caab06 100644 --- a/tests/generator-Tests/expected.ji/Streams/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/Streams/__NamespaceMapping__.cs @@ -1,15 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.io", Managed="Java.IO")] - -delegate int _JniMarshal_PP_I (IntPtr jnienv, IntPtr klass); -delegate IntPtr _JniMarshal_PP_L (IntPtr jnienv, IntPtr klass); -delegate void _JniMarshal_PP_V (IntPtr jnienv, IntPtr klass); -delegate bool _JniMarshal_PP_Z (IntPtr jnienv, IntPtr klass); -delegate void _JniMarshal_PPI_V (IntPtr jnienv, IntPtr klass, int p0); -delegate long _JniMarshal_PPJ_J (IntPtr jnienv, IntPtr klass, long p0); -delegate int _JniMarshal_PPL_I (IntPtr jnienv, IntPtr klass, IntPtr p0); -delegate void _JniMarshal_PPL_V (IntPtr jnienv, IntPtr klass, IntPtr p0); -delegate int _JniMarshal_PPLII_I (IntPtr jnienv, IntPtr klass, IntPtr p0, int p1, int p2); -delegate void _JniMarshal_PPLII_V (IntPtr jnienv, IntPtr klass, IntPtr p0, int p1, int p2); diff --git a/tests/generator-Tests/expected.ji/TestInterface/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/TestInterface/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/TestInterface/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/TestInterface/Java.Lang.String.cs b/tests/generator-Tests/expected.ji/TestInterface/Java.Lang.String.cs index 8bd2e2e72..4cf8f3b23 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/Java.Lang.String.cs +++ b/tests/generator-Tests/expected.ji/TestInterface/Java.Lang.String.cs @@ -1,38 +1,21 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='String']" - [global::Android.Runtime.Register ("java/lang/String", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/String", GenerateJavaPeer=false)] public sealed partial class String : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/String", typeof (String)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - internal String (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + internal String (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } diff --git a/tests/generator-Tests/expected.ji/TestInterface/Mono.Android.projitems b/tests/generator-Tests/expected.ji/TestInterface/Mono.Android.projitems index 5a3e90231..543e7917a 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/TestInterface/Mono.Android.projitems @@ -7,7 +7,6 @@ - diff --git a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericImplementation.cs b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericImplementation.cs index 3a5cdda34..57548f289 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericImplementation.cs +++ b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericImplementation.cs @@ -1,92 +1,49 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Test.ME { // Metadata.xml XPath class reference: path="/api/package[@name='test.me']/class[@name='GenericImplementation']" - [global::Android.Runtime.Register ("test/me/GenericImplementation", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("test/me/GenericImplementation", GenerateJavaPeer=false)] public partial class GenericImplementation : global::Java.Lang.Object, global::Test.ME.IGenericInterface { static readonly JniPeerMembers _members = new JniPeerMembers ("test/me/GenericImplementation", typeof (GenericImplementation)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected GenericImplementation (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected GenericImplementation (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath constructor reference: path="/api/package[@name='test.me']/class[@name='GenericImplementation']/constructor[@name='GenericImplementation' and count(parameter)=0]" - [Register (".ctor", "()V", "")] - public unsafe GenericImplementation () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe GenericImplementation () : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "()V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; try { var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { } } - static Delegate cb_SetObject_arrayB; -#pragma warning disable 0169 - static Delegate GetSetObject_arrayBHandler () - { - if (cb_SetObject_arrayB == null) - cb_SetObject_arrayB = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetObject_arrayB); - return cb_SetObject_arrayB; - } - - static void n_SetObject_arrayB (IntPtr jnienv, IntPtr native__this, IntPtr native_value) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var value = (byte[]) JNIEnv.GetArray (native_value, JniHandleOwnership.DoNotTransfer, typeof (byte)); - __this.SetObject (value); - if (value != null) - JNIEnv.CopyArray (value, native_value); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/class[@name='GenericImplementation']/method[@name='SetObject' and count(parameter)=1 and parameter[1][@type='byte[]']]" - [Register ("SetObject", "([B)V", "GetSetObject_arrayBHandler")] - public virtual unsafe void SetObject (byte[] value) + public virtual unsafe void SetObject (global::Java.Interop.JavaSByteArray value) { const string __id = "SetObject.([B)V"; - IntPtr native_value = JNIEnv.NewArray (value); try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue (native_value); + __args [0] = new JniArgumentValue (value); _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); } finally { - if (value != null) { - JNIEnv.CopyArray (native_value, value); - JNIEnv.DeleteLocalRef (native_value); - } global::System.GC.KeepAlive (value); } } @@ -94,7 +51,7 @@ public virtual unsafe void SetObject (byte[] value) // This method is explicitly implemented as a member of an instantiated Test.ME.IGenericInterface void global::Test.ME.IGenericInterface.SetObject (global::Java.Lang.Object value) { - SetObject (value.ToArray ()); + SetObject (global::Java.Interop.JavaObjectExtensions.JavaCast(value)); } } diff --git a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericObjectPropertyImplementation.cs b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericObjectPropertyImplementation.cs index 4e8786789..f9eaaf0a1 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericObjectPropertyImplementation.cs +++ b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericObjectPropertyImplementation.cs @@ -1,109 +1,56 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Test.ME { // Metadata.xml XPath class reference: path="/api/package[@name='test.me']/class[@name='GenericObjectPropertyImplementation']" - [global::Android.Runtime.Register ("test/me/GenericObjectPropertyImplementation", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("test/me/GenericObjectPropertyImplementation", GenerateJavaPeer=false)] public partial class GenericObjectPropertyImplementation : global::Java.Lang.Object, global::Test.ME.IGenericPropertyInterface { static readonly JniPeerMembers _members = new JniPeerMembers ("test/me/GenericObjectPropertyImplementation", typeof (GenericObjectPropertyImplementation)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected GenericObjectPropertyImplementation (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected GenericObjectPropertyImplementation (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath constructor reference: path="/api/package[@name='test.me']/class[@name='GenericObjectPropertyImplementation']/constructor[@name='GenericObjectPropertyImplementation' and count(parameter)=0]" - [Register (".ctor", "()V", "")] - public unsafe GenericObjectPropertyImplementation () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe GenericObjectPropertyImplementation () : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "()V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; try { var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { } } - static Delegate cb_getObject; -#pragma warning disable 0169 - static Delegate GetGetObjectHandler () - { - if (cb_getObject == null) - cb_getObject = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetObject); - return cb_getObject; - } - - static IntPtr n_GetObject (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.ToLocalJniHandle (__this.Object); - } -#pragma warning restore 0169 - - static Delegate cb_setObject_Ljava_lang_Object_; -#pragma warning disable 0169 - static Delegate GetSetObject_Ljava_lang_Object_Handler () - { - if (cb_setObject_Ljava_lang_Object_ == null) - cb_setObject_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetObject_Ljava_lang_Object_); - return cb_setObject_Ljava_lang_Object_; - } - - static void n_SetObject_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var value = global::Java.Lang.Object.GetObject (native_value, JniHandleOwnership.DoNotTransfer); - __this.Object = value; - } -#pragma warning restore 0169 - public virtual unsafe global::Java.Lang.Object Object { // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/class[@name='GenericObjectPropertyImplementation']/method[@name='getObject' and count(parameter)=0]" - [Register ("getObject", "()Ljava/lang/Object;", "GetGetObjectHandler")] get { const string __id = "getObject.()Ljava/lang/Object;"; try { var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); - return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/class[@name='GenericObjectPropertyImplementation']/method[@name='setObject' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" - [Register ("setObject", "(Ljava/lang/Object;)V", "GetSetObject_Ljava_lang_Object_Handler")] set { const string __id = "setObject.(Ljava/lang/Object;)V"; try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue ((value == null) ? IntPtr.Zero : ((global::Java.Lang.Object) value).Handle); + __args [0] = new JniArgumentValue (value); _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); } finally { global::System.GC.KeepAlive (value); diff --git a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericStringImplementation.cs b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericStringImplementation.cs index d04fdb041..980f0f8c1 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericStringImplementation.cs +++ b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericStringImplementation.cs @@ -1,92 +1,49 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Test.ME { // Metadata.xml XPath class reference: path="/api/package[@name='test.me']/class[@name='GenericStringImplementation']" - [global::Android.Runtime.Register ("test/me/GenericStringImplementation", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("test/me/GenericStringImplementation", GenerateJavaPeer=false)] public partial class GenericStringImplementation : global::Java.Lang.Object, global::Test.ME.IGenericInterface { static readonly JniPeerMembers _members = new JniPeerMembers ("test/me/GenericStringImplementation", typeof (GenericStringImplementation)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected GenericStringImplementation (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected GenericStringImplementation (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath constructor reference: path="/api/package[@name='test.me']/class[@name='GenericStringImplementation']/constructor[@name='GenericStringImplementation' and count(parameter)=0]" - [Register (".ctor", "()V", "")] - public unsafe GenericStringImplementation () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe GenericStringImplementation () : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "()V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; try { var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { } } - static Delegate cb_SetObject_arrayLjava_lang_String_; -#pragma warning disable 0169 - static Delegate GetSetObject_arrayLjava_lang_String_Handler () - { - if (cb_SetObject_arrayLjava_lang_String_ == null) - cb_SetObject_arrayLjava_lang_String_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetObject_arrayLjava_lang_String_); - return cb_SetObject_arrayLjava_lang_String_; - } - - static void n_SetObject_arrayLjava_lang_String_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var value = (string[]) JNIEnv.GetArray (native_value, JniHandleOwnership.DoNotTransfer, typeof (string)); - __this.SetObject (value); - if (value != null) - JNIEnv.CopyArray (value, native_value); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/class[@name='GenericStringImplementation']/method[@name='SetObject' and count(parameter)=1 and parameter[1][@type='java.lang.String[]']]" - [Register ("SetObject", "([Ljava/lang/String;)V", "GetSetObject_arrayLjava_lang_String_Handler")] - public virtual unsafe void SetObject (string[] value) + public virtual unsafe void SetObject (global::Java.Interop.JavaObjectArray value) { const string __id = "SetObject.([Ljava/lang/String;)V"; - IntPtr native_value = JNIEnv.NewArray (value); try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue (native_value); + __args [0] = new JniArgumentValue (value); _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); } finally { - if (value != null) { - JNIEnv.CopyArray (native_value, value); - JNIEnv.DeleteLocalRef (native_value); - } global::System.GC.KeepAlive (value); } } @@ -94,7 +51,7 @@ public virtual unsafe void SetObject (string[] value) // This method is explicitly implemented as a member of an instantiated Test.ME.IGenericInterface void global::Test.ME.IGenericInterface.SetObject (global::Java.Lang.Object value) { - SetObject (value.ToArray ()); + SetObject (global::Java.Interop.JavaObjectExtensions.JavaCast>(value)); } } diff --git a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericStringPropertyImplementation.cs b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericStringPropertyImplementation.cs index 8be8abe7b..4d1a64e6c 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericStringPropertyImplementation.cs +++ b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.GenericStringPropertyImplementation.cs @@ -1,113 +1,60 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Test.ME { // Metadata.xml XPath class reference: path="/api/package[@name='test.me']/class[@name='GenericStringPropertyImplementation']" - [global::Android.Runtime.Register ("test/me/GenericStringPropertyImplementation", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("test/me/GenericStringPropertyImplementation", GenerateJavaPeer=false)] public partial class GenericStringPropertyImplementation : global::Java.Lang.Object, global::Test.ME.IGenericPropertyInterface { static readonly JniPeerMembers _members = new JniPeerMembers ("test/me/GenericStringPropertyImplementation", typeof (GenericStringPropertyImplementation)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected GenericStringPropertyImplementation (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected GenericStringPropertyImplementation (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath constructor reference: path="/api/package[@name='test.me']/class[@name='GenericStringPropertyImplementation']/constructor[@name='GenericStringPropertyImplementation' and count(parameter)=0]" - [Register (".ctor", "()V", "")] - public unsafe GenericStringPropertyImplementation () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe GenericStringPropertyImplementation () : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "()V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; try { var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { } } - static Delegate cb_getObject; -#pragma warning disable 0169 - static Delegate GetGetObjectHandler () - { - if (cb_getObject == null) - cb_getObject = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetObject); - return cb_getObject; - } - - static IntPtr n_GetObject (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.NewString (__this.Object); - } -#pragma warning restore 0169 - - static Delegate cb_SetObject_Ljava_lang_String_; -#pragma warning disable 0169 - static Delegate GetSetObject_Ljava_lang_String_Handler () - { - if (cb_SetObject_Ljava_lang_String_ == null) - cb_SetObject_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetObject_Ljava_lang_String_); - return cb_SetObject_Ljava_lang_String_; - } - - static void n_SetObject_Ljava_lang_String_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var value = JNIEnv.GetString (native_value, JniHandleOwnership.DoNotTransfer); - __this.Object = value; - } -#pragma warning restore 0169 - public virtual unsafe string Object { // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/class[@name='GenericStringPropertyImplementation']/method[@name='getObject' and count(parameter)=0]" - [Register ("getObject", "()Ljava/lang/String;", "GetGetObjectHandler")] get { const string __id = "getObject.()Ljava/lang/String;"; try { var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); - return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose); } finally { } } // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/class[@name='GenericStringPropertyImplementation']/method[@name='SetObject' and count(parameter)=1 and parameter[1][@type='java.lang.String']]" - [Register ("SetObject", "(Ljava/lang/String;)V", "GetSetObject_Ljava_lang_String_Handler")] set { const string __id = "SetObject.(Ljava/lang/String;)V"; - IntPtr native_value = JNIEnv.NewString (value); + var native_value = global::Java.Interop.JniEnvironment.Strings.NewString (value); try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (native_value); _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); } finally { - JNIEnv.DeleteLocalRef (native_value); + global::Java.Interop.JniObjectReference.Dispose (ref native_value); } } } diff --git a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericInterface.cs b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericInterface.cs index 55919db03..148fbb718 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericInterface.cs +++ b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericInterface.cs @@ -1,103 +1,15 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Test.ME { // Metadata.xml XPath interface reference: path="/api/package[@name='test.me']/interface[@name='GenericInterface']" - [Register ("test/me/GenericInterface", "", "Test.ME.IGenericInterfaceInvoker")] + [global::Java.Interop.JniTypeSignature ("test/me/GenericInterface", GenerateJavaPeer=false)] [global::Java.Interop.JavaTypeParameters (new string [] {"T"})] - public partial interface IGenericInterface : IJavaObject, IJavaPeerable { + public partial interface IGenericInterface : IJavaPeerable { // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='GenericInterface']/method[@name='SetObject' and count(parameter)=1 and parameter[1][@type='T']]" - [Register ("SetObject", "(Ljava/lang/Object;)V", "GetSetObject_Ljava_lang_Object_Handler:Test.ME.IGenericInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] void SetObject (global::Java.Lang.Object value); } - - [global::Android.Runtime.Register ("test/me/GenericInterface", DoNotGenerateAcw=true)] - internal partial class IGenericInterfaceInvoker : global::Java.Lang.Object, IGenericInterface { - static readonly JniPeerMembers _members = new JniPeerMembers ("test/me/GenericInterface", typeof (IGenericInterfaceInvoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static IGenericInterface GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'test.me.GenericInterface'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public IGenericInterfaceInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - - static Delegate cb_SetObject_Ljava_lang_Object_; -#pragma warning disable 0169 - static Delegate GetSetObject_Ljava_lang_Object_Handler () - { - if (cb_SetObject_Ljava_lang_Object_ == null) - cb_SetObject_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetObject_Ljava_lang_Object_); - return cb_SetObject_Ljava_lang_Object_; - } - - static void n_SetObject_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var value = global::Java.Lang.Object.GetObject (native_value, JniHandleOwnership.DoNotTransfer); - __this.SetObject (value); - } -#pragma warning restore 0169 - - IntPtr id_SetObject_Ljava_lang_Object_; - public unsafe void SetObject (global::Java.Lang.Object value) - { - if (id_SetObject_Ljava_lang_Object_ == IntPtr.Zero) - id_SetObject_Ljava_lang_Object_ = JNIEnv.GetMethodID (class_ref, "SetObject", "(Ljava/lang/Object;)V"); - IntPtr native_value = JNIEnv.ToLocalJniHandle (value); - JValue* __args = stackalloc JValue [1]; - __args [0] = new JValue (native_value); - JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_SetObject_Ljava_lang_Object_, __args); - JNIEnv.DeleteLocalRef (native_value); - } - - } } diff --git a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericPropertyInterface.cs b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericPropertyInterface.cs index fb53d8fed..cb88559ca 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericPropertyInterface.cs +++ b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericPropertyInterface.cs @@ -1,132 +1,20 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Test.ME { // Metadata.xml XPath interface reference: path="/api/package[@name='test.me']/interface[@name='GenericPropertyInterface']" - [Register ("test/me/GenericPropertyInterface", "", "Test.ME.IGenericPropertyInterfaceInvoker")] + [global::Java.Interop.JniTypeSignature ("test/me/GenericPropertyInterface", GenerateJavaPeer=false)] [global::Java.Interop.JavaTypeParameters (new string [] {"T"})] - public partial interface IGenericPropertyInterface : IJavaObject, IJavaPeerable { + public partial interface IGenericPropertyInterface : IJavaPeerable { global::Java.Lang.Object Object { // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='GenericPropertyInterface']/method[@name='getObject' and count(parameter)=0]" - [Register ("getObject", "()Ljava/lang/Object;", "GetGetObjectHandler:Test.ME.IGenericPropertyInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] get; // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='GenericPropertyInterface']/method[@name='setObject' and count(parameter)=1 and parameter[1][@type='T']]" - [Register ("setObject", "(Ljava/lang/Object;)V", "GetSetObject_Ljava_lang_Object_Handler:Test.ME.IGenericPropertyInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] set; } } - - [global::Android.Runtime.Register ("test/me/GenericPropertyInterface", DoNotGenerateAcw=true)] - internal partial class IGenericPropertyInterfaceInvoker : global::Java.Lang.Object, IGenericPropertyInterface { - static readonly JniPeerMembers _members = new JniPeerMembers ("test/me/GenericPropertyInterface", typeof (IGenericPropertyInterfaceInvoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static IGenericPropertyInterface GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'test.me.GenericPropertyInterface'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public IGenericPropertyInterfaceInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - - static Delegate cb_getObject; -#pragma warning disable 0169 - static Delegate GetGetObjectHandler () - { - if (cb_getObject == null) - cb_getObject = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetObject); - return cb_getObject; - } - - static IntPtr n_GetObject (IntPtr jnienv, IntPtr native__this) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - return JNIEnv.ToLocalJniHandle (__this.Object); - } -#pragma warning restore 0169 - - static Delegate cb_setObject_Ljava_lang_Object_; -#pragma warning disable 0169 - static Delegate GetSetObject_Ljava_lang_Object_Handler () - { - if (cb_setObject_Ljava_lang_Object_ == null) - cb_setObject_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetObject_Ljava_lang_Object_); - return cb_setObject_Ljava_lang_Object_; - } - - static void n_SetObject_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var value = global::Java.Lang.Object.GetObject (native_value, JniHandleOwnership.DoNotTransfer); - __this.Object = value; - } -#pragma warning restore 0169 - - IntPtr id_getObject; - IntPtr id_setObject_Ljava_lang_Object_; - public unsafe global::Java.Lang.Object Object { - get { - if (id_getObject == IntPtr.Zero) - id_getObject = JNIEnv.GetMethodID (class_ref, "getObject", "()Ljava/lang/Object;"); - return (global::Java.Lang.Object) global::Java.Lang.Object.GetObject (JNIEnv.CallObjectMethod (((global::Java.Lang.Object) this).Handle, id_getObject), JniHandleOwnership.TransferLocalRef); - } - set { - if (id_setObject_Ljava_lang_Object_ == IntPtr.Zero) - id_setObject_Ljava_lang_Object_ = JNIEnv.GetMethodID (class_ref, "setObject", "(Ljava/lang/Object;)V"); - IntPtr native_value = JNIEnv.ToLocalJniHandle (value); - JValue* __args = stackalloc JValue [1]; - __args [0] = new JValue (native_value); - JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_setObject_Ljava_lang_Object_, __args); - JNIEnv.DeleteLocalRef (native_value); - } - } - - } } diff --git a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.ITestInterface.cs b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.ITestInterface.cs index 25e8fca1c..809216acb 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.ITestInterface.cs +++ b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.ITestInterface.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Test.ME { @@ -12,18 +11,16 @@ internal TestInterface () } // Metadata.xml XPath field reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/field[@name='SPAN_COMPOSING']" - [Register ("SPAN_COMPOSING")] public const int SpanComposing = (int) 256; // Metadata.xml XPath field reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/field[@name='DEFAULT_FOO']" - [Register ("DEFAULT_FOO")] public static global::Java.Lang.Object DefaultFoo { get { const string __id = "DEFAULT_FOO.Ljava/lang/Object;"; var __v = _members.StaticFields.GetObjectValue (__id); - return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose); } } @@ -41,18 +38,15 @@ private TestInterfaceConsts () } // Metadata.xml XPath interface reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']" - [Register ("test/me/TestInterface", "", "Test.ME.ITestInterfaceInvoker")] - public partial interface ITestInterface : IJavaObject, IJavaPeerable { + [global::Java.Interop.JniTypeSignature ("test/me/TestInterface", GenerateJavaPeer=false)] + public partial interface ITestInterface : IJavaPeerable { // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='getSpanFlags' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" - [Register ("getSpanFlags", "(Ljava/lang/Object;)I", "GetGetSpanFlags_Ljava_lang_Object_Handler:Test.ME.ITestInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] int GetSpanFlags (global::Java.Lang.Object tag); // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='append' and count(parameter)=1 and parameter[1][@type='java.lang.CharSequence']]" - [Register ("append", "(Ljava/lang/CharSequence;)V", "GetAppend_Ljava_lang_CharSequence_Handler:Test.ME.ITestInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] void Append (global::Java.Lang.ICharSequence value); // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='identity' and count(parameter)=1 and parameter[1][@type='java.lang.CharSequence']]" - [Register ("identity", "(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;", "GetIdentity_Ljava_lang_CharSequence_Handler:Test.ME.ITestInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] global::Java.Lang.ICharSequence IdentityFormatted (global::Java.Lang.ICharSequence value); } @@ -75,150 +69,4 @@ public static string Identity (this Test.ME.ITestInterface self, string value) } } - - [global::Android.Runtime.Register ("test/me/TestInterface", DoNotGenerateAcw=true)] - internal partial class ITestInterfaceInvoker : global::Java.Lang.Object, ITestInterface { - static readonly JniPeerMembers _members = new JniPeerMembers ("test/me/TestInterface", typeof (ITestInterfaceInvoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static ITestInterface GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'test.me.TestInterface'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public ITestInterfaceInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - - static Delegate cb_getSpanFlags_Ljava_lang_Object_; -#pragma warning disable 0169 - static Delegate GetGetSpanFlags_Ljava_lang_Object_Handler () - { - if (cb_getSpanFlags_Ljava_lang_Object_ == null) - cb_getSpanFlags_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetSpanFlags_Ljava_lang_Object_); - return cb_getSpanFlags_Ljava_lang_Object_; - } - - static int n_GetSpanFlags_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_tag) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var tag = global::Java.Lang.Object.GetObject (native_tag, JniHandleOwnership.DoNotTransfer); - int __ret = __this.GetSpanFlags (tag); - return __ret; - } -#pragma warning restore 0169 - - IntPtr id_getSpanFlags_Ljava_lang_Object_; - public unsafe int GetSpanFlags (global::Java.Lang.Object tag) - { - if (id_getSpanFlags_Ljava_lang_Object_ == IntPtr.Zero) - id_getSpanFlags_Ljava_lang_Object_ = JNIEnv.GetMethodID (class_ref, "getSpanFlags", "(Ljava/lang/Object;)I"); - JValue* __args = stackalloc JValue [1]; - __args [0] = new JValue ((tag == null) ? IntPtr.Zero : ((global::Java.Lang.Object) tag).Handle); - var __ret = JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_getSpanFlags_Ljava_lang_Object_, __args); - return __ret; - } - - static Delegate cb_append_Ljava_lang_CharSequence_; -#pragma warning disable 0169 - static Delegate GetAppend_Ljava_lang_CharSequence_Handler () - { - if (cb_append_Ljava_lang_CharSequence_ == null) - cb_append_Ljava_lang_CharSequence_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_Append_Ljava_lang_CharSequence_); - return cb_append_Ljava_lang_CharSequence_; - } - - static void n_Append_Ljava_lang_CharSequence_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var value = global::Java.Lang.Object.GetObject (native_value, JniHandleOwnership.DoNotTransfer); - __this.Append (value); - } -#pragma warning restore 0169 - - IntPtr id_append_Ljava_lang_CharSequence_; - public unsafe void Append (global::Java.Lang.ICharSequence value) - { - if (id_append_Ljava_lang_CharSequence_ == IntPtr.Zero) - id_append_Ljava_lang_CharSequence_ = JNIEnv.GetMethodID (class_ref, "append", "(Ljava/lang/CharSequence;)V"); - IntPtr native_value = CharSequence.ToLocalJniHandle (value); - JValue* __args = stackalloc JValue [1]; - __args [0] = new JValue (native_value); - JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_append_Ljava_lang_CharSequence_, __args); - JNIEnv.DeleteLocalRef (native_value); - } - - static Delegate cb_identity_Ljava_lang_CharSequence_; -#pragma warning disable 0169 - static Delegate GetIdentity_Ljava_lang_CharSequence_Handler () - { - if (cb_identity_Ljava_lang_CharSequence_ == null) - cb_identity_Ljava_lang_CharSequence_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_L) n_Identity_Ljava_lang_CharSequence_); - return cb_identity_Ljava_lang_CharSequence_; - } - - static IntPtr n_Identity_Ljava_lang_CharSequence_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var value = global::Java.Lang.Object.GetObject (native_value, JniHandleOwnership.DoNotTransfer); - IntPtr __ret = CharSequence.ToLocalJniHandle (__this.IdentityFormatted (value)); - return __ret; - } -#pragma warning restore 0169 - - IntPtr id_identity_Ljava_lang_CharSequence_; - public unsafe global::Java.Lang.ICharSequence IdentityFormatted (global::Java.Lang.ICharSequence value) - { - if (id_identity_Ljava_lang_CharSequence_ == IntPtr.Zero) - id_identity_Ljava_lang_CharSequence_ = JNIEnv.GetMethodID (class_ref, "identity", "(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;"); - IntPtr native_value = CharSequence.ToLocalJniHandle (value); - JValue* __args = stackalloc JValue [1]; - __args [0] = new JValue (native_value); - var __ret = global::Java.Lang.Object.GetObject (JNIEnv.CallObjectMethod (((global::Java.Lang.Object) this).Handle, id_identity_Ljava_lang_CharSequence_, __args), JniHandleOwnership.TransferLocalRef); - JNIEnv.DeleteLocalRef (native_value); - return __ret; - } - - } } diff --git a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.TestInterfaceImplementation.cs b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.TestInterfaceImplementation.cs index 671ac041d..e1d682227 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.TestInterfaceImplementation.cs +++ b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.TestInterfaceImplementation.cs @@ -1,29 +1,26 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Test.ME { // Metadata.xml XPath class reference: path="/api/package[@name='test.me']/class[@name='TestInterfaceImplementation']" - [global::Android.Runtime.Register ("test/me/TestInterfaceImplementation", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("test/me/TestInterfaceImplementation", GenerateJavaPeer=false)] public abstract partial class TestInterfaceImplementation : global::Java.Lang.Object, global::Test.ME.ITestInterface { public static class InterfaceConsts { // The following are fields from: test.me.TestInterface // Metadata.xml XPath field reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/field[@name='SPAN_COMPOSING']" - [Register ("SPAN_COMPOSING")] public const int SpanComposing = (int) 256; // Metadata.xml XPath field reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/field[@name='DEFAULT_FOO']" - [Register ("DEFAULT_FOO")] public static global::Java.Lang.Object DefaultFoo { get { const string __id = "DEFAULT_FOO.Ljava/lang/Object;"; var __v = _members.StaticFields.GetObjectValue (__id); - return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose); } } @@ -31,90 +28,36 @@ public static class InterfaceConsts { static readonly JniPeerMembers _members = new JniPeerMembers ("test/me/TestInterfaceImplementation", typeof (TestInterfaceImplementation)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected TestInterfaceImplementation (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected TestInterfaceImplementation (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath constructor reference: path="/api/package[@name='test.me']/class[@name='TestInterfaceImplementation']/constructor[@name='TestInterfaceImplementation' and count(parameter)=0]" - [Register (".ctor", "()V", "")] - public unsafe TestInterfaceImplementation () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + public unsafe TestInterfaceImplementation () : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { const string __id = "()V"; - if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + if (PeerReference.IsValid) return; try { var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); - SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { } } - static Delegate cb_getSpanFlags_Ljava_lang_Object_; -#pragma warning disable 0169 - static Delegate GetGetSpanFlags_Ljava_lang_Object_Handler () - { - if (cb_getSpanFlags_Ljava_lang_Object_ == null) - cb_getSpanFlags_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetSpanFlags_Ljava_lang_Object_); - return cb_getSpanFlags_Ljava_lang_Object_; - } - - static int n_GetSpanFlags_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_tag) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var tag = global::Java.Lang.Object.GetObject (native_tag, JniHandleOwnership.DoNotTransfer); - int __ret = __this.GetSpanFlags (tag); - return __ret; - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='getSpanFlags' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" - [Register ("getSpanFlags", "(Ljava/lang/Object;)I", "GetGetSpanFlags_Ljava_lang_Object_Handler")] public abstract int GetSpanFlags (global::Java.Lang.Object tag); - static Delegate cb_append_Ljava_lang_CharSequence_; -#pragma warning disable 0169 - static Delegate GetAppend_Ljava_lang_CharSequence_Handler () - { - if (cb_append_Ljava_lang_CharSequence_ == null) - cb_append_Ljava_lang_CharSequence_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_Append_Ljava_lang_CharSequence_); - return cb_append_Ljava_lang_CharSequence_; - } - - static void n_Append_Ljava_lang_CharSequence_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var value = global::Java.Lang.Object.GetObject (native_value, JniHandleOwnership.DoNotTransfer); - __this.Append (value); - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='append' and count(parameter)=1 and parameter[1][@type='java.lang.CharSequence']]" - [Register ("append", "(Ljava/lang/CharSequence;)V", "GetAppend_Ljava_lang_CharSequence_Handler")] public abstract void Append (global::Java.Lang.ICharSequence value); public void Append (string value) @@ -124,26 +67,7 @@ public void Append (string value) jls_value?.Dispose (); } - static Delegate cb_identity_Ljava_lang_CharSequence_; -#pragma warning disable 0169 - static Delegate GetIdentity_Ljava_lang_CharSequence_Handler () - { - if (cb_identity_Ljava_lang_CharSequence_ == null) - cb_identity_Ljava_lang_CharSequence_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_L) n_Identity_Ljava_lang_CharSequence_); - return cb_identity_Ljava_lang_CharSequence_; - } - - static IntPtr n_Identity_Ljava_lang_CharSequence_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var value = global::Java.Lang.Object.GetObject (native_value, JniHandleOwnership.DoNotTransfer); - IntPtr __ret = CharSequence.ToLocalJniHandle (__this.IdentityFormatted (value)); - return __ret; - } -#pragma warning restore 0169 - // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='identity' and count(parameter)=1 and parameter[1][@type='java.lang.CharSequence']]" - [Register ("identity", "(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;", "GetIdentity_Ljava_lang_CharSequence_Handler")] public abstract global::Java.Lang.ICharSequence IdentityFormatted (global::Java.Lang.ICharSequence value); public string Identity (string value) @@ -157,9 +81,9 @@ public string Identity (string value) } - [global::Android.Runtime.Register ("test/me/TestInterfaceImplementation", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("test/me/TestInterfaceImplementation", GenerateJavaPeer=false)] internal partial class TestInterfaceImplementationInvoker : TestInterfaceImplementation { - public TestInterfaceImplementationInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + public TestInterfaceImplementationInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } @@ -171,20 +95,13 @@ public TestInterfaceImplementationInvoker (IntPtr handle, JniHandleOwnership tra get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='getSpanFlags' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" - [Register ("getSpanFlags", "(Ljava/lang/Object;)I", "GetGetSpanFlags_Ljava_lang_Object_Handler")] public override unsafe int GetSpanFlags (global::Java.Lang.Object tag) { const string __id = "getSpanFlags.(Ljava/lang/Object;)I"; try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; - __args [0] = new JniArgumentValue ((tag == null) ? IntPtr.Zero : ((global::Java.Lang.Object) tag).Handle); + __args [0] = new JniArgumentValue (tag); var __rm = _members.InstanceMethods.InvokeAbstractInt32Method (__id, this, __args); return __rm; } finally { @@ -193,7 +110,6 @@ public override unsafe int GetSpanFlags (global::Java.Lang.Object tag) } // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='append' and count(parameter)=1 and parameter[1][@type='java.lang.CharSequence']]" - [Register ("append", "(Ljava/lang/CharSequence;)V", "GetAppend_Ljava_lang_CharSequence_Handler")] public override unsafe void Append (global::Java.Lang.ICharSequence value) { const string __id = "append.(Ljava/lang/CharSequence;)V"; @@ -209,7 +125,6 @@ public override unsafe void Append (global::Java.Lang.ICharSequence value) } // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='identity' and count(parameter)=1 and parameter[1][@type='java.lang.CharSequence']]" - [Register ("identity", "(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;", "GetIdentity_Ljava_lang_CharSequence_Handler")] public override unsafe global::Java.Lang.ICharSequence IdentityFormatted (global::Java.Lang.ICharSequence value) { const string __id = "identity.(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;"; @@ -218,7 +133,7 @@ public override unsafe void Append (global::Java.Lang.ICharSequence value) JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (native_value); var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, __args); - return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Lang.Object.GetObject (__rm, JniHandleOwnership.TransferLocalRef); } finally { JNIEnv.DeleteLocalRef (native_value); global::System.GC.KeepAlive (value); diff --git a/tests/generator-Tests/expected.ji/TestInterface/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/TestInterface/__NamespaceMapping__.cs index f4ff95e01..417caab06 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/TestInterface/__NamespaceMapping__.cs @@ -1,11 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "test.me", Managed="Test.ME")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "", Managed="")] - -delegate IntPtr _JniMarshal_PP_L (IntPtr jnienv, IntPtr klass); -delegate void _JniMarshal_PP_V (IntPtr jnienv, IntPtr klass); -delegate int _JniMarshal_PPL_I (IntPtr jnienv, IntPtr klass, IntPtr p0); -delegate IntPtr _JniMarshal_PPL_L (IntPtr jnienv, IntPtr klass, IntPtr p0); -delegate void _JniMarshal_PPL_V (IntPtr jnienv, IntPtr klass, IntPtr p0); diff --git a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Enum.cs b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Enum.cs index 3370de241..bbec25401 100644 --- a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Enum.cs +++ b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Enum.cs @@ -1,44 +1,26 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Enum']" - [global::Android.Runtime.Register ("java/lang/Enum", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Enum", GenerateJavaPeer=false)] [global::Java.Interop.JavaTypeParameters (new string [] {"E extends java.lang.Enum"})] public abstract partial class Enum : global::Java.Lang.Object, global::Java.Lang.IComparable { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Enum", typeof (Enum)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected Enum (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected Enum (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } // Metadata.xml XPath method reference: path="/api/package[@name='java.lang']/class[@name='Enum']/method[@name='compareTo' and count(parameter)=1 and parameter[1][@type='E']]" - [Register ("compareTo", "(Ljava/lang/Enum;)I", "")] public unsafe int CompareTo (global::Java.Lang.Object o) { const string __id = "compareTo.(Ljava/lang/Enum;)I"; @@ -56,9 +38,9 @@ public unsafe int CompareTo (global::Java.Lang.Object o) } - [global::Android.Runtime.Register ("java/lang/Enum", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Enum", GenerateJavaPeer=false)] internal partial class EnumInvoker : Enum, global::Java.Lang.IComparable { - public EnumInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + public EnumInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } @@ -70,11 +52,5 @@ public EnumInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - } } diff --git a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs index e5d745baa..3907f9f94 100644 --- a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs +++ b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs @@ -1,105 +1,15 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath interface reference: path="/api/package[@name='java.lang']/interface[@name='Comparable']" - [Register ("java/lang/Comparable", "", "Java.Lang.IComparableInvoker")] + [global::Java.Interop.JniTypeSignature ("java/lang/Comparable", GenerateJavaPeer=false)] [global::Java.Interop.JavaTypeParameters (new string [] {"T"})] - public partial interface IComparable : IJavaObject, IJavaPeerable { + public partial interface IComparable : IJavaPeerable { // Metadata.xml XPath method reference: path="/api/package[@name='java.lang']/interface[@name='Comparable']/method[@name='compareTo' and count(parameter)=1 and parameter[1][@type='T']]" - [Register ("compareTo", "(Ljava/lang/Object;)I", "GetCompareTo_Ljava_lang_Object_Handler:Java.Lang.IComparableInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] int CompareTo (global::Java.Lang.Object another); } - - [global::Android.Runtime.Register ("java/lang/Comparable", DoNotGenerateAcw=true)] - internal partial class IComparableInvoker : global::Java.Lang.Object, IComparable { - static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Comparable", typeof (IComparableInvoker)); - - static IntPtr java_class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - public override global::Java.Interop.JniPeerMembers JniPeerMembers { - get { return _members; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return class_ref; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - new IntPtr class_ref; - - public static IComparable GetObject (IntPtr handle, JniHandleOwnership transfer) - { - return global::Java.Lang.Object.GetObject (handle, transfer); - } - - static IntPtr Validate (IntPtr handle) - { - if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.lang.Comparable'."); - return handle; - } - - protected override void Dispose (bool disposing) - { - if (this.class_ref != IntPtr.Zero) - JNIEnv.DeleteGlobalRef (this.class_ref); - this.class_ref = IntPtr.Zero; - base.Dispose (disposing); - } - - public IComparableInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) - { - IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); - this.class_ref = JNIEnv.NewGlobalRef (local_ref); - JNIEnv.DeleteLocalRef (local_ref); - } - - static Delegate cb_compareTo_Ljava_lang_Object_; -#pragma warning disable 0169 - static Delegate GetCompareTo_Ljava_lang_Object_Handler () - { - if (cb_compareTo_Ljava_lang_Object_ == null) - cb_compareTo_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_CompareTo_Ljava_lang_Object_); - return cb_compareTo_Ljava_lang_Object_; - } - - static int n_CompareTo_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_another) - { - var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); - var another = global::Java.Lang.Object.GetObject (native_another, JniHandleOwnership.DoNotTransfer); - int __ret = __this.CompareTo (another); - return __ret; - } -#pragma warning restore 0169 - - IntPtr id_compareTo_Ljava_lang_Object_; - public unsafe int CompareTo (global::Java.Lang.Object another) - { - if (id_compareTo_Ljava_lang_Object_ == IntPtr.Zero) - id_compareTo_Ljava_lang_Object_ = JNIEnv.GetMethodID (class_ref, "compareTo", "(Ljava/lang/Object;)I"); - IntPtr native_another = JNIEnv.ToLocalJniHandle (another); - JValue* __args = stackalloc JValue [1]; - __args [0] = new JValue (native_another); - var __ret = JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_compareTo_Ljava_lang_Object_, __args); - JNIEnv.DeleteLocalRef (native_another); - return __ret; - } - - } } diff --git a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.State.cs b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.State.cs index 808dfbbf7..adf0c6bf8 100644 --- a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.State.cs +++ b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.State.cs @@ -1,110 +1,87 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='State']" - [global::Android.Runtime.Register ("java/lang/State", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/State", GenerateJavaPeer=false)] public sealed partial class State : global::Java.Lang.Enum { // Metadata.xml XPath field reference: path="/api/package[@name='java.lang']/class[@name='State']/field[@name='BLOCKED']" - [Register ("BLOCKED")] public static global::Java.Lang.State Blocked { get { const string __id = "BLOCKED.Ljava/lang/State;"; var __v = _members.StaticFields.GetObjectValue (__id); - return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose); } } // Metadata.xml XPath field reference: path="/api/package[@name='java.lang']/class[@name='State']/field[@name='NEW']" - [Register ("NEW")] public static global::Java.Lang.State New { get { const string __id = "NEW.Ljava/lang/State;"; var __v = _members.StaticFields.GetObjectValue (__id); - return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose); } } // Metadata.xml XPath field reference: path="/api/package[@name='java.lang']/class[@name='State']/field[@name='RUNNABLE']" - [Register ("RUNNABLE")] public static global::Java.Lang.State Runnable { get { const string __id = "RUNNABLE.Ljava/lang/State;"; var __v = _members.StaticFields.GetObjectValue (__id); - return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose); } } // Metadata.xml XPath field reference: path="/api/package[@name='java.lang']/class[@name='State']/field[@name='TERMINATED']" - [Register ("TERMINATED")] public static global::Java.Lang.State Terminated { get { const string __id = "TERMINATED.Ljava/lang/State;"; var __v = _members.StaticFields.GetObjectValue (__id); - return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose); } } // Metadata.xml XPath field reference: path="/api/package[@name='java.lang']/class[@name='State']/field[@name='TIMED_WAITING']" - [Register ("TIMED_WAITING")] public static global::Java.Lang.State TimedWaiting { get { const string __id = "TIMED_WAITING.Ljava/lang/State;"; var __v = _members.StaticFields.GetObjectValue (__id); - return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose); } } // Metadata.xml XPath field reference: path="/api/package[@name='java.lang']/class[@name='State']/field[@name='WAITING']" - [Register ("WAITING")] public static global::Java.Lang.State Waiting { get { const string __id = "WAITING.Ljava/lang/State;"; var __v = _members.StaticFields.GetObjectValue (__id); - return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose); } } static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/State", typeof (State)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - internal State (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + internal State (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } diff --git a/tests/generator-Tests/expected.ji/java.lang.Enum/Mono.Android.projitems b/tests/generator-Tests/expected.ji/java.lang.Enum/Mono.Android.projitems index fa2e06041..24a983853 100644 --- a/tests/generator-Tests/expected.ji/java.lang.Enum/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/java.lang.Enum/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/java.lang.Enum/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/java.lang.Enum/__NamespaceMapping__.cs index c2f92bdc5..417caab06 100644 --- a/tests/generator-Tests/expected.ji/java.lang.Enum/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/java.lang.Enum/__NamespaceMapping__.cs @@ -1,5 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] - -delegate int _JniMarshal_PPL_I (IntPtr jnienv, IntPtr klass, IntPtr p0); diff --git a/tests/generator-Tests/expected.ji/java.lang.Object/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/java.lang.Object/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/java.lang.Object/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/java.lang.Object/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/java.lang.Object/Mono.Android.projitems b/tests/generator-Tests/expected.ji/java.lang.Object/Mono.Android.projitems index d140c8de1..2ebaae2b7 100644 --- a/tests/generator-Tests/expected.ji/java.lang.Object/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/java.lang.Object/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/java.lang.Object/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/java.lang.Object/__NamespaceMapping__.cs index 01ebfbe27..417caab06 100644 --- a/tests/generator-Tests/expected.ji/java.lang.Object/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/java.lang.Object/__NamespaceMapping__.cs @@ -1,4 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] - diff --git a/tests/generator-Tests/expected.ji/java.util.List/Java.Lang.Object.cs b/tests/generator-Tests/expected.ji/java.util.List/Java.Lang.Object.cs index 5744963dc..86d0bd17b 100644 --- a/tests/generator-Tests/expected.ji/java.util.List/Java.Lang.Object.cs +++ b/tests/generator-Tests/expected.ji/java.util.List/Java.Lang.Object.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Java.Lang { // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" - [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] public partial class Object { static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); - internal static IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - } } diff --git a/tests/generator-Tests/expected.ji/java.util.List/Mono.Android.projitems b/tests/generator-Tests/expected.ji/java.util.List/Mono.Android.projitems index 066be1dd1..c47692f39 100644 --- a/tests/generator-Tests/expected.ji/java.util.List/Mono.Android.projitems +++ b/tests/generator-Tests/expected.ji/java.util.List/Mono.Android.projitems @@ -5,7 +5,6 @@ - diff --git a/tests/generator-Tests/expected.ji/java.util.List/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.ji/java.util.List/Xamarin.Test.SomeObject.cs index c15782e06..db94fbb40 100644 --- a/tests/generator-Tests/expected.ji/java.util.List/Xamarin.Test.SomeObject.cs +++ b/tests/generator-Tests/expected.ji/java.util.List/Xamarin.Test.SomeObject.cs @@ -1,16 +1,14 @@ using System; using System.Collections.Generic; -using Android.Runtime; using Java.Interop; namespace Xamarin.Test { // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" - [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + [global::Java.Interop.JniTypeSignature ("xamarin/test/SomeObject", GenerateJavaPeer=false)] public partial class SomeObject : global::Java.Lang.Object { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myStrings']" - [Register ("myStrings")] public global::System.Collections.Generic.IList MyStrings { get { const string __id = "myStrings.Ljava/util/List;"; @@ -32,7 +30,6 @@ public partial class SomeObject : global::Java.Lang.Object { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myInts']" - [Register ("myInts")] public global::System.Collections.Generic.IList MyInts { get { const string __id = "myInts.Ljava/util/List;"; @@ -54,7 +51,6 @@ public partial class SomeObject : global::Java.Lang.Object { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='mybools']" - [Register ("mybools")] public global::System.Collections.Generic.IList Mybools { get { const string __id = "mybools.Ljava/util/List;"; @@ -76,7 +72,6 @@ public partial class SomeObject : global::Java.Lang.Object { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myObjects']" - [Register ("myObjects")] public global::System.Collections.Generic.IList MyObjects { get { const string __id = "myObjects.Ljava/util/List;"; @@ -98,7 +93,6 @@ public partial class SomeObject : global::Java.Lang.Object { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myfloats']" - [Register ("myfloats")] public global::System.Collections.Generic.IList Myfloats { get { const string __id = "myfloats.Ljava/util/List;"; @@ -120,7 +114,6 @@ public partial class SomeObject : global::Java.Lang.Object { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='mydoubles']" - [Register ("mydoubles")] public global::System.Collections.Generic.IList Mydoubles { get { const string __id = "mydoubles.Ljava/util/List;"; @@ -142,7 +135,6 @@ public partial class SomeObject : global::Java.Lang.Object { // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='mylongs']" - [Register ("mylongs")] public global::System.Collections.Generic.IList Mylongs { get { const string __id = "mylongs.Ljava/util/List;"; @@ -164,29 +156,13 @@ public partial class SomeObject : global::Java.Lang.Object { static readonly JniPeerMembers _members = new JniPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); - internal static new IntPtr class_ref { - get { return _members.JniPeerType.PeerReference.Handle; } - } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] public override global::Java.Interop.JniPeerMembers JniPeerMembers { get { return _members; } } - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override IntPtr ThresholdClass { - get { return _members.JniPeerType.PeerReference.Handle; } - } - - [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] - [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] - protected override global::System.Type ThresholdType { - get { return _members.ManagedPeerType; } - } - - protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + protected SomeObject (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) { } diff --git a/tests/generator-Tests/expected.ji/java.util.List/__NamespaceMapping__.cs b/tests/generator-Tests/expected.ji/java.util.List/__NamespaceMapping__.cs index acb570f6c..417caab06 100644 --- a/tests/generator-Tests/expected.ji/java.util.List/__NamespaceMapping__.cs +++ b/tests/generator-Tests/expected.ji/java.util.List/__NamespaceMapping__.cs @@ -1,5 +1,2 @@ using System; -[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] -[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] - diff --git a/tests/generator-Tests/expected.ji/Adapters/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/AccessModifiers/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/Adapters/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/AccessModifiers/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/AccessModifiers/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/AccessModifiers/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/AccessModifiers/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/AccessModifiers/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/AccessModifiers/Mono.Android.projitems new file mode 100644 index 000000000..8202bce47 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/AccessModifiers/Mono.Android.projitems @@ -0,0 +1,20 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.BasePublicClass.cs b/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.BasePublicClass.cs new file mode 100644 index 000000000..02797a529 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.BasePublicClass.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='BasePublicClass']" + [global::Android.Runtime.Register ("xamarin/test/BasePublicClass", DoNotGenerateAcw=true)] + public partial class BasePublicClass : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/BasePublicClass", typeof (BasePublicClass)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected BasePublicClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_baseMethod; +#pragma warning disable 0169 + static Delegate GetBaseMethodHandler () + { + if (cb_baseMethod == null) + cb_baseMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_BaseMethod); + return cb_baseMethod; + } + + static void n_BaseMethod (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.BaseMethod (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='BasePublicClass']/method[@name='baseMethod' and count(parameter)=0]" + [Register ("baseMethod", "()V", "GetBaseMethodHandler")] + public virtual unsafe void BaseMethod () + { + const string __id = "baseMethod.()V"; + try { + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.ExtendPublicClass.cs b/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.ExtendPublicClass.cs new file mode 100644 index 000000000..78676aa31 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.ExtendPublicClass.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='ExtendPublicClass']" + [global::Android.Runtime.Register ("xamarin/test/ExtendPublicClass", DoNotGenerateAcw=true)] + public partial class ExtendPublicClass : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/ExtendPublicClass", typeof (ExtendPublicClass)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected ExtendPublicClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='ExtendPublicClass']/constructor[@name='ExtendPublicClass' and count(parameter)=0]" + [Register (".ctor", "()V", "")] + public unsafe ExtendPublicClass () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "()V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + static Delegate cb_foo; +#pragma warning disable 0169 + static Delegate GetFooHandler () + { + if (cb_foo == null) + cb_foo = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Foo); + return cb_foo; + } + + static void n_Foo (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Foo (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='ExtendPublicClass']/method[@name='foo' and count(parameter)=0]" + [Register ("foo", "()V", "GetFooHandler")] + public virtual unsafe void Foo () + { + const string __id = "foo.()V"; + try { + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.IExtendedInterface.cs b/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.IExtendedInterface.cs new file mode 100644 index 000000000..0e2d1348c --- /dev/null +++ b/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.IExtendedInterface.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath interface reference: path="/api/package[@name='xamarin.test']/interface[@name='ExtendedInterface']" + [Register ("xamarin/test/ExtendedInterface", "", "Xamarin.Test.IExtendedInterfaceInvoker")] + public partial interface IExtendedInterface : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='ExtendedInterface']/method[@name='extendedMethod' and count(parameter)=0]" + [Register ("extendedMethod", "()V", "GetExtendedMethodHandler:Xamarin.Test.IExtendedInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + void ExtendedMethod (); + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='BaseInterface']/method[@name='baseMethod' and count(parameter)=0]" + [Register ("baseMethod", "()V", "GetBaseMethodHandler:Xamarin.Test.IExtendedInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + void BaseMethod (); + + } + + [global::Android.Runtime.Register ("xamarin/test/ExtendedInterface", DoNotGenerateAcw=true)] + internal partial class IExtendedInterfaceInvoker : global::Java.Lang.Object, IExtendedInterface { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/ExtendedInterface", typeof (IExtendedInterfaceInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static IExtendedInterface GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.ExtendedInterface'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public IExtendedInterfaceInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_extendedMethod; +#pragma warning disable 0169 + static Delegate GetExtendedMethodHandler () + { + if (cb_extendedMethod == null) + cb_extendedMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_ExtendedMethod); + return cb_extendedMethod; + } + + static void n_ExtendedMethod (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.ExtendedMethod (); + } +#pragma warning restore 0169 + + IntPtr id_extendedMethod; + public unsafe void ExtendedMethod () + { + if (id_extendedMethod == IntPtr.Zero) + id_extendedMethod = JNIEnv.GetMethodID (class_ref, "extendedMethod", "()V"); + JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_extendedMethod); + } + + static Delegate cb_baseMethod; +#pragma warning disable 0169 + static Delegate GetBaseMethodHandler () + { + if (cb_baseMethod == null) + cb_baseMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_BaseMethod); + return cb_baseMethod; + } + + static void n_BaseMethod (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.BaseMethod (); + } +#pragma warning restore 0169 + + IntPtr id_baseMethod; + public unsafe void BaseMethod () + { + if (id_baseMethod == IntPtr.Zero) + id_baseMethod = JNIEnv.GetMethodID (class_ref, "baseMethod", "()V"); + JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_baseMethod); + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.PublicClass.cs b/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.PublicClass.cs new file mode 100644 index 000000000..0cb475b53 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.PublicClass.cs @@ -0,0 +1,174 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='PublicClass']" + [global::Android.Runtime.Register ("xamarin/test/PublicClass", DoNotGenerateAcw=true)] + public partial class PublicClass : global::Java.Lang.Object { + // Metadata.xml XPath interface reference: path="/api/package[@name='xamarin.test']/interface[@name='PublicClass.ProtectedInterface']" + [Register ("xamarin/test/PublicClass$ProtectedInterface", "", "Xamarin.Test.PublicClass/IProtectedInterfaceInvoker")] + protected internal partial interface IProtectedInterface : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='PublicClass.ProtectedInterface']/method[@name='foo' and count(parameter)=0]" + [Register ("foo", "()V", "GetFooHandler:Xamarin.Test.PublicClass/IProtectedInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + void Foo (); + + } + + [global::Android.Runtime.Register ("xamarin/test/PublicClass$ProtectedInterface", DoNotGenerateAcw=true)] + internal partial class IProtectedInterfaceInvoker : global::Java.Lang.Object, IProtectedInterface { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/PublicClass$ProtectedInterface", typeof (IProtectedInterfaceInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static IProtectedInterface GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.PublicClass.ProtectedInterface'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public IProtectedInterfaceInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_foo; +#pragma warning disable 0169 + static Delegate GetFooHandler () + { + if (cb_foo == null) + cb_foo = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Foo); + return cb_foo; + } + + static void n_Foo (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Foo (); + } +#pragma warning restore 0169 + + IntPtr id_foo; + public unsafe void Foo () + { + if (id_foo == IntPtr.Zero) + id_foo = JNIEnv.GetMethodID (class_ref, "foo", "()V"); + JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_foo); + } + + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/PublicClass", typeof (PublicClass)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected PublicClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='PublicClass']/constructor[@name='PublicClass' and count(parameter)=0]" + [Register (".ctor", "()V", "")] + public unsafe PublicClass () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "()V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + static Delegate cb_foo; +#pragma warning disable 0169 + static Delegate GetFooHandler () + { + if (cb_foo == null) + cb_foo = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Foo); + return cb_foo; + } + + static void n_Foo (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Foo (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='PublicClass']/method[@name='foo' and count(parameter)=0]" + [Register ("foo", "()V", "GetFooHandler")] + public virtual unsafe void Foo () + { + const string __id = "foo.()V"; + try { + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.PublicFinalClass.cs b/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.PublicFinalClass.cs new file mode 100644 index 000000000..06ede7658 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.PublicFinalClass.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='PublicFinalClass']" + [global::Android.Runtime.Register ("xamarin/test/PublicFinalClass", DoNotGenerateAcw=true)] + public sealed partial class PublicFinalClass : global::Xamarin.Test.BasePublicClass { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/PublicFinalClass", typeof (PublicFinalClass)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + internal PublicFinalClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='PublicFinalClass']/method[@name='publicMethod' and count(parameter)=0]" + [Register ("publicMethod", "()V", "")] + public unsafe void PublicMethod () + { + const string __id = "publicMethod.()V"; + try { + _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, null); + } finally { + } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='PackageClassB']/method[@name='packageMethodB' and count(parameter)=0]" + [Register ("packageMethodB", "()V", "")] + public unsafe void PackageMethodB () + { + const string __id = "packageMethodB.()V"; + try { + _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, null); + } finally { + } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='PackageClassA']/method[@name='packageMethodA' and count(parameter)=0]" + [Register ("packageMethodA", "()V", "")] + public unsafe void PackageMethodA () + { + const string __id = "packageMethodA.()V"; + try { + _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, null); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.TestClass.cs b/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.TestClass.cs new file mode 100644 index 000000000..785548cac --- /dev/null +++ b/tests/generator-Tests/expected.xaji/AccessModifiers/Xamarin.Test.TestClass.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='TestClass']" + [global::Android.Runtime.Register ("xamarin/test/TestClass", DoNotGenerateAcw=true)] + public partial class TestClass : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/TestClass", typeof (TestClass)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected TestClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='TestClass']/constructor[@name='TestClass' and count(parameter)=0]" + [Register (".ctor", "()V", "")] + public unsafe TestClass () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "()V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + static Delegate cb_baseMethod; +#pragma warning disable 0169 + static Delegate GetBaseMethodHandler () + { + if (cb_baseMethod == null) + cb_baseMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_BaseMethod); + return cb_baseMethod; + } + + static void n_BaseMethod (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.BaseMethod (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='TestClass']/method[@name='baseMethod' and count(parameter)=0]" + [Register ("baseMethod", "()V", "GetBaseMethodHandler")] + public virtual unsafe void BaseMethod () + { + const string __id = "baseMethod.()V"; + try { + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/AccessModifiers/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/AccessModifiers/__NamespaceMapping__.cs new file mode 100644 index 000000000..4c11e5976 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/AccessModifiers/__NamespaceMapping__.cs @@ -0,0 +1,16 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +delegate void _JniMarshal_PP_V (IntPtr jnienv, IntPtr klass); +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/AccessModifiers/enumlist b/tests/generator-Tests/expected.xaji/AccessModifiers/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/Android.Graphics.Color/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/Adapters/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/Android.Graphics.Color/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/Adapters/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/Adapters/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/Adapters/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Adapters/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Adapters/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/Adapters/Mono.Android.projitems new file mode 100644 index 000000000..4e6987503 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Adapters/Mono.Android.projitems @@ -0,0 +1,19 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.AbsSpinner.cs b/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.AbsSpinner.cs new file mode 100644 index 000000000..74b8e2a21 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.AbsSpinner.cs @@ -0,0 +1,147 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='AbsSpinner']" + [global::Android.Runtime.Register ("xamarin/test/AbsSpinner", DoNotGenerateAcw=true)] + public abstract partial class AbsSpinner : Xamarin.Test.AdapterView { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/AbsSpinner", typeof (AbsSpinner)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected AbsSpinner (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_getAdapter; +#pragma warning disable 0169 + static Delegate GetGetAdapterHandler () + { + if (cb_getAdapter == null) + cb_getAdapter = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetAdapter); + return cb_getAdapter; + } + + static IntPtr n_GetAdapter (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.ToLocalJniHandle (__this.Adapter); + } +#pragma warning restore 0169 + + static Delegate cb_setAdapter_Lxamarin_test_SpinnerAdapter_; +#pragma warning disable 0169 + static Delegate GetSetAdapter_Lxamarin_test_SpinnerAdapter_Handler () + { + if (cb_setAdapter_Lxamarin_test_SpinnerAdapter_ == null) + cb_setAdapter_Lxamarin_test_SpinnerAdapter_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetAdapter_Lxamarin_test_SpinnerAdapter_); + return cb_setAdapter_Lxamarin_test_SpinnerAdapter_; + } + + static void n_SetAdapter_Lxamarin_test_SpinnerAdapter_ (IntPtr jnienv, IntPtr native__this, IntPtr native_adapter) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var adapter = (global::Xamarin.Test.ISpinnerAdapter)global::Java.Lang.Object.GetObject (native_adapter, JniHandleOwnership.DoNotTransfer); + __this.Adapter = adapter; + } +#pragma warning restore 0169 + + public override unsafe global::Xamarin.Test.ISpinnerAdapter Adapter { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AbsSpinner']/method[@name='getAdapter' and count(parameter)=0]" + [Register ("getAdapter", "()Lxamarin/test/SpinnerAdapter;", "GetGetAdapterHandler")] + get { + const string __id = "getAdapter.()Lxamarin/test/SpinnerAdapter;"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); + return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AbsSpinner']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='xamarin.test.SpinnerAdapter']]" + [Register ("setAdapter", "(Lxamarin/test/SpinnerAdapter;)V", "GetSetAdapter_Lxamarin_test_SpinnerAdapter_Handler")] + set { + const string __id = "setAdapter.(Lxamarin/test/SpinnerAdapter;)V"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue ((value == null) ? IntPtr.Zero : ((global::Java.Lang.Object) value).Handle); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + global::System.GC.KeepAlive (value); + } + } + } + + } + + [global::Android.Runtime.Register ("xamarin/test/AbsSpinner", DoNotGenerateAcw=true)] + internal partial class AbsSpinnerInvoker : AbsSpinner { + public AbsSpinnerInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + { + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/AbsSpinner", typeof (AbsSpinnerInvoker)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected override unsafe global::Java.Lang.Object RawAdapter { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='getAdapter' and count(parameter)=0]" + [Register ("getAdapter", "()Lxamarin/test/Adapter;", "GetGetAdapterHandler")] + get { + const string __id = "getAdapter.()Lxamarin/test/Adapter;"; + try { + var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null); + return (global::Java.Lang.Object) global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='T']]" + [Register ("setAdapter", "(Lxamarin/test/Adapter;)V", "GetSetAdapter_Lxamarin_test_Adapter_Handler")] + set { + const string __id = "setAdapter.(Lxamarin/test/Adapter;)V"; + IntPtr native_value = JNIEnv.ToLocalJniHandle (value); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_value); + _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args); + } finally { + JNIEnv.DeleteLocalRef (native_value); + global::System.GC.KeepAlive (value); + } + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.AdapterView.cs b/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.AdapterView.cs new file mode 100644 index 000000000..ab52bf131 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.AdapterView.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']" + [global::Android.Runtime.Register ("xamarin/test/AdapterView", DoNotGenerateAcw=true)] + [global::Java.Interop.JavaTypeParameters (new string [] {"T extends xamarin.test.Adapter"})] + public abstract partial class AdapterView : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/AdapterView", typeof (AdapterView)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected AdapterView (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_getAdapter; +#pragma warning disable 0169 + static Delegate GetGetAdapterHandler () + { + if (cb_getAdapter == null) + cb_getAdapter = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetAdapter); + return cb_getAdapter; + } + + static IntPtr n_GetAdapter (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.ToLocalJniHandle (__this.RawAdapter); + } +#pragma warning restore 0169 + + static Delegate cb_setAdapter_Lxamarin_test_Adapter_; +#pragma warning disable 0169 + static Delegate GetSetAdapter_Lxamarin_test_Adapter_Handler () + { + if (cb_setAdapter_Lxamarin_test_Adapter_ == null) + cb_setAdapter_Lxamarin_test_Adapter_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetAdapter_Lxamarin_test_Adapter_); + return cb_setAdapter_Lxamarin_test_Adapter_; + } + + static void n_SetAdapter_Lxamarin_test_Adapter_ (IntPtr jnienv, IntPtr native__this, IntPtr native_adapter) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var adapter = global::Java.Lang.Object.GetObject (native_adapter, JniHandleOwnership.DoNotTransfer); + __this.RawAdapter = adapter; + } +#pragma warning restore 0169 + + protected abstract global::Java.Lang.Object RawAdapter { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='getAdapter' and count(parameter)=0]" + [Register ("getAdapter", "()Lxamarin/test/Adapter;", "GetGetAdapterHandler")] + get; + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='T']]" + [Register ("setAdapter", "(Lxamarin/test/Adapter;)V", "GetSetAdapter_Lxamarin_test_Adapter_Handler")] + set; + } + + } + + [global::Android.Runtime.Register ("xamarin/test/AdapterView", DoNotGenerateAcw=true)] + internal partial class AdapterViewInvoker : AdapterView { + public AdapterViewInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + { + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/AdapterView", typeof (AdapterViewInvoker)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected override unsafe global::Java.Lang.Object RawAdapter { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='getAdapter' and count(parameter)=0]" + [Register ("getAdapter", "()Lxamarin/test/Adapter;", "GetGetAdapterHandler")] + get { + const string __id = "getAdapter.()Lxamarin/test/Adapter;"; + try { + var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null); + return (global::Java.Lang.Object) global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='T']]" + [Register ("setAdapter", "(Lxamarin/test/Adapter;)V", "GetSetAdapter_Lxamarin_test_Adapter_Handler")] + set { + const string __id = "setAdapter.(Lxamarin/test/Adapter;)V"; + IntPtr native_value = JNIEnv.ToLocalJniHandle (value); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_value); + _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args); + } finally { + JNIEnv.DeleteLocalRef (native_value); + global::System.GC.KeepAlive (value); + } + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.GenericReturnObject.cs b/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.GenericReturnObject.cs new file mode 100644 index 000000000..626acaca3 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.GenericReturnObject.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='GenericReturnObject']" + [global::Android.Runtime.Register ("xamarin/test/GenericReturnObject", DoNotGenerateAcw=true)] + public partial class GenericReturnObject : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/GenericReturnObject", typeof (GenericReturnObject)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected GenericReturnObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_GenericReturn; +#pragma warning disable 0169 + static Delegate GetGenericReturnHandler () + { + if (cb_GenericReturn == null) + cb_GenericReturn = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GenericReturn); + return cb_GenericReturn; + } + + static IntPtr n_GenericReturn (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.ToLocalJniHandle (__this.GenericReturn ()); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='GenericReturnObject']/method[@name='GenericReturn' and count(parameter)=0]" + [Register ("GenericReturn", "()Lxamarin/test/AdapterView;", "GetGenericReturnHandler")] + public virtual unsafe global::Xamarin.Test.AdapterView GenericReturn () + { + const string __id = "GenericReturn.()Lxamarin/test/AdapterView;"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); + return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.IAdapter.cs b/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.IAdapter.cs new file mode 100644 index 000000000..2ce5da34f --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.IAdapter.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath interface reference: path="/api/package[@name='xamarin.test']/interface[@name='Adapter']" + [Register ("xamarin/test/Adapter", "", "Xamarin.Test.IAdapterInvoker")] + public partial interface IAdapter : IJavaObject, IJavaPeerable { + } + + [global::Android.Runtime.Register ("xamarin/test/Adapter", DoNotGenerateAcw=true)] + internal partial class IAdapterInvoker : global::Java.Lang.Object, IAdapter { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/Adapter", typeof (IAdapterInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static IAdapter GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.Adapter'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public IAdapterInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.ISpinnerAdapter.cs b/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.ISpinnerAdapter.cs new file mode 100644 index 000000000..0615fa4f4 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Adapters/Xamarin.Test.ISpinnerAdapter.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath interface reference: path="/api/package[@name='xamarin.test']/interface[@name='SpinnerAdapter']" + [Register ("xamarin/test/SpinnerAdapter", "", "Xamarin.Test.ISpinnerAdapterInvoker")] + public partial interface ISpinnerAdapter : global::Xamarin.Test.IAdapter { + } + + [global::Android.Runtime.Register ("xamarin/test/SpinnerAdapter", DoNotGenerateAcw=true)] + internal partial class ISpinnerAdapterInvoker : global::Java.Lang.Object, ISpinnerAdapter { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SpinnerAdapter", typeof (ISpinnerAdapterInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static ISpinnerAdapter GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.SpinnerAdapter'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public ISpinnerAdapterInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Adapters/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/Adapters/__NamespaceMapping__.cs new file mode 100644 index 000000000..e270a7de4 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Adapters/__NamespaceMapping__.cs @@ -0,0 +1,17 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +delegate IntPtr _JniMarshal_PP_L (IntPtr jnienv, IntPtr klass); +delegate void _JniMarshal_PPL_V (IntPtr jnienv, IntPtr klass, IntPtr p0); +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/Adapters/enumlist b/tests/generator-Tests/expected.xaji/Adapters/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/Arrays/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/Android.Graphics.Color/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/Arrays/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/Android.Graphics.Color/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/Android.Graphics.Color/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/Android.Graphics.Color/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Android.Graphics.Color/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Android.Graphics.Color/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/Android.Graphics.Color/Mono.Android.projitems new file mode 100644 index 000000000..066be1dd1 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Android.Graphics.Color/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/Android.Graphics.Color/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.xaji/Android.Graphics.Color/Xamarin.Test.SomeObject.cs new file mode 100644 index 000000000..9d7e469ce --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Android.Graphics.Color/Xamarin.Test.SomeObject.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" + [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + public abstract partial class SomeObject : global::Java.Lang.Object { + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='backColor']" + [Register ("backColor")] + public global::Android.Graphics.Color BackColor { + get { + const string __id = "backColor.I"; + + var __v = _members.InstanceFields.GetInt32Value (__id, this); + return new global::Android.Graphics.Color (__v); + } + set { + const string __id = "backColor.I"; + + try { + _members.InstanceFields.SetValue (__id, this, value.ToArgb ()); + } finally { + } + } + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_getSomeColor; +#pragma warning disable 0169 + static Delegate GetGetSomeColorHandler () + { + if (cb_getSomeColor == null) + cb_getSomeColor = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_GetSomeColor); + return cb_getSomeColor; + } + + static int n_GetSomeColor (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return __this.SomeColor.ToArgb (); + } +#pragma warning restore 0169 + + static Delegate cb_setSomeColor_I; +#pragma warning disable 0169 + static Delegate GetSetSomeColor_IHandler () + { + if (cb_setSomeColor_I == null) + cb_setSomeColor_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_SetSomeColor_I); + return cb_setSomeColor_I; + } + + static void n_SetSomeColor_I (IntPtr jnienv, IntPtr native__this, int native_newvalue) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var newvalue = new global::Android.Graphics.Color (native_newvalue); + __this.SomeColor = newvalue; + } +#pragma warning restore 0169 + + public abstract global::Android.Graphics.Color SomeColor { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeColor' and count(parameter)=0]" + [Register ("getSomeColor", "()I", "GetGetSomeColorHandler")] + get; + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeColor' and count(parameter)=1 and parameter[1][@type='Android.Graphics.Color']]" + [Register ("setSomeColor", "(I)V", "GetSetSomeColor_IHandler")] + set; + } + + } + + [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + internal partial class SomeObjectInvoker : SomeObject { + public SomeObjectInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + { + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject", typeof (SomeObjectInvoker)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + public override unsafe global::Android.Graphics.Color SomeColor { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeColor' and count(parameter)=0]" + [Register ("getSomeColor", "()I", "GetGetSomeColorHandler")] + get { + const string __id = "getSomeColor.()I"; + try { + var __rm = _members.InstanceMethods.InvokeAbstractInt32Method (__id, this, null); + return new global::Android.Graphics.Color (__rm); + } finally { + } + } + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeColor' and count(parameter)=1 and parameter[1][@type='Android.Graphics.Color']]" + [Register ("setSomeColor", "(I)V", "GetSetSomeColor_IHandler")] + set { + const string __id = "setSomeColor.(I)V"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (value.ToArgb ()); + _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args); + } finally { + } + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Android.Graphics.Color/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/Android.Graphics.Color/__NamespaceMapping__.cs new file mode 100644 index 000000000..ab541b01c --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Android.Graphics.Color/__NamespaceMapping__.cs @@ -0,0 +1,17 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +delegate int _JniMarshal_PP_I (IntPtr jnienv, IntPtr klass); +delegate void _JniMarshal_PPI_V (IntPtr jnienv, IntPtr klass, int p0); +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/Android.Graphics.Color/enumlist b/tests/generator-Tests/expected.xaji/Android.Graphics.Color/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/Constructors/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/Arrays/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/Constructors/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/Arrays/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/Arrays/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/Arrays/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Arrays/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Arrays/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/Arrays/Mono.Android.projitems new file mode 100644 index 000000000..066be1dd1 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Arrays/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/Arrays/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.xaji/Arrays/Xamarin.Test.SomeObject.cs new file mode 100644 index 000000000..9c21297f5 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Arrays/Xamarin.Test.SomeObject.cs @@ -0,0 +1,194 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" + [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + public partial class SomeObject : global::Java.Lang.Object { + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myStrings']" + [Register ("myStrings")] + public IList MyStrings { + get { + const string __id = "myStrings.[Ljava/lang/String;"; + + var __v = _members.InstanceFields.GetObjectValue (__id, this); + return global::Android.Runtime.JavaArray.FromJniHandle (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + set { + const string __id = "myStrings.[Ljava/lang/String;"; + + IntPtr native_value = global::Android.Runtime.JavaArray.ToLocalJniHandle (value); + try { + _members.InstanceFields.SetValue (__id, this, new JniObjectReference (native_value)); + } finally { + global::Android.Runtime.JNIEnv.DeleteLocalRef (native_value); + } + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myInts']" + [Register ("myInts")] + public IList MyInts { + get { + const string __id = "myInts.[I"; + + var __v = _members.InstanceFields.GetObjectValue (__id, this); + return global::Android.Runtime.JavaArray.FromJniHandle (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + set { + const string __id = "myInts.[I"; + + IntPtr native_value = global::Android.Runtime.JavaArray.ToLocalJniHandle (value); + try { + _members.InstanceFields.SetValue (__id, this, new JniObjectReference (native_value)); + } finally { + global::Android.Runtime.JNIEnv.DeleteLocalRef (native_value); + } + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='mybools']" + [Register ("mybools")] + public IList Mybools { + get { + const string __id = "mybools.[Z"; + + var __v = _members.InstanceFields.GetObjectValue (__id, this); + return global::Android.Runtime.JavaArray.FromJniHandle (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + set { + const string __id = "mybools.[Z"; + + IntPtr native_value = global::Android.Runtime.JavaArray.ToLocalJniHandle (value); + try { + _members.InstanceFields.SetValue (__id, this, new JniObjectReference (native_value)); + } finally { + global::Android.Runtime.JNIEnv.DeleteLocalRef (native_value); + } + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myObjects']" + [Register ("myObjects")] + public IList MyObjects { + get { + const string __id = "myObjects.[Ljava/lang/Object;"; + + var __v = _members.InstanceFields.GetObjectValue (__id, this); + return global::Android.Runtime.JavaArray.FromJniHandle (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + set { + const string __id = "myObjects.[Ljava/lang/Object;"; + + IntPtr native_value = global::Android.Runtime.JavaArray.ToLocalJniHandle (value); + try { + _members.InstanceFields.SetValue (__id, this, new JniObjectReference (native_value)); + } finally { + global::Android.Runtime.JNIEnv.DeleteLocalRef (native_value); + } + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myfloats']" + [Register ("myfloats")] + public IList Myfloats { + get { + const string __id = "myfloats.[F"; + + var __v = _members.InstanceFields.GetObjectValue (__id, this); + return global::Android.Runtime.JavaArray.FromJniHandle (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + set { + const string __id = "myfloats.[F"; + + IntPtr native_value = global::Android.Runtime.JavaArray.ToLocalJniHandle (value); + try { + _members.InstanceFields.SetValue (__id, this, new JniObjectReference (native_value)); + } finally { + global::Android.Runtime.JNIEnv.DeleteLocalRef (native_value); + } + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='mydoubles']" + [Register ("mydoubles")] + public IList Mydoubles { + get { + const string __id = "mydoubles.[D"; + + var __v = _members.InstanceFields.GetObjectValue (__id, this); + return global::Android.Runtime.JavaArray.FromJniHandle (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + set { + const string __id = "mydoubles.[D"; + + IntPtr native_value = global::Android.Runtime.JavaArray.ToLocalJniHandle (value); + try { + _members.InstanceFields.SetValue (__id, this, new JniObjectReference (native_value)); + } finally { + global::Android.Runtime.JNIEnv.DeleteLocalRef (native_value); + } + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='mylongs']" + [Register ("mylongs")] + public IList Mylongs { + get { + const string __id = "mylongs.[J"; + + var __v = _members.InstanceFields.GetObjectValue (__id, this); + return global::Android.Runtime.JavaArray.FromJniHandle (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + set { + const string __id = "mylongs.[J"; + + IntPtr native_value = global::Android.Runtime.JavaArray.ToLocalJniHandle (value); + try { + _members.InstanceFields.SetValue (__id, this, new JniObjectReference (native_value)); + } finally { + global::Android.Runtime.JNIEnv.DeleteLocalRef (native_value); + } + } + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Arrays/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/Arrays/__NamespaceMapping__.cs new file mode 100644 index 000000000..e9b0e4292 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Arrays/__NamespaceMapping__.cs @@ -0,0 +1,15 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/Arrays/enumlist b/tests/generator-Tests/expected.xaji/Arrays/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.xaji/CSharpKeywords/CSharpKeywords.xml b/tests/generator-Tests/expected.xaji/CSharpKeywords/CSharpKeywords.xml new file mode 100644 index 000000000..52d6f43cd --- /dev/null +++ b/tests/generator-Tests/expected.xaji/CSharpKeywords/CSharpKeywords.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/CSharpKeywords/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/CSharpKeywords/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/CSharpKeywords/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/CSharpKeywords/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/CSharpKeywords/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/CSharpKeywords/Java.Lang.Throwable.cs b/tests/generator-Tests/expected.xaji/CSharpKeywords/Java.Lang.Throwable.cs new file mode 100644 index 000000000..5687244ed --- /dev/null +++ b/tests/generator-Tests/expected.xaji/CSharpKeywords/Java.Lang.Throwable.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Throwable']" + [global::Android.Runtime.Register ("java/lang/Throwable", DoNotGenerateAcw=true)] + public partial class Throwable { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Throwable", typeof (Throwable)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + static Delegate cb_getMessage; +#pragma warning disable 0169 + static Delegate GetGetMessageHandler () + { + if (cb_getMessage == null) + cb_getMessage = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetMessage); + return cb_getMessage; + } + + static IntPtr n_GetMessage (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.NewString (__this.Message); + } +#pragma warning restore 0169 + + public new virtual unsafe string Message { + // Metadata.xml XPath method reference: path="/api/package[@name='java.lang']/class[@name='Throwable']/method[@name='getMessage' and count(parameter)=0]" + [Register ("getMessage", "()Ljava/lang/String;", "GetGetMessageHandler")] + get { + const string __id = "getMessage.()Ljava/lang/String;"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); + return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/CSharpKeywords/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/CSharpKeywords/Mono.Android.projitems new file mode 100644 index 000000000..1e80d027f --- /dev/null +++ b/tests/generator-Tests/expected.xaji/CSharpKeywords/Mono.Android.projitems @@ -0,0 +1,16 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/CSharpKeywords/Xamarin.Test.CSharpKeywords.cs b/tests/generator-Tests/expected.xaji/CSharpKeywords/Xamarin.Test.CSharpKeywords.cs new file mode 100644 index 000000000..0a041285c --- /dev/null +++ b/tests/generator-Tests/expected.xaji/CSharpKeywords/Xamarin.Test.CSharpKeywords.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='CSharpKeywords']" + [global::Android.Runtime.Register ("xamarin/test/CSharpKeywords", DoNotGenerateAcw=true)] + public partial class CSharpKeywords : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/CSharpKeywords", typeof (CSharpKeywords)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected CSharpKeywords (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_usePartial_I; +#pragma warning disable 0169 + static Delegate GetUsePartial_IHandler () + { + if (cb_usePartial_I == null) + cb_usePartial_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_L) n_UsePartial_I); + return cb_usePartial_I; + } + + static IntPtr n_UsePartial_I (IntPtr jnienv, IntPtr native__this, int partial) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.NewString (__this.UsePartial (partial)); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='CSharpKeywords']/method[@name='usePartial' and count(parameter)=1 and parameter[1][@type='int']]" + [Register ("usePartial", "(I)Ljava/lang/String;", "GetUsePartial_IHandler")] + public virtual unsafe string UsePartial (int partial) + { + const string __id = "usePartial.(I)Ljava/lang/String;"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (partial); + var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, __args); + return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='CSharpKeywords']/method[@name='useThis' and count(parameter)=1 and parameter[1][@type='java.lang.String']]" + [Register ("useThis", "(Ljava/lang/String;)Ljava/lang/String;", "")] + public static unsafe string UseThis (string this_) + { + const string __id = "useThis.(Ljava/lang/String;)Ljava/lang/String;"; + IntPtr native_this = JNIEnv.NewString (this_); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_this); + var __rm = _members.StaticMethods.InvokeObjectMethod (__id, __args); + return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + JNIEnv.DeleteLocalRef (native_this); + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/CSharpKeywords/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/CSharpKeywords/__NamespaceMapping__.cs new file mode 100644 index 000000000..db411e906 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/CSharpKeywords/__NamespaceMapping__.cs @@ -0,0 +1,17 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +delegate IntPtr _JniMarshal_PP_L (IntPtr jnienv, IntPtr klass); +delegate IntPtr _JniMarshal_PPI_L (IntPtr jnienv, IntPtr klass, int p0); +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/CSharpKeywords/enumlist b/tests/generator-Tests/expected.xaji/CSharpKeywords/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/NestedTypes/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/Constructors/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/NestedTypes/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/Constructors/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/Constructors/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/Constructors/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Constructors/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Constructors/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/Constructors/Mono.Android.projitems new file mode 100644 index 000000000..82192a590 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Constructors/Mono.Android.projitems @@ -0,0 +1,16 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/Constructors/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.xaji/Constructors/Xamarin.Test.SomeObject.cs new file mode 100644 index 000000000..96dc34d6a --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Constructors/Xamarin.Test.SomeObject.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" + [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + public partial class SomeObject : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/constructor[@name='SomeObject' and count(parameter)=0]" + [Register (".ctor", "()V", "")] + [Obsolete (@"deprecated")] + public unsafe SomeObject () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "()V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/constructor[@name='SomeObject' and count(parameter)=1 and parameter[1][@type='int']]" + [Register (".ctor", "(I)V", "")] + public unsafe SomeObject (int aint) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "(I)V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (aint); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, __args); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Constructors/Xamarin.Test.SomeObject2.cs b/tests/generator-Tests/expected.xaji/Constructors/Xamarin.Test.SomeObject2.cs new file mode 100644 index 000000000..9ea19a6a7 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Constructors/Xamarin.Test.SomeObject2.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject2']" + [global::Android.Runtime.Register ("xamarin/test/SomeObject2", DoNotGenerateAcw=true)] + public sealed partial class SomeObject2 : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject2", typeof (SomeObject2)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + internal SomeObject2 (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject2']/constructor[@name='SomeObject2' and count(parameter)=1 and parameter[1][@type='int']]" + [Register (".ctor", "(I)V", "")] + public unsafe SomeObject2 (int aint) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "(I)V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (aint); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, __args); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Constructors/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/Constructors/__NamespaceMapping__.cs new file mode 100644 index 000000000..e9b0e4292 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Constructors/__NamespaceMapping__.cs @@ -0,0 +1,15 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/Constructors/enumlist b/tests/generator-Tests/expected.xaji/Constructors/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.xaji/Core_ClassParse/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/Core_ClassParse/Java.Interop.__TypeRegistrations.cs new file mode 100644 index 000000000..05fa69b48 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_ClassParse/Java.Interop.__TypeRegistrations.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; + +namespace Java.Interop { + + partial class __TypeRegistrations { + + public static void RegisterPackages () + { +#if MONODROID_TIMING + var start = DateTime.Now; + Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages start: " + (start - new DateTime (1970, 1, 1)).TotalMilliseconds); +#endif // def MONODROID_TIMING + Java.Interop.TypeManager.RegisterPackages ( + new string[]{ + "xamarin/test/invalidnames", + }, + new Converter[]{ + lookup_xamarin_test_invalidnames_package, + }); +#if MONODROID_TIMING + var end = DateTime.Now; + Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages time: " + (end - new DateTime (1970, 1, 1)).TotalMilliseconds + " [elapsed: " + (end - start).TotalMilliseconds + " ms]"); +#endif // def MONODROID_TIMING + } + +#if NET5_0_OR_GREATER + [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage ("Trimming", "IL2057")] +#endif + static Type Lookup (string[] mappings, string javaType) + { + var managedType = Java.Interop.TypeManager.LookupTypeMapping (mappings, javaType); + if (managedType == null) + return null; + return Type.GetType (managedType); + } + + static string[] package_xamarin_test_invalidnames_mappings; + static Type lookup_xamarin_test_invalidnames_package (string klass) + { + if (package_xamarin_test_invalidnames_mappings == null) { + package_xamarin_test_invalidnames_mappings = new string[]{ + "xamarin/test/invalidnames/in:Xamarin.Test.Invalidnames.In", + }; + } + + return Lookup (package_xamarin_test_invalidnames_mappings, klass); + } + } +} diff --git a/tests/generator-Tests/expected.xaji/Core_ClassParse/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/Core_ClassParse/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_ClassParse/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Core_ClassParse/Java.Lang.String.cs b/tests/generator-Tests/expected.xaji/Core_ClassParse/Java.Lang.String.cs new file mode 100644 index 000000000..b5d48abc0 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_ClassParse/Java.Lang.String.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='String']" + [global::Android.Runtime.Register ("java/lang/String", DoNotGenerateAcw=true)] + public partial class String : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/String", typeof (String)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected String (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Core_ClassParse/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/Core_ClassParse/Mono.Android.projitems new file mode 100644 index 000000000..c6fa7bb59 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_ClassParse/Mono.Android.projitems @@ -0,0 +1,17 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/Core_ClassParse/Xamarin.Test.Invalidnames.In.cs b/tests/generator-Tests/expected.xaji/Core_ClassParse/Xamarin.Test.Invalidnames.In.cs new file mode 100644 index 000000000..2a8a6da05 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_ClassParse/Xamarin.Test.Invalidnames.In.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test.Invalidnames { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test.invalidnames']/class[@name='in']" + [global::Android.Runtime.Register ("xamarin/test/invalidnames/in", DoNotGenerateAcw=true)] + public partial class In : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/invalidnames/in", typeof (In)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected In (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Core_ClassParse/Xamarin.Test.Invalidnames.InvalidNameMembers.cs b/tests/generator-Tests/expected.xaji/Core_ClassParse/Xamarin.Test.Invalidnames.InvalidNameMembers.cs new file mode 100644 index 000000000..a46055f83 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_ClassParse/Xamarin.Test.Invalidnames.InvalidNameMembers.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test.Invalidnames { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test.invalidnames']/class[@name='InvalidNameMembers']" + [global::Android.Runtime.Register ("xamarin/test/invalidnames/InvalidNameMembers", DoNotGenerateAcw=true)] + public partial class InvalidNameMembers : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/invalidnames/InvalidNameMembers", typeof (InvalidNameMembers)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected InvalidNameMembers (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Core_ClassParse/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/Core_ClassParse/__NamespaceMapping__.cs new file mode 100644 index 000000000..966d718be --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_ClassParse/__NamespaceMapping__.cs @@ -0,0 +1,15 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test.invalidnames", Managed="Xamarin.Test.Invalidnames")] + +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/Core_ClassParse/enumlist b/tests/generator-Tests/expected.xaji/Core_ClassParse/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Text.ISpannable.cs b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Text.ISpannable.cs new file mode 100644 index 000000000..34f08bee7 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Text.ISpannable.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Android.Text { + + // Metadata.xml XPath interface reference: path="/api/package[@name='android.text']/interface[@name='Spannable']" + [Register ("android/text/Spannable", "", "Android.Text.ISpannableInvoker")] + public partial interface ISpannable : global::Android.Text.ISpanned { + } + + [global::Android.Runtime.Register ("android/text/Spannable", DoNotGenerateAcw=true)] + internal partial class ISpannableInvoker : global::Java.Lang.Object, ISpannable { + static readonly JniPeerMembers _members = new XAPeerMembers ("android/text/Spannable", typeof (ISpannableInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static ISpannable GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'android.text.Spannable'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public ISpannableInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_getSpanFlags_Ljava_lang_Object_; +#pragma warning disable 0169 + static Delegate GetGetSpanFlags_Ljava_lang_Object_Handler () + { + if (cb_getSpanFlags_Ljava_lang_Object_ == null) + cb_getSpanFlags_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetSpanFlags_Ljava_lang_Object_); + return cb_getSpanFlags_Ljava_lang_Object_; + } + + static int n_GetSpanFlags_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_tag) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var tag = global::Java.Lang.Object.GetObject (native_tag, JniHandleOwnership.DoNotTransfer); + int __ret = (int) __this.GetSpanFlags (tag); + return __ret; + } +#pragma warning restore 0169 + + IntPtr id_getSpanFlags_Ljava_lang_Object_; + public unsafe global::Android.Text.SpanTypes GetSpanFlags (global::Java.Lang.Object tag) + { + if (id_getSpanFlags_Ljava_lang_Object_ == IntPtr.Zero) + id_getSpanFlags_Ljava_lang_Object_ = JNIEnv.GetMethodID (class_ref, "getSpanFlags", "(Ljava/lang/Object;)I"); + JValue* __args = stackalloc JValue [1]; + __args [0] = new JValue ((tag == null) ? IntPtr.Zero : ((global::Java.Lang.Object) tag).Handle); + var __ret = (global::Android.Text.SpanTypes) JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_getSpanFlags_Ljava_lang_Object_, __args); + return __ret; + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Text.ISpanned.cs b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Text.ISpanned.cs new file mode 100644 index 000000000..ab995f700 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Text.ISpanned.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Android.Text { + + // Metadata.xml XPath interface reference: path="/api/package[@name='android.text']/interface[@name='Spanned']" + [Register ("android/text/Spanned", "", "Android.Text.ISpannedInvoker")] + public partial interface ISpanned : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='android.text']/interface[@name='Spanned']/method[@name='getSpanFlags' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" + [return:global::Android.Runtime.GeneratedEnum] + [Register ("getSpanFlags", "(Ljava/lang/Object;)I", "GetGetSpanFlags_Ljava_lang_Object_Handler:Android.Text.ISpannedInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + global::Android.Text.SpanTypes GetSpanFlags (global::Java.Lang.Object tag); + + } + + [global::Android.Runtime.Register ("android/text/Spanned", DoNotGenerateAcw=true)] + internal partial class ISpannedInvoker : global::Java.Lang.Object, ISpanned { + static readonly JniPeerMembers _members = new XAPeerMembers ("android/text/Spanned", typeof (ISpannedInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static ISpanned GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'android.text.Spanned'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public ISpannedInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_getSpanFlags_Ljava_lang_Object_; +#pragma warning disable 0169 + static Delegate GetGetSpanFlags_Ljava_lang_Object_Handler () + { + if (cb_getSpanFlags_Ljava_lang_Object_ == null) + cb_getSpanFlags_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetSpanFlags_Ljava_lang_Object_); + return cb_getSpanFlags_Ljava_lang_Object_; + } + + static int n_GetSpanFlags_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_tag) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var tag = global::Java.Lang.Object.GetObject (native_tag, JniHandleOwnership.DoNotTransfer); + int __ret = (int) __this.GetSpanFlags (tag); + return __ret; + } +#pragma warning restore 0169 + + IntPtr id_getSpanFlags_Ljava_lang_Object_; + public unsafe global::Android.Text.SpanTypes GetSpanFlags (global::Java.Lang.Object tag) + { + if (id_getSpanFlags_Ljava_lang_Object_ == IntPtr.Zero) + id_getSpanFlags_Ljava_lang_Object_ = JNIEnv.GetMethodID (class_ref, "getSpanFlags", "(Ljava/lang/Object;)I"); + JValue* __args = stackalloc JValue [1]; + __args [0] = new JValue ((tag == null) ? IntPtr.Zero : ((global::Java.Lang.Object) tag).Handle); + var __ret = (global::Android.Text.SpanTypes) JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_getSpanFlags_Ljava_lang_Object_, __args); + return __ret; + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Text.SpannableString.cs b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Text.SpannableString.cs new file mode 100644 index 000000000..a32c65a19 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Text.SpannableString.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Android.Text { + + // Metadata.xml XPath class reference: path="/api/package[@name='android.text']/class[@name='SpannableString']" + [global::Android.Runtime.Register ("android/text/SpannableString", DoNotGenerateAcw=true)] + public partial class SpannableString : global::Android.Text.SpannableStringInternal, global::Android.Text.ISpannable { + static readonly JniPeerMembers _members = new XAPeerMembers ("android/text/SpannableString", typeof (SpannableString)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected SpannableString (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='android.text']/class[@name='SpannableString']/constructor[@name='SpannableString' and count(parameter)=1 and parameter[1][@type='java.lang.CharSequence']]" + [Register (".ctor", "(Ljava/lang/CharSequence;)V", "")] + public unsafe SpannableString (global::Java.Lang.ICharSequence source) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "(Ljava/lang/CharSequence;)V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + IntPtr native_source = CharSequence.ToLocalJniHandle (source); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_source); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, __args); + } finally { + JNIEnv.DeleteLocalRef (native_source); + global::System.GC.KeepAlive (source); + } + } + + [Register (".ctor", "(Ljava/lang/CharSequence;)V", "")] + public unsafe SpannableString (string source) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "(Ljava/lang/CharSequence;)V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + IntPtr native_source = CharSequence.ToLocalJniHandle (source); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_source); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, __args); + } finally { + JNIEnv.DeleteLocalRef (native_source); + global::System.GC.KeepAlive (source); + } + } + + static Delegate cb_getSpanFlags_Ljava_lang_Object_; +#pragma warning disable 0169 + static Delegate GetGetSpanFlags_Ljava_lang_Object_Handler () + { + if (cb_getSpanFlags_Ljava_lang_Object_ == null) + cb_getSpanFlags_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetSpanFlags_Ljava_lang_Object_); + return cb_getSpanFlags_Ljava_lang_Object_; + } + + static int n_GetSpanFlags_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_what) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var what = global::Java.Lang.Object.GetObject (native_what, JniHandleOwnership.DoNotTransfer); + int __ret = (int) __this.GetSpanFlags (what); + return __ret; + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='android.text']/class[@name='SpannableString']/method[@name='getSpanFlags' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" + [Register ("getSpanFlags", "(Ljava/lang/Object;)I", "GetGetSpanFlags_Ljava_lang_Object_Handler")] + public override unsafe global::Android.Text.SpanTypes GetSpanFlags (global::Java.Lang.Object what) + { + const string __id = "getSpanFlags.(Ljava/lang/Object;)I"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue ((what == null) ? IntPtr.Zero : ((global::Java.Lang.Object) what).Handle); + var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, __args); + return (global::Android.Text.SpanTypes) __rm; + } finally { + global::System.GC.KeepAlive (what); + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Text.SpannableStringInternal.cs b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Text.SpannableStringInternal.cs new file mode 100644 index 000000000..734d765f5 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Text.SpannableStringInternal.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Android.Text { + + // Metadata.xml XPath class reference: path="/api/package[@name='android.text']/class[@name='SpannableStringInternal']" + [global::Android.Runtime.Register ("android/text/SpannableStringInternal", DoNotGenerateAcw=true)] + public abstract partial class SpannableStringInternal : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("android/text/SpannableStringInternal", typeof (SpannableStringInternal)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected SpannableStringInternal (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_getSpanFlags_Ljava_lang_Object_; +#pragma warning disable 0169 + static Delegate GetGetSpanFlags_Ljava_lang_Object_Handler () + { + if (cb_getSpanFlags_Ljava_lang_Object_ == null) + cb_getSpanFlags_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetSpanFlags_Ljava_lang_Object_); + return cb_getSpanFlags_Ljava_lang_Object_; + } + + static int n_GetSpanFlags_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_p0) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var p0 = global::Java.Lang.Object.GetObject (native_p0, JniHandleOwnership.DoNotTransfer); + int __ret = (int) __this.GetSpanFlags (p0); + return __ret; + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='android.text']/class[@name='SpannableStringInternal']/method[@name='getSpanFlags' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" + [return:global::Android.Runtime.GeneratedEnum] + [Register ("getSpanFlags", "(Ljava/lang/Object;)I", "GetGetSpanFlags_Ljava_lang_Object_Handler")] + public virtual unsafe global::Android.Text.SpanTypes GetSpanFlags (global::Java.Lang.Object p0) + { + const string __id = "getSpanFlags.(Ljava/lang/Object;)I"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue ((p0 == null) ? IntPtr.Zero : ((global::Java.Lang.Object) p0).Handle); + var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, __args); + return (global::Android.Text.SpanTypes) __rm; + } finally { + global::System.GC.KeepAlive (p0); + } + } + + } + + [global::Android.Runtime.Register ("android/text/SpannableStringInternal", DoNotGenerateAcw=true)] + internal partial class SpannableStringInternalInvoker : SpannableStringInternal { + public SpannableStringInternalInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + { + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("android/text/SpannableStringInternal", typeof (SpannableStringInternalInvoker)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Views.View.cs b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Views.View.cs new file mode 100644 index 000000000..85d34b24a --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Android.Views.View.cs @@ -0,0 +1,281 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Android.Views { + + // Metadata.xml XPath class reference: path="/api/package[@name='android.view']/class[@name='View']" + [global::Android.Runtime.Register ("android/view/View", DoNotGenerateAcw=true)] + public partial class View : global::Java.Lang.Object { + // Metadata.xml XPath interface reference: path="/api/package[@name='android.view']/interface[@name='View.OnClickListener']" + [Register ("android/view/View$OnClickListener", "", "Android.Views.View/IOnClickListenerInvoker")] + public partial interface IOnClickListener : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='android.view']/interface[@name='View.OnClickListener']/method[@name='onClick' and count(parameter)=1 and parameter[1][@type='android.view.View']]" + [Register ("onClick", "(Landroid/view/View;)V", "GetOnClick_Landroid_view_View_Handler:Android.Views.View/IOnClickListenerInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + void OnClick (global::Android.Views.View v); + + } + + [global::Android.Runtime.Register ("android/view/View$OnClickListener", DoNotGenerateAcw=true)] + internal partial class IOnClickListenerInvoker : global::Java.Lang.Object, IOnClickListener { + static readonly JniPeerMembers _members = new XAPeerMembers ("android/view/View$OnClickListener", typeof (IOnClickListenerInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static IOnClickListener GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'android.view.View.OnClickListener'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public IOnClickListenerInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_onClick_Landroid_view_View_; +#pragma warning disable 0169 + static Delegate GetOnClick_Landroid_view_View_Handler () + { + if (cb_onClick_Landroid_view_View_ == null) + cb_onClick_Landroid_view_View_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_OnClick_Landroid_view_View_); + return cb_onClick_Landroid_view_View_; + } + + static void n_OnClick_Landroid_view_View_ (IntPtr jnienv, IntPtr native__this, IntPtr native_v) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var v = global::Java.Lang.Object.GetObject (native_v, JniHandleOwnership.DoNotTransfer); + __this.OnClick (v); + } +#pragma warning restore 0169 + + IntPtr id_onClick_Landroid_view_View_; + public unsafe void OnClick (global::Android.Views.View v) + { + if (id_onClick_Landroid_view_View_ == IntPtr.Zero) + id_onClick_Landroid_view_View_ = JNIEnv.GetMethodID (class_ref, "onClick", "(Landroid/view/View;)V"); + JValue* __args = stackalloc JValue [1]; + __args [0] = new JValue ((v == null) ? IntPtr.Zero : ((global::Java.Lang.Object) v).Handle); + JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_onClick_Landroid_view_View_, __args); + } + + } + + [global::Android.Runtime.Register ("mono/android/view/View_OnClickListenerImplementor")] + internal sealed partial class IOnClickListenerImplementor : global::Java.Lang.Object, IOnClickListener { + public IOnClickListenerImplementor () : base (global::Android.Runtime.JNIEnv.StartCreateInstance ("mono/android/view/View_OnClickListenerImplementor", "()V"), JniHandleOwnership.TransferLocalRef) + { + global::Android.Runtime.JNIEnv.FinishCreateInstance (((global::Java.Lang.Object) this).Handle, "()V"); + } + + #pragma warning disable 0649 + public EventHandler Handler; + #pragma warning restore 0649 + + public void OnClick (global::Android.Views.View v) + { + var __h = Handler; + if (__h != null) + __h (v, new EventArgs ()); + } + + internal static bool __IsEmpty (IOnClickListenerImplementor value) + { + return value.Handler == null; + } + + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("android/view/View", typeof (View)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected View (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_setOnClickListener_Landroid_view_View_OnClickListener_; +#pragma warning disable 0169 + static Delegate GetSetOnClickListener_Landroid_view_View_OnClickListener_Handler () + { + if (cb_setOnClickListener_Landroid_view_View_OnClickListener_ == null) + cb_setOnClickListener_Landroid_view_View_OnClickListener_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetOnClickListener_Landroid_view_View_OnClickListener_); + return cb_setOnClickListener_Landroid_view_View_OnClickListener_; + } + + static void n_SetOnClickListener_Landroid_view_View_OnClickListener_ (IntPtr jnienv, IntPtr native__this, IntPtr native_l) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var l = (global::Android.Views.View.IOnClickListener)global::Java.Lang.Object.GetObject (native_l, JniHandleOwnership.DoNotTransfer); + __this.SetOnClickListener (l); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='android.view']/class[@name='View']/method[@name='setOnClickListener' and count(parameter)=1 and parameter[1][@type='android.view.View.OnClickListener']]" + [Register ("setOnClickListener", "(Landroid/view/View$OnClickListener;)V", "GetSetOnClickListener_Landroid_view_View_OnClickListener_Handler")] + public virtual unsafe void SetOnClickListener (global::Android.Views.View.IOnClickListener l) + { + const string __id = "setOnClickListener.(Landroid/view/View$OnClickListener;)V"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue ((l == null) ? IntPtr.Zero : ((global::Java.Lang.Object) l).Handle); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + global::System.GC.KeepAlive (l); + } + } + + static Delegate cb_setOn123Listener_Landroid_view_View_OnClickListener_; +#pragma warning disable 0169 + static Delegate GetSetOn123Listener_Landroid_view_View_OnClickListener_Handler () + { + if (cb_setOn123Listener_Landroid_view_View_OnClickListener_ == null) + cb_setOn123Listener_Landroid_view_View_OnClickListener_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetOn123Listener_Landroid_view_View_OnClickListener_); + return cb_setOn123Listener_Landroid_view_View_OnClickListener_; + } + + static void n_SetOn123Listener_Landroid_view_View_OnClickListener_ (IntPtr jnienv, IntPtr native__this, IntPtr native_l) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var l = (global::Android.Views.View.IOnClickListener)global::Java.Lang.Object.GetObject (native_l, JniHandleOwnership.DoNotTransfer); + __this.SetOn123Listener (l); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='android.view']/class[@name='View']/method[@name='setOn123Listener' and count(parameter)=1 and parameter[1][@type='android.view.View.OnClickListener']]" + [Register ("setOn123Listener", "(Landroid/view/View$OnClickListener;)V", "GetSetOn123Listener_Landroid_view_View_OnClickListener_Handler")] + public virtual unsafe void SetOn123Listener (global::Android.Views.View.IOnClickListener l) + { + const string __id = "setOn123Listener.(Landroid/view/View$OnClickListener;)V"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue ((l == null) ? IntPtr.Zero : ((global::Java.Lang.Object) l).Handle); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + global::System.GC.KeepAlive (l); + } + } + + static Delegate cb_addTouchables_Ljava_util_ArrayList_; +#pragma warning disable 0169 + static Delegate GetAddTouchables_Ljava_util_ArrayList_Handler () + { + if (cb_addTouchables_Ljava_util_ArrayList_ == null) + cb_addTouchables_Ljava_util_ArrayList_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_AddTouchables_Ljava_util_ArrayList_); + return cb_addTouchables_Ljava_util_ArrayList_; + } + + static void n_AddTouchables_Ljava_util_ArrayList_ (IntPtr jnienv, IntPtr native__this, IntPtr native_views) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var views = global::Android.Runtime.JavaList.FromJniHandle (native_views, JniHandleOwnership.DoNotTransfer); + __this.AddTouchables (views); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='android.view']/class[@name='View']/method[@name='addTouchables' and count(parameter)=1 and parameter[1][@type='java.util.ArrayList<android.view.View>']]" + [Register ("addTouchables", "(Ljava/util/ArrayList;)V", "GetAddTouchables_Ljava_util_ArrayList_Handler")] + public virtual unsafe void AddTouchables (global::System.Collections.Generic.IList views) + { + const string __id = "addTouchables.(Ljava/util/ArrayList;)V"; + IntPtr native_views = global::Android.Runtime.JavaList.ToLocalJniHandle (views); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_views); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + JNIEnv.DeleteLocalRef (native_views); + global::System.GC.KeepAlive (views); + } + } + + #region "Event implementation for Android.Views.View.IOnClickListener" + + public event EventHandler Click { + add { + global::Java.Interop.EventHelper.AddEventHandler( + ref weak_implementor_SetOnClickListener, + __CreateIOnClickListenerImplementor, + SetOnClickListener, + __h => __h.Handler += value); + } + remove { + global::Java.Interop.EventHelper.RemoveEventHandler( + ref weak_implementor_SetOnClickListener, + global::Android.Views.View.IOnClickListenerImplementor.__IsEmpty, + __v => SetOnClickListener (null), + __h => __h.Handler -= value); + } + } + + WeakReference weak_implementor_SetOnClickListener; + + global::Android.Views.View.IOnClickListenerImplementor __CreateIOnClickListenerImplementor () + { + return new global::Android.Views.View.IOnClickListenerImplementor (); + } + + #endregion + + } +} diff --git a/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Java.Interop.__TypeRegistrations.cs new file mode 100644 index 000000000..9c635c687 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Java.Interop.__TypeRegistrations.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; + +namespace Java.Interop { + + partial class __TypeRegistrations { + + public static void RegisterPackages () + { +#if MONODROID_TIMING + var start = DateTime.Now; + Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages start: " + (start - new DateTime (1970, 1, 1)).TotalMilliseconds); +#endif // def MONODROID_TIMING + Java.Interop.TypeManager.RegisterPackages ( + new string[]{ + "android/view", + }, + new Converter[]{ + lookup_android_view_package, + }); +#if MONODROID_TIMING + var end = DateTime.Now; + Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages time: " + (end - new DateTime (1970, 1, 1)).TotalMilliseconds + " [elapsed: " + (end - start).TotalMilliseconds + " ms]"); +#endif // def MONODROID_TIMING + } + +#if NET5_0_OR_GREATER + [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage ("Trimming", "IL2057")] +#endif + static Type Lookup (string[] mappings, string javaType) + { + var managedType = Java.Interop.TypeManager.LookupTypeMapping (mappings, javaType); + if (managedType == null) + return null; + return Type.GetType (managedType); + } + + static string[] package_android_view_mappings; + static Type lookup_android_view_package (string klass) + { + if (package_android_view_mappings == null) { + package_android_view_mappings = new string[]{ + "android/view/View:Android.Views.View", + }; + } + + return Lookup (package_android_view_mappings, klass); + } + } +} diff --git a/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Mono.Android.projitems new file mode 100644 index 000000000..0b239b193 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/Mono.Android.projitems @@ -0,0 +1,21 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/Core_Jar2Xml/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/__NamespaceMapping__.cs new file mode 100644 index 000000000..10bb4305e --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/__NamespaceMapping__.cs @@ -0,0 +1,18 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "android.view", Managed="Android.Views")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "android.text", Managed="Android.Text")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] + +delegate int _JniMarshal_PPL_I (IntPtr jnienv, IntPtr klass, IntPtr p0); +delegate void _JniMarshal_PPL_V (IntPtr jnienv, IntPtr klass, IntPtr p0); +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/Core_Jar2Xml/enumlist b/tests/generator-Tests/expected.xaji/Core_Jar2Xml/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.xaji/GenericArguments/Com.Google.Android.Exoplayer.Drm.FrameworkMediaCrypto.cs b/tests/generator-Tests/expected.xaji/GenericArguments/Com.Google.Android.Exoplayer.Drm.FrameworkMediaCrypto.cs new file mode 100644 index 000000000..9c849b559 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/GenericArguments/Com.Google.Android.Exoplayer.Drm.FrameworkMediaCrypto.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Com.Google.Android.Exoplayer.Drm { + + // Metadata.xml XPath class reference: path="/api/package[@name='com.google.android.exoplayer.drm']/class[@name='FrameworkMediaCrypto']" + [global::Android.Runtime.Register ("com/google/android/exoplayer/drm/FrameworkMediaCrypto", DoNotGenerateAcw=true)] + public sealed partial class FrameworkMediaCrypto : global::Java.Lang.Object, global::Com.Google.Android.Exoplayer.Drm.IExoMediaCrypto { + static readonly JniPeerMembers _members = new XAPeerMembers ("com/google/android/exoplayer/drm/FrameworkMediaCrypto", typeof (FrameworkMediaCrypto)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + internal FrameworkMediaCrypto (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='com.google.android.exoplayer.drm']/class[@name='FrameworkMediaCrypto']/constructor[@name='FrameworkMediaCrypto' and count(parameter)=0]" + [Register (".ctor", "()V", "")] + public unsafe FrameworkMediaCrypto () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "()V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='com.google.android.exoplayer.drm']/class[@name='FrameworkMediaCrypto']/method[@name='requiresSecureDecoderComponent' and count(parameter)=1 and parameter[1][@type='java.lang.String']]" + [Register ("requiresSecureDecoderComponent", "(Ljava/lang/String;)Z", "")] + public unsafe bool RequiresSecureDecoderComponent (string p0) + { + const string __id = "requiresSecureDecoderComponent.(Ljava/lang/String;)Z"; + IntPtr native_p0 = JNIEnv.NewString (p0); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_p0); + var __rm = _members.InstanceMethods.InvokeAbstractBooleanMethod (__id, this, __args); + return __rm; + } finally { + JNIEnv.DeleteLocalRef (native_p0); + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/GenericArguments/Com.Google.Android.Exoplayer.Drm.FrameworkMediaDrm.cs b/tests/generator-Tests/expected.xaji/GenericArguments/Com.Google.Android.Exoplayer.Drm.FrameworkMediaDrm.cs new file mode 100644 index 000000000..db4f1a2e1 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/GenericArguments/Com.Google.Android.Exoplayer.Drm.FrameworkMediaDrm.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Com.Google.Android.Exoplayer.Drm { + + // Metadata.xml XPath class reference: path="/api/package[@name='com.google.android.exoplayer.drm']/class[@name='FrameworkMediaDrm']" + [global::Android.Runtime.Register ("com/google/android/exoplayer/drm/FrameworkMediaDrm", DoNotGenerateAcw=true)] + public sealed partial class FrameworkMediaDrm : global::Java.Lang.Object, global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm { + static readonly JniPeerMembers _members = new XAPeerMembers ("com/google/android/exoplayer/drm/FrameworkMediaDrm", typeof (FrameworkMediaDrm)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + internal FrameworkMediaDrm (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='com.google.android.exoplayer.drm']/class[@name='FrameworkMediaDrm']/constructor[@name='FrameworkMediaDrm' and count(parameter)=0]" + [Register (".ctor", "()V", "")] + public unsafe FrameworkMediaDrm () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "()V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='com.google.android.exoplayer.drm']/class[@name='FrameworkMediaDrm']/method[@name='setOnEventListener' and count(parameter)=1 and parameter[1][@type='com.google.android.exoplayer.drm.ExoMediaDrm.OnEventListener<com.google.android.exoplayer.drm.FrameworkMediaCrypto>']]" + [Register ("setOnEventListener", "(Lcom/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener;)V", "")] + public unsafe void SetOnEventListener (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrmOnEventListener p0) + { + const string __id = "setOnEventListener.(Lcom/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener;)V"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue ((p0 == null) ? IntPtr.Zero : ((global::Java.Lang.Object) p0).Handle); + _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args); + } finally { + global::System.GC.KeepAlive (p0); + } + } + + // This method is explicitly implemented as a member of an instantiated Com.Google.Android.Exoplayer.Drm.IExoMediaDrm + void global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.SetOnEventListener (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrmOnEventListener p0) + { + SetOnEventListener (global::Java.Interop.JavaObjectExtensions.JavaCast(p0)); + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaCrypto.cs b/tests/generator-Tests/expected.xaji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaCrypto.cs new file mode 100644 index 000000000..c861cc6da --- /dev/null +++ b/tests/generator-Tests/expected.xaji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaCrypto.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Com.Google.Android.Exoplayer.Drm { + + // Metadata.xml XPath interface reference: path="/api/package[@name='com.google.android.exoplayer.drm']/interface[@name='ExoMediaCrypto']" + [Register ("com/google/android/exoplayer/drm/ExoMediaCrypto", "", "Com.Google.Android.Exoplayer.Drm.IExoMediaCryptoInvoker")] + public partial interface IExoMediaCrypto : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='com.google.android.exoplayer.drm']/interface[@name='ExoMediaCrypto']/method[@name='requiresSecureDecoderComponent' and count(parameter)=1 and parameter[1][@type='java.lang.String']]" + [Register ("requiresSecureDecoderComponent", "(Ljava/lang/String;)Z", "GetRequiresSecureDecoderComponent_Ljava_lang_String_Handler:Com.Google.Android.Exoplayer.Drm.IExoMediaCryptoInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + bool RequiresSecureDecoderComponent (string p0); + + } + + [global::Android.Runtime.Register ("com/google/android/exoplayer/drm/ExoMediaCrypto", DoNotGenerateAcw=true)] + internal partial class IExoMediaCryptoInvoker : global::Java.Lang.Object, IExoMediaCrypto { + static readonly JniPeerMembers _members = new XAPeerMembers ("com/google/android/exoplayer/drm/ExoMediaCrypto", typeof (IExoMediaCryptoInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static IExoMediaCrypto GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.google.android.exoplayer.drm.ExoMediaCrypto'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public IExoMediaCryptoInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_requiresSecureDecoderComponent_Ljava_lang_String_; +#pragma warning disable 0169 + static Delegate GetRequiresSecureDecoderComponent_Ljava_lang_String_Handler () + { + if (cb_requiresSecureDecoderComponent_Ljava_lang_String_ == null) + cb_requiresSecureDecoderComponent_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_Z) n_RequiresSecureDecoderComponent_Ljava_lang_String_); + return cb_requiresSecureDecoderComponent_Ljava_lang_String_; + } + + static bool n_RequiresSecureDecoderComponent_Ljava_lang_String_ (IntPtr jnienv, IntPtr native__this, IntPtr native_p0) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var p0 = JNIEnv.GetString (native_p0, JniHandleOwnership.DoNotTransfer); + bool __ret = __this.RequiresSecureDecoderComponent (p0); + return __ret; + } +#pragma warning restore 0169 + + IntPtr id_requiresSecureDecoderComponent_Ljava_lang_String_; + public unsafe bool RequiresSecureDecoderComponent (string p0) + { + if (id_requiresSecureDecoderComponent_Ljava_lang_String_ == IntPtr.Zero) + id_requiresSecureDecoderComponent_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "requiresSecureDecoderComponent", "(Ljava/lang/String;)Z"); + IntPtr native_p0 = JNIEnv.NewString (p0); + JValue* __args = stackalloc JValue [1]; + __args [0] = new JValue (native_p0); + var __ret = JNIEnv.CallBooleanMethod (((global::Java.Lang.Object) this).Handle, id_requiresSecureDecoderComponent_Ljava_lang_String_, __args); + JNIEnv.DeleteLocalRef (native_p0); + return __ret; + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs b/tests/generator-Tests/expected.xaji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs new file mode 100644 index 000000000..ed95935a8 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs @@ -0,0 +1,287 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Com.Google.Android.Exoplayer.Drm { + + // Metadata.xml XPath interface reference: path="/api/package[@name='com.google.android.exoplayer.drm']/interface[@name='ExoMediaDrm.OnEventListener']" + [Register ("com/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener", "", "Com.Google.Android.Exoplayer.Drm.IExoMediaDrmOnEventListenerInvoker")] + [global::Java.Interop.JavaTypeParameters (new string [] {"T extends com.google.android.exoplayer.drm.ExoMediaCrypto"})] + public partial interface IExoMediaDrmOnEventListener : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='com.google.android.exoplayer.drm']/interface[@name='ExoMediaDrm.OnEventListener']/method[@name='onEvent' and count(parameter)=5 and parameter[1][@type='com.google.android.exoplayer.drm.ExoMediaDrm<T>'] and parameter[2][@type='byte[]'] and parameter[3][@type='int'] and parameter[4][@type='int'] and parameter[5][@type='byte[]']]" + [Register ("onEvent", "(Lcom/google/android/exoplayer/drm/ExoMediaDrm;[BII[B)V", "GetOnEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayBHandler:Com.Google.Android.Exoplayer.Drm.IExoMediaDrmOnEventListenerInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + void OnEvent (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm p0, byte[] p1, int p2, int p3, byte[] p4); + + } + + [global::Android.Runtime.Register ("com/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener", DoNotGenerateAcw=true)] + internal partial class IExoMediaDrmOnEventListenerInvoker : global::Java.Lang.Object, IExoMediaDrmOnEventListener { + static readonly JniPeerMembers _members = new XAPeerMembers ("com/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener", typeof (IExoMediaDrmOnEventListenerInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static IExoMediaDrmOnEventListener GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.google.android.exoplayer.drm.ExoMediaDrm.OnEventListener'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public IExoMediaDrmOnEventListenerInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB; +#pragma warning disable 0169 + static Delegate GetOnEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayBHandler () + { + if (cb_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB == null) + cb_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPLLIIL_V) n_OnEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB); + return cb_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB; + } + + static void n_OnEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB (IntPtr jnienv, IntPtr native__this, IntPtr native_p0, IntPtr native_p1, int p2, int p3, IntPtr native_p4) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var p0 = (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm)global::Java.Lang.Object.GetObject (native_p0, JniHandleOwnership.DoNotTransfer); + var p1 = (byte[]) JNIEnv.GetArray (native_p1, JniHandleOwnership.DoNotTransfer, typeof (byte)); + var p4 = (byte[]) JNIEnv.GetArray (native_p4, JniHandleOwnership.DoNotTransfer, typeof (byte)); + __this.OnEvent (p0, p1, p2, p3, p4); + if (p1 != null) + JNIEnv.CopyArray (p1, native_p1); + if (p4 != null) + JNIEnv.CopyArray (p4, native_p4); + } +#pragma warning restore 0169 + + IntPtr id_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB; + public unsafe void OnEvent (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm p0, byte[] p1, int p2, int p3, byte[] p4) + { + if (id_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB == IntPtr.Zero) + id_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB = JNIEnv.GetMethodID (class_ref, "onEvent", "(Lcom/google/android/exoplayer/drm/ExoMediaDrm;[BII[B)V"); + IntPtr native_p1 = JNIEnv.NewArray (p1); + IntPtr native_p4 = JNIEnv.NewArray (p4); + JValue* __args = stackalloc JValue [5]; + __args [0] = new JValue ((p0 == null) ? IntPtr.Zero : ((global::Java.Lang.Object) p0).Handle); + __args [1] = new JValue (native_p1); + __args [2] = new JValue (p2); + __args [3] = new JValue (p3); + __args [4] = new JValue (native_p4); + JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_onEvent_Lcom_google_android_exoplayer_drm_ExoMediaDrm_arrayBIIarrayB, __args); + if (p1 != null) { + JNIEnv.CopyArray (native_p1, p1); + JNIEnv.DeleteLocalRef (native_p1); + } + if (p4 != null) { + JNIEnv.CopyArray (native_p4, p4); + JNIEnv.DeleteLocalRef (native_p4); + } + } + + } + + // event args for com.google.android.exoplayer.drm.ExoMediaDrm.OnEventListener.onEvent + public partial class ExoMediaDrmOnEventEventArgs : global::System.EventArgs { + public ExoMediaDrmOnEventEventArgs (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm p0, byte[] p1, int p2, int p3, byte[] p4) + { + this.p0 = p0; + this.p1 = p1; + this.p2 = p2; + this.p3 = p3; + this.p4 = p4; + } + + global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm p0; + + public global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm P0 { + get { return p0; } + } + + byte[] p1; + + public byte[] P1 { + get { return p1; } + } + + int p2; + + public int P2 { + get { return p2; } + } + + int p3; + + public int P3 { + get { return p3; } + } + + byte[] p4; + + public byte[] P4 { + get { return p4; } + } + + } + + [global::Android.Runtime.Register ("mono/com/google/android/exoplayer/drm/ExoMediaDrm_OnEventListenerImplementor")] + internal sealed partial class IExoMediaDrmOnEventListenerImplementor : global::Java.Lang.Object, IExoMediaDrmOnEventListener { + + object sender; + + public IExoMediaDrmOnEventListenerImplementor (object sender) : base (global::Android.Runtime.JNIEnv.StartCreateInstance ("mono/com/google/android/exoplayer/drm/ExoMediaDrm_OnEventListenerImplementor", "()V"), JniHandleOwnership.TransferLocalRef) + { + global::Android.Runtime.JNIEnv.FinishCreateInstance (((global::Java.Lang.Object) this).Handle, "()V"); + this.sender = sender; + } + + #pragma warning disable 0649 + public EventHandler Handler; + #pragma warning restore 0649 + + public void OnEvent (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrm p0, byte[] p1, int p2, int p3, byte[] p4) + { + var __h = Handler; + if (__h != null) + __h (sender, new ExoMediaDrmOnEventEventArgs (p0, p1, p2, p3, p4)); + } + + internal static bool __IsEmpty (IExoMediaDrmOnEventListenerImplementor value) + { + return value.Handler == null; + } + + } + + // Metadata.xml XPath interface reference: path="/api/package[@name='com.google.android.exoplayer.drm']/interface[@name='ExoMediaDrm']" + [Register ("com/google/android/exoplayer/drm/ExoMediaDrm", "", "Com.Google.Android.Exoplayer.Drm.IExoMediaDrmInvoker")] + [global::Java.Interop.JavaTypeParameters (new string [] {"T extends com.google.android.exoplayer.drm.ExoMediaCrypto"})] + public partial interface IExoMediaDrm : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='com.google.android.exoplayer.drm']/interface[@name='ExoMediaDrm']/method[@name='setOnEventListener' and count(parameter)=1 and parameter[1][@type='com.google.android.exoplayer.drm.ExoMediaDrm.OnEventListener<T>']]" + [Register ("setOnEventListener", "(Lcom/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener;)V", "GetSetOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_Handler:Com.Google.Android.Exoplayer.Drm.IExoMediaDrmInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + void SetOnEventListener (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrmOnEventListener p0); + + } + + [global::Android.Runtime.Register ("com/google/android/exoplayer/drm/ExoMediaDrm", DoNotGenerateAcw=true)] + internal partial class IExoMediaDrmInvoker : global::Java.Lang.Object, IExoMediaDrm { + static readonly JniPeerMembers _members = new XAPeerMembers ("com/google/android/exoplayer/drm/ExoMediaDrm", typeof (IExoMediaDrmInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static IExoMediaDrm GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.google.android.exoplayer.drm.ExoMediaDrm'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public IExoMediaDrmInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_; +#pragma warning disable 0169 + static Delegate GetSetOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_Handler () + { + if (cb_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_ == null) + cb_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_); + return cb_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_; + } + + static void n_SetOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_ (IntPtr jnienv, IntPtr native__this, IntPtr native_p0) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var p0 = (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrmOnEventListener)global::Java.Lang.Object.GetObject (native_p0, JniHandleOwnership.DoNotTransfer); + __this.SetOnEventListener (p0); + } +#pragma warning restore 0169 + + IntPtr id_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_; + public unsafe void SetOnEventListener (global::Com.Google.Android.Exoplayer.Drm.IExoMediaDrmOnEventListener p0) + { + if (id_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_ == IntPtr.Zero) + id_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_ = JNIEnv.GetMethodID (class_ref, "setOnEventListener", "(Lcom/google/android/exoplayer/drm/ExoMediaDrm$OnEventListener;)V"); + JValue* __args = stackalloc JValue [1]; + __args [0] = new JValue ((p0 == null) ? IntPtr.Zero : ((global::Java.Lang.Object) p0).Handle); + JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_setOnEventListener_Lcom_google_android_exoplayer_drm_ExoMediaDrm_OnEventListener_, __args); + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/GenericArguments/GenericArguments.xml b/tests/generator-Tests/expected.xaji/GenericArguments/GenericArguments.xml new file mode 100644 index 000000000..f9387a080 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/GenericArguments/GenericArguments.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.ji/NonStaticFields/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/GenericArguments/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/NonStaticFields/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/GenericArguments/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/GenericArguments/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/GenericArguments/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/GenericArguments/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/GenericArguments/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/GenericArguments/Mono.Android.projitems new file mode 100644 index 000000000..ce2c2b1c9 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/GenericArguments/Mono.Android.projitems @@ -0,0 +1,18 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/GenericArguments/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/GenericArguments/__NamespaceMapping__.cs new file mode 100644 index 000000000..34146efa8 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/GenericArguments/__NamespaceMapping__.cs @@ -0,0 +1,18 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "com.google.android.exoplayer.drm", Managed="Com.Google.Android.Exoplayer.Drm")] + +delegate void _JniMarshal_PPL_V (IntPtr jnienv, IntPtr klass, IntPtr p0); +delegate bool _JniMarshal_PPL_Z (IntPtr jnienv, IntPtr klass, IntPtr p0); +delegate void _JniMarshal_PPLLIIL_V (IntPtr jnienv, IntPtr klass, IntPtr p0, IntPtr p1, int p2, int p3, IntPtr p4); +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/GenericArguments/enumlist b/tests/generator-Tests/expected.xaji/GenericArguments/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/InterfaceMethodsConflict.xml b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/InterfaceMethodsConflict.xml new file mode 100644 index 000000000..703f91b24 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/InterfaceMethodsConflict.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/generator-Tests/expected.ji/NormalMethods/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/NormalMethods/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Mono.Android.projitems new file mode 100644 index 000000000..03c426cd6 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Mono.Android.projitems @@ -0,0 +1,18 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Xamarin.Test.II1.cs b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Xamarin.Test.II1.cs new file mode 100644 index 000000000..634e2dedd --- /dev/null +++ b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Xamarin.Test.II1.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath interface reference: path="/api/package[@name='xamarin.test']/interface[@name='I1']" + [Register ("xamarin/test/I1", "", "Xamarin.Test.II1Invoker")] + public partial interface II1 : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='I1']/method[@name='close' and count(parameter)=0]" + [Register ("close", "()V", "GetCloseHandler:Xamarin.Test.II1Invoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + void Close (); + + } + + [global::Android.Runtime.Register ("xamarin/test/I1", DoNotGenerateAcw=true)] + internal partial class II1Invoker : global::Java.Lang.Object, II1 { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/I1", typeof (II1Invoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static II1 GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.I1'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public II1Invoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_close; +#pragma warning disable 0169 + static Delegate GetCloseHandler () + { + if (cb_close == null) + cb_close = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Close); + return cb_close; + } + + static void n_Close (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Close (); + } +#pragma warning restore 0169 + + IntPtr id_close; + public unsafe void Close () + { + if (id_close == IntPtr.Zero) + id_close = JNIEnv.GetMethodID (class_ref, "close", "()V"); + JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_close); + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Xamarin.Test.II2.cs b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Xamarin.Test.II2.cs new file mode 100644 index 000000000..1e200b19a --- /dev/null +++ b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Xamarin.Test.II2.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath interface reference: path="/api/package[@name='xamarin.test']/interface[@name='I2']" + [Register ("xamarin/test/I2", "", "Xamarin.Test.II2Invoker")] + public partial interface II2 : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='I2']/method[@name='close' and count(parameter)=0]" + [Register ("close", "()V", "GetCloseHandler:Xamarin.Test.II2Invoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + void Close (); + + } + + [global::Android.Runtime.Register ("xamarin/test/I2", DoNotGenerateAcw=true)] + internal partial class II2Invoker : global::Java.Lang.Object, II2 { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/I2", typeof (II2Invoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static II2 GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.I2'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public II2Invoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_close; +#pragma warning disable 0169 + static Delegate GetCloseHandler () + { + if (cb_close == null) + cb_close = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Close); + return cb_close; + } + + static void n_Close (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Close (); + } +#pragma warning restore 0169 + + IntPtr id_close; + public unsafe void Close () + { + if (id_close == IntPtr.Zero) + id_close = JNIEnv.GetMethodID (class_ref, "close", "()V"); + JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_close); + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Xamarin.Test.SomeObject.cs new file mode 100644 index 000000000..c21c66181 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Xamarin.Test.SomeObject.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" + [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + public partial class SomeObject : global::Java.Lang.Object, global::Xamarin.Test.II1, global::Xamarin.Test.II2 { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_close; +#pragma warning disable 0169 + static Delegate GetCloseHandler () + { + if (cb_close == null) + cb_close = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Close); + return cb_close; + } + + static void n_Close (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Close (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='close' and count(parameter)=0]" + [Register ("close", "()V", "GetCloseHandler")] + public virtual unsafe void Close () + { + const string __id = "close.()V"; + try { + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Xamarin.Test.SomeObject2.cs b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Xamarin.Test.SomeObject2.cs new file mode 100644 index 000000000..effc57aa8 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/Xamarin.Test.SomeObject2.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject2']" + [global::Android.Runtime.Register ("xamarin/test/SomeObject2", DoNotGenerateAcw=true)] + public abstract partial class SomeObject2 : global::Java.Lang.Object, global::Xamarin.Test.II1, global::Xamarin.Test.II2 { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject2", typeof (SomeObject2)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected SomeObject2 (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_irrelevant; +#pragma warning disable 0169 + static Delegate GetIrrelevantHandler () + { + if (cb_irrelevant == null) + cb_irrelevant = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Irrelevant); + return cb_irrelevant; + } + + static void n_Irrelevant (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Irrelevant (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject2']/method[@name='irrelevant' and count(parameter)=0]" + [Register ("irrelevant", "()V", "GetIrrelevantHandler")] + public virtual unsafe void Irrelevant () + { + const string __id = "irrelevant.()V"; + try { + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null); + } finally { + } + } + + static Delegate cb_close; +#pragma warning disable 0169 + static Delegate GetCloseHandler () + { + if (cb_close == null) + cb_close = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Close); + return cb_close; + } + + static void n_Close (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Close (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='I1']/method[@name='close' and count(parameter)=0]" + [Register ("close", "()V", "GetCloseHandler")] + public abstract void Close (); + + } + + [global::Android.Runtime.Register ("xamarin/test/SomeObject2", DoNotGenerateAcw=true)] + internal partial class SomeObject2Invoker : SomeObject2 { + public SomeObject2Invoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + { + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject2", typeof (SomeObject2Invoker)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='I1']/method[@name='close' and count(parameter)=0]" + [Register ("close", "()V", "GetCloseHandler")] + public override unsafe void Close () + { + const string __id = "close.()V"; + try { + _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, null); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/__NamespaceMapping__.cs new file mode 100644 index 000000000..4c11e5976 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/__NamespaceMapping__.cs @@ -0,0 +1,16 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +delegate void _JniMarshal_PP_V (IntPtr jnienv, IntPtr klass); +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/enumlist b/tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/NormalProperties/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/NestedTypes/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/NormalProperties/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/NestedTypes/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/NestedTypes/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/NestedTypes/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NestedTypes/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/NestedTypes/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/NestedTypes/Mono.Android.projitems new file mode 100644 index 000000000..5e66c0f7f --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NestedTypes/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs b/tests/generator-Tests/expected.xaji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs new file mode 100644 index 000000000..85d621b46 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs @@ -0,0 +1,262 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='NotificationCompatBase']" + [global::Android.Runtime.Register ("xamarin/test/NotificationCompatBase", DoNotGenerateAcw=true)] + public partial class NotificationCompatBase : global::Java.Lang.Object { + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='NotificationCompatBase.Action']" + [global::Android.Runtime.Register ("xamarin/test/NotificationCompatBase$Action", DoNotGenerateAcw=true)] + public abstract partial class Action : global::Java.Lang.Object { + // Metadata.xml XPath interface reference: path="/api/package[@name='xamarin.test']/interface[@name='NotificationCompatBase.Action.Factory']" + [Register ("xamarin/test/NotificationCompatBase$Action$Factory", "", "Xamarin.Test.NotificationCompatBase/Action/IFactoryInvoker")] + public partial interface IFactory : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='NotificationCompatBase.Action.Factory']/method[@name='build' and count(parameter)=1 and parameter[1][@type='int']]" + [Register ("build", "(I)Lxamarin/test/NotificationCompatBase$Action;", "GetBuild_IHandler:Xamarin.Test.NotificationCompatBase/Action/IFactoryInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + global::Xamarin.Test.NotificationCompatBase.Action Build (int p0); + + } + + [global::Android.Runtime.Register ("xamarin/test/NotificationCompatBase$Action$Factory", DoNotGenerateAcw=true)] + internal partial class IFactoryInvoker : global::Java.Lang.Object, IFactory { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/NotificationCompatBase$Action$Factory", typeof (IFactoryInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static IFactory GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.NotificationCompatBase.Action.Factory'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public IFactoryInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_build_I; +#pragma warning disable 0169 + static Delegate GetBuild_IHandler () + { + if (cb_build_I == null) + cb_build_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_L) n_Build_I); + return cb_build_I; + } + + static IntPtr n_Build_I (IntPtr jnienv, IntPtr native__this, int p0) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.ToLocalJniHandle (__this.Build (p0)); + } +#pragma warning restore 0169 + + IntPtr id_build_I; + public unsafe global::Xamarin.Test.NotificationCompatBase.Action Build (int p0) + { + if (id_build_I == IntPtr.Zero) + id_build_I = JNIEnv.GetMethodID (class_ref, "build", "(I)Lxamarin/test/NotificationCompatBase$Action;"); + JValue* __args = stackalloc JValue [1]; + __args [0] = new JValue (p0); + return global::Java.Lang.Object.GetObject (JNIEnv.CallObjectMethod (((global::Java.Lang.Object) this).Handle, id_build_I, __args), JniHandleOwnership.TransferLocalRef); + } + + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/NotificationCompatBase$Action", typeof (Action)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected Action (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + } + + [global::Android.Runtime.Register ("xamarin/test/NotificationCompatBase$Action", DoNotGenerateAcw=true)] + internal partial class ActionInvoker : Action { + public ActionInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + { + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/NotificationCompatBase$Action", typeof (ActionInvoker)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + } + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='NotificationCompatBase.InstanceInner']" + [global::Android.Runtime.Register ("xamarin/test/NotificationCompatBase$InstanceInner", DoNotGenerateAcw=true)] + public abstract partial class InstanceInner : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/NotificationCompatBase$InstanceInner", typeof (InstanceInner)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected InstanceInner (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='NotificationCompatBase.InstanceInner']/constructor[@name='NotificationCompatBase.InstanceInner' and count(parameter)=1 and parameter[1][@type='xamarin.test.NotificationCompatBase']]" + [Register (".ctor", "(Lxamarin/test/NotificationCompatBase;)V", "")] + public unsafe InstanceInner (global::Xamarin.Test.NotificationCompatBase __self) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + string __id = "(L" + global::Android.Runtime.JNIEnv.GetJniName (GetType ().DeclaringType) + ";)V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue ((__self == null) ? IntPtr.Zero : ((global::Java.Lang.Object) __self).Handle); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, __args); + } finally { + global::System.GC.KeepAlive (__self); + } + } + + } + + [global::Android.Runtime.Register ("xamarin/test/NotificationCompatBase$InstanceInner", DoNotGenerateAcw=true)] + internal partial class InstanceInnerInvoker : InstanceInner { + public InstanceInnerInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + { + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/NotificationCompatBase$InstanceInner", typeof (InstanceInnerInvoker)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/NotificationCompatBase", typeof (NotificationCompatBase)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected NotificationCompatBase (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/NestedTypes/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/NestedTypes/__NamespaceMapping__.cs new file mode 100644 index 000000000..6ae237a9d --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NestedTypes/__NamespaceMapping__.cs @@ -0,0 +1,16 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +delegate IntPtr _JniMarshal_PPI_L (IntPtr jnienv, IntPtr klass, int p0); +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/NestedTypes/enumlist b/tests/generator-Tests/expected.xaji/NestedTypes/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/ParameterXPath/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/NonStaticFields/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/ParameterXPath/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/NonStaticFields/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/NonStaticFields/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/NonStaticFields/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NonStaticFields/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/NonStaticFields/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/NonStaticFields/Mono.Android.projitems new file mode 100644 index 000000000..066be1dd1 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NonStaticFields/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/NonStaticFields/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.xaji/NonStaticFields/Xamarin.Test.SomeObject.cs new file mode 100644 index 000000000..93cb9e94e --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NonStaticFields/Xamarin.Test.SomeObject.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" + [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + public partial class SomeObject : global::Java.Lang.Object { + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='Value']" + [Register ("Value")] + public int Value { + get { + const string __id = "Value.I"; + + var __v = _members.InstanceFields.GetInt32Value (__id, this); + return __v; + } + set { + const string __id = "Value.I"; + + try { + _members.InstanceFields.SetValue (__id, this, value); + } finally { + } + } + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/NonStaticFields/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/NonStaticFields/__NamespaceMapping__.cs new file mode 100644 index 000000000..e9b0e4292 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NonStaticFields/__NamespaceMapping__.cs @@ -0,0 +1,15 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/NonStaticFields/enumlist b/tests/generator-Tests/expected.xaji/NonStaticFields/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/StaticFields/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/NormalMethods/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/StaticFields/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/NormalMethods/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/NormalMethods/Java.Lang.Class.cs b/tests/generator-Tests/expected.xaji/NormalMethods/Java.Lang.Class.cs new file mode 100644 index 000000000..d1ce76990 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NormalMethods/Java.Lang.Class.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Class']" + [global::Android.Runtime.Register ("java/lang/Class", DoNotGenerateAcw=true)] + [global::Java.Interop.JavaTypeParameters (new string [] {"T"})] + public partial class Class : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Class", typeof (Class)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected Class (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/NormalMethods/Java.Lang.Integer.cs b/tests/generator-Tests/expected.xaji/NormalMethods/Java.Lang.Integer.cs new file mode 100644 index 000000000..7499dd94d --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NormalMethods/Java.Lang.Integer.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Integer']" + [global::Android.Runtime.Register ("java/lang/Integer", DoNotGenerateAcw=true)] + public partial class Integer : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Integer", typeof (Integer)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected Integer (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/NormalMethods/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/NormalMethods/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NormalMethods/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/NormalMethods/Java.Lang.Throwable.cs b/tests/generator-Tests/expected.xaji/NormalMethods/Java.Lang.Throwable.cs new file mode 100644 index 000000000..03307c7e5 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NormalMethods/Java.Lang.Throwable.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Throwable']" + [global::Android.Runtime.Register ("java/lang/Throwable", DoNotGenerateAcw=true)] + public partial class Throwable { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Throwable", typeof (Throwable)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/NormalMethods/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/NormalMethods/Mono.Android.projitems new file mode 100644 index 000000000..98ca90f0d --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NormalMethods/Mono.Android.projitems @@ -0,0 +1,20 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/NormalMethods/Xamarin.Test.A.cs b/tests/generator-Tests/expected.xaji/NormalMethods/Xamarin.Test.A.cs new file mode 100644 index 000000000..eebb6a326 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NormalMethods/Xamarin.Test.A.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='A']" + [global::Android.Runtime.Register ("xamarin/test/A", DoNotGenerateAcw=true)] + public partial class A : global::Java.Lang.Object { + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='A.B']" + [global::Android.Runtime.Register ("xamarin/test/A$B", DoNotGenerateAcw=true)] + [global::Java.Interop.JavaTypeParameters (new string [] {"T extends xamarin.test.A.B"})] + public partial class B : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/A$B", typeof (B)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected B (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_setCustomDimension_I; +#pragma warning disable 0169 + static Delegate GetSetCustomDimension_IHandler () + { + if (cb_setCustomDimension_I == null) + cb_setCustomDimension_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_L) n_SetCustomDimension_I); + return cb_setCustomDimension_I; + } + + static IntPtr n_SetCustomDimension_I (IntPtr jnienv, IntPtr native__this, int index) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.ToLocalJniHandle (__this.SetCustomDimension (index)); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='A.B']/method[@name='setCustomDimension' and count(parameter)=1 and parameter[1][@type='int']]" + [Register ("setCustomDimension", "(I)Lxamarin/test/A$B;", "GetSetCustomDimension_IHandler")] + public virtual unsafe global::Java.Lang.Object SetCustomDimension (int index) + { + const string __id = "setCustomDimension.(I)Lxamarin/test/A$B;"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (index); + var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, __args); + return (global::Java.Lang.Object) global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/A", typeof (A)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected A (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_getHandle; +#pragma warning disable 0169 + static Delegate GetGetHandleHandler () + { + if (cb_getHandle == null) + cb_getHandle = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_GetHandle); + return cb_getHandle; + } + + static int n_GetHandle (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return __this.GetHandle (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='A']/method[@name='getHandle' and count(parameter)=0]" + [Register ("getHandle", "()I", "GetGetHandleHandler")] + public virtual unsafe int GetHandle () + { + const string __id = "getHandle.()I"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, null); + return __rm; + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/NormalMethods/Xamarin.Test.C.cs b/tests/generator-Tests/expected.xaji/NormalMethods/Xamarin.Test.C.cs new file mode 100644 index 000000000..8883d55e3 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NormalMethods/Xamarin.Test.C.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='C']" + [global::Android.Runtime.Register ("xamarin/test/C", DoNotGenerateAcw=true)] + [global::Java.Interop.JavaTypeParameters (new string [] {"T extends xamarin.test.C"})] + public partial class C : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/C", typeof (C)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected C (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_setCustomDimension_I; +#pragma warning disable 0169 + static Delegate GetSetCustomDimension_IHandler () + { + if (cb_setCustomDimension_I == null) + cb_setCustomDimension_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_L) n_SetCustomDimension_I); + return cb_setCustomDimension_I; + } + + static IntPtr n_SetCustomDimension_I (IntPtr jnienv, IntPtr native__this, int index) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.ToLocalJniHandle (__this.SetCustomDimension (index)); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='C']/method[@name='setCustomDimension' and count(parameter)=1 and parameter[1][@type='int']]" + [Register ("setCustomDimension", "(I)Lxamarin/test/C;", "GetSetCustomDimension_IHandler")] + public virtual unsafe global::Java.Lang.Object SetCustomDimension (int index) + { + const string __id = "setCustomDimension.(I)Lxamarin/test/C;"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (index); + var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, __args); + return (global::Java.Lang.Object) global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/NormalMethods/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.xaji/NormalMethods/Xamarin.Test.SomeObject.cs new file mode 100644 index 000000000..9eda0833c --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NormalMethods/Xamarin.Test.SomeObject.cs @@ -0,0 +1,335 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" + [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + public partial class SomeObject : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/constructor[@name='SomeObject' and count(parameter)=1 and parameter[1][@type='java.lang.Class<? extends xamarin.test.SomeObject>']]" + [Register (".ctor", "(Ljava/lang/Class;)V", "")] + public unsafe SomeObject (global::Java.Lang.Class c) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "(Ljava/lang/Class;)V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue ((c == null) ? IntPtr.Zero : ((global::Java.Lang.Object) c).Handle); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, __args); + } finally { + global::System.GC.KeepAlive (c); + } + } + + static Delegate cb_getType; +#pragma warning disable 0169 + static Delegate GetGetTypeHandler () + { + if (cb_getType == null) + cb_getType = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetType); + return cb_getType; + } + + static IntPtr n_GetType (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.NewArray (__this.GetType ()); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getType' and count(parameter)=0]" + [Register ("getType", "()[I", "GetGetTypeHandler")] + public new virtual unsafe int[] GetType () + { + const string __id = "getType.()[I"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); + return (int[]) JNIEnv.GetArray (__rm.Handle, JniHandleOwnership.TransferLocalRef, typeof (int)); + } finally { + } + } + + static Delegate cb_handle_Ljava_lang_Object_Ljava_lang_Throwable_; +#pragma warning disable 0169 + static Delegate GetHandle_Ljava_lang_Object_Ljava_lang_Throwable_Handler () + { + if (cb_handle_Ljava_lang_Object_Ljava_lang_Throwable_ == null) + cb_handle_Ljava_lang_Object_Ljava_lang_Throwable_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPLL_I) n_Handle_Ljava_lang_Object_Ljava_lang_Throwable_); + return cb_handle_Ljava_lang_Object_Ljava_lang_Throwable_; + } + + static int n_Handle_Ljava_lang_Object_Ljava_lang_Throwable_ (IntPtr jnienv, IntPtr native__this, IntPtr native_o, IntPtr native_t) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var o = global::Java.Lang.Object.GetObject (native_o, JniHandleOwnership.DoNotTransfer); + var t = global::Java.Lang.Object.GetObject (native_t, JniHandleOwnership.DoNotTransfer); + int __ret = __this.Handle (o, t); + return __ret; + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='handle' and count(parameter)=2 and parameter[1][@type='java.lang.Object'] and parameter[2][@type='java.lang.Throwable']]" + [Register ("handle", "(Ljava/lang/Object;Ljava/lang/Throwable;)I", "GetHandle_Ljava_lang_Object_Ljava_lang_Throwable_Handler")] + public new virtual unsafe int Handle (global::Java.Lang.Object o, global::Java.Lang.Throwable t) + { + const string __id = "handle.(Ljava/lang/Object;Ljava/lang/Throwable;)I"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [2]; + __args [0] = new JniArgumentValue ((o == null) ? IntPtr.Zero : ((global::Java.Lang.Object) o).Handle); + __args [1] = new JniArgumentValue ((t == null) ? IntPtr.Zero : ((global::Java.Lang.Throwable) t).Handle); + var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, __args); + return __rm; + } finally { + global::System.GC.KeepAlive (o); + global::System.GC.KeepAlive (t); + } + } + + static Delegate cb_IntegerMethod; +#pragma warning disable 0169 + static Delegate GetIntegerMethodHandler () + { + if (cb_IntegerMethod == null) + cb_IntegerMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_IntegerMethod); + return cb_IntegerMethod; + } + + static int n_IntegerMethod (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return __this.IntegerMethod (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='IntegerMethod' and count(parameter)=0]" + [Register ("IntegerMethod", "()I", "GetIntegerMethodHandler")] + public virtual unsafe int IntegerMethod () + { + const string __id = "IntegerMethod.()I"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, null); + return __rm; + } finally { + } + } + + static Delegate cb_VoidMethod; +#pragma warning disable 0169 + static Delegate GetVoidMethodHandler () + { + if (cb_VoidMethod == null) + cb_VoidMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_VoidMethod); + return cb_VoidMethod; + } + + static void n_VoidMethod (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.VoidMethod (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='VoidMethod' and count(parameter)=0]" + [Register ("VoidMethod", "()V", "GetVoidMethodHandler")] + public virtual unsafe void VoidMethod () + { + const string __id = "VoidMethod.()V"; + try { + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null); + } finally { + } + } + + static Delegate cb_StringMethod; +#pragma warning disable 0169 + static Delegate GetStringMethodHandler () + { + if (cb_StringMethod == null) + cb_StringMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_StringMethod); + return cb_StringMethod; + } + + static IntPtr n_StringMethod (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.NewString (__this.StringMethod ()); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='StringMethod' and count(parameter)=0]" + [Register ("StringMethod", "()Ljava/lang/String;", "GetStringMethodHandler")] + public virtual unsafe string StringMethod () + { + const string __id = "StringMethod.()Ljava/lang/String;"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); + return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + + static Delegate cb_ObjectMethod; +#pragma warning disable 0169 + static Delegate GetObjectMethodHandler () + { + if (cb_ObjectMethod == null) + cb_ObjectMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_ObjectMethod); + return cb_ObjectMethod; + } + + static IntPtr n_ObjectMethod (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.ToLocalJniHandle (__this.ObjectMethod ()); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='ObjectMethod' and count(parameter)=0]" + [Register ("ObjectMethod", "()Ljava/lang/Object;", "GetObjectMethodHandler")] + public virtual unsafe global::Java.Lang.Object ObjectMethod () + { + const string __id = "ObjectMethod.()Ljava/lang/Object;"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); + return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + + static Delegate cb_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_; +#pragma warning disable 0169 + static Delegate GetVoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_Handler () + { + if (cb_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_ == null) + cb_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPLIL_V) n_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_); + return cb_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_; + } + + static void n_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_astring, int anint, IntPtr native_anObject) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var astring = JNIEnv.GetString (native_astring, JniHandleOwnership.DoNotTransfer); + var anObject = global::Java.Lang.Object.GetObject (native_anObject, JniHandleOwnership.DoNotTransfer); + __this.VoidMethodWithParams (astring, anint, anObject); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='VoidMethodWithParams' and count(parameter)=3 and parameter[1][@type='java.lang.String'] and parameter[2][@type='int'] and parameter[3][@type='java.lang.Object']]" + [Register ("VoidMethodWithParams", "(Ljava/lang/String;ILjava/lang/Object;)V", "GetVoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_Handler")] + public virtual unsafe void VoidMethodWithParams (string astring, int anint, global::Java.Lang.Object anObject) + { + const string __id = "VoidMethodWithParams.(Ljava/lang/String;ILjava/lang/Object;)V"; + IntPtr native_astring = JNIEnv.NewString (astring); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [3]; + __args [0] = new JniArgumentValue (native_astring); + __args [1] = new JniArgumentValue (anint); + __args [2] = new JniArgumentValue ((anObject == null) ? IntPtr.Zero : ((global::Java.Lang.Object) anObject).Handle); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + JNIEnv.DeleteLocalRef (native_astring); + global::System.GC.KeepAlive (anObject); + } + } + + static Delegate cb_ObsoleteMethod; +#pragma warning disable 0169 + [Obsolete] + static Delegate GetObsoleteMethodHandler () + { + if (cb_ObsoleteMethod == null) + cb_ObsoleteMethod = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_ObsoleteMethod); + return cb_ObsoleteMethod; + } + + [Obsolete] + static int n_ObsoleteMethod (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return __this.ObsoleteMethod (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='ObsoleteMethod' and count(parameter)=0]" + [Obsolete (@"Deprecated please use IntegerMethod instead")] + [Register ("ObsoleteMethod", "()I", "GetObsoleteMethodHandler")] + public virtual unsafe int ObsoleteMethod () + { + const string __id = "ObsoleteMethod.()I"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, null); + return __rm; + } finally { + } + } + + static Delegate cb_ArrayListTest_Ljava_util_ArrayList_; +#pragma warning disable 0169 + static Delegate GetArrayListTest_Ljava_util_ArrayList_Handler () + { + if (cb_ArrayListTest_Ljava_util_ArrayList_ == null) + cb_ArrayListTest_Ljava_util_ArrayList_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_ArrayListTest_Ljava_util_ArrayList_); + return cb_ArrayListTest_Ljava_util_ArrayList_; + } + + static void n_ArrayListTest_Ljava_util_ArrayList_ (IntPtr jnienv, IntPtr native__this, IntPtr native_p0) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var p0 = global::Android.Runtime.JavaList.FromJniHandle (native_p0, JniHandleOwnership.DoNotTransfer); + __this.ArrayListTest (p0); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='ArrayListTest' and count(parameter)=1 and parameter[1][@type='java.util.ArrayList<java.lang.Integer>']]" + [Register ("ArrayListTest", "(Ljava/util/ArrayList;)V", "GetArrayListTest_Ljava_util_ArrayList_Handler")] + public virtual unsafe void ArrayListTest (global::System.Collections.Generic.IList p0) + { + const string __id = "ArrayListTest.(Ljava/util/ArrayList;)V"; + IntPtr native_p0 = global::Android.Runtime.JavaList.ToLocalJniHandle (p0); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_p0); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + JNIEnv.DeleteLocalRef (native_p0); + global::System.GC.KeepAlive (p0); + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/NormalMethods/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/NormalMethods/__NamespaceMapping__.cs new file mode 100644 index 000000000..85b6a37af --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NormalMethods/__NamespaceMapping__.cs @@ -0,0 +1,22 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +delegate int _JniMarshal_PP_I (IntPtr jnienv, IntPtr klass); +delegate IntPtr _JniMarshal_PP_L (IntPtr jnienv, IntPtr klass); +delegate void _JniMarshal_PP_V (IntPtr jnienv, IntPtr klass); +delegate IntPtr _JniMarshal_PPI_L (IntPtr jnienv, IntPtr klass, int p0); +delegate void _JniMarshal_PPL_V (IntPtr jnienv, IntPtr klass, IntPtr p0); +delegate void _JniMarshal_PPLIL_V (IntPtr jnienv, IntPtr klass, IntPtr p0, int p1, IntPtr p2); +delegate int _JniMarshal_PPLL_I (IntPtr jnienv, IntPtr klass, IntPtr p0, IntPtr p1); +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/NormalMethods/enumlist b/tests/generator-Tests/expected.xaji/NormalMethods/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/StaticMethods/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/NormalProperties/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/StaticMethods/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/NormalProperties/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/NormalProperties/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/NormalProperties/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NormalProperties/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/NormalProperties/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/NormalProperties/Mono.Android.projitems new file mode 100644 index 000000000..066be1dd1 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NormalProperties/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/NormalProperties/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.xaji/NormalProperties/Xamarin.Test.SomeObject.cs new file mode 100644 index 000000000..eb02219c8 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NormalProperties/Xamarin.Test.SomeObject.cs @@ -0,0 +1,265 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" + [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + public abstract partial class SomeObject : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_getSomeInteger; +#pragma warning disable 0169 + static Delegate GetGetSomeIntegerHandler () + { + if (cb_getSomeInteger == null) + cb_getSomeInteger = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_GetSomeInteger); + return cb_getSomeInteger; + } + + static int n_GetSomeInteger (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return __this.SomeInteger; + } +#pragma warning restore 0169 + + static Delegate cb_setSomeInteger_I; +#pragma warning disable 0169 + static Delegate GetSetSomeInteger_IHandler () + { + if (cb_setSomeInteger_I == null) + cb_setSomeInteger_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_SetSomeInteger_I); + return cb_setSomeInteger_I; + } + + static void n_SetSomeInteger_I (IntPtr jnienv, IntPtr native__this, int newvalue) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.SomeInteger = newvalue; + } +#pragma warning restore 0169 + + public abstract int SomeInteger { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeInteger' and count(parameter)=0]" + [Register ("getSomeInteger", "()I", "GetGetSomeIntegerHandler")] + get; + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeInteger' and count(parameter)=1 and parameter[1][@type='int']]" + [Register ("setSomeInteger", "(I)V", "GetSetSomeInteger_IHandler")] + set; + } + + static Delegate cb_getSomeObjectProperty; +#pragma warning disable 0169 + static Delegate GetGetSomeObjectPropertyHandler () + { + if (cb_getSomeObjectProperty == null) + cb_getSomeObjectProperty = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetSomeObjectProperty); + return cb_getSomeObjectProperty; + } + + static IntPtr n_GetSomeObjectProperty (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.ToLocalJniHandle (__this.SomeObjectProperty); + } +#pragma warning restore 0169 + + static Delegate cb_setSomeObjectProperty_Ljava_lang_Object_; +#pragma warning disable 0169 + static Delegate GetSetSomeObjectProperty_Ljava_lang_Object_Handler () + { + if (cb_setSomeObjectProperty_Ljava_lang_Object_ == null) + cb_setSomeObjectProperty_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetSomeObjectProperty_Ljava_lang_Object_); + return cb_setSomeObjectProperty_Ljava_lang_Object_; + } + + static void n_SetSomeObjectProperty_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_newvalue) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var newvalue = global::Java.Lang.Object.GetObject (native_newvalue, JniHandleOwnership.DoNotTransfer); + __this.SomeObjectProperty = newvalue; + } +#pragma warning restore 0169 + + public abstract global::Java.Lang.Object SomeObjectProperty { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeObjectProperty' and count(parameter)=0]" + [Register ("getSomeObjectProperty", "()Ljava/lang/Object;", "GetGetSomeObjectPropertyHandler")] + get; + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeObjectProperty' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" + [Register ("setSomeObjectProperty", "(Ljava/lang/Object;)V", "GetSetSomeObjectProperty_Ljava_lang_Object_Handler")] + set; + } + + static Delegate cb_getSomeString; +#pragma warning disable 0169 + static Delegate GetGetSomeStringHandler () + { + if (cb_getSomeString == null) + cb_getSomeString = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetSomeString); + return cb_getSomeString; + } + + static IntPtr n_GetSomeString (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.NewString (__this.SomeString); + } +#pragma warning restore 0169 + + static Delegate cb_setSomeString_Ljava_lang_String_; +#pragma warning disable 0169 + static Delegate GetSetSomeString_Ljava_lang_String_Handler () + { + if (cb_setSomeString_Ljava_lang_String_ == null) + cb_setSomeString_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetSomeString_Ljava_lang_String_); + return cb_setSomeString_Ljava_lang_String_; + } + + static void n_SetSomeString_Ljava_lang_String_ (IntPtr jnienv, IntPtr native__this, IntPtr native_newvalue) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var newvalue = JNIEnv.GetString (native_newvalue, JniHandleOwnership.DoNotTransfer); + __this.SomeString = newvalue; + } +#pragma warning restore 0169 + + public abstract string SomeString { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeString' and count(parameter)=0]" + [Register ("getSomeString", "()Ljava/lang/String;", "GetGetSomeStringHandler")] + get; + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeString' and count(parameter)=1 and parameter[1][@type='java.lang.String']]" + [Register ("setSomeString", "(Ljava/lang/String;)V", "GetSetSomeString_Ljava_lang_String_Handler")] + set; + } + + } + + [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + internal partial class SomeObjectInvoker : SomeObject { + public SomeObjectInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + { + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject", typeof (SomeObjectInvoker)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + public override unsafe int SomeInteger { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeInteger' and count(parameter)=0]" + [Register ("getSomeInteger", "()I", "GetGetSomeIntegerHandler")] + get { + const string __id = "getSomeInteger.()I"; + try { + var __rm = _members.InstanceMethods.InvokeAbstractInt32Method (__id, this, null); + return __rm; + } finally { + } + } + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeInteger' and count(parameter)=1 and parameter[1][@type='int']]" + [Register ("setSomeInteger", "(I)V", "GetSetSomeInteger_IHandler")] + set { + const string __id = "setSomeInteger.(I)V"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (value); + _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args); + } finally { + } + } + } + + public override unsafe global::Java.Lang.Object SomeObjectProperty { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeObjectProperty' and count(parameter)=0]" + [Register ("getSomeObjectProperty", "()Ljava/lang/Object;", "GetGetSomeObjectPropertyHandler")] + get { + const string __id = "getSomeObjectProperty.()Ljava/lang/Object;"; + try { + var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null); + return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeObjectProperty' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" + [Register ("setSomeObjectProperty", "(Ljava/lang/Object;)V", "GetSetSomeObjectProperty_Ljava_lang_Object_Handler")] + set { + const string __id = "setSomeObjectProperty.(Ljava/lang/Object;)V"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue ((value == null) ? IntPtr.Zero : ((global::Java.Lang.Object) value).Handle); + _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args); + } finally { + global::System.GC.KeepAlive (value); + } + } + } + + public override unsafe string SomeString { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeString' and count(parameter)=0]" + [Register ("getSomeString", "()Ljava/lang/String;", "GetGetSomeStringHandler")] + get { + const string __id = "getSomeString.()Ljava/lang/String;"; + try { + var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null); + return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeString' and count(parameter)=1 and parameter[1][@type='java.lang.String']]" + [Register ("setSomeString", "(Ljava/lang/String;)V", "GetSetSomeString_Ljava_lang_String_Handler")] + set { + const string __id = "setSomeString.(Ljava/lang/String;)V"; + IntPtr native_value = JNIEnv.NewString (value); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_value); + _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args); + } finally { + JNIEnv.DeleteLocalRef (native_value); + } + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/NormalProperties/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/NormalProperties/__NamespaceMapping__.cs new file mode 100644 index 000000000..8c8e6cce3 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/NormalProperties/__NamespaceMapping__.cs @@ -0,0 +1,19 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +delegate int _JniMarshal_PP_I (IntPtr jnienv, IntPtr klass); +delegate IntPtr _JniMarshal_PP_L (IntPtr jnienv, IntPtr klass); +delegate void _JniMarshal_PPI_V (IntPtr jnienv, IntPtr klass, int p0); +delegate void _JniMarshal_PPL_V (IntPtr jnienv, IntPtr klass, IntPtr p0); +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/NormalProperties/enumlist b/tests/generator-Tests/expected.xaji/NormalProperties/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/StaticProperties/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/ParameterXPath/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/StaticProperties/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/ParameterXPath/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/ParameterXPath/Java.Lang.Integer.cs b/tests/generator-Tests/expected.xaji/ParameterXPath/Java.Lang.Integer.cs new file mode 100644 index 000000000..7499dd94d --- /dev/null +++ b/tests/generator-Tests/expected.xaji/ParameterXPath/Java.Lang.Integer.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Integer']" + [global::Android.Runtime.Register ("java/lang/Integer", DoNotGenerateAcw=true)] + public partial class Integer : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Integer", typeof (Integer)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected Integer (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/ParameterXPath/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/ParameterXPath/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/ParameterXPath/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/ParameterXPath/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/ParameterXPath/Mono.Android.projitems new file mode 100644 index 000000000..e6f21d31f --- /dev/null +++ b/tests/generator-Tests/expected.xaji/ParameterXPath/Mono.Android.projitems @@ -0,0 +1,16 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/ParameterXPath/Xamarin.Test.A.cs b/tests/generator-Tests/expected.xaji/ParameterXPath/Xamarin.Test.A.cs new file mode 100644 index 000000000..3250e8db5 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/ParameterXPath/Xamarin.Test.A.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='A']" + [global::Android.Runtime.Register ("xamarin/test/A", DoNotGenerateAcw=true)] + [global::Java.Interop.JavaTypeParameters (new string [] {"T extends java.lang.Object"})] + public partial class A : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/A", typeof (A)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected A (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_setA_Ljava_lang_Object_; +#pragma warning disable 0169 + static Delegate GetSetA_Ljava_lang_Object_Handler () + { + if (cb_setA_Ljava_lang_Object_ == null) + cb_setA_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetA_Ljava_lang_Object_); + return cb_setA_Ljava_lang_Object_; + } + + static void n_SetA_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_adapter) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var adapter = global::Java.Lang.Object.GetObject (native_adapter, JniHandleOwnership.DoNotTransfer); + __this.SetA (adapter); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='A']/method[@name='setA' and count(parameter)=1 and parameter[1][@type='T']]" + [Register ("setA", "(Ljava/lang/Object;)V", "GetSetA_Ljava_lang_Object_Handler")] + public virtual unsafe void SetA (global::Java.Lang.Object adapter) + { + const string __id = "setA.(Ljava/lang/Object;)V"; + IntPtr native_adapter = JNIEnv.ToLocalJniHandle (adapter); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_adapter); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + JNIEnv.DeleteLocalRef (native_adapter); + global::System.GC.KeepAlive (adapter); + } + } + + static Delegate cb_listTest_Ljava_util_List_; +#pragma warning disable 0169 + static Delegate GetListTest_Ljava_util_List_Handler () + { + if (cb_listTest_Ljava_util_List_ == null) + cb_listTest_Ljava_util_List_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_ListTest_Ljava_util_List_); + return cb_listTest_Ljava_util_List_; + } + + static void n_ListTest_Ljava_util_List_ (IntPtr jnienv, IntPtr native__this, IntPtr native_p0) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var p0 = global::Android.Runtime.JavaList.FromJniHandle (native_p0, JniHandleOwnership.DoNotTransfer); + __this.ListTest (p0); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='A']/method[@name='listTest' and count(parameter)=1 and parameter[1][@type='java.util.List<java.lang.Integer>']]" + [Register ("listTest", "(Ljava/util/List;)V", "GetListTest_Ljava_util_List_Handler")] + public virtual unsafe void ListTest (global::System.Collections.Generic.IList p0) + { + const string __id = "listTest.(Ljava/util/List;)V"; + IntPtr native_p0 = global::Android.Runtime.JavaList.ToLocalJniHandle (p0); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_p0); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + JNIEnv.DeleteLocalRef (native_p0); + global::System.GC.KeepAlive (p0); + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/ParameterXPath/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/ParameterXPath/__NamespaceMapping__.cs new file mode 100644 index 000000000..f66004a12 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/ParameterXPath/__NamespaceMapping__.cs @@ -0,0 +1,16 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +delegate void _JniMarshal_PPL_V (IntPtr jnienv, IntPtr klass, IntPtr p0); +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/ParameterXPath/enumlist b/tests/generator-Tests/expected.xaji/ParameterXPath/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/Streams/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/StaticFields/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/Streams/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/StaticFields/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/StaticFields/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/StaticFields/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/StaticFields/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/StaticFields/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/StaticFields/Mono.Android.projitems new file mode 100644 index 000000000..066be1dd1 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/StaticFields/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/StaticFields/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.xaji/StaticFields/Xamarin.Test.SomeObject.cs new file mode 100644 index 000000000..a56021cda --- /dev/null +++ b/tests/generator-Tests/expected.xaji/StaticFields/Xamarin.Test.SomeObject.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" + [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + public partial class SomeObject : global::Java.Lang.Object { + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='Value']" + [Register ("Value")] + public static int Value { + get { + const string __id = "Value.I"; + + var __v = _members.StaticFields.GetInt32Value (__id); + return __v; + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='Value2']" + [Register ("Value2")] + public static int Value2 { + get { + const string __id = "Value2.I"; + + var __v = _members.StaticFields.GetInt32Value (__id); + return __v; + } + set { + const string __id = "Value2.I"; + + try { + _members.StaticFields.SetValue (__id, value); + } finally { + } + } + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/StaticFields/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/StaticFields/__NamespaceMapping__.cs new file mode 100644 index 000000000..e9b0e4292 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/StaticFields/__NamespaceMapping__.cs @@ -0,0 +1,15 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/StaticFields/enumlist b/tests/generator-Tests/expected.xaji/StaticFields/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/TestInterface/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/StaticMethods/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/TestInterface/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/StaticMethods/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/StaticMethods/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/StaticMethods/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/StaticMethods/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/StaticMethods/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/StaticMethods/Mono.Android.projitems new file mode 100644 index 000000000..066be1dd1 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/StaticMethods/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/StaticMethods/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.xaji/StaticMethods/Xamarin.Test.SomeObject.cs new file mode 100644 index 000000000..ca9637dd7 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/StaticMethods/Xamarin.Test.SomeObject.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" + [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + public partial class SomeObject : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='methodAsInt' and count(parameter)=0]" + [Register ("methodAsInt", "()I", "")] + public static unsafe int MethodAsInt () + { + const string __id = "methodAsInt.()I"; + try { + var __rm = _members.StaticMethods.InvokeInt32Method (__id, null); + return __rm; + } finally { + } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='methodAsString' and count(parameter)=0]" + [Register ("methodAsString", "()Ljava/lang/String;", "")] + public static unsafe string MethodAsString () + { + const string __id = "methodAsString.()Ljava/lang/String;"; + try { + var __rm = _members.StaticMethods.InvokeObjectMethod (__id, null); + return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='Obsoletemethod' and count(parameter)=0]" + [Obsolete (@"Deprecated please use methodAsString")] + [Register ("Obsoletemethod", "()Ljava/lang/String;", "")] + public static unsafe string Obsoletemethod () + { + const string __id = "Obsoletemethod.()Ljava/lang/String;"; + try { + var __rm = _members.StaticMethods.InvokeObjectMethod (__id, null); + return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/StaticMethods/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/StaticMethods/__NamespaceMapping__.cs new file mode 100644 index 000000000..e9b0e4292 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/StaticMethods/__NamespaceMapping__.cs @@ -0,0 +1,15 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/StaticMethods/enumlist b/tests/generator-Tests/expected.xaji/StaticMethods/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/StaticProperties/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/java.lang.Enum/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/StaticProperties/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/StaticProperties/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/StaticProperties/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/StaticProperties/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/StaticProperties/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/StaticProperties/Mono.Android.projitems new file mode 100644 index 000000000..066be1dd1 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/StaticProperties/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/StaticProperties/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.xaji/StaticProperties/Xamarin.Test.SomeObject.cs new file mode 100644 index 000000000..d380412f9 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/StaticProperties/Xamarin.Test.SomeObject.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" + [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + public partial class SomeObject : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + public static unsafe int SomeInteger { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeInteger' and count(parameter)=0]" + [Register ("getSomeInteger", "()I", "")] + get { + const string __id = "getSomeInteger.()I"; + try { + var __rm = _members.StaticMethods.InvokeInt32Method (__id, null); + return __rm; + } finally { + } + } + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeInteger' and count(parameter)=1 and parameter[1][@type='int']]" + [Register ("setSomeInteger", "(I)V", "")] + set { + const string __id = "setSomeInteger.(I)V"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (value); + _members.StaticMethods.InvokeVoidMethod (__id, __args); + } finally { + } + } + } + + public static unsafe string SomeString { + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeString' and count(parameter)=0]" + [Register ("getSomeString", "()Ljava/lang/String;", "")] + get { + const string __id = "getSomeString.()Ljava/lang/String;"; + try { + var __rm = _members.StaticMethods.InvokeObjectMethod (__id, null); + return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeString' and count(parameter)=1 and parameter[1][@type='java.lang.String']]" + [Register ("setSomeString", "(Ljava/lang/String;)V", "")] + set { + const string __id = "setSomeString.(Ljava/lang/String;)V"; + IntPtr native_value = JNIEnv.NewString (value); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_value); + _members.StaticMethods.InvokeVoidMethod (__id, __args); + } finally { + JNIEnv.DeleteLocalRef (native_value); + } + } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getSomeObject' and count(parameter)=0]" + [Register ("getSomeObject", "()Ljava/lang/Object;", "")] + public static unsafe global::Java.Lang.Object GetSomeObject () + { + const string __id = "getSomeObject.()Ljava/lang/Object;"; + try { + var __rm = _members.StaticMethods.InvokeObjectMethod (__id, null); + return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='setSomeObject' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" + [Register ("setSomeObject", "(Ljava/lang/Object;)V", "")] + public static unsafe void SetSomeObject (global::Java.Lang.Object newvalue) + { + const string __id = "setSomeObject.(Ljava/lang/Object;)V"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue ((newvalue == null) ? IntPtr.Zero : ((global::Java.Lang.Object) newvalue).Handle); + _members.StaticMethods.InvokeVoidMethod (__id, __args); + } finally { + global::System.GC.KeepAlive (newvalue); + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/StaticProperties/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/StaticProperties/__NamespaceMapping__.cs new file mode 100644 index 000000000..e9b0e4292 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/StaticProperties/__NamespaceMapping__.cs @@ -0,0 +1,15 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/StaticProperties/enumlist b/tests/generator-Tests/expected.xaji/StaticProperties/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.xaji/Streams/Java.IO.FilterOutputStream.cs b/tests/generator-Tests/expected.xaji/Streams/Java.IO.FilterOutputStream.cs new file mode 100644 index 000000000..db367cc52 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Streams/Java.IO.FilterOutputStream.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.IO { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.io']/class[@name='FilterOutputStream']" + [global::Android.Runtime.Register ("java/io/FilterOutputStream", DoNotGenerateAcw=true)] + public partial class FilterOutputStream : global::Java.IO.OutputStream { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/io/FilterOutputStream", typeof (FilterOutputStream)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected FilterOutputStream (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='java.io']/class[@name='FilterOutputStream']/constructor[@name='FilterOutputStream' and count(parameter)=1 and parameter[1][@type='java.io.OutputStream']]" + [Register (".ctor", "(Ljava/io/OutputStream;)V", "")] + public unsafe FilterOutputStream (global::System.IO.Stream @out) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "(Ljava/io/OutputStream;)V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + IntPtr native__out = global::Android.Runtime.OutputStreamAdapter.ToLocalJniHandle (@out); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native__out); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, __args); + } finally { + JNIEnv.DeleteLocalRef (native__out); + global::System.GC.KeepAlive (@out); + } + } + + static Delegate cb_write_I; +#pragma warning disable 0169 + static Delegate GetWrite_IHandler () + { + if (cb_write_I == null) + cb_write_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_Write_I); + return cb_write_I; + } + + static void n_Write_I (IntPtr jnienv, IntPtr native__this, int oneByte) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Write (oneByte); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='FilterOutputStream']/method[@name='write' and count(parameter)=1 and parameter[1][@type='int']]" + [Register ("write", "(I)V", "GetWrite_IHandler")] + public override unsafe void Write (int oneByte) + { + const string __id = "write.(I)V"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (oneByte); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Streams/Java.IO.IOException.cs b/tests/generator-Tests/expected.xaji/Streams/Java.IO.IOException.cs new file mode 100644 index 000000000..06e9f376d --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Streams/Java.IO.IOException.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.IO { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.io']/class[@name='IOException']" + [global::Android.Runtime.Register ("java/io/IOException", DoNotGenerateAcw=true)] + public abstract partial class IOException : global::Java.Lang.Throwable { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/io/IOException", typeof (IOException)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected IOException (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + static Delegate cb_printStackTrace; +#pragma warning disable 0169 + static Delegate GetPrintStackTraceHandler () + { + if (cb_printStackTrace == null) + cb_printStackTrace = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_PrintStackTrace); + return cb_printStackTrace; + } + + static void n_PrintStackTrace (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.PrintStackTrace (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='IOException']/method[@name='printStackTrace' and count(parameter)=0]" + [Register ("printStackTrace", "()V", "GetPrintStackTraceHandler")] + public virtual unsafe void PrintStackTrace () + { + const string __id = "printStackTrace.()V"; + try { + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null); + } finally { + } + } + + } + + [global::Android.Runtime.Register ("java/io/IOException", DoNotGenerateAcw=true)] + internal partial class IOExceptionInvoker : IOException { + public IOExceptionInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + { + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("java/io/IOException", typeof (IOExceptionInvoker)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Streams/Java.IO.InputStream.cs b/tests/generator-Tests/expected.xaji/Streams/Java.IO.InputStream.cs new file mode 100644 index 000000000..c58a4991a --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Streams/Java.IO.InputStream.cs @@ -0,0 +1,362 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.IO { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.io']/class[@name='InputStream']" + [global::Android.Runtime.Register ("java/io/InputStream", DoNotGenerateAcw=true)] + public abstract partial class InputStream : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/io/InputStream", typeof (InputStream)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected InputStream (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='java.io']/class[@name='InputStream']/constructor[@name='InputStream' and count(parameter)=0]" + [Register (".ctor", "()V", "")] + public unsafe InputStream () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "()V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + static Delegate cb_available; +#pragma warning disable 0169 + static Delegate GetAvailableHandler () + { + if (cb_available == null) + cb_available = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_Available); + return cb_available; + } + + static int n_Available (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return __this.Available (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='available' and count(parameter)=0]" + [Register ("available", "()I", "GetAvailableHandler")] + public virtual unsafe int Available () + { + const string __id = "available.()I"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, null); + return __rm; + } finally { + } + } + + static Delegate cb_close; +#pragma warning disable 0169 + static Delegate GetCloseHandler () + { + if (cb_close == null) + cb_close = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Close); + return cb_close; + } + + static void n_Close (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Close (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='close' and count(parameter)=0]" + [Register ("close", "()V", "GetCloseHandler")] + public virtual unsafe void Close () + { + const string __id = "close.()V"; + try { + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null); + } finally { + } + } + + static Delegate cb_mark_I; +#pragma warning disable 0169 + static Delegate GetMark_IHandler () + { + if (cb_mark_I == null) + cb_mark_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_Mark_I); + return cb_mark_I; + } + + static void n_Mark_I (IntPtr jnienv, IntPtr native__this, int readlimit) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Mark (readlimit); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='mark' and count(parameter)=1 and parameter[1][@type='int']]" + [Register ("mark", "(I)V", "GetMark_IHandler")] + public virtual unsafe void Mark (int readlimit) + { + const string __id = "mark.(I)V"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (readlimit); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + } + } + + static Delegate cb_markSupported; +#pragma warning disable 0169 + static Delegate GetMarkSupportedHandler () + { + if (cb_markSupported == null) + cb_markSupported = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_Z) n_MarkSupported); + return cb_markSupported; + } + + static bool n_MarkSupported (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return __this.MarkSupported (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='markSupported' and count(parameter)=0]" + [Register ("markSupported", "()Z", "GetMarkSupportedHandler")] + public virtual unsafe bool MarkSupported () + { + const string __id = "markSupported.()Z"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualBooleanMethod (__id, this, null); + return __rm; + } finally { + } + } + + static Delegate cb_read; +#pragma warning disable 0169 + static Delegate GetReadHandler () + { + if (cb_read == null) + cb_read = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_I) n_Read); + return cb_read; + } + + static int n_Read (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return __this.Read (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='read' and count(parameter)=0]" + [Register ("read", "()I", "GetReadHandler")] + public abstract int Read (); + + static Delegate cb_read_arrayB; +#pragma warning disable 0169 + static Delegate GetRead_arrayBHandler () + { + if (cb_read_arrayB == null) + cb_read_arrayB = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_Read_arrayB); + return cb_read_arrayB; + } + + static int n_Read_arrayB (IntPtr jnienv, IntPtr native__this, IntPtr native_buffer) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var buffer = (byte[]) JNIEnv.GetArray (native_buffer, JniHandleOwnership.DoNotTransfer, typeof (byte)); + int __ret = __this.Read (buffer); + if (buffer != null) + JNIEnv.CopyArray (buffer, native_buffer); + return __ret; + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='read' and count(parameter)=1 and parameter[1][@type='byte[]']]" + [Register ("read", "([B)I", "GetRead_arrayBHandler")] + public virtual unsafe int Read (byte[] buffer) + { + const string __id = "read.([B)I"; + IntPtr native_buffer = JNIEnv.NewArray (buffer); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_buffer); + var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, __args); + return __rm; + } finally { + if (buffer != null) { + JNIEnv.CopyArray (native_buffer, buffer); + JNIEnv.DeleteLocalRef (native_buffer); + } + global::System.GC.KeepAlive (buffer); + } + } + + static Delegate cb_read_arrayBII; +#pragma warning disable 0169 + static Delegate GetRead_arrayBIIHandler () + { + if (cb_read_arrayBII == null) + cb_read_arrayBII = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPLII_I) n_Read_arrayBII); + return cb_read_arrayBII; + } + + static int n_Read_arrayBII (IntPtr jnienv, IntPtr native__this, IntPtr native_buffer, int byteOffset, int byteCount) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var buffer = (byte[]) JNIEnv.GetArray (native_buffer, JniHandleOwnership.DoNotTransfer, typeof (byte)); + int __ret = __this.Read (buffer, byteOffset, byteCount); + if (buffer != null) + JNIEnv.CopyArray (buffer, native_buffer); + return __ret; + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='read' and count(parameter)=3 and parameter[1][@type='byte[]'] and parameter[2][@type='int'] and parameter[3][@type='int']]" + [Register ("read", "([BII)I", "GetRead_arrayBIIHandler")] + public virtual unsafe int Read (byte[] buffer, int byteOffset, int byteCount) + { + const string __id = "read.([BII)I"; + IntPtr native_buffer = JNIEnv.NewArray (buffer); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [3]; + __args [0] = new JniArgumentValue (native_buffer); + __args [1] = new JniArgumentValue (byteOffset); + __args [2] = new JniArgumentValue (byteCount); + var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, __args); + return __rm; + } finally { + if (buffer != null) { + JNIEnv.CopyArray (native_buffer, buffer); + JNIEnv.DeleteLocalRef (native_buffer); + } + global::System.GC.KeepAlive (buffer); + } + } + + static Delegate cb_reset; +#pragma warning disable 0169 + static Delegate GetResetHandler () + { + if (cb_reset == null) + cb_reset = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Reset); + return cb_reset; + } + + static void n_Reset (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Reset (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='reset' and count(parameter)=0]" + [Register ("reset", "()V", "GetResetHandler")] + public virtual unsafe void Reset () + { + const string __id = "reset.()V"; + try { + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null); + } finally { + } + } + + static Delegate cb_skip_J; +#pragma warning disable 0169 + static Delegate GetSkip_JHandler () + { + if (cb_skip_J == null) + cb_skip_J = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPJ_J) n_Skip_J); + return cb_skip_J; + } + + static long n_Skip_J (IntPtr jnienv, IntPtr native__this, long byteCount) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return __this.Skip (byteCount); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='skip' and count(parameter)=1 and parameter[1][@type='long']]" + [Register ("skip", "(J)J", "GetSkip_JHandler")] + public virtual unsafe long Skip (long byteCount) + { + const string __id = "skip.(J)J"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (byteCount); + var __rm = _members.InstanceMethods.InvokeVirtualInt64Method (__id, this, __args); + return __rm; + } finally { + } + } + + } + + [global::Android.Runtime.Register ("java/io/InputStream", DoNotGenerateAcw=true)] + internal partial class InputStreamInvoker : InputStream { + public InputStreamInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + { + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("java/io/InputStream", typeof (InputStreamInvoker)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='InputStream']/method[@name='read' and count(parameter)=0]" + [Register ("read", "()I", "GetReadHandler")] + public override unsafe int Read () + { + const string __id = "read.()I"; + try { + var __rm = _members.InstanceMethods.InvokeAbstractInt32Method (__id, this, null); + return __rm; + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Streams/Java.IO.OutputStream.cs b/tests/generator-Tests/expected.xaji/Streams/Java.IO.OutputStream.cs new file mode 100644 index 000000000..f3bd27f36 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Streams/Java.IO.OutputStream.cs @@ -0,0 +1,244 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.IO { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.io']/class[@name='OutputStream']" + [global::Android.Runtime.Register ("java/io/OutputStream", DoNotGenerateAcw=true)] + public abstract partial class OutputStream : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/io/OutputStream", typeof (OutputStream)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected OutputStream (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='java.io']/class[@name='OutputStream']/constructor[@name='OutputStream' and count(parameter)=0]" + [Register (".ctor", "()V", "")] + public unsafe OutputStream () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "()V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + static Delegate cb_close; +#pragma warning disable 0169 + static Delegate GetCloseHandler () + { + if (cb_close == null) + cb_close = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Close); + return cb_close; + } + + static void n_Close (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Close (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='OutputStream']/method[@name='close' and count(parameter)=0]" + [Register ("close", "()V", "GetCloseHandler")] + public virtual unsafe void Close () + { + const string __id = "close.()V"; + try { + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null); + } finally { + } + } + + static Delegate cb_flush; +#pragma warning disable 0169 + static Delegate GetFlushHandler () + { + if (cb_flush == null) + cb_flush = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Flush); + return cb_flush; + } + + static void n_Flush (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Flush (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='OutputStream']/method[@name='flush' and count(parameter)=0]" + [Register ("flush", "()V", "GetFlushHandler")] + public virtual unsafe void Flush () + { + const string __id = "flush.()V"; + try { + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null); + } finally { + } + } + + static Delegate cb_write_arrayB; +#pragma warning disable 0169 + static Delegate GetWrite_arrayBHandler () + { + if (cb_write_arrayB == null) + cb_write_arrayB = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_Write_arrayB); + return cb_write_arrayB; + } + + static void n_Write_arrayB (IntPtr jnienv, IntPtr native__this, IntPtr native_buffer) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var buffer = (byte[]) JNIEnv.GetArray (native_buffer, JniHandleOwnership.DoNotTransfer, typeof (byte)); + __this.Write (buffer); + if (buffer != null) + JNIEnv.CopyArray (buffer, native_buffer); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='OutputStream']/method[@name='write' and count(parameter)=1 and parameter[1][@type='byte[]']]" + [Register ("write", "([B)V", "GetWrite_arrayBHandler")] + public virtual unsafe void Write (byte[] buffer) + { + const string __id = "write.([B)V"; + IntPtr native_buffer = JNIEnv.NewArray (buffer); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_buffer); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + if (buffer != null) { + JNIEnv.CopyArray (native_buffer, buffer); + JNIEnv.DeleteLocalRef (native_buffer); + } + global::System.GC.KeepAlive (buffer); + } + } + + static Delegate cb_write_arrayBII; +#pragma warning disable 0169 + static Delegate GetWrite_arrayBIIHandler () + { + if (cb_write_arrayBII == null) + cb_write_arrayBII = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPLII_V) n_Write_arrayBII); + return cb_write_arrayBII; + } + + static void n_Write_arrayBII (IntPtr jnienv, IntPtr native__this, IntPtr native_buffer, int offset, int count) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var buffer = (byte[]) JNIEnv.GetArray (native_buffer, JniHandleOwnership.DoNotTransfer, typeof (byte)); + __this.Write (buffer, offset, count); + if (buffer != null) + JNIEnv.CopyArray (buffer, native_buffer); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='OutputStream']/method[@name='write' and count(parameter)=3 and parameter[1][@type='byte[]'] and parameter[2][@type='int'] and parameter[3][@type='int']]" + [Register ("write", "([BII)V", "GetWrite_arrayBIIHandler")] + public virtual unsafe void Write (byte[] buffer, int offset, int count) + { + const string __id = "write.([BII)V"; + IntPtr native_buffer = JNIEnv.NewArray (buffer); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [3]; + __args [0] = new JniArgumentValue (native_buffer); + __args [1] = new JniArgumentValue (offset); + __args [2] = new JniArgumentValue (count); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + if (buffer != null) { + JNIEnv.CopyArray (native_buffer, buffer); + JNIEnv.DeleteLocalRef (native_buffer); + } + global::System.GC.KeepAlive (buffer); + } + } + + static Delegate cb_write_I; +#pragma warning disable 0169 + static Delegate GetWrite_IHandler () + { + if (cb_write_I == null) + cb_write_I = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPI_V) n_Write_I); + return cb_write_I; + } + + static void n_Write_I (IntPtr jnienv, IntPtr native__this, int oneByte) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Write (oneByte); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='OutputStream']/method[@name='write' and count(parameter)=1 and parameter[1][@type='int']]" + [Register ("write", "(I)V", "GetWrite_IHandler")] + public abstract void Write (int oneByte); + + } + + [global::Android.Runtime.Register ("java/io/OutputStream", DoNotGenerateAcw=true)] + internal partial class OutputStreamInvoker : OutputStream { + public OutputStreamInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + { + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("java/io/OutputStream", typeof (OutputStreamInvoker)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='java.io']/class[@name='OutputStream']/method[@name='write' and count(parameter)=1 and parameter[1][@type='int']]" + [Register ("write", "(I)V", "GetWrite_IHandler")] + public override unsafe void Write (int oneByte) + { + const string __id = "write.(I)V"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (oneByte); + _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args); + } finally { + } + } + + } +} diff --git a/tests/generator-Tests/expected.ji/java.lang.Object/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/Streams/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/java.lang.Object/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/Streams/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/Streams/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/Streams/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Streams/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Streams/Java.Lang.Throwable.cs b/tests/generator-Tests/expected.xaji/Streams/Java.Lang.Throwable.cs new file mode 100644 index 000000000..5687244ed --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Streams/Java.Lang.Throwable.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Throwable']" + [global::Android.Runtime.Register ("java/lang/Throwable", DoNotGenerateAcw=true)] + public partial class Throwable { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Throwable", typeof (Throwable)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + static Delegate cb_getMessage; +#pragma warning disable 0169 + static Delegate GetGetMessageHandler () + { + if (cb_getMessage == null) + cb_getMessage = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetMessage); + return cb_getMessage; + } + + static IntPtr n_GetMessage (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.NewString (__this.Message); + } +#pragma warning restore 0169 + + public new virtual unsafe string Message { + // Metadata.xml XPath method reference: path="/api/package[@name='java.lang']/class[@name='Throwable']/method[@name='getMessage' and count(parameter)=0]" + [Register ("getMessage", "()Ljava/lang/String;", "GetGetMessageHandler")] + get { + const string __id = "getMessage.()Ljava/lang/String;"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); + return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/Streams/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/Streams/Mono.Android.projitems new file mode 100644 index 000000000..3d19ddac3 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Streams/Mono.Android.projitems @@ -0,0 +1,19 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/Streams/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/Streams/__NamespaceMapping__.cs new file mode 100644 index 000000000..814865162 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/Streams/__NamespaceMapping__.cs @@ -0,0 +1,25 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.io", Managed="Java.IO")] + +delegate int _JniMarshal_PP_I (IntPtr jnienv, IntPtr klass); +delegate IntPtr _JniMarshal_PP_L (IntPtr jnienv, IntPtr klass); +delegate void _JniMarshal_PP_V (IntPtr jnienv, IntPtr klass); +delegate bool _JniMarshal_PP_Z (IntPtr jnienv, IntPtr klass); +delegate void _JniMarshal_PPI_V (IntPtr jnienv, IntPtr klass, int p0); +delegate long _JniMarshal_PPJ_J (IntPtr jnienv, IntPtr klass, long p0); +delegate int _JniMarshal_PPL_I (IntPtr jnienv, IntPtr klass, IntPtr p0); +delegate void _JniMarshal_PPL_V (IntPtr jnienv, IntPtr klass, IntPtr p0); +delegate int _JniMarshal_PPLII_I (IntPtr jnienv, IntPtr klass, IntPtr p0, int p1, int p2); +delegate void _JniMarshal_PPLII_V (IntPtr jnienv, IntPtr klass, IntPtr p0, int p1, int p2); +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/Streams/enumlist b/tests/generator-Tests/expected.xaji/Streams/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.xaji/TestInterface/ClassWithoutNamespace.cs b/tests/generator-Tests/expected.xaji/TestInterface/ClassWithoutNamespace.cs new file mode 100644 index 000000000..d811133c3 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/TestInterface/ClassWithoutNamespace.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +// Metadata.xml XPath class reference: path="/api/package[@name='']/class[@name='ClassWithoutNamespace']" +[global::Android.Runtime.Register ("ClassWithoutNamespace", DoNotGenerateAcw=true)] +public abstract partial class ClassWithoutNamespace : global::Java.Lang.Object, IInterfaceWithoutNamespace { + static readonly JniPeerMembers _members = new XAPeerMembers ("ClassWithoutNamespace", typeof (ClassWithoutNamespace)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected ClassWithoutNamespace (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='']/class[@name='ClassWithoutNamespace']/constructor[@name='ClassWithoutNamespace' and count(parameter)=0]" + [Register (".ctor", "()V", "")] + public unsafe ClassWithoutNamespace () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "()V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + static Delegate cb_Foo; +#pragma warning disable 0169 + static Delegate GetFooHandler () + { + if (cb_Foo == null) + cb_Foo = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Foo); + return cb_Foo; + } + + static void n_Foo (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Foo (); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='']/interface[@name='InterfaceWithoutNamespace']/method[@name='Foo' and count(parameter)=0]" + [Register ("Foo", "()V", "GetFooHandler")] + public abstract void Foo (); + +} + +[global::Android.Runtime.Register ("ClassWithoutNamespace", DoNotGenerateAcw=true)] +internal partial class ClassWithoutNamespaceInvoker : ClassWithoutNamespace { + public ClassWithoutNamespaceInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + { + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("ClassWithoutNamespace", typeof (ClassWithoutNamespaceInvoker)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='']/interface[@name='InterfaceWithoutNamespace']/method[@name='Foo' and count(parameter)=0]" + [Register ("Foo", "()V", "GetFooHandler")] + public override unsafe void Foo () + { + const string __id = "Foo.()V"; + try { + _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, null); + } finally { + } + } + +} diff --git a/tests/generator-Tests/expected.xaji/TestInterface/IInterfaceWithoutNamespace.cs b/tests/generator-Tests/expected.xaji/TestInterface/IInterfaceWithoutNamespace.cs new file mode 100644 index 000000000..379f08295 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/TestInterface/IInterfaceWithoutNamespace.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +// Metadata.xml XPath interface reference: path="/api/package[@name='']/interface[@name='InterfaceWithoutNamespace']" +[Register ("InterfaceWithoutNamespace", "", "IInterfaceWithoutNamespaceInvoker")] +public partial interface IInterfaceWithoutNamespace : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='']/interface[@name='InterfaceWithoutNamespace']/method[@name='Foo' and count(parameter)=0]" + [Register ("Foo", "()V", "GetFooHandler:IInterfaceWithoutNamespaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + void Foo (); + +} + +[global::Android.Runtime.Register ("InterfaceWithoutNamespace", DoNotGenerateAcw=true)] +internal partial class IInterfaceWithoutNamespaceInvoker : global::Java.Lang.Object, IInterfaceWithoutNamespace { + static readonly JniPeerMembers _members = new XAPeerMembers ("InterfaceWithoutNamespace", typeof (IInterfaceWithoutNamespaceInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static IInterfaceWithoutNamespace GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'InterfaceWithoutNamespace'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public IInterfaceWithoutNamespaceInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_Foo; +#pragma warning disable 0169 + static Delegate GetFooHandler () + { + if (cb_Foo == null) + cb_Foo = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_Foo); + return cb_Foo; + } + + static void n_Foo (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + __this.Foo (); + } +#pragma warning restore 0169 + + IntPtr id_Foo; + public unsafe void Foo () + { + if (id_Foo == IntPtr.Zero) + id_Foo = JNIEnv.GetMethodID (class_ref, "Foo", "()V"); + JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_Foo); + } + +} diff --git a/tests/generator-Tests/expected.ji/java.util.List/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/TestInterface/Java.Interop.__TypeRegistrations.cs similarity index 100% rename from tests/generator-Tests/expected.ji/java.util.List/Java.Interop.__TypeRegistrations.cs rename to tests/generator-Tests/expected.xaji/TestInterface/Java.Interop.__TypeRegistrations.cs diff --git a/tests/generator-Tests/expected.xaji/TestInterface/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/TestInterface/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/TestInterface/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/TestInterface/Java.Lang.String.cs b/tests/generator-Tests/expected.xaji/TestInterface/Java.Lang.String.cs new file mode 100644 index 000000000..660b75317 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/TestInterface/Java.Lang.String.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='String']" + [global::Android.Runtime.Register ("java/lang/String", DoNotGenerateAcw=true)] + public sealed partial class String : global::Java.Lang.Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/String", typeof (String)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + internal String (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/TestInterface/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/TestInterface/Mono.Android.projitems new file mode 100644 index 000000000..5a3e90231 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/TestInterface/Mono.Android.projitems @@ -0,0 +1,25 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.GenericImplementation.cs b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.GenericImplementation.cs new file mode 100644 index 000000000..f68437bb2 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.GenericImplementation.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Test.ME { + + // Metadata.xml XPath class reference: path="/api/package[@name='test.me']/class[@name='GenericImplementation']" + [global::Android.Runtime.Register ("test/me/GenericImplementation", DoNotGenerateAcw=true)] + public partial class GenericImplementation : global::Java.Lang.Object, global::Test.ME.IGenericInterface { + static readonly JniPeerMembers _members = new XAPeerMembers ("test/me/GenericImplementation", typeof (GenericImplementation)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected GenericImplementation (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='test.me']/class[@name='GenericImplementation']/constructor[@name='GenericImplementation' and count(parameter)=0]" + [Register (".ctor", "()V", "")] + public unsafe GenericImplementation () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "()V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + static Delegate cb_SetObject_arrayB; +#pragma warning disable 0169 + static Delegate GetSetObject_arrayBHandler () + { + if (cb_SetObject_arrayB == null) + cb_SetObject_arrayB = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetObject_arrayB); + return cb_SetObject_arrayB; + } + + static void n_SetObject_arrayB (IntPtr jnienv, IntPtr native__this, IntPtr native_value) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var value = (byte[]) JNIEnv.GetArray (native_value, JniHandleOwnership.DoNotTransfer, typeof (byte)); + __this.SetObject (value); + if (value != null) + JNIEnv.CopyArray (value, native_value); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/class[@name='GenericImplementation']/method[@name='SetObject' and count(parameter)=1 and parameter[1][@type='byte[]']]" + [Register ("SetObject", "([B)V", "GetSetObject_arrayBHandler")] + public virtual unsafe void SetObject (byte[] value) + { + const string __id = "SetObject.([B)V"; + IntPtr native_value = JNIEnv.NewArray (value); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_value); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + if (value != null) { + JNIEnv.CopyArray (native_value, value); + JNIEnv.DeleteLocalRef (native_value); + } + global::System.GC.KeepAlive (value); + } + } + + // This method is explicitly implemented as a member of an instantiated Test.ME.IGenericInterface + void global::Test.ME.IGenericInterface.SetObject (global::Java.Lang.Object value) + { + SetObject (value.ToArray ()); + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.GenericObjectPropertyImplementation.cs b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.GenericObjectPropertyImplementation.cs new file mode 100644 index 000000000..3679f00c9 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.GenericObjectPropertyImplementation.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Test.ME { + + // Metadata.xml XPath class reference: path="/api/package[@name='test.me']/class[@name='GenericObjectPropertyImplementation']" + [global::Android.Runtime.Register ("test/me/GenericObjectPropertyImplementation", DoNotGenerateAcw=true)] + public partial class GenericObjectPropertyImplementation : global::Java.Lang.Object, global::Test.ME.IGenericPropertyInterface { + static readonly JniPeerMembers _members = new XAPeerMembers ("test/me/GenericObjectPropertyImplementation", typeof (GenericObjectPropertyImplementation)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected GenericObjectPropertyImplementation (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='test.me']/class[@name='GenericObjectPropertyImplementation']/constructor[@name='GenericObjectPropertyImplementation' and count(parameter)=0]" + [Register (".ctor", "()V", "")] + public unsafe GenericObjectPropertyImplementation () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "()V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + static Delegate cb_getObject; +#pragma warning disable 0169 + static Delegate GetGetObjectHandler () + { + if (cb_getObject == null) + cb_getObject = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetObject); + return cb_getObject; + } + + static IntPtr n_GetObject (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.ToLocalJniHandle (__this.Object); + } +#pragma warning restore 0169 + + static Delegate cb_setObject_Ljava_lang_Object_; +#pragma warning disable 0169 + static Delegate GetSetObject_Ljava_lang_Object_Handler () + { + if (cb_setObject_Ljava_lang_Object_ == null) + cb_setObject_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetObject_Ljava_lang_Object_); + return cb_setObject_Ljava_lang_Object_; + } + + static void n_SetObject_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var value = global::Java.Lang.Object.GetObject (native_value, JniHandleOwnership.DoNotTransfer); + __this.Object = value; + } +#pragma warning restore 0169 + + public virtual unsafe global::Java.Lang.Object Object { + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/class[@name='GenericObjectPropertyImplementation']/method[@name='getObject' and count(parameter)=0]" + [Register ("getObject", "()Ljava/lang/Object;", "GetGetObjectHandler")] + get { + const string __id = "getObject.()Ljava/lang/Object;"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); + return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/class[@name='GenericObjectPropertyImplementation']/method[@name='setObject' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" + [Register ("setObject", "(Ljava/lang/Object;)V", "GetSetObject_Ljava_lang_Object_Handler")] + set { + const string __id = "setObject.(Ljava/lang/Object;)V"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue ((value == null) ? IntPtr.Zero : ((global::Java.Lang.Object) value).Handle); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + global::System.GC.KeepAlive (value); + } + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.GenericStringImplementation.cs b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.GenericStringImplementation.cs new file mode 100644 index 000000000..12d584ea4 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.GenericStringImplementation.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Test.ME { + + // Metadata.xml XPath class reference: path="/api/package[@name='test.me']/class[@name='GenericStringImplementation']" + [global::Android.Runtime.Register ("test/me/GenericStringImplementation", DoNotGenerateAcw=true)] + public partial class GenericStringImplementation : global::Java.Lang.Object, global::Test.ME.IGenericInterface { + static readonly JniPeerMembers _members = new XAPeerMembers ("test/me/GenericStringImplementation", typeof (GenericStringImplementation)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected GenericStringImplementation (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='test.me']/class[@name='GenericStringImplementation']/constructor[@name='GenericStringImplementation' and count(parameter)=0]" + [Register (".ctor", "()V", "")] + public unsafe GenericStringImplementation () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "()V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + static Delegate cb_SetObject_arrayLjava_lang_String_; +#pragma warning disable 0169 + static Delegate GetSetObject_arrayLjava_lang_String_Handler () + { + if (cb_SetObject_arrayLjava_lang_String_ == null) + cb_SetObject_arrayLjava_lang_String_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetObject_arrayLjava_lang_String_); + return cb_SetObject_arrayLjava_lang_String_; + } + + static void n_SetObject_arrayLjava_lang_String_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var value = (string[]) JNIEnv.GetArray (native_value, JniHandleOwnership.DoNotTransfer, typeof (string)); + __this.SetObject (value); + if (value != null) + JNIEnv.CopyArray (value, native_value); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/class[@name='GenericStringImplementation']/method[@name='SetObject' and count(parameter)=1 and parameter[1][@type='java.lang.String[]']]" + [Register ("SetObject", "([Ljava/lang/String;)V", "GetSetObject_arrayLjava_lang_String_Handler")] + public virtual unsafe void SetObject (string[] value) + { + const string __id = "SetObject.([Ljava/lang/String;)V"; + IntPtr native_value = JNIEnv.NewArray (value); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_value); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + if (value != null) { + JNIEnv.CopyArray (native_value, value); + JNIEnv.DeleteLocalRef (native_value); + } + global::System.GC.KeepAlive (value); + } + } + + // This method is explicitly implemented as a member of an instantiated Test.ME.IGenericInterface + void global::Test.ME.IGenericInterface.SetObject (global::Java.Lang.Object value) + { + SetObject (value.ToArray ()); + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.GenericStringPropertyImplementation.cs b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.GenericStringPropertyImplementation.cs new file mode 100644 index 000000000..f40f509ee --- /dev/null +++ b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.GenericStringPropertyImplementation.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Test.ME { + + // Metadata.xml XPath class reference: path="/api/package[@name='test.me']/class[@name='GenericStringPropertyImplementation']" + [global::Android.Runtime.Register ("test/me/GenericStringPropertyImplementation", DoNotGenerateAcw=true)] + public partial class GenericStringPropertyImplementation : global::Java.Lang.Object, global::Test.ME.IGenericPropertyInterface { + static readonly JniPeerMembers _members = new XAPeerMembers ("test/me/GenericStringPropertyImplementation", typeof (GenericStringPropertyImplementation)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected GenericStringPropertyImplementation (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='test.me']/class[@name='GenericStringPropertyImplementation']/constructor[@name='GenericStringPropertyImplementation' and count(parameter)=0]" + [Register (".ctor", "()V", "")] + public unsafe GenericStringPropertyImplementation () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "()V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + static Delegate cb_getObject; +#pragma warning disable 0169 + static Delegate GetGetObjectHandler () + { + if (cb_getObject == null) + cb_getObject = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetObject); + return cb_getObject; + } + + static IntPtr n_GetObject (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.NewString (__this.Object); + } +#pragma warning restore 0169 + + static Delegate cb_SetObject_Ljava_lang_String_; +#pragma warning disable 0169 + static Delegate GetSetObject_Ljava_lang_String_Handler () + { + if (cb_SetObject_Ljava_lang_String_ == null) + cb_SetObject_Ljava_lang_String_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetObject_Ljava_lang_String_); + return cb_SetObject_Ljava_lang_String_; + } + + static void n_SetObject_Ljava_lang_String_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var value = JNIEnv.GetString (native_value, JniHandleOwnership.DoNotTransfer); + __this.Object = value; + } +#pragma warning restore 0169 + + public virtual unsafe string Object { + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/class[@name='GenericStringPropertyImplementation']/method[@name='getObject' and count(parameter)=0]" + [Register ("getObject", "()Ljava/lang/String;", "GetGetObjectHandler")] + get { + const string __id = "getObject.()Ljava/lang/String;"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); + return JNIEnv.GetString (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + } + } + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/class[@name='GenericStringPropertyImplementation']/method[@name='SetObject' and count(parameter)=1 and parameter[1][@type='java.lang.String']]" + [Register ("SetObject", "(Ljava/lang/String;)V", "GetSetObject_Ljava_lang_String_Handler")] + set { + const string __id = "SetObject.(Ljava/lang/String;)V"; + IntPtr native_value = JNIEnv.NewString (value); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_value); + _members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args); + } finally { + JNIEnv.DeleteLocalRef (native_value); + } + } + } + + // This method is explicitly implemented as a member of an instantiated Test.ME.IGenericPropertyInterface + global::Java.Lang.Object global::Test.ME.IGenericPropertyInterface.Object { + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='GenericPropertyInterface']/method[@name='getObject' and count(parameter)=0]" + [Register ("getObject", "()Ljava/lang/Object;", "GetGetObjectHandler:Test.ME.IGenericPropertyInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + get { return Object; } + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='GenericPropertyInterface']/method[@name='setObject' and count(parameter)=1 and parameter[1][@type='T']]" + [Register ("setObject", "(Ljava/lang/Object;)V", "GetSetObject_Ljava_lang_Object_Handler:Test.ME.IGenericPropertyInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + set { Object = value.ToString (); } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.IGenericInterface.cs b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.IGenericInterface.cs new file mode 100644 index 000000000..5f56ad2ba --- /dev/null +++ b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.IGenericInterface.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Test.ME { + + // Metadata.xml XPath interface reference: path="/api/package[@name='test.me']/interface[@name='GenericInterface']" + [Register ("test/me/GenericInterface", "", "Test.ME.IGenericInterfaceInvoker")] + [global::Java.Interop.JavaTypeParameters (new string [] {"T"})] + public partial interface IGenericInterface : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='GenericInterface']/method[@name='SetObject' and count(parameter)=1 and parameter[1][@type='T']]" + [Register ("SetObject", "(Ljava/lang/Object;)V", "GetSetObject_Ljava_lang_Object_Handler:Test.ME.IGenericInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + void SetObject (global::Java.Lang.Object value); + + } + + [global::Android.Runtime.Register ("test/me/GenericInterface", DoNotGenerateAcw=true)] + internal partial class IGenericInterfaceInvoker : global::Java.Lang.Object, IGenericInterface { + static readonly JniPeerMembers _members = new XAPeerMembers ("test/me/GenericInterface", typeof (IGenericInterfaceInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static IGenericInterface GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'test.me.GenericInterface'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public IGenericInterfaceInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_SetObject_Ljava_lang_Object_; +#pragma warning disable 0169 + static Delegate GetSetObject_Ljava_lang_Object_Handler () + { + if (cb_SetObject_Ljava_lang_Object_ == null) + cb_SetObject_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetObject_Ljava_lang_Object_); + return cb_SetObject_Ljava_lang_Object_; + } + + static void n_SetObject_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var value = global::Java.Lang.Object.GetObject (native_value, JniHandleOwnership.DoNotTransfer); + __this.SetObject (value); + } +#pragma warning restore 0169 + + IntPtr id_SetObject_Ljava_lang_Object_; + public unsafe void SetObject (global::Java.Lang.Object value) + { + if (id_SetObject_Ljava_lang_Object_ == IntPtr.Zero) + id_SetObject_Ljava_lang_Object_ = JNIEnv.GetMethodID (class_ref, "SetObject", "(Ljava/lang/Object;)V"); + IntPtr native_value = JNIEnv.ToLocalJniHandle (value); + JValue* __args = stackalloc JValue [1]; + __args [0] = new JValue (native_value); + JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_SetObject_Ljava_lang_Object_, __args); + JNIEnv.DeleteLocalRef (native_value); + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.IGenericPropertyInterface.cs b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.IGenericPropertyInterface.cs new file mode 100644 index 000000000..11c5b47d9 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.IGenericPropertyInterface.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Test.ME { + + // Metadata.xml XPath interface reference: path="/api/package[@name='test.me']/interface[@name='GenericPropertyInterface']" + [Register ("test/me/GenericPropertyInterface", "", "Test.ME.IGenericPropertyInterfaceInvoker")] + [global::Java.Interop.JavaTypeParameters (new string [] {"T"})] + public partial interface IGenericPropertyInterface : IJavaObject, IJavaPeerable { + global::Java.Lang.Object Object { + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='GenericPropertyInterface']/method[@name='getObject' and count(parameter)=0]" + [Register ("getObject", "()Ljava/lang/Object;", "GetGetObjectHandler:Test.ME.IGenericPropertyInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + get; + + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='GenericPropertyInterface']/method[@name='setObject' and count(parameter)=1 and parameter[1][@type='T']]" + [Register ("setObject", "(Ljava/lang/Object;)V", "GetSetObject_Ljava_lang_Object_Handler:Test.ME.IGenericPropertyInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + set; + } + + } + + [global::Android.Runtime.Register ("test/me/GenericPropertyInterface", DoNotGenerateAcw=true)] + internal partial class IGenericPropertyInterfaceInvoker : global::Java.Lang.Object, IGenericPropertyInterface { + static readonly JniPeerMembers _members = new XAPeerMembers ("test/me/GenericPropertyInterface", typeof (IGenericPropertyInterfaceInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static IGenericPropertyInterface GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'test.me.GenericPropertyInterface'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public IGenericPropertyInterfaceInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_getObject; +#pragma warning disable 0169 + static Delegate GetGetObjectHandler () + { + if (cb_getObject == null) + cb_getObject = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetObject); + return cb_getObject; + } + + static IntPtr n_GetObject (IntPtr jnienv, IntPtr native__this) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.ToLocalJniHandle (__this.Object); + } +#pragma warning restore 0169 + + static Delegate cb_setObject_Ljava_lang_Object_; +#pragma warning disable 0169 + static Delegate GetSetObject_Ljava_lang_Object_Handler () + { + if (cb_setObject_Ljava_lang_Object_ == null) + cb_setObject_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_SetObject_Ljava_lang_Object_); + return cb_setObject_Ljava_lang_Object_; + } + + static void n_SetObject_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var value = global::Java.Lang.Object.GetObject (native_value, JniHandleOwnership.DoNotTransfer); + __this.Object = value; + } +#pragma warning restore 0169 + + IntPtr id_getObject; + IntPtr id_setObject_Ljava_lang_Object_; + public unsafe global::Java.Lang.Object Object { + get { + if (id_getObject == IntPtr.Zero) + id_getObject = JNIEnv.GetMethodID (class_ref, "getObject", "()Ljava/lang/Object;"); + return (global::Java.Lang.Object) global::Java.Lang.Object.GetObject (JNIEnv.CallObjectMethod (((global::Java.Lang.Object) this).Handle, id_getObject), JniHandleOwnership.TransferLocalRef); + } + set { + if (id_setObject_Ljava_lang_Object_ == IntPtr.Zero) + id_setObject_Ljava_lang_Object_ = JNIEnv.GetMethodID (class_ref, "setObject", "(Ljava/lang/Object;)V"); + IntPtr native_value = JNIEnv.ToLocalJniHandle (value); + JValue* __args = stackalloc JValue [1]; + __args [0] = new JValue (native_value); + JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_setObject_Ljava_lang_Object_, __args); + JNIEnv.DeleteLocalRef (native_value); + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.ITestInterface.cs b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.ITestInterface.cs new file mode 100644 index 000000000..40d8be3c3 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.ITestInterface.cs @@ -0,0 +1,224 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Test.ME { + + [Register ("test/me/TestInterface", DoNotGenerateAcw=true)] + public abstract class TestInterface : Java.Lang.Object { + internal TestInterface () + { + } + + // Metadata.xml XPath field reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/field[@name='SPAN_COMPOSING']" + [Register ("SPAN_COMPOSING")] + public const int SpanComposing = (int) 256; + + + // Metadata.xml XPath field reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/field[@name='DEFAULT_FOO']" + [Register ("DEFAULT_FOO")] + public static global::Java.Lang.Object DefaultFoo { + get { + const string __id = "DEFAULT_FOO.Ljava/lang/Object;"; + + var __v = _members.StaticFields.GetObjectValue (__id); + return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("test/me/TestInterface", typeof (TestInterface)); + + } + + [Register ("test/me/TestInterface", DoNotGenerateAcw=true)] + [global::System.Obsolete ("Use the 'TestInterface' type. This type will be removed in a future release.", error: true)] + public abstract class TestInterfaceConsts : TestInterface { + private TestInterfaceConsts () + { + } + + } + + // Metadata.xml XPath interface reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']" + [Register ("test/me/TestInterface", "", "Test.ME.ITestInterfaceInvoker")] + public partial interface ITestInterface : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='getSpanFlags' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" + [Register ("getSpanFlags", "(Ljava/lang/Object;)I", "GetGetSpanFlags_Ljava_lang_Object_Handler:Test.ME.ITestInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + int GetSpanFlags (global::Java.Lang.Object tag); + + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='append' and count(parameter)=1 and parameter[1][@type='java.lang.CharSequence']]" + [Register ("append", "(Ljava/lang/CharSequence;)V", "GetAppend_Ljava_lang_CharSequence_Handler:Test.ME.ITestInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + void Append (global::Java.Lang.ICharSequence value); + + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='identity' and count(parameter)=1 and parameter[1][@type='java.lang.CharSequence']]" + [Register ("identity", "(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;", "GetIdentity_Ljava_lang_CharSequence_Handler:Test.ME.ITestInterfaceInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + global::Java.Lang.ICharSequence IdentityFormatted (global::Java.Lang.ICharSequence value); + + } + + public static partial class ITestInterfaceExtensions { + public static void Append (this Test.ME.ITestInterface self, string value) + { + var jls_value = value == null ? null : new global::Java.Lang.String (value); + self.Append (jls_value); + jls_value?.Dispose (); + } + + public static string Identity (this Test.ME.ITestInterface self, string value) + { + var jls_value = value == null ? null : new global::Java.Lang.String (value); + global::Java.Lang.ICharSequence __result = self.IdentityFormatted (jls_value); + var __rsval = __result?.ToString (); + jls_value?.Dispose (); + return __rsval; + } + + } + + [global::Android.Runtime.Register ("test/me/TestInterface", DoNotGenerateAcw=true)] + internal partial class ITestInterfaceInvoker : global::Java.Lang.Object, ITestInterface { + static readonly JniPeerMembers _members = new XAPeerMembers ("test/me/TestInterface", typeof (ITestInterfaceInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static ITestInterface GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'test.me.TestInterface'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public ITestInterfaceInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_getSpanFlags_Ljava_lang_Object_; +#pragma warning disable 0169 + static Delegate GetGetSpanFlags_Ljava_lang_Object_Handler () + { + if (cb_getSpanFlags_Ljava_lang_Object_ == null) + cb_getSpanFlags_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetSpanFlags_Ljava_lang_Object_); + return cb_getSpanFlags_Ljava_lang_Object_; + } + + static int n_GetSpanFlags_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_tag) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var tag = global::Java.Lang.Object.GetObject (native_tag, JniHandleOwnership.DoNotTransfer); + int __ret = __this.GetSpanFlags (tag); + return __ret; + } +#pragma warning restore 0169 + + IntPtr id_getSpanFlags_Ljava_lang_Object_; + public unsafe int GetSpanFlags (global::Java.Lang.Object tag) + { + if (id_getSpanFlags_Ljava_lang_Object_ == IntPtr.Zero) + id_getSpanFlags_Ljava_lang_Object_ = JNIEnv.GetMethodID (class_ref, "getSpanFlags", "(Ljava/lang/Object;)I"); + JValue* __args = stackalloc JValue [1]; + __args [0] = new JValue ((tag == null) ? IntPtr.Zero : ((global::Java.Lang.Object) tag).Handle); + var __ret = JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_getSpanFlags_Ljava_lang_Object_, __args); + return __ret; + } + + static Delegate cb_append_Ljava_lang_CharSequence_; +#pragma warning disable 0169 + static Delegate GetAppend_Ljava_lang_CharSequence_Handler () + { + if (cb_append_Ljava_lang_CharSequence_ == null) + cb_append_Ljava_lang_CharSequence_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_Append_Ljava_lang_CharSequence_); + return cb_append_Ljava_lang_CharSequence_; + } + + static void n_Append_Ljava_lang_CharSequence_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var value = global::Java.Lang.Object.GetObject (native_value, JniHandleOwnership.DoNotTransfer); + __this.Append (value); + } +#pragma warning restore 0169 + + IntPtr id_append_Ljava_lang_CharSequence_; + public unsafe void Append (global::Java.Lang.ICharSequence value) + { + if (id_append_Ljava_lang_CharSequence_ == IntPtr.Zero) + id_append_Ljava_lang_CharSequence_ = JNIEnv.GetMethodID (class_ref, "append", "(Ljava/lang/CharSequence;)V"); + IntPtr native_value = CharSequence.ToLocalJniHandle (value); + JValue* __args = stackalloc JValue [1]; + __args [0] = new JValue (native_value); + JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_append_Ljava_lang_CharSequence_, __args); + JNIEnv.DeleteLocalRef (native_value); + } + + static Delegate cb_identity_Ljava_lang_CharSequence_; +#pragma warning disable 0169 + static Delegate GetIdentity_Ljava_lang_CharSequence_Handler () + { + if (cb_identity_Ljava_lang_CharSequence_ == null) + cb_identity_Ljava_lang_CharSequence_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_L) n_Identity_Ljava_lang_CharSequence_); + return cb_identity_Ljava_lang_CharSequence_; + } + + static IntPtr n_Identity_Ljava_lang_CharSequence_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var value = global::Java.Lang.Object.GetObject (native_value, JniHandleOwnership.DoNotTransfer); + IntPtr __ret = CharSequence.ToLocalJniHandle (__this.IdentityFormatted (value)); + return __ret; + } +#pragma warning restore 0169 + + IntPtr id_identity_Ljava_lang_CharSequence_; + public unsafe global::Java.Lang.ICharSequence IdentityFormatted (global::Java.Lang.ICharSequence value) + { + if (id_identity_Ljava_lang_CharSequence_ == IntPtr.Zero) + id_identity_Ljava_lang_CharSequence_ = JNIEnv.GetMethodID (class_ref, "identity", "(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;"); + IntPtr native_value = CharSequence.ToLocalJniHandle (value); + JValue* __args = stackalloc JValue [1]; + __args [0] = new JValue (native_value); + var __ret = global::Java.Lang.Object.GetObject (JNIEnv.CallObjectMethod (((global::Java.Lang.Object) this).Handle, id_identity_Ljava_lang_CharSequence_, __args), JniHandleOwnership.TransferLocalRef); + JNIEnv.DeleteLocalRef (native_value); + return __ret; + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.TestInterfaceImplementation.cs b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.TestInterfaceImplementation.cs new file mode 100644 index 000000000..7cef23b99 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/TestInterface/Test.ME.TestInterfaceImplementation.cs @@ -0,0 +1,229 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Test.ME { + + // Metadata.xml XPath class reference: path="/api/package[@name='test.me']/class[@name='TestInterfaceImplementation']" + [global::Android.Runtime.Register ("test/me/TestInterfaceImplementation", DoNotGenerateAcw=true)] + public abstract partial class TestInterfaceImplementation : global::Java.Lang.Object, global::Test.ME.ITestInterface { + public static class InterfaceConsts { + // The following are fields from: test.me.TestInterface + + // Metadata.xml XPath field reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/field[@name='SPAN_COMPOSING']" + [Register ("SPAN_COMPOSING")] + public const int SpanComposing = (int) 256; + + + // Metadata.xml XPath field reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/field[@name='DEFAULT_FOO']" + [Register ("DEFAULT_FOO")] + public static global::Java.Lang.Object DefaultFoo { + get { + const string __id = "DEFAULT_FOO.Ljava/lang/Object;"; + + var __v = _members.StaticFields.GetObjectValue (__id); + return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + } + + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("test/me/TestInterfaceImplementation", typeof (TestInterfaceImplementation)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected TestInterfaceImplementation (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath constructor reference: path="/api/package[@name='test.me']/class[@name='TestInterfaceImplementation']/constructor[@name='TestInterfaceImplementation' and count(parameter)=0]" + [Register (".ctor", "()V", "")] + public unsafe TestInterfaceImplementation () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer) + { + const string __id = "()V"; + + if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero) + return; + + try { + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); + SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); + _members.InstanceMethods.FinishCreateInstance (__id, this, null); + } finally { + } + } + + static Delegate cb_getSpanFlags_Ljava_lang_Object_; +#pragma warning disable 0169 + static Delegate GetGetSpanFlags_Ljava_lang_Object_Handler () + { + if (cb_getSpanFlags_Ljava_lang_Object_ == null) + cb_getSpanFlags_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_GetSpanFlags_Ljava_lang_Object_); + return cb_getSpanFlags_Ljava_lang_Object_; + } + + static int n_GetSpanFlags_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_tag) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var tag = global::Java.Lang.Object.GetObject (native_tag, JniHandleOwnership.DoNotTransfer); + int __ret = __this.GetSpanFlags (tag); + return __ret; + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='getSpanFlags' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" + [Register ("getSpanFlags", "(Ljava/lang/Object;)I", "GetGetSpanFlags_Ljava_lang_Object_Handler")] + public abstract int GetSpanFlags (global::Java.Lang.Object tag); + + static Delegate cb_append_Ljava_lang_CharSequence_; +#pragma warning disable 0169 + static Delegate GetAppend_Ljava_lang_CharSequence_Handler () + { + if (cb_append_Ljava_lang_CharSequence_ == null) + cb_append_Ljava_lang_CharSequence_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_V) n_Append_Ljava_lang_CharSequence_); + return cb_append_Ljava_lang_CharSequence_; + } + + static void n_Append_Ljava_lang_CharSequence_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var value = global::Java.Lang.Object.GetObject (native_value, JniHandleOwnership.DoNotTransfer); + __this.Append (value); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='append' and count(parameter)=1 and parameter[1][@type='java.lang.CharSequence']]" + [Register ("append", "(Ljava/lang/CharSequence;)V", "GetAppend_Ljava_lang_CharSequence_Handler")] + public abstract void Append (global::Java.Lang.ICharSequence value); + + public void Append (string value) + { + var jls_value = value == null ? null : new global::Java.Lang.String (value); + Append (jls_value); + jls_value?.Dispose (); + } + + static Delegate cb_identity_Ljava_lang_CharSequence_; +#pragma warning disable 0169 + static Delegate GetIdentity_Ljava_lang_CharSequence_Handler () + { + if (cb_identity_Ljava_lang_CharSequence_ == null) + cb_identity_Ljava_lang_CharSequence_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_L) n_Identity_Ljava_lang_CharSequence_); + return cb_identity_Ljava_lang_CharSequence_; + } + + static IntPtr n_Identity_Ljava_lang_CharSequence_ (IntPtr jnienv, IntPtr native__this, IntPtr native_value) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var value = global::Java.Lang.Object.GetObject (native_value, JniHandleOwnership.DoNotTransfer); + IntPtr __ret = CharSequence.ToLocalJniHandle (__this.IdentityFormatted (value)); + return __ret; + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='identity' and count(parameter)=1 and parameter[1][@type='java.lang.CharSequence']]" + [Register ("identity", "(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;", "GetIdentity_Ljava_lang_CharSequence_Handler")] + public abstract global::Java.Lang.ICharSequence IdentityFormatted (global::Java.Lang.ICharSequence value); + + public string Identity (string value) + { + var jls_value = value == null ? null : new global::Java.Lang.String (value); + global::Java.Lang.ICharSequence __result = IdentityFormatted (jls_value); + var __rsval = __result?.ToString (); + jls_value?.Dispose (); + return __rsval; + } + + } + + [global::Android.Runtime.Register ("test/me/TestInterfaceImplementation", DoNotGenerateAcw=true)] + internal partial class TestInterfaceImplementationInvoker : TestInterfaceImplementation { + public TestInterfaceImplementationInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + { + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("test/me/TestInterfaceImplementation", typeof (TestInterfaceImplementationInvoker)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='getSpanFlags' and count(parameter)=1 and parameter[1][@type='java.lang.Object']]" + [Register ("getSpanFlags", "(Ljava/lang/Object;)I", "GetGetSpanFlags_Ljava_lang_Object_Handler")] + public override unsafe int GetSpanFlags (global::Java.Lang.Object tag) + { + const string __id = "getSpanFlags.(Ljava/lang/Object;)I"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue ((tag == null) ? IntPtr.Zero : ((global::Java.Lang.Object) tag).Handle); + var __rm = _members.InstanceMethods.InvokeAbstractInt32Method (__id, this, __args); + return __rm; + } finally { + global::System.GC.KeepAlive (tag); + } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='append' and count(parameter)=1 and parameter[1][@type='java.lang.CharSequence']]" + [Register ("append", "(Ljava/lang/CharSequence;)V", "GetAppend_Ljava_lang_CharSequence_Handler")] + public override unsafe void Append (global::Java.Lang.ICharSequence value) + { + const string __id = "append.(Ljava/lang/CharSequence;)V"; + IntPtr native_value = CharSequence.ToLocalJniHandle (value); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_value); + _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args); + } finally { + JNIEnv.DeleteLocalRef (native_value); + global::System.GC.KeepAlive (value); + } + } + + // Metadata.xml XPath method reference: path="/api/package[@name='test.me']/interface[@name='TestInterface']/method[@name='identity' and count(parameter)=1 and parameter[1][@type='java.lang.CharSequence']]" + [Register ("identity", "(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;", "GetIdentity_Ljava_lang_CharSequence_Handler")] + public override unsafe global::Java.Lang.ICharSequence IdentityFormatted (global::Java.Lang.ICharSequence value) + { + const string __id = "identity.(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;"; + IntPtr native_value = CharSequence.ToLocalJniHandle (value); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_value); + var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, __args); + return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef); + } finally { + JNIEnv.DeleteLocalRef (native_value); + global::System.GC.KeepAlive (value); + } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/TestInterface/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/TestInterface/__NamespaceMapping__.cs new file mode 100644 index 000000000..e4d9dc265 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/TestInterface/__NamespaceMapping__.cs @@ -0,0 +1,21 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "test.me", Managed="Test.ME")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "", Managed="")] + +delegate IntPtr _JniMarshal_PP_L (IntPtr jnienv, IntPtr klass); +delegate void _JniMarshal_PP_V (IntPtr jnienv, IntPtr klass); +delegate int _JniMarshal_PPL_I (IntPtr jnienv, IntPtr klass, IntPtr p0); +delegate IntPtr _JniMarshal_PPL_L (IntPtr jnienv, IntPtr klass, IntPtr p0); +delegate void _JniMarshal_PPL_V (IntPtr jnienv, IntPtr klass, IntPtr p0); +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/TestInterface/enumlist b/tests/generator-Tests/expected.xaji/TestInterface/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Interop.__TypeRegistrations.cs new file mode 100644 index 000000000..d71a25b64 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Interop.__TypeRegistrations.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; + +namespace Java.Interop { + + partial class __TypeRegistrations { + + public static void RegisterPackages () + { +#if MONODROID_TIMING + var start = DateTime.Now; + Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages start: " + (start - new DateTime (1970, 1, 1)).TotalMilliseconds); +#endif // def MONODROID_TIMING + Java.Interop.TypeManager.RegisterPackages ( + new string[]{ + }, + new Converter[]{ + }); +#if MONODROID_TIMING + var end = DateTime.Now; + Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages time: " + (end - new DateTime (1970, 1, 1)).TotalMilliseconds + " [elapsed: " + (end - start).TotalMilliseconds + " ms]"); +#endif // def MONODROID_TIMING + } + +#if NET5_0_OR_GREATER + [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage ("Trimming", "IL2057")] +#endif + static Type Lookup (string[] mappings, string javaType) + { + var managedType = Java.Interop.TypeManager.LookupTypeMapping (mappings, javaType); + if (managedType == null) + return null; + return Type.GetType (managedType); + } + } +} diff --git a/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Lang.Enum.cs b/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Lang.Enum.cs new file mode 100644 index 000000000..97d0fc470 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Lang.Enum.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Enum']" + [global::Android.Runtime.Register ("java/lang/Enum", DoNotGenerateAcw=true)] + [global::Java.Interop.JavaTypeParameters (new string [] {"E extends java.lang.Enum"})] + public abstract partial class Enum : global::Java.Lang.Object, global::Java.Lang.IComparable { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Enum", typeof (Enum)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected Enum (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + // Metadata.xml XPath method reference: path="/api/package[@name='java.lang']/class[@name='Enum']/method[@name='compareTo' and count(parameter)=1 and parameter[1][@type='E']]" + [Register ("compareTo", "(Ljava/lang/Enum;)I", "")] + public unsafe int CompareTo (global::Java.Lang.Object o) + { + const string __id = "compareTo.(Ljava/lang/Enum;)I"; + IntPtr native_o = JNIEnv.ToLocalJniHandle (o); + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [1]; + __args [0] = new JniArgumentValue (native_o); + var __rm = _members.InstanceMethods.InvokeNonvirtualInt32Method (__id, this, __args); + return __rm; + } finally { + JNIEnv.DeleteLocalRef (native_o); + global::System.GC.KeepAlive (o); + } + } + + } + + [global::Android.Runtime.Register ("java/lang/Enum", DoNotGenerateAcw=true)] + internal partial class EnumInvoker : Enum, global::Java.Lang.IComparable { + public EnumInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) + { + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Enum", typeof (EnumInvoker)); + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Lang.IComparable.cs b/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Lang.IComparable.cs new file mode 100644 index 000000000..bbe178542 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Lang.IComparable.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath interface reference: path="/api/package[@name='java.lang']/interface[@name='Comparable']" + [Register ("java/lang/Comparable", "", "Java.Lang.IComparableInvoker")] + [global::Java.Interop.JavaTypeParameters (new string [] {"T"})] + public partial interface IComparable : IJavaObject, IJavaPeerable { + // Metadata.xml XPath method reference: path="/api/package[@name='java.lang']/interface[@name='Comparable']/method[@name='compareTo' and count(parameter)=1 and parameter[1][@type='T']]" + [Register ("compareTo", "(Ljava/lang/Object;)I", "GetCompareTo_Ljava_lang_Object_Handler:Java.Lang.IComparableInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] + int CompareTo (global::Java.Lang.Object another); + + } + + [global::Android.Runtime.Register ("java/lang/Comparable", DoNotGenerateAcw=true)] + internal partial class IComparableInvoker : global::Java.Lang.Object, IComparable { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Comparable", typeof (IComparableInvoker)); + + static IntPtr java_class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return class_ref; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + new IntPtr class_ref; + + public static IComparable GetObject (IntPtr handle, JniHandleOwnership transfer) + { + return global::Java.Lang.Object.GetObject (handle, transfer); + } + + static IntPtr Validate (IntPtr handle) + { + if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.lang.Comparable'."); + return handle; + } + + protected override void Dispose (bool disposing) + { + if (this.class_ref != IntPtr.Zero) + JNIEnv.DeleteGlobalRef (this.class_ref); + this.class_ref = IntPtr.Zero; + base.Dispose (disposing); + } + + public IComparableInvoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer) + { + IntPtr local_ref = JNIEnv.GetObjectClass (((global::Java.Lang.Object) this).Handle); + this.class_ref = JNIEnv.NewGlobalRef (local_ref); + JNIEnv.DeleteLocalRef (local_ref); + } + + static Delegate cb_compareTo_Ljava_lang_Object_; +#pragma warning disable 0169 + static Delegate GetCompareTo_Ljava_lang_Object_Handler () + { + if (cb_compareTo_Ljava_lang_Object_ == null) + cb_compareTo_Ljava_lang_Object_ = JNINativeWrapper.CreateDelegate ((_JniMarshal_PPL_I) n_CompareTo_Ljava_lang_Object_); + return cb_compareTo_Ljava_lang_Object_; + } + + static int n_CompareTo_Ljava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native_another) + { + var __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + var another = global::Java.Lang.Object.GetObject (native_another, JniHandleOwnership.DoNotTransfer); + int __ret = __this.CompareTo (another); + return __ret; + } +#pragma warning restore 0169 + + IntPtr id_compareTo_Ljava_lang_Object_; + public unsafe int CompareTo (global::Java.Lang.Object another) + { + if (id_compareTo_Ljava_lang_Object_ == IntPtr.Zero) + id_compareTo_Ljava_lang_Object_ = JNIEnv.GetMethodID (class_ref, "compareTo", "(Ljava/lang/Object;)I"); + IntPtr native_another = JNIEnv.ToLocalJniHandle (another); + JValue* __args = stackalloc JValue [1]; + __args [0] = new JValue (native_another); + var __ret = JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_compareTo_Ljava_lang_Object_, __args); + JNIEnv.DeleteLocalRef (native_another); + return __ret; + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Lang.State.cs b/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Lang.State.cs new file mode 100644 index 000000000..9295c438c --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.lang.Enum/Java.Lang.State.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='State']" + [global::Android.Runtime.Register ("java/lang/State", DoNotGenerateAcw=true)] + public sealed partial class State : global::Java.Lang.Enum { + + // Metadata.xml XPath field reference: path="/api/package[@name='java.lang']/class[@name='State']/field[@name='BLOCKED']" + [Register ("BLOCKED")] + public static global::Java.Lang.State Blocked { + get { + const string __id = "BLOCKED.Ljava/lang/State;"; + + var __v = _members.StaticFields.GetObjectValue (__id); + return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='java.lang']/class[@name='State']/field[@name='NEW']" + [Register ("NEW")] + public static global::Java.Lang.State New { + get { + const string __id = "NEW.Ljava/lang/State;"; + + var __v = _members.StaticFields.GetObjectValue (__id); + return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='java.lang']/class[@name='State']/field[@name='RUNNABLE']" + [Register ("RUNNABLE")] + public static global::Java.Lang.State Runnable { + get { + const string __id = "RUNNABLE.Ljava/lang/State;"; + + var __v = _members.StaticFields.GetObjectValue (__id); + return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='java.lang']/class[@name='State']/field[@name='TERMINATED']" + [Register ("TERMINATED")] + public static global::Java.Lang.State Terminated { + get { + const string __id = "TERMINATED.Ljava/lang/State;"; + + var __v = _members.StaticFields.GetObjectValue (__id); + return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='java.lang']/class[@name='State']/field[@name='TIMED_WAITING']" + [Register ("TIMED_WAITING")] + public static global::Java.Lang.State TimedWaiting { + get { + const string __id = "TIMED_WAITING.Ljava/lang/State;"; + + var __v = _members.StaticFields.GetObjectValue (__id); + return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='java.lang']/class[@name='State']/field[@name='WAITING']" + [Register ("WAITING")] + public static global::Java.Lang.State Waiting { + get { + const string __id = "WAITING.Ljava/lang/State;"; + + var __v = _members.StaticFields.GetObjectValue (__id); + return global::Java.Lang.Object.GetObject (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/State", typeof (State)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + internal State (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/java.lang.Enum/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/java.lang.Enum/Mono.Android.projitems new file mode 100644 index 000000000..fa2e06041 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.lang.Enum/Mono.Android.projitems @@ -0,0 +1,17 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/java.lang.Enum/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/java.lang.Enum/__NamespaceMapping__.cs new file mode 100644 index 000000000..23b7b4538 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.lang.Enum/__NamespaceMapping__.cs @@ -0,0 +1,15 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] + +delegate int _JniMarshal_PPL_I (IntPtr jnienv, IntPtr klass, IntPtr p0); +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/java.lang.Enum/enumlist b/tests/generator-Tests/expected.xaji/java.lang.Enum/enumlist new file mode 100644 index 000000000..368c3f7b2 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.lang.Enum/enumlist @@ -0,0 +1 @@ +java.lang.State:Java.Lang:State diff --git a/tests/generator-Tests/expected.xaji/java.lang.Object/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/java.lang.Object/Java.Interop.__TypeRegistrations.cs new file mode 100644 index 000000000..d71a25b64 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.lang.Object/Java.Interop.__TypeRegistrations.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; + +namespace Java.Interop { + + partial class __TypeRegistrations { + + public static void RegisterPackages () + { +#if MONODROID_TIMING + var start = DateTime.Now; + Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages start: " + (start - new DateTime (1970, 1, 1)).TotalMilliseconds); +#endif // def MONODROID_TIMING + Java.Interop.TypeManager.RegisterPackages ( + new string[]{ + }, + new Converter[]{ + }); +#if MONODROID_TIMING + var end = DateTime.Now; + Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages time: " + (end - new DateTime (1970, 1, 1)).TotalMilliseconds + " [elapsed: " + (end - start).TotalMilliseconds + " ms]"); +#endif // def MONODROID_TIMING + } + +#if NET5_0_OR_GREATER + [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage ("Trimming", "IL2057")] +#endif + static Type Lookup (string[] mappings, string javaType) + { + var managedType = Java.Interop.TypeManager.LookupTypeMapping (mappings, javaType); + if (managedType == null) + return null; + return Type.GetType (managedType); + } + } +} diff --git a/tests/generator-Tests/expected.xaji/java.lang.Object/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/java.lang.Object/Java.Lang.Object.cs new file mode 100644 index 000000000..5744963dc --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.lang.Object/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new JniPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/java.lang.Object/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/java.lang.Object/Mono.Android.projitems new file mode 100644 index 000000000..d140c8de1 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.lang.Object/Mono.Android.projitems @@ -0,0 +1,14 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/java.lang.Object/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/java.lang.Object/__NamespaceMapping__.cs new file mode 100644 index 000000000..01ebfbe27 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.lang.Object/__NamespaceMapping__.cs @@ -0,0 +1,4 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] + diff --git a/tests/generator-Tests/expected.xaji/java.lang.Object/enumlist b/tests/generator-Tests/expected.xaji/java.lang.Object/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected.xaji/java.util.List/Java.Interop.__TypeRegistrations.cs b/tests/generator-Tests/expected.xaji/java.util.List/Java.Interop.__TypeRegistrations.cs new file mode 100644 index 000000000..d71a25b64 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.util.List/Java.Interop.__TypeRegistrations.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; + +namespace Java.Interop { + + partial class __TypeRegistrations { + + public static void RegisterPackages () + { +#if MONODROID_TIMING + var start = DateTime.Now; + Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages start: " + (start - new DateTime (1970, 1, 1)).TotalMilliseconds); +#endif // def MONODROID_TIMING + Java.Interop.TypeManager.RegisterPackages ( + new string[]{ + }, + new Converter[]{ + }); +#if MONODROID_TIMING + var end = DateTime.Now; + Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages time: " + (end - new DateTime (1970, 1, 1)).TotalMilliseconds + " [elapsed: " + (end - start).TotalMilliseconds + " ms]"); +#endif // def MONODROID_TIMING + } + +#if NET5_0_OR_GREATER + [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage ("Trimming", "IL2057")] +#endif + static Type Lookup (string[] mappings, string javaType) + { + var managedType = Java.Interop.TypeManager.LookupTypeMapping (mappings, javaType); + if (managedType == null) + return null; + return Type.GetType (managedType); + } + } +} diff --git a/tests/generator-Tests/expected.xaji/java.util.List/Java.Lang.Object.cs b/tests/generator-Tests/expected.xaji/java.util.List/Java.Lang.Object.cs new file mode 100644 index 000000000..634d01cdf --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.util.List/Java.Lang.Object.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" + [global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] + public partial class Object { + static readonly JniPeerMembers _members = new XAPeerMembers ("java/lang/Object", typeof (Object)); + + internal static IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/java.util.List/Mono.Android.projitems b/tests/generator-Tests/expected.xaji/java.util.List/Mono.Android.projitems new file mode 100644 index 000000000..066be1dd1 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.util.List/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tests/generator-Tests/expected.xaji/java.util.List/Xamarin.Test.SomeObject.cs b/tests/generator-Tests/expected.xaji/java.util.List/Xamarin.Test.SomeObject.cs new file mode 100644 index 000000000..10a2952f0 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.util.List/Xamarin.Test.SomeObject.cs @@ -0,0 +1,194 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Xamarin.Test { + + // Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']" + [global::Android.Runtime.Register ("xamarin/test/SomeObject", DoNotGenerateAcw=true)] + public partial class SomeObject : global::Java.Lang.Object { + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myStrings']" + [Register ("myStrings")] + public global::System.Collections.Generic.IList MyStrings { + get { + const string __id = "myStrings.Ljava/util/List;"; + + var __v = _members.InstanceFields.GetObjectValue (__id, this); + return global::Android.Runtime.JavaList.FromJniHandle (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + set { + const string __id = "myStrings.Ljava/util/List;"; + + IntPtr native_value = global::Android.Runtime.JavaList.ToLocalJniHandle (value); + try { + _members.InstanceFields.SetValue (__id, this, new JniObjectReference (native_value)); + } finally { + JNIEnv.DeleteLocalRef (native_value); + } + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myInts']" + [Register ("myInts")] + public global::System.Collections.Generic.IList MyInts { + get { + const string __id = "myInts.Ljava/util/List;"; + + var __v = _members.InstanceFields.GetObjectValue (__id, this); + return global::Android.Runtime.JavaList.FromJniHandle (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + set { + const string __id = "myInts.Ljava/util/List;"; + + IntPtr native_value = global::Android.Runtime.JavaList.ToLocalJniHandle (value); + try { + _members.InstanceFields.SetValue (__id, this, new JniObjectReference (native_value)); + } finally { + JNIEnv.DeleteLocalRef (native_value); + } + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='mybools']" + [Register ("mybools")] + public global::System.Collections.Generic.IList Mybools { + get { + const string __id = "mybools.Ljava/util/List;"; + + var __v = _members.InstanceFields.GetObjectValue (__id, this); + return global::Android.Runtime.JavaList.FromJniHandle (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + set { + const string __id = "mybools.Ljava/util/List;"; + + IntPtr native_value = global::Android.Runtime.JavaList.ToLocalJniHandle (value); + try { + _members.InstanceFields.SetValue (__id, this, new JniObjectReference (native_value)); + } finally { + JNIEnv.DeleteLocalRef (native_value); + } + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myObjects']" + [Register ("myObjects")] + public global::System.Collections.Generic.IList MyObjects { + get { + const string __id = "myObjects.Ljava/util/List;"; + + var __v = _members.InstanceFields.GetObjectValue (__id, this); + return global::Android.Runtime.JavaList.FromJniHandle (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + set { + const string __id = "myObjects.Ljava/util/List;"; + + IntPtr native_value = global::Android.Runtime.JavaList.ToLocalJniHandle (value); + try { + _members.InstanceFields.SetValue (__id, this, new JniObjectReference (native_value)); + } finally { + JNIEnv.DeleteLocalRef (native_value); + } + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='myfloats']" + [Register ("myfloats")] + public global::System.Collections.Generic.IList Myfloats { + get { + const string __id = "myfloats.Ljava/util/List;"; + + var __v = _members.InstanceFields.GetObjectValue (__id, this); + return global::Android.Runtime.JavaList.FromJniHandle (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + set { + const string __id = "myfloats.Ljava/util/List;"; + + IntPtr native_value = global::Android.Runtime.JavaList.ToLocalJniHandle (value); + try { + _members.InstanceFields.SetValue (__id, this, new JniObjectReference (native_value)); + } finally { + JNIEnv.DeleteLocalRef (native_value); + } + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='mydoubles']" + [Register ("mydoubles")] + public global::System.Collections.Generic.IList Mydoubles { + get { + const string __id = "mydoubles.Ljava/util/List;"; + + var __v = _members.InstanceFields.GetObjectValue (__id, this); + return global::Android.Runtime.JavaList.FromJniHandle (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + set { + const string __id = "mydoubles.Ljava/util/List;"; + + IntPtr native_value = global::Android.Runtime.JavaList.ToLocalJniHandle (value); + try { + _members.InstanceFields.SetValue (__id, this, new JniObjectReference (native_value)); + } finally { + JNIEnv.DeleteLocalRef (native_value); + } + } + } + + + // Metadata.xml XPath field reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/field[@name='mylongs']" + [Register ("mylongs")] + public global::System.Collections.Generic.IList Mylongs { + get { + const string __id = "mylongs.Ljava/util/List;"; + + var __v = _members.InstanceFields.GetObjectValue (__id, this); + return global::Android.Runtime.JavaList.FromJniHandle (__v.Handle, JniHandleOwnership.TransferLocalRef); + } + set { + const string __id = "mylongs.Ljava/util/List;"; + + IntPtr native_value = global::Android.Runtime.JavaList.ToLocalJniHandle (value); + try { + _members.InstanceFields.SetValue (__id, this, new JniObjectReference (native_value)); + } finally { + JNIEnv.DeleteLocalRef (native_value); + } + } + } + + static readonly JniPeerMembers _members = new XAPeerMembers ("xamarin/test/SomeObject", typeof (SomeObject)); + + internal static new IntPtr class_ref { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + public override global::Java.Interop.JniPeerMembers JniPeerMembers { + get { return _members; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override IntPtr ThresholdClass { + get { return _members.JniPeerType.PeerReference.Handle; } + } + + [global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)] + [global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)] + protected override global::System.Type ThresholdType { + get { return _members.ManagedPeerType; } + } + + protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) + { + } + + } +} diff --git a/tests/generator-Tests/expected.xaji/java.util.List/__NamespaceMapping__.cs b/tests/generator-Tests/expected.xaji/java.util.List/__NamespaceMapping__.cs new file mode 100644 index 000000000..e9b0e4292 --- /dev/null +++ b/tests/generator-Tests/expected.xaji/java.util.List/__NamespaceMapping__.cs @@ -0,0 +1,15 @@ +using System; + +[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] +[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test", Managed="Xamarin.Test")] + +#if !NET +namespace System.Runtime.Versioning { + [System.Diagnostics.Conditional("NEVER")] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + internal sealed class SupportedOSPlatformAttribute : Attribute { + public SupportedOSPlatformAttribute (string platformName) { } + } +} +#endif + diff --git a/tests/generator-Tests/expected.xaji/java.util.List/enumlist b/tests/generator-Tests/expected.xaji/java.util.List/enumlist new file mode 100644 index 000000000..e69de29bb diff --git a/tests/generator-Tests/expected/Adapters/SupportFiles/AdapterView.cs b/tests/generator-Tests/expected/Adapters/SupportFiles/AdapterView.cs index 9beef13cc..0e5f39535 100644 --- a/tests/generator-Tests/expected/Adapters/SupportFiles/AdapterView.cs +++ b/tests/generator-Tests/expected/Adapters/SupportFiles/AdapterView.cs @@ -6,6 +6,25 @@ namespace Xamarin.Test { public abstract class AdapterView : AdapterView where T : IAdapter { +#if JAVA_INTEROP1 + + public AdapterView (ref JniObjectReference reference, JniObjectReferenceOptions options) + : base (ref reference, options) + { + } + + protected override Java.Lang.Object RawAdapter { + get => throw new NotImplementedException (); + set {} + } + + public abstract T Adapter { + get; + set; + } + +#else // !JAVA_INTEROP1 + public AdapterView (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) { @@ -20,6 +39,8 @@ public abstract T Adapter { [Register ("getAdapter", "()Landroid/widget/Adapter;", "GetGetAdapterHandler")] get; [Register ("setAdapter", "(Landroid/widget/Adapter;)V", "GetSetAdapter_Landroid_widget_Adapter_Handler")] set; } + +#endif // !JAVA_INTEROP1 } } diff --git a/tests/generator-Tests/expected/Streams/SupportFiles/InputStreamAdapter.cs b/tests/generator-Tests/expected/Streams/SupportFiles/InputStreamAdapter.cs index ddb62e5a0..b20b29151 100644 --- a/tests/generator-Tests/expected/Streams/SupportFiles/InputStreamAdapter.cs +++ b/tests/generator-Tests/expected/Streams/SupportFiles/InputStreamAdapter.cs @@ -1,3 +1,4 @@ +#if !JAVA_INTEROP1 using System; using System.IO; @@ -43,4 +44,4 @@ public static IntPtr ToLocalJniHandle (Stream value) } } } - +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/expected/Streams/SupportFiles/InputStreamInvoker.cs b/tests/generator-Tests/expected/Streams/SupportFiles/InputStreamInvoker.cs index 1d77d02f8..ffb26e125 100644 --- a/tests/generator-Tests/expected/Streams/SupportFiles/InputStreamInvoker.cs +++ b/tests/generator-Tests/expected/Streams/SupportFiles/InputStreamInvoker.cs @@ -1,4 +1,5 @@ -using System; +#if !JAVA_INTEROP1 +using System; using System.IO; namespace Android.Runtime @@ -60,4 +61,4 @@ public static Stream FromJniHandle (IntPtr handle, JniHandleOwnership transfer) } } } - +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/expected/Streams/SupportFiles/OutputStreamAdapter.cs b/tests/generator-Tests/expected/Streams/SupportFiles/OutputStreamAdapter.cs index d1f1ec30a..b2996d073 100644 --- a/tests/generator-Tests/expected/Streams/SupportFiles/OutputStreamAdapter.cs +++ b/tests/generator-Tests/expected/Streams/SupportFiles/OutputStreamAdapter.cs @@ -1,4 +1,5 @@ -using System; +#if !JAVA_INTEROP1 +using System; using System.IO; namespace Android.Runtime @@ -49,4 +50,4 @@ public static IntPtr ToLocalJniHandle (Stream value) } } } - +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/expected/Streams/SupportFiles/OutputStreamInvoker.cs b/tests/generator-Tests/expected/Streams/SupportFiles/OutputStreamInvoker.cs index f90dac734..1189c1d75 100644 --- a/tests/generator-Tests/expected/Streams/SupportFiles/OutputStreamInvoker.cs +++ b/tests/generator-Tests/expected/Streams/SupportFiles/OutputStreamInvoker.cs @@ -1,4 +1,5 @@ -using System; +#if !JAVA_INTEROP1 +using System; using System.IO; namespace Android.Runtime @@ -65,4 +66,4 @@ internal static Stream FromNative (IntPtr handle, JniHandleOwnership transfer) } } } - +#endif // !JAVA_INTEROP1 diff --git a/tests/generator-Tests/generator-Tests.csproj b/tests/generator-Tests/generator-Tests.csproj index 4b677c73a..28466b7fa 100644 --- a/tests/generator-Tests/generator-Tests.csproj +++ b/tests/generator-Tests/generator-Tests.csproj @@ -31,6 +31,7 @@ + @@ -40,6 +41,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/tools/generator/CodeGenerationOptions.cs b/tools/generator/CodeGenerationOptions.cs index 00a7e8e2e..ced29d57b 100644 --- a/tools/generator/CodeGenerationOptions.cs +++ b/tools/generator/CodeGenerationOptions.cs @@ -43,7 +43,14 @@ internal CodeGenerator CreateCodeGenerator (TextWriter writer) } } - public SymbolTable SymbolTable { get; } = new SymbolTable (); + SymbolTable symbolTable; + public SymbolTable SymbolTable { + get { + if (symbolTable != null) + return symbolTable; + return symbolTable = new SymbolTable (CodeGenerationTarget); + } + } readonly SortedSet jni_marshal_delegates = new SortedSet (); readonly object jni_marshal_delegates_lock = new object (); diff --git a/tools/generator/CodeGenerator.cs b/tools/generator/CodeGenerator.cs index 7fe5479a5..d246a952e 100644 --- a/tools/generator/CodeGenerator.cs +++ b/tools/generator/CodeGenerator.cs @@ -246,7 +246,7 @@ static void Run (CodeGeneratorOptions options, DirectoryAssemblyResolver resolve // Create the .cs files for the enums var enumFiles = enums == null ? null - : enummap.WriteEnumerations (enumdir, enums, FlattenNestedTypes (gens).ToArray (), opt.UseShortFileNames); + : enummap.WriteEnumerations (enumdir, enums, FlattenNestedTypes (gens).ToArray (), opt); gen_info.GenerateLibraryProjectFile (options, enumFiles); } diff --git a/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/CodeGenerator.cs b/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/CodeGenerator.cs index 4789cbea9..9278208f2 100644 --- a/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/CodeGenerator.cs +++ b/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/CodeGenerator.cs @@ -644,7 +644,7 @@ public void WriteInterfaceEventHandlerImpl (InterfaceGen @interface, string inde writer.WriteLine ("{0}\t\t\tglobal::Android.Runtime.JNIEnv.StartCreateInstance (\"{1}\", \"()V\"),", indent, jniClass); writer.WriteLine ("{0}\t\t\tJniHandleOwnership.TransferLocalRef)", indent); writer.WriteLine ("{0}\t{{", indent); - writer.WriteLine ("{0}\t\tglobal::Android.Runtime.JNIEnv.FinishCreateInstance ({1}, \"()V\");", indent, @interface.GetObjectHandleProperty ("this")); + writer.WriteLine ("{0}\t\tglobal::Android.Runtime.JNIEnv.FinishCreateInstance ({1}, \"()V\");", indent, @interface.GetObjectHandleProperty (opt, "this")); if (needs_sender) writer.WriteLine ("{0}\t\tthis.sender = sender;", indent); writer.WriteLine ("{0}\t}}", indent); @@ -863,7 +863,7 @@ public void WriteInterfaceInvoker (InterfaceGen @interface, string indent) writer.WriteLine (); writer.WriteLine ("{0}\tpublic {1}Invoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer)", indent, @interface.Name); writer.WriteLine ("{0}\t{{", indent); - writer.WriteLine ("{0}\t\tIntPtr local_ref = JNIEnv.GetObjectClass ({1});", indent, Context.ContextType.GetObjectHandleProperty ("this")); + writer.WriteLine ("{0}\t\tIntPtr local_ref = JNIEnv.GetObjectClass ({1});", indent, Context.ContextType.GetObjectHandleProperty (opt, "this")); writer.WriteLine ("{0}\t\tthis.class_ref = JNIEnv.NewGlobalRef (local_ref);", indent); writer.WriteLine ("{0}\t\tJNIEnv.DeleteLocalRef (local_ref);", indent); writer.WriteLine ("{0}\t}}", indent); @@ -1283,7 +1283,7 @@ public void WriteMethodInvokerBody (Method method, string indent) WriteParameterListCallArgs (method.Parameters, indent, invoker: true); string env_method = "Call" + method.RetVal.CallMethodPrefix + "Method"; string call = method.RetVal.ReturnCast + "JNIEnv." + env_method + " (" + - Context.ContextType.GetObjectHandleProperty ("this") + ", " + method.EscapedIdName + method.Parameters.GetCallArgs (opt, invoker: true) + ")"; + Context.ContextType.GetObjectHandleProperty (opt, "this") + ", " + method.EscapedIdName + method.Parameters.GetCallArgs (opt, invoker: true) + ")"; if (method.IsVoid) writer.WriteLine ("{0}{1};", indent, call); else diff --git a/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/EnumGenerator.cs b/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/EnumGenerator.cs index b717fbfd4..c1b673a54 100644 --- a/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/EnumGenerator.cs +++ b/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/EnumGenerator.cs @@ -4,6 +4,8 @@ using System.Linq; using static MonoDroid.Generation.EnumMappings; +using CodeGenerationTarget = Xamarin.Android.Binder.CodeGenerationTarget; + namespace MonoDroid.Generation { class EnumGenerator @@ -15,7 +17,7 @@ public EnumGenerator (TextWriter writer) sw = writer; } - public void WriteEnumeration (KeyValuePair enu, GenBase [] gens) + public void WriteEnumeration (CodeGenerationOptions opt, KeyValuePair enu, GenBase [] gens) { string ns = enu.Key.Substring (0, enu.Key.LastIndexOf ('.')).Trim (); string enoom = enu.Key.Substring (enu.Key.LastIndexOf ('.') + 1).Trim (); @@ -27,7 +29,8 @@ public void WriteEnumeration (KeyValuePair enu, GenBase foreach (var member in enu.Value.Members) { var managedMember = FindManagedMember (enu.Value, member.Key, gens); - sw.WriteLine ("\t\t[global::Android.Runtime.IntDefinition (" + (managedMember != null ? "\"" + managedMember + "\"" : "null") + ", JniField = \"" + StripExtraInterfaceSpec (enu.Value.JniNames [member.Key]) + "\")]"); + if (opt.CodeGenerationTarget != CodeGenerationTarget.JavaInterop1) + sw.WriteLine ("\t\t[global::Android.Runtime.IntDefinition (" + (managedMember != null ? "\"" + managedMember + "\"" : "null") + ", JniField = \"" + StripExtraInterfaceSpec (enu.Value.JniNames [member.Key]) + "\")]"); sw.WriteLine ("\t\t{0} = {1},", member.Key.Trim (), member.Value.Trim ()); } sw.WriteLine ("\t}"); diff --git a/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/XamarinAndroidCodeGenerator.cs b/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/XamarinAndroidCodeGenerator.cs index 8bc7868f4..54239ed0c 100644 --- a/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/XamarinAndroidCodeGenerator.cs +++ b/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/XamarinAndroidCodeGenerator.cs @@ -66,7 +66,7 @@ internal override void WriteConstructorIdField (Ctor ctor, string indent) internal override void WriteConstructorBody (Ctor ctor, string indent, System.Collections.Specialized.StringCollection call_cleanup) { - writer.WriteLine ("{0}if ({1} != IntPtr.Zero)", indent, Context.ContextType.GetObjectHandleProperty ("this")); + writer.WriteLine ("{0}if ({1} != IntPtr.Zero)", indent, Context.ContextType.GetObjectHandleProperty (opt, "this")); writer.WriteLine ("{0}\treturn;", indent); writer.WriteLine (); foreach (string prep in ctor.Parameters.GetCallPrep (opt)) @@ -84,7 +84,7 @@ internal override void WriteConstructorBody (Ctor ctor, string indent, System.Co writer.WriteLine ("{0}\t\t\tJniHandleOwnership.TransferLocalRef);", indent); writer.WriteLine ("{0}\tglobal::Android.Runtime.JNIEnv.FinishCreateInstance ({1}, \"{2}\"{3});", indent, - Context.ContextType.GetObjectHandleProperty ("this"), + Context.ContextType.GetObjectHandleProperty (opt, "this"), ctor.IsNonStaticNestedType ? "(" + ctor.Parameters.GetJniNestedDerivedSignature (opt) + ")V" : ctor.JniSignature, ctor.Parameters.GetCallArgs (opt, invoker:false)); writer.WriteLine ("{0}\treturn;", indent); @@ -98,7 +98,7 @@ internal override void WriteConstructorBody (Ctor ctor, string indent, System.Co writer.WriteLine ("{0}\t\tJniHandleOwnership.TransferLocalRef);", indent); writer.WriteLine ("{0}JNIEnv.FinishCreateInstance ({1}, class_ref, {2}{3});", indent, - Context.ContextType.GetObjectHandleProperty ("this"), + Context.ContextType.GetObjectHandleProperty (opt, "this"), ctor.ID, ctor.Parameters.GetCallArgs (opt, invoker:false)); indent = oldindent; @@ -143,13 +143,13 @@ internal override void WriteMethodBody (Method method, string indent, GenBase ty writer.WriteLine ("{0}if (((object) this).GetType () == ThresholdType)", indent); GenerateJNICall (method, indent + "\t", "JNIEnv.Call" + method.RetVal.CallMethodPrefix + "Method (" + - method.DeclaringType.GetObjectHandleProperty ("this") + + method.DeclaringType.GetObjectHandleProperty (opt, "this") + ", " + method.EscapedIdName + method.Parameters.GetCallArgs (opt, invoker:false) + ")", declare_ret: false); writer.WriteLine ("{0}else", indent); GenerateJNICall (method, indent + "\t", "JNIEnv.CallNonvirtual" + method.RetVal.CallMethodPrefix + "Method (" + - method.DeclaringType.GetObjectHandleProperty ("this") + + method.DeclaringType.GetObjectHandleProperty (opt, "this") + ", ThresholdClass, " + string.Format ("JNIEnv.GetMethodID (ThresholdClass, \"{0}\", \"{1}\")", method.JavaName, method.JniSignature) + method.Parameters.GetCallArgs (opt, invoker:false) + ")", @@ -159,7 +159,7 @@ internal override void WriteMethodBody (Method method, string indent, GenBase ty method, indent, "JNIEnv.Call" + method.RetVal.CallMethodPrefix + "Method (" + - method.DeclaringType.GetObjectHandleProperty ("this") + + method.DeclaringType.GetObjectHandleProperty (opt, "this") + ", " + method.EscapedIdName + method.Parameters.GetCallArgs (opt, invoker:false) + ")", declare_ret: true); @@ -190,7 +190,7 @@ internal override void WriteFieldGetBody (Field field, string indent, GenBase ty field.GetMethodPrefix, field.IsStatic ? "class_ref" - : type.GetObjectHandleProperty ("this"), + : type.GetObjectHandleProperty (opt, "this"), field.ID); //var asym = Symbol as ArraySymbol; @@ -237,7 +237,7 @@ internal override void WriteFieldSetBody (Field field, string indent, GenBase ty : String.Empty, field.IsStatic ? "class_ref" - : type.GetObjectHandleProperty ("this"), + : type.GetObjectHandleProperty (opt, "this"), field.ID, arg); diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ClassGen.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ClassGen.cs index 0506acd69..57e76c0be 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ClassGen.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ClassGen.cs @@ -123,8 +123,14 @@ public override void FixupExplicitImplementation () nt.FixupExplicitImplementation (); } - public override string FromNative (CodeGenerationOptions opt, string varname, bool owned) => - $"global::Java.Lang.Object.GetObject<{opt.GetOutputName (FullName)}> ({varname}, {(owned ? "JniHandleOwnership.TransferLocalRef" : "JniHandleOwnership.DoNotTransfer")})"; + public override string FromNative (CodeGenerationOptions opt, string varname, bool owned) => opt.CodeGenerationTarget switch { + CodeGenerationTarget.JavaInterop1 => + "global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<" + + opt.GetOutputName (FullName) + + $"> (ref {varname}, JniObjectReferenceOptions.{(owned ? "CopyAndDispose" : "Copy")})", + _ => + $"global::Java.Lang.Object.GetObject<{opt.GetOutputName (FullName)}> ({varname}, {(owned ? "JniHandleOwnership.TransferLocalRef" : "JniHandleOwnership.DoNotTransfer")})" + }; public bool FromXml { get; set; } @@ -133,7 +139,9 @@ public override void Generate (CodeGenerationOptions opt, GenerationInfo gen_inf using (var sw = gen_info.OpenStream (opt.GetFileName (FullName))) { sw.WriteLine ("using System;"); sw.WriteLine ("using System.Collections.Generic;"); - sw.WriteLine ("using Android.Runtime;"); + if (opt.CodeGenerationTarget != CodeGenerationTarget.JavaInterop1) { + sw.WriteLine ("using Android.Runtime;"); + } if (opt.CodeGenerationTarget != CodeGenerationTarget.XamarinAndroid) { sw.WriteLine ("using Java.Interop;"); } @@ -163,6 +171,9 @@ public static void GenerateEnumList (GenerationInfo gen_info) public static void GenerateTypeRegistrations (CodeGenerationOptions opt, GenerationInfo gen_info) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return; + } using (var sw = gen_info.OpenStream (opt.GetFileName ("Java.Interop.__TypeRegistrations"))) { Dictionary>> mapping = new Dictionary>> (); @@ -179,7 +190,9 @@ public static void GenerateTypeRegistrations (CodeGenerationOptions opt, Generat sw.WriteLine ("using System;"); sw.WriteLine ("using System.Collections.Generic;"); - sw.WriteLine ("using Android.Runtime;"); + if (opt.CodeGenerationTarget != CodeGenerationTarget.JavaInterop1) { + sw.WriteLine ("using Android.Runtime;"); + } sw.WriteLine (); sw.WriteLine ("namespace Java.Interop {"); sw.WriteLine (); diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenBase.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenBase.cs index aaa3f82c2..1322ea41f 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenBase.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenBase.cs @@ -4,6 +4,7 @@ using System.Reflection; using Java.Interop.Tools.Generator; using MonoDroid.Generation.Utilities; +using Xamarin.Android.Binder; namespace MonoDroid.Generation { @@ -488,8 +489,11 @@ public virtual string GetGenericType (Dictionary mappings) return null; } - public string GetObjectHandleProperty (string variable) + public string GetObjectHandleProperty (CodeGenerationOptions opt, string variable) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return $"{variable}.PeerReference"; + } var handleType = IsThrowable () ? "Java.Lang.Throwable" : "Java.Lang.Object"; return $"((global::{handleType}) {variable}).Handle"; @@ -715,12 +719,27 @@ public string [] PreCallback (CodeGenerationOptions opt, string var_name, bool o { var rgm = this as IRequireGenericMarshal; + string format = opt.CodeGenerationTarget switch { + CodeGenerationTarget.JavaInterop1 => + "{0} {1} = {5}global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<{4}> (ref {2}, {3});", + _ => + "{0} {1} = {5}global::Java.Lang.Object.GetObject<{4}> ({2}, {3});", + }; + string transfer = opt.CodeGenerationTarget switch { + CodeGenerationTarget.JavaInterop1 => "JniObjectReferenceOptions.CopyAndDispose", + _ => "JniHandleOwnership.TransferLocalRef", + }; + string doNotTransfer = opt.CodeGenerationTarget switch { + CodeGenerationTarget.JavaInterop1 => "JniObjectReferenceOptions.Copy", + _ => "JniHandleOwnership.DoNotTransfer", + }; + return new string []{ - string.Format ("{0} {1} = {5}global::Java.Lang.Object.GetObject<{4}> ({2}, {3});", + string.Format (format, "var", opt.GetSafeIdentifier (var_name), opt.GetSafeIdentifier (TypeNameUtilities.GetNativeName (var_name)), - owned ? "JniHandleOwnership.TransferLocalRef" : "JniHandleOwnership.DoNotTransfer", + owned ? transfer : doNotTransfer, opt.GetOutputName (rgm != null ? (rgm.GetGenericJavaObjectTypeOverride () ?? FullName) : FullName), rgm != null ? "(" + opt.GetOutputName (FullName) + opt.NullableOperator + ")" : string.Empty) }; diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/InterfaceGen.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/InterfaceGen.cs index 6e0947616..8b17fe928 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/InterfaceGen.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/InterfaceGen.cs @@ -43,6 +43,11 @@ public override void AddNestedType (GenBase gen) public override string FromNative (CodeGenerationOptions opt, string varname, bool owned) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return "global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<" + + opt.GetOutputName (FullName) + + $"> (ref {varname}, JniObjectReferenceOptions.{(owned ? "CopyAndDispose" : "Copy")})"; + } return string.Format ("global::Java.Lang.Object.GetObject<{0}> ({1}, {2})", opt.GetOutputName (FullName), varname, owned ? "JniHandleOwnership.TransferLocalRef" : "JniHandleOwnership.DoNotTransfer"); /* if (String.IsNullOrEmpty (Marshaler)) @@ -81,7 +86,9 @@ public override void Generate (CodeGenerationOptions opt, GenerationInfo gen_inf using (var sw = gen_info.OpenStream (opt.GetFileName (FullName))) { sw.WriteLine ("using System;"); sw.WriteLine ("using System.Collections.Generic;"); - sw.WriteLine ("using Android.Runtime;"); + if (opt.CodeGenerationTarget != CodeGenerationTarget.JavaInterop1) { + sw.WriteLine ("using Android.Runtime;"); + } if (opt.CodeGenerationTarget != CodeGenerationTarget.XamarinAndroid) { sw.WriteLine ("using Java.Interop;"); } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/NamespaceMapping.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/NamespaceMapping.cs index 96026d0eb..1326f04ac 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/NamespaceMapping.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/NamespaceMapping.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using CodeGenerationTarget = Xamarin.Android.Binder.CodeGenerationTarget; + namespace MonoDroid.Generation { public class NamespaceMapping @@ -22,11 +24,12 @@ public void Generate (CodeGenerationOptions opt, GenerationInfo gen_info) sw.WriteLine ("using System;"); sw.WriteLine (); - foreach (var p in mappings) - sw.WriteLine ("[assembly:global::Android.Runtime.NamespaceMapping (Java = \"{0}\", Managed=\"{1}\")]", - p.Key, p.Value); - - sw.WriteLine (); + if (opt.CodeGenerationTarget != CodeGenerationTarget.JavaInterop1) { + foreach (var p in mappings) { + sw.WriteLine ($"[assembly:global::Android.Runtime.NamespaceMapping (Java = \"{p.Key}\", Managed=\"{p.Value}\")]"); + } + sw.WriteLine (); + } // delegate bool _JniMarshal_PPL_Z (IntPtr jnienv, IntPtr klass, IntPtr a); foreach (var jni in opt.GetJniMarshalDelegates ()) diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Parameter.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Parameter.cs index f3a886596..a32c49abc 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Parameter.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Parameter.cs @@ -45,9 +45,13 @@ public string GetCall (CodeGenerationOptions opt) return c; if (!NeedsPrep) return c; - var h = sym.GetObjectHandleProperty (c); - if (sym.PreCall (opt, Name).Length == 0) + var h = sym.GetObjectHandleProperty (opt, c); + if (sym.PreCall (opt, Name).Length == 0) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return c; + } return string.Format ("({0} == null) ? IntPtr.Zero : {1}", c, h); + } return c; } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ReturnValue.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ReturnValue.cs index 55d989d6a..9a2cc73a9 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ReturnValue.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ReturnValue.cs @@ -94,6 +94,11 @@ public string RawJavaType { public string FromNative (CodeGenerationOptions opt, string var_name, bool owned) { if (!string.IsNullOrEmpty (managed_type) && (sym is ClassGen || sym is InterfaceGen)) { + if (opt.CodeGenerationTarget == Xamarin.Android.Binder.CodeGenerationTarget.JavaInterop1) { + return "global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<" + + opt.GetOutputName (managed_type) + + $"> (ref __rm, JniObjectReferenceOptions.Copy)"; + } return string.Format ("global::Java.Lang.Object.GetObject<{0}> ({1}, {2})", opt.GetOutputName (managed_type), var_name, owned ? "JniHandleOwnership.TransferLocalRef" : "JniHandleOwnership.DoNotTransfer"); } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/ArraySymbol.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/ArraySymbol.cs index 55bd29895..4c3f371fd 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/ArraySymbol.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/ArraySymbol.cs @@ -4,6 +4,8 @@ using MonoDroid.Utils; +using CodeGenerationTarget = Xamarin.Android.Binder.CodeGenerationTarget; + namespace MonoDroid.Generation { public class ArraySymbol : ISymbol { @@ -12,9 +14,11 @@ public class ArraySymbol : ISymbol { ISymbol sym; bool is_params; + CodeGenerationTarget target; - public ArraySymbol (ISymbol sym) + public ArraySymbol (ISymbol sym, CodeGenerationTarget target) { + this.target = target; if (sym.FullName == "sbyte") this.sym = byte_sym; else @@ -32,7 +36,12 @@ public string ElementType { } public string FullName { - get { return (is_params ? "params " : String.Empty) + ElementType + "[]"; } + get { + if (!is_params && target == CodeGenerationTarget.JavaInterop1) { + return GetJavaInterop1ParameterType (); + } + return (is_params ? "params " : String.Empty) + ElementType + "[]"; + } } public bool IsGeneric { @@ -66,9 +75,9 @@ public bool IsArray { public string ReturnCast => string.Empty; - public string GetObjectHandleProperty (string variable) + public string GetObjectHandleProperty (CodeGenerationOptions opt, string variable) { - return sym.GetObjectHandleProperty (variable); + return sym.GetObjectHandleProperty (opt, variable); } public string GetGenericType (Dictionary mappings) @@ -78,11 +87,19 @@ public string GetGenericType (Dictionary mappings) public string FromNative (CodeGenerationOptions opt, string var_name, bool owned) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + var transfer = "JniObjectReferenceOptions." + (owned ? "CopyAndDispose" : "Copy"); + return $"global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue" + + $"(ref {var_name}, {transfer})"; + } return String.Format ("({0}[]{4}) JNIEnv.GetArray ({1}, {2}, typeof ({3}))", opt.GetOutputName (ElementType), var_name, owned ? "JniHandleOwnership.TransferLocalRef" : "JniHandleOwnership.DoNotTransfer", opt.GetOutputName (sym.FullName), opt.NullableOperator); } public string ToNative (CodeGenerationOptions opt, string var_name, Dictionary mappings = null) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return $"global::{GetJavaInterop1MarshalType ()}.CreateMarshalArray ({var_name})"; + } return String.Format ("JNIEnv.NewArray ({0})", var_name); } @@ -98,21 +115,44 @@ public string Call (CodeGenerationOptions opt, string var_name) public string[] PostCallback (CodeGenerationOptions opt, string var_name) { - string[] result = new string [2]; - result [0] = String.Format ("if ({0} != null)", opt.GetSafeIdentifier (var_name)); - result [1] = String.Format ("\tJNIEnv.CopyArray ({0}, {1});", opt.GetSafeIdentifier (var_name), opt.GetSafeIdentifier (TypeNameUtilities.GetNativeName (var_name))); - return result; + string managed_name = opt.GetSafeIdentifier (var_name); + string native_name = opt.GetSafeIdentifier (TypeNameUtilities.GetNativeName (var_name)); + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return new string[]{ + $"throw new NotSupportedException (\"ArraySymbol.PostCallback\");", + }; + } + return new[]{ + $"if ({managed_name} != null)", + $"\tJNIEnv.CopyArray ({managed_name}, {native_name});", + }; } public string[] PostCall (CodeGenerationOptions opt, string var_name) { - string native_name = opt.GetSafeIdentifier (TypeNameUtilities.GetNativeName (var_name)); - string[] result = new string [4]; - result [0] = String.Format ("if ({0} != null) {{", opt.GetSafeIdentifier (var_name)); - result [1] = String.Format ("\tJNIEnv.CopyArray ({0}, {1});", native_name, opt.GetSafeIdentifier (var_name)); - result [2] = String.Format ("\tJNIEnv.DeleteLocalRef ({0});", native_name); - result [3] = "}"; - return result; + string managed_name = opt.GetSafeIdentifier (var_name); + string native_name = opt.GetSafeIdentifier (TypeNameUtilities.GetNativeName (var_name)); + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + if (IsParams) { + return new[]{ + $"if ({managed_name} != null) {{", + $"\t{native_name}.CopyTo ({managed_name}, 0);", + $"\t{native_name}.Dispose ();", + $"}}", + }; + } + return new[]{ + $"if ({managed_name} != null) {{", + $"\t{native_name}.DisposeUnlessReferenced ();", + $"}}", + }; + } + return new[]{ + $"if ({managed_name} != null) {{", + $"\tJNIEnv.CopyArray ({native_name}, {managed_name});", + $"\tJNIEnv.DeleteLocalRef ({native_name});", + $"}}", + }; } public string[] PreCallback (CodeGenerationOptions opt, string var_name, bool owned) @@ -122,10 +162,57 @@ public string[] PreCallback (CodeGenerationOptions opt, string var_name, bool ow public string[] PreCall (CodeGenerationOptions opt, string var_name) { + string managed_name = opt.GetSafeIdentifier (var_name); + string native_name = opt.GetSafeIdentifier (TypeNameUtilities.GetNativeName (var_name)); + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return new[]{ + $"var {native_name} = global::{GetJavaInterop1MarshalType ()}.CreateMarshalArray ({managed_name});", + }; + } return new string[] { String.Format ("IntPtr {0} = JNIEnv.NewArray ({1});", opt.GetSafeIdentifier (TypeNameUtilities.GetNativeName (var_name)), opt.GetSafeIdentifier (var_name)) }; } public bool NeedsPrep { get { return true; } } + + string GetJavaInterop1ParameterType () + { + var typeParam = ElementType switch { + "string" => "string", + _ => $"global::{ElementType}", + }; + return sym.JniName switch { + "B" => "System.Collections.Generic.IList", + "C" => "System.Collections.Generic.IList", + "D" => "System.Collections.Generic.IList", + "F" => "System.Collections.Generic.IList", + "I" => "System.Collections.Generic.IList", + "J" => "System.Collections.Generic.IList", + "S" => "System.Collections.Generic.IList", + "V" => throw new InvalidOperationException ("`void` cannot be used as an array type."), + "Z" => "System.Collections.Generic.IList", + _ => $"System.Collections.Generic.IList<{typeParam}>", + }; + } + + string GetJavaInterop1MarshalType () + { + var typeParam = ElementType switch { + "string" => "string", + _ => $"global::{ElementType}", + }; + return sym.JniName switch { + "B" => "Java.Interop.JavaSByteArray", + "C" => "Java.Interop.JavaCharArray", + "D" => "Java.Interop.JavaDoubleArray", + "F" => "Java.Interop.JavaSingleArray", + "I" => "Java.Interop.JavaInt32Array", + "J" => "Java.Interop.JavaInt64Array", + "S" => "Java.Interop.JavaInt16Array", + "V" => throw new InvalidOperationException ("`void` cannot be used as an array type."), + "Z" => "Java.Interop.JavaBooleanArray", + _ => $"Java.Interop.JavaObjectArray<{typeParam}>", + }; + } } } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/CharSequenceSymbol.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/CharSequenceSymbol.cs index cadc2b749..750fd84b0 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/CharSequenceSymbol.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/CharSequenceSymbol.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CodeGenerationTarget = Xamarin.Android.Binder.CodeGenerationTarget; namespace MonoDroid.Generation { @@ -43,8 +44,11 @@ public string ElementType { public string ReturnCast => string.Empty; - public string GetObjectHandleProperty (string variable) + public string GetObjectHandleProperty (CodeGenerationOptions opt, string variable) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return $"{variable}.PeerReference"; + } return $"((global::Java.Lang.Object) {variable}).Handle"; } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/CollectionSymbol.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/CollectionSymbol.cs index e97dabc92..227a2f401 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/CollectionSymbol.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/CollectionSymbol.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; - +using CodeGenerationTarget = Xamarin.Android.Binder.CodeGenerationTarget; namespace MonoDroid.Generation { @@ -58,8 +58,11 @@ public bool MayHaveManagedGenericArguments { public string ReturnCast => string.Empty; - public string GetObjectHandleProperty (string variable) + public string GetObjectHandleProperty (CodeGenerationOptions opt, string variable) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return $"{variable}.PeerReference"; + } return $"((global::Java.Lang.Object) {variable}).Handle"; } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/EnumSymbol.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/EnumSymbol.cs index 8782b556b..ad377c13a 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/EnumSymbol.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/EnumSymbol.cs @@ -48,7 +48,7 @@ public string ElementType { public string ReturnCast => string.Empty; - public string GetObjectHandleProperty (string variable) + public string GetObjectHandleProperty (CodeGenerationOptions opt, string variable) { return null; } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/FormatSymbol.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/FormatSymbol.cs index 859a5f162..a6aaa4f0e 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/FormatSymbol.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/FormatSymbol.cs @@ -65,7 +65,7 @@ public string ElementType { public string ReturnCast => return_cast; - public string GetObjectHandleProperty (string variable) + public string GetObjectHandleProperty (CodeGenerationOptions opt, string variable) { return null; } @@ -77,7 +77,7 @@ public string GetGenericType (Dictionary mappings) public string FromNative (CodeGenerationOptions opt, string varname, bool owned) { - return String.Format (from_fmt, varname, owned ? "JniHandleOwnership.TransferLocalRef" : "JniHandleOwnership.DoNotTransfer"); + return String.Format (from_fmt, varname, owned ? "/* FormatSymbol */ JniHandleOwnership.TransferLocalRef" : "JniHandleOwnership.DoNotTransfer"); } public string ToNative (CodeGenerationOptions opt, string varname, Dictionary mappings = null) diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/GeneratedEnumSymbol.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/GeneratedEnumSymbol.cs index 1878cd89a..b2b687eab 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/GeneratedEnumSymbol.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/GeneratedEnumSymbol.cs @@ -79,7 +79,7 @@ public string ElementType { public string ReturnCast => string.Empty; - public string GetObjectHandleProperty (string variable) + public string GetObjectHandleProperty (CodeGenerationOptions opt, string variable) { return null; } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/GenericSymbol.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/GenericSymbol.cs index 2c9fc2a47..49849c913 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/GenericSymbol.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/GenericSymbol.cs @@ -65,9 +65,9 @@ public ISymbol [] TypeParams { public string ReturnCast => string.Empty; - public string GetObjectHandleProperty (string variable) + public string GetObjectHandleProperty (CodeGenerationOptions opt, string variable) { - return gen.GetObjectHandleProperty (variable); + return gen.GetObjectHandleProperty (opt, variable); } string MapTypeParams (Dictionary mappings) diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/GenericTypeParameter.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/GenericTypeParameter.cs index eaf012bf1..5d2b5f3db 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/GenericTypeParameter.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/GenericTypeParameter.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; +using CodeGenerationTarget = Xamarin.Android.Binder.CodeGenerationTarget; namespace MonoDroid.Generation { @@ -65,13 +66,18 @@ public string ElementType { public string ReturnCast => string.Empty; - public string GetObjectHandleProperty (string variable) + public string GetObjectHandleProperty (CodeGenerationOptions opt, string variable) { return null; } public string FromNative (CodeGenerationOptions opt, string varname, bool owned) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + var transfer = "JniObjectReferenceOptions." + (owned ? "CopyAndDispose" : "Copy"); + return $"global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<{opt.GetOutputName (FullName)}>" + + $"(ref {varname}, {transfer})"; + } return String.Format ("({0}{4}) global::Java.Lang.Object.GetObject<{3}> ({1}, {2})", opt.GetOutputName (type), varname, owned ? "JniHandleOwnership.TransferLocalRef" : "JniHandleOwnership.DoNotTransfer", opt.GetOutputName (FullName), opt.NullableOperator); } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/ISymbol.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/ISymbol.cs index c5182c83a..5b1566a31 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/ISymbol.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/ISymbol.cs @@ -15,7 +15,7 @@ public interface ISymbol { string ElementType { get; } string ReturnCast { get; } - string GetObjectHandleProperty (string variable); + string GetObjectHandleProperty (CodeGenerationOptions opt, string variable); string GetGenericType (Dictionary mappings); diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/StreamSymbol.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/StreamSymbol.cs index a4730d73d..0e7b5022f 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/StreamSymbol.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/StreamSymbol.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CodeGenerationTarget = Xamarin.Android.Binder.CodeGenerationTarget; namespace MonoDroid.Generation { @@ -56,8 +57,11 @@ public string ElementType { public string ReturnCast => string.Empty; - public string GetObjectHandleProperty (string variable) + public string GetObjectHandleProperty (CodeGenerationOptions opt, string variable) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return $"{variable}.PeerReference"; + } return $"((global::Java.Lang.Object) {variable}).Handle"; } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/StringSymbol.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/StringSymbol.cs index d7a7e0c20..e24b8ce9d 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/StringSymbol.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/StringSymbol.cs @@ -4,6 +4,8 @@ using MonoDroid.Utils; +using CodeGenerationTarget = Xamarin.Android.Binder.CodeGenerationTarget; + namespace MonoDroid.Generation { public class StringSymbol : ISymbol { @@ -46,8 +48,11 @@ public string ElementType { public string ReturnCast => string.Empty; - public string GetObjectHandleProperty (string variable) + public string GetObjectHandleProperty (CodeGenerationOptions opt, string variable) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return $"{variable}.PeerReference"; + } return $"((global::Java.Lang.Object) {variable}).Handle"; } @@ -58,11 +63,20 @@ public string GetGenericType (Dictionary mappings) public string FromNative (CodeGenerationOptions opt, string var_name, bool owned) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return String.Format ( + "global::Java.Interop.JniEnvironment.Strings.ToString (ref {0}, JniObjectReferenceOptions.{1})", + var_name, + owned ? "CopyAndDispose" : "Copy"); + } return String.Format ("JNIEnv.GetString ({0}, {1})", var_name, owned ? "JniHandleOwnership.TransferLocalRef" : "JniHandleOwnership.DoNotTransfer"); } public string ToNative (CodeGenerationOptions opt, string var_name, Dictionary mappings = null) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return String.Format ("global::Java.Interop.JniEnvironment.Strings.NewString ({0})", var_name); + } return String.Format ("JNIEnv.NewString ({0})", var_name); } @@ -83,6 +97,12 @@ public string[] PostCallback (CodeGenerationOptions opt, string var_name) public string[] PostCall (CodeGenerationOptions opt, string var_name) { + string native_name = opt.GetSafeIdentifier (TypeNameUtilities.GetNativeName (var_name)); + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return new[]{ + $"global::Java.Interop.JniObjectReference.Dispose (ref {native_name});", + }; + } return new string[]{ string.Format ("JNIEnv.DeleteLocalRef ({0});", opt.GetSafeIdentifier (TypeNameUtilities.GetNativeName (var_name))), }; @@ -95,7 +115,16 @@ public string[] PreCallback (CodeGenerationOptions opt, string var_name, bool ow public string[] PreCall (CodeGenerationOptions opt, string var_name) { - return new string[] { String.Format ("IntPtr {0} = JNIEnv.NewString ({1});", opt.GetSafeIdentifier (TypeNameUtilities.GetNativeName (var_name)), opt.GetSafeIdentifier (var_name)) }; + string managed_name = opt.GetSafeIdentifier (var_name); + string native_name = opt.GetSafeIdentifier (TypeNameUtilities.GetNativeName (var_name)); + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return new[]{ + $"var {native_name} = global::Java.Interop.JniEnvironment.Strings.NewString ({managed_name});", + }; + } + return new[]{ + $"IntPtr {native_name} = JNIEnv.NewString ({managed_name});", + }; } public bool NeedsPrep { get { return true; } } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/SymbolTable.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/SymbolTable.cs index 4cd4fe7f5..e90f62710 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/SymbolTable.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/SymbolTable.cs @@ -4,6 +4,8 @@ using System.Collections.Generic; using System.Collections.Concurrent; +using CodeGenerationTarget = Xamarin.Android.Binder.CodeGenerationTarget; + namespace MonoDroid.Generation { public class SymbolTable { @@ -23,6 +25,8 @@ public class SymbolTable { ISymbol xmlresourceparser_sym; ISymbol string_sym; + CodeGenerationTarget target; + static readonly string[] InvariantSymbols = new string[]{ "Android.Graphics.Color", "boolean", @@ -48,8 +52,10 @@ public IEnumerable AllRegisteredSymbols (CodeGenerationOptions options) return symbols.Values.SelectMany (v => v); } - public SymbolTable () + public SymbolTable (CodeGenerationTarget target) { + this.target = target; + AddType (new SimpleSymbol ("IntPtr.Zero", "void", "void", "V")); AddType (new SimpleSymbol ("false", "boolean", "bool", "Z")); AddType (new SimpleSymbol ("0", "byte", "sbyte", "B")); @@ -63,15 +69,18 @@ public SymbolTable () AddType (new SimpleSymbol ("0", "ushort", "ushort", "S", returnCast: "(ushort)")); AddType (new SimpleSymbol ("0", "ulong", "ulong", "J", returnCast: "(ulong)")); AddType (new SimpleSymbol ("0", "ubyte", "byte", "B", returnCast: "(byte)")); - AddType ("Android.Graphics.Color", new ColorSymbol ()); char_seq = new CharSequenceSymbol (); + string_sym = new StringSymbol (); + if (target == CodeGenerationTarget.JavaInterop1) { + return; + } + AddType ("Android.Graphics.Color", new ColorSymbol ()); instream_sym = new StreamSymbol ("InputStream"); outstream_sym = new StreamSymbol ("OutputStream"); fileinstream_sym = new StreamSymbol ("FileInputStream", "InputStream"); fileoutstream_sym = new StreamSymbol ("FileOutputStream", "OutputStream"); xmlpullparser_sym = new XmlPullParserSymbol (); xmlresourceparser_sym = new XmlResourceParserSymbol (); - string_sym = new StringSymbol (); } // Extract symbol information @@ -241,7 +250,7 @@ ISymbol CreateArray (ISymbol symbol, int rank, bool has_ellipsis) ArraySymbol r = null; while (rank-- > 0) - symbol = r = new ArraySymbol (symbol); + symbol = r = new ArraySymbol (symbol, target); if (r != null) r.IsParams = has_ellipsis; return symbol; diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/XmlPullParserSymbol.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/XmlPullParserSymbol.cs index 9584a2f5a..a2b4e1466 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/XmlPullParserSymbol.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/XmlPullParserSymbol.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CodeGenerationTarget = Xamarin.Android.Binder.CodeGenerationTarget; namespace MonoDroid.Generation { @@ -43,8 +44,11 @@ public string ElementType { public string ReturnCast => string.Empty; - public string GetObjectHandleProperty (string variable) + public string GetObjectHandleProperty (CodeGenerationOptions opt, string variable) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return $"{variable}.PeerReference"; + } return $"((global::Java.Lang.Object) {variable}).Handle"; } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/XmlResourceParserSymbol.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/XmlResourceParserSymbol.cs index 9cb814582..63569ae02 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/XmlResourceParserSymbol.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/XmlResourceParserSymbol.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CodeGenerationTarget = Xamarin.Android.Binder.CodeGenerationTarget; namespace MonoDroid.Generation { @@ -43,8 +44,11 @@ public string ElementType { public string ReturnCast => string.Empty; - public string GetObjectHandleProperty (string variable) + public string GetObjectHandleProperty (CodeGenerationOptions opt, string variable) { + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + return $"{variable}.PeerReference"; + } return $"((global::Java.Lang.Object) {variable}).Handle"; } diff --git a/tools/generator/Java.Interop.Tools.Generator.Transformation/EnumMappings.cs b/tools/generator/Java.Interop.Tools.Generator.Transformation/EnumMappings.cs index 39e764cd2..6b5341ea9 100644 --- a/tools/generator/Java.Interop.Tools.Generator.Transformation/EnumMappings.cs +++ b/tools/generator/Java.Interop.Tools.Generator.Transformation/EnumMappings.cs @@ -107,8 +107,9 @@ static void DoParseJniMember (string jniMember, out string package, out string t } } - internal List WriteEnumerations (string output_dir, Dictionary enums, GenBase [] gens, bool useShortFileNames) + internal List WriteEnumerations (string output_dir, Dictionary enums, GenBase [] gens, CodeGenerationOptions opt) { + bool useShortFileNames = opt.UseShortFileNames; if (!Directory.Exists (output_dir)) Directory.CreateDirectory (output_dir); @@ -120,7 +121,7 @@ internal List WriteEnumerations (string output_dir, Dictionary i.IsGeneric)) Implements.Add (opt.GetOutputName (igen.FullName)); - Attributes.Add (new RegisterAttr (klass.RawJniName, noAcw: true, additionalProperties: klass.AdditionalAttributeString ()) { UseGlobal = true }); + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + Attributes.Add (new JniTypeSignatureAttr (klass.RawJniName, false)); + } else { + Attributes.Add (new RegisterAttr (klass.RawJniName, noAcw: true, additionalProperties: klass.AdditionalAttributeString ()) { UseGlobal = true }); + } SourceWriterExtensions.AddSupportedOSPlatform (Attributes, klass, opt); - var ctor = new ConstructorWriter { - Name = Name, - IsPublic = true, - BaseCall = "base (handle, transfer)" - }; - - ctor.Parameters.Add (new MethodParameterWriter ("handle", TypeReferenceWriter.IntPtr)); - ctor.Parameters.Add (new MethodParameterWriter ("transfer", new TypeReferenceWriter ("JniHandleOwnership"))); + ConstructorWriter ctor = opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1 + ? new ConstructorWriter { + Name = Name, + IsPublic = true, + BaseCall = "base (ref reference, options)", + Parameters = { + new MethodParameterWriter ("reference", new TypeReferenceWriter ("ref JniObjectReference")), + new MethodParameterWriter ("options", new TypeReferenceWriter ("JniObjectReferenceOptions")), + }, + } + : new ConstructorWriter { + Name = Name, + IsPublic = true, + BaseCall = "base (handle, transfer)", + Parameters = { + new MethodParameterWriter ("handle", TypeReferenceWriter.IntPtr), + new MethodParameterWriter ("transfer", new TypeReferenceWriter ("JniHandleOwnership")), + }, + } + ; Constructors.Add (ctor); // ClassInvokerHandle Fields.Add (new PeerMembersField (opt, klass.RawJniName, $"{klass.Name}Invoker", false)); Properties.Add (new JniPeerMembersGetter ()); - Properties.Add (new ThresholdTypeGetter ()); + if (opt.CodeGenerationTarget != CodeGenerationTarget.JavaInterop1) { + Properties.Add (new ThresholdTypeGetter ()); + } AddMemberInvokers (klass, opt, new HashSet ()); } diff --git a/tools/generator/SourceWriters/Extensions/SourceWriterExtensions.cs b/tools/generator/SourceWriters/Extensions/SourceWriterExtensions.cs index dd965bf15..88bd55689 100644 --- a/tools/generator/SourceWriters/Extensions/SourceWriterExtensions.cs +++ b/tools/generator/SourceWriters/Extensions/SourceWriterExtensions.cs @@ -6,6 +6,7 @@ using Java.Interop.Tools.Generator; using MonoDroid.Generation; using Xamarin.SourceWriter; +using Xamarin.Android.Binder; namespace generator.SourceWriters { @@ -258,7 +259,10 @@ public static void AddMethodBody (List body, Method method, CodeGenerati body.Add ($"\t{return_var}_members.{method_type}.Invoke{virt_type}{invokeType}Method ({this_param});"); if (!method.IsVoid) { - var r = invokeType == "Object" ? "__rm.Handle" : "__rm"; + var r = "__rm"; + if (opt.CodeGenerationTarget != CodeGenerationTarget.JavaInterop1 && invokeType == "Object") { + r += ".Handle"; + } body.Add ($"\treturn {method.RetVal.ReturnCast}{method.RetVal.FromNative (opt, r, true) + opt.GetNullForgiveness (method.RetVal)};"); } diff --git a/tools/generator/SourceWriters/InterfaceEventHandlerImplClass.cs b/tools/generator/SourceWriters/InterfaceEventHandlerImplClass.cs index e988661c5..91a9550d0 100644 --- a/tools/generator/SourceWriters/InterfaceEventHandlerImplClass.cs +++ b/tools/generator/SourceWriters/InterfaceEventHandlerImplClass.cs @@ -43,7 +43,7 @@ void AddConstructor (InterfaceGen iface, string jniClass, CodeGenerationOptions ctor.BaseCall = $"base (global::Android.Runtime.JNIEnv.StartCreateInstance (\"{jniClass}\", \"()V\"), JniHandleOwnership.TransferLocalRef)"; - ctor.Body.Add ($"global::Android.Runtime.JNIEnv.FinishCreateInstance ({iface.GetObjectHandleProperty ("this")}, \"()V\");"); + ctor.Body.Add ($"global::Android.Runtime.JNIEnv.FinishCreateInstance ({iface.GetObjectHandleProperty (opt, "this")}, \"()V\");"); if (iface.NeedsSender) ctor.Body.Add ("this.sender = sender;"); diff --git a/tools/generator/SourceWriters/InterfaceInvokerClass.cs b/tools/generator/SourceWriters/InterfaceInvokerClass.cs index 1f16753fe..e5e1997a6 100644 --- a/tools/generator/SourceWriters/InterfaceInvokerClass.cs +++ b/tools/generator/SourceWriters/InterfaceInvokerClass.cs @@ -7,6 +7,8 @@ using MonoDroid.Generation; using Xamarin.SourceWriter; +using CodeGenerationTarget = Xamarin.Android.Binder.CodeGenerationTarget; + namespace generator.SourceWriters { public class InterfaceInvokerClass : ClassWriter @@ -22,14 +24,27 @@ public InterfaceInvokerClass (InterfaceGen iface, CodeGenerationOptions opt, Cod Inherits = "global::Java.Lang.Object"; Implements.Add (iface.Name); - Attributes.Add (new RegisterAttr (iface.RawJniName, noAcw: true, additionalProperties: iface.AdditionalAttributeString ()) { UseGlobal = true }); + bool ji = opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1; + + if (ji) { + Attributes.Add (new JniTypeSignatureAttr (iface.RawJniName, false)); + } + else { + Attributes.Add (new RegisterAttr (iface.RawJniName, noAcw: true, additionalProperties: iface.AdditionalAttributeString ()) { UseGlobal = true }); + } Fields.Add (new PeerMembersField (opt, iface.RawJniName, $"{iface.Name}Invoker", false)); - Properties.Add (new InterfaceHandleGetter ()); + if (!ji) { + Properties.Add (new InterfaceHandleGetter ()); + } + Properties.Add (new JniPeerMembersGetter ()); - Properties.Add (new InterfaceThresholdClassGetter ()); - Properties.Add (new ThresholdTypeGetter ()); + + if (!ji) { + Properties.Add (new InterfaceThresholdClassGetter ()); + Properties.Add (new ThresholdTypeGetter ()); + } Fields.Add (new FieldWriter { Name = "class_ref", Type = TypeReferenceWriter.IntPtr, IsShadow = opt.BuildingCoreAssembly }); @@ -37,7 +52,7 @@ public InterfaceInvokerClass (InterfaceGen iface, CodeGenerationOptions opt, Cod Methods.Add (new ValidateMethod (iface)); Methods.Add (new DisposeMethod ()); - Constructors.Add (new InterfaceInvokerConstructor (iface, context)); + Constructors.Add (new InterfaceInvokerConstructor (opt, iface, context)); AddMemberInvokers (iface, new HashSet (), opt, context); } @@ -171,7 +186,7 @@ public class InterfaceInvokerConstructor : ConstructorWriter // this.class_ref = JNIEnv.NewGlobalRef (local_ref); // JNIEnv.DeleteLocalRef (local_ref); // } - public InterfaceInvokerConstructor (InterfaceGen iface, CodeGeneratorContext context) + public InterfaceInvokerConstructor (CodeGenerationOptions opt, InterfaceGen iface, CodeGeneratorContext context) { Name = iface.Name + "Invoker"; @@ -182,7 +197,7 @@ public InterfaceInvokerConstructor (InterfaceGen iface, CodeGeneratorContext con BaseCall = "base (Validate (handle), transfer)"; - Body.Add ($"IntPtr local_ref = JNIEnv.GetObjectClass ({context.ContextType.GetObjectHandleProperty ("this")});"); + Body.Add ($"IntPtr local_ref = JNIEnv.GetObjectClass ({context.ContextType.GetObjectHandleProperty (opt, "this")});"); Body.Add ("this.class_ref = JNIEnv.NewGlobalRef (local_ref);"); Body.Add ("JNIEnv.DeleteLocalRef (local_ref);"); } diff --git a/tools/generator/SourceWriters/InterfaceInvokerMethod.cs b/tools/generator/SourceWriters/InterfaceInvokerMethod.cs index 686ce6122..cc9a69c05 100644 --- a/tools/generator/SourceWriters/InterfaceInvokerMethod.cs +++ b/tools/generator/SourceWriters/InterfaceInvokerMethod.cs @@ -28,7 +28,7 @@ public InterfaceInvokerMethod (InterfaceGen iface, Method method, CodeGeneration IsStatic = method.IsStatic; method_callback = new MethodCallback (iface, method, opt, null, method.IsReturnCharSequence); - context_this = context.ContextType.GetObjectHandleProperty ("this"); + context_this = context.ContextType.GetObjectHandleProperty (opt, "this"); SourceWriterExtensions.AddSupportedOSPlatform (Attributes, method, opt); diff --git a/tools/generator/SourceWriters/InterfaceInvokerProperty.cs b/tools/generator/SourceWriters/InterfaceInvokerProperty.cs index 6da3e66f5..ec858c2b8 100644 --- a/tools/generator/SourceWriters/InterfaceInvokerProperty.cs +++ b/tools/generator/SourceWriters/InterfaceInvokerProperty.cs @@ -41,7 +41,7 @@ public InterfaceInvokerProperty (InterfaceGen iface, Property property, CodeGene setter_callback = new MethodCallback (iface, property.Setter, opt, property.AdjustedName, false); } - context_this = context.ContextType.GetObjectHandleProperty ("this"); + context_this = context.ContextType.GetObjectHandleProperty (opt, "this"); } public override void Write (CodeWriter writer) diff --git a/tools/generator/SourceWriters/JavaLangObjectConstructor.cs b/tools/generator/SourceWriters/JavaLangObjectConstructor.cs index a7cac874f..a36bb69c5 100644 --- a/tools/generator/SourceWriters/JavaLangObjectConstructor.cs +++ b/tools/generator/SourceWriters/JavaLangObjectConstructor.cs @@ -11,7 +11,7 @@ namespace generator.SourceWriters { public class JavaLangObjectConstructor : ConstructorWriter { - public JavaLangObjectConstructor (ClassGen klass) + public JavaLangObjectConstructor (ClassGen klass, CodeGenerationOptions opt) { Name = klass.Name; @@ -20,10 +20,17 @@ public JavaLangObjectConstructor (ClassGen klass) else IsProtected = true; - Parameters.Add (new MethodParameterWriter ("javaReference", TypeReferenceWriter.IntPtr)); - Parameters.Add (new MethodParameterWriter ("transfer", new TypeReferenceWriter ("JniHandleOwnership"))); + if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { + Parameters.Add (new MethodParameterWriter ("reference", new TypeReferenceWriter ("ref JniObjectReference"))); + Parameters.Add (new MethodParameterWriter ("options", new TypeReferenceWriter ("JniObjectReferenceOptions"))); - BaseCall = "base (javaReference, transfer)"; + BaseCall = "base (ref reference, options)"; + } else { + Parameters.Add (new MethodParameterWriter ("javaReference", TypeReferenceWriter.IntPtr)); + Parameters.Add (new MethodParameterWriter ("transfer", new TypeReferenceWriter ("JniHandleOwnership"))); + + BaseCall = "base (javaReference, transfer)"; + } } } }