Skip to content

Commit

Permalink
Merge pull request #87 from robotpy/destructor
Browse files Browse the repository at this point in the history
Use destroy functions as destructors
  • Loading branch information
virtuald committed Jan 14, 2019
2 parents 414b2f7 + 9ba13d3 commit 448ff77
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion gen/CANifier_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ c_CANifier_Create1:
self.hal_data[v] = 0.001 # What's the default?
hal_data['CAN'][deviceNumber] = self.hal_data
c_CANifier_Destroy:
ignore: true
c_CANifier_DestroyAll:
ignore: true # TODO
ignore: true
c_CANifier_GetDescription:
ignore: true # TODO
get: description
Expand Down
4 changes: 3 additions & 1 deletion gen/MotController_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@ c_MotController_Create1:
hal_data['CAN'][deviceId] = self.hal_data
self._notifier = None
c_MotController_Destroy:
ignore: true
c_MotController_DestroyAll:
ignore: true # TODO
ignore: true
c_MotController_GetDeviceNumber:
code: |
retval = self._deviceId
Expand Down
4 changes: 3 additions & 1 deletion gen/PigeonIMU_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ c_PigeonIMU_Create1:
internal: true
code: |
self.create_called = True
c_PigeonIMU_Destroy:
ignore: true
c_PigeonIMU_DestroyAll:
ignore: true # TODO
ignore: true
c_PigeonIMU_GetDescription:
ignore: true # TODO
code: |
Expand Down
6 changes: 5 additions & 1 deletion gen/gen_wrapcci.hpp.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ class {{ module_name }}{% if inherits is defined %} : public {{ inherits }}{% en
public:
{% for header in headers %}
{% for fn in header.functions %}
{% if 'ignore' not in fn.data %}
{% if fn.x_name == 'destroy' %}
~{{ module_name}}() {
{{ fn.name }}(m_handle);
}
{% elif 'ignore' not in fn.data %}
{% if fn.x_name.startswith('_create') %}
void {{ fn.x_name }}({{ fn.x_in_params | join(', ', attribute='x_decl') }}) {
m_handle = {{ fn.name }}({{ fn.parameters[0:] | join(', ', attribute='x_callname') }});
Expand Down

0 comments on commit 448ff77

Please sign in to comment.