Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
    * ridlbe/c++11/visitors/struct.rb:
    * tests/idl4/struct_cppmapping/test.idl:
  • Loading branch information
jwillemsen committed Oct 23, 2024
1 parent a840a2e commit 6094278
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions ridlbe/c++11/visitors/struct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,25 @@ def base

# Which cpp_mapping we should use, default to class with methods
def cpp_mapping
return 'CLASS_WITH_PUBLIC_ACCESSORS_AND_MODIFIERS' unless node.annotations[:cpp_mapping].first.nil?
node.annotations[:cpp_mapping].first
return 'CLASS_WITH_PUBLIC_ACCESSORS_AND_MODIFIERS' if node.annotations[:cpp_mapping].first.nil?
node.annotations[:cpp_mapping].first.fields[:value]
end

# How can we access a struct member, directly or through a method call
def member_accessor
' ()' if cpp_mapping == 'CLASS_WITH_PUBLIC_ACCESSORS_AND_MODIFIERS'
return ' ()' if cpp_mapping == 'CLASS_WITH_PUBLIC_ACCESSORS_AND_MODIFIERS'
''
end

# Possible postfix for all members in C++
def member_postfix
'_' if cpp_mapping == 'CLASS_WITH_PUBLIC_ACCESSORS_AND_MODIFIERS'
return '_' if cpp_mapping == 'CLASS_WITH_PUBLIC_ACCESSORS_AND_MODIFIERS'
''
end

# Do we map to a C++ class or struct
def class_struct
'class' if cpp_mapping == 'CLASS_WITH_PUBLIC_ACCESSORS_AND_MODIFIERS'
return 'class' if cpp_mapping == 'CLASS_WITH_PUBLIC_ACCESSORS_AND_MODIFIERS'
'struct'
end

Expand Down
4 changes: 2 additions & 2 deletions tests/idl4/struct_cppmapping/test.idl
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* @copyright Copyright (c) Remedy IT Expertise BV
*/

@struct_mapping(STRUCT_WITH_PUBLIC_MEMBERS)
@cpp_mapping(STRUCT_WITH_PUBLIC_MEMBERS)
struct bar_struct {
short b;
};

@struct_mapping(CLASS_WITH_PUBLIC_ACCESSORS_AND_MODIFIERS)
@cpp_mapping(CLASS_WITH_PUBLIC_ACCESSORS_AND_MODIFIERS)
struct bar_class {
short b;
};

0 comments on commit 6094278

Please sign in to comment.