Skip to content

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

Merged
saudet merged 3 commits into
bytedeco:masterfrom
equeim:readonly
Mar 1, 2021
Merged

saudet merged 3 commits into
bytedeco:masterfrom
equeim:readonly

Conversation

@equeim

@equeim equeim commented Feb 14, 2021

Copy link
Copy Markdown
Contributor

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.

boolean inaccessible = false;
boolean objectify = false;
boolean virtualize = false;
boolean readOnlyMembers = false;

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants