Code Monkey home page Code Monkey logo

Comments (3)

pavouk avatar pavouk commented on June 8, 2024

Confirmed, I can see the problem, thanks for the report. Generally, bindings are not good at handling complex typed struct field definitions liek arrays, because fields do not have transfer information attached in GI, and this is root of this problem. Typically, wrapped C interface provides construction methods for boxed structs which also take initialization values as arguments - something likeg_dbus_interface_info_create (const gchar *name, GDBusMethodInfo *methods, ...) but unfortunately GDBus introspection provides nothing like that.

I'm working on some solution here, I was almost there, but hunting final leak proved that I'm not on the right track. I'll continue some other day, when time permits. If it will work, something like following code could be used:

local node = Gio.DBusNodeInfo {
   path = '/some/path',
   interfaces = {
      Gio.DBusInterfaceInfo {
     name = 'SomeInterace',
     methods = {
        Gio.DBusMethodInfo {
           name = 'SomeMethod',
           in_args = {
          Gio.DBusArgInfo {
             name = 'args',
             signature = 's',
          },
          Gio.DBusArgInfo {
             name = 'argi',
             signature = 'i',
          },
           },
        },
     },
     properties = {
        Gio.DBusPropertyInfo {
           name = 'someProperty',
           signature = 's',
           flags = { 'READABLE', 'WRITABLE' },
        },
     },
      },
   },
}

This is quite nice Lua-style, but even more verbose than XML, so quite unsuitable to write manually. Maybe some IDL parser would be handy (probably task for lpeg? :-)

BTW, did you try to use Gio.DBusNodeInfo.new_for_xml()? I guess that this one should work fine as is.

from lgi.

jdesgats avatar jdesgats commented on June 8, 2024

Thank you for this detailed feedback :)

Actually, the PoC that I am working is based on function decorators, and some other metadata directly added to code in order to expose an object on DBus, so the Gio.DBusNodeInfo approach is definitely the way to go, as its verbosity is hidden anyway.

As you suggested; I tried to replace it by the Gio.DBusNodeInfo.new_for_xml() method and so far it seems to work: no more segfault on GC, and Valgrind does not complain anymore. So I will keep it like this for now.

from lgi.

pavouk avatar pavouk commented on June 8, 2024

I have pushed support for DBus*Info structures. Sample above should work nicely, and I also added Gio.DBusNodeInfo.xml attribute for easy XML generation.

One thing which is still 'broken' is reassigning of already assigned fields with new values (e.g. setting methods attribute when one is already set). This will result in memory leaks (old values are not freed), but this is generic GI field support limitation, so I tend to not fix this one, as it might get quite involved and complex, and I do not see much gain in it.

Please let me know if you find anything missing in DBus*Info support (or anywhere else :-).

from lgi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.