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

C#: Deprecate accessor methods and generate correct int and float types #28423

Conversation

neikeq
Copy link
Contributor

@neikeq neikeq commented Apr 25, 2019

@neikeq neikeq added this to the 3.2 milestone Apr 25, 2019
@neikeq neikeq requested a review from reduz as a code owner April 25, 2019 18:32
- Normal log messages are no longer warnings.
- BindingsGenerator is no longer a singleton.
- Added a log function.
- Methods that act as accessors for properties in the same class (like `GetPosition` and `SetPosition` are for `Position`) are now marked as obsolete. They will be made private in the future.
@neikeq neikeq force-pushed the dont-forget-to-think-a-name-for-this-branch branch from a92bfad to f2b35eb Compare April 25, 2019 18:35
core/object.h Outdated
METADATA_INT_IS_UI64,
METADATA_REAL_IS_FLOAT,
METADATA_REAL_IS_DOUBLE
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@reduz Are you fine with this?

Copy link
Member

@reduz reduz Apr 25, 2019

Choose a reason for hiding this comment

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

Nope, please do the following:

  • use a property usage for unsigned
  • use another property usage for 64 bits

There is no point at all in supporting 8 and 16 bits. I prefer this rather than adding yet another field to property info (which is used everywhere), which is just bloat for something so core, and confusing to anyone reading the code.

I know it may bother you to not have the only 4 functions in the whole bindings (which are very rarely used) exposed exactly as they are, but please understand it bothers me a lot more to have to add an extra field to PropertyInfo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can see the point in avoiding the bloat of adding a field to a struct that is used everywhere. What if we surround it with #ifdef DEBUG_METHODS_ENABLED?
I can't take the second statement seriously. This code couldn't be simpler. I can't imagine anyone getting confused by it, let alone annoyed.

Copy link
Member

Choose a reason for hiding this comment

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

I'm very serious about it, a PR like this won't go through. My first priority will always be to keep bloat out of core and this is an extremely core class. If for you this inconsistency is unacceptable, I prefer to remove the 4 occurrences of the < 32 bits arguments so there are no longer any functions using them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does that mean surrounding #ifdef DEBUG_METHODS_ENABLED is not an option? If not, I'm thinking of an alternative to having the field in PropertyInfo.

Copy link
Member

Choose a reason for hiding this comment

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

No, please let's not add hack to that. Definitely go the property usage way and let's get rid of 8/16 bit access if you need them.

Copy link
Member

Choose a reason for hiding this comment

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

Even modern processors don't really support this type of access, it's a thing of the past.

@neikeq
Copy link
Contributor Author

neikeq commented Apr 25, 2019

@karroffel The int/float commit may be of use for GDNative.

core/object.h Outdated
METADATA_INT_IS_UI64,
METADATA_REAL_IS_FLOAT,
METADATA_REAL_IS_DOUBLE
};
Copy link
Member

@reduz reduz Apr 25, 2019

Choose a reason for hiding this comment

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

Nope, please do the following:

  • use a property usage for unsigned
  • use another property usage for 64 bits

There is no point at all in supporting 8 and 16 bits. I prefer this rather than adding yet another field to property info (which is used everywhere), which is just bloat for something so core, and confusing to anyone reading the code.

I know it may bother you to not have the only 4 functions in the whole bindings (which are very rarely used) exposed exactly as they are, but please understand it bothers me a lot more to have to add an extra field to PropertyInfo.

core/object.h Outdated
METADATA_INT_IS_UI64,
METADATA_REAL_IS_FLOAT,
METADATA_REAL_IS_DOUBLE
};
Copy link
Member

Choose a reason for hiding this comment

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

I'm very serious about it, a PR like this won't go through. My first priority will always be to keep bloat out of core and this is an extremely core class. If for you this inconsistency is unacceptable, I prefer to remove the 4 occurrences of the < 32 bits arguments so there are no longer any functions using them.

@neikeq neikeq force-pushed the dont-forget-to-think-a-name-for-this-branch branch 3 times, most recently from e044b17 to 49bd240 Compare April 26, 2019 22:47
@neikeq neikeq force-pushed the dont-forget-to-think-a-name-for-this-branch branch from 49bd240 to 3380565 Compare April 26, 2019 23:49
@neikeq
Copy link
Contributor Author

neikeq commented Apr 27, 2019

Tried it in a different way as a last attempt. Let me know if you don't like this one either.

@reduz
Copy link
Member

reduz commented Apr 27, 2019

I really still think you are over complicating it. That will make it more difficult for those writing binders to understand what it is, and it will add strings to everything that has bindings (I know they are stringnames so it's just a pointer, but still.). The doc generators or code completion may also get confused (or need to take this into consideration) with this given they also use it.

I keep insisting on the approach I proposed and drop 8 and 16 bits. I can remove them from the API if you want, as they are useless.

@neikeq
Copy link
Contributor Author

neikeq commented Apr 27, 2019

That will make it more difficult for those writing binders to understand what it is

This change doesn't affect any existing binders. If they don't decide to use it, nothing changes for them.

and it will add strings to everything that has bindings (I know they are stringnames so it's just a pointer, but still.).

I don't understand what you mean. This code is not using String nor StringName at all. All the code in this commit that uses StringName is in the C# bindings generator.

The doc generators or code completion may also get confused (or need to take this into consideration) with this given they also use it.

The doc generators and code completion won't use this AFAIK. GDScript only supports int (64bit integer) so there is no point in using this, and as I said this doesn't break any existing code, it's a completely opt-in thing.

@neikeq
Copy link
Contributor Author

neikeq commented Apr 27, 2019

I would rather do it this way, but I don't really mind doing it the way you suggested if you ultimately decide so (there are only a few places using byte and short any way). I just don't understand these points.

@reduz
Copy link
Member

reduz commented Apr 28, 2019

Nevermind, I misread the PR. I guess this is OK.

@akien-mga akien-mga merged commit 554c0ea into godotengine:master Apr 29, 2019
@akien-mga
Copy link
Member

Thanks!

@karroffel
Copy link
Contributor

This does not change the way ptrcall receives arguments, right? I'm a bit confused what this does then apart from documentation purposes?

@neikeq
Copy link
Contributor Author

neikeq commented May 3, 2019

@karroffel It does not change anything in ptrcall. This is metadata you can optionally use when generating bindings for a language.

If a C# method has a parameter of type short, this parameter has to be stored in a variable of the correct type in order to pass it to ptrcall. In the case of any integral type that would be int64_t, as defined in core/method_ptrcall.h.

@neikeq neikeq deleted the dont-forget-to-think-a-name-for-this-branch branch May 13, 2021 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

randi() of RandomGenerator returns signed int instead of unsigned int
4 participants