Skip to content

Commit

Permalink
remove deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
matsadler committed Nov 19, 2022
1 parent df2f721 commit 471c140
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 44 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
(use `free_immediately`).

### Removed
- `String::encode_utf8`, use `r_string.conv_enc(RbEncoding::utf8())` instead.
- `Value::leak`, use `gc::register_mark_object` instead.
- `define_global_variable` (use `define_variable`).

### Fixed
- Memory leak of the message when returning an `Error` to raise an exception.
Expand Down
6 changes: 0 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1952,12 +1952,6 @@ pub fn define_variable<T: Into<Value>>(name: &str, initial: T) -> Result<*mut Va
Ok(ptr)
}

/// Define a global variable.
#[deprecated(since = "0.3.0", note = "please use `define_variable` instead")]
pub fn define_global_variable<T: Into<Value>>(name: &str, initial: T) -> Result<*mut Value, Error> {
define_variable(name, initial)
}

/// Define a global constant.
pub fn define_global_const<T>(name: &str, value: T) -> Result<(), Error>
where
Expand Down
10 changes: 0 additions & 10 deletions src/r_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,16 +462,6 @@ impl RString {
encindex == encoding::Index::utf8() || encindex == encoding::Index::usascii()
}

/// Returns a new string by reencoding `self` from its current encoding to
/// UTF-8.
#[deprecated(
since = "0.3.0",
note = "please use `r_string.conv_enc(RbEncoding::utf8())` instead"
)]
pub fn encode_utf8(self) -> Result<Self, Error> {
self.conv_enc(RbEncoding::utf8())
}

/// Returns a new string by reencoding `self` from its current encoding to
/// the given `enc`.
///
Expand Down
8 changes: 4 additions & 4 deletions src/rb_sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub unsafe fn resume_error(e: Error) -> ! {
}

/// Convert [`magnus::Value`](Value) to [`rb_sys::VALUE`].
#[deprecated(since = "0.3.3", note = "please use `Value::as_raw` instead")]
#[deprecated(since = "0.4.0", note = "please use `Value::as_raw` instead")]
pub fn raw_value(val: Value) -> VALUE {
val.as_raw()
}
Expand All @@ -207,13 +207,13 @@ pub fn raw_value(val: Value) -> VALUE {
/// You must only supply a valid [`VALUE`] obtained from [rb-sys](rb_sys) to
/// this function. Using a invalid [`Value`] produced from this function will
/// void all saftey guarantees provided by Magnus.
#[deprecated(since = "0.3.3", note = "please use `Value::from_raw` instead")]
#[deprecated(since = "0.4.0", note = "please use `Value::from_raw` instead")]
pub unsafe fn value_from_raw(val: VALUE) -> Value {
Value::from_raw(val)
}

/// Convert [`magnus::value::Id`](Id) to [`rb_sys::ID`].
#[deprecated(since = "0.3.3", note = "please use `Id::as_raw` instead")]
#[deprecated(since = "0.4.0", note = "please use `Id::as_raw` instead")]
pub fn raw_id(id: Id) -> ID {
id.as_raw()
}
Expand All @@ -225,7 +225,7 @@ pub fn raw_id(id: Id) -> ID {
/// You must only supply a valid [`ID`] obtained from [rb-sys](rb_sys) to this
/// function. Using a invalid [`Id`] produced from this function will void all
/// saftey guarantees provided by Magnus.
#[deprecated(since = "0.3.3", note = "please use `Id::from_raw` instead")]
#[deprecated(since = "0.4.0", note = "please use `Id::from_raw` instead")]
pub unsafe fn id_from_raw(id: ID) -> Id {
Id::from_raw(id)
}
Expand Down
27 changes: 3 additions & 24 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pub use flonum::Flonum;
use rb_sys::{
rb_any_to_s, rb_block_call, rb_check_funcall, rb_check_id, rb_check_id_cstr,
rb_check_symbol_cstr, rb_enumeratorize_with_size, rb_eql, rb_equal, rb_funcall_with_block,
rb_funcallv, rb_gc_register_address, rb_gc_register_mark_object, rb_gc_unregister_address,
rb_id2name, rb_id2sym, rb_inspect, rb_intern3, rb_ll2inum, rb_obj_as_string, rb_obj_classname,
rb_obj_freeze, rb_obj_is_kind_of, rb_obj_respond_to, rb_sym2id, rb_ull2inum, ruby_fl_type,
rb_funcallv, rb_gc_register_address, rb_gc_unregister_address, rb_id2name, rb_id2sym,
rb_inspect, rb_intern3, rb_ll2inum, rb_obj_as_string, rb_obj_classname, rb_obj_freeze,
rb_obj_is_kind_of, rb_obj_respond_to, rb_sym2id, rb_ull2inum, ruby_fl_type,
ruby_special_consts, ruby_value_type, RBasic, ID, VALUE,
};

Expand Down Expand Up @@ -348,27 +348,6 @@ impl Value {
self.0
}

/// Registers `self` as to never be garbage collected.
///
/// # Examples
///
/// ```
/// use magnus::{eval, RArray};
/// # let _cleanup = unsafe { magnus::embed::init() };
///
/// let ary = eval::<RArray>("[1, 2, 3]").unwrap();
/// ary.leak();
/// ```
#[deprecated(
since = "0.3.0",
note = "please use `gc::register_mark_object` instead"
)]
pub fn leak(self) {
debug_assert_value!(self);
// safe ffi to Ruby, call doesn't raise
unsafe { rb_gc_register_mark_object(self.as_rb_value()) }
}

/// Returns whether `self` is 'frozen'.
///
/// Ruby prevents modifying frozen objects.
Expand Down

0 comments on commit 471c140

Please sign in to comment.