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

Add Info.readOnlyMembers to disable generating setters for publi… #461

Merged
merged 3 commits into from
Mar 1, 2021

Conversation

equeim
Copy link
Contributor

@equeim equeim commented Feb 14, 2021

Sometimes it is needed to pass data from C++ to Java in form of struct, but there is no need to make it mutable. In this case, generated setter methods are unused and only increase size of native library and compiled Java classes.

@@ -62,6 +63,7 @@
boolean inaccessible = false;
boolean objectify = false;
boolean virtualize = false;
boolean readOnlyMembers = false;
Copy link
Member

Choose a reason for hiding this comment

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

For consistency, what about naming this "constify"? (It's actually a term that C++ programmers use!)

Copy link
Member

Choose a reason for hiding this comment

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

Or maybe just "immutable"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But that way this property would also have to disable non-const C++ methods (and maybe some other things too) otherwise it would be confusing.

Although, current name also doesn't make it 100% clear that it deals only with data members, since methods in C++ are technically called member functions.

Copy link
Member

Choose a reason for hiding this comment

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

Right w.r.t to "const", but "immutable" can only refer to data and usually only to "properties", even in the case of C++. Functions, or even variables for that matter, are not "properties", because well we can't do things like make them immutable. :)

Copy link
Member

Choose a reason for hiding this comment

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

I see, we can't currently apply this to individual fields, but ideally it's something that it should let us do. I guess we can wait until someone asks for it before implementing this though.

@saudet saudet merged commit 7ad5b66 into bytedeco:master Mar 1, 2021
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.

None yet

2 participants