avm2: Stub `SoundChannel.leftPeak` and `SoundChannel.rightPeak`

This commit is contained in:
David Wendt 2021-08-18 18:18:41 -04:00 committed by kmeisthax
parent 50092e6c04
commit 4e77f89e0f
1 changed files with 29 additions and 1 deletions

View File

@ -2,7 +2,7 @@
use crate::avm2::activation::Activation;
use crate::avm2::class::{Class, ClassAttributes};
use crate::avm2::method::Method;
use crate::avm2::method::{Method, NativeMethodImpl};
use crate::avm2::names::{Namespace, QName};
use crate::avm2::object::{soundchannel_allocator, Object};
use crate::avm2::value::Value;
@ -31,6 +31,24 @@ pub fn class_init<'gc>(
Ok(Value::Undefined)
}
/// Stub `SoundChannel.leftPeak`
pub fn left_peak<'gc>(
_activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> {
Err("Sound.leftPeak is a stub.".into())
}
/// Stub `SoundChannel.rightPeak`
pub fn right_peak<'gc>(
_activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> {
Err("Sound.rightPeak is a stub.".into())
}
/// Construct `SoundChannel`'s class.
pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>> {
let class = Class::new(
@ -46,5 +64,15 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
write.set_attributes(ClassAttributes::SEALED | ClassAttributes::FINAL);
write.set_instance_allocator(soundchannel_allocator);
const PUBLIC_INSTANCE_PROPERTIES: &[(
&str,
Option<NativeMethodImpl>,
Option<NativeMethodImpl>,
)] = &[
("leftPeak", Some(left_peak), None),
("rightPeak", Some(right_peak), None),
];
write.define_public_builtin_instance_properties(mc, PUBLIC_INSTANCE_PROPERTIES);
class
}