Skip to content

Commit

Permalink
Merge pull request #103 from mvidner/data-unmarshal
Browse files Browse the repository at this point in the history
Add DBus::Data, test and refactor PacketMarshaller, PacketUnmarshaller
  • Loading branch information
mvidner authored Apr 4, 2022
2 parents d779e6c + ecb5644 commit 6cdd910
Show file tree
Hide file tree
Showing 17 changed files with 3,117 additions and 707 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
API:
* Renamed the DBus::Type::Type class to DBus::Type
(which was previously a module).
* Introduced DBus::Data classes, use them in Properties.Get,
Properties.GetAll to return correct types as declared (still [#97][]).

Bug fixes:
* Signature validation: Ensure DBus.type produces a valid Type
* Detect more malformed messages: non-NUL padding bytes, variants with
multiple or no value.
* Added thorough tests (`spec/data/marshall.yaml`) to detect nearly all
invalid data at unmarshalling time.

## Ruby D-Bus 0.18.0.beta1 - 2022-02-24

Expand Down
21 changes: 21 additions & 0 deletions examples/service/complex-property.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "dbus"

# Complex property
class Test < DBus::Object
dbus_interface "net.vidner.Scratch" do
dbus_attr_reader :progress, "(stttt)"
end

def initialize(opath)
@progress = ["working", 1, 0, 100, 42].freeze
super(opath)
end
end

bus = DBus::SessionBus.instance
svc = bus.request_service("net.vidner.Scratch")
svc.export(Test.new("/net/vidner/Scratch"))
DBus::Main.new.tap { |m| m << bus }.run
6 changes: 6 additions & 0 deletions lib/dbus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
require_relative "dbus/auth"
require_relative "dbus/bus"
require_relative "dbus/bus_name"
require_relative "dbus/data"
require_relative "dbus/error"
require_relative "dbus/introspect"
require_relative "dbus/logger"
Expand All @@ -26,6 +27,7 @@
require_relative "dbus/proxy_object"
require_relative "dbus/proxy_object_factory"
require_relative "dbus/proxy_object_interface"
require_relative "dbus/raw_message"
require_relative "dbus/type"
require_relative "dbus/xml"

Expand All @@ -49,6 +51,10 @@ module DBus
BIG_END
end

# Comparing symbols is faster than strings
# @return [:little,:big]
HOST_ENDIANNESS = RawMessage.endianness(HOST_END)

# General exceptions.

# Exception raised when there is a problem with a type (may be unknown or
Expand Down
Loading

0 comments on commit 6cdd910

Please sign in to comment.