core: `TObject::get_local` no longer requires you to resolve after retrieving it
This commit is contained in:
parent
a121a3a4d0
commit
26590d4c63
|
@ -457,7 +457,7 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> {
|
|||
avm: &mut Avm1<'gc>,
|
||||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
this: Object<'gc>,
|
||||
) -> Result<ReturnValue<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
self.base.get_local(name, avm, context, this)
|
||||
}
|
||||
|
||||
|
|
|
@ -875,12 +875,8 @@ fn local_to_global<'gc>(
|
|||
// localToGlobal does no coercion; it fails if the properties are not numbers.
|
||||
// It does not search the prototype chain.
|
||||
if let (Value::Number(x), Value::Number(y)) = (
|
||||
point
|
||||
.get_local("x", avm, context, *point)?
|
||||
.resolve(avm, context)?,
|
||||
point
|
||||
.get_local("y", avm, context, *point)?
|
||||
.resolve(avm, context)?,
|
||||
point.get_local("x", avm, context, *point)?,
|
||||
point.get_local("y", avm, context, *point)?,
|
||||
) {
|
||||
let x = Twips::from_pixels(x);
|
||||
let y = Twips::from_pixels(y);
|
||||
|
@ -961,12 +957,8 @@ fn global_to_local<'gc>(
|
|||
// globalToLocal does no coercion; it fails if the properties are not numbers.
|
||||
// It does not search the prototype chain.
|
||||
if let (Value::Number(x), Value::Number(y)) = (
|
||||
point
|
||||
.get_local("x", avm, context, *point)?
|
||||
.resolve(avm, context)?,
|
||||
point
|
||||
.get_local("y", avm, context, *point)?
|
||||
.resolve(avm, context)?,
|
||||
point.get_local("x", avm, context, *point)?,
|
||||
point.get_local("y", avm, context, *point)?,
|
||||
) {
|
||||
let x = Twips::from_pixels(x);
|
||||
let y = Twips::from_pixels(y);
|
||||
|
|
|
@ -48,7 +48,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
avm: &mut Avm1<'gc>,
|
||||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
this: Object<'gc>,
|
||||
) -> Result<ReturnValue<'gc>, Error>;
|
||||
) -> Result<Value<'gc>, Error>;
|
||||
|
||||
/// Retrieve a named property from the object, or it's prototype.
|
||||
fn get(
|
||||
|
@ -58,8 +58,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
if self.has_own_property(avm, context, name) {
|
||||
self.get_local(name, avm, context, (*self).into())?
|
||||
.resolve(avm, context)
|
||||
self.get_local(name, avm, context, (*self).into())
|
||||
} else {
|
||||
search_prototype(self.proto(), name, avm, context, (*self).into())?
|
||||
.0
|
||||
|
@ -462,7 +461,10 @@ pub fn search_prototype<'gc>(
|
|||
}
|
||||
|
||||
if proto.unwrap().has_own_property(avm, context, name) {
|
||||
return Ok((proto.unwrap().get_local(name, avm, context, this)?, proto));
|
||||
return Ok((
|
||||
proto.unwrap().get_local(name, avm, context, this)?.into(),
|
||||
proto,
|
||||
));
|
||||
}
|
||||
|
||||
proto = proto.unwrap().proto();
|
||||
|
|
|
@ -293,16 +293,18 @@ impl<'gc> TObject<'gc> for ScriptObject<'gc> {
|
|||
avm: &mut Avm1<'gc>,
|
||||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
this: Object<'gc>,
|
||||
) -> Result<ReturnValue<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
if name == "__proto__" {
|
||||
return Ok(self.proto().map_or(Value::Undefined, Value::Object).into());
|
||||
return Ok(self.proto().map_or(Value::Undefined, Value::Object));
|
||||
}
|
||||
|
||||
if let Some(value) = self.0.read().values.get(name, avm.is_case_sensitive()) {
|
||||
return value.get(avm, context, this, Some((*self).into()));
|
||||
return value
|
||||
.get(avm, context, this, Some((*self).into()))?
|
||||
.resolve(avm, context);
|
||||
}
|
||||
|
||||
Ok(Value::Undefined.into())
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
/// Set a named property on the object.
|
||||
|
|
|
@ -135,7 +135,7 @@ impl<'gc> TObject<'gc> for SoundObject<'gc> {
|
|||
avm: &mut Avm1<'gc>,
|
||||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
this: Object<'gc>,
|
||||
) -> Result<ReturnValue<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
self.base().get_local(name, avm, context, this)
|
||||
}
|
||||
|
||||
|
|
|
@ -69,8 +69,7 @@ impl<'gc> TObject<'gc> for StageObject<'gc> {
|
|||
// Property search order for DisplayObjects:
|
||||
if self.has_own_property(avm, context, name) {
|
||||
// 1) Actual properties on the underlying object
|
||||
self.get_local(name, avm, context, (*self).into())?
|
||||
.resolve(avm, context)
|
||||
self.get_local(name, avm, context, (*self).into())
|
||||
} else if let Some(property) = props.read().get_by_name(&name) {
|
||||
// 2) Display object properties such as _x, _y
|
||||
let val = property.get(avm, context, self.display_object)?;
|
||||
|
@ -99,7 +98,7 @@ impl<'gc> TObject<'gc> for StageObject<'gc> {
|
|||
avm: &mut Avm1<'gc>,
|
||||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
this: Object<'gc>,
|
||||
) -> Result<ReturnValue<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
self.base.get_local(name, avm, context, this)
|
||||
}
|
||||
|
||||
|
|
|
@ -84,8 +84,8 @@ impl<'gc> TObject<'gc> for SuperObject<'gc> {
|
|||
_avm: &mut Avm1<'gc>,
|
||||
_context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
_this: Object<'gc>,
|
||||
) -> Result<ReturnValue<'gc>, Error> {
|
||||
Ok(Value::Undefined.into())
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
fn set(
|
||||
|
|
|
@ -124,7 +124,7 @@ impl<'gc> TObject<'gc> for ValueObject<'gc> {
|
|||
avm: &mut Avm1<'gc>,
|
||||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
this: Object<'gc>,
|
||||
) -> Result<ReturnValue<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
self.0.read().base.get_local(name, avm, context, this)
|
||||
}
|
||||
|
||||
|
|
|
@ -61,13 +61,12 @@ impl<'gc> TObject<'gc> for XMLAttributesObject<'gc> {
|
|||
_avm: &mut Avm1<'gc>,
|
||||
_context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
_this: Object<'gc>,
|
||||
) -> Result<ReturnValue<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
Ok(self
|
||||
.node()
|
||||
.attribute_value(&XMLName::from_str(name))
|
||||
.map(|s| s.into())
|
||||
.unwrap_or_else(|| Value::Undefined)
|
||||
.into())
|
||||
.unwrap_or_else(|| Value::Undefined))
|
||||
}
|
||||
|
||||
fn set(
|
||||
|
|
|
@ -61,7 +61,7 @@ impl<'gc> TObject<'gc> for XMLIDMapObject<'gc> {
|
|||
avm: &mut Avm1<'gc>,
|
||||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
this: Object<'gc>,
|
||||
) -> Result<ReturnValue<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
if let Some(mut node) = self.document().get_node_by_id(name) {
|
||||
Ok(node
|
||||
.script_object(context.gc_context, Some(avm.prototypes().xml_node))
|
||||
|
|
|
@ -62,7 +62,7 @@ impl<'gc> TObject<'gc> for XMLObject<'gc> {
|
|||
avm: &mut Avm1<'gc>,
|
||||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
this: Object<'gc>,
|
||||
) -> Result<ReturnValue<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
self.base().get_local(name, avm, context, this)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue