Skip to content

Commit

Permalink
Added lf_reactor_name function
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardalee committed Dec 29, 2024
1 parent 5e27792 commit 6306c11
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
2 changes: 2 additions & 0 deletions core/reactor_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ void lf_set_stop_tag(environment_t* env, tag_t tag) {
}
}

const char* lf_reactor_name(self_base_t* self) { return self->name; }

const char* lf_reactor_full_name(self_base_t* self) {
if (self->full_name != NULL) {
return self->full_name;
Expand Down
15 changes: 15 additions & 0 deletions include/api/reaction_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,23 @@
*/
#define lf_time_logical_elapsed() lf_time_logical_elapsed(self->base.environment)

/**
* @brief Return the instance name of the reactor.
*
* The instance name is the name of given to the instance created by the `new` operator in LF.
* If the instance is in a bank, then the name will have a suffix of the form `[bank_index]`.
*
* @param reactor The reactor to get the name of.
*/
#define lf_reactor_name(reactor) lf_reactor_name(&reactor->base)

/**
* @brief Return the fully qualified name of the reactor.
*
* The fully qualified name of a reactor is the instance name of the reactor concatenated with the names of all
* of its parents, separated by dots. If the reactor or any of its parents is a bank, then the name
* will have a suffix of the form `[bank_index]`.
*
* @param reactor The reactor to get the name of.
*/
#define lf_reactor_full_name(reactor) lf_reactor_full_name(&reactor->base)
Expand Down
1 change: 1 addition & 0 deletions include/api/reaction_macros_undef.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#undef lf_time_logical
#undef lf_time_logical_elapsed

#undef lf_reactor_name
#undef lf_reactor_full_name

#endif // REACTION_MACROS_H
4 changes: 2 additions & 2 deletions include/core/lf_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ struct trigger_t {
* An allocation record that is used by a destructor for a reactor
* to free memory that has been dynamically allocated for the particular
* instance of the reactor. This will be an element of linked list.
* If the indirect field is true, then the allocated pointer points to
* pointer to allocated memory, rather than directly to the allocated memory.
* The `allocated` pointer points to the allocated memory, and the `next`
* pointer points to the next allocation record (or NULL if there are no more).
*/
typedef struct allocation_record_t {
void* allocated;
Expand Down
15 changes: 13 additions & 2 deletions include/core/reactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,22 @@ void lf_free_all_reactors(void);
*/
void lf_free_reactor(self_base_t* self);

/**
* @brief Return the instance name of the reactor.
*
* The instance name is the name of given to the instance created by the `new` operator in LF.
* If the instance is in a bank, then the name will have a suffix of the form `[bank_index]`.
*
* @param self The self struct of the reactor.
*/
const char* lf_reactor_name(self_base_t* self);

/**
* @brief Return the full name of the reactor.
*
* The full name includes the names of all the parent reactors, separated by dots.
* If any reactor is a bank, the name will have a suffix of the form `[bank_index]`.
* The fully qualified name of a reactor is the instance name of the reactor concatenated with the names of all
* of its parents, separated by dots. If the reactor or any of its parents is a bank, then the name
* will have a suffix of the form `[bank_index]`.
*
* @param self The self struct of the reactor.
*/
Expand Down

0 comments on commit 6306c11

Please sign in to comment.