Skip to content

Commit 34b1176

Browse files
avm2: Return correct values in DisplayObjectContainer functions when receiver is not of correct type
We can now skip coercing return values of native methods
1 parent a9a8bfb commit 34b1176

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

core/src/avm2/function.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ pub fn exec<'gc>(
201201
}
202202

203203
let signature = &*method.resolved_param_config();
204-
let return_type = method.resolved_return_type();
205204

206205
// Check for too many arguments
207206
if arguments.len() > signature.len() && !method.is_variadic() && !method.is_unchecked()
@@ -233,14 +232,7 @@ pub fn exec<'gc>(
233232
.avm2
234233
.push_call(activation.gc(), method, bound_class);
235234

236-
let result = native_method(&mut activation, receiver, &arguments);
237-
result.and_then(|v| {
238-
if let Some(return_type) = return_type {
239-
v.coerce_to_type(&mut activation, return_type)
240-
} else {
241-
Ok(v)
242-
}
243-
})
235+
native_method(&mut activation, receiver, &arguments)
244236
}
245237
MethodKind::Bytecode(_) => {
246238
// This used to be a one step called Activation::from_method,

core/src/avm2/globals/flash/display/display_object_container.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ pub fn get_child_at<'gc>(
153153
};
154154
}
155155

156-
Ok(Value::Undefined)
156+
Ok(Value::Null)
157157
}
158158

159159
/// Implements `DisplayObjectContainer.getChildByName`
@@ -176,7 +176,7 @@ pub fn get_child_by_name<'gc>(
176176
}
177177
}
178178

179-
Ok(Value::Undefined)
179+
Ok(Value::Null)
180180
}
181181

182182
/// Implements `DisplayObjectContainer.addChild`
@@ -203,7 +203,7 @@ pub fn add_child<'gc>(
203203
}
204204
}
205205

206-
Ok(Value::Undefined)
206+
Ok(Value::Null)
207207
}
208208

209209
/// Implements `DisplayObjectContainer.addChildAt`
@@ -227,7 +227,7 @@ pub fn add_child_at<'gc>(
227227
return Ok(child.object2());
228228
}
229229

230-
Ok(Value::Undefined)
230+
Ok(Value::Null)
231231
}
232232

233233
/// Implements `DisplayObjectContainer.removeChild`
@@ -250,7 +250,7 @@ pub fn remove_child<'gc>(
250250
return Ok(child.object2());
251251
}
252252

253-
Ok(Value::Undefined)
253+
Ok(Value::Null)
254254
}
255255

256256
/// Implements `DisplayObjectContainer.numChildren`
@@ -268,7 +268,7 @@ pub fn get_num_children<'gc>(
268268
return Ok(parent.num_children().into());
269269
}
270270

271-
Ok(Value::Undefined)
271+
Ok(0.into())
272272
}
273273

274274
/// Implements `DisplayObjectContainer.contains`
@@ -356,7 +356,7 @@ pub fn remove_child_at<'gc>(
356356
}
357357
}
358358

359-
Ok(Value::Undefined)
359+
Ok(Value::Null)
360360
}
361361

362362
/// Implements `DisplayObjectContainer.removeChildren`
@@ -634,7 +634,7 @@ pub fn get_mouse_children<'gc>(
634634
{
635635
return Ok(dobj.raw_container().mouse_children().into());
636636
}
637-
Ok(Value::Undefined)
637+
Ok(false.into())
638638
}
639639

640640
pub fn set_mouse_children<'gc>(
@@ -669,7 +669,7 @@ pub fn get_tab_children<'gc>(
669669
{
670670
Ok(Value::Bool(obj.is_tab_children(activation.context)))
671671
} else {
672-
Ok(Value::Undefined)
672+
Ok(false.into())
673673
}
674674
}
675675

0 commit comments

Comments
 (0)