Closed rfk closed 4 years ago
This isn't a Nimbus blocker, right? The fanciest data type in @tarikeshaq's proposed IDL is ApplicationContext
, and that's a dictionary
so it has value semantics, but just wanted to double-check!
I'll try to make this issue 😉
Great, thanks for diving in!
Make sure the sprites example still runs and outputs sensible result (in lieu of actual tests, which are forthcoming).
I should note, since I wrote the above, the examples have evolved into actual (if pretty minimal) tests, which will run here in CI or can be executed using cargo test
if you have all the various command-line tools for the different target languages installed.
Currently, every rust function exposed over the FFI is expected to take ownership of its arguments. This is most obvious in the existing "sprites" example, where the code for
translate
has to be declared as:fn translate(p: Point, v: Vector) -> Point
Which means that when the
move_to
method of theSprite
class calls it, it has to pass in a clone:self.current_position = translate(self.current_position.clone(), direction)
Making this more egonomic could be a good opportunity for somone new to the codebase to get familiar with it. The challenge would be to update the sprites example so that the
translate
function is declared as:fn translate(p: &Point, v: &Vector) -> Point
And the
.clone()
mentioned above can be removed.In order to achieve this I think you would need to:
Argument
struct so that it's available when you're generating the code.Argument
struct that currently says "argument attributes are not yet supported", which corresponds to the extended attributes feature of WebIDL.translate
function insprites.idl
, something likePoint translate([ByRef] Point position, [ByRef] Vector direction)
.attributes
member on the arguments that we get back from the WebIDL parser!Argument
strut, then use that flag during code-gen to know whether to pass by reference.┆Issue is synchronized with this Jira Task