From e8db7adeec2ca3d93fa6996ac08fd79edeffdfe1 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Tue, 28 Jan 2014 10:28:31 -0800 Subject: [PATCH 1/2] Expose API to inhibit GC. --- jsapi.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jsapi.rs b/jsapi.rs index 2288435b9..c353b8ef2 100644 --- a/jsapi.rs +++ b/jsapi.rs @@ -940,6 +940,10 @@ pub fn JS_GC(rt: *JSRuntime); pub fn JS_MaybeGC(cx: *JSContext); +pub fn JS_InhibitGC(cx: *JSContext); + +pub fn JS_AllowGC(cx: *JSContext); + pub fn JS_SetGCCallback(rt: *JSRuntime, cb: JSGCCallback); pub fn JS_SetFinalizeCallback(rt: *JSRuntime, cb: JSFinalizeCallback); From 6a9db14da31271868090963067e1e689904e515d Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Wed, 29 Jan 2014 18:16:47 -0800 Subject: [PATCH 2/2] Add trace hook deriving via Encoder/Encodable. --- js.rc | 1 + trace.rs | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 trace.rs diff --git a/js.rc b/js.rc index e8fd315ba..272eee0dc 100644 --- a/js.rc +++ b/js.rc @@ -44,6 +44,7 @@ pub mod name_pool; pub mod rust; pub mod global; pub mod glue; +pub mod trace; pub mod crust; pub mod jsval; pub mod jsfriendapi; diff --git a/trace.rs b/trace.rs new file mode 100644 index 000000000..e2ecd72db --- /dev/null +++ b/trace.rs @@ -0,0 +1,81 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use jsapi::JSTracer; + +use extra::serialize::Encoder; + +impl Encoder for JSTracer { + fn emit_nil(&mut self) {} + fn emit_uint(&mut self, _v: uint) {} + fn emit_u64(&mut self, _v: u64) {} + fn emit_u32(&mut self, __v: u32) {} + fn emit_u16(&mut self, _v: u16) {} + fn emit_u8(&mut self, _v: u8) {} + fn emit_int(&mut self, _v: int) {} + fn emit_i64(&mut self, _v: i64) {} + fn emit_i32(&mut self, _v: i32) {} + fn emit_i16(&mut self, _v: i16) {} + fn emit_i8(&mut self, _v: i8) {} + fn emit_bool(&mut self, _v: bool) {} + fn emit_f64(&mut self, _v: f64) {} + fn emit_f32(&mut self, _v: f32) {} + fn emit_char(&mut self, _v: char) {} + fn emit_str(&mut self, _v: &str) {} + fn emit_enum(&mut self, _name: &str, f: |&mut JSTracer|) { + f(self); + } + fn emit_enum_variant(&mut self, _v_name: &str, _v_id: uint, _len: uint, f: |&mut JSTracer|) { + f(self); + } + fn emit_enum_variant_arg(&mut self, _a_idx: uint, f: |&mut JSTracer|) { + f(self); + } + fn emit_enum_struct_variant(&mut self, _v_name: &str, _v_id: uint, _len: uint, f: |&mut JSTracer|) { + f(self); + } + fn emit_enum_struct_variant_field(&mut self, _f_name: &str, _f_idx: uint, f: |&mut JSTracer|) { + f(self); + } + fn emit_struct(&mut self, _name: &str, _len: uint, f: |&mut JSTracer|) { + f(self); + } + fn emit_struct_field(&mut self, _f_name: &str, _f_idx: uint, f: |&mut JSTracer|) { + f(self); + } + fn emit_tuple(&mut self, _len: uint, f: |&mut JSTracer|) { + f(self); + } + fn emit_tuple_arg(&mut self, _idx: uint, f: |&mut JSTracer|) { + f(self); + } + fn emit_tuple_struct(&mut self, _name: &str, _len: uint, f: |&mut JSTracer|) { + f(self); + } + fn emit_tuple_struct_arg(&mut self, _f_idx: uint, f: |&mut JSTracer|) { + f(self); + } + fn emit_option(&mut self, f: |&mut JSTracer|) { + f(self); + } + fn emit_option_none(&mut self) {} + fn emit_option_some(&mut self, f: |&mut JSTracer|) { + f(self); + } + fn emit_seq(&mut self, _len: uint, f: |this: &mut JSTracer|) { + f(self); + } + fn emit_seq_elt(&mut self, _idx: uint, f: |this: &mut JSTracer|) { + f(self); + } + fn emit_map(&mut self, _len: uint, f: |&mut JSTracer|) { + f(self); + } + fn emit_map_elt_key(&mut self, _idx: uint, f: |&mut JSTracer|) { + f(self); + } + fn emit_map_elt_val(&mut self, _idx: uint, f: |&mut JSTracer|) { + f(self); + } +} \ No newline at end of file