From db37034d119012df505d7c6bbdd5dcd42a3407f0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 19 Dec 2017 09:30:57 -0800 Subject: [PATCH] Add some notes about impl details of objects --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 2240a783..ab903c9a 100644 --- a/README.md +++ b/README.md @@ -341,6 +341,7 @@ macro itself. Arguments allowed are: * Owned strings (`String`) * Owned structs (`Foo`) defined in the same bindgen macro * Borrowed structs (`&Foo` or `&mut Bar`) defined in the same bindgen macro +* The `JsObject` type and `&JsObject` (not mutable references) All of the above can also be returned except borrowed references. Strings are implemented with shim functions to copy data in/out of the Rust heap. That is, a @@ -353,6 +354,10 @@ pointer. The pointer is to have a defined ABI, and the `RefCell` is to ensure safety with reentrancy and aliasing in JS. In general you shouldn't see `RefCell` panics with normal usage. +JS-values-in-Rust are implemented through indexes that index a table generated +as part of the JS bindings. This table is managed via the ownership specified in +Rust and through the bindings that we're returning. + All of these constructs currently create relatively straightforward code on the JS side of things, mostly haveing a 1:1 match in Rust with JS.