-
Notifications
You must be signed in to change notification settings - Fork 33
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
Slightly improved support for GPtrArray #839
Conversation
424d2f2
to
eb7d6a5
Compare
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.
Thank you for PR. In general this looks okayish to me. But this is not due to your code, but because I just discovered that there is potentially a pretty big bug (see #840).
Can you test if a method with an interface glib pointer array return type works even if some memory is leaked?
If not I think we should probably add a unit test to verify the behavior or go in the opposite direction not rendering any function returning a GLibPtrArray of interfaces. This could be done by keeping the files you added and just throw an exception in the "Convert" method. If the generator crashes after this change some "try/catch" blocks are missing: An exception in some converter should not stop the generator but just stop generation of the current element.
The build pipeline reported there is something wrong with your file encodings. Can you fix those, too?
@@ -0,0 +1,14 @@ | |||
namespace Generator.Renderer.Internal.ReturnType; | |||
|
|||
internal class InterfaceArray : ReturnTypeConverter |
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.
As this class handles "GLibPtrArray" please name it InterfaceGLibPtrArray
instead of InterfaceArray
. We need to keep this name available for the regular array implementations.
|
||
namespace Generator.Renderer.Public.ReturnType; | ||
|
||
internal class InterfaceArray : ReturnTypeConverter |
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.
As this class handles "GLibPtrArray" please name it InterfaceGLibPtrArray
instead of InterfaceArray
. We need to keep this name available for the regular array implementations.
|
||
namespace Generator.Renderer.Public.ReturnTypeToManagedExpressions; | ||
|
||
internal class InterfaceArray : ReturnTypeConverter |
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.
As this class handles "GLibPtrArray" please name it InterfaceGLibPtrArray
instead of InterfaceArray
. We need to keep this name available for the regular array implementations.
Hm, I think the code can't work. See the docs. The array is just a struct of a pointer and a length. Treating it as a regular array reads memory it probably shouldn't or can't read at all. Perhaps we should really go in the opposite direction and disable those functions. This should allow adding GtkSourceView and then we add support for GLib arrays as part of #840. It can even be that there are already functions generated and be broken in a similar way if they use GLib arrays. I think I don't have a proper solution for them currently and we need to wait for #840. @cameronwhite: Do you agree? |
If I'm reading these changes correctly, the internal return type currently would be I see there are generated |
Yes it would be @hol430 So let's do the opposite of your PR then. Meaning the PR ensures that nothing related to GLib arrays is rendered. |
eb7d6a5
to
34d966e
Compare
34d966e
to
6a614ef
Compare
@badcel looks like totally preventing any GPtrArrays from being rendered is also problematic; there's a delegate in Gio which takes a parameter of type |
Looks good to me. Thank you 👍 |
This is needed for the gtksourceview bindings (specifically, the completion API, which gets only partially rendered without this, which results in build errors).
I'm not totally certain of the internal -> public conversion so let me know if that looks sketchy. I largely copied it from the interface converter.