Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for std::set and std::list #15

Open
dsogari opened this issue Jan 23, 2024 · 3 comments
Open

Support for std::set and std::list #15

dsogari opened this issue Jan 23, 2024 · 3 comments

Comments

@dsogari
Copy link

dsogari commented Jan 23, 2024

Sorry to bother you again... :P

It appears that std::set and std::list are not supported for JavaScript, although they are supported for languages such as Java, Ruby and Python. Would it be too difficult to implement this feature? I would definitely tackle this myself if I had enough knowledge of the SWIG codebase. If you can give me some pointers, I could give it a shot.

@dsogari dsogari changed the title Support for std::set Support for std::set and std::list Jan 23, 2024
@mmomtchev
Copy link
Owner

std::list will be the same as std::vector and in fact the best way to do it is to probably transform the current std::vector maps so that they can be used with any STL that supports forward iterators.

However std::set is much problematic since the JS Set does not have a C++ API, it is a userland implementation and any C++ wrapper will have to call the JS methods.

@dsogari
Copy link
Author

dsogari commented Jan 25, 2024

Hm, I guess you're right. But isn't it just a matter of providing an interface matching the JS Set, instead of actually using a JS Set? A user might complain about lack of idiomaticity, but at least they can call their functions.

@mmomtchev
Copy link
Owner

This you can already do: you can simply wrap std::set by using %template(IntegerSet) std::set<int>; and you will get a JavaScript-accessible class called IntegerSet that will be fully usable. But you won't have transparent and automatic conversion of arguments.

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

No branches or pull requests

2 participants