-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #311 from jwillemsen/jwi-bitsetclass
Generate a class for a bitset
- Loading branch information
Showing
6 changed files
with
116 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
|
||
// generated from <%= ridl_template_path %> | ||
/// @copydoc <%= doc_scoped_name %> | ||
/// THIS MAPPING IS NOT COMPLETE | ||
struct <%= cxxname %> | ||
/// @todo THIS MAPPING IS NOT COMPLETE | ||
class <%= cxxname %><% unless base.nil? %> : public <%= base.cxxname %><% end %> | ||
{ | ||
%bitfields.each do |_bitfield| | ||
/// @copydoc #{doc_scoped_name}::#{_bitfield.name} | ||
<%= _bitfield.cxx_member_type %> <%= _bitfield.cxxname %> : <%= _bitfield.bits %>; | ||
public: | ||
<%= cxxname %> () = default; | ||
~<%= cxxname %> () noexcept = default; | ||
<%= cxxname %> (const <%= cxxname %>&) = default; | ||
<%= cxxname %> (<%= cxxname %>&&) = default; | ||
<%= cxxname %>& operator= (const <%= cxxname %>&) = default; | ||
<%= cxxname %>& operator= (<%= cxxname %>&&) = default; | ||
|
||
%bitfields.each do |_m| | ||
% unless _m.cxxname.empty? | ||
inline void <%= _m.cxxname %> (<%= _m.cxx_in_type %> _x11_<%= _m.cxxname %>) { this->_taox11_<%= cxxname.downcase %>.<%= _m.cxxname %> = _x11_<%= _m.cxxname %>; } | ||
inline <%= _m.cxx_in_type %> <%= _m.cxxname %> () const { return this->_taox11_<%= cxxname.downcase %>.<%= _m.cxxname %>; } | ||
% end | ||
%end | ||
|
||
private: | ||
struct | ||
{ | ||
%bitfields.each do |bitfield| | ||
/// @copydoc #{bitfield.doc_scoped_name}::#{bitfield.name} | ||
<%= bitfield.cxx_member_type %> <%= bitfield.cxxname %> : <%= bitfield.bits %>; | ||
%end | ||
} _taox11_<%= cxxname.downcase %>; | ||
}; // <%= cxxname %> | ||
|
||
% visit_template('typecode') if generate_typecode_support? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
%# TODO handle inheritance | ||
// generated from <%= ridl_template_path %> | ||
template<> | ||
struct traits <<%= scoped_cxxtype %>> | ||
: IDL::common_byval_traits<<%= scoped_cxxtype %>> | ||
{ | ||
template <typename OStrm_, typename Formatter = formatter<value_type, OStrm_>> | ||
static inline OStrm_& write_on(OStrm_& os_, in_type val_, Formatter fmt_ = Formatter ()) | ||
{ | ||
return fmt_ (os_, val_); | ||
} | ||
|
||
template <typename Formatter = std::false_type> | ||
static inline __Writer<Formatter> write (in_type val) { return {val}; } | ||
}; | ||
|
||
template <typename OStrm_> | ||
struct formatter<<%= scoped_cxxtype %>, OStrm_> | ||
{ | ||
inline OStrm_& operator ()(OStrm_& os_, <%= scoped_cxx_in_type %> val_) | ||
{ | ||
%_sep = nil | ||
os_ << "<%= formatted_cxxname %>{" | ||
%bitfields.each do |_m| | ||
% unless _m.cxxname.empty? | ||
<< "<%= _sep %><%= _m.cxxname %>=" << IDL::traits<<%= _m.scoped_cxxtype %>>::write(val_.<%= _m.cxxname %> ()) | ||
% _sep = ',' unless _sep | ||
% end | ||
%end | ||
<< '}'; | ||
return os_; | ||
} | ||
}; | ||
|
||
template <typename OStrm_, typename Fmt> | ||
inline OStrm_& operator <<(OStrm_& os, IDL::traits<<%= scoped_cxxtype %>>::__Writer<Fmt> w) | ||
{ | ||
using writer_t = IDL::traits<<%= scoped_cxxtype %>>::__Writer<Fmt>; | ||
using formatter_t = typename std::conditional< | ||
std::is_same< | ||
typename writer_t::formatter_t, | ||
std::false_type>::value, | ||
formatter<<%= scoped_cxxtype %>, OStrm_>, | ||
typename writer_t::formatter_t>::type; | ||
return IDL::traits<<%= scoped_cxxtype %>>::write_on (os, w.val_, formatter_t ()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @file bitset_inherit_struct.idl | ||
* @author Johnny Willemsen | ||
* | ||
* ridlc shall reject use of a bitset which inherits from a struct | ||
* | ||
* @copyright Copyright (c) Remedy IT Expertise BV | ||
*/ | ||
|
||
struct Base { | ||
short Foo; | ||
}; | ||
|
||
bitset MyBitset : Base { | ||
bitfield<6> x; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @file bitset_multiple_inheritance.idl | ||
* @author Johnny Willemsen | ||
* | ||
* ridlc shall reject use of a bitset which inherits from multiple bases | ||
* | ||
* @copyright Copyright (c) Remedy IT Expertise BV | ||
*/ | ||
|
||
bitset Base1 { | ||
bitfield<1> y; | ||
}; | ||
|
||
bitset Base2 { | ||
bitfield<1> z; | ||
}; | ||
|
||
bitset MyBitset : Base1, Base2 { | ||
bitfield<6> x; | ||
}; |