Skip to content

Commit

Permalink
avm2: Use slot access in native FileReference code
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-McSweeney authored and Lord-McSweeney committed Dec 10, 2024
1 parent 57da4a7 commit cd21130
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion core/src/avm2/globals/flash/net/FileFilter.as
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package flash.net {
public final class FileFilter {
[Ruffle(InternalSlot)]
private var _description:String;

[Ruffle(InternalSlot)]
private var _extension:String;

[Ruffle(InternalSlot)]
private var _macType:String;

public function FileFilter(description:String, extension:String, macType:String = null) {
Expand Down Expand Up @@ -35,4 +40,4 @@ package flash.net {
}

}
}
}
10 changes: 6 additions & 4 deletions core/src/avm2/globals/flash/net/file_reference.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use crate::avm2::bytearray::ByteArrayStorage;
use crate::avm2::error::{argument_error, error, make_error_2037, make_error_2097};
pub use crate::avm2::object::file_reference_allocator;
use crate::avm2::globals::slots::flash_net_file_filter as file_filter_slots;
use crate::avm2::object::{ByteArrayObject, DateObject, FileReference};
use crate::avm2::{Activation, Avm2, Error, EventObject, Object, TObject, Value};
use crate::backend::ui::FileFilter;
use crate::string::AvmString;

pub use crate::avm2::object::file_reference_allocator;

pub fn get_creation_date<'gc>(
activation: &mut Activation<'_, 'gc>,
this: Object<'gc>,
Expand Down Expand Up @@ -140,9 +142,9 @@ pub fn browse<'gc>(
return Err(make_error_2097(activation));
}

let description = obj.get_public_property("description", activation)?;
let extension = obj.get_public_property("extension", activation)?;
let mac_type = obj.get_public_property("macType", activation)?;
let description = obj.get_slot(file_filter_slots::_DESCRIPTION);
let extension = obj.get_slot(file_filter_slots::_EXTENSION);
let mac_type = obj.get_slot(file_filter_slots::_MAC_TYPE);

// The description and extension must be non-empty strings.
match (description, extension) {
Expand Down

0 comments on commit cd21130

Please sign in to comment.