avm2: Make 'set_local_property_is_enumerable` infallible

We always returned `Ok(())`
This commit is contained in:
Aaron Hill 2022-08-27 20:11:49 -05:00
parent f8289b47d8
commit 1296121dc5
13 changed files with 37 additions and 52 deletions

View File

@ -82,8 +82,8 @@ fn class_init<'gc>(
.into(),
activation,
)?;
boolean_proto.set_local_property_is_enumerable(gc_context, "toString".into(), false)?;
boolean_proto.set_local_property_is_enumerable(gc_context, "valueOf".into(), false)?;
boolean_proto.set_local_property_is_enumerable(gc_context, "toString".into(), false);
boolean_proto.set_local_property_is_enumerable(gc_context, "valueOf".into(), false);
}
Ok(Value::Undefined)

View File

@ -316,7 +316,7 @@ pub fn class_init<'gc>(
.into(),
activation,
)?;
date_proto.set_local_property_is_enumerable(gc_context, (*name).into(), false)?;
date_proto.set_local_property_is_enumerable(gc_context, (*name).into(), false);
}
}
Ok(Value::Undefined)

View File

@ -64,12 +64,12 @@ pub fn class_init<'gc>(
activation.context.gc_context,
"call".into(),
false,
)?;
);
function_proto.set_local_property_is_enumerable(
activation.context.gc_context,
"apply".into(),
false,
)?;
);
}
Ok(Value::Undefined)
}

View File

@ -120,11 +120,11 @@ fn class_init<'gc>(
activation,
)?;
int_proto.set_local_property_is_enumerable(gc_context, "toExponential".into(), false)?;
int_proto.set_local_property_is_enumerable(gc_context, "toFixed".into(), false)?;
int_proto.set_local_property_is_enumerable(gc_context, "toPrecision".into(), false)?;
int_proto.set_local_property_is_enumerable(gc_context, "toString".into(), false)?;
int_proto.set_local_property_is_enumerable(gc_context, "valueOf".into(), false)?;
int_proto.set_local_property_is_enumerable(gc_context, "toExponential".into(), false);
int_proto.set_local_property_is_enumerable(gc_context, "toFixed".into(), false);
int_proto.set_local_property_is_enumerable(gc_context, "toPrecision".into(), false);
int_proto.set_local_property_is_enumerable(gc_context, "toString".into(), false);
int_proto.set_local_property_is_enumerable(gc_context, "valueOf".into(), false);
}
Ok(Value::Undefined)

View File

@ -118,11 +118,11 @@ fn class_init<'gc>(
.into(),
activation,
)?;
number_proto.set_local_property_is_enumerable(gc_context, "toExponential".into(), false)?;
number_proto.set_local_property_is_enumerable(gc_context, "toFixed".into(), false)?;
number_proto.set_local_property_is_enumerable(gc_context, "toPrecision".into(), false)?;
number_proto.set_local_property_is_enumerable(gc_context, "toString".into(), false)?;
number_proto.set_local_property_is_enumerable(gc_context, "valueOf".into(), false)?;
number_proto.set_local_property_is_enumerable(gc_context, "toExponential".into(), false);
number_proto.set_local_property_is_enumerable(gc_context, "toFixed".into(), false);
number_proto.set_local_property_is_enumerable(gc_context, "toPrecision".into(), false);
number_proto.set_local_property_is_enumerable(gc_context, "toString".into(), false);
number_proto.set_local_property_is_enumerable(gc_context, "valueOf".into(), false);
}
Ok(Value::Undefined)

View File

