nsf / gogobject

GObject-introspection based bindings generator
MIT License
47 stars 5 forks source link

Adding gstreamer support. #7

Open dradtke opened 11 years ago

dradtke commented 11 years ago

I'm trying to add gstreamer support, but I keep running into a weird build error. I already found and fixed a couple (mostly related to locating modules), but now it's complaining that it can't find the ObjectLike interface, despite the "gobject/gobject-2.0" module being successfully imported. From basing the input file off of what's already there, I'm not sure what I'm doing wrong.

The changes I've made so far can be found in my forked copy, and the full build log can be found here.

nsf commented 11 years ago

I'll try to figure out what's wrong with this one. But I should also warn you about two things:

  1. I don't work on gogobject anymore as you can see, there are various reasons for that: Go cannot handle signals within threads created by C code (happens on some desktop configurations with gtk and dbus), Go bloats binaries because of its reflection model (gogtk-demo = 20M + 56 linked .so libraries), lack of enthusiasm.
  2. Gogobject is terribly broken for Go tip version, which means when go 1.1 comes out, it will require more changes to keep it working.

Now to your issue. I've cloned your repo, trying to build it shows this error instead of the one you have:

In file included from gstreamer-0.10/gst.go:3:0:
/home/nsf/tmp/gogobject/build/gstreamer-0.10/gst.gen.h:1440:41: error: unknown type name 'GStaticRecMutex'
/home/nsf/tmp/gogobject/build/gstreamer-0.10/gst.gen.h:1442:45: error: unknown type name 'GThreadPriority'

So, I'm wondering what go compiler version are you using?

nsf commented 11 years ago

But in general when you see errors like that, probably it's due to broken gobject-introspection type annotations. For example I'm looking at the generated build/gstreamer-0.10/gst.go file, and it contains functions like this:

func ChildProxyChildAdded(object0 ObjectLike, child0 ObjectLike) {
        var object1 *C.GstObject
        var child1 *C.GstObject
        if object0 != nil {
            object1 = object0.InheritedFromGstObject()
        }
        if child0 != nil {
            child1 = child0.InheritedFromGstObject()
        }
        C.gst_child_proxy_child_added(object1, child1)
}

It refers to the C type GstObject. Now I'm looking at the file /usr/share/gir-1.0/Gst-0.10.gir and it definitely contains the Object type annotations. So, it must be defined then if not blacklisted, looking for Object definition in the gst.go and seeing this: // blacklisted: Object (object)

In your config file you've blacklisted all objects implicitly by not adding them to the whitelist:

    "whitelist": {
            "objects": [],
            "structs": [],
            "functions": [],
            "callbacks": []
    },

So, hence that's the reason of a failure.

nsf commented 11 years ago

The process of adding bindings is quite painful as it is. You blacklist things that don't work, you whitelist things that work properly and if there is a desirable dependency that is not automatically generated you implement it manually. Generator is incomplete (I haven't finished it, for example it doesn't handle maps (aka dicts, hashmaps) marshaling properly), the build system is incomplete, the project is far from completion. Sorry if that's the only thing you can rely on.