avm1: Add TObject::set_proto
This commit is contained in:
parent
6316d7e0b3
commit
6b48e77b61
|
@ -519,6 +519,10 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> {
|
|||
self.base.proto()
|
||||
}
|
||||
|
||||
fn set_proto(&self, gc_context: MutationContext<'gc, '_>, prototype: Option<Object<'gc>>) {
|
||||
self.base.set_proto(gc_context, prototype);
|
||||
}
|
||||
|
||||
fn define_value(
|
||||
&self,
|
||||
gc_context: MutationContext<'gc, '_>,
|
||||
|
|
|
@ -118,6 +118,13 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
/// `get`.
|
||||
fn proto(&self) -> Option<Object<'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, gc_context: MutationContext<'gc, '_>, prototype: Option<Object<'gc>>);
|
||||
|
||||
/// Define a value on an object.
|
||||
///
|
||||
/// Unlike setting a value, this function is intended to replace any
|
||||
|
|
|
@ -409,6 +409,10 @@ impl<'gc> TObject<'gc> for ScriptObject<'gc> {
|
|||
self.0.read().prototype
|
||||
}
|
||||
|
||||
fn set_proto(&self, gc_context: MutationContext<'gc, '_>, prototype: Option<Object<'gc>>) {
|
||||
self.0.write(gc_context).prototype = prototype;
|
||||
}
|
||||
|
||||
/// Checks if the object has a given named property.
|
||||
fn has_property(
|
||||
&self,
|
||||
|
|
|
@ -183,6 +183,10 @@ impl<'gc> TObject<'gc> for SoundObject<'gc> {
|
|||
self.base().proto()
|
||||
}
|
||||
|
||||
fn set_proto(&self, gc_context: MutationContext<'gc, '_>, prototype: Option<Object<'gc>>) {
|
||||
self.base().set_proto(gc_context, prototype);
|
||||
}
|
||||
|
||||
fn define_value(
|
||||
&self,
|
||||
gc_context: MutationContext<'gc, '_>,
|
||||
|
|
|
@ -157,6 +157,10 @@ impl<'gc> TObject<'gc> for StageObject<'gc> {
|
|||
self.base.proto()
|
||||
}
|
||||
|
||||
fn set_proto(&self, gc_context: MutationContext<'gc, '_>, prototype: Option<Object<'gc>>) {
|
||||
self.base.set_proto(gc_context, prototype);
|
||||
}
|
||||
|
||||
fn define_value(
|
||||
&self,
|
||||
gc_context: MutationContext<'gc, '_>,
|
||||
|
|
|
@ -134,6 +134,10 @@ impl<'gc> TObject<'gc> for SuperObject<'gc> {
|
|||
self.0.read().proto
|
||||
}
|
||||
|
||||
fn set_proto(&self, gc_context: MutationContext<'gc, '_>, prototype: Option<Object<'gc>>) {
|
||||
self.0.write(gc_context).proto = prototype;
|
||||
}
|
||||
|
||||
fn define_value(
|
||||
&self,
|
||||
_gc_context: MutationContext<'gc, '_>,
|
||||
|
|
|
@ -229,6 +229,13 @@ impl<'gc> TObject<'gc> for ValueObject<'gc> {
|
|||
self.0.read().base.proto()
|
||||
}
|
||||
|
||||
fn set_proto(&self, gc_context: MutationContext<'gc, '_>, prototype: Option<Object<'gc>>) {
|
||||
self.0
|
||||
.write(gc_context)
|
||||
.base
|
||||
.set_proto(gc_context, prototype);
|
||||
}
|
||||
|
||||
fn has_property(
|
||||
&self,
|
||||
avm: &mut Avm1<'gc>,
|
||||
|
|
|
@ -169,6 +169,10 @@ impl<'gc> TObject<'gc> for XMLAttributesObject<'gc> {
|
|||
self.base().proto()
|
||||
}
|
||||
|
||||
fn set_proto(&self, gc_context: MutationContext<'gc, '_>, prototype: Option<Object<'gc>>) {
|
||||
self.base().set_proto(gc_context, prototype);
|
||||
}
|
||||
|
||||
fn has_property(
|
||||
&self,
|
||||
avm: &mut Avm1<'gc>,
|
||||
|
|
|
@ -163,6 +163,10 @@ impl<'gc> TObject<'gc> for XMLIDMapObject<'gc> {
|
|||
self.base().proto()
|
||||
}
|
||||
|
||||
fn set_proto(&self, gc_context: MutationContext<'gc, '_>, prototype: Option<Object<'gc>>) {
|
||||
self.base().set_proto(gc_context, prototype);
|
||||
}
|
||||
|
||||
fn has_property(
|
||||
&self,
|
||||
avm: &mut Avm1<'gc>,
|
||||
|
|
|
@ -157,6 +157,10 @@ impl<'gc> TObject<'gc> for XMLObject<'gc> {
|
|||
self.base().proto()
|
||||
}
|
||||
|
||||
fn set_proto(&self, gc_context: MutationContext<'gc, '_>, prototype: Option<Object<'gc>>) {
|
||||
self.base().set_proto(gc_context, prototype);
|
||||
}
|
||||
|
||||
fn has_property(
|
||||
&self,
|
||||
avm: &mut Avm1<'gc>,
|
||||
|
|
Loading…
Reference in New Issue