ahgilak / deno_gi

Deno port of Gnome libraries (such as Gtk).
https://deno.land/x/deno_gi
30 stars 2 forks source link

Add property typechecks #15

Open vixalien opened 9 months ago

vixalien commented 9 months ago

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:

vixalien commented 8 months ago

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 commented 8 months ago

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.