Script to build templates for H and C files

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Script to build templates for H and C files

Pavlo Solntsev-2
Dear community,

I found that generation a class skeleton for GObject derived classes is a painful process. Some information in official documentation is also confusing and requires a significant amount of time to digest (speaking for myself). Therefore, I decided to write a script (and get some python experience) to generate general header and source files based on provided information. It is still not perfect, work in progress. I will continue working on this script for myself but I just wanted to share this information with this community. I thought it may be a good idea to develop a best practice for new users how a new class should be declared and defined. Again, the goal here is not to build a swiss knife for all possible cases but generate a starting point. Before I made this script, I also checked GObject generator but found it too complicated and it actually serves a different purpose. 

I am open to comments and critics. Any suggestions are very welcome. I am more than willing to see a tool like that as part of the glib library. 

goteg - stands for GObject TEmplate Generator.


-Pavlo Solntsev
---------------------------------------------------------------------------------------------
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html


_______________________________________________
gtk-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: Script to build templates for H and C files

Emmanuele Bassi
Hi;

creating GObject classes with modern best practices is matter of calling:

  G_DECLARE_FINAL_TYPE

or:

  G_DECLARE_DERIVABLE_TYPE

in your header file, and:

  G_DEFINE_TYPE

in your source file. Anything else is usually dependent on what your
class is going to contain; properties? Signals? A custom constructor?
Private data? A singleton pattern for g_object_new()?

Templating will get you only as far as you're going to make the
template flexible enough.

On 8 January 2018 at 19:07, Pavlo Solntsev <[hidden email]> wrote:

> I am open to comments and critics. Any suggestions are very welcome. I am
> more than willing to see a tool like that as part of the glib library.

You probably want to look at GNOME Builder's snippet functionality, if
you want to generate code.

Additionally, we had a UI tool ages ago called "Turbine", which was
fairly flexible:

https://git.gnome.org//browse/turbine

You could fork it and update its templates. to follow best practices

In general, though, I don't think we're going to have this tool
shipped as part of GLib; after all, we have never landed an interface
definition language to generate code either.

Ciao,
 Emmanuele.

--
https://www.bassi.io
[@] ebassi [@gmail.com]
_______________________________________________
gtk-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: Script to build templates for H and C files

Pavlo Solntsev-2
Thanks, Emmanuele.

turbine actually very similar to what I have been doing. I will play with different options you mentioned. 

-Pavlo Solntsev
---------------------------------------------------------------------------------------------
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html


On Mon, Jan 8, 2018 at 1:37 PM, Emmanuele Bassi <[hidden email]> wrote:
Hi;

creating GObject classes with modern best practices is matter of calling:

  G_DECLARE_FINAL_TYPE

or:

  G_DECLARE_DERIVABLE_TYPE

in your header file, and:

  G_DEFINE_TYPE

in your source file. Anything else is usually dependent on what your
class is going to contain; properties? Signals? A custom constructor?
Private data? A singleton pattern for g_object_new()?

Templating will get you only as far as you're going to make the
template flexible enough.

On 8 January 2018 at 19:07, Pavlo Solntsev <[hidden email]> wrote:

> I am open to comments and critics. Any suggestions are very welcome. I am
> more than willing to see a tool like that as part of the glib library.

You probably want to look at GNOME Builder's snippet functionality, if
you want to generate code.

Additionally, we had a UI tool ages ago called "Turbine", which was
fairly flexible:

https://git.gnome.org//browse/turbine

You could fork it and update its templates. to follow best practices

In general, though, I don't think we're going to have this tool
shipped as part of GLib; after all, we have never landed an interface
definition language to generate code either.

Ciao,
 Emmanuele.

--
https://www.bassi.io
[@] ebassi [@gmail.com]


_______________________________________________
gtk-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-devel-list