amenzhinsky / dbus-codegen-go

D-Bus code-generation for golang
MIT License
16 stars 14 forks source link

Generate introspection data #9

Closed knightpp closed 2 years ago

knightpp commented 2 years ago

Hi. I thought it would be great to generate introspection data or maybe I don't see a better way? So, I've added this functionality, you can check it https://github.com/knightpp/dbus-codegen-go/commit/051006ed81fa961dfee205da18ddd0adca8c1ed2 if you are interested I can create PR.

Example output:

var (
    // Introspection for org.kde.StatusNotifierItem
    IntrospectDataStatusNotifierItem = introspect.Interface{
        Name: "org.kde.StatusNotifierItem",
        Methods: []introspect.Method{{Name: "ContextMenu", Args: []introspect.Arg{
            {Name: "x", Type: "i", Direction: "in"},
            {Name: "y", Type: "i", Direction: "in"},
        }},
        },
        Signals: []introspect.Signal{{Name: "NewTitle"},
            {Name: "NewStatus", Args: []introspect.Arg{
                {Name: "status", Type: "s", Direction: ""},
            }},
        },
        Properties: []introspect.Property{{Name: "Category", Type: "s", Access: "read"},
            {Name: "AttentionMovieName", Type: "s", Access: "read"},
            {Name: "ToolTip", Type: "(sa(iiay)ss)", Access: "read", Annotations: []introspect.Annotation{
                {Name: "org.qtproject.QtDBus.QtTypeName", Value: "KDbusToolTipStruct"},
            }},
        },
        Annotations: []introspect.Annotation{},
    }
)

The main purpose for me is to preserve argument names and add introspection for signals.