Skip to content

Commit 7cbba5b

Browse files
torokati44Herschel
authored andcommitted
avm2: Stub flash.accessibility.AccessibilityProperties
1 parent 91c1a40 commit 7cbba5b

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

core/src/avm2/globals.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,5 +961,12 @@ pub fn load_player_globals<'gc>(
961961
script,
962962
)?;
963963

964+
// package `flash.accessibility`
965+
class(
966+
activation,
967+
flash::accessibility::accessibilityproperties::create_class(mc),
968+
script,
969+
)?;
970+
964971
Ok(())
965972
}

core/src/avm2/globals/flash.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! `flash` namespace
22
3+
pub mod accessibility;
34
pub mod crypto;
45
pub mod display;
56
pub mod events;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! `flash.accessibility` namespace
2+
3+
pub mod accessibilityproperties;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
//! `flash.accessibility.AccessibilityProperties` builtin/prototype
2+
3+
use crate::avm2::activation::Activation;
4+
use crate::avm2::class::{Class, ClassAttributes};
5+
use crate::avm2::method::Method;
6+
use crate::avm2::names::{Namespace, QName};
7+
use crate::avm2::object::Object;
8+
use crate::avm2::value::Value;
9+
use crate::avm2::Error;
10+
use gc_arena::{GcCell, MutationContext};
11+
12+
fn instance_init<'gc>(
13+
activation: &mut Activation<'_, 'gc, '_>,
14+
this: Option<Object<'gc>>,
15+
_args: &[Value<'gc>],
16+
) -> Result<Value<'gc>, Error> {
17+
if let Some(this) = this {
18+
activation.super_init(this, &[])?;
19+
}
20+
21+
Ok(Value::Undefined)
22+
}
23+
24+
fn class_init<'gc>(
25+
_activation: &mut Activation<'_, 'gc, '_>,
26+
_this: Option<Object<'gc>>,
27+
_args: &[Value<'gc>],
28+
) -> Result<Value<'gc>, Error> {
29+
Ok(Value::Undefined)
30+
}
31+
32+
/// Construct `flash.accessibility.AccessibilityProperties`'s class.
33+
pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>> {
34+
let class = Class::new(
35+
QName::new(
36+
Namespace::package("flash.accessibility"),
37+
"AccessibilityProperties",
38+
),
39+
Some(QName::new(Namespace::public(), "Object").into()),
40+
Method::from_builtin(
41+
instance_init,
42+
"<AccessibilityProperties instance initializer>",
43+
mc,
44+
),
45+
Method::from_builtin(
46+
class_init,
47+
"<AccessibilityProperties class initializer>",
48+
mc,
49+
),
50+
mc,
51+
);
52+
53+
let mut write = class.write(mc);
54+
write.set_attributes(ClassAttributes::SEALED);
55+
56+
const PUBLIC_INSTANCE_SLOTS: &[(&str, &str, &str)] = &[
57+
("description", "", "String"),
58+
("forceSimple", "", "Boolean"),
59+
("name", "", "String"),
60+
("noAutoLabeling", "", "Boolean"),
61+
("shortcut", "", "String"),
62+
("silent", "", "Boolean"),
63+
];
64+
65+
write.define_public_slot_instance_traits(PUBLIC_INSTANCE_SLOTS);
66+
67+
class
68+
}

0 commit comments

Comments
 (0)