Skip to content
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

Add DBus::Data, test and refactor PacketMarshaller, PacketUnmarshaller #103

Merged
merged 31 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6ed7c36
WIP Data classes, use them with unmarshaling overhaul
mvidner Feb 26, 2022
a4fcb96
Fix endianness for parts of messages
mvidner Mar 15, 2022
f375e54
Test PacketUnmarshaller: allow DBus::Data::Base as result
mvidner Mar 15, 2022
ff98634
Pass PacketUnmarshaller spec for basic (non-container) types
mvidner Mar 16, 2022
ef43312
Port the recent InvalidPacketException improvements from master
mvidner Mar 16, 2022
1560d05
Data classes work in plain mode; tests pass.
mvidner Mar 16, 2022
c3b7ce7
Enable and test exact mode for PacketUnmarshaller#unmarshall
mvidner Mar 17, 2022
abd9fba
Converting the PacketUmnarshaller tests to YAML
mvidner Mar 17, 2022
39346fd
Use YAML data to test PacketUnmarshaller
mvidner Mar 17, 2022
b493375
Use YAML data to test PacketUnmarshaller, the rest of it.
mvidner Mar 18, 2022
c72d010
Don't skip test cases for 'b':false.
mvidner Mar 18, 2022
8c1245d
Test PacketMarshaller using the YAML data.
mvidner Mar 18, 2022
be36986
Declare Data.make_typed, start using it for Properties interface
mvidner Mar 22, 2022
1073e0b
More YARD doc of existing API
mvidner Mar 23, 2022
0f28329
Data::Fixed#initialize: check that the value is in range
mvidner Mar 23, 2022
063a4dd
Refactor PacketMarshaller#append for Basic types, preparing for Data.…
mvidner Mar 23, 2022
05e17e2
Merge branch 'master' into data-unmarshal
mvidner Mar 27, 2022
fddcac8
Validate signatures on unmarshalling
mvidner Mar 28, 2022
e616db6
DBus::Data::StringLike#initialize: test validity
mvidner Mar 29, 2022
3b5ef7f
Type::Type is just Type
mvidner Mar 30, 2022
ba234fd
Enable Data.make_typed to fix Properties.Get,.GetAll
mvidner Mar 30, 2022
0e0ffcf
Fixup Yard comments to silence its warnings
mvidner Mar 31, 2022
57323d4
Test that Properties.Get .GetAll returns correct types for a struct.
mvidner Mar 31, 2022
23c5319
Initialize the memoization variable
mvidner Mar 31, 2022
a3633d1
Rename the file to match the module.
mvidner Apr 1, 2022
aba87d6
Array tests WIP
mvidner Apr 1, 2022
3ccb322
Tests for Data::Struct#initialize
mvidner Apr 4, 2022
b261d76
Restore buffer.dup
mvidner Apr 4, 2022
5592314
Adjust fixmes and todos to current state.
mvidner Apr 4, 2022
a06cbee
An overview of DBus::Data for Yard
mvidner Apr 4, 2022
ecb5644
Summarize the user-visible changes.
mvidner Apr 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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