From fb7fb6f99a7f04f89d67a2e7079daaca4c16c249 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Tue, 28 Jul 2020 20:00:07 +0200 Subject: [PATCH] avm1: Make FunctionObject::functional require prototype, it's not optional --- core/src/avm1/activation.rs | 4 +- core/src/avm1/function.rs | 4 +- core/src/avm1/globals.rs | 15 ++++--- core/src/avm1/globals/as_broadcaster.rs | 16 +++++--- core/src/avm1/globals/color_transform.rs | 4 +- core/src/avm1/globals/display_object.rs | 12 +++--- core/src/avm1/globals/point.rs | 2 +- core/src/avm1/globals/rectangle.rs | 28 ++++++------- core/src/avm1/globals/sound.rs | 6 +-- core/src/avm1/globals/stage.rs | 33 ++++++++++----- core/src/avm1/globals/system.rs | 16 ++++---- core/src/avm1/globals/system_capabilities.rs | 2 +- core/src/avm1/globals/system_security.rs | 16 ++++---- core/src/avm1/globals/text_field.rs | 42 ++++++++++---------- core/src/avm1/globals/xml.rs | 34 ++++++++-------- core/src/avm1/object/script_object.rs | 18 +++++---- core/src/avm1/value.rs | 2 +- 17 files changed, 138 insertions(+), 116 deletions(-) diff --git a/core/src/avm1/activation.rs b/core/src/avm1/activation.rs index 87268564f..9b32af780 100644 --- a/core/src/avm1/activation.rs +++ b/core/src/avm1/activation.rs @@ -919,7 +919,7 @@ impl<'a, 'gc: 'a> Activation<'a, 'gc> { context.gc_context, Gc::allocate(context.gc_context, func), Some(self.avm.prototypes.function), - Some(prototype), + prototype, ); if name == "" { self.avm.push(func_obj); @@ -954,7 +954,7 @@ impl<'a, 'gc: 'a> Activation<'a, 'gc> { context.gc_context, Gc::allocate(context.gc_context, func), Some(self.avm.prototypes.function), - Some(prototype), + prototype, ); if action_func.name == "" { self.avm.push(func_obj); diff --git a/core/src/avm1/function.rs b/core/src/avm1/function.rs index b744beb68..dd0a228f3 100644 --- a/core/src/avm1/function.rs +++ b/core/src/avm1/function.rs @@ -487,11 +487,11 @@ impl<'gc> FunctionObject<'gc> { context: MutationContext<'gc, '_>, function: impl Into>, fn_proto: Option>, - prototype: Option>, + prototype: Object<'gc>, ) -> Object<'gc> { // Avoid type inference issues let none: Option = None; - Self::allocate_function(context, Some(function), none, fn_proto, prototype) + Self::allocate_function(context, Some(function), none, fn_proto, Some(prototype)) } /// Construct a constructor function from an executable and associated protos. diff --git a/core/src/avm1/globals.rs b/core/src/avm1/globals.rs index 9fcb43d16..c0a8a4e51 100644 --- a/core/src/avm1/globals.rs +++ b/core/src/avm1/globals.rs @@ -389,14 +389,14 @@ pub fn create_globals<'gc>( gc_context, Executable::Native(color_transform::constructor), Some(function_proto), - Some(color_transform_proto), + color_transform_proto, ) .into(), EnumSet::empty(), ); let (broadcaster_functions, as_broadcaster) = - as_broadcaster::create(gc_context, Some(object_proto), Some(function_proto)); + as_broadcaster::create(gc_context, Some(object_proto), function_proto); let mut globals = ScriptObject::bare_object(gc_context); globals.define_value( @@ -474,8 +474,7 @@ pub fn create_globals<'gc>( DontEnum.into(), ); - let system_security = - system_security::create(gc_context, Some(object_proto), Some(function_proto)); + let system_security = system_security::create(gc_context, Some(object_proto), function_proto); let system_capabilities = system_capabilities::create(gc_context, Some(object_proto), function_proto); let system_ime = system_ime::create( @@ -489,7 +488,7 @@ pub fn create_globals<'gc>( let system = system::create( gc_context, Some(object_proto), - Some(function_proto), + function_proto, system_security, system_capabilities, system_ime, @@ -537,7 +536,7 @@ pub fn create_globals<'gc>( gc_context, Some(object_proto), Some(array_proto), - Some(function_proto), + function_proto, broadcaster_functions, )), DontEnum.into(), @@ -594,7 +593,7 @@ pub fn create_globals<'gc>( gc_context, Executable::Native(get_nan), Some(function_proto), - Some(function_proto), + function_proto, ), None, DontEnum.into(), @@ -606,7 +605,7 @@ pub fn create_globals<'gc>( gc_context, Executable::Native(get_infinity), Some(function_proto), - Some(function_proto), + function_proto, ), None, DontEnum.into(), diff --git a/core/src/avm1/globals/as_broadcaster.rs b/core/src/avm1/globals/as_broadcaster.rs index 58a35dad4..7dead54a8 100644 --- a/core/src/avm1/globals/as_broadcaster.rs +++ b/core/src/avm1/globals/as_broadcaster.rs @@ -194,7 +194,7 @@ pub fn initialize_internal<'gc>( pub fn create<'gc>( gc_context: MutationContext<'gc, '_>, proto: Option>, - fn_proto: Option>, + fn_proto: Object<'gc>, ) -> (BroadcasterFunctions<'gc>, Object<'gc>) { let mut as_broadcaster = ScriptObject::object(gc_context, proto); @@ -203,11 +203,15 @@ pub fn create<'gc>( initialize, gc_context, DontDelete | DontEnum, - fn_proto, + Some(fn_proto), ); - let add_listener = - FunctionObject::function(gc_context, Executable::Native(add_listener), fn_proto, None); + let add_listener = FunctionObject::function( + gc_context, + Executable::Native(add_listener), + Some(fn_proto), + fn_proto, + ); as_broadcaster.define_value( gc_context, "addListener", @@ -218,8 +222,8 @@ pub fn create<'gc>( let remove_listener = FunctionObject::function( gc_context, Executable::Native(remove_listener), + Some(fn_proto), fn_proto, - None, ); as_broadcaster.define_value( gc_context, @@ -231,8 +235,8 @@ pub fn create<'gc>( let broadcast_message = FunctionObject::function( gc_context, Executable::Native(broadcast_message), + Some(fn_proto), fn_proto, - None, ); as_broadcaster.define_value( gc_context, diff --git a/core/src/avm1/globals/color_transform.rs b/core/src/avm1/globals/color_transform.rs index e211fe7f6..31637308c 100644 --- a/core/src/avm1/globals/color_transform.rs +++ b/core/src/avm1/globals/color_transform.rs @@ -18,8 +18,8 @@ macro_rules! with_color_transform { $obj.add_property( $gc, $name, - FunctionObject::function($gc, Executable::Native($get), Some($fn_proto), Some($fn_proto)), - Some(FunctionObject::function($gc, Executable::Native($set), Some($fn_proto), Some($fn_proto))), + FunctionObject::function($gc, Executable::Native($get), Some($fn_proto), $fn_proto), + Some(FunctionObject::function($gc, Executable::Native($set), Some($fn_proto), $fn_proto)), EnumSet::empty(), ); )* diff --git a/core/src/avm1/globals/display_object.rs b/core/src/avm1/globals/display_object.rs index c63602460..577e84060 100644 --- a/core/src/avm1/globals/display_object.rs +++ b/core/src/avm1/globals/display_object.rs @@ -60,13 +60,13 @@ pub fn define_display_object_proto<'gc>( Ok(activation.avm.global_object(context)) }), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(overwrite_global), Some(fn_proto), - Some(fn_proto), + fn_proto, )), DontDelete | ReadOnly | DontEnum, ); @@ -80,13 +80,13 @@ pub fn define_display_object_proto<'gc>( Ok(activation.root_object(context)) }), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(overwrite_root), Some(fn_proto), - Some(fn_proto), + fn_proto, )), DontDelete | ReadOnly | DontEnum, ); @@ -98,13 +98,13 @@ pub fn define_display_object_proto<'gc>( gc_context, Executable::Native(get_parent), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(overwrite_parent), Some(fn_proto), - Some(fn_proto), + fn_proto, )), DontDelete | ReadOnly | DontEnum, ); diff --git a/core/src/avm1/globals/point.rs b/core/src/avm1/globals/point.rs index 78642a1fa..db58fcce7 100644 --- a/core/src/avm1/globals/point.rs +++ b/core/src/avm1/globals/point.rs @@ -394,7 +394,7 @@ pub fn create_proto<'gc>( gc_context, Executable::Native(length), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, Attribute::ReadOnly.into(), diff --git a/core/src/avm1/globals/rectangle.rs b/core/src/avm1/globals/rectangle.rs index b8e9c7723..af8ef78af 100644 --- a/core/src/avm1/globals/rectangle.rs +++ b/core/src/avm1/globals/rectangle.rs @@ -1040,13 +1040,13 @@ pub fn create_proto<'gc>( gc_context, Executable::Native(get_left), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_left), Some(fn_proto), - Some(fn_proto), + fn_proto, )), Attribute::DontDelete | Attribute::DontEnum, ); @@ -1058,13 +1058,13 @@ pub fn create_proto<'gc>( gc_context, Executable::Native(get_top), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_top), Some(fn_proto), - Some(fn_proto), + fn_proto, )), Attribute::DontDelete | Attribute::DontEnum, ); @@ -1076,13 +1076,13 @@ pub fn create_proto<'gc>( gc_context, Executable::Native(get_right), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_right), Some(fn_proto), - Some(fn_proto), + fn_proto, )), Attribute::DontDelete | Attribute::DontEnum, ); @@ -1094,13 +1094,13 @@ pub fn create_proto<'gc>( gc_context, Executable::Native(get_bottom), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_bottom), Some(fn_proto), - Some(fn_proto), + fn_proto, )), Attribute::DontDelete | Attribute::DontEnum, ); @@ -1112,13 +1112,13 @@ pub fn create_proto<'gc>( gc_context, Executable::Native(get_size), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_size), Some(fn_proto), - Some(fn_proto), + fn_proto, )), Attribute::DontDelete | Attribute::DontEnum, ); @@ -1130,13 +1130,13 @@ pub fn create_proto<'gc>( gc_context, Executable::Native(get_top_left), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_top_left), Some(fn_proto), - Some(fn_proto), + fn_proto, )), Attribute::DontDelete | Attribute::DontEnum, ); @@ -1148,13 +1148,13 @@ pub fn create_proto<'gc>( gc_context, Executable::Native(get_bottom_right), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_bottom_right), Some(fn_proto), - Some(fn_proto), + fn_proto, )), Attribute::DontDelete | Attribute::DontEnum, ); diff --git a/core/src/avm1/globals/sound.rs b/core/src/avm1/globals/sound.rs index 2c4e5797d..ec20c451f 100644 --- a/core/src/avm1/globals/sound.rs +++ b/core/src/avm1/globals/sound.rs @@ -53,7 +53,7 @@ pub fn create_proto<'gc>( gc_context, Executable::Native(duration), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, DontDelete | ReadOnly | DontEnum, @@ -66,7 +66,7 @@ pub fn create_proto<'gc>( gc_context, Executable::Native(id3), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, DontDelete | ReadOnly | DontEnum, @@ -127,7 +127,7 @@ pub fn create_proto<'gc>( gc_context, Executable::Native(position), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, DontDelete | ReadOnly | DontEnum, diff --git a/core/src/avm1/globals/stage.rs b/core/src/avm1/globals/stage.rs index a95781a35..2761a15e1 100644 --- a/core/src/avm1/globals/stage.rs +++ b/core/src/avm1/globals/stage.rs @@ -14,7 +14,7 @@ pub fn create_stage_object<'gc>( gc_context: MutationContext<'gc, '_>, proto: Option>, array_proto: Option>, - fn_proto: Option>, + fn_proto: Object<'gc>, broadcaster_functions: BroadcasterFunctions<'gc>, ) -> Object<'gc> { let stage = ScriptObject::object(gc_context, proto); @@ -24,11 +24,16 @@ pub fn create_stage_object<'gc>( stage.add_property( gc_context, "align", - FunctionObject::function(gc_context, Executable::Native(align), fn_proto, fn_proto), + FunctionObject::function( + gc_context, + Executable::Native(align), + Some(fn_proto), + fn_proto, + ), Some(FunctionObject::function( gc_context, Executable::Native(set_align), - fn_proto, + Some(fn_proto), fn_proto, )), Attribute::DontEnum | Attribute::DontDelete, @@ -37,7 +42,12 @@ pub fn create_stage_object<'gc>( stage.add_property( gc_context, "height", - FunctionObject::function(gc_context, Executable::Native(height), fn_proto, fn_proto), + FunctionObject::function( + gc_context, + Executable::Native(height), + Some(fn_proto), + fn_proto, + ), None, Attribute::DontEnum | Attribute::DontDelete | Attribute::ReadOnly, ); @@ -48,13 +58,13 @@ pub fn create_stage_object<'gc>( FunctionObject::function( gc_context, Executable::Native(scale_mode), - fn_proto, + Some(fn_proto), fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_scale_mode), - fn_proto, + Some(fn_proto), fn_proto, )), Attribute::DontEnum | Attribute::DontDelete, @@ -66,13 +76,13 @@ pub fn create_stage_object<'gc>( FunctionObject::function( gc_context, Executable::Native(show_menu), - fn_proto, + Some(fn_proto), fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_show_menu), - fn_proto, + Some(fn_proto), fn_proto, )), Attribute::DontEnum | Attribute::DontDelete, @@ -81,7 +91,12 @@ pub fn create_stage_object<'gc>( stage.add_property( gc_context, "width", - FunctionObject::function(gc_context, Executable::Native(width), fn_proto, fn_proto), + FunctionObject::function( + gc_context, + Executable::Native(width), + Some(fn_proto), + fn_proto, + ), None, Attribute::DontEnum | Attribute::DontDelete | Attribute::ReadOnly, ); diff --git a/core/src/avm1/globals/system.rs b/core/src/avm1/globals/system.rs index f5defe90d..ce3aaa094 100644 --- a/core/src/avm1/globals/system.rs +++ b/core/src/avm1/globals/system.rs @@ -509,7 +509,7 @@ pub fn on_status<'gc>( pub fn create<'gc>( gc_context: MutationContext<'gc, '_>, proto: Option>, - fn_proto: Option>, + fn_proto: Object<'gc>, security: Object<'gc>, capabilities: Object<'gc>, ime: Object<'gc>, @@ -522,13 +522,13 @@ pub fn create<'gc>( FunctionObject::function( gc_context, Executable::Native(get_exact_settings), - fn_proto, + Some(fn_proto), fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_exact_settings), - fn_proto, + Some(fn_proto), fn_proto, )), EnumSet::empty(), @@ -540,13 +540,13 @@ pub fn create<'gc>( FunctionObject::function( gc_context, Executable::Native(get_use_code_page), - fn_proto, + Some(fn_proto), fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_use_code_page), - fn_proto, + Some(fn_proto), fn_proto, )), EnumSet::empty(), @@ -568,7 +568,7 @@ pub fn create<'gc>( set_clipboard, gc_context, EnumSet::empty(), - fn_proto, + Some(fn_proto), ); system.force_set_function( @@ -576,7 +576,7 @@ pub fn create<'gc>( show_settings, gc_context, EnumSet::empty(), - fn_proto, + Some(fn_proto), ); // Pretty sure this is a variable @@ -585,7 +585,7 @@ pub fn create<'gc>( on_status, gc_context, EnumSet::empty(), - fn_proto, + Some(fn_proto), ); system.into() diff --git a/core/src/avm1/globals/system_capabilities.rs b/core/src/avm1/globals/system_capabilities.rs index 81709147c..5affbbca5 100644 --- a/core/src/avm1/globals/system_capabilities.rs +++ b/core/src/avm1/globals/system_capabilities.rs @@ -40,7 +40,7 @@ macro_rules! capabilities_prop { $capabilities.add_property( $gc_ctx, $name, - FunctionObject::function($gc_ctx, Executable::Native($func), Some($fn_proto), Some($fn_proto)), + FunctionObject::function($gc_ctx, Executable::Native($func), Some($fn_proto), $fn_proto), None, EnumSet::empty() ); diff --git a/core/src/avm1/globals/system_security.rs b/core/src/avm1/globals/system_security.rs index ac14aa9a8..e4c955c70 100644 --- a/core/src/avm1/globals/system_security.rs +++ b/core/src/avm1/globals/system_security.rs @@ -93,7 +93,7 @@ fn policy_file_resolver<'gc>( pub fn create<'gc>( gc_context: MutationContext<'gc, '_>, proto: Option>, - fn_proto: Option>, + fn_proto: Object<'gc>, ) -> Object<'gc> { let mut security = ScriptObject::object(gc_context, proto); @@ -102,7 +102,7 @@ pub fn create<'gc>( policy_file_resolver, gc_context, EnumSet::empty(), - fn_proto, + Some(fn_proto), ); security.force_set_function( @@ -110,7 +110,7 @@ pub fn create<'gc>( allow_domain, gc_context, EnumSet::empty(), - fn_proto, + Some(fn_proto), ); security.force_set_function( @@ -118,7 +118,7 @@ pub fn create<'gc>( allow_insecure_domain, gc_context, EnumSet::empty(), - fn_proto, + Some(fn_proto), ); security.force_set_function( @@ -126,7 +126,7 @@ pub fn create<'gc>( load_policy_file, gc_context, EnumSet::empty(), - fn_proto, + Some(fn_proto), ); security.force_set_function( @@ -134,7 +134,7 @@ pub fn create<'gc>( escape_domain, gc_context, EnumSet::empty(), - fn_proto, + Some(fn_proto), ); security.add_property( @@ -143,7 +143,7 @@ pub fn create<'gc>( FunctionObject::function( gc_context, Executable::Native(get_sandbox_type), - fn_proto, + Some(fn_proto), fn_proto, ), None, @@ -156,7 +156,7 @@ pub fn create<'gc>( FunctionObject::function( gc_context, Executable::Native(get_choose_local_swf_path), - fn_proto, + Some(fn_proto), fn_proto, ), None, diff --git a/core/src/avm1/globals/text_field.rs b/core/src/avm1/globals/text_field.rs index 726253f56..a509b2b76 100644 --- a/core/src/avm1/globals/text_field.rs +++ b/core/src/avm1/globals/text_field.rs @@ -452,13 +452,13 @@ pub fn attach_virtual_properties<'gc>( gc_context, Executable::Native(get_text), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_text), Some(fn_proto), - Some(fn_proto), + fn_proto, )), ReadOnly.into(), ); @@ -469,13 +469,13 @@ pub fn attach_virtual_properties<'gc>( gc_context, Executable::Native(get_html), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_html), Some(fn_proto), - Some(fn_proto), + fn_proto, )), ReadOnly.into(), ); @@ -486,13 +486,13 @@ pub fn attach_virtual_properties<'gc>( gc_context, Executable::Native(get_html_text), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_html_text), Some(fn_proto), - Some(fn_proto), + fn_proto, )), ReadOnly.into(), ); @@ -503,7 +503,7 @@ pub fn attach_virtual_properties<'gc>( gc_context, Executable::Native(get_length), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -515,7 +515,7 @@ pub fn attach_virtual_properties<'gc>( gc_context, Executable::Native(text_width), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -527,7 +527,7 @@ pub fn attach_virtual_properties<'gc>( gc_context, Executable::Native(text_height), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -539,13 +539,13 @@ pub fn attach_virtual_properties<'gc>( gc_context, Executable::Native(multiline), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_multiline), Some(fn_proto), - Some(fn_proto), + fn_proto, )), ReadOnly.into(), ); @@ -556,13 +556,13 @@ pub fn attach_virtual_properties<'gc>( gc_context, Executable::Native(variable), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_variable), Some(fn_proto), - Some(fn_proto), + fn_proto, )), DontDelete | ReadOnly | DontEnum, ); @@ -573,13 +573,13 @@ pub fn attach_virtual_properties<'gc>( gc_context, Executable::Native(word_wrap), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_word_wrap), Some(fn_proto), - Some(fn_proto), + fn_proto, )), ReadOnly.into(), ); @@ -590,13 +590,13 @@ pub fn attach_virtual_properties<'gc>( gc_context, Executable::Native(auto_size), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_auto_size), Some(fn_proto), - Some(fn_proto), + fn_proto, )), ReadOnly.into(), ); @@ -607,13 +607,13 @@ pub fn attach_virtual_properties<'gc>( gc_context, Executable::Native(get_border), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_border), Some(fn_proto), - Some(fn_proto), + fn_proto, )), ReadOnly.into(), ); @@ -624,13 +624,13 @@ pub fn attach_virtual_properties<'gc>( gc_context, Executable::Native(get_embed_fonts), Some(fn_proto), - Some(fn_proto), + fn_proto, ), Some(FunctionObject::function( gc_context, Executable::Native(set_embed_fonts), Some(fn_proto), - Some(fn_proto), + fn_proto, )), ReadOnly.into(), ); diff --git a/core/src/avm1/globals/xml.rs b/core/src/avm1/globals/xml.rs index 6065bf201..debe7b4b7 100644 --- a/core/src/avm1/globals/xml.rs +++ b/core/src/avm1/globals/xml.rs @@ -527,7 +527,7 @@ pub fn create_xmlnode_proto<'gc>( gc_context, Executable::Native(xmlnode_local_name), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -539,7 +539,7 @@ pub fn create_xmlnode_proto<'gc>( gc_context, Executable::Native(xmlnode_node_name), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -551,7 +551,7 @@ pub fn create_xmlnode_proto<'gc>( gc_context, Executable::Native(xmlnode_node_type), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -563,7 +563,7 @@ pub fn create_xmlnode_proto<'gc>( gc_context, Executable::Native(xmlnode_node_value), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -575,7 +575,7 @@ pub fn create_xmlnode_proto<'gc>( gc_context, Executable::Native(xmlnode_prefix), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -587,7 +587,7 @@ pub fn create_xmlnode_proto<'gc>( gc_context, Executable::Native(xmlnode_child_nodes), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -599,7 +599,7 @@ pub fn create_xmlnode_proto<'gc>( gc_context, Executable::Native(xmlnode_first_child), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -611,7 +611,7 @@ pub fn create_xmlnode_proto<'gc>( gc_context, Executable::Native(xmlnode_last_child), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -623,7 +623,7 @@ pub fn create_xmlnode_proto<'gc>( gc_context, Executable::Native(xmlnode_parent_node), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -635,7 +635,7 @@ pub fn create_xmlnode_proto<'gc>( gc_context, Executable::Native(xmlnode_previous_sibling), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -647,7 +647,7 @@ pub fn create_xmlnode_proto<'gc>( gc_context, Executable::Native(xmlnode_next_sibling), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -659,7 +659,7 @@ pub fn create_xmlnode_proto<'gc>( gc_context, Executable::Native(xmlnode_attributes), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -671,7 +671,7 @@ pub fn create_xmlnode_proto<'gc>( gc_context, Executable::Native(xmlnode_namespace_uri), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -1056,7 +1056,7 @@ pub fn create_xml_proto<'gc>( gc_context, Executable::Native(xml_doc_type_decl), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -1068,7 +1068,7 @@ pub fn create_xml_proto<'gc>( gc_context, Executable::Native(xml_xml_decl), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -1080,7 +1080,7 @@ pub fn create_xml_proto<'gc>( gc_context, Executable::Native(xml_id_map), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), @@ -1092,7 +1092,7 @@ pub fn create_xml_proto<'gc>( gc_context, Executable::Native(xml_status), Some(fn_proto), - Some(fn_proto), + fn_proto, ), None, ReadOnly.into(), diff --git a/core/src/avm1/object/script_object.rs b/core/src/avm1/object/script_object.rs index 837abd616..4e6c73cf9 100644 --- a/core/src/avm1/object/script_object.rs +++ b/core/src/avm1/object/script_object.rs @@ -1,6 +1,6 @@ use crate::avm1::activation::Activation; use crate::avm1::error::Error; -use crate::avm1::function::{ExecutionReason, FunctionObject, NativeFunction}; +use crate::avm1::function::{Executable, ExecutionReason, FunctionObject, NativeFunction}; use crate::avm1::property::{Attribute, Property}; use crate::avm1::{AvmString, Object, ObjectPtr, TObject, UpdateContext, Value}; use crate::property_map::{Entry, PropertyMap}; @@ -196,9 +196,13 @@ impl<'gc> ScriptObject<'gc> { self.define_value( gc_context, name, - Value::Object(FunctionObject::function( - gc_context, function, fn_proto, None, - )), + FunctionObject::bare_function( + gc_context, + Some(function), + Option::::None, + fn_proto, + ) + .into(), attributes.into(), ) } @@ -1061,7 +1065,7 @@ mod tests { context.gc_context, Executable::Native(|_avm, _context, _this, _args| Ok("Virtual!".into())), None, - None, + activation.avm.prototypes.function, ); object.as_script_object().unwrap().add_property( @@ -1095,7 +1099,7 @@ mod tests { context.gc_context, Executable::Native(|_avm, _context, _this, _args| Ok("Virtual!".into())), None, - None, + activation.avm.prototypes.function, ); object.as_script_object().unwrap().add_property( @@ -1172,7 +1176,7 @@ mod tests { context.gc_context, Executable::Native(|_avm, _context, _this, _args| Ok(Value::Null)), None, - None, + activation.avm.prototypes.function, ); object.as_script_object().unwrap().define_value( diff --git a/core/src/avm1/value.rs b/core/src/avm1/value.rs index a67252ea6..ff760b174 100644 --- a/core/src/avm1/value.rs +++ b/core/src/avm1/value.rs @@ -633,7 +633,7 @@ mod test { context.gc_context, Executable::Native(value_of_impl), Some(protos.function), - None, + protos.function, ); let o = ScriptObject::object_cell(context.gc_context, Some(protos.object));