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 property typechecks #15

Open
vixalien opened this issue Dec 14, 2023 · 2 comments
Open

Add property typechecks #15

vixalien opened this issue Dec 14, 2023 · 2 comments

Comments

@vixalien
Copy link
Contributor

vixalien commented Dec 14, 2023

When setting a property on an object, the bindings assume the correct type was passed. For example, when setting an uint8 property, the bindings assume that a comparable number was given.

It would be better to check the values given before setting properties. Here are some ways this can improve UX and help reduce programmer errors:

  • Emit a warning when a high number value is set for a uint8 (maybe the integer is out of range, or a boolean was passed)
  • Warn when a floating type was converted to an integer
  • Don't allow setting integers to string properties and vice versa.
  • Check if function parameters are correct, too.
@vixalien
Copy link
Contributor Author

vixalien commented Jan 6, 2024

Another idea is automatically converting different datatypes if possible, for easier GLib compatibility. For example, a JS object or a map can be converted to and from a HashMap instead of forcing the user to do the conversion always manually.

There could be other smart conversions too, like converting a JS Set to an array, etc..

@ahgilak
Copy link
Owner

ahgilak commented Jan 6, 2024

Another idea is automatically converting different datatypes if possible, for easier GLib compatibility. For example, a JS object or a map can be converted to and from a HashMap instead of forcing the user to do the conversion always manually.

Does GJS (or any other bindings) does such thing?

It would be fairly hard to implement that because arguments are not always constants.
you have to proxy the original object and apply every changes made to it on the new object.

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