avm2: class methods can also live in the AS3 namespace

This commit is contained in:
lukaszN 2021-09-01 10:46:20 +02:00 committed by Adrian Wielgosik
parent 5e5d8e4fff
commit 91d63e4dc1
2 changed files with 14 additions and 1 deletions

View File

@ -553,6 +553,19 @@ impl<'gc> Class<'gc> {
}
}
#[inline(never)]
pub fn define_as3_builtin_class_methods(
&mut self,
mc: MutationContext<'gc, '_>,
items: &[(&'static str, NativeMethodImpl)],
) {
for &(name, value) in items {
self.define_class_trait(Trait::from_method(
QName::new(Namespace::as3_namespace(), name),
Method::from_builtin(value, name, mc),
));
}
}
#[inline(never)]
pub fn define_as3_builtin_instance_methods(
&mut self,
mc: MutationContext<'gc, '_>,

View File

@ -341,7 +341,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
write.define_as3_builtin_instance_methods(mc, AS3_INSTANCE_METHODS);
const PUBLIC_CLASS_METHODS: &[(&str, NativeMethodImpl)] = &[("fromCharCode", from_char_code)];
write.define_public_builtin_class_methods(mc, PUBLIC_CLASS_METHODS);
write.define_as3_builtin_class_methods(mc, PUBLIC_CLASS_METHODS);
class
}