Skip to content

Can't specify a type for variants #3

Description

@bartbes

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.

Activity

  1. bartbes commented on Feb 15, 2016

    @bartbes
    Author

    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

  2. RafaGago commented on Feb 14, 2018

    @RafaGago

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions