personalrobotics / chimera

:snake: A CLI tool for generating Boost.Python/pybind11 bindings from C/C++
BSD 3-Clause "New" or "Revised" License
13 stars 1 forks source link

Fix #105: generating an extra comma in explicit list of base classes #323

Closed jslee02 closed 4 years ago

jslee02 commented 4 years ago

Chimera uses {{last}} in each template to indicate whether the parent map in a sequence is the last entry. However, this convention is not obeyed when parsing sequence in configuration YAML using wrapYAMLNode().

This PR fixes the issue by updating wrapYAMLNode() to take an optional flag whether to insert last: true entry for the last map entry in a sequence.

Fixes #105

jslee02 commented 4 years ago

This is looking much better -- but it seems like the markLast behavior should not be recursive, right?

I think it's necessary if we want to mark every last map element for all the nested map sequences.

For example:

classes
  - name: ClassA
  - name: ClassB
    bases:
      - BaseA
      - BaseB
      - BaseC
        last: true
  - name: ClassC
    last: true
psigen commented 4 years ago

Hmm.. should we just make a mangled name like __last and always mark the end of sequences?

I am worried that this behavior is a bit inconsistent if it is only applied to a few locations. Here it is only applied to the nested contents of bases()! :thinking:

jslee02 commented 4 years ago

Hmm.. should we just make a mangled name like __last and always mark the end of sequences?

Make sense to me since #105 is one case that caused by inconsistency.