Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Lara-JS/scripts/build-interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ import {
registerJoinpointMapper,
wrapJoinPoint,
unwrapJoinPoint,
} from "lara-js/api/LaraJoinPoint.js";\n\n`
} from "lara-js/api/LaraJoinPoint.js";
import eventListener from "./clava/events/EventListener.js";
import { Event, EventTime } from "./clava/events/Events.js";\n\n`
Comment on lines +65 to +66
Copy link
Member

Choose a reason for hiding this comment

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

The LARA framework should not know about the existence of Clava, which uses it. This is a sign that the events code currently in the Clava repository should be moved to the LARA framework repository, into the adequate folder.

I suggest moving moving the files to lara-framework/Lara-JS/src-api/lara/events and update imports accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

After looking at the code in PR#157, it is not immediately possible to move the code the the lara-framework, it would need further refactoring in order to separate the Events interface from the Clava-specific implementation.

);

generateDefaultAttributeMappers(specification.joinpoints, outputFile);
Expand Down
19 changes: 17 additions & 2 deletions Lara-JS/scripts/generate-ts-joinpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,28 @@ function generateJoinpointAction(action, outputFile, joinpoints) {
)
.join(", ");

const eventParameters = action.parameters
.map((parameter) => parameter.name.split(":")[0])
.join(", ");

fs.writeSync(
outputFile,
`${generateDocumentation(action.tooltip)} ${action.name}(${parameters}): ${
action.returnType
} { return wrapJoinPoint(this._javaObject.${
} {
eventListener.emit("ACTION", new Event(EventTime.BEFORE, "${
action.name
}", this, undefined${
eventParameters.length > 0 ? `, ${eventParameters}` : ""
}));
const res = wrapJoinPoint(this._javaObject.${
action.name
}(${callParameters})); }\n`
}(${callParameters}));
eventListener.emit("ACTION", new Event(EventTime.AFTER, "${
action.name
}", this, res${eventParameters.length > 0 ? `, ${eventParameters}` : ""}));
return res;
}\n`
);
}

Expand Down