Skip to content

Improved our JavaScript and Python bindings#558

Merged
agarny merged 5 commits into
opencor:mainfrom
agarny:bindings
May 28, 2026
Merged

Improved our JavaScript and Python bindings#558
agarny merged 5 commits into
opencor:mainfrom
agarny:bindings

Conversation

@agarny

@agarny agarny commented May 28, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 28, 2026 12:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Improves the JavaScript and Python language bindings by adding Pythonic/JavaScript-idiomatic interfaces on top of the existing C++-style API: vectors exposed to JS now expose .length and are iterable (so callers can use for..of, spread, etc. instead of .size()/.get(i)); Python File, FileManager, SedInstance, Issue, and Solver types get __repr__/__str__/__len__/__iter__ where appropriate. The test suites are updated to use these more idiomatic patterns, replacing == True/== False/== None with truthiness/is None checks and replacing .size() with .length.

Changes:

  • Add __repr__, __str__, __len__, and __iter__ bindings to relevant Python classes; add toString and array-like .length + Symbol.iterator to relevant JS classes.
  • Update Python tests to use truthiness / is None / is not None and new iteration helpers (len(instance), list(instance), len(file_manager), list(file_manager)).
  • Update JS tests and example script to use .length and for..of over registered vector types.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
VERSION.txt Bumps patch version.
src/bindings/python/file.cpp Adds __repr__ to File and __len__/__iter__ to FileManager.
src/bindings/python/logger.cpp Adds __repr__/__str__ to Issue.
src/bindings/python/sed.cpp Adds __len__/__iter__ to SedInstance.
src/bindings/python/solver.cpp Adds __repr__ to Solver.
src/bindings/javascript/logger.cpp Adds toString() to Issue.
src/bindings/javascript/solver.cpp Adds toString() to Solver.
src/bindings/javascript/main.cpp Adds length getter and Symbol.iterator to all registered vector types via EM_ASM.
tests/bindings/python/test_*.py Switches assertions to idiomatic truthiness / is None and exercises new iter/len.
tests/bindings/python/test_logger_coverage.py Adds test_issue_str covering __str__.
tests/bindings/javascript/*.test.js Switches .size() to .length and adds toString() test.
tests/bindings/javascript/utils.in.js Uses Array.from(issues).entries() instead of indexed access.
tests/bindings/javascript/res/res/libopencor.js Uses for..of over issues and files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/bindings/javascript/main.cpp Outdated
Comment thread src/bindings/javascript/main.cpp
@agarny agarny force-pushed the bindings branch 2 times, most recently from b604a4d to 1c9df90 Compare May 28, 2026 12:59
@agarny agarny merged commit c7fe06f into opencor:main May 28, 2026
46 of 48 checks passed
@agarny agarny deleted the bindings branch May 28, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants