Merge lp:~jamesh/unity-scopes-api/expose-filter-deserialize into lp:unity-scopes-api

Proposed by James Henstridge
Status: Merged
Approved by: Michi Henning
Approved revision: 278
Merged at revision: 285
Proposed branch: lp:~jamesh/unity-scopes-api/expose-filter-deserialize
Merge into: lp:unity-scopes-api
Diff against target: 137 lines (+19/-7)
6 files modified
debian/libunity-scopes3.symbols (+2/-0)
include/unity/scopes/FilterBase.h (+1/-0)
include/unity/scopes/FilterState.h (+1/-0)
src/scopes/FilterBase.cpp (+4/-0)
src/scopes/FilterState.cpp (+4/-0)
test/gtest/scopes/Filters/Filters_test.cpp (+7/-7)
To merge this branch: bzr merge lp:~jamesh/unity-scopes-api/expose-filter-deserialize
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michi Henning (community) Approve
Review via email: mp+245845@code.launchpad.net

Commit message

Expose the deserialize() static method on FilterBase and FilterState for use by the Go bindings.

Description of the change

To reduce the size of the C shim in the Go binding, it would be useful to be able to construct filter objects from a VariantMap.

This way rather than creating C shims for each individual filter class, I can implement the filters in Go and just have them produce the serialised representation to pass down to C and then C++.

All I needed for this was to expose FilterBaseImpl::deserialize() on the public FilterBase class, which is what this branch does.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
277. By James Henstridge

Update symbols file.

278. By James Henstridge

Also expose FilterState::deserialize().

Revision history for this message
Michi Henning (michihenning) wrote :

Looks good, thanks!

I think we should bump the micro version?

review: Needs Information
Revision history for this message
Michi Henning (michihenning) wrote :

Ah, right, no need. We have plenty of version bumps in the other branches waiting to be reviewed.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
279. By James Henstridge

