Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for C methods #1215

Merged
merged 3 commits into from
Jun 10, 2022
Merged

Support for C methods #1215

merged 3 commits into from
Jun 10, 2022

Conversation

edwardalee
Copy link
Collaborator

I've added support for methods in C because I need this to implement LET.
The invocation of a method in target code is a bit awkward.
You have to do this:

    self->my_method(self, my_arguments);

But with this design, method names need not be unique across reactors.

@Soroosh129
Copy link
Contributor

There is an alternative way to do this using #define and #undef within the body of reactions.

foo_reaction_function_1(...) {
    #define my_method(var1, var2) foo_my_method(self, var1, var2)

    #undef my_method
}

This would make the syntax for accessing methods slightly different though from the syntax for accessing state variables.

@edwardalee
Copy link
Collaborator Author

Great idea! I will do this.

@lhstrh
Copy link
Member

lhstrh commented Jun 7, 2022

I personally don't find using the self struct to find a method all that awkward. In fact, that's were I would look for them given that's where state variables live...

Copy link
Contributor

@Soroosh129 Soroosh129 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@edwardalee edwardalee merged commit 6e34cc2 into master Jun 10, 2022
@Soroosh129 Soroosh129 deleted the c-methods branch July 1, 2022 22:45
@Soroosh129 Soroosh129 added enhancement Enhancement of existing feature c Related to C target labels Jul 1, 2022
@lhstrh lhstrh added feature New feature and removed enhancement Enhancement of existing feature labels Jul 7, 2022
@lhstrh lhstrh changed the title Added support for C methods Support for C methods Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c Related to C target feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants