Commit Graph

3663 Commits

Author SHA1 Message Date
David Wendt d225d03043 avm2: Implement `flash.utils.Proxy` 2021-11-09 17:28:33 -07:00
David Wendt 51af0f708f core: Remove commented-out helper methods. 2021-11-09 16:48:29 -07:00
David Wendt c78e5e31fd core: Store `DisplayObjectBase` in `InteractiveObjectBase`.
This also necessitated removing the `impl_display_object` family of macros, as you cannot name a field of a field in a macro expression. I tried. So instead I've reverted to standard default method inheritance, in the same way we did with AVM2 objects.
2021-11-09 16:48:29 -07:00
David Wendt 2ea35dcbb1 avm2: Enforce the `mouseEnabled` flag. 2021-11-09 16:48:29 -07:00
David Wendt b2e0586252 docs: Document the current event-handling flow in `Player`. 2021-11-09 16:48:29 -07:00
David Wendt bb8ca8f136 core: Move `handle_clip_event` to `TInteractiveObject`, and split it into three pieces.
`handle_clip_event` is now a default trait method that calls three methods in order:

 * `filter_clip_event`, to determine which events that either this object or it's children may handle
 * `propagate_to_children`, to check if any children of this object want to handle an event. (This also includes AVM2 button states, which are not technically "children" in the usual sense...)
 * `event_dispatch`, which does the actual "object reacts to an event" bit if no child handles the object.

These roughly correspond to phases of existing event-handling objects pre-`InteractiveObject`.
2021-11-09 16:48:29 -07:00
David Wendt 95f105aadd core: `Stage`, `EditText`, and `Avm2Button` should also be interactive objects. 2021-11-09 16:48:29 -07:00
David Wendt e71c749db5 avm2: Implement accessors for new `InteractiveObject` flags. 2021-11-09 16:48:29 -07:00
David Wendt 618c32f859 core: Add `InteractiveObject` trait for objects that can receive input events 2021-11-09 16:48:29 -07:00
relrelb 89718475df avm2: Introduce `TextFormatObject` 2021-11-09 16:21:35 -07:00
relrelb 9308513ae8 chore: Appease clippy 2021-11-06 10:44:01 +02:00
David Wendt 6c7d10e4d4 avm2: Requests for instance traits instead resolve to an associated public-namespace method 2021-11-02 16:54:38 -06:00
dependabot[bot] 0ef702d415 build(deps): bump syn from 1.0.80 to 1.0.81
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.80 to 1.0.81.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.80...1.0.81)

