-
Notifications
You must be signed in to change notification settings - Fork 64
[generator] Cache static final field values. #1248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...ts/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteCachedReferenceTypeField.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Metadata.xml XPath class reference: path="/api/package[@name='java.code']/class[@name='MyClass']" | ||
| [global::Java.Interop.JniTypeSignature ("java/code/MyClass", GenerateJavaPeer=false)] | ||
| public partial class MyClass { | ||
| private static java.code.Example? _field_cache; | ||
|
|
||
| // Metadata.xml XPath field reference: path="/api/package[@name='java.code']/class[@name='MyClass']/field[@name='field']" | ||
| public static java.code.Example? field { | ||
| get { | ||
| if (_field_cache != null) return (java.code.Example)_field_cache; | ||
|
|
||
| const string __id = "field.Ljava/code/Example;"; | ||
|
|
||
| var __v = _members.StaticFields.GetObjectValue (__id); | ||
| return (java.code.Example?)(_field_cache = global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<java.code.Example? >(ref __v, JniObjectReferenceOptions.Copy)); | ||
| } | ||
| } | ||
|
|
||
| static readonly JniPeerMembers _members = new JniPeerMembers ("java/code/MyClass", typeof (MyClass)); | ||
|
|
||
| protected MyClass (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) | ||
| { | ||
| } | ||
|
|
||
| } | ||
24 changes: 24 additions & 0 deletions
24
...-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteCachedValueTypeField.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Metadata.xml XPath class reference: path="/api/package[@name='java.code']/class[@name='MyClass']" | ||
| [global::Java.Interop.JniTypeSignature ("java/code/MyClass", GenerateJavaPeer=false)] | ||
| public partial class MyClass { | ||
| private static int? _field_cache; | ||
|
|
||
| // Metadata.xml XPath field reference: path="/api/package[@name='java.code']/class[@name='MyClass']/field[@name='field']" | ||
| public static int field { | ||
| get { | ||
| if (_field_cache != null) return (int)_field_cache; | ||
|
|
||
| const string __id = "field.I"; | ||
|
|
||
| var __v = _members.StaticFields.GetInt32Value (__id); | ||
| return (int)(_field_cache = __v); | ||
| } | ||
| } | ||
|
|
||
| static readonly JniPeerMembers _members = new JniPeerMembers ("java/code/MyClass", typeof (MyClass)); | ||
|
|
||
| protected MyClass (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options) | ||
| { | ||
| } | ||
|
|
||
| } |
29 changes: 29 additions & 0 deletions
29
...t-Tests/CodeGeneratorExpectedResults/XAJavaInterop1-NRT/WriteCachedReferenceTypeField.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // 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 { | ||
| private static java.code.Example? _field_cache; | ||
|
|
||
| // Metadata.xml XPath field reference: path="/api/package[@name='java.code']/class[@name='MyClass']/field[@name='field']" | ||
| [Register ("field")] | ||
| public static java.code.Example? field { | ||
| get { | ||
| if (_field_cache != null) return (java.code.Example)_field_cache; | ||
|
|
||
| const string __id = "field.Ljava/code/Example;"; | ||
|
|
||
| var __v = _members.StaticFields.GetObjectValue (__id); | ||
| return (java.code.Example?)(_field_cache = global::Java.Lang.Object.GetObject<java.code.Example> (__v.Handle, JniHandleOwnership.TransferLocalRef)); | ||
| } | ||
| } | ||
|
|
||
| static readonly JniPeerMembers _members = new XAPeerMembers ("java/code/MyClass", typeof (MyClass)); | ||
|
|
||
| internal static IntPtr class_ref { | ||
| get { return _members.JniPeerType.PeerReference.Handle; } | ||
| } | ||
|
|
||
| protected MyClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) | ||
| { | ||
| } | ||
|
|
||
| } |
29 changes: 29 additions & 0 deletions
29
.../Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1-NRT/WriteCachedValueTypeField.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // 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 { | ||
| private static int? _field_cache; | ||
|
|
||
| // Metadata.xml XPath field reference: path="/api/package[@name='java.code']/class[@name='MyClass']/field[@name='field']" | ||
| [Register ("field")] | ||
| public static int field { | ||
| get { | ||
| if (_field_cache != null) return (int)_field_cache; | ||
|
|
||
| const string __id = "field.I"; | ||
|
|
||
| var __v = _members.StaticFields.GetInt32Value (__id); | ||
| return (int)(_field_cache = __v); | ||
| } | ||
| } | ||
|
|
||
| static readonly JniPeerMembers _members = new XAPeerMembers ("java/code/MyClass", typeof (MyClass)); | ||
|
|
||
| internal static IntPtr class_ref { | ||
| get { return _members.JniPeerType.PeerReference.Handle; } | ||
| } | ||
|
|
||
| protected MyClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) | ||
| { | ||
| } | ||
|
|
||
| } |
26 changes: 26 additions & 0 deletions
26
.../Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteCachedReferenceTypeField.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // 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 { | ||
|
|
||
| // Metadata.xml XPath field reference: path="/api/package[@name='java.code']/class[@name='MyClass']/field[@name='field']" | ||
| [Register ("field")] | ||
| public static java.code.Example field { | ||
| get { | ||
| const string __id = "field.Ljava/code/Example;"; | ||
|
|
||
| var __v = _members.StaticFields.GetObjectValue (__id); | ||
| return global::Java.Lang.Object.GetObject<java.code.Example> (__v.Handle, JniHandleOwnership.TransferLocalRef); | ||
| } | ||
| } | ||
|
|
||
| static readonly JniPeerMembers _members = new XAPeerMembers ("java/code/MyClass", typeof (MyClass)); | ||
|
|
||
| internal static IntPtr class_ref { | ||
| get { return _members.JniPeerType.PeerReference.Handle; } | ||
| } | ||
|
|
||
| protected MyClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) | ||
| { | ||
| } | ||
|
|
||
| } |
26 changes: 26 additions & 0 deletions
26
...ests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteCachedValueTypeField.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // 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 { | ||
|
|
||
| // Metadata.xml XPath field reference: path="/api/package[@name='java.code']/class[@name='MyClass']/field[@name='field']" | ||
| [Register ("field")] | ||
| public static int field { | ||
| get { | ||
| const string __id = "field.I"; | ||
|
|
||
| var __v = _members.StaticFields.GetInt32Value (__id); | ||
| return __v; | ||
| } | ||
| } | ||
|
|
||
| static readonly JniPeerMembers _members = new XAPeerMembers ("java/code/MyClass", typeof (MyClass)); | ||
|
|
||
| internal static IntPtr class_ref { | ||
| get { return _members.JniPeerType.PeerReference.Handle; } | ||
| } | ||
|
|
||
| protected MyClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) | ||
| { | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI is suggesting something like this:
Of course, we'd need
global::System.Threading.Volatile. Maybe renamevalueto__result.