Skip to content
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

Custom GObjects #52

Merged
merged 168 commits into from
Oct 26, 2020
Merged

Custom GObjects #52

merged 168 commits into from
Oct 26, 2020

Conversation

badcel
Copy link
Member

@badcel badcel commented Aug 16, 2020

Some remarks for this implementation:

  • If a System.Type has no Method Sys.Type GetGType() it is assumed that this type is a wrapper
  • The Binding class is an example implementation. The GBinding has no _new function. Meaning it can only be created with an existing pointer or via the construct only properties.
  • I don't use a type dictionary. I'm always asking the C typesystem for information. If this does not impact the performance I prefer it, because there is less code and no duplicated type information (C vs C#)

I suppose that in most cases it is okay, to just call the base constructor without any parameters. Because after the base constructor finished the object is constructed and we can set the properties of our instance afterwards in the C# constructor.

If there are some properties which are construct only (like in GBinding) we could call the Object(params Prop[] properties) constructor without the need to implement this kind of constructor in a subclass.


Edit:

Todo

  • Register/FromExisting split
  • Remove old properties code
  • Rename property descriptors (remove 'Ex')
  • Move Sys.Type to GObject.Type
  • Generator
    • properties
    • events
    • events via property indexer
  • Samples
  • Test other libraries (Gtk, libhandy, etc)
  • rename ConstructProp to ConstructParam as this is an actual construct in GObject used for a near-identical purpose.
  • No custom code in wrapper libraries. Properly wrap Sys.Type + Sys.Value in Core

@badcel
Copy link
Member Author

badcel commented Aug 17, 2020

Missing;

  • ClassInit: Call static constructor if called from C world
  • InstanceInit: Call constructor if called from C world

@mjakeman
Copy link
Member

I am liking this approach quite a lot more. The type registration is fundamentally the same but you've managed to bypass the typedict, which I always considered a necessessary evil.

I agree that we'd be better off not having a type dictionary if we can avoid it, since we're basically just reimplementing GType.

I might have a go at handling object lifecycles (wrapping, lifetimes, toggle refs, etc) on top of this branch to see if we can stick with this going forward.

@badcel
Copy link
Member Author

badcel commented Aug 17, 2020

I would suggest you create a new branch for your lifecycle management code on top of this. In this way we can discuss the pros and cons afterwards if i have s.th. working.

I think the code in this branch could be improved. I like your style of coding / documenting, it is very easy to read and follow along. I think whatever code we decide to take over, we should work over it together.

@badcel badcel linked an issue Aug 18, 2020 that may be closed by this pull request
Mainly fleshes out our support for construct-time properties. Also
contains some general code cleanup, commenting, etc
Unfortunately encountered difficulties with managing object lifecycles
without a type dictionary. It looks like the typedict might be
necessary after all.

Added a type dict (entirely self-contained in GObject.Object however),
and implemented methods for looking up types that have yet to be
registered. Attempted to register recursively where possible.

Also:
 - Corrected class name InitallyUnowned -> Init*i*allyUnowned
 - Changed file name Object.TypeSystemIntegration.cs to the shorter
   Object.TypeIntegration.cs
firox263 and others added 5 commits August 23, 2020 14:32
This commit makes a limited subset of Gtk3 work with the new
GObject code. It adds `Samples/Gtk3/QuickStart` which tests
basic type dictionary code.

Next steps include:
 - Autogenerating API-level code
 - Making other libraries compile
Object Integration + Basic Lifecycle Management
@badcel
Copy link
Member Author

badcel commented Aug 23, 2020

@na2axl An Update for you:

@firox263 and I just had a meeting on how to progress. We decided to generate parts of the core libraries to ease up object creation. The result of this inital work for this is in the Samples/Gtk3/Quickstart.

I'm probably going to implement the generator today. If this is done we have the most important things for the type system integration available.

Afterwards it would be nice if you can rebase your pull request #58 on this one. Than we have a foundation on which we can apply all the small things to make it nice and finalize the work on the properties.

If this is done the generator should generate the properties, too. The last part are methods and we need to figure out if we want / can generate them. (I'm not sure if this will be easy, because I want the async and await in this library).

@badcel
Copy link
Member Author

badcel commented Aug 23, 2020

I updated the code to generate the core classes partially. The code is compiling but not working because I had to remove the connections to the properties. I think this could be the start of our future gir.core base.

badcel and others added 7 commits October 20, 2020 17:01
 - Fix compile errors
 - Move SignalArgs indexer support to Object
 - Use Notebook as testclass for generic signals
Fix various parts of the quick-start demo, as well as add
significant amounts of commenting to serve as a self-contained
tutorial for learning Gir.Core.
 - Support concrete types as sender (without null check in client code)
 - Support Events which just send empty EventArgs
 - Make SetArgs internal
 - Extract signal data only on request
@na2axl na2axl mentioned this pull request Oct 25, 2020
9 tasks
na2axl and others added 13 commits October 25, 2020 08:36
Finally got this .editorconfig file. Configured to follow the default C# code spec, and compatible with StyleCop.
Apply .editorconfig code style
# Conflicts:
#	Generator/Templates/Core/class.sbntxt
#	Libs/GObject/Core/Classes/Binding.cs
#	Libs/GObject/Core/Classes/InitiallyUnowned.cs
#	Libs/GObject/Core/Classes/Object.cs
#	Libs/GObject/Core/Classes/Signal.cs
#	Libs/GObject/Core/Classes/TypeModule.cs
#	Libs/Gtk3/Classes/Button.cs
#	Libs/Gtk3/Classes/Window.cs
#	Samples/Gtk3/QuickStart/Gtk/Bin.Generated.cs
#	Samples/Gtk3/QuickStart/Gtk/Button.Generated.cs
#	Samples/Gtk3/QuickStart/Gtk/Container.Generated.cs
#	Samples/Gtk3/QuickStart/Gtk/Container.cs
#	Samples/Gtk3/QuickStart/Gtk/Widget.Generated.cs
#	Samples/Gtk3/QuickStart/Gtk/Widget.cs
#	Samples/Gtk3/QuickStart/Gtk/Window.Generated.cs
@badcel badcel marked this pull request as ready for review October 26, 2020 20:06
@badcel badcel merged commit bd6a187 into develop Oct 26, 2020
@badcel badcel deleted the CustomGObjects branch October 26, 2020 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC002] Static GProperty Descriptors [RFC-1] Type System Integration with GObject
4 participants