---
updated-dependencies:
- dependency-name: syn
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-02 07:02:06 +02:00
Mike Welsh c6e6de4a47 core: Unclosed fills in Drawing API should auto-close 2021-10-31 19:01:55 -07:00
Mike Welsh 8cf0f9b7b1 avm1: duplicateMovieClip copies drawings (fix #5487)
duplicateMovieClip also clones the drawing API state of the clip,
including in-progress drawing and style info.

Fixes #5487.
2021-10-31 19:01:55 -07:00
Mike Welsh 0e4b0f7c62 avm1: Allow duplicateMovieClip on dynamically created clips
Previously duplicating a clip created with `createEmptyMovieClip`
would fail.
2021-10-31 19:01:55 -07:00
David Wendt b0b1c79143 avm2: Split the `slot_id` and `disp_id` accessors. 2021-10-31 00:52:58 -07:00
David Wendt 0cc55df5ca avm2: Remove `FINAL` flag and associated machinery as we now validate traits at class construction time. 2021-10-31 00:52:58 -07:00
David Wendt a1be42abfb avm2: Exempt system classes from class validation. 2021-10-31 00:52:58 -07:00
David Wendt dd4717e08e avm2: Move `final`/`override` check enforcement to class construction time.
This is an O(n^2) algorithm, which sucks, but at least it only runs once per class rather than per *object allocation*.
2021-10-31 00:52:58 -07:00
David Wendt 8d40e41ee1 avm2: Make `Executable` zero-alloc 2021-10-31 00:52:58 -07:00
David Wendt cea3997396 avm2: Remove `superclass_object` and related parameters from `TObject.call` and other downstream functions.
Turns out there's a *lot* of downstream functions.
2021-10-31 00:52:58 -07:00
David Wendt 272b1784b8 avm2: Don't skip method binding in `callproperty` if the method requires `arguments`, as it may access `callee`. 2021-10-31 00:52:58 -07:00
David Wendt 1b5869e15a avm2: Preserve ability to `callmethod` on slot IDs that have not yet been bound, by binding them at that time. 2021-10-31 00:52:58 -07:00
David Wendt d0d19bcf38 avm2: Stop instantiating methods at object construction time. 2021-10-31 00:52:58 -07:00
David Wendt bfbd2271b0 avm2: Allow uninstantiated methods to be created on-the-fly. 2021-10-31 00:52:58 -07:00
David Wendt 3562c50dee avm2: `call_property` on classes should also call unbound methods 2021-10-31 00:52:58 -07:00
David Wendt 477add3dd0 avm2: Add `ClassObject` methods for pulling unbound methods or bound method objects from the class or instance. 2021-10-31 00:52:58 -07:00
David Wendt 9c031070b3 avm2: `ClassObject` should include class traits in `TObject` methods that reference the current object's traits. 2021-10-31 00:52:58 -07:00
David Wendt 74fb965301 avm2: Call methods directly if we can find a class with an instance trait matching it's name. 2021-10-31 00:52:58 -07:00
David Wendt 039777c41e avm2: `Object.hasOwnProperty`, `propertyIsEnumerable`, and `setPropertyIsEnumerable` only work with public-NS properties. 2021-10-30 11:44:29 -06:00
relrelb 9aed0e7db4 core: Reset `TextFormat.color` alpha
Since `TextFormat.color` should preserve the alpha value, and the AVM1
getter/setter no longer reset it, we need to reset it in other places:

* `TextField.textColor` setter.
* `EditText` SWF tag handling.
* HTML parsing.

And to set it explicitly to 255 in `LayoutBox::as_renderable_text`.
2021-10-30 10:03:36 -07:00
relrelb 34d1fa5226 avm1: Introduce `TextFormatObject`
`TextFormat` objects differ from regular objects in that
`TextField.setTextFormat` and `TextField.setNewTextFormat` accept
only the former, and ignore the latter.

Also, `TextFormat.prototype` has native accessors that coerce the
values on get/set.
2021-10-30 10:03:36 -07:00
Mike Welsh bc801b2b32 avm1: GotoFrame2 after bogus SetTarget affects _root
For example, `tellTarget("bogus!!!") { var n = 2; gotoAndPlay(n); }`
should cause the _root clip to go to frame 2.

Fixes the character freezing in Steppenwolf 3-1 mentioned in #4585.
2021-10-28 10:18:18 -07:00
Mike Welsh 2e3154baa0 avm1: tellTarget should fail if base clip is removed
`tellTarget` to other clips should fail if the current base clip
has been removed. All properties of the clip return `undefined`
at this point, so traversing the target path should fail.

Fixes soft-lock in Steppenwolf 2-1 as mentioned in #4452.
2021-10-28 10:18:18 -07:00
EmperorBale 5ac8e75239 avm2: Make ObjectEncoding C-like 2021-10-25 16:32:55 -07:00
EmperorBale bab74f83fc avm2: Remove all unsafe from bytearray 2021-10-25 16:32:55 -07:00
EmperorBale 9126c9297c avm2: Derive PartialEq and Eq for enums 2021-10-25 16:32:55 -07:00
EmperorBale 69f2002d2a avm2: Add todo comment 2021-10-25 16:32:55 -07:00
EmperorBale da601a4984 chore: Improve safety comments 2021-10-25 16:32:55 -07:00
EmperorBale 3b2a84ef9b chore: Small cleanups 2021-10-25 16:32:55 -07:00
EmperorBale b257e5537c chore: Appease clippy 2021-10-25 16:32:55 -07:00
EmperorBale 42fe351c0d avm2: Optimize readBytes & writeBytes by implementing write_at_within 2021-10-25 16:32:55 -07:00
EmperorBale e86bdfdc3e avm2: Remove unneeded condition 2021-10-25 16:32:55 -07:00
EmperorBale 3f3e600820 chore: Appease clippy 2021-10-25 16:32:55 -07:00
EmperorBale 83005a7ce5 avm2: Update flash-lso version 2021-10-25 16:32:55 -07:00
EmperorBale efb3062d98 avm2: Add flash.net.ObjectEncoding 2021-10-25 16:32:55 -07:00
EmperorBale e5fc2c8e66 avm1: Update SharedObject 2021-10-25 16:32:55 -07:00
EmperorBale e2c2ac8961 avm2: Implement ByteArray.readObject + flash.net.ObjectEncoding 2021-10-25 16:32:55 -07:00
EmperorBale c191340972 avm2: Refactor readBytes & writeBytes 2021-10-25 16:32:55 -07:00
EmperorBale 67ffc7bcc8 avm2: Forward get_enumerant_name and property_is_enumerable to base when not found 2021-10-25 13:45:29 -07:00
Mike Welsh 25c56b7000 chore: Appease clippy 2021-10-24 15:59:59 -07:00
Mike Welsh 8ae8de4d51 chore: Appease clippy
Squelch some false positives from `question_mark` and
`match_str_case_mismatch` lints.
2021-10-24 15:33:09 -07:00
relrelb 1fec012053 avm1: Inline `Value::call`
It was used only in `CallableValue`, and is not very useful by itself,
as it's a tiny wrapper around `TObject::call`.
2021-10-23 10:51:21 -07:00
relrelb e6181dfcce Revert "avm1: Don't warn in case a method doesn't exist"
This reverts commit 54d417c539,
because it no longer necessary as the warning was removed in the
previous commit.
2021-10-23 10:51:21 -07:00
relrelb 982a83ce24 avm1: Remove `base_proto` parameter of `TObject::call`
Use prototype depths instead. Most calls passed `base_proto = None`,
which is equivalent to `depth = 0`, and is now the default.
The few other cases were adapted to use `Executable::exec` directly,
where `depth` can be specified manually.
2021-10-23 10:51:21 -07:00
relrelb 09f72b880d avm1: Avoid unnecessary calls to `search_prototype`
The signature of `search_prototype` is going to change in a following
commit.
Use `TObject::call_method` instead.
2021-10-23 10:51:21 -07:00
relrelb d0763607e2 avm1: Remove `base_proto` parameter of `TObject::set_local`
The only usage of it was `ScriptObject::set_local`, where it can
be computed locally.
2021-10-23 10:51:21 -07:00
relrelb 0a66dac280 avm1: Remove `set` specialization from `impl_custom_object!`
`base_proto` is going to be eliminated in a following commit, so
there will no longer be a difference between the two `set_local`
variants.
2021-10-23 10:51:21 -07:00
Mike Welsh 3fc0209e03 chore: Appease clippy 2021-10-22 22:48:26 -07:00
David Wendt 5abb11482e avm2: Make builtin class prototypes also instances of `Object`, with the sole exception of `Function`, whose prototype is an instance of it's class. 2021-10-22 20:12:48 -07:00
David Wendt 469f8cb9db avm2: All prototypes are instances of `Object`, not their own class. 2021-10-22 20:12:48 -07:00
Adrian Wielgosik c1850d0d54 avm2: Stub flash.net.SharedObject
Just enough for the following to not crash:

```
var so = SharedObject.getLocal("name");
so.data.stuff = "xyz";
so.flush();
trace(so.data.stuff);
```
2021-10-22 10:02:35 -07:00
Mike Welsh 11ae981890 audio: Fix skipping initial frame of MP3 audio
The changes in #5498 caused the samples from the initial MP3 frame
to be skipped. This was noticable in:
https://www.newgrounds.com/portal/view/1

This change properly removes the redundant `num_samples` variable
and considers the samples from the initial MP3 frame.
2021-10-21 10:25:47 -07:00
Adrian Wielgosik 969fab7619 refactor: Stop manually borrowing fields in mutate_with_update_context 2021-10-21 10:24:05 -07:00
Adrian Wielgosik 8cc00f32bb chore: Stop using traits available in prelude 2021-10-21 10:24:05 -07:00
Adrian Wielgosik bc82a4f705 build: Bump Rust edition to 2021 2021-10-21 10:24:05 -07:00
EmperorBale 70cbd13201 avm2: Global scope should be null instead of undefined by default 2021-10-19 18:39:41 -06:00
EmperorBale 903246d5af chore: Appease clippy 2021-10-19 18:39:41 -06:00
EmperorBale ab3ff34944 avm2: Derive Collect for NativeExecutable 2021-10-19 18:39:41 -06:00
EmperorBale 2a84b0cbbb avm2: Instance traits and class traits should use seperate scopechains 2021-10-19 18:39:41 -06:00
EmperorBale 77bf5973a7 chore: Appease clippy 2021-10-19 18:39:41 -06:00
EmperorBale 1dd899a76f avm2: Allow small mutations to ScopeChain 2021-10-19 18:39:41 -06:00
EmperorBale 9de7d7ba7a chore: Add todo comment for callstatic 2021-10-19 18:39:41 -06:00
EmperorBale a19488c048 chore: Cleanup comments 2021-10-19 18:39:41 -06:00
EmperorBale d71188e80c avm2: Change code_context to caller_domain 2021-10-19 18:39:41 -06:00
EmperorBale 4667921259 avm2: Push global scope when property is not found 2021-10-19 18:39:41 -06:00
EmperorBale 7e251cfe05 avm2: Add support for pushwith 2021-10-19 18:39:41 -06:00
EmperorBale 388fdbd513 avm2: Scope redesign
avm2: Update scopechain design
2021-10-19 18:39:41 -06:00
dependabot[bot] 5cab790bd7 build(deps): bump encoding_rs from 0.8.28 to 0.8.29
Bumps [encoding_rs](https://github.com/hsivonen/encoding_rs) from 0.8.28 to 0.8.29.
- [Release notes](https://github.com/hsivonen/encoding_rs/releases)
- [Commits](https://github.com/hsivonen/encoding_rs/compare/v0.8.28...v0.8.29)

---
updated-dependencies:
- dependency-name: encoding_rs
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-18 14:01:23 -07:00
dependabot[bot] ca32fe9b90 build(deps): bump gif from 0.11.2 to 0.11.3
Bumps [gif](https://github.com/image-rs/image-gif) from 0.11.2 to 0.11.3.
- [Release notes](https://github.com/image-rs/image-gif/releases)
- [Changelog](https://github.com/image-rs/image-gif/blob/master/Changes.md)
- [Commits](https://github.com/image-rs/image-gif/compare/v0.11.2...v0.11.3)

---
updated-dependencies:
- dependency-name: gif
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-18 13:43:37 -07:00
Mike Welsh 7745c9137f audio: Grab MP3 sample rate directly from MP3 data
MP3 data in an SWF can be of a different sample rate than
indicated in the SWF tag, so grab the sample rate from the MP3
decoder instead of passing it in from the SWF tag.

Also, a general clean up of the MP3 decoders.

Fixes #335.
2021-10-17 20:34:15 -07:00
Mike Welsh 3dfa5ade18 audio: Ask decoder for sound sample rate
Don't rely on the sample rate in the SWF tags, as this could differ
from the actual sample rate of the audio (see #335).
2021-10-17 20:34:15 -07:00
Mike Welsh 60f5dc2477 avm2: Implement SoundChannel.position
Fix various issues with `SoundChannel`:
 * Change `avm2::Object::as_sound_instance` to `as_sound_channel`.
 * Cache sound position in `SoundChannelObject`.
 * `SoundInfo::in_sample` is in units of 44100Hz.
 * Clamp `num_loops` to 1.
2021-10-16 22:53:25 -07:00
Mike Welsh 6034b4a3af avm1: Sound.position and duration are not version-gated
Even though they were added in SWFv6, they will be available when
playing a v5 SWF in Flash Player 6 and higher.

See #340 for an example in the wild.
2021-10-16 22:53:25 -07:00
Mike Welsh 105c889f5f desktop: Implement AudioBackend::get_sound_position 2021-10-16 22:53:25 -07:00
Mike Welsh bca31b2c51 audio: Grab Sound.position from audio backend
* Change `AudioBackend::get_sound_position` to return `f64` to
   match `AudioBackend::get_sound_duration`.
 * Wire up `AudioBackend::get_sound_position` to `Sound.position`.
 * Remove unimplmeneted warning from `Sound.position`.
2021-10-16 22:53:25 -07:00
relrelb e9efc2841b avm1: Store depth in `SuperObject`
This is a temporary hack to calculate depth from `base_proto` and
`this`, so that changing `this.__proto__` will affect `super`.

In the future, `depth` should be passed instead of `base_proto`.
2021-10-16 11:14:38 -07:00
relrelb 299b7a778c avm1: Correct `base_proto` for method calls
In case the method is found directly on `this` (normally it shouldn't
because it's usually defined on `this.__proto__`), it seems like the
`super` object behaves identically as-if the method was found on
the object's prototype.
2021-10-16 11:14:38 -07:00
relrelb 7008f9bacc avm1: Correct `base_proto` for constructions
Previously constructions had `base_proto` set to the newly-created
object (`this`). However this doesn't match the `base_proto` of method
calls, which is `this.__proto__` (or more precisely where the function
is found on the prototype chain). This caused wrong behavior when using
the `super` object from within constructors.

Change `base_proto` in that case to be `this.__proto__`, which aligns
with method calls.
In order to keep things working, `SuperObject::call` needs to look-up
one level less than before.

An alternative can be changing `base_proto` for method calls instead,
but that seems to be harder because this would require `search_prototype`
to return the before-last visited object in the prototype chain.
2021-10-16 11:14:38 -07:00
relrelb 1772def6e6 avm1: Fix `SuperObject::get_local_stored`
It should return `None` in order to continue further walking on the
prototype chain.
2021-10-16 11:14:38 -07:00
Chris Midgley c5ad8e76ee
audio: Fail to create invalid ADPCM decoder 2021-10-13 23:12:32 -07:00
Mike Welsh 219d3af284 avm1: Function base clip defaults to `this` if clip no longer exists
When a function is defined, the base clip is stored in the function
object, and used when the function is called in SWFv6+. This
affects the target clip for GotoFrame and other actions.

However, if that base clip no longer exists when the function is
called, the base clip should default to the `this` display object.
Previously Ruffle would still use the previously unloaded base clip.
2021-10-12 17:23:01 -07:00
relrelb c0021204c6 Revert "core: Fix clip depth handling in `MovieClip::mouse_pick`"
This reverts commit 37e3f0903e.
2021-10-12 22:42:11 +03:00
dependabot[bot] 72e50bd3c6 build(deps): bump quote from 1.0.9 to 1.0.10
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.9 to 1.0.10.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.9...1.0.10)

---
updated-dependencies:
- dependency-name: quote
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-11 17:14:42 -07:00
dependabot[bot] ce70dbb52e build(deps): bump png from 0.17.1 to 0.17.2
Bumps [png](https://github.com/image-rs/image-png) from 0.17.1 to 0.17.2.
- [Release notes](https://github.com/image-rs/image-png/releases)
- [Changelog](https://github.com/image-rs/image-png/blob/master/CHANGES.md)
- [Commits](https://github.com/image-rs/image-png/commits)

---
updated-dependencies:
- dependency-name: png
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-11 15:30:20 -07:00
dependabot[bot] fd64530288 build(deps): bump syn from 1.0.78 to 1.0.80
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.78 to 1.0.80.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.78...1.0.80)

---
updated-dependencies:
- dependency-name: syn
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-11 15:29:29 -07:00
relrelb 37e3f0903e core: Fix clip depth handling in `MovieClip::mouse_pick` 2021-10-10 18:51:59 -07:00
Mike Welsh 0786350a6f avm2: Defer self-gotos to end of frame script execution
If a movieclip calls a seek operation like `gotoAndStop` on
itself while executing a frame script, this goto is not executed
until the frame script has completed. In contrast, calling a goto
on other clips will execute the goto immediately.
2021-10-10 18:27:30 -07:00
Mike Welsh 57be2397ef avm2: Initialize slots to appropriate values when no default given
Slots and const traits should initialize to an appropriate value
for their type if no default is specified. Remove the `Option`
from `default_value`, and always set it to an appropriate null-ish
value (`0` for ints, `NaN` for `Number`, `null` for objects, etc.)
2021-10-10 14:01:36 -07:00
EmperorBale 34ecb32b85 avm2: Add custom implementations for get_enumerant_name and property_is_enumerable for VectorObject 2021-10-10 11:02:42 -07:00
EmperorBale 6eea0f2067 avm2: Add custom get_enumerant_name & property_is_enumerable implementations for ArrayObject 2021-10-10 11:02:42 -07:00
Chris Midgley 2dfaa33282 chore: fmt 2021-10-09 10:10:03 -07:00
Chris Midgley c9e67d31dc core: move avm_type from display object to update context 2021-10-09 10:10:03 -07:00
relrelb 54df49f96e core: Random SWF-related cleanups 2021-10-08 13:22:45 -07:00
relrelb 4fcf0907ac core: Remove `SwfSlice` usage from `MovieClip::new` 2021-10-08 13:22:45 -07:00
relrelb b8152f431e core: Use `SwfSlice::read_from` 2021-10-08 13:22:45 -07:00
Moulins 4ad6e1e698 avm1: Propagate AvmString<'gc>s to all methods on Object
Some frequently-used Object methods have an Into<impl AvmString<'gc>>
parameter to reduce the size of the changes.
2021-10-06 19:47:35 -06:00
Moulins 9aa601d43b core: Store AvmString<'gc>s in avm1::PropertyMap 2021-10-06 19:47:35 -06:00
TÖRÖK Attila 525dfcba05 chore: Bump h263-rs and h263-rs-yuv git refs 2021-10-05 10:58:46 -07:00
TÖRÖK Attila 3869950578 video/vp6: Add VP6[A] video decoding support
Gated behind the "vp6" feature, enabled by default.
Utilizing a heavily stripped-down version of the NihAV project,
retaining only the VP6 decoder, relicensed under MIT.
Including VP6WithAlpha decoding, proper FrameDependency reporting,
and cropping the unwanted encoded pixels on the right/bottom manually.
2021-10-04 22:33:06 -07:00
dependabot[bot] 006275632c build(deps): bump syn from 1.0.77 to 1.0.78
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.77 to 1.0.78.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.77...1.0.78)

---
updated-dependencies:
- dependency-name: syn
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-04 15:01:47 -07:00
dependabot[bot] 3d754a5d7d build(deps): bump smallvec from 1.6.1 to 1.7.0
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.6.1 to 1.7.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.6.1...v1.7.0)

---
updated-dependencies:
- dependency-name: smallvec
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-04 15:01:36 -07:00
David Wendt ee9341cb1c avm2: Remove `is_boxed_primitive`, as we are no longer accepting boxed primitives on the stack. 2021-10-03 15:57:43 -07:00
David Wendt 71c953b6ac avm2: Automatically unbox any boxed primitives that happen to make their way onto the stack.
This particular occurance is unlikely in practice, but could become far more common as more primitive constructors are implemented.
2021-10-03 15:57:43 -07:00
relrelb d49ea10267 swf: Rename `TryBlock` fields
* `try_actions` -> `try_body`
* `catch` -> `catch_body`
* `finally` -> `finally_body`

This aligns with the names used in SWF19, and is more consistent.
2021-10-02 23:01:32 +03:00
relrelb 81c864c6c8 avm1: Propagate exceptions in `Key.isDown`
Also change `coerce_to_f64` to `coerce_to_i32`.
2021-10-02 23:01:32 +03:00
relrelb 0a30057a63 avm1: Use enum constants instead of hard-coded numbers 2021-10-02 23:01:32 +03:00
TÖRÖK Attila a1ee508ff8
chore: Fix nightly clippy lint: clippy::if_then_panic (#5400)
* chore: Fix nightly clippy lint: clippy::if_then_panic

* chore: Fix nightly clippy lint: clippy::if_then_panic in swf tests too

* Address review notes
2021-10-02 16:14:53 +03:00
David Wendt f2e7457bc0 avm2: Move `QNameObject` specific methods behind an `as_qname_object` downcast. 2021-10-01 16:30:58 -06:00
David Wendt aaca3460d4 avm2: `QName` overrides `toString` and `valueOf` in both namespaces 2021-10-01 16:30:58 -06:00
David Wendt 513965b624 avm2: `Function.call` and `Function.apply` need to be accessible in the public namespace.
We should be able to move the AS3 versions to traits, but that breaks two other tests.
2021-10-01 16:30:58 -06:00
David Wendt 273872e2ab avm2: `Any` namespaces are represented as `*` in `QName`'s string form 2021-10-01 16:30:58 -06:00
David Wendt 294b0fc53e avm2: Impl `QName`'s constructor and properties 2021-10-01 16:30:58 -06:00
David Wendt 5387b1a4e0 avm2: Add stub boxed `QName` object type and class 2021-10-01 16:30:58 -06:00
relrelb 05d8f13b26 audio: ADPCM small cleanup 2021-09-30 20:16:04 +03:00
relrelb b9307af78f audio: Move ADPCM's tables out of `AdpcmDecoder` 2021-09-30 20:16:04 +03:00
relrelb 50ec497c60 audio: Introduce `AdpcmDecoder::channels`
This reduces duplicated code.
2021-09-30 20:16:04 +03:00
relrelb 4deaaed75c audio: Inline `AdpcmDecoder::next_sample` 2021-09-30 20:16:04 +03:00
relrelb 99827caf2b audio: Localize `AdpcmDecoder::{left,right}_step`
Since they were used only in a single scope.
2021-09-30 20:16:04 +03:00
dependabot[bot] 8c123c10af build(deps): bump syn from 1.0.76 to 1.0.77
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.76 to 1.0.77.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.76...1.0.77)

---
updated-dependencies:
- dependency-name: syn
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-28 01:27:10 +03:00
dependabot[bot] 5fe0994a3a build(deps): bump symphonia from 0.3.0 to 0.4.0
Bumps [symphonia](https://github.com/pdeljanov/Symphonia) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/pdeljanov/Symphonia/releases)
- [Commits](https://github.com/pdeljanov/Symphonia/compare/v0.3.0...v0.4.0)

---
updated-dependencies:
- dependency-name: symphonia
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-28 01:26:57 +03:00
Adrian Wielgosik 5ce2266be7 chore: clippy 2021-09-27 11:03:48 +02:00
Adrian Wielgosik 87625fa302 avm2: Change core types from Object to ClassObject where possible 2021-09-27 11:03:48 +02:00
Adrian Wielgosik 83b7420a3f avm2: Remove unneeded indirection from ClassObject methods 2021-09-27 11:03:48 +02:00
David Wendt 6753608e78 chore: Fix incorrect doccomment 2021-09-25 16:54:36 -06:00
David Wendt c299f63784 avm2: Implement object space enumeration.
This required making enumerants into `Value`s, rather than `QName`s.
2021-09-25 16:54:36 -06:00
David Wendt dbe9dffe0e avm2: Implement object-space overrides for `getproperty`, `setproperty`, `deleteproperty`, and `in`. 2021-09-25 16:54:36 -06:00
David Wendt 925604f730 avm2: Implement `DictionaryObject` and `Dictionary` 2021-09-25 16:54:36 -06:00
EmperorBale 28b34cbe25 chore: Typo 2021-09-23 23:14:30 -06:00
EmperorBale 3f81910bb6 avm2: Remove custom_object macros 2021-09-23 23:14:30 -06:00
relrelb 54d417c539 avm1: Don't warn in case a method doesn't exist 2021-09-23 18:55:49 -06:00
David Wendt f298a23ec8 avm2: Ensure all bare function calls pull an appropriate `superclass_object` 2021-09-23 15:59:06 -06:00
David Wendt 7ef7b80395 avm2: Prototypes are not instances of their class 2021-09-23 15:59:06 -06:00
David Wendt b8c086eb7a avm2: Calls to object properties should use the new `call_property` method 2021-09-23 15:59:06 -06:00
David Wendt 7cefeb2b2a avm2: Add a `constructprop` method for objects, too. 2021-09-23 15:59:06 -06:00
David Wendt b07ad8070c avm2: Make `get_property`, `set_property`, `init_property`, and various other derivative methods take a `Multiname` and run the search inside `Object`.
This also introduces a `call_property` method.
2021-09-23 15:59:06 -06:00
David Wendt 945cb2c4bf avm2: Global class inheritance issues should report which class cannot be found 2021-09-23 15:59:06 -06:00
David Wendt 8f8134e4f4 avm2: Add private instance slots for `FrameLabel`'s properties 2021-09-23 15:59:06 -06:00
David Wendt 5ba2421225 avm2: Add private instance slots for `Scene`'s properties 2021-09-23 15:59:06 -06:00
David Wendt 97924d20ad avm2: Add private instance slots for `Point`'s properties 2021-09-23 15:59:06 -06:00
David Wendt dfc90984dc avm2: Add private instance slots for `Rectangle`'s properties 2021-09-23 15:59:06 -06:00
David Wendt 81da1aad4b avm2: `Video` is not a subclass of `flash.media.DisplayObject` (which doesn't exist) 2021-09-23 15:59:06 -06:00
EmperorBale 1874223224 avm2: Remove ignore_next 2021-09-23 00:01:50 +02:00
EmperorBale 31abe5d9d7 avm2: Specify that date should coerce to string by default 2021-09-23 00:01:50 +02:00
EmperorBale 64eb47a65c avm2: Remove YearType 2021-09-23 00:01:50 +02:00
EmperorBale bd6ca72510 avm2: Implement Date.parse 2021-09-23 00:01:50 +02:00
EmperorBale 10be7ef3bf avm2: Implement toUTCString 2021-09-23 00:01:50 +02:00
EmperorBale 292a9bda4b avm2: Implement toLocaleString, toLocaleTimeString, toDateString, toLocaleDateString 2021-09-23 00:01:50 +02:00
EmperorBale b9fd7f5977 avm2: Implement toString, toTimeString 2021-09-23 00:01:50 +02:00
EmperorBale 931080cd49 avm2: Implement valueOf 2021-09-23 00:01:50 +02:00
EmperorBale aca23b744e chore: Appease clippy 2021-09-23 00:01:50 +02:00
EmperorBale 7f8e01b426 avm2: Implement UTC 2021-09-23 00:01:50 +02:00
EmperorBale 453486265f avm2: Implement timezoneOffset 2021-09-23 00:01:50 +02:00
EmperorBale 0732efc9d9 avm2: Impement day, dayUTC 2021-09-23 00:01:50 +02:00
EmperorBale fe584f7508 chore: Fix typos 2021-09-23 00:01:50 +02:00
EmperorBale 97da4d1b7b avm2: Implement UTC variants 2021-09-23 00:01:50 +02:00
EmperorBale 0dc0bc9694 avm2: Implement month, fullYear 2021-09-23 00:01:50 +02:00
EmperorBale 273ae48654 avm2: Refactor date implementation 2021-09-23 00:01:50 +02:00
EmperorBale 6ab0d89040 avm2: Implement minutes, hours, date 2021-09-23 00:01:50 +02:00
EmperorBale d5621c1ce7 avm2: Implement time, seconds, milliseconds 2021-09-23 00:01:50 +02:00
EmperorBale 32eb9d1579 avm2: Implement Dates instance initializer 2021-09-23 00:01:50 +02:00
EmperorBale db550b035c avm2: Add Date stub 2021-09-23 00:01:50 +02:00
relrelb 3463e50a72 avm1: Avoid `impl Into<Value<'gc>>` parameter in `Avm1::push`
This might create templatized functions leading to unnecessary code bloat.

So instead use just `Value<'gc>` parameters and add `.into()` in callers
where needed.
2021-09-22 23:13:13 +02:00
kmeisthax 42275f43f3 avm2: Properly make all classes an instance of `Class`. (#57)
* avm2: Properly make all classes an instance of `Class`.

Also, does this technically mean that `Class` is a metaclass?

* avm2: Remove `Function::from_method_and_proto` as it will no longer be needed

* avm2: Ensure builtin classes are also instances of `Class`.

This requires tying a veritable gordian knot of classes; everything needs to be allocated up-front, linked together, and then properly initialized later on. This necessitated splitting the whole class construction process up into three steps:

1. Allocation via `from_class_partial`, which does everything that can be done without any other classes
2. Weaving via `link_prototype` and `link_type`, which links all of the allocated parts together correctly. This also includes initializing `SystemClasses` and `SystemPrototypes`.
3. Initialization via `into_finished_class`, which must be done *after* the weave has finished.

Once complete you have core classes that are all instances of `Class`, along with prototypes that have their usual legacy quirks.

Note that this does *not* make prototypes instances of their class. We do need to do that, but doing so breaks ES3 legacy support. This is because we currently only work with bound methods, but need to be able to call unbound methods in `callproperty`.

* tests: Add a test for all core classes' instance-of relationships
2021-09-22 00:29:37 +02:00
Adrian Wielgosik f8c32d3a68 avm2: Fix get_own_class_definition users to use either instance_of or as_. 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 71e41e2c92 chore: cargo fmt 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 22482ed080 avm2: Remove unwrap in get_own_class_definition 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 7736818069 avm2: Rename as_class -> get_own_class_definition 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 26e60fa8ea avm2: Rename as_class_object_really -> as_class_object 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 008162c514 avm2: Replace all uses of as_class_object by instance_of 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 4b7f8b3dbd avm2: inner_class_definition is not an Option 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 3e1764aa1e avm2: Reimplement as_class_object() in terms of other methods 2021-09-22 00:29:37 +02:00
Adrian Wielgosik e02feb919a avm2: Reimplement as_class() in terms of other methods 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 4380978b2a avm2: Move instance_allocator() to ClassObject 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 1d22009c6b avm2: Drop seemingly-unused set_class_object() 2021-09-22 00:29:37 +02:00
Adrian Wielgosik f3ab6c9da3 avm2: Move as_class_params() to ClassObject 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 0679fd1a9e amv2: Move superclass_object() to ClassObject 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 2dfa875712 avm2: Move interfaces to ClassObject 2021-09-22 00:29:37 +02:00
Chris Midgley 6f0b026f13 chore: cargo fmt 2021-09-18 18:42:36 +02:00
Chris Midgley 7bab1de1e7 avm2: implement coerce_x opcodes 2021-09-18 18:42:36 +02:00
Adrian Wielgosik ba35611c47 chore: cargo fmt 2021-09-18 18:37:46 +02:00
lukaszN a76f2403ac avm2: String rename PUBLIC_CLASS_METHODS to AS3_CLASS_METHODS 2021-09-18 18:37:46 +02:00
lukaszN 0f41193c3b avm2: String.match match lastIndex behavior 2021-09-18 18:37:46 +02:00
lukaszN d5588f3f90 avm2: String refactor index_of, match 2021-09-18 18:37:46 +02:00
lukaszN 42300d4a1e avm2: String tests 2021-09-18 18:37:46 +02:00
lukaszN 4abde1500b avm2: String fixes for tests 2021-09-18 18:37:46 +02:00
lukaszN e24390ff58 avm2: String slice, substr, substring 2021-09-18 18:37:46 +02:00
lukaszN d953fea5df avm2: String match 2021-09-18 18:37:46 +02:00
lukaszN 91d63e4dc1 avm2: class methods can also live in the AS3 namespace 2021-09-18 18:37:46 +02:00
lukaszN 5e5d8e4fff avm2: String concat, lastIndexOf, indexOf, fromCharCode 2021-09-18 18:37:46 +02:00
relrelb 1ab953887c avm1: Simplify `Value::abstract_eq`
Make it return `bool` instead of a `Value` that can be either `true`
or `false`.
2021-09-18 17:47:25 +02:00
Giles Cope 42c2b40052 unused deps 2021-09-18 15:28:24 +02:00
Chris Midgley 758d84f549 avm2: fix button typo 2021-09-18 15:26:52 +02:00
Chris Midgley 909428943b avm2: implement bkpt, bkptline, timestamp as no-ops 2021-09-17 23:06:59 +02:00
relrelb ff1c29d952 avm1: Simplify `Value::abstract_lt`
* Change its return type to `Option<bool>`.
* Use Rust's `f64::partial_cmp` to compare two numbers, which should
be more efficient.
2021-09-16 13:46:04 +03:00
relrelb f92926af54 avm1: Correct `Math.{min,max}`
Don't use `abstract_lt` because it compares strings alphabetically,
unlike `Math.min` and `Math.max` that coerce to a number before comparing.
2021-09-16 02:38:34 -07:00
dependabot[bot] 76f4b0d8cd build(deps): bump flate2 from 1.0.21 to 1.0.22
Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.21 to 1.0.22.
- [Release notes](https://github.com/rust-lang/flate2-rs/releases)
- [Commits](https://github.com/rust-lang/flate2-rs/compare/1.0.21...1.0.22)

---
updated-dependencies:
- dependency-name: flate2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-13 14:27:26 -07:00
Moulins 73bce495c2 chore: move core::avm1::string::AvmString to core::string::AvmString 2021-09-13 03:30:17 -07:00
Moulins 87e8b44fe9 chore: move core::string_utils to core::string::utils
Also move case tables to a separate file.
2021-09-13 03:30:17 -07:00
Mike Welsh d84f65874e chore: Appease clippy
Debug/Clone dervies no longer squelch dead code warnings, see:
See https://github.com/rust-lang/rust/pull/85200
2021-09-11 21:50:52 -07:00
Mike Welsh e3c05a021e core: De-duplicate enums between Avm1Button and Avm2Button
Needed to appease clippy.
2021-09-11 21:50:52 -07:00
Ray Redondo 167b5a45de avm2: move flash.display.IBitmapDrawable init 2021-09-11 15:47:20 -07:00
Ray Redondo 40d53cda59 avm2: make BitmapData and DisplayObject impl IBitmapDrawable 2021-09-11 15:47:20 -07:00
Ray Redondo 7f895473cb avm2: IBitmapDrawable stub 2021-09-11 15:47:20 -07:00
David Wendt 1e0d259075 avm2: Allow nulling `Bitmap.bitmapData`.
One of the two tests in this PR relies upon the backend storing bitmap data, but the test rendering backend does not yet do this.
2021-09-11 12:11:35 -07:00
David Wendt bfb6f03d62 avm2: Impl `Bitmap.smoothing`
Also, `smoothing` should be set at construction time even if we're setting up a timeline bitmap.
2021-09-11 12:11:35 -07:00
David Wendt 2ba0e12b7e avm2: Stub `Bitmap.pixelSmoothing` 2021-09-11 12:11:35 -07:00
David Wendt 8ae669b96c avm2: `BitmapData` should be traceable 2021-09-11 12:11:35 -07:00
David Wendt 31e3741982 avm2: Allow access to the `BitmapData` of a `Bitmap`. 2021-09-11 12:11:35 -07:00
David Wendt 7c5dc568f1 avm2: Impl `BitmapData.getPixel`.
This also changes the `bitmapdata_constr` test slightly to use a different starting value. Our premultiplied alpha calculations generate slightly different values from Flash Player which trips the test.
2021-09-11 12:11:35 -07:00
David Wendt 4c9bd0a6fe avm2: Impl `BitmapData.transparent` 2021-09-11 12:11:35 -07:00
David Wendt e18caa2fbf core: Silence error relating to `Bitmap` symbol class associations 2021-09-11 12:11:35 -07:00
David Wendt dca473fc2a avm2: Impl `BitmapData.width` and `BitmapData.height` 2021-09-11 12:11:35 -07:00
David Wendt 335aec5be0 avm2: Implement `BitmapData`'s constructor.
This includes support for both embedded bitmap data (resolved via the SymbolClass mechanism) as well as empty bitmaps configured via arguments.
2021-09-11 12:11:35 -07:00
David Wendt e5151d147d core: When constructing a `Bitmap`, do not attempt to cache it's associated `BitmapData`'s handle.
Attempting to do so results in borrow-mut panics. Furthermore, it's unnecessary; the handle provided to this function is already derived from the bitmap data in this way.
2021-09-11 12:11:35 -07:00
David Wendt 54740d6093 core: Allow `BitmapData` to hold an AVM2 side. 2021-09-11 12:11:35 -07:00
David Wendt 10b98f72f5 core: Allow `Bitmap` to be reassociated with new `BitmapData` 2021-09-11 12:11:35 -07:00
David Wendt a807cf7623 avm2: Stub `flash.display.BitmapData` & storage object 2021-09-11 12:11:35 -07:00
David Wendt 609b97cfb9 core: Allow `Bitmap`s to hold an AVM2 representation 2021-09-11 12:11:35 -07:00
Chris Midgley bd26790f5b
avm1: Fix `this` inside watchers (#5276)
* fix: fix 'this' inside watchers

* tests: test value of 'this' in watcher

* lint: cargo fmt
2021-09-11 15:15:16 +03:00
relrelb 923201d2e4 chore: Appease clippy 2021-09-10 15:42:37 +02:00
Chris Midgley 3e04c2b0d2 dev: remove allow unused mut and corresponding mut 2021-09-09 19:06:49 -06:00
Daniel Jacobs 5ac9796ffd web: Support salign, quality, & scale embed/object attributes (part of #4258) 2021-09-08 16:25:47 -07:00
Tal Hayon 7d6eaf127d core: Fix EditText width and height scaling (close #3001) 2021-09-08 02:39:01 -07:00
relrelb c2fcc03c35 avm1: Remove `TObject::get_local` in favor of `TObject::get_local_stored`
`get_local` is basically equivalent to `get_local_stored` that also
handles virtual getters. So instead handle virtual getters in
`search_prototype`. This allows to inline the `get_local_sub` helper
methods into the implementations of `get_local_stored`.
The remaining usages of `get_local` were not exactly correct as they
all should ignore virtual getters. This change solves this as well
by using `get_local_stored` that ignores virtual getters.
2021-09-08 12:21:17 +03:00
relrelb 1f96c2fcb8 audio: Small cleanup 2021-09-07 18:28:17 -07:00
relrelb 65205ac6d7 audio: Store sound transform values in 30-bit integers
It seems like Flash stores sound transform values in 30-bit unsigned integers:
* Negative values are equivalent to their absolute value.
* Specifically, 0x40000000, -0x40000000 and -0x80000000 are equivalent to zero.
2021-09-07 18:28:17 -07:00
Chris Midgley 868706d775
avm1: call watcher, if defined, from virtual properties on prototype (#4827)
* avm1: extract get_watcher

* tests: add tests for TextField text watch

* avm1: call the watcher, if defined, from call_setter

* dev: shadow variable to avoid unused mut warning

* dev: remove value mutability

* chore: cargo fmt

* dev: unify virtual and stored property watcher cases

* tests: add test for watching prototyped property

* feat: when getting old values, ascend the proto chain ignoring virtual properties

* chore: lint

* dev: share complicated code

* chore: Small cleanups

Co-authored-by: relrelb <relrelbachar@gmail.com>
2021-09-08 03:41:18 +03:00
Mike Welsh 483995823f core: Add symphonia as optional MP3 decoder
Add symphonia_mp3 feature to enable symphonia as an MP3 decoder.
This is a pure Rust MP3 decoder that could be used on web.
2021-09-07 16:48:34 -07:00
Mike Welsh 94d02fa653 core: Add AudioMixer to core
Pull out the audio mixing code from desktop and add it to core.
This will allow other backends to use it (such as the web audio
backend) to get consistent audio across all platforms.
2021-09-07 16:48:34 -07:00
Tal Hayon 4625ca0e0b web: fix base param 2021-09-07 16:45:35 -07:00
dependabot[bot] 5e07d4e464 build(deps): bump syn from 1.0.75 to 1.0.76
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.75 to 1.0.76.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.75...1.0.76)

---
updated-dependencies:
- dependency-name: syn
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-06 14:33:56 -07:00
Adrian Wielgosik 9bd0b624fd avm2: Add more Event class stubs and constants 2021-09-05 11:56:21 +02:00
David Wendt bc4f790031 avm2: Stub `SoundMixer.areSoundsInaccessible` and `SoundMixer.computeSpectrum` 2021-09-03 16:47:02 -06:00
David Wendt 34fe35a998 avm2: Impl `SoundMixer.bufferTime` 2021-09-03 16:47:02 -06:00
David Wendt 364ee62c92 avm2: Impl `SoundChannel`'s `soundComplete` event.
This includes a test that is currently ignored because `NullAudioBackend` can't fire complete events.
2021-09-03 16:47:02 -06:00
David Wendt d5718fe408 avm2: Initialize all sounds and channels at time of allocation 2021-09-03 16:47:02 -06:00
David Wendt efcab92d97 avm2: Impl `SoundMixer.stopAll` 2021-09-03 16:47:02 -06:00
David Wendt d73ba586d0 avm2: Impl `SoundChannel.stop()` 2021-09-03 16:47:02 -06:00
David Wendt 39305f6a38 avm2: Implement `SoundChannel.soundTransform` 2021-09-03 16:47:02 -06:00
David Wendt 9c6c64e4e3 core: `NullAudioBackend` should falsely report all sounds as not playing, like the real backends
This prevents sounds from being removed from the `AudioManager`, which allows sound transforms to be placed on them in tests.
2021-09-03 16:47:02 -06:00
David Wendt 6b7609ff4e avm2: Stub `SoundChannel.position`.
This also comes with an ignored test for `position`, because I originally believed this to be implementable.
2021-09-03 16:47:02 -06:00
David Wendt 4e77f89e0f avm2: Stub `SoundChannel.leftPeak` and `SoundChannel.rightPeak` 2021-09-03 16:47:02 -06:00
David Wendt 50092e6c04 avm2: Stub all remaining `Sound` methods. 2021-09-03 16:47:02 -06:00
David Wendt b6167c2f86 avm2: Allow playing sounds with a given `SoundTransform`. 2021-09-03 16:47:02 -06:00
David Wendt 5771d4c826 avm2: Deduplicate the sound transform conversion code 2021-09-03 16:47:02 -06:00
David Wendt 116fb1f323 avm2: Impl `Sound.play`
This does not (yet) implement the third `SoundTransform` parameter on `play`.
2021-09-03 16:47:02 -06:00
David Wendt 8a58956f1f avm2: Add `flash.media.SoundChannel` class & associated object storage 2021-09-03 16:47:02 -06:00
David Wendt 46de9ee46e avm2: `soundTransform` isn't a movieclip property, so don't ask for one. 2021-09-03 16:47:02 -06:00
David Wendt 1bde07089d avm2: Alias `SimpleButton.soundTransform` to the class property of `SoundMixer.soundTransform` 2021-09-03 16:47:02 -06:00
David Wendt 0f625e7864 avm2: Impl `SoundMixer.soundTransform` class property 2021-09-03 16:47:02 -06:00
David Wendt 8e1122104d avm2: Correct `SoundTransform` class definition to match docs 2021-09-03 16:47:02 -06:00
David Wendt 2f6e695483 avm2: Impl `Sprite.soundTransform` 2021-09-03 16:47:02 -06:00
David Wendt 3b9f0f271d avm2: `SoundTransform.pan` returns 0 if the transform sends sound to different channels 2021-09-03 16:47:02 -06:00
David Wendt 2b7a0bf898 avm2: `SoundTransform` stores it's values as square roots 2021-09-03 16:47:02 -06:00
David Wendt bd3cec0d20 avm2: Impl `flash.media.SoundTransform` 2021-09-03 16:47:02 -06:00
David Wendt 3b6eea2a1d core: Report sound duration as `f64` and round down in AS1 2021-09-03 16:47:02 -06:00
David Wendt e4c6e29b8a core: `NullAudioBackend` should not report latency seek data as part of the size of a sound. 2021-09-03 16:47:02 -06:00
David Wendt d7f2f782c4 avm2: Impl `Sound.length`
This also adds duration tracking for `NullAudioBackend`.
2021-09-03 16:47:02 -06:00
David Wendt e25fb732ea avm2: Stub `Sound.isBuffering`, `Sound.isURLInaccessible`, and `Sound.url` 2021-09-03 16:47:02 -06:00
David Wendt 89b411593f avm2: Impl `Sound.bytesTotal` 2021-09-03 16:47:02 -06:00
David Wendt d5fb807387 avm2: Allow calling `Function.apply` without a second argument 2021-09-03 16:47:02 -06:00
David Wendt 7b31cd9a4d avm2: Allow instantiating a SWF sound by constructing it's symbol class 2021-09-03 16:47:02 -06:00
David Wendt 37eb746989 core: Don't warn when associating sounds to AS3 classes 2021-09-03 16:47:02 -06:00
David Wendt 0c591f3370 avm2: Stub implementation of `Sound` and accompanying object type 2021-09-03 16:47:02 -06:00
David Wendt 70556e5830 avm2: Forbid `applytype` opcodes with more than one argument type. 2021-09-02 17:57:58 -06:00
David Wendt e2bf0a9857 avm2: Prohibit naming types with more than one parameter, as they don't exist. 2021-09-02 17:57:58 -06:00
David Wendt 141b992a73 avm2: Storing past the end of a vector only works for the immediate one-off-the-end index 2021-09-02 17:57:58 -06:00
David Wendt 8cd2b4fd5e avm2: Fill vector holes with the default value at creation time instead of storing them. 2021-09-02 17:57:58 -06:00
David Wendt 3b48216762 avm2: Don't store more than one object parameter, because there are no classes with multiple paramters. 2021-09-02 17:57:58 -06:00
David Wendt 5c740ef1e1 chore: Grammar 2021-09-02 17:57:58 -06:00
David Wendt d1b9df61f3 avm2: Move `Vector`'s properties to the AS3 namespace and add prototype properties in the public one 2021-09-02 17:57:58 -06:00
David Wendt cc15809f49 avm2: Add the ability to have a separate class initializer for each specialization of `Vector` 2021-09-02 17:57:58 -06:00
David Wendt e087a27e56 avm2: `Vector.sort` actually *does* calculate an indexed sort array, but then discards it.
Normally we could skip sorting, but values in the vector may have side effects when coerced. So we need to make sure coercions run, at least.
2021-09-02 17:57:58 -06:00
David Wendt 280fbbde45 avm2: Pick nits in `Vector`'s `instance_init` 2021-09-02 17:57:58 -06:00
David Wendt 2095c1831a avm2: Replace some if expressions with easier-to-read equivalents 2021-09-02 17:57:58 -06:00
David Wendt 464605d015 avm2: Pre-allocate all the things 2021-09-02 17:57:58 -06:00
David Wendt bf4492c454 avm2: Add the legacy Vector types that old movies can use.
This one was rather tough to test, as I actually can't generate ABCs in Animate CC that reference these classes. I instead had to modify a compiled SWF to open the package-internal namespace that these pre-specialized classes exist in.
2021-09-02 17:57:58 -06:00
David Wendt dcf6d87363 avm2: Accept `null` as a valid type in `applytype`.
In AVM2, the `*` (any) type is represented as `null`.

This requires also changing the parameters on classes and objects to be nullable, too.

We do *not* represent `null` as a particular value on the underyling vector storage object, however. We instead change it to `Object`, as that's the root of all other types.

This may require revision if non-`Object`-extending types appear in the future.
2021-09-02 17:57:58 -06:00
David Wendt ee30f21e8e avm2: Remove unnecessary `mut` 2021-09-02 17:57:58 -06:00
David Wendt aaddcc598f avm2: Impl `Vector.toLocaleString` and test `toString` 2021-09-02 17:57:58 -06:00
David Wendt d1e49db3cc avm2: Stub `Number.toLocaleString`
This exists but is undocumented, and I accidentally wrote a Vector test that needs it.
2021-09-02 17:57:58 -06:00
David Wendt dbc6f38c34 avm2: Impl `Vector.splice` 2021-09-02 17:57:58 -06:00
David Wendt 81d0775776 avm2: Impl `Vector.sort` 2021-09-02 17:57:58 -06:00
David Wendt 9fcd846a4d avm2: Fix ineffective Vector typechecks 2021-09-02 17:57:58 -06:00
David Wendt 44a9f13047 avm2: Impl `Vector.slice` 2021-09-02 17:57:58 -06:00
David Wendt 077fd87842 avm2: Impl `Vector.reverse` 2021-09-02 17:57:58 -06:00
David Wendt aa2d729a44 avm2: Impl `Vector.removeAt` 2021-09-02 17:57:58 -06:00
David Wendt a053015558 avm2: Impl `Vector.insertAt` 2021-09-02 17:57:58 -06:00