Skip to content

Commit

Permalink
Merge branch 'master' into wsxarcher/loadttfdefaults
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxarcher authored Sep 5, 2024
2 parents 71f6c74 + d80246f commit b9e7106
Show file tree
Hide file tree
Showing 73 changed files with 383 additions and 126 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/release_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update PKGBUILD
working-directory: desktop/packages/linux/aur/ruffle-nightly-bin
run: >
sed -i ./PKGBUILD
-e "s/@VERSION@/${{ steps.current_time_dots.outputs.formattedTime }}/"
Expand All @@ -587,7 +588,7 @@ jobs:
uses: KSXGitHub/[email protected]
with:
pkgname: ruffle-nightly-bin
pkgbuild: ./PKGBUILD
pkgbuild: desktop/packages/linux/aur/ruffle-nightly-bin/PKGBUILD
commit_username: RuffleBuild
commit_email: [email protected]
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
Expand Down
54 changes: 32 additions & 22 deletions .github/workflows/test_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FEATURES: lzma,jpegxr
TEST_OPTS: --workspace --locked --no-fail-fast -j 4

# This is to counteract the disabling by rust-cache.
# See: https://github.com/Swatinem/rust-cache/issues/43
CARGO_INCREMENTAL: '1'

# Supposedly makes "Updating crates.io index" faster on Windows.
# See: https://github.com/rust-lang/cargo/issues/9167
CARGO_NET_GIT_FETCH_WITH_CLI: 'true'

# Workaround for: https://github.com/nextest-rs/nextest/issues/1493
# See also: https://github.com/rust-lang/rustup/issues/3825
RUSTUP_WINDOWS_PATH_ADD_BIN: '1'

# (Linux) Just to silence warnings about it missing
XDG_RUNTIME_DIR: ''

jobs:
changes:
name: Paths filter
Expand Down Expand Up @@ -64,10 +83,14 @@ jobs:
# See also: https://github.com/dtolnay/linkme/issues/94
# Additionally: https://lld.llvm.org/ELF/start-stop-gc
- name: Disable linker start-stop-gc
# Note: We also use `rust-lld` on Windows, see `config.toml`.
if: runner.os != 'macOS'
if: runner.os == 'Linux'
run: echo RUSTFLAGS=${RUSTFLAGS}\ --cfg=web_sys_unstable_apis\ -Clink-args=-znostart-stop-gc >> $GITHUB_ENV

- name: Enable image tests
if: runner.os != 'macOS'
shell: bash
run: echo FEATURES=${FEATURES},imgtests | tee -a $GITHUB_ENV

- name: Cache Cargo output
uses: Swatinem/rust-cache@v2
with:
Expand All @@ -79,26 +102,13 @@ jobs:
with:
tool: cargo-nextest

- name: Run tests with image tests
if: runner.os != 'macOS'
run: cargo nextest run --profile ci --cargo-profile ci --workspace --locked --no-fail-fast -j 4 --features imgtests,lzma,jpegxr
env:
# This is to counteract the disabling by rust-cache.
# See: https://github.com/Swatinem/rust-cache/issues/43
CARGO_INCREMENTAL: '1'
# Supposedly makes "Updating crates.io index" faster on Windows.
# See: https://github.com/rust-lang/cargo/issues/9167
CARGO_NET_GIT_FETCH_WITH_CLI: 'true'
# Workaround for: https://github.com/nextest-rs/nextest/issues/1493
# See also: https://github.com/rust-lang/rustup/issues/3825
RUSTUP_WINDOWS_PATH_ADD_BIN: '1'
XDG_RUNTIME_DIR: '' # dummy value, just to silence warnings about it missing

- name: Run tests without image tests
if: runner.os == 'macOS'
run: cargo nextest run --profile ci --cargo-profile ci --workspace --locked --no-fail-fast -j 4 --features lzma,jpegxr
env:
XDG_RUNTIME_DIR: '' # dummy value, just to silence warnings about it missing
- name: Run tests
shell: bash
run: cargo nextest run --profile ci --cargo-profile ci ${TEST_OPTS} --features ${FEATURES}

