Replies: 3 comments 9 replies
-
|
GtkD implements these as custom methods. There are in fact some of these constructors described in the Gtk3 GIR file (search for "gtk_message_dialog_new"). However, they are marked as "introspectable"=0, because they have varargs. Currently gidgen ignores non-introspectable API. If you think it is useful, you could add a custom implementation of these methods, similar to how GtkD does it. It can be done like so in the defs/gtk3.d file: //!class MessageDialog
void this (Window parent, gtk.types.DialogFlags flags, gtk.types.MessageType type, gtk.types.ButtonsType buttons, string messageFormat, string message=null)
{
...You can keep adding code and it will get inserted into the MessageDialog file. |
Beta Was this translation helpful? Give feedback.
-
|
Thinking about this more.. I can think of a couple ways to have gidgen generate varargs functions/methods:
Having both of these options would allow for type-safe varargs methods to be generated. A tuple type could be used in instances where the C callable has a predictable sequence of types, though that may require a template as well. These methods could then be set to introspectable="1" using a |
Beta Was this translation helpful? Give feedback.
-
|
After looking over the MessageDialog constructors again, they seem to be not very ideal for creating D bindings for them, at least in an automated way. The varargs are used as arguments to a printf style format string. Using C printf formatting from D is not of particularly great value and subverts some of the safety aspects of D, since there is no way to enforce the types being passed to such a function and there could be issues converting D types to C, leading to crashes or other issues. The GtkD implementations of them are kind of nonsensical as well and have security issues, from what I can tell. They take a messageFormat string, but lack the ability to pass any arguments for it, except for an additional message string which is supposed to be null. The assumption here is that the string formatting is supposed to be handled in D. The problem is, if this rendered string content contains user defined input, % sequences could be inserted to cause undefined behavior (crashes or worse, if someone figures out how to exploit this in some way), because it is used as the format string! If I was to write a binding for this, I would tend to do things similarly, in that there would just be a single string for the message, but it would not be used as the printf format string. Instead "%s" would be passed as the format string and then the message would be the argument to that. So it seems like custom binding methods are the way to handle this for now. However, I can see potentially adding some features to gidgen to make it easier to write custom bindings. In particular a way to have gidgen insert the documentation provided by the GIR file when creating a custom binding for an existing callable. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to convert a GtkD application (DIDE) to gid:gtk3
I can't find how to do the following using gid:gtk3:
or
I am not expecting to have these constructors as GIR files may not have them, but appropriate setters would do. Trouble is - I can't find them in the generated code. (Not sure they are in GIR either, will look at that later)
Beta Was this translation helpful? Give feedback.
All reactions