avm1: Require some more prototypes

Since they are never `None`.
This commit is contained in:
relrelb 2022-10-13 15:11:35 +03:00 committed by relrelb
parent 491ffbbf09
commit bc73301592
52 changed files with 104 additions and 114 deletions

View File

@ -740,9 +740,8 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> {
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
prototype: Object<'gc>, prototype: Object<'gc>,
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObject::new(activation.context.gc_context, Some(prototype)); Ok(FunctionObject {
let fn_object = FunctionObject { base: ScriptObject::new(activation.context.gc_context, Some(prototype)),
base,
data: GcCell::allocate( data: GcCell::allocate(
activation.context.gc_context, activation.context.gc_context,
FunctionObjectData { FunctionObjectData {
@ -750,9 +749,8 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> {
constructor: None, constructor: None,
}, },
), ),
}; }
.into())
Ok(fn_object.into())
} }
fn delete(&self, activation: &mut Activation<'_, 'gc, '_>, name: AvmString<'gc>) -> bool { fn delete(&self, activation: &mut Activation<'_, 'gc, '_>, name: AvmString<'gc>) -> bool {

View File

@ -571,7 +571,7 @@ pub fn create_globals<'gc>(
let selection_proto = selection::create_proto(gc_context, object_proto); let selection_proto = selection::create_proto(gc_context, object_proto);
let (broadcaster_functions, as_broadcaster) = let (broadcaster_functions, as_broadcaster) =
as_broadcaster::create(gc_context, Some(object_proto), function_proto); as_broadcaster::create(gc_context, object_proto, function_proto);
let movie_clip_loader_proto = movie_clip_loader::create_proto( let movie_clip_loader_proto = movie_clip_loader::create_proto(
gc_context, gc_context,
@ -1047,12 +1047,11 @@ pub fn create_globals<'gc>(
Attribute::DONT_ENUM, Attribute::DONT_ENUM,
); );
let system_security = system_security::create(gc_context, Some(object_proto), function_proto); let system_security = system_security::create(gc_context, object_proto, function_proto);
let system_capabilities = let system_capabilities = system_capabilities::create(gc_context, object_proto, function_proto);
system_capabilities::create(gc_context, Some(object_proto), function_proto);
let system_ime = system_ime::create( let system_ime = system_ime::create(
gc_context, gc_context,
Some(object_proto), object_proto,
function_proto, function_proto,
broadcaster_functions, broadcaster_functions,
array_proto, array_proto,
@ -1060,7 +1059,7 @@ pub fn create_globals<'gc>(
let system = system::create( let system = system::create(
gc_context, gc_context,
Some(object_proto), object_proto,
function_proto, function_proto,
system_security, system_security,
system_capabilities, system_capabilities,
@ -1071,7 +1070,7 @@ pub fn create_globals<'gc>(
globals.define_value( globals.define_value(
gc_context, gc_context,
"Math", "Math",
Value::Object(math::create(gc_context, Some(object_proto), function_proto)), Value::Object(math::create(gc_context, object_proto, function_proto)),
Attribute::DONT_ENUM, Attribute::DONT_ENUM,
); );
globals.define_value( globals.define_value(
@ -1079,7 +1078,7 @@ pub fn create_globals<'gc>(
"Mouse", "Mouse",
Value::Object(mouse::create_mouse_object( Value::Object(mouse::create_mouse_object(
gc_context, gc_context,
Some(object_proto), object_proto,
function_proto, function_proto,
broadcaster_functions, broadcaster_functions,
array_proto, array_proto,
@ -1091,7 +1090,7 @@ pub fn create_globals<'gc>(
"Key", "Key",
Value::Object(key::create_key_object( Value::Object(key::create_key_object(
gc_context, gc_context,
Some(object_proto), object_proto,
function_proto, function_proto,
broadcaster_functions, broadcaster_functions,
array_proto, array_proto,
@ -1103,8 +1102,8 @@ pub fn create_globals<'gc>(
"Stage", "Stage",
Value::Object(stage::create_stage_object( Value::Object(stage::create_stage_object(
gc_context, gc_context,
Some(object_proto), object_proto,
Some(array_proto), array_proto,
function_proto, function_proto,
broadcaster_functions, broadcaster_functions,
)), )),
@ -1115,7 +1114,7 @@ pub fn create_globals<'gc>(
"Accessibility", "Accessibility",
Value::Object(accessibility::create_accessibility_object( Value::Object(accessibility::create_accessibility_object(
gc_context, gc_context,
Some(object_proto), object_proto,
function_proto, function_proto,
)), )),
Attribute::DONT_ENUM, Attribute::DONT_ENUM,

View File

@ -41,10 +41,10 @@ pub fn update_properties<'gc>(
pub fn create_accessibility_object<'gc>( pub fn create_accessibility_object<'gc>(
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let accessibility = ScriptObject::new(gc_context, proto); let accessibility = ScriptObject::new(gc_context, Some(proto));
define_properties_on(OBJECT_DECLS, gc_context, accessibility, fn_proto); define_properties_on(OBJECT_DECLS, gc_context, accessibility, fn_proto);
accessibility.into() accessibility.into()
} }

View File

@ -18,10 +18,10 @@ const OBJECT_DECLS: &[Declaration] = declare_properties! {
pub fn create<'gc>( pub fn create<'gc>(
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> (BroadcasterFunctions<'gc>, Object<'gc>) { ) -> (BroadcasterFunctions<'gc>, Object<'gc>) {
let object = ScriptObject::new(gc_context, proto); let object = ScriptObject::new(gc_context, Some(proto));
let define_as_object = |index: usize| -> Object<'gc> { let define_as_object = |index: usize| -> Object<'gc> {
match OBJECT_DECLS[index].define_on(gc_context, object, fn_proto) { match OBJECT_DECLS[index].define_on(gc_context, object, fn_proto) {

View File

@ -408,7 +408,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let object = BevelFilterObject::empty_object(gc_context, Some(proto)); let object = BevelFilterObject::empty_object(gc_context, proto);
let script_object = object.as_script_object().unwrap(); let script_object = object.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, script_object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, script_object, fn_proto);
object.into() object.into()

View File

@ -380,7 +380,7 @@ pub fn clone<'gc>(
if !bitmap_data.disposed() { if !bitmap_data.disposed() {
let new_bitmap_data = BitmapDataObject::empty_object( let new_bitmap_data = BitmapDataObject::empty_object(
activation.context.gc_context, activation.context.gc_context,
Some(activation.context.avm1.prototypes().bitmap_data), activation.context.avm1.prototypes().bitmap_data,
); );
new_bitmap_data new_bitmap_data
@ -1172,7 +1172,7 @@ pub fn compare<'gc>(
match BitmapData::compare(&this_bitmap_data, &other_bitmap_data) { match BitmapData::compare(&this_bitmap_data, &other_bitmap_data) {
Some(bitmap_data) => Ok(BitmapDataObject::with_bitmap_data( Some(bitmap_data) => Ok(BitmapDataObject::with_bitmap_data(
activation.context.gc_context, activation.context.gc_context,
Some(activation.context.avm1.prototypes().bitmap_data), activation.context.avm1.prototypes().bitmap_data,
bitmap_data, bitmap_data,
) )
.into()), .into()),
@ -1185,7 +1185,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let bitmap_data_object = BitmapDataObject::empty_object(gc_context, Some(proto)); let bitmap_data_object = BitmapDataObject::empty_object(gc_context, proto);
let object = bitmap_data_object.as_script_object().unwrap(); let object = bitmap_data_object.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
bitmap_data_object.into() bitmap_data_object.into()
@ -1216,7 +1216,7 @@ pub fn load_bitmap<'gc>(
if let Some(bitmap) = renderer.get_bitmap_pixels(bitmap_handle) { if let Some(bitmap) = renderer.get_bitmap_pixels(bitmap_handle) {
let new_bitmap_data = BitmapDataObject::empty_object( let new_bitmap_data = BitmapDataObject::empty_object(
activation.context.gc_context, activation.context.gc_context,
Some(activation.context.avm1.prototypes().bitmap_data), activation.context.avm1.prototypes().bitmap_data,
); );
let width = bitmap.width(); let width = bitmap.width();

View File

@ -120,7 +120,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let blur_filter = BlurFilterObject::empty_object(gc_context, Some(proto)); let blur_filter = BlurFilterObject::empty_object(gc_context, proto);
let object = blur_filter.as_script_object().unwrap(); let object = blur_filter.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
blur_filter.into() blur_filter.into()

View File

@ -65,7 +65,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let boolean_proto = ValueObject::empty_box(gc_context, Some(proto)); let boolean_proto = ValueObject::empty_box(gc_context, proto);
let object = boolean_proto.as_script_object().unwrap(); let object = boolean_proto.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
boolean_proto boolean_proto

View File

@ -68,7 +68,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let color_matrix_filter = ColorMatrixFilterObject::empty_object(gc_context, Some(proto)); let color_matrix_filter = ColorMatrixFilterObject::empty_object(gc_context, proto);
let object = color_matrix_filter.as_script_object().unwrap(); let object = color_matrix_filter.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
color_matrix_filter.into() color_matrix_filter.into()

View File

@ -319,7 +319,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let filter = ConvolutionFilterObject::empty_object(gc_context, Some(proto)); let filter = ConvolutionFilterObject::empty_object(gc_context, proto);
let object = filter.as_script_object().unwrap(); let object = filter.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
filter.into() filter.into()

View File

@ -305,7 +305,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let filter = DisplacementMapFilterObject::empty_object(gc_context, Some(proto)); let filter = DisplacementMapFilterObject::empty_object(gc_context, proto);
let object = filter.as_script_object().unwrap(); let object = filter.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
filter.into() filter.into()

View File

@ -373,7 +373,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let drop_shadow_filter = DropShadowFilterObject::empty_object(gc_context, Some(proto)); let drop_shadow_filter = DropShadowFilterObject::empty_object(gc_context, proto);
let object = drop_shadow_filter.as_script_object().unwrap(); let object = drop_shadow_filter.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
drop_shadow_filter.into() drop_shadow_filter.into()

View File

@ -276,7 +276,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let glow_filter = GlowFilterObject::empty_object(gc_context, Some(proto)); let glow_filter = GlowFilterObject::empty_object(gc_context, proto);
let object = glow_filter.as_script_object().unwrap(); let object = glow_filter.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
glow_filter.into() glow_filter.into()

View File

@ -451,7 +451,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let color_matrix_filter = GradientBevelFilterObject::empty_object(gc_context, Some(proto)); let color_matrix_filter = GradientBevelFilterObject::empty_object(gc_context, proto);
let object = color_matrix_filter.as_script_object().unwrap(); let object = color_matrix_filter.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
color_matrix_filter.into() color_matrix_filter.into()

View File

@ -451,7 +451,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let color_matrix_filter = GradientGlowFilterObject::empty_object(gc_context, Some(proto)); let color_matrix_filter = GradientGlowFilterObject::empty_object(gc_context, proto);
let object = color_matrix_filter.as_script_object().unwrap(); let object = color_matrix_filter.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
color_matrix_filter.into() color_matrix_filter.into()

View File

@ -67,12 +67,12 @@ pub fn get_code<'gc>(
pub fn create_key_object<'gc>( pub fn create_key_object<'gc>(
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
broadcaster_functions: BroadcasterFunctions<'gc>, broadcaster_functions: BroadcasterFunctions<'gc>,
array_proto: Object<'gc>, array_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let key = ScriptObject::new(gc_context, proto); let key = ScriptObject::new(gc_context, Some(proto));
broadcaster_functions.initialize(gc_context, key.into(), array_proto); broadcaster_functions.initialize(gc_context, key.into(), array_proto);
define_properties_on(OBJECT_DECLS, gc_context, key, fn_proto); define_properties_on(OBJECT_DECLS, gc_context, key, fn_proto);
key.into() key.into()

View File

@ -158,10 +158,10 @@ pub fn random<'gc>(
pub fn create<'gc>( pub fn create<'gc>(
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let math = ScriptObject::new(gc_context, proto); let math = ScriptObject::new(gc_context, Some(proto));
define_properties_on(OBJECT_DECLS, gc_context, math, fn_proto); define_properties_on(OBJECT_DECLS, gc_context, math, fn_proto);
math.into() math.into()
} }
@ -174,7 +174,7 @@ mod tests {
fn setup<'gc>(activation: &mut Activation<'_, 'gc, '_>) -> Object<'gc> { fn setup<'gc>(activation: &mut Activation<'_, 'gc, '_>) -> Object<'gc> {
create( create(
activation.context.gc_context, activation.context.gc_context,
Some(activation.context.avm1.prototypes().object), activation.context.avm1.prototypes().object,
activation.context.avm1.prototypes().function, activation.context.avm1.prototypes().function,
) )
} }
@ -392,7 +392,7 @@ mod tests {
with_avm(19, |activation, _root| -> Result<(), Error> { with_avm(19, |activation, _root| -> Result<(), Error> {
let math = create( let math = create(
activation.context.gc_context, activation.context.gc_context,
Some(activation.context.avm1.prototypes().object), activation.context.avm1.prototypes().object,
activation.context.avm1.prototypes().function, activation.context.avm1.prototypes().function,
); );
@ -418,7 +418,7 @@ mod tests {
with_avm(19, |activation, _root| -> Result<(), Error> { with_avm(19, |activation, _root| -> Result<(), Error> {
let math = create( let math = create(
activation.context.gc_context, activation.context.gc_context,
Some(activation.context.avm1.prototypes().object), activation.context.avm1.prototypes().object,
activation.context.avm1.prototypes().function, activation.context.avm1.prototypes().function,
); );

View File

@ -32,12 +32,12 @@ pub fn hide_mouse<'gc>(
pub fn create_mouse_object<'gc>( pub fn create_mouse_object<'gc>(
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
broadcaster_functions: BroadcasterFunctions<'gc>, broadcaster_functions: BroadcasterFunctions<'gc>,
array_proto: Object<'gc>, array_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let mouse = ScriptObject::new(gc_context, proto); let mouse = ScriptObject::new(gc_context, Some(proto));
broadcaster_functions.initialize(gc_context, mouse.into(), array_proto); broadcaster_functions.initialize(gc_context, mouse.into(), array_proto);
define_properties_on(OBJECT_DECLS, gc_context, mouse, fn_proto); define_properties_on(OBJECT_DECLS, gc_context, mouse, fn_proto);
mouse.into() mouse.into()

View File

@ -83,7 +83,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let number_proto = ValueObject::empty_box(gc_context, Some(proto)); let number_proto = ValueObject::empty_box(gc_context, proto);
let object = number_proto.as_script_object().unwrap(); let object = number_proto.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
number_proto number_proto

View File

@ -555,7 +555,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let shared_obj = SharedObject::empty_shared_obj(gc_context, Some(proto)); let shared_obj = SharedObject::empty_shared_obj(gc_context, proto);
let object = shared_obj.as_script_object().unwrap(); let object = shared_obj.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
shared_obj.into() shared_obj.into()

View File

@ -60,7 +60,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let sound = SoundObject::empty_sound(gc_context, Some(proto)); let sound = SoundObject::empty_sound(gc_context, proto);
let object = sound.as_script_object().unwrap(); let object = sound.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
sound.into() sound.into()

View File

@ -22,13 +22,13 @@ const OBJECT_DECLS: &[Declaration] = declare_properties! {
pub fn create_stage_object<'gc>( pub fn create_stage_object<'gc>(
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>, proto: Object<'gc>,
array_proto: Option<Object<'gc>>, array_proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
broadcaster_functions: BroadcasterFunctions<'gc>, broadcaster_functions: BroadcasterFunctions<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let stage = ScriptObject::new(gc_context, proto); let stage = ScriptObject::new(gc_context, Some(proto));
broadcaster_functions.initialize(gc_context, stage.into(), array_proto.unwrap()); broadcaster_functions.initialize(gc_context, stage.into(), array_proto);
define_properties_on(OBJECT_DECLS, gc_context, stage, fn_proto); define_properties_on(OBJECT_DECLS, gc_context, stage, fn_proto);
stage.into() stage.into()
} }

View File

@ -94,7 +94,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let string_proto = ValueObject::empty_box(gc_context, Some(proto)); let string_proto = ValueObject::empty_box(gc_context, proto);
let object = string_proto.as_script_object().unwrap(); let object = string_proto.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
string_proto string_proto

View File

@ -518,13 +518,13 @@ pub fn on_status<'gc>(
pub fn create<'gc>( pub fn create<'gc>(
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
security: Object<'gc>, security: Object<'gc>,
capabilities: Object<'gc>, capabilities: Object<'gc>,
ime: Object<'gc>, ime: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let system = ScriptObject::new(gc_context, proto); let system = ScriptObject::new(gc_context, Some(proto));
define_properties_on(OBJECT_DECLS, gc_context, system, fn_proto); define_properties_on(OBJECT_DECLS, gc_context, system, fn_proto);
system.define_value(gc_context, "IME", ime.into(), Attribute::empty()); system.define_value(gc_context, "IME", ime.into(), Attribute::empty());
system.define_value(gc_context, "security", security.into(), Attribute::empty()); system.define_value(gc_context, "security", security.into(), Attribute::empty());

View File

@ -251,10 +251,10 @@ pub fn get_max_idc_level<'gc>(
pub fn create<'gc>( pub fn create<'gc>(
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let capabilities = ScriptObject::new(gc_context, proto); let capabilities = ScriptObject::new(gc_context, Some(proto));
define_properties_on(OBJECT_DECLS, gc_context, capabilities, fn_proto); define_properties_on(OBJECT_DECLS, gc_context, capabilities, fn_proto);
capabilities.into() capabilities.into()
} }

View File

@ -81,12 +81,12 @@ fn set_enabled<'gc>(
pub fn create<'gc>( pub fn create<'gc>(
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
broadcaster_functions: BroadcasterFunctions<'gc>, broadcaster_functions: BroadcasterFunctions<'gc>,
array_proto: Object<'gc>, array_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let ime = ScriptObject::new(gc_context, proto); let ime = ScriptObject::new(gc_context, Some(proto));
broadcaster_functions.initialize(gc_context, ime.into(), array_proto); broadcaster_functions.initialize(gc_context, ime.into(), array_proto);
define_properties_on(OBJECT_DECLS, gc_context, ime, fn_proto); define_properties_on(OBJECT_DECLS, gc_context, ime, fn_proto);
ime.into() ime.into()

View File

@ -97,10 +97,10 @@ fn policy_file_resolver<'gc>(
pub fn create<'gc>( pub fn create<'gc>(
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let security = ScriptObject::new(gc_context, proto); let security = ScriptObject::new(gc_context, Some(proto));
define_properties_on(OBJECT_DECLS, gc_context, security, fn_proto); define_properties_on(OBJECT_DECLS, gc_context, security, fn_proto);
security.into() security.into()
} }

View File

@ -67,7 +67,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let transform_object = TransformObject::empty(gc_context, Some(proto)); let transform_object = TransformObject::empty(gc_context, proto);
let object = transform_object.as_script_object().unwrap(); let object = transform_object.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
transform_object.into() transform_object.into()

View File

@ -290,7 +290,7 @@ pub fn create_proto<'gc>(
proto: Object<'gc>, proto: Object<'gc>,
fn_proto: Object<'gc>, fn_proto: Object<'gc>,
) -> Object<'gc> { ) -> Object<'gc> {
let xml_proto = XmlObject::empty(gc_context, Some(proto)); let xml_proto = XmlObject::empty(gc_context, proto);
let object = xml_proto.as_script_object().unwrap(); let object = xml_proto.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, fn_proto); define_properties_on(PROTO_DECLS, gc_context, object, fn_proto);
xml_proto.into() xml_proto.into()

View File

@ -97,11 +97,11 @@ impl<'gc> BevelFilterObject<'gc> {
[set_type, get_type, type_, BevelFilterType], [set_type, get_type, type_, BevelFilterType],
); );
pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Option<Object<'gc>>) -> Self { pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
BevelFilterObject(GcCell::allocate( BevelFilterObject(GcCell::allocate(
gc_context, gc_context,
BevelFilterData { BevelFilterData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
angle: 44.9999999772279, angle: 44.9999999772279,
blur_x: 4.0, blur_x: 4.0,
blur_y: 4.0, blur_y: 4.0,

View File

@ -34,19 +34,19 @@ impl<'gc> BitmapDataObject<'gc> {
[data, GcCell<'gc, BitmapData<'gc>>, set => set_bitmap_data, get => bitmap_data], [data, GcCell<'gc, BitmapData<'gc>>, set => set_bitmap_data, get => bitmap_data],
); );
pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Option<Object<'gc>>) -> Self { pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
Self::with_bitmap_data(gc_context, proto, Default::default()) Self::with_bitmap_data(gc_context, proto, Default::default())
} }
pub fn with_bitmap_data( pub fn with_bitmap_data(
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>, proto: Object<'gc>,
bitmap_data: BitmapData<'gc>, bitmap_data: BitmapData<'gc>,
) -> Self { ) -> Self {
Self(GcCell::allocate( Self(GcCell::allocate(
gc_context, gc_context,
BitmapDataData { BitmapDataData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
data: GcCell::allocate(gc_context, bitmap_data), data: GcCell::allocate(gc_context, bitmap_data),
}, },
)) ))

View File

@ -39,11 +39,11 @@ impl<'gc> BlurFilterObject<'gc> {
[set_quality, quality, quality, i32], [set_quality, quality, quality, i32],
); );
pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Option<Object<'gc>>) -> Self { pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
BlurFilterObject(GcCell::allocate( BlurFilterObject(GcCell::allocate(
gc_context, gc_context,
BlurFilterData { BlurFilterData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
blur_x: 4.0, blur_x: 4.0,
blur_y: 4.0, blur_y: 4.0,
quality: 1, quality: 1,

View File

@ -31,11 +31,11 @@ impl fmt::Debug for ColorMatrixFilterObject<'_> {
impl<'gc> ColorMatrixFilterObject<'gc> { impl<'gc> ColorMatrixFilterObject<'gc> {
add_field_accessors!([set_matrix, matrix, matrix, [f64; 4 * 5]],); add_field_accessors!([set_matrix, matrix, matrix, [f64; 4 * 5]],);
pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Option<Object<'gc>>) -> Self { pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
ColorMatrixFilterObject(GcCell::allocate( ColorMatrixFilterObject(GcCell::allocate(
gc_context, gc_context,
ColorMatrixFilterData { ColorMatrixFilterData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
matrix: [ matrix: [
1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0,

View File

@ -79,11 +79,11 @@ impl<'gc> ConvolutionFilterObject<'gc> {
self.update_matrix_length(gc_context); self.update_matrix_length(gc_context);
} }
pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Option<Object<'gc>>) -> Self { pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
ConvolutionFilterObject(GcCell::allocate( ConvolutionFilterObject(GcCell::allocate(
gc_context, gc_context,
ConvolutionFilterData { ConvolutionFilterData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
alpha: 0.0, alpha: 0.0,
bias: 0.0, bias: 0.0,
clamp: true, clamp: true,

View File

@ -14,7 +14,7 @@ macro_rules! impl_custom_object {
activation: &mut $crate::avm1::Activation<'_, 'gc, '_>, activation: &mut $crate::avm1::Activation<'_, 'gc, '_>,
this: $crate::avm1::Object<'gc>, this: $crate::avm1::Object<'gc>,
) -> Result<$crate::avm1::Object<'gc>, $crate::avm1::Error<'gc>> { ) -> Result<$crate::avm1::Object<'gc>, $crate::avm1::Error<'gc>> {
Ok($obj_type::$new(activation.context.gc_context, Some(this)).into()) Ok($obj_type::$new(activation.context.gc_context, this).into())
} }
}; };

View File

@ -93,11 +93,11 @@ impl<'gc> DisplacementMapFilterObject<'gc> {
[set_scale_y, scale_y, scale_y, f64], [set_scale_y, scale_y, scale_y, f64],
); );
pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Option<Object<'gc>>) -> Self { pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
DisplacementMapFilterObject(GcCell::allocate( DisplacementMapFilterObject(GcCell::allocate(
gc_context, gc_context,
DisplacementMapFilterData { DisplacementMapFilterData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
alpha: 0.0, alpha: 0.0,
color: 0, color: 0,
component_x: 0, component_x: 0,

View File

@ -63,11 +63,11 @@ impl<'gc> DropShadowFilterObject<'gc> {
[set_strength, strength, strength, f64], [set_strength, strength, strength, f64],
); );
pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Option<Object<'gc>>) -> Self { pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
DropShadowFilterObject(GcCell::allocate( DropShadowFilterObject(GcCell::allocate(
gc_context, gc_context,
DropShadowFilterData { DropShadowFilterData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
distance: 4.0, distance: 4.0,
hide_object: false, hide_object: false,
angle: 44.9999999772279, angle: 44.9999999772279,

View File

@ -54,11 +54,11 @@ impl<'gc> GlowFilterObject<'gc> {
[set_strength, strength, strength, f64], [set_strength, strength, strength, f64],
); );
pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Option<Object<'gc>>) -> Self { pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
GlowFilterObject(GcCell::allocate( GlowFilterObject(GcCell::allocate(
gc_context, gc_context,
GlowFilterData { GlowFilterData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
alpha: 1.0, alpha: 1.0,
blur_x: 6.0, blur_x: 6.0,
blur_y: 6.0, blur_y: 6.0,

View File

@ -76,11 +76,11 @@ impl<'gc> GradientBevelFilterObject<'gc> {
self.0.read().ratios.clone() self.0.read().ratios.clone()
} }
pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Option<Object<'gc>>) -> Self { pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
GradientBevelFilterObject(GcCell::allocate( GradientBevelFilterObject(GcCell::allocate(
gc_context, gc_context,
GradientBevelFilterData { GradientBevelFilterData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
alphas: vec![], alphas: vec![],
angle: 0.0, angle: 0.0,
blur_x: 0.0, blur_x: 0.0,

View File

@ -76,11 +76,11 @@ impl<'gc> GradientGlowFilterObject<'gc> {
self.0.read().ratios.clone() self.0.read().ratios.clone()
} }
pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Option<Object<'gc>>) -> Self { pub fn empty_object(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
GradientGlowFilterObject(GcCell::allocate( GradientGlowFilterObject(GcCell::allocate(
gc_context, gc_context,
GradientGlowFilterData { GradientGlowFilterData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
alphas: vec![], alphas: vec![],
angle: 0.0, angle: 0.0,
blur_x: 0.0, blur_x: 0.0,

View File

@ -30,14 +30,11 @@ impl fmt::Debug for SharedObject<'_> {
} }
impl<'gc> SharedObject<'gc> { impl<'gc> SharedObject<'gc> {
pub fn empty_shared_obj( pub fn empty_shared_obj(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>,
) -> Self {
SharedObject(GcCell::allocate( SharedObject(GcCell::allocate(
gc_context, gc_context,
SharedObjectData { SharedObjectData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
name: None, name: None,
}, },
)) ))

View File

@ -58,12 +58,12 @@ impl fmt::Debug for SoundObject<'_> {
impl<'gc> SoundObject<'gc> { impl<'gc> SoundObject<'gc> {
pub fn empty_sound( pub fn empty_sound(
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>, proto: Object<'gc>,
) -> SoundObject<'gc> { ) -> SoundObject<'gc> {
SoundObject(GcCell::allocate( SoundObject(GcCell::allocate(
gc_context, gc_context,
SoundObjectData { SoundObjectData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
sound: None, sound: None,
sound_instance: None, sound_instance: None,
owner: None, owner: None,

View File

@ -40,12 +40,12 @@ impl<'gc> StageObject<'gc> {
pub fn for_display_object( pub fn for_display_object(
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
display_object: DisplayObject<'gc>, display_object: DisplayObject<'gc>,
proto: Option<Object<'gc>>, proto: Object<'gc>,
) -> Self { ) -> Self {
Self(GcCell::allocate( Self(GcCell::allocate(
gc_context, gc_context,
StageObjectData { StageObjectData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
display_object, display_object,
text_field_bindings: Vec::new(), text_field_bindings: Vec::new(),
}, },

View File

@ -27,11 +27,11 @@ impl fmt::Debug for TransformObject<'_> {
} }
impl<'gc> TransformObject<'gc> { impl<'gc> TransformObject<'gc> {
pub fn empty(gc_context: MutationContext<'gc, '_>, proto: Option<Object<'gc>>) -> Self { pub fn empty(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
Self(GcCell::allocate( Self(GcCell::allocate(
gc_context, gc_context,
TransformData { TransformData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
clip: None, clip: None,
}, },
)) ))

View File

@ -79,14 +79,11 @@ impl<'gc> ValueObject<'gc> {
} }
/// Construct an empty box to be filled by a constructor. /// Construct an empty box to be filled by a constructor.
pub fn empty_box( pub fn empty_box(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Object<'gc> {
gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>,
) -> Object<'gc> {
ValueObject(GcCell::allocate( ValueObject(GcCell::allocate(
gc_context, gc_context,
ValueObjectData { ValueObjectData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
value: Value::Undefined, value: Value::Undefined,
}, },
)) ))

View File

@ -26,12 +26,12 @@ impl<'gc> XmlNodeObject<'gc> {
pub fn from_xml_node( pub fn from_xml_node(
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
mut node: XmlNode<'gc>, mut node: XmlNode<'gc>,
proto: Option<Object<'gc>>, proto: Object<'gc>,
) -> Self { ) -> Self {
let object = Self(GcCell::allocate( let object = Self(GcCell::allocate(
gc_context, gc_context,
XmlNodeObjectData { XmlNodeObjectData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
node, node,
}, },
)); ));
@ -61,7 +61,7 @@ impl<'gc> TObject<'gc> for XmlNodeObject<'gc> {
Ok(Self::from_xml_node( Ok(Self::from_xml_node(
activation.context.gc_context, activation.context.gc_context,
XmlNode::new(activation.context.gc_context, TEXT_NODE, Some("".into())), XmlNode::new(activation.context.gc_context, TEXT_NODE, Some("".into())),
Some(this), this,
) )
.into()) .into())
} }

View File

@ -80,12 +80,12 @@ pub struct XmlObjectData<'gc> {
impl<'gc> XmlObject<'gc> { impl<'gc> XmlObject<'gc> {
/// Construct a new XML document and object pair. /// Construct a new XML document and object pair.
pub fn empty(gc_context: MutationContext<'gc, '_>, proto: Option<Object<'gc>>) -> Self { pub fn empty(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
let mut root = XmlNode::new(gc_context, ELEMENT_NODE, None); let mut root = XmlNode::new(gc_context, ELEMENT_NODE, None);
let object = Self(GcCell::allocate( let object = Self(GcCell::allocate(
gc_context, gc_context,
XmlObjectData { XmlObjectData {
base: ScriptObject::new(gc_context, proto), base: ScriptObject::new(gc_context, Some(proto)),
root, root,
xml_decl: None, xml_decl: None,
doctype: None, doctype: None,
@ -235,7 +235,7 @@ impl<'gc> TObject<'gc> for XmlObject<'gc> {
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Object<'gc>, this: Object<'gc>,
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
Ok(Self::empty(activation.context.gc_context, Some(this)).into()) Ok(Self::empty(activation.context.gc_context, this).into())
} }
fn as_xml(&self) -> Option<XmlObject<'gc>> { fn as_xml(&self) -> Option<XmlObject<'gc>> {

View File

@ -267,7 +267,7 @@ impl<'gc> TDisplayObject<'gc> for Avm1Button<'gc> {
let object = StageObject::for_display_object( let object = StageObject::for_display_object(
context.gc_context, context.gc_context,
(*self).into(), (*self).into(),
Some(context.avm1.prototypes().button), context.avm1.prototypes().button,
); );
mc.object = Some(object.into()); mc.object = Some(object.into());

View File

@ -1331,7 +1331,7 @@ impl<'gc> EditText<'gc> {
let object: Avm1Object<'gc> = Avm1StageObject::for_display_object( let object: Avm1Object<'gc> = Avm1StageObject::for_display_object(
context.gc_context, context.gc_context,
(*self).into(), (*self).into(),
Some(context.avm1.prototypes().text_field), context.avm1.prototypes().text_field,
) )
.into(); .into();

View File

@ -1942,7 +1942,7 @@ impl<'gc> MovieClip<'gc> {
let object: Avm1Object<'gc> = StageObject::for_display_object( let object: Avm1Object<'gc> = StageObject::for_display_object(
activation.context.gc_context, activation.context.gc_context,
self.into(), self.into(),
Some(prototype), prototype,
) )
.into(); .into();
self.0.write(activation.context.gc_context).object = Some(object.into()); self.0.write(activation.context.gc_context).object = Some(object.into());
@ -1969,7 +1969,7 @@ impl<'gc> MovieClip<'gc> {
let object: Avm1Object<'gc> = StageObject::for_display_object( let object: Avm1Object<'gc> = StageObject::for_display_object(
context.gc_context, context.gc_context,
self.into(), self.into(),
Some(context.avm1.prototypes().movie_clip), context.avm1.prototypes().movie_clip,
) )
.into(); .into();
self.0.write(context.gc_context).object = Some(object.into()); self.0.write(context.gc_context).object = Some(object.into());

View File

@ -376,7 +376,7 @@ impl<'gc> TDisplayObject<'gc> for Video<'gc> {
let object: Avm1Object<'_> = Avm1StageObject::for_display_object( let object: Avm1Object<'_> = Avm1StageObject::for_display_object(
context.gc_context, context.gc_context,
(*self).into(), (*self).into(),
Some(context.avm1.prototypes().video), context.avm1.prototypes().video,
) )
.into(); .into();
write.object = Some(object.into()); write.object = Some(object.into());

View File

@ -364,8 +364,7 @@ impl<'gc> XmlNode<'gc> {
Some(object) => object, Some(object) => object,
None => { None => {
let proto = activation.context.avm1.prototypes().xml_node; let proto = activation.context.avm1.prototypes().xml_node;
XmlNodeObject::from_xml_node(activation.context.gc_context, *self, Some(proto)) XmlNodeObject::from_xml_node(activation.context.gc_context, *self, proto).into()
.into()
} }
} }
} }