avm1: Remove `TObject::set_proto`
The last usage of it was in `Player`, which anyway should operate only on newly created objects that don't have any virtual properties nor watchers. So it is safe to replace with `define_value`, that also cannot fail.
This commit is contained in:
parent
3641822f7d
commit
141f886cdd
|
@ -684,14 +684,6 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> {
|
|||
self.base.proto(activation)
|
||||
}
|
||||
|
||||
fn set_proto(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
prototype: Value<'gc>,
|
||||
) -> Result<(), Error<'gc>> {
|
||||
self.base.set_proto(activation, prototype)
|
||||
}
|
||||
|
||||
fn define_value(
|
||||
&self,
|
||||
gc_context: MutationContext<'gc, '_>,
|
||||
|
|
|
@ -266,17 +266,6 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
/// `get`.
|
||||
fn proto(&self, activation: &mut Activation<'_, 'gc, '_>) -> Value<'gc>;
|
||||
|
||||
/// Sets the `__proto__` of a given object.
|
||||
///
|
||||
/// The proto is another object used to resolve methods across a class of
|
||||
/// multiple objects. It should also be accessible as `__proto__` in
|
||||
/// `set`.
|
||||
fn set_proto(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
prototype: Value<'gc>,
|
||||
) -> Result<(), Error<'gc>>;
|
||||
|
||||
/// Define a value on an object.
|
||||
///
|
||||
/// Unlike setting a value, this function is intended to replace any
|
||||
|
|
|
@ -225,14 +225,6 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
|
|||
self.0.read().proto(activation)
|
||||
}
|
||||
|
||||
fn set_proto(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
prototype: Value<'gc>,
|
||||
) -> Result<(), Error<'gc>> {
|
||||
self.0.read().set_proto(activation, prototype)
|
||||
}
|
||||
|
||||
fn has_property(&self, activation: &mut Activation<'_, 'gc, '_>, name: &str) -> bool {
|
||||
self.0.read().has_property(activation, name)
|
||||
}
|
||||
|
|
|
@ -97,14 +97,6 @@ macro_rules! impl_custom_object {
|
|||
self.0.read().$field.proto(activation)
|
||||
}
|
||||
|
||||
fn set_proto(
|
||||
&self,
|
||||
activation: &mut crate::avm1::Activation<'_, 'gc, '_>,
|
||||
prototype: crate::avm1::Value<'gc>,
|
||||
) -> Result<(), crate::avm1::Error<'gc>> {
|
||||
self.0.read().$field.set_proto(activation, prototype)
|
||||
}
|
||||
|
||||
fn define_value(
|
||||
&self,
|
||||
gc_context: gc_arena::MutationContext<'gc, '_>,
|
||||
|
|
|
@ -439,14 +439,6 @@ impl<'gc> TObject<'gc> for ScriptObject<'gc> {
|
|||
self.get_data("__proto__", activation)
|
||||
}
|
||||
|
||||
fn set_proto(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
prototype: Value<'gc>,
|
||||
) -> Result<(), Error<'gc>> {
|
||||
self.set_data("__proto__", prototype, activation)
|
||||
}
|
||||
|
||||
/// Checks if the object has a given named property.
|
||||
fn has_property(&self, activation: &mut Activation<'_, 'gc, '_>, name: &str) -> bool {
|
||||
self.has_own_property(activation, name)
|
||||
|
|
|
@ -273,14 +273,6 @@ impl<'gc> TObject<'gc> for StageObject<'gc> {
|
|||
self.0.read().base.proto(activation)
|
||||
}
|
||||
|
||||
fn set_proto(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
prototype: Value<'gc>,
|
||||
) -> Result<(), Error<'gc>> {
|
||||
self.0.read().base.set_proto(activation, prototype)
|
||||
}
|
||||
|
||||
fn define_value(
|
||||
&self,
|
||||
gc_context: MutationContext<'gc, '_>,
|
||||
|
|
|
@ -161,17 +161,6 @@ impl<'gc> TObject<'gc> for SuperObject<'gc> {
|
|||
self.0.read().base_proto.proto(activation)
|
||||
}
|
||||
|
||||
fn set_proto(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
prototype: Value<'gc>,
|
||||
) -> Result<(), Error<'gc>> {
|
||||
if let Value::Object(prototype) = prototype {
|
||||
self.0.write(activation.context.gc_context).base_proto = prototype;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn define_value(
|
||||
&self,
|
||||
_gc_context: MutationContext<'gc, '_>,
|
||||
|
|
|
@ -182,14 +182,6 @@ impl<'gc> TObject<'gc> for XmlAttributesObject<'gc> {
|
|||
self.base().proto(activation)
|
||||
}
|
||||
|
||||
fn set_proto(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
prototype: Value<'gc>,
|
||||
) -> Result<(), Error<'gc>> {
|
||||
self.base().set_proto(activation, prototype)
|
||||
}
|
||||
|
||||
fn has_property(&self, activation: &mut Activation<'_, 'gc, '_>, name: &str) -> bool {
|
||||
self.base().has_property(activation, name)
|
||||
}
|
||||
|
|
|
@ -183,14 +183,6 @@ impl<'gc> TObject<'gc> for XmlIdMapObject<'gc> {
|
|||
self.base().proto(activation)
|
||||
}
|
||||
|
||||
fn set_proto(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
prototype: Value<'gc>,
|
||||
) -> Result<(), Error<'gc>> {
|
||||
self.base().set_proto(activation, prototype)
|
||||
}
|
||||
|
||||
fn has_property(&self, activation: &mut Activation<'_, 'gc, '_>, name: &str) -> bool {
|
||||
self.base().has_property(activation, name)
|
||||
}
|
||||
|
|
|
@ -1309,7 +1309,12 @@ impl Player {
|
|||
);
|
||||
if let Ok(prototype) = constructor.get("prototype", &mut activation) {
|
||||
if let Value::Object(object) = actions.clip.object() {
|
||||
object.set_proto(&mut activation, prototype).unwrap(); // TODO: What happens on error?
|
||||
object.define_value(
|
||||
activation.context.gc_context,
|
||||
"__proto__",
|
||||
prototype,
|
||||
Attribute::empty(),
|
||||
);
|
||||
for event in events {
|
||||
let _ = activation.run_child_frame_for_action(
|
||||
"[Actions]",
|
||||
|
|
Loading…
Reference in New Issue