Skip to content

Commit

Permalink
run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
bates64 committed Nov 29, 2023
1 parent e49d346 commit f4596f6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/content/docs/cheerp/01-tutorials/03-pong.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ void Graphics::keyDownHandler(client::KeyboardEvent* e)
platform.moveRight(400);
}
```

Notice that we are using `fmin` and `fmax` instead of the usual `std::min`/`std::max`. In general, standard library (STL) functions are compiled to Wasm. We can use STL functions from the JS code but there are restrictions. One of these dictates that Wasm functions that have pointers or references to basic types are not available in the JS-annotated part of the code. Indeed, `std::min`/`std::max` get references to basic types while `std::fmin`/`std::fmax` get their inputs by copy. Another solution would have been to wrap `std::min`/`std::max` in non-JS-annotated functions that take `int`s by copy. This limitation will hopefully disappear at some point in the future.

Let's also register an `EventListener` in `Graphics::initializeCanvas`.
Expand Down

0 comments on commit f4596f6

Please sign in to comment.