@ -139,29 +139,21 @@ pub fn class_init<'gc>(
activation,
)?;
object_proto.set_local_property_is_enumerable(
gc_context,
"hasOwnProperty".into(),
false,
)?;
object_proto.set_local_property_is_enumerable(gc_context, "hasOwnProperty".into(), false);
object_proto.set_local_property_is_enumerable(
gc_context,
"propertyIsEnumerable".into(),
false,
)?;
);
object_proto.set_local_property_is_enumerable(
gc_context,
"setPropertyIsEnumerable".into(),
false,
)?;
object_proto.set_local_property_is_enumerable(gc_context, "isPrototypeOf".into(), false)?;
object_proto.set_local_property_is_enumerable(gc_context, "toString".into(), false)?;
object_proto.set_local_property_is_enumerable(
gc_context,
"toLocaleString".into(),
false,
)?;
object_proto.set_local_property_is_enumerable(gc_context, "valueOf".into(), false)?;
);
object_proto.set_local_property_is_enumerable(gc_context, "isPrototypeOf".into(), false);
object_proto.set_local_property_is_enumerable(gc_context, "toString".into(), false);
object_proto.set_local_property_is_enumerable(gc_context, "toLocaleString".into(), false);
object_proto.set_local_property_is_enumerable(gc_context, "valueOf".into(), false);
}
Ok(Value::Undefined)
@ -260,7 +252,7 @@ pub fn set_property_is_enumerable<'gc>(
let name = name?.coerce_to_string(activation)?;
if let Some(Value::Bool(is_enum)) = args.get(1) {
this.set_local_property_is_enumerable(activation.context.gc_context, name, *is_enum)?;
this.set_local_property_is_enumerable(activation.context.gc_context, name, *is_enum);
}
Ok(Value::Undefined)

View File

@ -99,12 +99,12 @@ pub fn class_init<'gc>(
activation.context.gc_context,
"toString".into(),
false,
)?;
);
qname_proto.set_local_property_is_enumerable(
activation.context.gc_context,
"valueOf".into(),
false,
)?;
);
Ok(Value::Undefined)
}

View File

@ -119,11 +119,11 @@ fn class_init<'gc>(
.into(),
activation,
)?;
uint_proto.set_local_property_is_enumerable(gc_context, "toExponential".into(), false)?;
uint_proto.set_local_property_is_enumerable(gc_context, "toFixed".into(), false)?;
uint_proto.set_local_property_is_enumerable(gc_context, "toPrecision".into(), false)?;
uint_proto.set_local_property_is_enumerable(gc_context, "toString".into(), false)?;
uint_proto.set_local_property_is_enumerable(gc_context, "valueOf".into(), false)?;
uint_proto.set_local_property_is_enumerable(gc_context, "toExponential".into(), false);
uint_proto.set_local_property_is_enumerable(gc_context, "toFixed".into(), false);
uint_proto.set_local_property_is_enumerable(gc_context, "toPrecision".into(), false);
uint_proto.set_local_property_is_enumerable(gc_context, "toString".into(), false);
uint_proto.set_local_property_is_enumerable(gc_context, "valueOf".into(), false);
}
Ok(Value::Undefined)

View File

@ -227,7 +227,7 @@ pub fn specialized_class_init<'gc>(
activation.context.gc_context,
(*pubname).into(),
false,
)?;
);
}
}

View File

@ -588,7 +588,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
mc: MutationContext<'gc, '_>,
name: AvmString<'gc>,
is_enumerable: bool,
) -> Result<(), Error> {
) {
let mut base = self.base_mut(mc);
base.set_local_property_is_enumerable(name, is_enumerable)

View File

@ -293,7 +293,7 @@ impl<'gc> ClassObject<'gc> {
activation.context.gc_context,
"constructor".into(),
false,
)?;
);
Ok(())
}
@ -848,11 +848,11 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
mc: MutationContext<'gc, '_>,
name: AvmString<'gc>,
is_enumerable: bool,
) -> Result<(), Error> {
) {
self.0
.write(mc)
.base
.set_local_property_is_enumerable(name, is_enumerable)
.set_local_property_is_enumerable(name, is_enumerable);
}
fn apply(

View File

@ -142,7 +142,6 @@ impl<'gc> TObject<'gc> for DictionaryObject<'gc> {
_mc: MutationContext<'gc, '_>,
_name: AvmString<'gc>,
_is_enumerable: bool,
) -> Result<(), Error> {
Ok(())
) {
}
}

View File

@ -397,11 +397,7 @@ impl<'gc> ScriptObjectData<'gc> {
self.enumerants.contains(&name)
}
pub fn set_local_property_is_enumerable(
&mut self,
name: AvmString<'gc>,
is_enumerable: bool,
) -> Result<(), Error> {
pub fn set_local_property_is_enumerable(&mut self, name: AvmString<'gc>, is_enumerable: bool) {
if is_enumerable && self.values.contains_key(&name) && !self.enumerants.contains(&name) {
self.enumerants.push(name);
} else if !is_enumerable && self.enumerants.contains(&name) {
@ -416,8 +412,6 @@ impl<'gc> ScriptObjectData<'gc> {
self.enumerants.remove(index);
}
}
Ok(())
}
/// Gets the number of (standard) enumerants.