Extract attach-bsdl into core; add it to the wx GUI.
Second editing op into the wx frontend. Extract the logic (parse the .bsd,
apply it to the part, record bsdl_path) into core/app/edit.hpp::attach_bsdl
(Part*, path) -> {ok, error, entity, bound, unbound, ports_total}, failing
without mutation when the file can't be parsed.
The TUI `attach-bsdl` command now renders that result (output unchanged); the
wx GUI gains an Edit ▸ Attach BSDL… menu reusing PickPart() + a .bsd file
dialog. Prune the now-dead bsdl_model include from commands.cpp.
tests/test_edit.cpp: parse failure leaves the part untouched; null part. The
success path is covered by a batch run (entity + bound/total ports). 381 core
assertions green; tui + wx build clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,22 @@ struct SetConnectorTypeResult {
|
||||
// (ok=false, error set, no mutation) when the kind is invalid for the part.
|
||||
SetConnectorTypeResult set_connector_type(Part *part, const std::string &kind);
|
||||
|
||||
// Outcome of attaching a BSDL model to a part. On success the part's pin specs
|
||||
// are filled from the model and its bsdl_path is recorded.
|
||||
struct AttachBsdlResult {
|
||||
bool ok = false;
|
||||
std::string error; ///< set when the .bsd cannot be parsed
|
||||
std::string entity; ///< the BSDL entity name
|
||||
int bound = 0; ///< ports matched to a pin
|
||||
int unbound = 0; ///< ports with no matching pin
|
||||
int ports_total = 0; ///< ports declared in the model
|
||||
};
|
||||
|
||||
// Parse the BSDL file at `path` and apply it to `part` (fills each pin's role
|
||||
// and direction; records bsdl_path). Fails (ok=false, error set, no mutation)
|
||||
// when the file cannot be parsed.
|
||||
AttachBsdlResult attach_bsdl(Part *part, const std::string &path);
|
||||
|
||||
} // namespace app
|
||||
|
||||
#endif // _APP_EDIT_HPP_
|
||||
|
||||
Reference in New Issue
Block a user