Skip to content

Commit d6585b8

Browse files
authored
Revert "Implement metacall_box for passing function arguments with different …"
This reverts commit ae05b71.
1 parent fce639c commit d6585b8

File tree

5 files changed

+23
-51
lines changed

5 files changed

+23
-51
lines changed

source/ports/rs_port/src/cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,6 @@ pub fn metacallobj_untyped_to_raw(ret: Box<dyn MetaCallValue>) -> Option<*mut c_
235235
None
236236
}
237237

238-
pub fn metacall_box(v: impl MetaCallValue) -> Box<dyn MetaCallValue> {
238+
pub fn metacall_implementer_to_traitobj(v: impl MetaCallValue) -> Box<dyn MetaCallValue> {
239239
Box::new(v) as Box<dyn MetaCallValue>
240240
}

source/ports/rs_port/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ pub use types::*;
8888
#[doc(hidden)]
8989
mod init;
9090

91-
pub use cast::metacall_box;
9291
pub use init::initialize;
9392
pub use init::is_initialized;
9493

source/ports/rs_port/src/types/metacall_exception.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl MetaCallThrowable {
180180
Ok(mut value) => {
181181
value.leak = true;
182182

183-
cast::metacall_box(value)
183+
cast::metacall_implementer_to_traitobj(value)
184184
}
185185
Err(original) => original,
186186
}

source/ports/rs_port/src/types/metacall_value.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -429,36 +429,3 @@ impl MetaCallValue for MetaCallThrowable {
429429
self.into_raw()
430430
}
431431
}
432-
/// Just a Rust barrier made for easier polymorphism.
433-
impl MetaCallValue for Box<dyn MetaCallValue> {
434-
fn get_metacall_id() -> metacall_value_id {
435-
metacall_value_id::METACALL_INVALID
436-
}
437-
fn from_metacall_raw_leak(v: *mut c_void) -> Result<Self, Box<dyn MetaCallValue>> {
438-
Ok(cast::raw_to_metacallobj_untyped_leak(v))
439-
}
440-
fn into_metacall_raw(self) -> *mut c_void {
441-
match_metacall_value!(self, {
442-
bool: bool => bool.into_metacall_raw(),
443-
char: char => char.into_metacall_raw(),
444-
num: i16 => num.into_metacall_raw(),
445-
num: i32 => num.into_metacall_raw(),
446-
num: i64 => num.into_metacall_raw(),
447-
num: f32 => num.into_metacall_raw(),
448-
num: f64 => num.into_metacall_raw(),
449-
str: String => str.into_metacall_raw(),
450-
buf: Vec<i8> => buf.into_metacall_raw(),
451-
arr: Vec<Box<dyn MetaCallValue>> => arr.into_metacall_raw(),
452-
map: HashMap<String, Box<dyn MetaCallValue>> => map.into_metacall_raw(),
453-
ptr: MetaCallPointer => ptr.into_metacall_raw(),
454-
fut: MetaCallFuture => fut.into_metacall_raw(),
455-
fun: MetaCallFunction => fun.into_metacall_raw(),
456-
null: MetaCallNull => null.into_metacall_raw(),
457-
cls: MetaCallClass => cls.into_metacall_raw(),
458-
obj: MetaCallObject => obj.into_metacall_raw(),
459-
exc: MetaCallException => exc.into_metacall_raw(),
460-
thr: MetaCallThrowable => thr.into_metacall_raw(),
461-
_ => MetaCallNull().into_metacall_raw()
462-
})
463-
}
464-
}

source/ports/rs_port/tests/metacall_test.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,27 @@ fn test_float() {
8181
fn test_double() {
8282
generate_test::<f64>("test_double", 1.2345_f64);
8383
}
84-
fn test_mixed_numbers() {
85-
let result = ::metacall::metacall::<i64>(
86-
"test_mixed_numbers",
87-
[
88-
::metacall::metacall_box(1 as i16),
89-
::metacall::metacall_box(2 as i32),
90-
::metacall::metacall_box(3 as i64),
91-
],
92-
);
84+
// TODO
85+
// fn test_mixed_numbers() {
86+
// let result = ::metacall::metacall::<i64>(
87+
// "test_mixed_numbers",
88+
// [
89+
// Box::new(1 as i16) as Box<dyn MetaCallValue>,
90+
// Box::new(2 as i32) as Box<dyn MetaCallValue>,
91+
// Box::new(3 as i64) as Box<dyn MetaCallValue>,
92+
// ],
93+
// );
9394

94-
assert!(result.is_ok());
95+
// // TODO
96+
// // ::metacall::metacall::<i64>("test_mixed_numbers", [1_i16, 2_i32, 3_i64]);
97+
// // ::metacall::metacall::<i64>("test_mixed_numbers", (1_i16, 2_i32, 3_i64));
9598

96-
if let Ok(ret) = result {
97-
assert_eq!(ret, 6_i64)
98-
}
99-
}
99+
// assert!(result.is_ok());
100+
101+
// if let Ok(ret) = result {
102+
// assert_eq!(ret, 6_i64)
103+
// }
104+
// }
100105
fn test_string() {
101106
generate_test::<String>(
102107
"return_the_argument_py",
@@ -388,7 +393,8 @@ fn metacall() {
388393
test_int();
389394
test_long();
390395
test_short();
391-
test_mixed_numbers();
396+
// TODO
397+
// test_mixed_numbers();
392398
}
393399
if load::from_single_file("node", js_test_file).is_ok() {
394400
test_exception();

0 commit comments

Comments
 (0)