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

QByteArrayView is special.. #184

Open
arnetheduck opened this issue Mar 13, 2025 · 3 comments
Open

QByteArrayView is special.. #184

arnetheduck opened this issue Mar 13, 2025 · 3 comments
Labels
duplicate This issue or pull request already exists wishlist

Comments

@arnetheduck
Copy link
Contributor

Similar to QByteArray but without the copy, this view-only type probably should be mapped to miqt_string - this also begs the question what to do with overloads that both decay to miqt_string, ie they likely can be removed such as in https://doc.qt.io/qt-6/qbytearraymatcher.html#QByteArrayMatcher-4

@arnetheduck
Copy link
Contributor Author

arnetheduck commented Mar 14, 2025

Ditto QAnyStringView

@mappu
Copy link
Owner

mappu commented Mar 15, 2025

Probably a duplicate of #142. 😄

Projecting as a miqt_string is reasonable. For Go there is a caveat that C(++) cannot hold pointers to Go memory beyond the lifetime of a C call in case Go GC's the memory, so depending exactly on the Qt API in question, there may need to be a memory copy anyway.

@mappu mappu added duplicate This issue or pull request already exists wishlist labels Mar 15, 2025
@arnetheduck
Copy link
Contributor Author

there may need to be a memory copy anyway.

I think the intent of the type is that it's used only temporarily, ie passing in a regex that gets parsed to some internal structure - or in the case that it outlives the one function call, the caller can be responsible for ensuring things don't get collected (by holding a reference) - I came across it with QMetaType::fromName where it's used as a lookup key for example - here, a copy would be counterproductive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists wishlist
Projects
None yet
Development

No branches or pull requests

2 participants