- name: Run doctests
shell: bash
run: cargo test --doc --profile ci ${TEST_OPTS} --features ${FEATURES}

- name: Upload images
if: failure()
Expand Down
28 changes: 17 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/build_playerglobal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ fn strip_metadata(abc: &mut AbcFile) {
/// If we don't properly declare 'namespace AS3' in the input to asc.jar, then
/// a call like `self.AS3::toXMLString()` will end up getting compiled to weird bytecode like this:
///
/// ```
/// ```pcode
/// getlex Multiname("AS3",[PackageNamespace(""),PrivateNamespace(null,"35"),PackageInternalNs(""),PrivateNamespace(null,"33"),ProtectedNamespace("XML"),StaticProtectedNs("XML")])
/// coerce QName(PackageNamespace(""),"Namespace")
/// getproperty RTQName("toXMLString")
Expand Down
3 changes: 2 additions & 1 deletion core/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use syn::{
TraitItem, Visibility,
};

/// `enum_trait_object` will define an enum whose variants each implement a trait.
/// Define an enum whose variants each implement a trait.
///
/// It can be used as faux-dynamic dispatch. This is used as an alternative to a
/// trait object, which doesn't get along with GC'd types.
///
Expand Down
1 change: 0 additions & 1 deletion core/src/avm2/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,6 @@ impl<'gc> Class<'gc> {
read.vtable.init_vtable(
self,
None,
&read.traits,
None,
read.super_class.map(|c| c.vtable()),
context.gc_context,
Expand Down
4 changes: 4 additions & 0 deletions core/src/avm2/e4x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ impl<'gc> E4XNode<'gc> {
return false;
}

if self.namespace().map(|ns| ns.uri) != other.namespace().map(|ns| ns.uri) {
return false;
}

let this = self.0.read();
let other = other.0.read();

Expand Down
1 change: 0 additions & 1 deletion core/src/avm2/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,6 @@ pub fn load_player_globals<'gc>(
global_obj_vtable.init_vtable(
global_classdef,
Some(object_class),
&global_classdef.traits(),
Some(scope),
Some(object_class.instance_vtable()),
mc,
Expand Down
34 changes: 17 additions & 17 deletions core/src/avm2/globals/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,16 @@ pub fn concat<'gc>(
return Err("Not a vector-structured object".into());
};

let original_length = new_vector_storage.length();

let use_swf10_behavior = activation
.caller_movie()
.map_or(false, |m| m.version() < 11);

let val_class = new_vector_storage.value_type_for_coercion(activation);

for arg in args {
let arg_obj = arg
.as_object()
.ok_or("Cannot concat Vector with null or undefined")?;
let arg_obj = arg.coerce_to_object_or_typeerror(activation, None)?;

// this is Vector.<int/uint/Number/*>
let my_base_vector_class = activation
Expand Down Expand Up @@ -284,21 +288,17 @@ pub fn concat<'gc>(
continue;
};

for val in old_vec {
if let Ok(val_obj) = val.coerce_to_object(activation) {
if !val.is_of_type(activation, val_class) {
let other_val_class = val_obj.instance_class();
return Err(format!(
"TypeError: Cannot coerce Vector value of type {:?} to type {:?}",
other_val_class.name(),
val_class.name()
)
.into());
}
}

for (i, val) in old_vec.iter().enumerate() {
let insertion_index = (original_length + i) as i32;
let coerced_val = val.coerce_to_type(activation, val_class)?;
new_vector_storage.push(coerced_val, activation)?;

if use_swf10_behavior {
// See bugzilla 504525: In SWFv10, calling `concat` with multiple
// arguments passed results in concatenating in the wrong order.
new_vector_storage.insert(insertion_index, coerced_val, activation)?;
} else {
new_vector_storage.push(coerced_val, activation)?;
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions core/src/avm2/object/class_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ impl<'gc> ClassObject<'gc> {
self.instance_vtable().init_vtable(
class,
self.superclass_object(),
&class.traits(),
Some(self.instance_scope()),
self.superclass_object().map(|cls| cls.instance_vtable()),
activation.context.gc_context,
Expand Down Expand Up @@ -254,7 +253,6 @@ impl<'gc> ClassObject<'gc> {
class_vtable.init_vtable(
c_class,
Some(class_classobject),
&c_class.traits(),
Some(self.class_scope()),
Some(class_classobject.instance_vtable()),
activation.context.gc_context,
Expand Down
2 changes: 1 addition & 1 deletion core/src/avm2/optimize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl<'gc> Stack<'gc> {

/// Checks if the method fits the following pattern:
///
/// ```
/// ```text
/// [Debug/DebugFile/DebugLine] zero or more times
/// GetLocal { index: 0 }
/// [Debug/DebugFile/DebugLine] zero or more times
Expand Down
1 change: 0 additions & 1 deletion core/src/avm2/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ impl<'gc> Script<'gc> {
global_obj_vtable.init_vtable(
global_class,
Some(object_class),
&global_class.traits(),
Some(scope),
Some(object_class.instance_vtable()),
mc,
Expand Down
3 changes: 1 addition & 2 deletions core/src/avm2/vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ impl<'gc> VTable<'gc> {
self,
defining_class_def: Class<'gc>,
super_class_obj: Option<ClassObject<'gc>>,
traits: &[Trait<'gc>],
scope: Option<ScopeChain<'gc>>,
superclass_vtable: Option<Self>,
mc: &Mutation<'gc>,
Expand Down Expand Up @@ -316,7 +315,7 @@ impl<'gc> VTable<'gc> {
&mut write.slot_classes,
);

for trait_data in traits {
for trait_data in &*defining_class_def.traits() {
match trait_data.kind() {
TraitKind::Method { method, .. } => {
let entry = ClassBoundMethod {
Expand Down
7 changes: 7 additions & 0 deletions core/src/backend/audio/decoders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ impl<T: Decoder + ?Sized> Decoder for Box<T> {
}
}

/// Audio stream decoder.
///
/// A "stream" sound is a sound that has its data distributed across `SoundStreamBlock` tags,
/// one per each frame of a MovieClip. The sound is synced to the MovieClip's timeline, and will
/// stop/seek as the MovieClip stops/seeks.
Expand Down Expand Up @@ -144,6 +146,8 @@ impl Iterator for StandardStreamDecoder {
}
}

/// ADPCM stream decoder.
///
/// Stream sounds encoded with ADPCM have an ADPCM header in each `SoundStreamBlock` tag, unlike
/// other compression formats that remain the same as if they were a single sound clip.
/// Therefore, we must recreate the decoder with each `SoundStreamBlock` to parse the additional
Expand Down Expand Up @@ -482,6 +486,7 @@ impl Read for SubstreamTagReader {
}

/// Create a new decoder that reads data from a shared `Substream` instance.
///
/// This works similarly to `make_stream_decoder` but using the new buffer
/// infrastructure that will eventually replace SWF-specific streaming.
///
Expand Down Expand Up @@ -537,6 +542,8 @@ impl Iterator for StandardSubstreamDecoder {
}
}

/// ADPCM substream decoder.
///
/// Stream sounds encoded with ADPCM have an ADPCM header in each `SoundStreamBlock` tag, unlike
/// other compression formats that remain the same as if they were a single sound clip.
/// Therefore, we must recreate the decoder with each `SoundStreamBlock` to parse the additional
Expand Down
10 changes: 6 additions & 4 deletions core/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,13 @@ impl From<MouseButton> for KeyCode {
}
}

/// Key codes for SWF4 keyPress button handlers. These are annoyingly different than
/// `Key.isDown` key codes.
/// Key codes for SWF4 keyPress button handlers.
///
/// These are annoyingly different than `Key.isDown` key codes.
///
/// TODO: After 18, these are mostly ASCII... should we just use u8? How are different
/// keyboard layouts/languages handled?
/// SWF19 pp. 198-199
/// keyboard layouts/languages handled?
/// SWF19 pp. 198-199
#[derive(Debug, PartialEq, Eq, Copy, Clone, FromPrimitive, ToPrimitive)]
pub enum ButtonKeyCode {
Unknown = 0,
Expand Down
Loading

0 comments on commit b9e7106

Please sign in to comment.