chore: Raise errors during Object.registerClass
This commit is contained in:
parent
7bed4d4940
commit
751b15beec
|
@ -138,17 +138,15 @@ pub fn register_class<'gc>(
|
||||||
_this: Object<'gc>,
|
_this: Object<'gc>,
|
||||||
args: &[Value<'gc>],
|
args: &[Value<'gc>],
|
||||||
) -> Result<ReturnValue<'gc>, Error> {
|
) -> Result<ReturnValue<'gc>, Error> {
|
||||||
if let Some(class_name) = args
|
if let Some(class_name) = args.get(0).cloned() {
|
||||||
.get(0)
|
let class_name = class_name.coerce_to_string(avm, context)?;
|
||||||
.and_then(|v| v.clone().coerce_to_string(avm, context).ok())
|
|
||||||
{
|
|
||||||
if let Some(Character::MovieClip(movie_clip)) = context
|
if let Some(Character::MovieClip(movie_clip)) = context
|
||||||
.library
|
.library
|
||||||
.library_for_movie_mut(context.swf.clone())
|
.library_for_movie_mut(context.swf.clone())
|
||||||
.get_character_by_export_name(&class_name)
|
.get_character_by_export_name(&class_name)
|
||||||
{
|
{
|
||||||
if let Some(constructor) = args.get(1).and_then(|v| v.as_object().ok()) {
|
if let Some(constructor) = args.get(1) {
|
||||||
movie_clip.set_avm1_constructor(context.gc_context, Some(constructor));
|
movie_clip.set_avm1_constructor(context.gc_context, Some(constructor.as_object()?));
|
||||||
} else {
|
} else {
|
||||||
movie_clip.set_avm1_constructor(context.gc_context, None);
|
movie_clip.set_avm1_constructor(context.gc_context, None);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue