From 7b0bd7ea3c0f942b696c9a2b0632fbfba81d80bb Mon Sep 17 00:00:00 2001 From: Omer Majeed Date: Sat, 4 Nov 2023 01:36:22 +0500 Subject: [PATCH] spotlessApply to fix the indentation --- .../org/lflang/generator/c/CGenerator.java | 14 +++---- test/C/src/ParentParamsAccessToChildInit.lf | 41 +++++++++++-------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/core/src/main/java/org/lflang/generator/c/CGenerator.java b/core/src/main/java/org/lflang/generator/c/CGenerator.java index cc3a383500..4d77463c4f 100644 --- a/core/src/main/java/org/lflang/generator/c/CGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CGenerator.java @@ -1726,13 +1726,13 @@ public void generateReactorInstance(ReactorInstance instance) { startTimeStep.startScopedBlock(child); initializeTriggerObjects.startScopedBlock(child); // Generate the parent self struct for children to access its params - initializeTriggerObjects.pr( - CUtil.selfType(instance) - + " *self = " - + CUtil.reactorRefName(instance) - + "[" - + CUtil.runtimeIndex(instance) - + "];"); + initializeTriggerObjects.pr( + CUtil.selfType(instance) + + " *self = " + + CUtil.reactorRefName(instance) + + "[" + + CUtil.runtimeIndex(instance) + + "];"); generateReactorInstance(child); initializeTriggerObjects.endScopedBlock(); startTimeStep.endScopedBlock(); diff --git a/test/C/src/ParentParamsAccessToChildInit.lf b/test/C/src/ParentParamsAccessToChildInit.lf index e1f0eb4aa4..8325d65150 100644 --- a/test/C/src/ParentParamsAccessToChildInit.lf +++ b/test/C/src/ParentParamsAccessToChildInit.lf @@ -1,24 +1,31 @@ -target C; +target C + preamble {= - extern int child_ids[10]; + extern int child_ids[10]; =} -reactor Child (bank_index:int = 0, parent_index:int = 0, value:int = 0) { - preamble {= - int child_ids[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - =} - reaction (startup) {= - printf("Child bank_index:%d parent_index:%d value:%d\n", self->bank_index, self->parent_index, self->value); - =} +reactor Child(bank_index: int = 0, parent_index: int = 0, value: int = 0) { + preamble {= + int child_ids[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + =} + + reaction(startup) {= + printf("Child bank_index:%d parent_index:%d value:%d\n", self->bank_index, self->parent_index, self->value); + =} } -reactor Parent (bank_index:int = 0, n_parents:int = 0, n_children:int = 1) { - c = new [n_children] Child (parent_index = {=self->bank_index=}, value = {=child_ids[(self->bank_index * self->n_children + bank_index) % (sizeof(child_ids) / sizeof(*child_ids))]=}) - reaction (startup) {= - printf("Parent[%d/%d] bank_index:%d\n", self->bank_index + 1, self->n_parents, self->bank_index); - =} +reactor Parent(bank_index: int = 0, n_parents: int = 0, n_children: int = 1) { + c = new[n_children] Child( + parent_index=bank_index, + value = {= + child_ids[(self->bank_index * self->n_children + bank_index) % (sizeof(child_ids) / sizeof(*child_ids))] + =}) + + reaction(startup) {= + printf("Parent[%d/%d] bank_index:%d\n", self->bank_index + 1, self->n_parents, self->bank_index); + =} } -main reactor ParentParamsAccessToChildInit (n_parents:int = 2, per_parent_n_children:int = 3) { - p = new [n_parents] Parent (n_parents = n_parents, n_children = per_parent_n_children); -} \ No newline at end of file +main reactor ParentParamsAccessToChildInit(n_parents: int = 2, per_parent_n_children: int = 3) { + p = new[n_parents] Parent(n_parents=n_parents, n_children=per_parent_n_children) +}