Merge from trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/libunity-scopes3.symbols'
2--- debian/libunity-scopes3.symbols 2015-01-19 08:09:07 +0000
3+++ debian/libunity-scopes3.symbols 2015-01-21 12:33:34 +0000
4@@ -306,6 +306,7 @@
5 (c++)"unity::scopes::experimental::ValueSliderFilter::~ValueSliderFilter()@Base" 0.5.0+14.10.20140619
6 (c++)"unity::scopes::experimental::ValueSliderFilter::ValueSliderFilter(unity::scopes::internal::ValueSliderFilterImpl*)@Base" 0.5.0+14.10.20140619
7 (c++)"unity::scopes::experimental::ValueSliderFilter::value(unity::scopes::FilterState const&) const@Base" 0.5.0+14.10.20140619
8+ (c++)"unity::scopes::FilterBase::deserialize(std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unity::scopes::Variant, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, unity::scopes::Variant> > > const&)@Base" 0replaceme
9 (c++)"unity::scopes::FilterBase::display_hints() const@Base" 0.4.6+14.10.20140519
10 (c++)"unity::scopes::FilterBase::~FilterBase()@Base" 0.4.0+14.04.20140312.1
11 (c++)"unity::scopes::FilterBase::FilterBase(unity::scopes::internal::FilterBaseImpl*)@Base" 0.4.0+14.04.20140312.1
12@@ -317,6 +318,7 @@
13 (c++)"unity::scopes::FilterOption::FilterOption(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1
14 (c++)"unity::scopes::FilterOption::id() const@Base" 0.4.0+14.04.20140312.1
15 (c++)"unity::scopes::FilterOption::label() const@Base" 0.4.0+14.04.20140312.1
16+ (c++)"unity::scopes::FilterState::deserialize(std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unity::scopes::Variant, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, unity::scopes::Variant> > > const&)@Base" 0replaceme
17 (c++)"unity::scopes::FilterState::~FilterState()@Base" 0.4.0+14.04.20140312.1
18 (c++)"unity::scopes::FilterState::FilterState()@Base" 0.4.0+14.04.20140312.1
19 (c++)"unity::scopes::FilterState::FilterState(unity::scopes::FilterState&&)@Base" 0.4.0+14.04.20140312.1
20
21=== modified file 'include/unity/scopes/FilterBase.h'
22--- include/unity/scopes/FilterBase.h 2014-11-03 05:31:30 +0000
23+++ include/unity/scopes/FilterBase.h 2015-01-21 12:33:34 +0000
24@@ -82,6 +82,7 @@
25
26 /// @cond
27 VariantMap serialize() const;
28+ static FilterBase::SCPtr deserialize(VariantMap const& var);
29 /// @endcond
30
31 /**
32
33=== modified file 'include/unity/scopes/FilterState.h'
34--- include/unity/scopes/FilterState.h 2014-11-03 05:31:30 +0000
35+++ include/unity/scopes/FilterState.h 2015-01-21 12:33:34 +0000
36@@ -51,6 +51,7 @@
37
38 ~FilterState();
39 VariantMap serialize() const;
40+ static FilterState deserialize(VariantMap const& var);
41 /// @endcond
42
43 /**
44
45=== modified file 'src/scopes/FilterBase.cpp'
46--- src/scopes/FilterBase.cpp 2014-05-02 10:19:46 +0000
47+++ src/scopes/FilterBase.cpp 2015-01-21 12:33:34 +0000
48@@ -36,6 +36,10 @@
49 return p->serialize();
50 }
51
52+FilterBase::SCPtr FilterBase::deserialize(VariantMap const& var) {
53+ return internal::FilterBaseImpl::deserialize(var);
54+}
55+
56 FilterBase::~FilterBase() = default;
57 /// @endcond
58
59
60=== modified file 'src/scopes/FilterState.cpp'
61--- src/scopes/FilterState.cpp 2014-03-10 04:17:09 +0000
62+++ src/scopes/FilterState.cpp 2015-01-21 12:33:34 +0000
63@@ -62,6 +62,10 @@
64 return p->serialize();
65 }
66
67+FilterState FilterState::deserialize(VariantMap const& var) {
68+ return internal::FilterStateImpl::deserialize(var);
69+}
70+
71 /// @endcond
72
73 bool FilterState::has_filter(std::string const& id) const
74
75=== modified file 'test/gtest/scopes/Filters/Filters_test.cpp'
76--- test/gtest/scopes/Filters/Filters_test.cpp 2015-01-09 03:16:51 +0000
77+++ test/gtest/scopes/Filters/Filters_test.cpp 2015-01-21 12:33:34 +0000
78@@ -162,13 +162,13 @@
79
80 TEST(Filters, deserialize)
81 {
82- // check that FilterBaseImpl::deserialize() creates valid instances of all filter types
83+ // check that FilterBase::deserialize() creates valid instances of all filter types
84 {
85 OptionSelectorFilter::SPtr filter1 = OptionSelectorFilter::create("f1", "Options", false);
86 auto option1 = filter1->add_option("1", "Option 1");
87 auto var = filter1->serialize();
88
89- auto f = internal::FilterBaseImpl::deserialize(var);
90+ auto f = FilterBase::deserialize(var);
91 EXPECT_TRUE(std::dynamic_pointer_cast<OptionSelectorFilter const>(f) != nullptr);
92 EXPECT_EQ("option_selector", f->filter_type());
93
94@@ -181,7 +181,7 @@
95 auto option1 = filter1->add_option("1", "Option 1");
96 auto var = filter1->serialize();
97
98- auto f = internal::FilterBaseImpl::deserialize(var);
99+ auto f = FilterBase::deserialize(var);
100 EXPECT_TRUE(std::dynamic_pointer_cast<RadioButtonsFilter const>(f) != nullptr);
101 EXPECT_EQ("radio_buttons", f->filter_type());
102
103@@ -193,7 +193,7 @@
104 RatingFilter::SPtr filter1 = RatingFilter::create("f1", "Options", 5);
105 auto var = filter1->serialize();
106
107- auto f = internal::FilterBaseImpl::deserialize(var);
108+ auto f = FilterBase::deserialize(var);
109 EXPECT_TRUE(std::dynamic_pointer_cast<RatingFilter const>(f) != nullptr);
110 EXPECT_EQ("rating", f->filter_type());
111
112@@ -205,7 +205,7 @@
113 SwitchFilter::SPtr filter1 = SwitchFilter::create("f1", "Latest");
114 auto var = filter1->serialize();
115
116- auto f = internal::FilterBaseImpl::deserialize(var);
117+ auto f = FilterBase::deserialize(var);
118 EXPECT_TRUE(std::dynamic_pointer_cast<SwitchFilter const>(f) != nullptr);
119 EXPECT_EQ("switch", f->filter_type());
120
121@@ -217,7 +217,7 @@
122 ValueSliderFilter::SPtr filter1 = ValueSliderFilter::create("f1", "Max size", "Less than %f", 0.0f, 100.0f);
123 auto var = filter1->serialize();
124
125- auto f = internal::FilterBaseImpl::deserialize(var);
126+ auto f = FilterBase::deserialize(var);
127 EXPECT_TRUE(std::dynamic_pointer_cast<ValueSliderFilter const>(f) != nullptr);
128 EXPECT_EQ("value_slider", f->filter_type());
129
130@@ -228,7 +228,7 @@
131 {
132 // invalid data (no filter_type)
133 VariantMap var;
134- EXPECT_THROW(internal::FilterBaseImpl::deserialize(var), unity::LogicException);
135+ EXPECT_THROW(FilterBase::deserialize(var), unity::LogicException);
136 }
137 }
138

Subscribers

People subscribed via source and target branches

to all changes: