NatLabRockies / NatLabRockies/OpenStudio

Update to latest SWIG so we can use std_string_view.i

Open
#5,393 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component - C# component - Python bindings component - Ruby bindings Developer Issue Enhancement Request
Dominant language
C++
Stars
646
Forks
237
Avg merge
3d 11h
Merged PRs (30d)
10

Description

Enhancement Request

While working on:

I realized we have missing typemaps for std::string_view in Utilities, for getSharedModulePrefix() for eg

https://github.com/NREL/OpenStudio/blob/a882f64d0989414b26e18dc071415740ee92c43c/src/utilities/core/ApplicationPathHelpers.hpp#L54-L60

This is also the same thing for Python mind you.

In [1]: import openstudio
ope
In [2]: openstudio.getSharedModulePrefix()
Out[2]: <Swig Object of type 'std::string_view *' at 0x7664d3189d40>

In [3]: print(openstudio.getSharedModulePrefix())
<Swig Object of type 'std::string_view *' at 0x7664ba3ccd50>
swig/python detected a memory leak of type 'std::string_view *', no destructor found.

Detailed Description

Swig 4.2.0 added a std_string_view.i (which is NOT in stl.i by default I think).

Possible Implementation

I am diffing the conan-center-index recipe that is currently used upstream with the custom one I used to upload to NREL's artifactory, and I'm not seeing minimal diffs, so there's a good chance it'll work right out of the box.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/utilities/core/ApplicationPathHelpers.hpp around getSharedModulePrefix() and inspect the current SWIG and Conan configuration. Check how SWIG 4.2.0 provides std_string_view.i, then verify the Python binding returns a string without the reported Swig object or memory-leak warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.