-
Notifications
You must be signed in to change notification settings - Fork 555
[Bgen] Ensure that GC.KeepAlive is called in extension methods. #22433
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
Changes from 1 commit
360f46b
c5afe1e
c1426d5
ca0e9b0
cddc790
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2958,7 +2958,7 @@ void GenerateInvoke (bool stret, bool supercall, MethodInfo mi, MemberInformatio | |||||
| print ($"IntPtr {handleName};"); | ||||||
| print ($"{handleName} = global::{NamespaceCache.Messaging}.IntPtr_objc_msgSend (Class.GetHandle (typeof (T)), Selector.GetHandle (\"alloc\"));"); | ||||||
| print ($"{handleName} = {sig} ({handleName}, {selector_field}{args});"); | ||||||
| print ($"{(assign_to_temp ? "ret = " : "return ")} global::ObjCRuntime.Runtime.GetINativeObject<T> ({handleName}, true);"); | ||||||
| print ($"ret = global::ObjCRuntime.Runtime.GetINativeObject<T> ({handleName}, true);"); | ||||||
| } else { | ||||||
| bool returns = mi.ReturnType != TypeCache.System_Void && mi.Name != "Constructor"; | ||||||
| string cast_a = "", cast_b = ""; | ||||||
|
|
@@ -2973,20 +2973,26 @@ void GenerateInvoke (bool stret, bool supercall, MethodInfo mi, MemberInformatio | |||||
|
|
||||||
| if (minfo.is_static) | ||||||
| print ("{0}{1}{2} (class_ptr, {5}{6}){7};", | ||||||
| returns ? (assign_to_temp ? "ret = " : "return ") : "", | ||||||
| returns ? "ret = " : "", | ||||||
| cast_a, sig, target_name, | ||||||
| "/*unusued3*/", //supercall ? "Super" : "", | ||||||
| selector_field, args, cast_b); | ||||||
| else | ||||||
| print ("{0}{1}{2} ({3}{4}, {5}{6}){7};", | ||||||
| returns ? (assign_to_temp ? "ret = " : "return ") : "", | ||||||
| returns ? "ret = " : "", | ||||||
| cast_a, sig, target_name, | ||||||
| handle, | ||||||
| selector_field, args, cast_b); | ||||||
|
|
||||||
| if (postproc.Length > 0) | ||||||
| print (postproc.ToString ()); | ||||||
| } | ||||||
|
|
||||||
| if (target_name == "This") { | ||||||
|
||||||
| if (target_name == "This") { | |
| if (useExtensionMethod) { |
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.
Sure, but will be the opposite, useInstanceMethod:
var useExtensionMethod = (category_type is null && !minfo.is_extension_method && !minfo.is_protocol_implementation_method);Is ensuring that we are not a category etc.. We could move it to an or, but I don't like to change bool operations just because.
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.
ah, yes, flip the logic:
var useExtensionMethod = !(category_type is null && !minfo.is_extension_method && !minfo.is_protocol_implementation_method);
string target_name = useExtensionMethod ? "This" : "this";boolean logic is hard!
Outdated
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.
Debug statement?
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.
Looks like we don't need the
assign_to_tempvariable/parameter, so it can be removed.