core: Remove some manual `Collect` impls
Some were completely unused, while others could be replaced with a `#[derive(Collect)]`
This commit is contained in:
parent
7a09dd5639
commit
6dc628e49f
|
@ -171,15 +171,6 @@ impl<'a> ActivationIdentifier<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<'gc> gc_arena::Collect for ActivationIdentifier<'gc> {
|
|
||||||
fn needs_trace() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn trace(&self, _cc: gc_arena::CollectionContext) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Activation<'a, 'gc: 'a, 'gc_context: 'a> {
|
pub struct Activation<'a, 'gc: 'a, 'gc_context: 'a> {
|
||||||
/// Represents the SWF version of a given function.
|
/// Represents the SWF version of a given function.
|
||||||
///
|
///
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::avm1::{ArrayObject, Object, ObjectPtr, ScriptObject, TObject};
|
||||||
use crate::display_object::{DisplayObject, TDisplayObject};
|
use crate::display_object::{DisplayObject, TDisplayObject};
|
||||||
use crate::string::AvmString;
|
use crate::string::AvmString;
|
||||||
use crate::tag_utils::SwfSlice;
|
use crate::tag_utils::SwfSlice;
|
||||||
use gc_arena::{Collect, CollectionContext, Gc, GcCell, MutationContext};
|
use gc_arena::{Collect, Gc, GcCell, MutationContext};
|
||||||
use std::{borrow::Cow, fmt, num::NonZeroU8};
|
use std::{borrow::Cow, fmt, num::NonZeroU8};
|
||||||
use swf::{avm1::types::FunctionFlags, SwfStr};
|
use swf::{avm1::types::FunctionFlags, SwfStr};
|
||||||
|
|
||||||
|
@ -290,25 +290,17 @@ struct Param<'gc> {
|
||||||
|
|
||||||
/// Represents a function that can be defined in the Ruffle runtime or by the
|
/// Represents a function that can be defined in the Ruffle runtime or by the
|
||||||
/// AVM1 bytecode itself.
|
/// AVM1 bytecode itself.
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Collect)]
|
||||||
|
#[collect(no_drop)]
|
||||||
pub enum Executable<'gc> {
|
pub enum Executable<'gc> {
|
||||||
/// A function provided by the Ruffle runtime and implemented in Rust.
|
/// A function provided by the Ruffle runtime and implemented in Rust.
|
||||||
Native(NativeFunction),
|
Native(#[collect(require_static)] NativeFunction),
|
||||||
|
|
||||||
/// ActionScript data defined by a previous `DefineFunction` or
|
/// ActionScript data defined by a previous `DefineFunction` or
|
||||||
/// `DefineFunction2` action.
|
/// `DefineFunction2` action.
|
||||||
Action(Gc<'gc, Avm1Function<'gc>>),
|
Action(Gc<'gc, Avm1Function<'gc>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<'gc> Collect for Executable<'gc> {
|
|
||||||
fn trace(&self, cc: CollectionContext) {
|
|
||||||
match self {
|
|
||||||
Self::Native(_) => {}
|
|
||||||
Self::Action(af) => af.trace(cc),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for Executable<'_> {
|
impl fmt::Debug for Executable<'_> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
|
|
@ -345,18 +345,22 @@ impl<'gc> TObject<'gc> for StageObject<'gc> {
|
||||||
/// "special" properties stored in a separate map that display objects look at in addition
|
/// "special" properties stored in a separate map that display objects look at in addition
|
||||||
/// to normal property lookup.
|
/// to normal property lookup.
|
||||||
/// The map of property names to display object getts/setters.
|
/// The map of property names to display object getts/setters.
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, Collect)]
|
||||||
pub struct DisplayProperty<'gc> {
|
#[collect(require_static)]
|
||||||
get: DisplayGetter<'gc>,
|
pub struct DisplayProperty {
|
||||||
set: Option<DisplaySetter<'gc>>,
|
get: DisplayGetter,
|
||||||
|
set: Option<DisplaySetter>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type DisplayGetter<'gc> = fn(&mut Activation<'_, 'gc, '_>, DisplayObject<'gc>) -> Value<'gc>;
|
pub type DisplayGetter =
|
||||||
|
for<'gc> fn(&mut Activation<'_, 'gc, '_>, DisplayObject<'gc>) -> Value<'gc>;
|
||||||
|
pub type DisplaySetter = for<'gc> fn(
|
||||||
|
&mut Activation<'_, 'gc, '_>,
|
||||||
|
DisplayObject<'gc>,
|
||||||
|
Value<'gc>,
|
||||||
|
) -> Result<(), Error<'gc>>;
|
||||||
|
|
||||||
pub type DisplaySetter<'gc> =
|
impl<'gc> DisplayProperty {
|
||||||
fn(&mut Activation<'_, 'gc, '_>, DisplayObject<'gc>, Value<'gc>) -> Result<(), Error<'gc>>;
|
|
||||||
|
|
||||||
impl<'gc> DisplayProperty<'gc> {
|
|
||||||
pub fn get(
|
pub fn get(
|
||||||
&self,
|
&self,
|
||||||
activation: &mut Activation<'_, 'gc, '_>,
|
activation: &mut Activation<'_, 'gc, '_>,
|
||||||
|
@ -378,16 +382,10 @@ impl<'gc> DisplayProperty<'gc> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<'gc> Collect for DisplayProperty<'gc> {
|
|
||||||
fn needs_trace() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The map from key/index to function pointers for special display object properties.
|
/// The map from key/index to function pointers for special display object properties.
|
||||||
#[derive(Collect)]
|
#[derive(Collect)]
|
||||||
#[collect(no_drop)]
|
#[collect(no_drop)]
|
||||||
pub struct DisplayPropertyMap<'gc>(PropertyMap<'gc, DisplayProperty<'gc>>);
|
pub struct DisplayPropertyMap<'gc>(PropertyMap<'gc, DisplayProperty>);
|
||||||
|
|
||||||
impl<'gc> DisplayPropertyMap<'gc> {
|
impl<'gc> DisplayPropertyMap<'gc> {
|
||||||
/// Creates the display property map.
|
/// Creates the display property map.
|
||||||
|
@ -428,7 +426,7 @@ impl<'gc> DisplayPropertyMap<'gc> {
|
||||||
|
|
||||||
/// Gets a property slot by name.
|
/// Gets a property slot by name.
|
||||||
/// Used by `GetMember`, `GetVariable`, `SetMember`, and `SetVariable`.
|
/// Used by `GetMember`, `GetVariable`, `SetMember`, and `SetVariable`.
|
||||||
pub fn get_by_name(&self, name: AvmString<'gc>) -> Option<&DisplayProperty<'gc>> {
|
pub fn get_by_name(&self, name: AvmString<'gc>) -> Option<&DisplayProperty> {
|
||||||
// Display object properties are case insensitive, regardless of SWF version!?
|
// Display object properties are case insensitive, regardless of SWF version!?
|
||||||
// TODO: Another string alloc; optimize this eventually.
|
// TODO: Another string alloc; optimize this eventually.
|
||||||
self.0.get(name, false)
|
self.0.get(name, false)
|
||||||
|
@ -438,15 +436,15 @@ impl<'gc> DisplayPropertyMap<'gc> {
|
||||||
/// The order is defined by the SWF specs.
|
/// The order is defined by the SWF specs.
|
||||||
/// Used by `GetProperty`/`SetProperty`.
|
/// Used by `GetProperty`/`SetProperty`.
|
||||||
/// SWF19 pp. 85-86
|
/// SWF19 pp. 85-86
|
||||||
pub fn get_by_index(&self, index: usize) -> Option<&DisplayProperty<'gc>> {
|
pub fn get_by_index(&self, index: usize) -> Option<&DisplayProperty> {
|
||||||
self.0.get_index(index)
|
self.0.get_index(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_property(
|
fn add_property(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: AvmString<'gc>,
|
name: AvmString<'gc>,
|
||||||
get: DisplayGetter<'gc>,
|
get: DisplayGetter,
|
||||||
set: Option<DisplaySetter<'gc>>,
|
set: Option<DisplaySetter>,
|
||||||
) {
|
) {
|
||||||
let prop = DisplayProperty { get, set };
|
let prop = DisplayProperty { get, set };
|
||||||
self.0.insert(name, prop, false);
|
self.0.insert(name, prop, false);
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::avm2::value::{abc_default_value, Value};
|
||||||
use crate::avm2::Error;
|
use crate::avm2::Error;
|
||||||
use crate::avm2::Multiname;
|
use crate::avm2::Multiname;
|
||||||
use crate::string::AvmString;
|
use crate::string::AvmString;
|
||||||
use gc_arena::{Collect, CollectionContext, Gc, MutationContext};
|
use gc_arena::{Collect, Gc, MutationContext};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -256,9 +256,11 @@ impl<'gc> BytecodeMethod<'gc> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An uninstantiated method
|
/// An uninstantiated method
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Collect)]
|
||||||
|
#[collect(no_drop)]
|
||||||
pub struct NativeMethod<'gc> {
|
pub struct NativeMethod<'gc> {
|
||||||
/// The function to call to execute the method.
|
/// The function to call to execute the method.
|
||||||
|
#[collect(require_static)]
|
||||||
pub method: NativeMethodImpl,
|
pub method: NativeMethodImpl,
|
||||||
|
|
||||||
/// The name of the method.
|
/// The name of the method.
|
||||||
|
@ -272,12 +274,6 @@ pub struct NativeMethod<'gc> {
|
||||||
pub is_variadic: bool,
|
pub is_variadic: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<'gc> Collect for NativeMethod<'gc> {
|
|
||||||
fn trace(&self, cc: CollectionContext) {
|
|
||||||
self.signature.trace(cc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'gc> fmt::Debug for NativeMethod<'gc> {
|
impl<'gc> fmt::Debug for NativeMethod<'gc> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("NativeMethod")
|
f.debug_struct("NativeMethod")
|
||||||
|
|
Loading…
Reference in New Issue