crossbind
GitHub

Structs and enums

The public fields of a struct become properties, and every member of an enum is there by name.

new Point() creates a Point with both fields at zero, and x and y read and write like any property. step takes the point by value, so C++ works on a copy and returns a new point.

The members of enum class Direction are Direction.North, Direction.East and so on. They pass straight into C++, and a member that comes back is the same object, so === compares them.

A field of a number, a bool or a std::string is a property; a field of vector or class type needs accessor methods. Whatever is private stays inside C++.

Try it
Declare Direction turnLeft(Direction direction); in native.h, define it in native.cpp and walk the square the other way round.
Open in playgroundRuns without a compile until the C++, Rust, packages or imports change.
Console
Press Run, or Ctrl+Enter, to run main.js.
Type to search every guide page and section.
↑↓ navigate↵ openesc close