avm1: Remove `ScriptObject::object_cell`

Use `ScriptObject::new` instead.
This commit is contained in:
relrelb 2022-08-19 13:54:09 +03:00 committed by Mike Welsh
parent 04b4a6cabe
commit 5cbfcde784
5 changed files with 13 additions and 17 deletions

View File

@ -534,7 +534,7 @@ pub fn create_globals<'gc>(
Object<'gc>,
as_broadcaster::BroadcasterFunctions<'gc>,
) {
let object_proto = ScriptObject::object_cell(gc_context, None);
let object_proto = ScriptObject::new(gc_context, None).into();
let function_proto = function::create_proto(gc_context, object_proto);
object::fill_proto(gc_context, object_proto, function_proto);

View File

@ -117,8 +117,12 @@ pub fn apply<'gc>(
/// returned object is also a bare object, which will need to be linked into
/// the prototype of `Object`.
pub fn create_proto<'gc>(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Object<'gc> {
let function_proto = ScriptObject::object_cell(gc_context, Some(proto));
let object = function_proto.as_script_object().unwrap();
define_properties_on(PROTO_DECLS, gc_context, object, function_proto);
function_proto
let function_proto = ScriptObject::new(gc_context, Some(proto));
define_properties_on(
PROTO_DECLS,
gc_context,
function_proto,
function_proto.into(),
);
function_proto.into()
}

View File

@ -87,14 +87,6 @@ impl<'gc> ScriptObject<'gc> {
object
}
/// Constructs and allocates an empty but normal object in one go.
pub fn object_cell(
gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>,
) -> Object<'gc> {
Self::new(gc_context, proto).into()
}
/// Constructs an object with no properties, not even builtins.
///
/// Intended for constructing scope chains, since they exclusively use the

View File

@ -52,7 +52,7 @@ impl<'gc> Scope<'gc> {
Scope {
parent: Some(parent),
class: ScopeClass::Local,
values: ScriptObject::object_cell(mc, None),
values: ScriptObject::new(mc, None).into(),
}
}
@ -104,7 +104,7 @@ impl<'gc> Scope<'gc> {
Self {
parent: None,
class: ScopeClass::Global,
values: ScriptObject::object_cell(mc, None),
values: ScriptObject::new(mc, None).into(),
},
)
})

View File

@ -889,7 +889,7 @@ mod test {
protos.function,
);
let o = ScriptObject::object_cell(activation.context.gc_context, Some(protos.object));
let o = ScriptObject::new(activation.context.gc_context, Some(protos.object));
o.define_value(
activation.context.gc_context,
"valueOf",
@ -898,7 +898,7 @@ mod test {
);
assert_eq!(
Value::Object(o).to_primitive_num(activation).unwrap(),
Value::from(o).to_primitive_num(activation).unwrap(),
5.into()
);