Comments (3)
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.
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.
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)
- Does lgi support Gtk4? HOT 24
- How to emit signals on an object HOT 26
- GVariant dictionnaries returned from GDBus method calls and signals are empty HOT 4
- Errors in callbacks don't terminate the loop HOT 4
- Segmentation fault in Gio.File.copy_async HOT 7
- API reference such as https://lazka.github.io/pgi-docs/? HOT 2
- Misaligned memory accesses in marshal_2c_int and marshal_2lua_int HOT 2
- Building in Windows with meson is looking for luajit-5.1.lib HOT 3
- GtkContainer.child SIGSEGVs on access HOT 5
- How to connect signal on derived class of GstBin? HOT 5
- Segmentation fault when using netwok manager HOT 1
- Segmentation fault when using upower and playerctl interfaces HOT 1
- push to luarocks HOT 14
- Fails to install on fedora 36, Lua 5.4-1 HOT 5
- install error HOT 3
- _resolve can cause luajit to segmentation fault
- Cannot import Glib HOT 1
- Makefile doesn't work on systems with multiple lua versions? HOT 5
- `GLib.Variant: no 'n'` when using `GLib.Variant("(av)", ...)`
- Cairo Native Interop? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lgi.