From 96a0bb9e66334e2ee6de14b30d6720d3ff22357d Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 18 Nov 2015 15:17:31 +0100 Subject: [PATCH 1/2] Rename CallArgs::{get, get_mut} to {index, index_mut}. CallArgs::get exists in C++ with different semantics. It is confusing to have it exist in this form. --- src/rust.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rust.rs b/src/rust.rs index cab62e63d..950b25383 100644 --- a/src/rust.rs +++ b/src/rust.rs @@ -572,14 +572,14 @@ impl CallArgs { } } - pub fn get(&self, i: u32) -> HandleValue { + pub fn index(&self, i: u32) -> HandleValue { assert!(i < self._base.argc_); unsafe { HandleValue::from_marked_location(self._base._base.argv_.offset(i as isize)) } } - pub fn get_mut(&self, i: u32) -> MutableHandleValue { + pub fn index_mut(&self, i: u32) -> MutableHandleValue { assert!(i < self._base.argc_); unsafe { MutableHandleValue::from_marked_location(self._base._base.argv_.offset(i as isize)) From 288af44d2da5eaa2d28df9af7577058eadad10e9 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 18 Nov 2015 15:18:46 +0100 Subject: [PATCH 2/2] Introduce a new CallArgs::get(). This matches the semantics in C++. --- src/rust.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/rust.rs b/src/rust.rs index 950b25383..ba5b0ed70 100644 --- a/src/rust.rs +++ b/src/rust.rs @@ -586,6 +586,16 @@ impl CallArgs { } } + pub fn get(&self, i: u32) -> HandleValue { + unsafe { + if i < self._base.argc_ { + HandleValue::from_marked_location(self._base._base.argv_.offset(i as isize)) + } else { + UndefinedHandleValue + } + } + } + pub fn rval(&self) -> MutableHandleValue { unsafe { MutableHandleValue::from_marked_location(self._base._base.argv_.offset(-2))