avm2: Make 'set_local_property_is_enumerable` infallible
We always returned `Ok(())`
This commit is contained in:
parent
f8289b47d8
commit
1296121dc5
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -227,7 +227,7 @@ pub fn specialized_class_init<'gc>(
|
|||
activation.context.gc_context,
|
||||
(*pubname).into(),
|
||||
false,
|
||||
)?;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -142,7 +142,6 @@ impl<'gc> TObject<'gc> for DictionaryObject<'gc> {
|
|||
_mc: MutationContext<'gc, '_>,
|
||||
_name: AvmString<'gc>,
|
||||
_is_enumerable: bool,
|
||||
) -> Result<(), Error> {
|
||||
Ok(())
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue