Skip to content

Can't specify a type for variants #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bartbes opened this issue Feb 14, 2016 · 2 comments
Open

Can't specify a type for variants #3

bartbes opened this issue Feb 14, 2016 · 2 comments

Comments

@bartbes
Copy link

bartbes commented Feb 14, 2016

The current code, at least for ldbus, seems to derive the actual type of a variant at runtime. This however means certain types, in particular numerical types, cannot be expressed. Additionally, considering properties are implemented with a Get that returns a variant, properties aren't actually of the type they claim to be, nor are they ever typechecked.

@bartbes
Copy link
Author

bartbes commented Feb 15, 2016

For now I've monkeypatched it in my own code using the following:

        local orig_append = luadbus.raw.append_arg
        function luadbus.raw.append_arg(iter, value, typ, subtyp)
                if typ == "v" and type(value) == "function" then
                        value, subtyp = value()
                        local subiter = iter:open_container("v", subtyp)
                        luadbus.raw.append_arg(subiter, value, subtyp)
                        iter:close_container(subiter)
                        return
                end
                return orig_append(iter, value, typ, subtyp)
        end

This allows a variant to be a function, returning the value then the type. Not the cleanest solution, but it works for now. Of course it still requires things like the Properties interface to be updated, or the read function returning such a functio

@RafaGago
Copy link

This project is dead, but for anyone still using this and some other things on the dbus backend are fixed in:
#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants