Ticket #6 (closed enhancement: fixed)

Opened 9 months ago

Last modified 8 months ago

The enums should be automatically imported by all files - no need to import gtkc.gtktypes!

Reported by: kaarna Assigned to: JJR
Priority: major Milestone: Pre-release 8
Component: gtkd - classes Version: TRUNK
Keywords: enum enums modules import Cc:

Description

Currently in gtkD when you want to use the enums of gtkD (which you have to do all the time), you'll have to import the C functions definition files e.g. gtkc.gtktypes. That creates a bit unclean looking code. And people really do expect the enums to be usable at all times.

Suggestion to fix it: The enums should be automatically public imported by all files. And the enums should propably be in a file of their own then called something like /src/gtk/gtkEnums.d or /src/gtkc/gtkenums.d. And then that file should be imported by all /src/gtk/ files. (And the same for all other packages gdk, glib, gstreamer etc.) You shouldn't need to import gtkc.gtktypes to get the enums. That would be a lot cleaner.

Another issue is that should the C type enum names be allowed too. In C you'd have for example a positiontype enum which has the following defined: GTK_POS_LEFT
GTK_POS_RIGHT
GTK_POS_TOP
GTK_POS_BOTTOM

In gtkD we have: public enum GtkPositionType? {

LEFT, RIGHT, TOP, BOTTOM

}

Should the C versions be defined in /src/gtkc/gtkc.d (Or in a file called gtkcenums.d that would be imported by /src/gtkc/gtkc.d which doesn't yet exist.) And then the D versions (named enums) could be defined in /src/gtk/gtkEnums.d and imported by all files in /src/gtk/ like suggested above. That way we could again have the direct C wrapper in /src/gtkc/ and the D object oriented wrapper in /src/gtk/ like people have suggested before.

Another option would be to only have the named enums (current situation) which is not bad, but if somebody would want to use the direct C functions then they propably expect the C enums to work too.

Whichever path is chosen with the C enums, the D enums should be fixed quickly to be imported by all files, as that will simplify all the examples (take out one ugly line) and make the conversion of GTK examples from other languages easier.

Change History

12/21/07 08:50:18 changed by Pse

  • keywords changed from enum to enum enums modules import.

I agree. The current state is messy at best and not intuitive. Kaarna, would you mind having a look at what needs to be done? By all means, if you intend to make the necessary changes, don't hesitate to assign this to yourself. This could be a nice, big improvement for pre-release 8.

12/23/07 05:10:30 changed by JJR

Another good suggestion, kaarna. These enums should be public imported. I'll try playing with some ideas in the experimental branch. If it works out, we can carry the changes over to trunk.

12/29/07 01:30:09 changed by Pse

  • version set to TRUNK.

12/31/07 01:39:18 changed by Pse

In r361 type information is publicly imported (wrapper-only, changes will we mirrored in the next full wrap). TODO: remove unnecessary imports for types in the demos.

12/31/07 02:02:29 changed by Pse

  • status changed from new to closed.
  • resolution set to fixed.

Having public imports for all typing information is enough for this ticket's milestone. Should anyone feel further improvements are necessary, please create a new ticket or reopen this one.