Mike Welsh
a5b5ba46ba
avm1: Unspecified arguments should be set to undefined ( fix #2166 )
...
Unspecified arguments should be set to undefined to prevent
assignments from leaking to the parent scope, for example:
```
function f(arg0) {
arg0 = "BAD"; // Previously could set _root.arg0
}
f();
```
2020-12-31 20:01:05 -08:00
Mike Welsh
22ab8df8f5
tests: Add test for #2166
2020-12-31 20:01:05 -08:00
dependabot-preview[bot]
6a3b9f9f53
build(deps): bump smallvec from 1.5.1 to 1.6.0
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.5.1 to 1.6.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.5.1...v1.6.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-31 14:37:38 -08:00
Mike Welsh
9b6295f33a
render: Pass library to RenderBackend::register_shape ( fix #2037 )
...
Pass the movie library to `register_shape` methods so that bitmap
charcter IDs can be resolved immediately on the proper SWF.
This fixes #2037 , which cause incorrect bitmaps to be used when
multiple movies were loaded.
2020-12-31 13:10:21 -08:00
Adrian Wielgosik
2b2a7c3c27
Remove redundant SystemPrototypes from UpdateContext.
2020-12-31 13:09:59 -08:00
Mike Welsh
ea3b6f59df
avm1: Implement XML.ignoreWhite
2020-12-30 16:00:39 -08:00
Mike Welsh
caa2d8e383
tests: Add test for XML.ignoreWhite
2020-12-30 16:00:39 -08:00
Mike Welsh
d736293425
avm1: Fix method calls with null/empty string name
...
`f[null]` should call `f["null"]`.
`f[undefined]`, `f[""]`, `f[o]` where o.toString returns the empty
string should call `f` directly.
2020-12-30 13:35:36 -08:00
CUB3D
5fb15c8f80
core: Support CallMethod with non-string method_name ( fix #2160 )
2020-12-30 13:35:36 -08:00
paq
4f980becb2
avm1: Implement escape
2020-12-30 12:42:03 -08:00
Mike Welsh
3ce4406434
core: Fix memory leak caused by unbound text variables
...
Text fields without variables would return as unbound in
EditText::try_bind_text_field_variable, causing them to be added
to the unbound textfield list even though they had no variable
setting. Return successful bidning by default to avoid adding
these textfields to the unbound list.
2020-12-29 14:18:07 -08:00
Mike Welsh
802aa9b7a7
avm1: Allow SharedObject creation even if URL is unknown ( fix #2150 )
...
Allow SharedObjects to be created even in the case that the movie
URL is None (for example, loading an SWF from bytes). Use a dummy
"localhost" URL.
2020-12-29 14:17:57 -08:00
Mike Welsh
ff5ecf9754
avm1: Fix incorrect name used for SharedObject cache ( fix #2149 )
2020-12-29 14:17:57 -08:00
Callum Thomson
7b202bd2e7
avm1: Implement flash.filters.ColorMatrixFilter avm1 built-in
2020-12-29 03:10:46 -08:00
paq
8c86434e38
avm1: Implement Matrix.deltaTransformPoint
2020-12-28 01:17:00 -08:00
paq
8baa36e801
avm2: Implement isFinite
2020-12-27 23:02:39 -08:00
paq
ce2d7efac3
avm2: Implement isNaN
2020-12-27 23:02:39 -08:00
Mike Welsh
7bdbb6c37d
text: Fix masking of text area ( fix #1496 , #1554 )
2020-12-27 23:01:24 -08:00
Mike Welsh
8d707bc6ab
core: onKeyUp/Down method handlers fire only if clip has focus ( fix #2120 )
2020-12-27 16:08:27 -08:00
paq
7bfe3f7177
avm1: Implement Matrix.transformPoint (ruffle-rs#303)
2020-12-27 14:27:04 -08:00
Mike Welsh
8222d3095b
desktop: Add --timedemo benchmark
...
Add --timedemo for benchmarking, which will run the given SWF as
quickly as possible for 5000 frames or the end of the root
timeline, whichever comes first. The total duration will be output
upon completion.
2020-12-26 23:59:12 -08:00
jmckiern
a3b4074fc4
core: Fix multiline selection bug
2020-12-26 23:18:02 -08:00
jmckiern
208a69d715
core: Move caret to start or end of selection if shift is not held
...
Previously pressing left with a selection would set `selection.to = selection.start() - 1`, now it sets it to `selection.to = selection.start()`. The same is true for right/selection.end()
2020-12-26 23:18:02 -08:00
jmckiern
464f2b63a9
chore: Fix spelling mistake
2020-12-26 23:18:02 -08:00
jmckiern
c277c1083b
core: Render selected text as white with black background
2020-12-26 23:18:02 -08:00
jmckiern
0269c31dbc
core: Change caret color to text color
2020-12-26 23:18:02 -08:00
dependabot-preview[bot]
1b4c8265b7
build(deps): bump syn from 1.0.55 to 1.0.56
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.55 to 1.0.56.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.55...1.0.56 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-26 14:01:15 -08:00
Sam Morrow
38bdb8b39a
web/desktop: Add basic dialog handling ( closes #1978 )
2020-12-23 19:08:18 -08:00
Mike Welsh
367404ddd8
core: SharedObjects are bucketed by domain
...
Key SharedObjects on the domain and path where the SWF is hosted,
and implement the localPath and secure parameters.
Fix #855 .
2020-12-22 14:18:06 -08:00
Callum Thomson
e38d559b1e
avm1: Implement flash.filters.DropShadowFilter
...
Implements the AVM object for DropShadowFilter. Actual rendering is still TODO.
2020-12-22 14:17:12 -08:00
David Wendt
b848e4c5ff
avm2: Get rid of `RufflePrivate` and just use regular private namespaces scoped to our own domain.
2020-12-21 21:47:29 -08:00
David Wendt
30d8dc21be
avm2: Remove weird `into` constructor on `EventHandler`
2020-12-21 21:47:29 -08:00
David Wendt
7baa3cc06d
avm2: Seal the `EventDispatcher` class
2020-12-21 21:47:29 -08:00
David Wendt
3ff9b87261
avm2: `RufflePrivate` namespaces should be treated as private namespaces.
2020-12-21 21:47:29 -08:00
David Wendt
19219ad0c1
avm2: Implement `dispatchEvent`.
...
Event dispatch is a surprisingly complicated procedure, so this makes sure to test:
1. Event dispatch on bare dispatchers
2. Event dispatch on hierarchial dispatchers (movieclips)
3. Event cancellation (which is reported by `dispatchEvent`)
4. The implicit `this` on unbound event handlers. I'm not yet sure if this is a special property of event dispatch or if all unbound functions inherit their global scope as `this`.
5. The execution order of handlers on both bare and hierarchial dispatchers
6. Delegation to hierarchial dispatchers
7. Modification of the dispatch list during dispatch of an event. Surprisingly enough, you can add handlers to the event you're handling and expect them to execute, *if* you added them to a further object in the order *or* you added a bubble handler in the capture phase.
2020-12-21 21:47:29 -08:00
David Wendt
f33e5f893a
avm2: Allow builtins to get at the global scope.
2020-12-21 21:47:29 -08:00
David Wendt
8efaed40a0
avm2: `event.eventPhase` is enumerated from 1
2020-12-21 21:47:29 -08:00
David Wendt
87ff679898
avm2: Implement `EventDispatcher.willTrigger`
2020-12-21 21:47:29 -08:00
David Wendt
a071800117
avm2: `EventDispatcher` should supercall, too.
2020-12-21 21:47:29 -08:00
David Wendt
e8163e43ab
avm2: Builtin constructors should supercall.
2020-12-21 21:47:29 -08:00
David Wendt
be4e37a55c
avm2: Implement `addEventListener`, `removeEventListener`, and `hasEventListener`.
2020-12-21 21:47:29 -08:00
David Wendt
2faf5259ca
avm2: Add a representation for event dispatch lists.
...
For various reasons, we store the dispatch list for an object on a separate property of an `EventDispatcher` rather than dictating that all children of `EventDispatcher` use a specific object type. This is because `EventDispatcher` is a very general class with lots of object representations it needs to cover. So instead, we introduce a new object representation for a *property* and store it in a Ruffle private namespace that is as isolated from user code as alternate object representations are.
2020-12-21 21:47:29 -08:00
David Wendt
b02897637f
avm2: Add a new namespace type to store runtime-internal properties we don't want user code being able to access ever.
2020-12-21 21:47:29 -08:00
dependabot-preview[bot]
606fd28b3b
build(deps): bump quote from 1.0.7 to 1.0.8
...
Bumps [quote](https://github.com/dtolnay/quote ) from 1.0.7 to 1.0.8.
- [Release notes](https://github.com/dtolnay/quote/releases )
- [Commits](https://github.com/dtolnay/quote/compare/1.0.7...1.0.8 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-20 15:54:45 -08:00
Callum Thomson
69ab12fcc3
avm1: Add flash.filters.GlowFilter
2020-12-20 15:31:09 -08:00
dependabot-preview[bot]
820572f204
build(deps): bump syn from 1.0.54 to 1.0.55
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.54 to 1.0.55.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.54...1.0.55 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-20 15:19:11 -08:00
Mike Welsh
8a0e55d74a
chore: Bump to rand 0.8
2020-12-19 14:33:12 -08:00
Mike Welsh
9d6e711006
tests: Add test for #2030
2020-12-19 02:14:27 -08:00
Mike Welsh
60d7c0a742
core: Fix incorrect bounds for Bitmap ( fix #2030 )
2020-12-19 02:14:27 -08:00
Mike Welsh
981a4de9c9
tests: Uncomment arguments.caller avm1 test
2020-12-19 01:46:20 -08:00
Mike Welsh
0dd8b24fec
avm1: Implement arguments.caller
2020-12-19 01:46:20 -08:00
Mike Welsh
a3f18b80b6
tests: Add test for TextField.replaceSel
2020-12-19 00:35:26 -08:00
Mike Welsh
62a3729b55
avm1: Implement TextField.replaceSel
2020-12-19 00:35:26 -08:00
Mike Welsh
042e9a444b
tests: Add parseFloat tests
2020-12-18 02:50:09 -08:00
Mike Welsh
80d5d9cd0a
avm1: Initial implementation of parseFloat
2020-12-18 02:50:09 -08:00
Mike Welsh
326a5b6212
core: Move device font to Library ( fix #1995 )
2020-12-17 23:20:22 -08:00
Mike Welsh
a58073cabd
core: Fix Collect impl for BitmapData ( fix #2009 )
2020-12-17 19:35:26 -08:00
Mike Welsh
72a24b9800
tests: Add tests for #1906
2020-12-17 18:07:01 -08:00
Mike Welsh
25cd4ee375
avm1: Color.setTransform/setRGB sets transformed-by-AS flag ( fix #1906 )
2020-12-17 18:07:01 -08:00
Mike Welsh
7cf217a911
swf: Use lzma-rs for LZMA SWFs ( fix #405 )
...
Pure Rust decoder that functions on desktop and wasm.
Enable lzma feature by default.
TODO: Switch to lzma-rs streaming API when stable on crates.io.
Currently decodes entire stream at once.
2020-12-17 16:40:21 -08:00
jmckiern
beed570475
core: Add string_utils char boundary functions
2020-12-17 16:15:24 -08:00
jmckiern
b81cb1a3eb
core: Extend text input to deal with multibyte chars
2020-12-17 16:15:24 -08:00
David Wendt
09f9e99fbb
avm2: Implement `rest` parameters in function calls.
2020-12-17 13:21:44 -08:00
David Wendt
453e013c2c
avm2: Implement `arguments`.
2020-12-17 13:21:44 -08:00
David Wendt
217890f4a6
avm2: Implement `Function.apply`
2020-12-17 13:21:44 -08:00
Mike Welsh
369c5bda56
render: Implement Bitmap smoothing property
2020-12-15 00:04:51 -08:00
CUB3D
3556ffd778
chore: Fixes after rebase
2020-12-15 00:04:51 -08:00
CUB3D
a92b8ffded
core: All other changes from review
2020-12-15 00:04:51 -08:00
CUB3D
ccd08f14d9
core: Fix naming and safety issues
2020-12-15 00:04:51 -08:00
CUB3D
e483d0959f
core: Remove unwraps
2020-12-15 00:04:51 -08:00
CUB3D
6f91352d41
chore: Fix clippy lints
2020-12-15 00:04:51 -08:00
CUB3D
eea45d6ae6
core: Tidy up loadBitmap
2020-12-15 00:04:51 -08:00
CUB3D
23a9c7143a
core: Support failiable constructors
2020-12-15 00:04:51 -08:00
CUB3D
b3dd5c0c0b
core+renderer: Fix corner cases
2020-12-15 00:04:51 -08:00
CUB3D
666c3db9c6
core: Refactor bitmapData
2020-12-15 00:04:51 -08:00
CUB3D
74ab728cff
core: Format
2020-12-15 00:04:51 -08:00
CUB3D
22a7b1d340
core: Add handling of invalid arguments for getColorBoundsRect/colorTransform
2020-12-15 00:04:51 -08:00
CUB3D
353d5a268b
core: Add better handling of invalid arguments to BitmapData
2020-12-15 00:04:51 -08:00
CUB3D
9d46d67588
core+web+renderer: Add load/attach Bitmap and handling for invalid args with BitmapData
2020-12-15 00:04:51 -08:00
CUB3D
3c12fa6ee5
core: Implement BitmapData.floodFill and correct getPixel for invalid coordinates
2020-12-15 00:04:51 -08:00
CUB3D
3afd20063f
core: Implement get/set pixel(32) functions
2020-12-15 00:04:51 -08:00
CUB3D
e45e942a1f
core: Start implementation for flash.display.BitmapData
2020-12-15 00:04:51 -08:00
dependabot-preview[bot]
843bc74292
build(deps): bump indexmap from 1.6.0 to 1.6.1
...
Bumps [indexmap](https://github.com/bluss/indexmap ) from 1.6.0 to 1.6.1.
- [Release notes](https://github.com/bluss/indexmap/releases )
- [Commits](https://github.com/bluss/indexmap/compare/1.6.0...1.6.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-14 17:49:16 -08:00
David Wendt
acadcb8fc0
avm2: `Event` is a sealed class.
2020-12-14 16:46:33 -08:00
David Wendt
f7f51dcde2
avm2: `EventPhase` and `PropagationMode` should be `Eq`
2020-12-14 16:46:33 -08:00
David Wendt
6caaf0d222
avm2: Implement all of the `Event` class constants.
...
I'm not writing tests for these, my wrists hurt enough as is.
2020-12-14 16:46:33 -08:00
David Wendt
8a787e6153
avm2: Implement `Event.toString` (which matches it's valueof behavior)
2020-12-14 16:46:33 -08:00
David Wendt
dc32d7894c
avm2: Remove redundant event phase accessor
2020-12-14 16:46:33 -08:00
David Wendt
ec63ff55cb
avm2: Implement `Event.stopPropagation` and `Event.stopImmediatePropagation`.
...
These aren't testable yet.
2020-12-14 16:46:33 -08:00
David Wendt
d393a5f4f8
avm2: Implement `Event.preventDefault` and `Event.isDefaultPrevented`
2020-12-14 16:46:33 -08:00
David Wendt
8b9a804ae9
avm2: Implement `Event.formatToString`.
2020-12-14 16:46:33 -08:00
David Wendt
584c6c8b11
avm2: Implement `Event.clone`
2020-12-14 16:46:33 -08:00
David Wendt
3d12929914
avm2: Expose `Event.target`, `currentTarget`, and `eventPhase`.
...
These have no tests because these properties can only be updated by an event broadcaster.
2020-12-14 16:46:33 -08:00
David Wendt
90da20579c
avm2: Implement `Event.bubbles`, `cancelable`, and `type`.
2020-12-14 16:46:33 -08:00
David Wendt
58f4470dc5
avm2: Add `Event` class, object type, and native representation
2020-12-14 16:46:33 -08:00
jmckiern
709561a255
avm1: Use ? on set_text_color so errors are raised
2020-12-14 12:45:45 -08:00
jmckiern
ec1ff0be3a
avm1: Use ? instead of match Ok()'s so errors are raised
2020-12-14 12:45:45 -08:00
jmckiern
a09ac58ebd
chore: Remove TODO
2020-12-14 12:45:45 -08:00
jmckiern
cfd003de7a
avm1: Implement TextField.backgroundColor
2020-12-14 12:45:45 -08:00
jmckiern
61e3214d0a
avm1: Implement TextField.borderColor
2020-12-14 12:45:45 -08:00
Sam Morrow
c4d7b24629
web: Fix cors issues with http (close ruffle-rs#1486)
2020-12-14 05:51:28 -08:00
Zeh Fernando
8e9de8e16b
core: Implement MovieClip._lockroot in avm1
...
This also enables the (previously ignored) _lockroot tests.
2020-12-13 15:34:42 -08:00
Mike Welsh
ee74197a00
avm1: Move TextField properties to prototype
...
Remove TextField::attach_virtual properties, as properties are
on the prototype, not the textfield itself.
Use the `with_text_field_props` macro for these properties.
Also remove `get_` prefix from most getters to match naming
conventions.
2020-12-09 14:45:20 -08:00
David Wendt
ed4d51dfc1
avm1: Don't panic if we encounter an invalid display object hierarchy for AS2. Instead, yield a runtime error.
2020-12-09 14:00:06 -08:00
David Wendt
afd033898c
avm2: Implement `hitTestObject`
2020-12-09 14:00:06 -08:00
David Wendt
d9172780c5
avm2: Implement `hitTestPoint`.
2020-12-09 14:00:06 -08:00
David Wendt
b18b87e566
avm2: Implement `mouseX` and `mouseY`.
...
Note that we cannot write a reproducible test for this.
2020-12-09 14:00:06 -08:00
David Wendt
06ba2f898a
avm2: Implement `visible`.
2020-12-09 14:00:06 -08:00
David Wendt
d489aca377
avm2: Expose `DisplayObject.root`
2020-12-09 14:00:06 -08:00
David Wendt
4b9deb7106
core: Don't crash on rootless display objects.
...
Instead, crash if AVM1 ever sees a rootless display object.
2020-12-09 14:00:06 -08:00
David Wendt
0069d51dad
swf: `pushshort` should be read as a `u30` and then cast to an `i16` as it's parsed representation.
2020-12-09 14:00:06 -08:00
David Wendt
1b2a4708d6
avm2: Implement `DisplayObject.parent`.
2020-12-09 14:00:06 -08:00
David Wendt
852f26bdeb
tests: Fix name test breaking with our half-working execution order
2020-12-09 14:00:06 -08:00
David Wendt
c053f2c87c
avm2: Expose DisplayObject `name` property
2020-12-09 14:00:06 -08:00
David Wendt
ea7efe8740
core: Avoid double-borrow when moving clips between parents
2020-12-09 14:00:06 -08:00
David Wendt
a7b4f7fbd0
core: Add instantiated by timeline flag as AVM2 appears to track that
2020-12-09 14:00:06 -08:00
David Wendt
6080585d73
core: Assign `rootN` format names to top-level AVM2 movie clips.
2020-12-09 14:00:06 -08:00
David Wendt
19f9e99954
avm2: Expose and test `rotation`.
2020-12-09 14:00:06 -08:00
David Wendt
29f96e76ab
tests: Activate alpha test (since it seems to work fine)
2020-12-09 14:00:06 -08:00
David Wendt
200581e1e3
avm2: Expose `x` and `y` properties.
2020-12-09 14:00:06 -08:00
David Wendt
4784dc3c03
tests: Add more stringent height/width test that we're only accurate to within 1 twip.
2020-12-09 14:00:06 -08:00
David Wendt
abca120628
avm2: Expose `width` to AS3 code.
2020-12-09 14:00:06 -08:00
David Wendt
3225cd40e2
core: Avoid panic when display objects are manipulated in clearly invalid ways.
2020-12-09 14:00:06 -08:00
David Wendt
990401a09c
core: Allow percentages (e.g. scalex/y) to be specified, stored, and cached at either [0..1] or [0..100] scale.
2020-12-09 14:00:06 -08:00
David Wendt
6da658a845
avm2: `pushshort` has an undocumented coercion step
2020-12-09 14:00:06 -08:00
David Wendt
90e203b004
avm2: `this.height` ignores negative values
2020-12-09 14:00:06 -08:00
David Wendt
bd00bea744
avm2: Expose `alpha`, `height`, `scaleY`, and `scaleX` to script code.
2020-12-09 14:00:06 -08:00
David Wendt
69db45131b
tests: Add inactive tests for `alpha`, `height`, `rotation`, `width`, `x`, and `y`.
2020-12-09 14:00:06 -08:00
dependabot-preview[bot]
d1c79a5dd5
build(deps): bump png from 0.16.7 to 0.16.8
...
Bumps [png](https://github.com/image-rs/image-png ) from 0.16.7 to 0.16.8.
- [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 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-08 21:13:22 -08:00
jmckiern
3cab11d18e
avm1: Implement TextField.textColor ( close #1863 )
2020-12-07 15:09:36 -08:00
dependabot-preview[bot]
17eb651682
build(deps): bump syn from 1.0.53 to 1.0.54
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.53 to 1.0.54.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.53...1.0.54 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-07 13:08:20 -08:00
Mike Welsh
9901738249
chore: Appease rustfmt
2020-12-07 10:35:40 -08:00
relrelb
989bfb8f3e
avm1: Improve loops treatment in Sound.start
...
The second argument of Sound.start, loops, can be greater than
std::u16::MAX, but previously greater values were treated as 1.
Ideally, the solution is to respect those values, but since SoundInfo
holds a u16, a short-term solution is to treat them as std::u16::MAX
instead.
2020-12-06 14:22:38 -08:00
Mike Welsh
16b9c77d02
core: Remove panic in morph shape lerp
2020-12-05 00:19:30 -08:00
dependabot-preview[bot]
f45fa80e29
build(deps): bump smallvec from 1.5.0 to 1.5.1
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.5.0 to 1.5.1.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.5.0...v1.5.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-04 17:54:47 -08:00
bbb651
92bd0874e1
Fixed "Swap" only working for i32
2020-12-03 15:51:37 -08:00
bbb651
8baf35e7af
Added AVM2 op "Swap"
2020-12-03 15:51:37 -08:00
Mike Welsh
758a32f5f0
core: Remove unimplemented! in decode_define_bits_lossless
2020-12-02 23:58:03 -08:00
Zeh Fernando
c018ac065c
tests: Add test for MovieClip._lockroot in avm1
2020-12-02 11:59:01 -08:00
Mike Welsh
a0d56aad44
core: Don't panic on DefineFont4
2020-12-01 23:01:35 -08:00
Mike Welsh
25e7ec99a0
core: Handle serializing arrays in SharedObjects
2020-11-30 22:15:34 -08:00
Mike Welsh
ad5028817a
core: Remove unnecssary parameter from Button::set_state
2020-11-30 01:15:43 -08:00
Mike Welsh
0d79d85d83
avm1: Fix MovieClip properties being attached to Object.prototype
2020-11-30 01:15:43 -08:00
Mike Welsh
aedddd29ab
avm1: Implement Button.enabled and MovieClip.enabled
2020-11-30 01:15:43 -08:00
dependabot-preview[bot]
827a8ee18d
build(deps): bump syn from 1.0.52 to 1.0.53
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.52 to 1.0.53.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.52...1.0.53 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-29 22:46:08 -08:00
Mike Welsh
ab200b6dc0
avm1: Don't fire button events when invisible ( fix #1521 )
2020-11-29 12:47:36 -08:00
Mike Welsh
dafe7e5027
avm1: Implement Key.getAscii
2020-11-29 02:31:10 -08:00
Mike Welsh
18addef831
core: Don't run stream sounds when stopped ( fix #1719 )
2020-11-27 21:11:15 -08:00
dependabot-preview[bot]
3d9ebbde9c
build(deps): bump syn from 1.0.51 to 1.0.52
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.51 to 1.0.52.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.51...1.0.52 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-27 15:46:54 -08:00
David Wendt
a978b649b9
core: Also gate the `set_parent` change on `remove_range` just in case
2020-11-27 13:23:34 -08:00
David Wendt
0f1d4d5248
core: Always remove children from their old render list positions regardless of what depth list position they had
2020-11-27 13:23:34 -08:00
David Wendt
e69e6fcc5e
core: Fix regression on Super Mario 63
2020-11-27 13:23:34 -08:00
David Wendt
6e565d4da2
core: Fix compliation error caused by the `TDisplayObjectContainer` refactor
2020-11-27 13:23:34 -08:00
David Wendt
5a2f17a642
core: Consistently refer to render list positions as an `index` for consistency with Rust naming conventions
2020-11-27 13:23:34 -08:00
David Wendt
c011c028de
avm2: Correctly coerce render list indicies as `i32`, not `u32`.
2020-11-27 13:23:34 -08:00
David Wendt
01539baf5d
core: Move `render_children` into `TDisplayObjectContainer`.
2020-11-27 13:23:34 -08:00
David Wendt
ba311dd5b4
core: Remove previous changes to make certain `DisplayObject` methods take `&mut self`, which noises up the PR
2020-11-27 13:23:34 -08:00
David Wendt
6d992e239a
core: Re-fix #1580 as it's fix didn't make it into the `DisplayObjectContainer` refactor the first time
2020-11-27 13:23:34 -08:00
David Wendt
8764831533
chore: cargo 1.47 changed the formatting algorithm
2020-11-27 13:23:34 -08:00
David Wendt
365601f2d9
core: New-depth children should always be placed before higher children, not after lower ones.
...
We will call this the "before-above" rule, to contrast with the previous "after-below" behavior. The main difference is how off-depth-list children are handled, which more closely matches AVM2.
The previous implementation of after-below wouldn't work unless we made the fallback case of not having a below child put it to the *end* of the list. This gave us test pass but broke animations. The first one I tried, Cirno's Perfect Math Class, prepends the entire depth list, which with the half-broken after-below behavior wound up appending to the render list.
There isn't an inverse problem with before-below and the end of the list, since we cover that case and we don't have to put weird exceptions.
2020-11-27 13:23:34 -08:00
David Wendt
74b50f2586
core: AVM2-locked children should still be removable from the depth list.
2020-11-27 13:23:34 -08:00
David Wendt
3769d24715
core: Fix incorrect placement of clips where depth placements intended to place objects at the bottom of the list instead placed them at the top.
2020-11-27 13:23:34 -08:00
David Wendt
35bc43cce2
avm2: Swapping children should lock them from depth manipulation.
2020-11-27 13:23:34 -08:00
David Wendt
c8cd4a9192
avm2: Remove outdated documentation on some internal functions.
2020-11-27 13:23:34 -08:00
David Wendt
6cb3ff9632
avm2: Stub `getObjectsUnderPoint` and `areInaccessibleObjectsUnderPoint` as we do not yet support the `Point` class
2020-11-27 13:23:34 -08:00
David Wendt
fec4e3c0a9
core: Replace direct container manipulation with `TDisplayObjectContainer` methods wherever possible.
...
The purpose of this refactor is twofold:
1. Ensure `TDisplayObjectContainer` holds all the container methods we need
2. Ensure that future adjustments to trait methods automatically apply to the display object's own use of the container, in case we want to do things in those methods that can't be done in a borrowed container
There are two places where we cannot use the new trait methods:
1. `Button.set_state` as it holds a borrow at the point we want to clear the container
2. `MovieClipData.goto_remove_object`, since it's a method on the data and thus cannot access trait methods
This particular commit generates a lot of noise as several `DisplayObject` methods were incorrectly marked as non-mutating.
2020-11-27 13:23:34 -08:00
David Wendt
9dde91e0fd
core: Store named children on AVM2 movieclips as object properties
2020-11-27 13:23:34 -08:00
David Wendt
86e1037940
avm2: Implement `stopAllMovieClips`
2020-11-27 13:23:34 -08:00
David Wendt
3cac03857c
chore: Clippy beta compliance
2020-11-27 13:23:34 -08:00
David Wendt
cad2c4ecee
tests: Add a button child execution order test.
2020-11-27 13:23:34 -08:00
David Wendt
e2e598edde
avm2: Implement `swapChildren` and `swapChildrenAt`.
2020-11-27 13:23:34 -08:00
David Wendt
71cdbd7194
avm2: Implement `setChildIndex`
2020-11-27 13:23:34 -08:00
David Wendt
cf0ab2d82f
avm2: Implement `removeChildren`.
...
This also changes the underlying `DisplayObjectContainer` method to accept any type of range. Turns out enum trait objects aren't actually trait objects and don't need to worry about object safety!
2020-11-27 13:23:34 -08:00
David Wendt
38fd29ae5f
avm2: Implement `removeChildAt`
2020-11-27 13:23:34 -08:00
David Wendt
c97ff2b024
core: Implement remove-by-range functionality
2020-11-27 13:23:34 -08:00
David Wendt
495dcf9d05
core: Remove direct execution list head manipulation and the `replace_at_depth` flag that indicates that it has occured.
...
Depending on how I'm reading the old code I replaced, it appeared to be constructing execution lists backwards. I have no idea if this was intended behavior or not. If so, then I'll need to add reverse-add capability to `replace_at_depth`.
2020-11-27 13:23:34 -08:00
David Wendt
80d7409fc5
core: Separate off container management into a separate `DisplayObjectContainer` trait
2020-11-27 13:23:34 -08:00
David Wendt
fed28a7b46
chore: Add `Default` for `ChildContainer` as per clippy
2020-11-27 13:23:34 -08:00
David Wendt
759a590d76
avm2: Implement `getChildIndex`
2020-11-27 13:23:34 -08:00
David Wendt
2454287342
tests: Enable the `removeChild` test that tests timeline manipulation.
2020-11-27 13:23:34 -08:00
David Wendt
85fa8f327d
avm2: Impl `contains` w/ test
2020-11-27 13:23:34 -08:00
David Wendt
e4b5a3f8fc
core: When removing a child from it's parent, make sure it's marked as having no parent.
2020-11-27 13:23:34 -08:00
David Wendt
a2d876bc8c
core: Remove double-ended support for `ChildIter` as it's unnecessary and wastes time
2020-11-27 13:23:34 -08:00
David Wendt
1f2c194ffd
avm2: Remove unnecessary execution list accesses and debugging statements from `DisplayObjectContainer`.
2020-11-27 13:23:34 -08:00
David Wendt
bcef9ef415
tests: Add a whole number of tests of depth/render list interaction from the AS3 side
2020-11-27 13:23:34 -08:00
David Wendt
ab4dd984e8
core: Refactor display list management into a separate `ChildContainer` struct.
...
`ChildContainer` is responsible for maintaining child lists for all display objects that can hold children. Currently, this is just `Button` and `MovieClip` since those are the only objects in AVM1 that can have children, but this will be extended to other objects in future commits.
The number of lists managed has also increased from two to three. The execution list is unchanged save for it's migration into the `ChildContainer` struct. The render list has been split in two to support AS3. Specifically, the render list is now a `Vec`. Render children are still rendered in order but they are now referenced by AS3 `id`s rather than depths. The old `BTreeMap` that served as a render list is now the depth list and serves to maintain compatibility with SWF tags and AVM1 code that refers to things on the timeline by depth.
2020-11-27 13:23:34 -08:00
David Wendt
a5f09d3c09
avm2: Implement `removeChild`.
2020-11-27 13:23:34 -08:00
David Wendt
a5ea9795f6
avm2: Implement `addChild` and `addChildAt`, with tests
2020-11-27 13:23:34 -08:00
David Wendt
c7199ff83f
core: Add a utility for placing a display object at a particular relative position (rather than a static depth) on the render list.
...
For example, let's say we had two objects on the clip at depths 5 and 6. AS3 would see them as children IDs 0 and 1. Adding something at ID 1 translates to putting something between depth 5 and 6. To do this, we shift all higher-depth children up one depth to make room for the incoming clip, producing a new order of depths 5, 6, and 7.
2020-11-27 13:23:34 -08:00
David Wendt
52efbd98a8
core: Remove child's sibling pointers when removing the child from the parent's exec list.
...
This fixes a hang in as-of-yet uncommitted AS3 tests that reused display objects, where repeated removals and additions to the same MovieClip caused the construction of a cyclic render list.
2020-11-27 13:23:34 -08:00
David Wendt
cfd6965b2c
avm2: Use order in the render list (but NOT depths) rather than the execution list for `get_child_by_id`
2020-11-27 13:23:34 -08:00
David Wendt
b263b52bca
avm2: Correctly instantiate timeline clips whose AVM2 constructor isn't specified as a `flash.display.MovieClip`.
2020-11-27 13:23:34 -08:00
David Wendt
4817e92992
avm2: `getChildAt` works in reverse execution list order, not by depth
2020-11-27 13:23:34 -08:00
David Wendt
f3ae65df93
core: Add flag for display objects which were placed by AS3.
...
In AS3. objects placed by scripts *cannot* be removed by `RemoveObject` tags. This enforces that in Ruffle.
2020-11-27 13:23:34 -08:00
David Wendt
8c9f8520b3
avm2: Implement `DisplayObjectContainer.numChildren`
2020-11-27 13:23:34 -08:00
David Wendt
f748576927
avm2: Implement `getChildByName`
2020-11-27 13:23:34 -08:00
David Wendt
827567bb58
avm2: `toString` of stage objects should work the same way as other objects
2020-11-27 13:23:34 -08:00
David Wendt
dc629af177
avm2: `getChildById` indexes by zero, but it gives me the child at depth one.
2020-11-27 13:23:34 -08:00
David Wendt
d04f131cfe
avm2: Implement `DisplayObjectContainer.getChildAt`.
...
This test doesn't work yet because it needs `avm2-domainscope` to get merged in.
2020-11-27 13:23:34 -08:00
relrelb
1d648a1d55
core: Use encoding_rs in load_vars_loader
...
This adds support for BOM.
2020-11-26 15:41:50 -08:00
Nathan Adams
d8728bbf25
avm1: Made firstChild and lastChild ignore non-node children
2020-11-26 11:18:00 -08:00
Nathan Adams
c8bb54977b
core: Fix panic loading 'invalid-ish' html in text fields - fixes #1193
2020-11-26 11:17:00 -08:00
Mike Welsh
aff34a4233
core: Seed RNG with timestamp
2020-11-26 00:07:59 -08:00
Mike Welsh
53212f192c
chore: Appease clippy, squelch unnecessary_wraps lint
2020-11-24 18:59:42 -08:00
Mike Welsh
e655cf0c08
web: Add Ruffle::audio_context getter
2020-11-24 16:36:33 -08:00
Mike Welsh
8db4482fcf
core: Avoid panic on truncated SWF ( fix #1583 )
2020-11-24 00:29:28 -08:00
dependabot-preview[bot]
6b60fbe432
build(deps): bump syn from 1.0.50 to 1.0.51
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.50 to 1.0.51.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.50...1.0.51 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-23 17:21:29 -08:00
Mike Welsh
d9ac9fa076
avm1: Array.reverse should return itself
2020-11-22 13:50:49 -08:00
Mike Welsh
7ac53be24f
avm1: Implement TextField.removeTextField
2020-11-22 01:55:46 -08:00
Mike Welsh
03ab4e28d1
chore: Bump quickxml to 0.20
2020-11-22 01:55:01 -08:00
Mike Welsh
a61d2b54ae
avm1: Implement TextField.type
2020-11-21 16:58:19 -08:00
dependabot-preview[bot]
22d695421f
build(deps): bump syn from 1.0.48 to 1.0.50
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.48 to 1.0.50.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.48...1.0.50 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-21 15:20:54 -08:00
Mike Welsh
8d78ee5172
avm1: Use f64 when calculating scale/rotation ( fix #1622 )
2020-11-21 11:39:41 -08:00
MrCheeze
5ea3814097
core: Fix issue where unloaded buttons can still trigger mouse rollout events ( close #1603 )
2020-11-21 11:36:21 -08:00
David Wendt
5d542680ae
avm1: Remove bounds checks from `ActionDefineFunction`, `ActionWith`, `ActionDefineFunction2`, and `ActionTry`.
2020-11-20 00:28:56 -08:00
David Wendt
8ff085b464
avm1: Allow execution of opcodes before the start of an action or function.
2020-11-20 00:28:56 -08:00
Mike Welsh
2d463629e2
core: Avoid borrow panic when text is removed ( fix #1580 )
2020-11-19 18:42:31 -08:00
Mike Welsh
d3265bfd60
avm1: Add allow_empty param to Activation:resolve_target_display_object
...
In some cases, the empty string path "" should resolve to the
starting clip. In other cases, it should be considered invalid.
Add a parameter to control this behavior, and set this to false
for MovieClip::hit_test to prevent `clip.hitTest("")` from
returning true.
2020-11-18 17:58:42 -08:00
Mike Welsh
4c01022a38
avm1: Allow string paths in hitTest ( fix #1559 )
2020-11-18 17:58:42 -08:00
dependabot-preview[bot]
6bfa3144c3
build(deps): bump smallvec from 1.4.2 to 1.5.0
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.4.2 to 1.5.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.4.2...v1.5.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-18 16:30:15 -08:00
relrelb
2e0509694c
docs: Miscellaneous spelling corrections
2020-11-12 13:34:05 -08:00
Mike Welsh
48ee47d88a
tests: Add test for AVM2 Math
...
Also allow specifying relative epsilon for swf_tests_approx.
2020-11-12 04:24:47 -08:00
Mike Welsh
3ce8bc3c4b
avm2: Implement Math
2020-11-12 04:24:47 -08:00
Mike Welsh
b927acb2c2
avm2: trace accepts multiple arguments
2020-11-10 17:05:56 -08:00
Mike Welsh
2e73eba6c9
tests: Add test for unload clip event
2020-11-09 17:26:19 -08:00
Mike Welsh
15d0d814a7
avm1: Exclude unload clip event from continue_if_base_clip_exists
...
Unload event handlers should not halt if their clip is removed
(because it is already removed when an unload handler starts).
This will probably get cleaner if #1535 is fixed (unload clips
stay alive for one frame).
Fixes #447 .
2020-11-09 17:26:19 -08:00
Mike Welsh
fe6ff77889
tests: Add test for initialize clip event
2020-11-09 10:43:18 -08:00
Mike Welsh
3905837679
avm1: Fire initialize clip event
...
This event fires for new clips before any construct clip events.
Split the action queue up into separate priorities, giving
initialize the highest priority.
2020-11-09 10:43:18 -08:00
Mike Welsh
316bc4e920
chore: Appease clippy
2020-11-09 01:52:57 -08:00
relrelb
930d6ebe59
core: Correct MovieClip method names in error messages
...
They all were MovieClip.attachMovie probably becuase of copy-pasting.
2020-11-06 12:33:05 -08:00
David A Roberts
1a978600c6
avm1: Swap rendering order of MovieClip
...
Renders drawing API behind siblings in the same clip.
2020-11-06 12:31:56 -08:00
dependabot-preview[bot]
fcf665fbe9
build(deps): bump url from 2.1.1 to 2.2.0
...
Bumps [url](https://github.com/servo/rust-url ) from 2.1.1 to 2.2.0.
- [Release notes](https://github.com/servo/rust-url/releases )
- [Commits](https://github.com/servo/rust-url/compare/v2.1.1...v2.2.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-06 00:45:35 -08:00
Mike Welsh
4fe5fc44a6
tests: Bump script timeout to 200 secs
2020-11-03 16:02:53 -08:00
Nathan Adams
6c270d8c3a
core: Fix double borrow in button post_init - fixes #1450 and #1190
2020-11-03 15:15:47 -08:00
Nathan Adams
8f064eea6e
core: Strip newlines when loading editboxes that contain them and are marked singleline. This appears to be the correct behaviour - they're never stripped anywhere else but on load
2020-11-02 11:43:10 -08:00
Nathan Adams
f285c990c0
avm1: _root should be allowed in text variable bindings
2020-11-02 11:43:10 -08:00
Nathan Adams
51f986e274
core: Propagate text variable bindings when text is typed
2020-11-02 11:43:10 -08:00
Nathan Adams
3b15babec6
core: Show caret on empty edit boxes
2020-11-02 11:43:10 -08:00
Nathan Adams
a067170afd
core: Rename EditText::get_selection to ::selection
2020-11-02 11:43:10 -08:00
Nathan Adams
c520ff1f50
core: Only show carets for editable text
2020-11-02 11:43:10 -08:00
Nathan Adams
e6d39658b9
core: Change text input to be a match statement
2020-11-02 11:43:10 -08:00
Nathan Adams
8abf5a5be8
core: Limit text input to only editable text
2020-11-02 11:43:10 -08:00
Nathan Adams
e856968f75
core: Allow arrow keys in edit boxes
2020-11-02 11:43:10 -08:00
Nathan Adams
5592a6ca9d
core: Perform delete & backspace in edit boxes
2020-11-02 11:43:10 -08:00
Nathan Adams
cefa42fae0
tests: Add an avm1 test for Selection
2020-11-02 11:43:10 -08:00
Nathan Adams
c910824de8
core: Fix caret position in multi layout text
2020-11-02 11:43:10 -08:00
Nathan Adams
9893972710
core: Allow typing of text in edit boxes
2020-11-02 11:43:10 -08:00
Nathan Adams
881bf3789e
core: Clicking on text will place the caret at the position clicked
2020-11-02 11:43:10 -08:00
Nathan Adams
8a43eb9972
core: Display a caret when the text selection isn't a highlight
2020-11-02 11:43:10 -08:00
Nathan Adams
01c34b97f3
core: Show highlighted text in a slightly different colour (todo: background)
2020-11-02 11:43:10 -08:00
Nathan Adams
163e9fd21b
core: Clicking on (selectable) texts will make that text focused
2020-11-02 11:43:10 -08:00
Nathan Adams
1a230bda09
core: Remove focus when the focused object is removed
2020-11-02 11:43:10 -08:00
Nathan Adams
a4a2cd00b2
avm1: Implement Selection index getters & setSelection - #271
2020-11-02 11:43:10 -08:00
Nathan Adams
3f2057b53e
core: Edit boxes are always focusable, regardless of settings
2020-11-02 11:43:10 -08:00
Nathan Adams
171e23e9e1
avm1: Implement Selection.getFocus and setFocus - #271
2020-11-02 11:43:10 -08:00
Nathan Adams
efbab816e7
avm1: Implement MovieClip.focusEnabled - #263
2020-11-02 11:43:10 -08:00
Nathan Adams
b61a72166f
avm1: Stubbed out Selection - #271
2020-11-02 11:43:10 -08:00
Nathan Adams
93acb07374
core: Introduce a focus tracker, to keep track of one (and only one) focused object
2020-11-02 11:43:10 -08:00
Nathan Adams
f72310be43
core: Change the cursor to an IBeam on selectable text
2020-11-02 11:43:10 -08:00
Nathan Adams
f6b46cb615
core: Implement EditBox.selectable - #280
2020-11-02 11:43:10 -08:00
dependabot-preview[bot]
f04f4ef961
build(deps): bump flate2 from 1.0.18 to 1.0.19
...
Bumps [flate2](https://github.com/rust-lang/flate2-rs ) from 1.0.18 to 1.0.19.
- [Release notes](https://github.com/rust-lang/flate2-rs/releases )
- [Commits](https://github.com/rust-lang/flate2-rs/compare/1.0.18...1.0.19 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-02 10:52:04 -08:00
Mike Welsh
93e7f657f1
tests: Update Array.concat test to print out entire array
2020-10-31 02:42:34 -07:00
Mike Welsh
ff74f67db8
avm1: Fix Array.concat incorrectly creating arrays
2020-10-31 02:42:34 -07:00
relrelb
e74e115cd0
core: Fix bug in PcmDecoder::next
...
It looks like the mono and stereo cases were mistakenly swapped
for 8-bit sounds. This commit simply swaps them to the correct
order.
2020-10-30 12:39:57 -07:00
Mike Welsh
0f4219610d
core: Properly handle masker-inside-masker ( fix #1347 )
...
If a masker is placed inside a masker, the inner mask is inactive
and instead renders as normal art, masked by the outer mask. Properly
handle this case by only pushing new masks if we are not currently
drawing the mask stencil.
Maskee inside maskee still functions as expected. (i.e., a clip
using a mask is masked itself).
2020-10-25 20:41:31 -07:00
dependabot-preview[bot]
55d16c200a
build(deps): bump approx from 0.3.2 to 0.4.0
...
Bumps [approx](https://github.com/brendanzab/approx ) from 0.3.2 to 0.4.0.
- [Release notes](https://github.com/brendanzab/approx/releases )
- [Commits](https://github.com/brendanzab/approx/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-25 12:07:13 -07:00
Mike Welsh
bc31c33f65
avm1: Test for removed clip after a function call
...
0482d1c
made it so that a stack frame halts if its base clip gets
removed (e.g. from a goto). It actually seems like this check
only occurs after a function/method call (see #1370 ). So
and gotoAndPlay method call can cause the stack frame to pop, but
a GotoFrame action cannot.
Only check if the base clip has been removed in CallFunction,
CallMethod, NewObject, NewMethod ops.
Fixes #1370 .
2020-10-24 17:36:38 -07:00
Mike Welsh
e55346a211
tests: Test for removed clip after a function call
2020-10-24 17:36:38 -07:00
dependabot-preview[bot]
05edb73d72
build(deps): bump syn from 1.0.46 to 1.0.48
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.46 to 1.0.48.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.46...1.0.48 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-24 17:20:21 -07:00
Mike Welsh
21818a896d
text: Draw white background for bordered text fields
2020-10-23 16:13:36 -07:00
relrelb
083e2a2ff5
core: Implement getBytes{Loaded,Total} (simpler approach)
2020-10-23 13:13:00 -07:00
relrelb
14a71b69cc
core: Implement getBytes{Loaded,Total}
2020-10-23 13:13:00 -07:00
Nathan Adams
bac4d8c2bf
avm1: Ratelimit timeout check to help ease performance
2020-10-23 13:03:47 -07:00
Mike Welsh
c2d4d56f88
avm1: Allow this in GetVariable/SetVariable paths
2020-10-22 17:23:22 -07:00
Mike Welsh
8da1eeafcb
tests: Add test for this in GetVariable action
2020-10-22 17:23:22 -07:00
Mike Welsh
41f77fade1
avm1: Export names are case insensitive
...
Fixes capital letters not appearing in #1346
2020-10-21 17:09:31 -07:00
Mike Welsh
e093f05656
tests: Add case insensitivity test for attachMovie
2020-10-21 17:09:31 -07:00
dependabot-preview[bot]
3e5457f712
build(deps): bump syn from 1.0.45 to 1.0.46
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.45 to 1.0.46.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.45...1.0.46 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-21 17:08:57 -07:00
Colin Berry
c51a31fde8
desktop: Support URL paths and Proxy options
2020-10-20 23:31:23 -07:00
dependabot-preview[bot]
2fdb378e4f
build(deps): bump syn from 1.0.44 to 1.0.45
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.44 to 1.0.45.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.44...1.0.45 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-17 13:00:00 -07:00
Nathan Adams
a2d53df49c
render: Store immutable part of wgpu rendering as a reusable object, to speed up exporting
2020-10-17 04:16:24 -07:00
David Wendt
6f659db342
tests: Fix the lazyinit test so that it actually passes on Ruffle
2020-10-17 03:32:09 -07:00
David Wendt
50d6ffb510
avm2: Prevent circularly referential scripts from causing stack overflows or double-borrows.
2020-10-17 03:32:09 -07:00
David Wendt
a484861f79
tests: Add a test for lazy initialization load order.
2020-10-17 03:32:09 -07:00
David Wendt
d27360b282
avm2: Enable lazy initialization for ABCs that request it.
2020-10-17 03:32:09 -07:00
David Wendt
0d1676afda
avm2: Create a separate domain for each loaded movie and pull symbols out of each.
2020-10-17 03:32:09 -07:00
David Wendt
cdab885979
avm2: Implement `ApplicationDomain` and all methods that don't require `Vector` or domain memory
2020-10-17 03:32:09 -07:00
David Wendt
1aceb7776d
avm2: Superclasses should resolve out of the current scope stack.
2020-10-17 03:32:09 -07:00
David Wendt
00fcc5ffa4
avm2: Reference the current domain at the bottom of the scope stack.
2020-10-17 03:32:09 -07:00
David Wendt
f2caf60d3e
avm2: Scripts should run in a child of the global domain.
2020-10-17 03:32:09 -07:00
David Wendt
1792939212
avm2: Script scopes should hold the domains they are a part of.
...
Also, this means we have a `TObject` representation for domains now.
2020-10-17 03:32:09 -07:00
David Wendt
6a736b0d2b
avm2: Wrap all player globals in a separate appdomain and script.
...
This entirely abolishes the "global scope object" in AVM2. I even had to redefine several global object functions to work with the bottom of the scope stack, which seems to be where ASC likes to stick the script scope.
2020-10-17 03:32:09 -07:00
David Wendt
add7c4d43d
avm2: Collect all script definition names and associated scripts into a `Domain`.
2020-10-17 03:32:09 -07:00
David Wendt
02e05e3d7f
Add separate scope object for each script.
2020-10-17 03:32:09 -07:00
Mike Welsh
4558be948e
render: Fix masking issues on wgpu/webgl backends
...
Change the usage of the stencil buffer to avoid running out of
stencil bits when too many nested masks are active.
This also cleans things up on wgpu which requires us to make
pipeline states in advice; now we only need a few stencil states
for masking as opposed to hundreds.
2020-10-17 02:42:56 -07:00
Mike Welsh
97a3ef73a3
tests: Add tests for issue #893
2020-10-15 00:10:55 -07:00
Mike Welsh
e66b71817b
avm1: Stop execution if base clip is removed ( fix #893 )
...
Stop execution of the current stack frame if the base clip was
removed (for example, due to a goto).
2020-10-15 00:10:55 -07:00
Nathan Adams
6d9155477c
core: Add flashvars support - #312
2020-10-12 15:28:16 -07:00
Mike Welsh
a6b952e44e
core: Switch from libflate to flate2
2020-10-12 13:47:35 -07:00
Mike Welsh
2c2aa82730
chore: Remove debug message
2020-10-12 13:30:03 -07:00
Nathan Adams
fd6431f724
core: Don't use std Instant as it doesn't work for web, use a wrapper
2020-10-11 13:34:15 -07:00
Nathan Adams
4abd02e2f7
core: Implement a timeout for script execution, defaulting to 15 seconds. Fixes #554
2020-10-11 13:34:15 -07:00
Mike Welsh
137ac2887e
core: Don't mouse pick children when invisible ( fix #1242 )
2020-10-11 04:10:25 -07:00
Mike Welsh
2c9cf6802d
core: Squelch false AS3 error before initial SWF loads
2020-10-10 19:28:01 -07:00
Mike Welsh
5c3dd25638
avm1: Avoid unwrap in Sound constructor
...
At least avoid the panic in this case, but it can possibly fail
(see #701 ).
2020-10-10 18:13:08 -07:00
dependabot-preview[bot]
2c2a70e714
build(deps): bump syn from 1.0.43 to 1.0.44
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.43 to 1.0.44.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.43...1.0.44 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-10 16:35:50 -07:00
Mike Welsh
23660e49c9
core: Avoid panic due to invalid style IDs
...
If the shape converter encountered a fill/line style with an
ID > the number of styles, Ruffle would panic as it tried to grab
the non-existent style. This could occur if we mis-parsed some
shape data, or the SWF contained incorrect data. Now we the invalid
style is gracefully ignored.
2020-10-10 16:35:37 -07:00
Mike Welsh
10aaae9247
chore: Appease nightly clippy
2020-10-10 00:03:25 -07:00
dependabot-preview[bot]
4af9632761
build(deps): bump syn from 1.0.42 to 1.0.43
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.42 to 1.0.43.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.42...1.0.43 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-09 12:22:43 -07:00
David Wendt
5abebd5433
avm2: Yield an error if the caller specifies a label/scene pair and the label is not present within the scene.
2020-10-06 06:03:22 -07:00
David Wendt
1a10f1e004
avm2: Lock old movies (SWFv8 and earlier) to always use AVM1
2020-10-06 06:03:22 -07:00
David Wendt
693e56dc67
core: Always instantiate a new movie's library before creating it's root movieclip.
2020-10-06 06:03:22 -07:00
David Wendt
7c719bfb0c
Only the first tag in a SWF file should be trusted to deliver file attributes.
2020-10-06 06:03:22 -07:00
David Wendt
ddccede9d3
avm2: Make VM type non-optional.
...
This has the side effect of forcing the AVM check to happen at the time of library construction, which is already very early on in movie loading.
2020-10-06 06:03:22 -07:00
David Wendt
ef665acaec
avm2: Movie clips not explicitly granted a `symbol_class` should be constructed using the `MovieClip` class directly
2020-10-06 06:03:22 -07:00
David Wendt
12cf8022cd
core: Remove useless uses of `matches!`.
2020-10-06 06:03:22 -07:00
David Wendt
007d54b389
avm2: Remove redundant implementations of `prev_frame` and `next_frame`
2020-10-06 06:03:22 -07:00
David Wendt
4c44ca8e77
avm2: Non-integer numbers should be handled as strings and integer-parsible strings should be handled as numbers.
2020-10-06 06:03:22 -07:00
David Wendt
e2f21d0a7d
avm2: Retire old references to the "VM tendency" nomenclature
2020-10-06 06:03:22 -07:00
David Wendt
896a5b37a5
avm2: Implement `new MovieClip()`.
2020-10-06 06:03:22 -07:00
David Wendt
d399811eb8
avm2: Allow `MovieClip` to be constructed by users.
2020-10-06 06:03:22 -07:00
David Wendt
50dd9a6733
avm2: Implement the programmatically-playing flag that governs `isPlaying` behavior.
2020-10-06 06:03:22 -07:00
David Wendt
035c841eb5
tests: Add tests for `gotoAndStop` and rename the `gotoAndPlay` one
2020-10-06 06:03:22 -07:00
David Wendt
1f29497b8c
tests: Add test for AS3 movieclip play
2020-10-06 06:03:22 -07:00
David Wendt
8152400a39
avm2: Implement `MovieClip.scenes`.
2020-10-06 06:03:22 -07:00
David Wendt
c682868205
avm2: Implement `MovieClip.currentScene`
2020-10-06 06:03:22 -07:00
David Wendt
2483201bcd
avm2: Store the lengths of each scene in a movie.
2020-10-06 06:03:22 -07:00
David Wendt
8a13d5fe10
avm2: Implement `Scene` object.
2020-10-06 06:03:22 -07:00
David Wendt
5e31c44b81
All objects should default to `toString`ing with their own classname.
2020-10-06 06:03:22 -07:00
David Wendt
de186ed5f3
avm2: Implement `MovieClip.currentLabels`
2020-10-06 06:03:22 -07:00
David Wendt
77a86aef9b
avm2: Implement `FrameLabel`.
2020-10-06 06:03:22 -07:00
David Wendt
86b07c0007
tests: Add tests for `prevScene` and `nextScene`.
2020-10-06 06:03:22 -07:00
David Wendt
542147d657
avm2: Run all AVM2 frame scripts on the action queue.
...
This is the same way that AVM1 actions run and it appears that frame scripts work exactly the same way. It fixes all outstanding bugs with movie clip navigation in AVM2 and allows me to remove a lot of weird workarounds I was writing for the old, incorrect behavior.
I'm also removing the "last run script frame" rule as `run_frame_internal` already had rules to prevent stopped clips from rerunning actions.
2020-10-06 06:03:22 -07:00
David Wendt
996d7528d5
avm2: Implement `prevScene` and `nextScene`.
2020-10-06 06:03:22 -07:00
David Wendt
864c6a37f9
avm2: Dynamic properties should be retrievable before they are actually set.
2020-10-06 06:03:22 -07:00
David Wendt
6d0befad97
avm2: Implement `prevFrame` and `nextFrame`, with tests.
2020-10-06 06:03:22 -07:00
David Wendt
bcf08b5bf7
avm2: Frame scripts should run when the frame number has changed, regardless of playhead state.
2020-10-06 06:03:22 -07:00
David Wendt
97048fb8bd
avm2: Implement `stop` and `play`, with tests for the former.
2020-10-06 06:03:22 -07:00
David Wendt
c8cd4d09cd
core: Don't run frame scripts on stopped movie clips.
2020-10-06 06:03:22 -07:00
David Wendt
556c951b1c
avm2: Implement `gotoAndPlay`/`gotoAndStop`, with test.
2020-10-06 06:03:22 -07:00
David Wendt
3513918149
avm2: Allow typechecking by prototype, rather than just by constructor.
2020-10-06 06:03:22 -07:00
David Wendt
e837840bba
core: Always skip frames after the current frame when getting the current scene or label.
2020-10-06 06:03:22 -07:00
David Wendt
5b83f6b4cc
avm2: Add test for movieclip-specific properties.
2020-10-06 06:03:22 -07:00
David Wendt
3b6f8cff4e
avm2: Implement `framesLoaded`, `isPlaying`, and `totalFrames`.
2020-10-06 06:03:22 -07:00
David Wendt
7ca34452a1
avm2: Implement `currentFrameLabel` and `currentFrame`.
2020-10-06 06:03:22 -07:00
David Wendt
6124ed468f
core: Add `current_label` for getting the current label on a given clip.
...
This also fixes `current_scene` as well.
2020-10-06 06:03:22 -07:00
David Wendt
c1b14b7639
avm2: Implement `currentFrame`.
2020-10-06 06:03:22 -07:00
David Wendt
7756fd530d
core: Allow grabbing the movieclip's current scene, if scene labels are defined.
2020-10-06 06:03:22 -07:00
David Wendt
d747ef7914
core: Store scene and frame labels generated by the `DefineSceneAndFrameLabelData` tag.
2020-10-06 06:03:22 -07:00
David Wendt
55fec14a1c
tests: Add tests for timeline scripts.
2020-10-06 06:03:22 -07:00
David Wendt
c04bf7d53c
`addFrameScript` indexes by zero, not by one.
2020-10-06 06:03:22 -07:00
David Wendt
ab45b9084d
avm2: Parse `SymbolClass` package paths correctly.
2020-10-06 06:03:22 -07:00
David Wendt
a1a21500d8
core: Warn when a movie clip is AVM2-constructed without an accompanying symbol class.
2020-10-06 06:03:22 -07:00
David Wendt
8c67260e68
core: Special-case ID 0 as the current movie timeline.
...
Note: This relies on the fact that SWF files do not stick `SymbolClass` declarations in child movieclips. If this isn't the case, then it will fail horribly, and we would then need to actually store clip 0 in the library somehow.
2020-10-06 06:03:22 -07:00
David Wendt
f2c3466026
avm2: The AVM2 constructor should be an actual Class, not it's prototype.
2020-10-06 06:03:22 -07:00
David Wendt
e915a07d4f
core: ABC files should resolve at the time of discovery, not on the action queue.
2020-10-06 06:03:22 -07:00
David Wendt
7e898457b0
avm2: Implement `addFrameScript`.
2020-10-06 06:03:22 -07:00
David Wendt
d991c49774
Implement `addFrameScript`.
2020-10-06 06:03:22 -07:00
David Wendt
664152d739
avm2: Mark `EventDispatcher` as implementing `IEventDispatcher`.
...
This doesn't actually implement any of it's methods yet, which *would* cause an error *if* we were verifying that.
2020-10-06 06:03:22 -07:00
David Wendt
e72c9776ec
avm2: Implement `IEventDispatcher`.
2020-10-06 06:03:22 -07:00
David Wendt
c899b3080a
avm2: Add function to unwrap a `StageObject` as it's underlying `DisplayObject`.
2020-10-06 06:03:22 -07:00
David Wendt
a70e1be466
Add code to instantiate AVM2 movie clips correctly.
...
This also includes several bits to build an effective VM barrier.
2020-10-06 06:03:22 -07:00
David Wendt
247e79e61a
core: Track the VM each movie has pledged to execute on.
...
This uses a "VM tendency" system wherein the presence of `DoAction` or `DoInitAction` tags defaults the movie to AVM1, while the presence of `DoABC` defaults to AVM2. The presence of a `FileAttributes` tag allows setting the VM tendency in the same manner using it's AS3 bit.
Particularly malformed SWFs may cause execution issues if Flash Player uses a dramatically different system from this.
2020-10-06 06:03:22 -07:00
David Wendt
3128bbcda6
core: Implement `SymbolClass` tag.
2020-10-06 06:03:22 -07:00
David Wendt
edd31c4b83
core: Allow pulling the AVM2 Object out of a participating movie clip.
2020-10-06 06:03:22 -07:00
David Wendt
f85319aa4c
core: Allow `DisplayObject` to hold AVM2 objects.
...
This requires the use of an intermediary enum called `AvmObject` which can hold either object representation. Currently, it's mostly just being unwrapped as AVM1 objects, which we will need to fix.
2020-10-06 06:03:22 -07:00
David Wendt
63f411d231
avm2: Add `StageObject` object implementation for holding display objects in AVM2.
2020-10-06 06:03:22 -07:00
David Wendt
3fb186e5c0
avm1: Remove fscommand debug code
2020-10-01 13:53:00 -07:00
David Wendt
1a77874e04
avm1: For good measure, also unload on empty URL in `ActionGetURL`.
2020-10-01 13:53:00 -07:00
David Wendt
bb5c367e91
chore: Remove dbg statement in loaders
2020-10-01 13:53:00 -07:00
David Wendt
e73cdd7987
avm1: Actually unload movies when we get an empty URL in `GetURL2` and the target is a sprite.
2020-10-01 13:53:00 -07:00
CUB3D
f0a02f00b5
core: Changes from review
2020-09-29 11:06:56 -07:00
CUB3D
110b9ec551
core: Fix edge cases and implement rest of bevel filter
2020-09-29 11:06:56 -07:00
CUB3D
2c3ee4d94b
core: Add flash.filters.BevelFilter
2020-09-29 11:06:56 -07:00
Sean-Thomas
5701312527
desktop: Implement play/pause for CPAL backend
...
- removed default implementations for `play()` and `pause()` methods for AudioBackend trait
- Implemented `play()` and `pause()` methods for CPAL audio backend
- Implemented empty block for `play()` and `pause()` methods for NULL audio backend
2020-09-29 11:05:23 -07:00
Sean-Thomas
a9538f81d0
web: Renamed "prime_audio" and "suspend_audio"
...
Renamed "prime_audio" and "suspend_audio" to "play" and "pause" respectfully.
2020-09-29 11:05:23 -07:00
Sean-Thomas
6b54cc4311
web: Add pause method for web player
...
Adds a suspend_audio method to compliment prime_audio on WebAudioBackend, as well as logic in player.rs on the set_is_playing method to suspend audio when is_playing is set to false. Exposes pause method for the ruffle player in JavaScript with logic to display the play button when paused.
2020-09-29 11:05:23 -07:00
Mike Welsh
ead845ff33
chore: Appease clippy
2020-09-26 18:19:37 -07:00
Mike Welsh
98d2651e62
tests: Add tests for Array single-param ctor
2020-09-26 14:13:06 -07:00
Mike Welsh
366e8aa926
Array: Fix Array single-param ctor
...
The Array constructor with a single param sets the length if the
parameter is a number (no coercion is done); otherwise, it is
creates an 1-length Array containing the parameter. Previously
we coerced the parameter to a float.
2020-09-26 14:13:06 -07:00
Mike Welsh
9e13058e04
avm1: Fix list of elements in Array ctor ( fix #1195 )
2020-09-26 14:13:06 -07:00
David Wendt
6bb6bcab7a
core: Store rotations in degrees to avoid floating-point conversion discrepancies.
2020-09-26 14:12:49 -07:00
David Wendt
28bf84bd8b
core: Store object scale as percentages to avoid floating point precision problems.
...
Fixes a specific pattern of preloader design where animations were handled by just making the box bigger every frame until it's 100. Of course, direct equality of f64 is a terrible idea, but it works in Flash, which apparantly must store scale in percentages. So we must, too.
2020-09-26 14:12:49 -07:00
David Wendt
f6f084098e
tests: Add a test for floating point errors in the AVM1 representation of `_xscale`, `_yscale`, and `_rotation`.
2020-09-26 14:12:49 -07:00
dependabot-preview[bot]
c5135fc737
build(deps): bump syn from 1.0.41 to 1.0.42
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.41 to 1.0.42.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.41...1.0.42 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-26 14:11:01 -07:00
dependabot-preview[bot]
0dfac7b1ac
build(deps): bump gif from 0.11.0 to 0.11.1
...
Bumps [gif](https://github.com/image-rs/image-gif ) from 0.11.0 to 0.11.1.
- [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.0...v0.11.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-25 13:22:07 -07:00
Mike Welsh
802636fbbf
chore: Bump to gif 0.11.0
2020-09-21 18:30:27 -07:00
Luca Weiss
8a8075ca99
avm1: Fix registered function names for Sound object ( #1209 )
...
The functions are just stubs currently so this shouldn't change any
behavior.
2020-09-19 16:21:50 -07:00
Nathan Adams
4a83641a6c
core: Support \r newlines in texts - fixes #1071 , #808
2020-09-19 16:18:35 -07:00
Luca Weiss
d5cb396331
*: fix spelling mistakes
2020-09-19 16:17:58 -07:00
Mike Welsh
2f84d468ee
text: Default text span color should be black
...
Previosuly color defaulted to 0% alpha, causing text to be
invisible if the text field did not specify a defualt color.
2020-09-18 18:58:09 -07:00
Mike Welsh
6f2655cf95
tests: Add test for SWF4 string ops
2020-09-17 16:03:51 -07:00
Mike Welsh
7eeba10bef
avm1: Clean up SWF4 string ops
...
Clean up SWF4 string ops:
* Operate on UTF-16 code units (in SWF6+)
* StringExtract indices are 1-based
2020-09-17 16:03:51 -07:00
Mike Welsh
4f6c017bc0
avm1: Move utf16 util methods to string_utils
2020-09-17 16:03:51 -07:00
Nathan Adams
ef3d5c1538
core: Apply a mask when rendering text, fixes parts of #1167
2020-09-17 16:03:16 -07:00
Nathan Adams
e008603426
core: Add draw_rect to the render backend API
2020-09-17 16:03:16 -07:00
Mike Welsh
3cc43265bf
core: Always recurse down into movieclips when mouse picking
...
Was only consdering the world bounds, but buttons can have separate
hit areas that don't actually affect the bounds of the parent clip.
(TODO: Could have keep track of a separate mouse_bounds instead.)
Fixes regression in Mini-Putt 2 (#1120 ).
2020-09-15 02:34:32 -07:00
Mike Welsh
4593320d36
tests: Add more tests to hittest_shapeflag test
2020-09-15 02:34:32 -07:00
Mike Welsh
fe3bf5cb59
core: Implement hit_test_shape for MorphShape
2020-09-15 02:34:32 -07:00
Mike Welsh
4d26ebe9b4
core: Implement hit_test_shape for EditText
2020-09-15 02:34:32 -07:00
Mike Welsh
e9a2ef5d82
core: DisplayObject::hit_test_shape now takes UpdateContext
...
Make default implementation the same as hit_test_bounds.
2020-09-15 02:34:32 -07:00
Mike Welsh
0d111ca92f
avm1: _target of root should be /
...
Also, levels other than 0 should be appened in slash syntax, e.g
_level1/clip
2020-09-15 02:20:24 -07:00
David Wendt
f2380d828a
chore: Don't capitalize our type arguments.
2020-09-15 02:20:11 -07:00
David Wendt
7e91c45950
avm2: Move trait methods into the AS3 namespace.
...
`toString`, `toLocaleString`, and `valueOf` are still `public`, because they're not supposed to be trait methods at all.
2020-09-15 02:20:11 -07:00
David Wendt
27eda5cdf1
avm2: Remove `ArrayIterator` trait.
...
I originally added this with the anticipation that `impl` return syntax only allowed one trait plus OIBITs. This was prior experience in Rust but apparantly the compiler accepts this just fine, so I suppose my defensive coding practice was a bad/outdated idea.
2020-09-15 02:20:11 -07:00
David Wendt
de0bc93839
Fix `hasOwnProperty` yielding false on populated non-hole array indicies.
2020-09-15 02:20:11 -07:00
David Wendt
e581704559
avm2: `new Array()` should reject negative and `NaN` length arguments as errors.
2020-09-15 02:20:11 -07:00
David Wendt
582df3bd7d
avm2: Misc perf fixes and nits in Array globals.
2020-09-15 02:20:11 -07:00
David Wendt
07e14463e2
avm2: Array `join` and `toString` treat `undefined` and `null` as empty strings.
2020-09-15 02:20:11 -07:00
David Wendt
3b7922d222
avm2: Implement `Array.sortOn`
2020-09-15 02:20:11 -07:00
David Wendt
0aa2c50118
avm2: Implement `Array.sort`
2020-09-15 02:20:11 -07:00
David Wendt
bb19699739
avm2: Add convenience method for converting a `Value` into an `EnumSet`.
2020-09-15 02:20:11 -07:00
David Wendt
a653a62a93
avm2: Add array sorting constants.
2020-09-15 02:20:11 -07:00
David Wendt
ca4982029b
avm2: Impl `Array.toLocaleString`.
2020-09-15 02:20:11 -07:00
David Wendt
2ae3b6445b
avm2: Partially implement `toLocaleString` insamuch as is necessary to run Array tests on it.
...
This appears to work almost like it's own TObject method; you can run `Object.prototype.toLocaleString` on all sorts of things and it has separate behavior to what the class method for it might be. I have attempted to match Flash Player as best as I can.
2020-09-15 02:20:11 -07:00
David Wendt
dbaef812fa
avm2: Impl `Array.splice`.
2020-09-15 02:20:11 -07:00
David Wendt
53b564bb52
avm2: Implement `Array.slice`.
2020-09-15 02:20:11 -07:00
David Wendt
685fbc12e0
tests: `Array.reverse`'s test should also include a check for holes.
2020-09-15 02:20:11 -07:00
David Wendt
036f7cbb90
avm2: Implement `Array.shift` and `Array.unshift`.
...
This also updates `Array.push` to support it's ability to push multiple arguments at once.
2020-09-15 02:20:11 -07:00
David Wendt
879aff3669
avm2: Implement `Array.reverse`
2020-09-15 02:20:11 -07:00
David Wendt
1ce78388a3
avm2: Implement `Array.push` and `Array.pop`
2020-09-15 02:20:11 -07:00
David Wendt
0ece924877
avm2: Implement `indexOf` and `lastIndexOf`
2020-09-15 02:20:11 -07:00
David Wendt
7aa1ab82e4
avm2: Avoid locking the array when running user code.
...
The array being iterated is explicitly handed to all callbacks, and it is legal for the callback to mutate the array. Hence, we can't actually hold a `Ref` to the array storage when we call user code. Instead, we implement a custom `Iterator` which iterates over the object like user code would.
This actually can't be an `Iterator` impl due to limitations of the underlying trait. Hence, we have to `while let` instead of `for`.
2020-09-15 02:20:11 -07:00
David Wendt
832bbdd711
avm2: Implement `forEach`, `map`, `filter`, `every`, and `some` on `Array`.
...
This also comes with some refactoring: building the resulting array object and resolving holes is now done in helper methods.
2020-09-15 02:20:11 -07:00
David Wendt
0eeee72be6
avm2: Implement `Array.join`, `Array.toString`, and `Array.valueOf` (w/tests)
2020-09-15 02:20:11 -07:00
David Wendt
79df789028
tests: Add test for `Array.concat`.
2020-09-15 02:20:11 -07:00
David Wendt
75e6018607
tests: Add test for `newarray`.
2020-09-15 02:20:11 -07:00
David Wendt
505018c3b8
avm2: Implement `newarray`.
2020-09-15 02:20:11 -07:00
David Wendt
27793092c2
tests: Add `array_holes` test.
2020-09-15 02:20:11 -07:00
David Wendt
3d37fda1ef
tests: Add tests for `deleteproperty` on arrays.
2020-09-15 02:20:11 -07:00
David Wendt
04828663e8
avm2: `deleteproperty` should only ever yield `false` when attempting to delete unknown properties on a sealed class object.
2020-09-15 02:20:11 -07:00
David Wendt
6d9b9c9218
avm2: Attempts to get unknown properties on dynamic objects should yield `undefined`.
2020-09-15 02:20:11 -07:00
David Wendt
966dfc3902
avm2: Add method to get at the `Class` of non-class objects with a prototype.
...
The only unclassed objects should be bare objects, which are hard to get at.
2020-09-15 02:20:11 -07:00
David Wendt
cac1717780
avm2: Add utility method `is_sealed` for `Class`.
2020-09-15 02:20:11 -07:00
David Wendt
1a8f041b77
tests: Add `array_storage` test.
2020-09-15 02:20:11 -07:00
David Wendt
34ba1643dd
tests: Add test for reading properties of an array
2020-09-15 02:20:11 -07:00
David Wendt
5a29b781ec
avm2: Ensure `ArrayObject` offers access to it's array properties for reading and writing.
2020-09-15 02:20:11 -07:00
David Wendt
e054456286
avm2: Add method to check if a particular namespace is the public namespace.
2020-09-15 02:20:11 -07:00
David Wendt
1d3f5d80be
tests: Add test for `new Array`'s arguments.
2020-09-15 02:20:11 -07:00
David Wendt
a09ba9d263
avm2: Implement `length`.
2020-09-15 02:20:11 -07:00
David Wendt
aaf586e3a7
avm2: `define_instance_trait` should actually define instance traits.
2020-09-15 02:20:11 -07:00
David Wendt
45c95cae02
avm2: Impl `Array.concat`
2020-09-15 02:20:11 -07:00
David Wendt
1092bf2bc5
avm2: Add the ability to wrap an already-constructed array in an object.
2020-09-15 02:20:11 -07:00
David Wendt
bd35ebb793
avm2: Impl `Array` constructor
2020-09-15 02:20:11 -07:00
David Wendt
bedd5fa007
avm2: Add a method for mutating the array storage of an object.
2020-09-15 02:20:11 -07:00
David Wendt
d92d3023e7
avm2: Restore `as_number`.
...
This is for the sake of methods that want to change behavior based on if they're working with a number or some other kind of value. It should not be used otherwise.
2020-09-15 02:20:11 -07:00
David Wendt
16e1a1bdf3
avm2: Add Array class.
...
This code also ensures that the prototypes of each system object are created in the appropriate `TObject` impl. This ensures that, for example, `new Array` hands you back an actual array.
2020-09-15 02:20:11 -07:00
David Wendt
88fc9b1538
avm2: Implement base types for array-shaped objects.
2020-09-15 02:20:11 -07:00
dependabot-preview[bot]
f0976cffc7
build(deps): bump syn from 1.0.40 to 1.0.41
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.40 to 1.0.41.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.40...1.0.41 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-14 12:02:03 -07:00
Nathan Adams
3ff399ca6b
core: Trace only to the log backend, but have the default log backend trace to the log crate
2020-09-13 13:51:39 -07:00
Nathan Adams
319efabb47
tests: Make tests capture trace output through new backend
2020-09-13 13:51:39 -07:00
Nathan Adams
e25e03a841
core: Log to new avm_trace method where we want things to show up
2020-09-13 13:51:39 -07:00
Nathan Adams
de009c7673
core: Add Log backend, for capturing trace output specific to a movie
2020-09-13 13:51:39 -07:00
dependabot-preview[bot]
491526cc93
build(deps): bump bitstream-io from 0.8.5 to 0.9.0
...
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io ) from 0.8.5 to 0.9.0.
- [Release notes](https://github.com/tuffy/bitstream-io/releases )
- [Commits](https://github.com/tuffy/bitstream-io/compare/v0.8.5...v0.9.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-11 21:17:24 -07:00
Adrian Wielgosik
0fe88f23bb
avm1: Use fnv hash in PropertyMap
2020-09-09 10:44:52 -07:00
CUB3D
8a5434c956
core: Switch to enum for differentiating callable values from uncallable ones
2020-09-07 13:14:48 -07:00
CUB3D
efa7e862fd
core: Propagate this through scope and get_variable
2020-09-07 13:14:48 -07:00
CUB3D
91d5e0f74b
core: Update tests
2020-09-07 13:14:48 -07:00
CUB3D
136a5664b0
core: Pass the correct this for CallFunction when in a with scope
...
fixes #805 , #945 , #1018
2020-09-07 13:14:48 -07:00
Mike Welsh
a18e80baf2
chore: Fix clippy lints
2020-09-07 12:18:41 -07:00
dependabot-preview[bot]
08f1299595
build(deps): bump syn from 1.0.39 to 1.0.40
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.39 to 1.0.40.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.39...1.0.40 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-07 11:14:14 -07:00
dependabot-preview[bot]
07a6075765
build(deps): bump indexmap from 1.5.2 to 1.6.0
...
Bumps [indexmap](https://github.com/bluss/indexmap ) from 1.5.2 to 1.6.0.
- [Release notes](https://github.com/bluss/indexmap/releases )
- [Commits](https://github.com/bluss/indexmap/compare/1.5.2...1.6.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-07 11:13:54 -07:00
David Wendt
35b589b2ac
avm2: `in` should only ever query non-namespaced/public properties.
2020-09-07 11:07:07 -07:00
David Wendt
3b5411547a
avm2: Implement `in`
2020-09-07 11:07:07 -07:00
David Wendt
11b8354905
avm2: `resolve_any` should resolve prototype properties.
2020-09-07 11:07:07 -07:00
Mike Welsh
64679e8796
avm1: typeof button/text should be object ( fix #1110 )
2020-09-04 11:33:40 -07:00
Nathan Adams
b2dc564628
avm1: Fix String.lastIndexOf(undefined)
2020-09-04 11:32:16 -07:00
Nathan Adams
ea7a9758c4
avm1: Fix String.indexOf(undefined)
2020-09-04 11:32:16 -07:00
Mike Welsh
86ab300ee8
core: Call post_instantiate on initial empty root ( fix #946 )
...
The `fake_root` did not have an object, which could cause the
player to panic if the SWF was not completely loaded when playing.
Calling `post_instantiate` ensures that this dummy root has an
object.
2020-09-04 11:31:04 -07:00
Mike Welsh
3a813f1f15
tests: Test for #1104
2020-09-03 19:09:48 -07:00
Mike Welsh
5ea06b0ce6
swf: Use Option for more PlaceObject parameters
...
There is a difference between empty/default (change value to default)
and none (don't modify), so make this explicit for some PlaceObject
parameters where it wasn't.
Fixes #1104 .
2020-09-03 19:09:48 -07:00
Mike Welsh
151b13a424
avm1: ExternalInterface properties are read only
2020-09-03 18:17:44 -07:00
Nathan Adams
b5531a48d0
web: Allow reentrant ExternalInterface callbacks
2020-09-03 18:17:44 -07:00
Nathan Adams
a49e8d8587
web: Implement two-way communication with ExternalInterface
2020-09-03 18:17:44 -07:00
Nathan Adams
687c912067
core: Allow for reentry from ExternalInterface methods
2020-09-03 18:17:44 -07:00
Nathan Adams
32de953822
core: Allow passing arguments and returning values to/from ExternalInterface
2020-09-03 18:17:44 -07:00
Nathan Adams
e1b3ac79d6
core: Add ability to call out to ExternalInterfaceProviders
2020-09-03 18:17:44 -07:00
Nathan Adams
502ea98ed4
core: Add ability to call in to ExternalInterface callbacks from outside of the player (+ test)
2020-09-03 18:17:44 -07:00
Nathan Adams
169c61bf96
tests: Added ability for tests to have a before_start and before_end, and added basic ExternalInterface test that uses it
2020-09-03 18:17:44 -07:00
Nathan Adams
3784f411b4
core: Add ExternalInterface::addCallback
2020-09-03 18:17:44 -07:00
Nathan Adams
b66e9f8d16
avm1: Add ExternalInterface with only 'available' property right now
2020-09-03 18:17:44 -07:00
Nathan Adams
8f11141426
core: Add initial ExternalInterface structs
2020-09-03 18:17:44 -07:00
Nathan Adams
c5ac707fb5
avm1: Iterating xmlnode attributes should list every attribute
2020-09-03 17:03:43 -07:00
Nathan Adams
bcb64b9a62
avm1: Fix calling Function() as a function - fixes #1074
2020-09-03 17:01:20 -07:00
Nathan Adams
40cdb84656
tests: Add test for avm1 Function(foo)
2020-09-03 17:01:20 -07:00
Mike Welsh
ce2b360ab7
core: Provide default impl for DisplayObject:hit_test_bounds
2020-09-02 17:51:55 -07:00
Mike Welsh
b0c9795cad
core: Graphic::from_swf_tag takes ownership of Shape
2020-09-02 17:51:55 -07:00
Mike Welsh
f2f70cc882
core: Mouse picking for buttons uses shape hit tests
2020-09-02 17:51:55 -07:00
Mike Welsh
d7a186b2cd
avm1: Implement shape hit testing
2020-09-02 17:51:55 -07:00
Mike Welsh
2da3c0d319
tests: Add hitTest shapeflag test
2020-09-02 17:51:55 -07:00
Nathan Adams
ec407a9514
avm1: Don't blanket impl From<i64> for Value, convert it explicitly where we know it's okay
2020-09-02 17:12:31 -07:00
Nathan Adams
0b5713557b
desktop: Implement LocaleBackend for desktop
2020-09-02 17:12:31 -07:00
Nathan Adams
f50b29151c
avm1: If a NaN is provided to new Date(timestamp), fail immediately
2020-09-02 17:12:31 -07:00
Nathan Adams
9dfc20e1ba
avm1: Implement Date.UTC
2020-09-02 17:12:31 -07:00
Nathan Adams
86eb6f2e50
avm1: Implement Date - #249
2020-09-02 17:12:31 -07:00
Nathan Adams
3d30ec67e2
test: Add more cases to registerClass tests
2020-09-02 15:18:59 -07:00
Nathan Adams
2178beec87
core: When constructing objects for DisplayObjects, make sure frames are run at the right moment
2020-09-02 15:18:59 -07:00
Mike Welsh
537cca7c38
tests: Add test for #1086
2020-09-02 13:25:53 -07:00
Mike Welsh
bc08971066
core: Return version from MovieClip::swf_version ( fix #1086 )
...
MovieClip was not returning the proper SWF version, causing it to
default to the newest SWF version in some cases when it shouldn't.
2020-09-02 13:25:53 -07:00
dependabot-preview[bot]
03dcdcd494
build(deps): bump indexmap from 1.5.1 to 1.5.2
...
Bumps [indexmap](https://github.com/bluss/indexmap ) from 1.5.1 to 1.5.2.
- [Release notes](https://github.com/bluss/indexmap/releases )
- [Commits](https://github.com/bluss/indexmap/compare/1.5.1...1.5.2 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-02 12:39:18 -07:00
CUB3D
e95c1ff758
core: Make blurX and blurY floating point
2020-09-02 10:59:00 -07:00
CUB3D
143ba03754
core: Fix clippy lints and format
2020-09-02 10:59:00 -07:00
CUB3D
a2c151677b
core: Add blurFilter and test
2020-09-02 10:59:00 -07:00
CUB3D
d1ad095bad
core: Add tests for bitmap_filter
2020-09-02 10:59:00 -07:00
CUB3D
34f485ca21
core: Add basic flash.filters.(BlurFilter|BitmapFilter)
2020-09-02 10:59:00 -07:00
Nathan Adams
cb2461920b
core: HTTP request values need to preserve order
2020-08-28 11:53:32 -07:00
dependabot-preview[bot]
4137a1cac0
build(deps): bump minimp3 from 0.4.0 to 0.5.0
...
Bumps [minimp3](https://github.com/germangb/minimp3-rs ) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/germangb/minimp3-rs/releases )
- [Commits](https://github.com/germangb/minimp3-rs/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-27 13:20:14 -07:00
dependabot-preview[bot]
9db07eb997
build(deps): bump minimp3 from 0.3.5 to 0.4.0
...
Bumps [minimp3](https://github.com/germangb/minimp3-rs ) from 0.3.5 to 0.4.0.
- [Release notes](https://github.com/germangb/minimp3-rs/releases )
- [Commits](https://github.com/germangb/minimp3-rs/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-26 09:57:40 -07:00
Mike Welsh
f55bac2014
text: HTML tags and attributes are case insensitive ( fix #1021 )
...
Use eq_ignore_ascii_case when parsing HTML tags. Different versions
of Flash may export HTML tags with different cases, so this will
work a little better; however, we'll need a true HTML parser to
handle this robustly (for opening and closing tags with different
cases, for example).
2020-08-24 11:27:14 -07:00
Mike Welsh
febada8a8e
text: Fix duplicated characters when parsing HTML entities ( fix #1026 )
2020-08-24 11:27:14 -07:00
Mike Welsh
e8178c35a3
core: Add MouseWheel player event
2020-08-23 13:38:59 -07:00
kmeisthax
559bc05b6a
avm2: Implement avm2 math opcodes (merge #1037 )
...
* Implement `add`, with tests.
* Implement `add_i`.
There's no test, because for whatever reason, I can't figure out how to emit this from Animate CC 2020.
* avm2: Implement `bitand` with tests.
* Implement `bitnot` with tests.
* Implement `bitor` with tests.
* avm2: Implement `bitxor`
* avm2: Implement `declocal`, `declocal_i`, `decrement`, and `decrement_i`.
* tests: `swf_approx` tests should be allowed to print NaNs.
* avm2: Implement `divide`.
* avm2: Implement `inclocal`, `inclocal_i`, `increment`, and `increment_i`.
* avm2: Implement `lshift`.
* Implement `modulo`.
* avm2: Implement `multiply` and `multiply_i` (no tests for the latter)
* avm2: Implement `negate` and `negate_i` (no tests for the latter)
* avm2: Implement `rshift`
* avm2: Implement `subtract` and `subtract_i` (the latter without tests)
* avm2: Implement `urshift`.
2020-08-23 13:38:38 -07:00
Mike Welsh
ba05894901
avm1: Don't mutably borrow self in TObject
2020-08-23 02:19:53 -07:00
Mike Welsh
2a84d924bb
chore: Don't mutably borrow self in TDisplayObject
2020-08-22 11:56:19 -07:00
dependabot-preview[bot]
5d2ba7fee6
build(deps): bump syn from 1.0.38 to 1.0.39
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.38 to 1.0.39.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.38...1.0.39 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-21 12:54:02 -07:00
Mike Welsh
06b6d14367
avm1: Fix removeMovieClip depth range
...
removeMovieClip should only function on objects within a certain
depth range, usually to prevent removing timeline clips. However,
this wasn't working properly in some cases because the depth was
being biased incorrectly (removeMovieClip never takes a depth
parameter, so we should not bias the depth).
2020-08-21 00:55:35 -07:00
Mike Welsh
528b52ac7c
tests: Activate unused remove_movie_clip test
2020-08-21 00:55:35 -07:00
Mike Welsh
1e6a053c56
avm1: Implement TargetPath
2020-08-20 18:14:01 -07:00
Mike Welsh
bbc5e01009
tests: Add test for targetPath action
2020-08-20 18:14:01 -07:00
Mike Welsh
e9f9cda34d
tests: Rename target_path test to string_path
2020-08-20 18:14:01 -07:00
Mike Welsh
b8f5a405b9
tests: Add test for flash.geom.Transform
2020-08-20 17:29:04 -07:00
Mike Welsh
ca3ed34c2c
avm1: Implement flash.geom.Transform
2020-08-20 17:29:04 -07:00
Mike Welsh
0a81dae7bb
avm1: toString for display objects
2020-08-18 01:18:15 -07:00
Mike Welsh
cefc0ce5c1
core: Add button children to execution list
...
Children of buttons were not getting linked up into the execution
list, which would cause certain methods to be incorrect (such as
button._width).
2020-08-18 01:18:15 -07:00
Mike Welsh
d2c49c0f33
core: Remove some mut from TDisplayObject methods
2020-08-18 01:18:15 -07:00
Mike Welsh
544c1becc2
tests: Add test for button children
2020-08-18 01:18:15 -07:00
Mike Welsh
59ebd0167e
core: Fix priority of conflicting instance names
2020-08-18 01:18:15 -07:00
Mike Welsh
b5c7e1dab0
tests: Add test for conflicting instance names
2020-08-18 01:18:15 -07:00
Mike Welsh
13b4b6bbbb
chore: Fix unused variable warning in url_from_relative_path
2020-08-16 18:44:57 -07:00
Floens
95acc14190
avm1: fix array unshift
...
update array_trivial test for it
2020-08-16 04:27:09 -07:00
Mike Welsh
f782ea8020
avm2: AVM2 built-in class suport (merge #802 )
...
Initial support for defining built-ins in AVM2
2020-08-16 03:45:02 -07:00
David Wendt
4c824fcefe
Rename `trait.rs` to `traits.rs` to avoid the use of reserved keyword syntax.
2020-08-14 21:20:41 -04:00
David Wendt
7b7f0b20e6
Consolidate all of our copied `CollectWrapper`s.
2020-08-14 20:52:09 -04:00
Albert Safin
e03373bceb
avm1: parseInt
2020-08-13 00:40:20 -07:00
Mike Welsh
cbd448522a
chore: Allow unknown clippy lints
...
same_item_push was added on nightly, but is currently throwing
a false negative. I added an allow for it, but this causes a
warning on stable for an unknown lints, so allow unknown lints for
now.
2020-08-12 23:51:12 -07:00
Mike Welsh
6c89869210
chore: Fix clippy lints
2020-08-12 19:04:14 -07:00
dependabot-preview[bot]
9b6dd45439
build(deps): bump smallvec from 1.4.1 to 1.4.2
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.4.1 to 1.4.2.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.4.1...v1.4.2 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-12 11:13:33 -07:00
David Wendt
825eb34c67
avm1: `Button` should not hold write locks on itself when instantiating children.
...
This fixes a bug where a nested textfield within a button with variable linkages would panic in Ruffle.
2020-08-12 11:08:27 -07:00
David Wendt
354b194b69
avm1: Add test for nested text fields in buttons.
2020-08-12 11:08:27 -07:00
David Wendt
32aad6176b
`FunctionObject::from_builtin_constr` should pull the scope and class off of it's given prototype and copy it onto the constructor function it returns.
2020-08-11 00:04:13 -04:00
David Wendt
11ddccfa6a
Remove the two-step initialization process and construct an ES4 class for `Object`, `Function`, and `Class`.
...
This has some particularly annoying consequences for initialization order: notably, we can't actually create any ES4 classes using the standard machinery until after the three objects I just mentioned get created. Ergo, we have to create them through lower-level means, handing prototypes around, and then initialize AVM2's system prototypes list for it.
When we start adding more system prototypes, we'll also have to fill the extras with blank objects and then slot them in as we create them.
2020-08-11 00:02:12 -04:00
David Wendt
16d8c85d20
Load player globals as soon as possible.
...
We're about to massively change the initialization process, and we really don't want to create another situation where the player can get caught with it's pants down.
2020-08-10 23:35:37 -04:00
David Wendt
a8e267ed16
Allow system prototypes to be initialized after the fact.
2020-08-10 23:35:37 -04:00
David Wendt
b1bcceaa78
Allow accessing the `Class` off of a constructor or prototype that references it.
2020-08-10 23:35:33 -04:00
David Wendt
22ec96b85e
`install_trait` and `install_foreign_trait` should return the value of the thing they installed.
2020-08-10 23:23:35 -04:00
David Wendt
df95482eb1
Allow setting `slot_id` or `disp_id` (depending on kind).
2020-08-10 23:23:34 -04:00
David Wendt
4ed5050f56
Add function to change trait attributes.
2020-08-10 23:23:34 -04:00
David Wendt
a5b62e833e
Add trait attributes, similar to that of class attributes
2020-08-10 23:23:31 -04:00
David Wendt
60d42fa558
Allow creating slot/const traits.
2020-08-10 23:19:22 -04:00
David Wendt
3ca8dfd21a
Allow constructing traits for getters, setters, and unbound free functions.
2020-08-10 23:19:22 -04:00
David Wendt
d366ceab0e
Allow setting the protected namespace of a builtin class.
2020-08-10 23:19:21 -04:00
David Wendt
9dc6cbe1ce
Allow creating builtin traits from methods.
2020-08-10 23:19:21 -04:00
David Wendt
5e932bcb75
Allow implementing interfaces in built-in classes.
2020-08-10 23:19:20 -04:00
David Wendt
94d5170277
When manually instantiating classes for globals, make sure that the classes get the global scope object when instantiated.
2020-08-10 23:19:15 -04:00
David Wendt
3585cf983b
Convert our stub implementations of all non-ECMA classes into `Class`es.
...
This was surprisingly tricky - due to the need to look up superclasses, class trait instantiation requires an active `Activation` and `UpdateContext`. We can't get those during VM instance creation, since the player needs the VM first before it can give it a context to work with. Ergo, we have to tear the global scope initialization in two. At the first possible moment, the player calls a new `load_player_globals` method that initializes all class traits in global scope.
2020-08-10 23:16:07 -04:00
David Wendt
6f284f60eb
Allow constructing a trait from a class.
2020-08-10 23:09:16 -04:00
David Wendt
b0b6cec117
Allow expanding a `QName` into a `Multiname` that selects exactly the `QName` and no more.
2020-08-10 23:09:15 -04:00
David Wendt
f09c35c4b9
`From<NativeMethod<'gc>>` doesn't always work, but using an explicit non-trait method sometimes does.
...
I have no idea why this is necessary - I was in a context where what *should* have been a `NativeMethod<'gc>` was instead being interpreted as some different function type with all the same lifetimes, but with an extra `'gc` lifetime as well. Funneling this through a non-trait method bypasses whatever is going on with the trait solver, and then at that point the trait solver knows what to do. Consider this an extra level of conversion.
2020-08-10 23:09:15 -04:00
David Wendt
4a2a456666
`Class::new` should also take the superclass name.
2020-08-10 23:09:13 -04:00
David Wendt
d96596fd8a
Add a function to manually change attributes.
2020-08-10 23:07:16 -04:00
David Wendt
44b8e5d9c7
Wrap up the existing sealed/final/interface bits in a `ClassAttributes` enumset.
2020-08-10 23:07:13 -04:00
David Wendt
bf6ccfeee1
Add some convenience functions for defining native classes.
2020-08-10 23:02:42 -04:00
David Wendt
c2cdc302c3
Remove further unnecessary primitive comparison checks
2020-08-10 16:38:04 -07:00
David Wendt
993f56798e
Extract all of the numerical conversions into a separate module and leverage them where appropriate in AVM2
2020-08-10 16:38:04 -07:00
David Wendt
566b262d60
Move all our custom object implementations into a separate module, and use a macro to implement them.
2020-08-10 16:38:04 -07:00
David Wendt
5bcd1be270
Remove another instance of `abs` for zero-checks.
2020-08-10 16:38:04 -07:00
David Wendt
2f55c08e37
`pushbyte` should generate signed integers rather than `Number`s.
2020-08-10 16:38:04 -07:00
David Wendt
7f479f24b9
Adjust `coerce_to_string` to be less silly.
2020-08-10 16:38:04 -07:00
David Wendt
a12f51903f
Non-finite covers everything here.
2020-08-10 16:38:04 -07:00
David Wendt
2e8acfe6f7
Apparantly, Rust already does not care about negative zero, so we don't need to, either.
2020-08-10 16:38:04 -07:00
David Wendt
1bb6f84beb
Avoid hitting `coerce_to_number` for integer comparison cases.
2020-08-10 16:38:04 -07:00
David Wendt
4e92352813
Don't promote to `f64` in strict-equality comparisons if we can promote to `i64` instead.
2020-08-10 16:38:04 -07:00
David Wendt
a211698464
Handle strict and abstract equality of our various number subtypes as if they were all the same type.
...
ECMA-262 3rd ed. doesn't mention anything about different number types, so the standard as-if rule applies. If we are going to distinguish number types, we have to treat them as if they were the same type, promoting to `f64` as necessary to facilitate the conversion. I took a cursory look at an ECMA-262 4th ed. draft and it appears to do the same, although it calls everything `GeneralNumber` and has some really confusing psuedo-Pascal syntax for some reason.
I am extremely glad AVM2 does not provide access to 64-bit integer types (for now, at least).
2020-08-10 16:38:04 -07:00
David Wendt
f3e47cb596
Further adjustments due to the massive refactor of `Activation`, `AvmX`, and `UpdateContext`.
2020-08-10 16:38:04 -07:00
David Wendt
ea4c42a6d1
Split `Value::Number` into separate floating-point, integer, and unsigned representations to match the three numerical classes provided by AS3.
2020-08-10 16:38:04 -07:00
David Wendt
a0895e843c
Fix `matches!` lint in nightly Rust being tripped.
2020-08-10 16:38:04 -07:00
David Wendt
b779dccdc1
Allow objects to provide a coercion hint for cases where a more obvious one is not available.
2020-08-10 16:38:04 -07:00
David Wendt
d14fa845c2
Remove `Value::Namespace`.
...
Namespaces as values adds a bunch of extra special cases to the coercion and equality rules that don't really belong there. Namespace itself just returns it's URI as a string, so we can just make `NamespaceObject` do that and then treat it the same way we treat boxed primitives.
2020-08-10 16:38:04 -07:00
David Wendt
e6aac48ae2
Add `NamespaceObject` to hold `Namespace`s.
...
The reason for this will become very apparent, very shortly.
2020-08-10 16:38:04 -07:00
David Wendt
aeb1752d0f
`PrimitiveObject`'s `toString` and `valueOf` should always yield their boxed values.
2020-08-10 16:38:04 -07:00
David Wendt
65b4392642
Remove `as_number`.
...
The only code that used it was the enumeration operations in AVM2.
2020-08-10 16:38:04 -07:00
David Wendt
4906c5a3f1
Remove uses of `as_string` in various places.
...
These include:
* Name resolution in `newobject`
* All runtime & late-bound multinames
* `Object.hasOwnProperty`
* `Object.propertyIsEnumerable`
* `Object.setPropertyIsEnumerable`
2020-08-10 16:38:04 -07:00
David Wendt
c040997be2
*Actually* fix the conversion.
...
So, I overlooked this reading the 1.45 documentation, but the first thing they did is completely change f64 conversions. Apparantly, what I was doing (and what JavaScript spec dictates) is actually considered UB in LLVM, and my ability to actually write a concise wrapping u32 conversion is actually a soundness hole in Rust. Ergo, I'm now emulating the wrapping and sign calculation, which makes this both passing it's tests again and free of soundness holes and UB.
2020-08-10 16:38:04 -07:00
David Wendt
473414e167
Explicitly request `u64` be involved with `u32` coercions.
...
I don't know why I'm doing this - tests are failing in CI but not locally, and I can only assume that the most obvious conversion is broken in some way on whatever other architecture GitHub Actions uses. This will explicitly mask the integer result as a u64, and then convert it down to u32. A not-broken compiler should treat this code identically.
2020-08-10 16:38:04 -07:00
David Wendt
962f6aa54c
Remove `as_object`.
...
AVM2 is based on ES4, which as far as I'm aware, does not distinguish between "primitive values" and "objects". Thus, it is expedient to interpret any statement requiring something to be an Object to mean "not null or undefined".
Since we internally represent register values with primitive types, it is important that the VM always coerces to object before doing any other sort of type checking. Hence, something like `as_object` is unhelpful as it accidentally enforces a primitive/object distinction that ES4 attempted to remove.
2020-08-10 16:38:04 -07:00
David Wendt
8de063a916
Implement automatic primitive boxing via `coerce_to_object`.
2020-08-10 16:38:04 -07:00
David Wendt
f12f67650b
Stub all primitive type classes.
2020-08-10 16:38:04 -07:00
David Wendt
cb0f1e9099
Add a new object variant for boxed primitives.
2020-08-10 16:38:04 -07:00
David Wendt
6ec1d453b8
Add tests for `greaterequals`, `greaterthan`, `lessequals`, and `lessthan`.
2020-08-10 16:38:04 -07:00
David Wendt
b7dfce51b8
Implement `greaterequals`, `greaterthan`, `lessequals`, and `lessthan`.
2020-08-10 16:38:04 -07:00
David Wendt
f88f2e225a
Add tests for `>`, `<`, `<=`, and `>=`.
...
Note that this does NOT completely test the full range of if instructions for abstract relational comparison. Notably, the Adobe Animate CC compiler compiles each operator into it's negated equivalent, e.g. `<` becomes `ifnlt`.
I do not know how to get it to emit `ifge` or the like, which differ only by how they handle `NaN`s.
2020-08-10 16:38:04 -07:00
David Wendt
730c47cf29
Implement `ifge`, `ifgt`, `ifle`, `iflt`, `ifnge`, `ifngt`, `ifnle`, and `ifnlt`.
2020-08-10 16:38:04 -07:00
David Wendt
70a27ccb81
Implement ECMA abstract relational comparison
2020-08-10 16:38:04 -07:00
David Wendt
2ef03c6019
Allow no-hint primitive coercion
2020-08-10 16:38:04 -07:00
David Wendt
76ab8570e4
Implement and test `equals`.
...
The test is also far more in-depth than the `if_eq`/`if_ne` tests, which use the same set of vectors as the strict-equality tests from a while ago. Interestingly, this test passed on first run
2020-08-10 16:38:04 -07:00
David Wendt
5da4e2f118
Test for `iseq` and `isne`
2020-08-10 16:38:04 -07:00
David Wendt
29d5ae9989
Implement `ifeq` and `ifne`.
2020-08-10 16:38:04 -07:00
David Wendt
ccc478e7dd
Implement ECMA-262 abstract equality.
2020-08-10 16:38:04 -07:00
David Wendt
0125a14d1f
Partially implement `ToObject` coercion.
...
Implementation is limited to generating exceptions on `null` or `undefined`. I'm not sure if primitive values don't exist in AVM2 or if this is supposed to box them like ES3, so I have decided to handle neither at this time.
2020-08-10 16:38:04 -07:00
David Wendt
86965eb674
Test for `coerce_s`.
...
I cannot yet figure out how to generate tests that use `convert_s`, so it's not covered.
2020-08-10 16:38:04 -07:00
David Wendt
0138300b5a
Implement `coerce_s` and `convert_s`.
2020-08-10 16:38:04 -07:00
David Wendt
90d2964adf
Properly handle all cases of ECMA-262 string coercions.
...
This code is slightly over/under-precise compared to AVM2. This is because we handle precision limiting in binary floats rather than as part of the float printing process. Flash Player may also be rounding differently than us. However, I'm pretty sure ECMA-262 allows us to slightly differ here.
2020-08-10 16:38:04 -07:00
David Wendt
35f939cb15
Add and test for `convert_u` using `ToUint32` from ECMA-262
2020-08-10 16:38:04 -07:00
David Wendt
6eb41035cf
Add & test ECMA-262 ToInt32 and `convert_i` opcode.
...
The ECMA-262 documentation is awfully overwrought for something that boils down to "chop off the non-whole part, wrap to 32 bits, then reinterpret as signed". Bitwise operations are *hell* to describe mathematically, and such descriptions are even harder to understand.
2020-08-10 16:38:04 -07:00
David Wendt
351fe026e9
Add a test for all the above numerical coercions.
2020-08-10 16:38:04 -07:00
David Wendt
4c1489a814
Promote bytes to signed representation before pushing.
...
For whatever reason, `pushbyte` appears to be processed as a *signed* byte, despite the clear wording of "*byte_value* is an unsigned byte" in avm2overview.pdf. I guess it's supposed to be manually converted and promoted in this manner.
2020-08-10 16:38:04 -07:00
David Wendt
736a94a244
Implement numerical coercions according to ECMA-262 3rd Edition spec.
2020-08-10 16:38:04 -07:00
David Wendt
24fd30652d
Allow tracing numbers to the console.
2020-08-10 16:38:04 -07:00
David Wendt
60f9613365
Implement and test for `convert_b`.
2020-08-10 16:38:04 -07:00
David Wendt
6cf48eb543
Implement and test `not`.
2020-08-10 16:38:04 -07:00
David Wendt
b972c24f7e
Oh look, I figured out how to emit `istrue`, so that's tested, too.
2020-08-10 16:38:04 -07:00
David Wendt
850ebc88a2
Add test for truthiness.
...
As compiled by Adobe Animate CC 2020, this test appears to only use `iffalse`. However, both `op_is_false` and `op_is_true` coerce in the same manner, so I'm not entirely sure this is a problem for now.
2020-08-10 16:38:04 -07:00
David Wendt
e5c8c5b340
Expose `Infinity` to AS3.
2020-08-10 16:38:04 -07:00
David Wendt
5bb8c1836f
Replace `as_bool` with `coerce_to_bool`.
...
Functions that need to assert Boolness without coercion should either:
1. Ensure their function declaration requires a Boolean. (We don't enforce type errors on ES4 typehints yet, but we should.)
2. Check the value type themselves and raise their own errors if necessary.
As it stands the only users of `as_bool` either needed to check the type themselves or use `coerce_to_bool`. Notably, `setPropertyIsEnumerable` doesn't appear to coerce *or* throw an error: it instead fails silently if you hand it a non-`Boolean` value.
2020-08-10 16:38:04 -07:00
dependabot-preview[bot]
04b146ffc4
build(deps): bump enumset from 1.0.0 to 1.0.1
...
Bumps [enumset](https://github.com/Lymia/enumset ) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/Lymia/enumset/releases )
- [Changelog](https://github.com/Lymia/enumset/blob/master/RELEASES.md )
- [Commits](https://github.com/Lymia/enumset/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-09 13:15:38 -07:00
dependabot-preview[bot]
178178d9dd
build(deps): bump indexmap from 1.5.0 to 1.5.1
...
Bumps [indexmap](https://github.com/bluss/indexmap ) from 1.5.0 to 1.5.1.
- [Release notes](https://github.com/bluss/indexmap/releases )
- [Commits](https://github.com/bluss/indexmap/compare/1.5.0...1.5.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-08 13:37:32 -07:00
dependabot-preview[bot]
53d32d4dac
build(deps): bump num_enum from 0.5.0 to 0.5.1
...
Bumps [num_enum](https://github.com/illicitonion/num_enum ) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/illicitonion/num_enum/releases )
- [Commits](https://github.com/illicitonion/num_enum/compare/0.5.0...0.5.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-05 16:00:27 -07:00
dependabot-preview[bot]
0c7edda6c2
build(deps): bump syn from 1.0.37 to 1.0.38
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.37 to 1.0.38.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.37...1.0.38 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-05 15:59:02 -07:00
unknown
47a8eb6f3e
avm1: Copy broadcast functions for MovieClipLoader
2020-08-04 07:02:14 -07:00
dependabot-preview[bot]
f8aa185c3e
build(deps): bump syn from 1.0.36 to 1.0.37
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.36 to 1.0.37.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.36...1.0.37 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-03 16:57:45 -07:00
David Wendt
8cb6e4af39
Further adjustments that fell through before.
2020-08-01 16:11:11 -04:00
David Wendt
4dbd26807e
Remove useless lifetime in `notify_system_listeners`
2020-08-01 15:49:29 -04:00
David Wendt
8ebf5405e2
Move AVM2 into the UpdateContext.
2020-08-01 15:49:29 -04:00
David Wendt
bfa5f8ae35
Further compilation fixes necessary to get the refactor to compile again.
...
Notably, all of the `Avm1` "run stack frame" functions can no longer take a self parameter as the update context they will be getting also has that same parameter. Ergo, they're associated functions that get the moral equivalent of self from the update context.
This also introduces a new `Activation::from_stub` which creates a stub frame that runs everything on the main movie in layer 0. This significantly reduces boilerplate code elsewhere in the project.
2020-08-01 15:49:28 -04:00
David Wendt
9b089ae1d7
Convert `array.rs` to the new activation-only format.
...
This also removes the function parameter on `sort_compare_numeric`. As it was only being used for string comparisons, and it was causing unfixable lifetime issues, I have instead had it take the case-sensitivity flag and call the two functions it would have been passed anyway. This fixes the lifetime issue.
2020-08-01 15:49:26 -04:00
David Wendt
a19595c8b4
Embed `UpdateContext` in `Activation` directly.
...
The process of constructing an `Activation` now involves calling `UpdateContext.reborrow`, which "sheds" a lifetime by copying all of the borrows into a new "owned" context with that lifetime.
Likewise, to call out to functions that don't need an `Activation`, just borrow the context out of the current activation. You can also construct child-frame activations by reborrowing the parent activation's context.
2020-08-01 15:49:19 -04:00
David Wendt
7c7b019087
Move AVM1 inside UpdateContext.
2020-08-01 13:44:04 -04:00
David Wendt
14bfbc358f
wip: Move UpdateContext into Activation
2020-08-01 13:33:04 -04:00
David Wendt
9f76a7b964
Ensure that `Player` always has a movie in level zero, even if no movie has been queued up yet.
...
There is a race condition inadvertently caused by allowing movies to be fetched in slot 0: it is possible for the player to be caught mid-load without a root movie. A lot of code assumes level 0 always exists (e.g. `levels.get(0).unwrap()`), while our initialization methods assumed no Player methods would be called until the root movie is installed. This is an unreasonable assumption, as among other things users can trigger the race condition by just playing the movie too quickly.
2020-08-01 02:35:00 -07:00
Nathan Adams
26b14bd904
avm1: Undone some __constructor__ setting on objects that don't actually construct
2020-08-01 02:33:14 -07:00
Nathan Adams
db4f5007f3
avm1: TObject::create_bare_object doesn't use or need args
2020-08-01 02:33:14 -07:00
Nathan Adams
79af3ffe44
avm1: Rename TObject::new to TObject::create_bare_object
2020-08-01 02:33:14 -07:00
Nathan Adams
2131f7860b
avm1: Change Object::construct to create and return a new object, instead of requiring the caller to do that first
2020-08-01 02:33:14 -07:00
Nathan Adams
e74d4f0abb
avm1: Make FunctionObject::allocate_function require prototype, it's not optional
2020-08-01 02:33:14 -07:00
Nathan Adams
fb7fb6f99a
avm1: Make FunctionObject::functional require prototype, it's not optional
2020-08-01 02:33:14 -07:00
Nathan Adams
9123d92513
avm1: Make FunctionObject::constructor require prototype, it's not optional
2020-08-01 02:33:14 -07:00
Nathan Adams
691e3b6804
avm1: Make FunctionObject::function_and_constructor require prototype, it's not optional
2020-08-01 02:33:14 -07:00
Nathan Adams
88a31cc5a9
avm1: Ensure we call movie constructors through Function::construct, not manually, to set __constructor__
2020-08-01 02:33:14 -07:00
Nathan Adams
69a4d10338
avm1: Replace manual constructor calling with Function::construct, to ensure we set __constructor__
2020-08-01 02:33:14 -07:00
Nathan Adams
2faf35d43e
avm1: Set __constructor__ in Function::construct
2020-08-01 02:33:14 -07:00
unknown
d6eeb723dc
avm1: Fix panic in broadcastMessage
2020-07-29 15:24:23 -07:00
unknown
1d17910b6d
chore: Remove an unnecessary file
2020-07-29 15:24:23 -07:00
unknown
ef4240e95d
chore: Satisfy rustfmt and clippy
2020-07-29 15:24:23 -07:00
unknown
a14f19e9e5
avm1: Call the respective listeners
2020-07-29 15:24:23 -07:00
unknown
795cd72dce
avm1: Broadcasting functions are now copied from AsBroadcaster
2020-07-29 15:24:23 -07:00
unknown
b72dbcae96
chore: Assert his inside of listeners
2020-07-29 15:24:23 -07:00
unknown
df50cbb27f
avm1: Fix the behavior of addListener and removeListener
2020-07-29 15:24:23 -07:00
unknown
20989ef03d
avm1: Initialize now copies the functions from AsBroadcaster
2020-07-29 15:24:23 -07:00
unknown
3a0af11e34
chore: Run rustfmt
2020-07-29 15:24:23 -07:00
unknown
890dc0ea13
avm1: Implement AsBroadcaster
2020-07-29 15:24:23 -07:00
Nathan Adams
32be19da6d
avm1: Allow gotoAndStop/gotoAndPlay with frame numbers in paths - #915
2020-07-29 13:53:57 -07:00
Mike Welsh
5d08956152
tests: Add typeof and labels for Object() test
2020-07-29 13:52:51 -07:00
CUB3D
0fe3a23fd6
core: Correct handling of Object function without args
2020-07-29 13:52:51 -07:00
CUB3D
49bee3fe5c
core: Implement Object() function
2020-07-29 13:52:51 -07:00
CUB3D
fa8b2bca8b
chore: Fix formatting
2020-07-27 12:50:31 -07:00
CUB3D
c1771d7d4e
core: Split function and constructor, tests, fix bug with constructor
2020-07-27 12:50:31 -07:00
CUB3D
4217138d1a
chore: Update comment
2020-07-27 12:50:31 -07:00
CUB3D
7792487181
chore: Fix clippy lints
2020-07-27 12:50:31 -07:00
CUB3D
afb1d6b42f
core: Add global Array() function
2020-07-27 12:50:31 -07:00
CUB3D
22db5ab76a
core: Populate function when creating a constructor
2020-07-27 10:38:50 -07:00
CUB3D
01b7e73459
core: Fix build
2020-07-27 10:38:50 -07:00
CUB3D
adb9af5a62
core: Update arguments
2020-07-27 10:38:50 -07:00
CUB3D
7b66968ebb
core: Cleanup
2020-07-27 10:38:50 -07:00
CUB3D
5f87b1361b
core: Update NewMethod action and update globals to use constructor
2020-07-27 10:38:50 -07:00
CUB3D
e83dbf7327
core: Split construct and call for function objects
2020-07-27 10:38:50 -07:00
Nathan Adams
337e3292dd
avm1: Treat MovieClipLoader _listeners as an array, not an object
2020-07-27 05:36:28 -07:00
dependabot-preview[bot]
ed07ea6db2
build(deps): bump syn from 1.0.35 to 1.0.36
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.35 to 1.0.36.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.35...1.0.36 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-27 05:17:11 -07:00
Nathan Adams
17344613e3
core: Lock variable dumping behind avm_debug
2020-07-27 04:13:31 -07:00
Nathan Adams
e98b953088
avm1: Use avm_warn and avm_error in all of avm1
2020-07-27 04:13:31 -07:00
Nathan Adams
10a739f714
avm1: Always assign function names (where possible) when running in avm_debug, not just when spamming output
2020-07-27 04:13:31 -07:00
Nathan Adams
810e231b8b
avm1: Add macros for more advanced log/error printing when avm_debug is on
2020-07-27 04:13:31 -07:00
Mike Welsh
e5480ee9b2
chore: Use matches! to fix clippy lint
2020-07-27 04:13:11 -07:00
Nathan Adams
f1f04e0e7a
avm1: Fixed a bunch of cases where we're using _level0 instead of current object ( fixes #926 )
2020-07-27 01:40:28 -07:00
Nathan Adams
cf61f8a4d3
avm1: Add failing test for registerClass in a loaded movie
2020-07-27 01:40:28 -07:00
Mike Welsh
8ac2ad9b40
avm1: Store movie URL on load and implement _url (merge #912 )
2020-07-27 01:38:28 -07:00
David Wendt
acd7ceb706
Fix missing import on web.
2020-07-25 22:20:30 -04:00
David Wendt
153b7b78a5
Add a web version of `url_from_relative_path` that just yields an error.
...
This allows us to remove the conditionals on implementations of `from_path` that need to call this function, as the function is now always guaranteed to be there, even if it's just a no-op/`Err` generator.
2020-07-25 19:48:32 -04:00
Mike Welsh
07122dc931
avm1: Implement Key listeners
2020-07-24 14:32:41 -07:00
Mike Welsh
85d9caef56
avm1: All properties of _global are DontEnum
2020-07-23 22:58:58 -07:00
Mike Welsh
794dc69809
avm1: Implement isFinite
2020-07-23 22:58:58 -07:00
David Wendt
aed47d458d
Level loads in GetURL2 should also propagate origin information.
2020-07-23 23:09:08 -04:00
David Wendt
a34e81a704
`_url` on desktop should always return a file URL for file-loaded movies.
2020-07-23 23:02:56 -04:00
David Wendt
f0e2c77c1f
URLs from paths is a desktop-only feature.
2020-07-23 23:02:55 -04:00
David Wendt
9b9d4076fe
Expose movie URL to ActionScript.
2020-07-23 23:02:55 -04:00
David Wendt
a8877ab63c
Yield the correct error when the root movie load fails.
2020-07-23 23:02:55 -04:00
David Wendt
d172441663
Also make absolute URLs for all movie loads passed through the load manager.
2020-07-23 23:02:54 -04:00
David Wendt
5d15f5bfe3
When loading a movie from the filesystem outside of the core, ensure that the URL is properly made absolute.
2020-07-23 23:02:54 -04:00
David Wendt
c926da8888
Refactor URL relativization into two utility methods that backends can provide base URLs and paths to.
2020-07-23 23:02:54 -04:00
David Wendt
7433bfe28f
Add a `NavigatorBackend` method to resolve relative URLs.
2020-07-23 23:02:53 -04:00
David Wendt
4813942fe7
The player should always change the audio backend's framerate itself.
2020-07-23 23:02:52 -04:00
David Wendt
f56d16a68d
Separate player creation from root movie setup, and allow users of Ruffle to load in movies synchronously or asynchronously.
...
During the small period of time when a player is created but has no root movie, a temporary empty movie is installed with an assumed stage size and framerate of 550x400@12fps. This is Flash default for new projects, so it seemed appropriate. User ActionScript cannot see these values, and I'm not even sure JavaScript can, either.
2020-07-23 23:02:51 -04:00
David Wendt
6998dafdb9
Store an origin URL on every movie that is loaded.
2020-07-23 23:02:50 -04:00
Nathan Adams
7f7281493f
core: Allow toggling avm_debug output on and off with ctrl+alt+d, defaults to off
2020-07-23 19:14:32 -07:00
Mike Welsh
efa059ff8d
tests: Add test for LoadVars
2020-07-23 03:00:19 -07:00
Mike Welsh
1709e76409
avm1: Implement LoadVars
2020-07-23 03:00:19 -07:00
Mike Welsh
74cb8609c1
avm1: Support loading into _level in GetURL2
...
Calling loadMovieNum with a variable parameter compiles into a
GetURL2 call with a `_level` window target parameter. Previously
this triggered Ruffle to try to navigate to the SWF. Now it
properly loads the SWF inside the current movie.
2020-07-23 02:08:48 -07:00
Nathan Adams
f0980301da
avm1: Implement arguments.callee
2020-07-22 15:57:45 -07:00
Nathan Adams
4a56cb1062
avm1: Make virtual properties store Object instead of Executable, so we can refer to the callee
2020-07-22 15:57:45 -07:00
Nathan Adams
f4ab57d6e0
avm1: Make property watchers take Object, not Executable, so we can track the callee
2020-07-22 15:57:45 -07:00
Nathan Adams
9ae10b6387
avm1: Made AvmString debug actually show contents of the string
2020-07-22 13:23:57 -07:00
Nathan Adams
3b2b7c226c
avm1: Fix gc unsoundness with missing collects in SystemPrototypes
2020-07-21 09:43:07 -07:00
Nathan Adams
0e0be34e17
avm1: Fix compile error when using avm_debug flag
2020-07-21 09:42:41 -07:00
Nathan Adams
d5deeee1b7
avm1: Properly implement the arguments object, it's an array
2020-07-21 07:49:00 -07:00
dependabot-preview[bot]
aa966fbfb6
build(deps): bump syn from 1.0.34 to 1.0.35
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.34 to 1.0.35.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.34...1.0.35 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-20 14:24:56 -07:00
Mike Welsh
1a5d7fe452
avm2: Initial AVM2 interpreter (merge #404 )
...
Initial work on the AVM2 interpreter.
2020-07-19 19:59:05 -07:00
David Wendt
7adabc8166
Use `unwrap_or_default`
2020-07-18 17:28:07 -04:00
David Wendt
44b924d7b4
`Script` should not hold write locks when probing it's internal caches.
2020-07-18 17:26:11 -04:00
Mike Welsh
034c125b80
core: Support radial gradients in morph shapes
...
Radial gradients were not accounted for in morph shapes.
Clean up the interpolation code and add support for radials.
Fixes #591 .
2020-07-18 14:12:04 -07:00
David Wendt
575a9b091a
Use FnvHashMap for the translation unit pools.
2020-07-18 17:02:52 -04:00
David Wendt
262bb148f1
Rename `a2me` to `entry` (or `method` in one case where it lets me simplify a struct declaration)
2020-07-18 17:02:32 -04:00
David Wendt
c415190376
Zero-index multinames should generate a validation error in `QName::from_abc_multiname`.
2020-07-18 16:48:10 -04:00
David Wendt
dc962f2abd
Add AVM2 equivalent of `PropertyMap` for further expansion.
2020-07-18 16:41:35 -04:00
David Wendt
37b6b89d26
Add a stub AVM2 string representation to allow for both VMs' strings to diverge.
2020-07-18 16:20:58 -04:00
David Wendt
ccacc540bf
Remove dead code on all now-in-use structs and methods.
2020-07-18 16:12:24 -04:00
dependabot-preview[bot]
0bd7f07649
build(deps): bump png from 0.16.6 to 0.16.7
...
Bumps [png](https://github.com/image-rs/image-png ) from 0.16.6 to 0.16.7.
- [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/compare/v0.16.6...v0.16.7 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-18 12:36:46 -07:00
Mike Welsh
ae7db80ea3
avm1: Move getURL to MovieClip.prototype ( fix #804 )
...
For example, _root.getURL should work.
2020-07-18 01:03:47 -07:00
dependabot-preview[bot]
ee2222a425
build(deps): bump indexmap from 1.4.0 to 1.5.0
...
Bumps [indexmap](https://github.com/bluss/indexmap ) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/bluss/indexmap/releases )
- [Commits](https://github.com/bluss/indexmap/compare/1.4.0...1.5.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-17 20:51:05 -07:00
Mike Welsh
8ecae5a87f
avm1: duplicateMovieClip copies clip events
...
Clip events should be copied from the source clip to the newly
created clip. Fixes objects remaining onscreen in #815 .
2020-07-17 20:49:05 -07:00
Mike Welsh
8c1ec01d75
tests: Test clip events copying in duplicateMovieClip
...
duplicateMovieClip should also copy any clip events on the source
clip to the newly created movie clip.
2020-07-17 20:49:05 -07:00
Mike Welsh
7c52a1bcc4
avm1: Accept path strings in ActionCall ( fix #832 )
2020-07-14 23:34:21 -07:00
Mike Welsh
b43fdca4ad
avm1: resolve_text_field_variable -> resolve_variable_path
2020-07-14 23:34:21 -07:00
Mike Welsh
f9b1c586d1
tests: Add test for paths in ActionCall
2020-07-14 23:34:21 -07:00
David Wendt
e354c53075
Remove any remaining uses of `abc_ref`.
...
Holding a `Ref` on a garbage-collected object inherently extends any borrow locks on that object. Since ABC files are references already, taking a `Ref` to them only helps to skip the refcount update. This is less useful than expected: in most situations, using `abc_ref` causes double-borrow panics. The few methods that can use it are going to be fragile in the face of future refactors, so I'm nipping the problem in the bud now.
2020-07-14 20:14:23 -04:00
David Wendt
f4c5075086
Run all string constant retrieval through the `TranslationUnit`, preventing us from making multiple copies of the same string.
...
For good measure, most of the other methods in `value` for retrieving pool primitives now also use `TranslationUnit` instead of `AbcFile`. This is the result of a handful of cascading changes throughout the project, and itself caused a few more.
2020-07-14 20:05:25 -04:00
David Wendt
70e9e7e9e9
Add support for cached/interned pool strings in the `TranslationUnit`.
2020-07-13 23:42:07 -04:00
David Wendt
e1b9b823fc
Remove `abc_string` and replace it with `abc_string_copy`. All code that pulls strings from the ABC file now uses `AvmString`s.
2020-07-13 23:41:46 -04:00
David Wendt
61a3ff8ae6
Replace `String` or `&str` references with `AvmString` everywhere in the AVM2 runtime.
2020-07-13 22:21:18 -04:00
David Wendt
2021cec9d3
Impl `Copy`, `Eq`, `PartialOrd`, `Ord`, and `Hash` for `AvmString`.
2020-07-13 22:09:34 -04:00
David Wendt
508fcd6e9e
`pool_string` should return a `Ref<str>` just like `value::abc_string`.
2020-07-13 17:45:12 -04:00
David Wendt
a406bdada2
Don't attempt to log debugging information if we're not in a debug build.
2020-07-13 17:45:12 -04:00
David Wendt
ae26615bb4
`coerce_string` may return a static string, which we shouldn't clone.
2020-07-13 17:45:12 -04:00
David Wendt
f0c633fe81
Allow borrowing string values from an ABC file instead of cloning everything.
2020-07-13 17:45:11 -04:00
David Wendt
64e5b46259
Add tests for `instanceof` and `is` operators.
2020-07-13 17:45:10 -04:00
David Wendt
39a4566f20
Instances should be listed as their prototypes (empty as they are)
2020-07-13 17:45:10 -04:00
David Wendt
c917b3d411
Implement `istype`, `istypelate`, and `instanceof`.
2020-07-13 17:45:10 -04:00
David Wendt
a0cb052795
Add `is_instance_of` trait method to `TObject`
2020-07-13 17:45:09 -04:00
David Wendt
3fae8b3832
Read the interface list when instantiating classes, resolve them, and stick them in the prototype for later use.
2020-07-13 17:45:09 -04:00
David Wendt
cce68dbc21
Add trait methods for getting and setting the interfaces list.
2020-07-13 17:45:08 -04:00
David Wendt
563a515189
Add a test for loading interfaces into the AVM2.
...
This test will fail if the AVM2 implementation does not support bodyless methods or bare classes properly.
2020-07-13 17:45:07 -04:00
David Wendt
8f2d3315f3
Allow the construction of classes with no base class.
...
This is primarily used for interfaces, in case you can't guess by the previous commit.
2020-07-13 17:45:07 -04:00
David Wendt
5d89d4ed85
Allow methods to not hold a body.
...
Interface methods are specifically not allowed to be called: as a result, they don't get a method body. Existing code assumed a 1:1 relationship between methods and bodies, which causes spurious errors.
2020-07-13 17:45:07 -04:00
David Wendt
090fe56bd3
Wrap `BytecodeMethod` (and the bytecode half of `Executable`) in a `Gc`.
...
This is inspired by Dinnerbone's similar PR on the AVM1 side, where the Action half of that VM's `Executable` was reduced from 128 bytes to 16 by shoving it in a `Gc`. This won't be as dramatic but should still save some memory.
In fact, it should save a *lot* of memory in bytecode execution, where thanks to the previous commit's rebase, we now need to clone the current method once *for each instruction executed*. That is terrible, but should stop now.
2020-07-13 17:45:06 -04:00
David Wendt
97e005622b
Invert the role of `Avm2` and it's `Activation`, similar to what was done with `Avm1` and it's `Activation`.
...
This also results in a far reduced role for `ReturnValue`, since I also took the liberty of removing most of it's use. Furthermore, I also made it apply equally to native and AVM2 code, which ensures all native implementations of methods don't double-borrow.
In AVM1, `ReturnValue` was actually removed entirely, because it's not needed. I attempted to do the same, but the fact that we're currently embedding `ScriptObjectData` in native objects means that we need it for virtual properties. Otherwise, virtual property implementations will see locked objects, which is bad.
2020-07-13 17:45:06 -04:00
David Wendt
5b5bf0719e
Remove `Avm2Function` as it is no longer used.
2020-07-13 17:45:05 -04:00
David Wendt
098b034de0
Refactor method-related structs into a separate method module.
...
This also renames `NativeFunction` and `Avm2MethodEntry` to `NativeMethod` and `BytecodeMethod`, respectively.
2020-07-13 17:45:05 -04:00
David Wendt
b6e05519cd
Remove `Avm2ClassEntry`. It is no longer used.
2020-07-13 17:45:05 -04:00
David Wendt
12fc13da7f
Clippy compliance for the last batch of commits.
2020-07-13 17:45:05 -04:00
David Wendt
041cb0b5c3
Resolve multiname constant zero as an error rather than a panic.
...
While some code that references pool multinames has zero as a valid index, we cannot validate exactly what the zero index is for a given index. Hence, callers instantiating multinames must check for zero and substitute the correct zero-value interpretation for their given type. If zero is an invalid value, it should ideally throw a different error than what's provided here.
2020-07-13 17:45:04 -04:00
David Wendt
0d2235d2e0
Resolve all remaining compilation issues with this refactor.
2020-07-13 17:45:04 -04:00
David Wendt
7684736bf7
`table_class` should resolve `Class`es straight from the current translation unit.
2020-07-13 17:45:04 -04:00
David Wendt
232c29dc5e
Fix remaining problems with method loading using `callstatic`
2020-07-13 17:45:03 -04:00
David Wendt
eaebd3c63c
Make `Avm2MethodEntry` hold it's `TranslationUnit` rather than an `AbcFile`.
2020-07-13 17:45:03 -04:00
David Wendt
4467bc3193
Make `TranslationUnit` a GC-mandatory type (only referred to by `GcCell`).
2020-07-13 17:45:03 -04:00
David Wendt
60f3ae3ba7
Remove `Avm2ScriptEntry`. It is now obsolete and unused.
2020-07-13 17:45:02 -04:00
David Wendt
f549d0146e
Fix compilation bugs involved with automatic script initializer execution.
2020-07-13 17:45:02 -04:00
David Wendt
b4f944b37b
Wrap ABC loading inside of a `TranslationUnit`.
2020-07-13 17:45:01 -04:00
David Wendt
70e9030072
Decouple the entire trait machinery from ABC-provided traits.
...
This commit breaks the build: we still need to tell `Avm2` how to turn ABC traits into our own internal `Trait<'gc>`, `Class<'gc>`, and `Method<'gc>` types. We also need something to track which traits have already been instantiated, because `callstatic` would otherwise reinstantiate the trait in a different scope. (In fact, I think it *does* do exactly that right now...)
2020-07-13 17:45:01 -04:00
David Wendt
15a62d31cb
Add an internal representation of `Trait`, separate from `swf::avm2::types::Trait`, which is specific to the ABC file format.
...
The intention is to completely replace all usage of `Avm2XYZEntry` with `Class`, `Trait`, and `Method`. This will allow runtime-provided global class traits to coexist with those provided by user code.
2020-07-13 17:45:01 -04:00
David Wendt
4cd30455de
Excise `ReturnValue<'gc>` from all `TObject` methods.
...
Inspired by Dinnerbone's PR doing the exact same thing to AVM1.
On AVM2 we have a bit of a subtle issue: the base implementation of `set_property_local` and `init_property_local` *must* return `ReturnValue`s to avoid double-borrows. Each implementation of `TObject` must resolve them before returning.
2020-07-13 17:45:00 -04:00
David Wendt
3362ec09e8
chore: Clippy conformance
2020-07-13 17:45:00 -04:00
David Wendt
fe283e6770
Silence this warning about occupied slots being an unused variant.
...
I don't know if I'm missing something, but I'm pretty sure this variant is reachable via `TObject::install_slot`.
2020-07-13 17:45:00 -04:00
David Wendt
6117288fe2
Add tests for `ifstricteq`, `ifstrictne`, and `strictequals`.
2020-07-13 17:44:59 -04:00
David Wendt
34ab8c8ce6
`NaN` is not special-cased in AS3.
2020-07-13 17:44:59 -04:00
David Wendt
34b3bbae63
*Correctly* implement `ifstricteq` and `ifstrictne`.
...
The previous implementation suffered from copypasta and was attempting to assert that both of it's values were `bool`.
2020-07-13 17:44:59 -04:00
David Wendt
ecfd16cec9
Add global constants `undefined`, `null`, and `NaN`.
2020-07-13 17:44:58 -04:00
David Wendt
03a240ebcd
Add tests for `valueOf`.
2020-07-13 17:44:58 -04:00
David Wendt
b4d907bf2e
Implement `strictequals`.
2020-07-13 17:44:58 -04:00
David Wendt
3b52dfe2ba
Since we have an `es3_inheritance` test now, rename the existing inheritance test to `es4_inheritance`.
2020-07-13 17:44:57 -04:00
David Wendt
cf6714d33c
Implement and test `toLocaleString`.
...
This function has vague documentation about enabling locale-specific formatting in subclasses. As far as I can tell, none of the objects I implemented so far do anything different than `toString`, so I just have it use the same `TObject` property I set up for `toString`.
2020-07-13 17:44:57 -04:00
David Wendt
3558c3afa0
Add test of `Function.prototype.call`
2020-07-13 17:44:56 -04:00
David Wendt
16774aa055
Add a test for legacy / ES3 inheritance.
...
This was originally something *way* more evil: mixed inheritance between ES3 and ES4 classes. It didn't pan out due to fundamental limitations of the two object models. How the hell did Brendan Eich/Adobe/TC-39 expect ES4 classes to be adopted in already-existing codebases?!
2020-07-13 17:44:56 -04:00
David Wendt
4b66af8dc3
ES4 classes, while superficially similar to functions, are not functions and should not inherit from the `Function` prototype.
...
We still reuse the `FunctionObject` machinery internally. If necessary, we may want to split this into a separate `ClassObject` if some internal `TObject` method needs replacing for classes.
2020-07-13 17:44:55 -04:00
David Wendt
8b36751fbb
Several built-in functions are not `public`, but instead live in the `AS3` namespace. This moves those functions there.
...
In practice not many movies will care about this, because the `AS3` namespace is open by default. You could opt-out of that, and I suppose that was there for using existing ES3 code in AS3 projects. ES4 would have had a similar ES4 namespace, which "JavaScript 2.0" code would need to opt into. Of course, ES4/JS2 never happened, so we just have this weird historical quirk here.
2020-07-13 17:44:55 -04:00
David Wendt
37cdcb3bce
Add tests for `toString` on objects, functions, and classes.
2020-07-13 17:44:54 -04:00
David Wendt
f493cf954f
Make `toString` and `valueOf` methods of `TObject`, called `to_string` and `value_of` respectively.
...
The reason for this is that, in AVM2, `toString` and `valueOf` are not defined on the classes or prototypes of `Function` or `Class`. Instead, they use the `Object.prototype` versions of those functions. Ergo, string and primitive coercion are inherent object methods (the ones that get `[[DoubleSquareBrackets]]` in the ECMA standards). In Ruffle, our equivalent to `[[DoubleSquareBrackets]]` methods are methods on the `TObject` trait, so we're adding them there.
This mechanism will make implementing boxed value types (ala AVM1's `BoxedObject`) easier, too.
We also add some reasonable defaults for `ScriptObject` and `FunctionObject` which will appear on objects, functions, and classes.
2020-07-13 17:44:53 -04:00
David Wendt
ba2c1f5750
Add test for `setPropertyIsEnumerable`
2020-07-13 17:44:39 -04:00
David Wendt
f13e2ea3c4
Implement `setPropertyIsEnumerable`
2020-07-13 17:44:37 -04:00
David Wendt
dc0cb00a03
Add a test for `propertyIsEnumerable`.
2020-07-13 17:44:37 -04:00
David Wendt
2afbcf450a
Impl `propertyIsEnumerable`
2020-07-13 17:44:36 -04:00
David Wendt
a0ca5891e4
Prevent instance traits from being accessible directly from prototypes.
2020-07-13 17:44:36 -04:00
David Wendt
307a95e5c4
`callproperty` and `callpropvoid` should *never* get callables from `base_proto`.
2020-07-13 17:44:35 -04:00
David Wendt
42cb8f57c8
Add a test for `has_own_property` in various class instance scenarios.
2020-07-13 17:44:35 -04:00
David Wendt
6e2508a79d
Fix `any` name resolution, at least enough for the `has_own_property` test to work.
...
Private names now return `false`, and we run any names through trait lookups. This also means any namespace resolution can fail now, in case we need to throw a `VerifyError`.
2020-07-13 17:44:34 -04:00
David Wendt
8677804ea0
Actually enable the `isPrototypeOf` test.
2020-07-13 17:44:34 -04:00
David Wendt
c6265bb50c
Allow tracing booleans.
...
This requires implementing *some level* of coercions, even though this isn't the way to do it.
2020-07-13 17:44:34 -04:00
David Wendt
00186f7602
Free functions always have a `prototype`, this is a holdover from ES3.
2020-07-13 17:44:33 -04:00
David Wendt
0e89cb2175
Impl `Object.isPrototypeOf` w/ test
2020-07-13 17:44:33 -04:00
David Wendt
d29f3dc1d0
Add `as3_object_enumeration` and `as3_class_enumeration` tests.
...
The former tests iterating normal objects and the latter tests iterating objects with prototypes.
2020-07-13 17:44:33 -04:00
David Wendt
c014b40109
Implement `hasnext`, `hasnext2`, `nextname`, `nextvalue`, and the underlying enumeration machinery that powers it.
...
I have... significant reservations with the way object enumeration happens in AVM2. For comparison, AVM1 enumeration works like this: You enumerate the entire object at once, producing a list of property names, which are then pushed onto the stack after a sentinel value. This is a properly abstract way to handle property enumeration.
In AVM2, they completely replaced this with index-based enumeration. What this means is that you hand the object an index and it gives you back a name or value. There's also an instruction that will give you the next index in the object.
The only advantage I can think of is that it results in less stack manipulation if you want to bail out of iteration early. You just jump out of your loop and kill the registers you don't care about. The disadvantage is that it locks the object representation down pretty hard. They also screwed up the definition of `hasnext`, and thus the VM is stuck enumerating properties from 1. This is because `hasnext` and `hasnext2` increment the index value before checking the object. Code generated by Animate 2020 (which I suspect to be the final version of that software that generates AVM2 code) initializes the index at hero, and then does `hasnext2`, hence we have to start from one.
I actually cheated a little and added a separate `Vec` for storing enumerant names. I strongly suspect that Adobe's implementation has objects be inherently slot-oriented, and named properties are just hashmap lookups to slots. This would allow enumerating the slots to get names out of the object.
2020-07-13 17:44:32 -04:00
David Wendt
73189b6449
Properly unwind errors thrown from the AVM2 reader.
2020-07-13 17:44:32 -04:00
David Wendt
1cc8954747
Impl `pop`, which is the opposite of `dup`; and also the opposite of all the `push` instructions.
...
Confusingly, this one isn't documented in the AVM2 spec at all, but it's method of operation is fairly obvious.
2020-07-13 17:44:31 -04:00
David Wendt
9496fbde0a
Remove `DontEnum`, `is_enumerable` and attribute mutation. They won't be needed.
2020-07-13 17:44:31 -04:00
David Wendt
67b7fbb593
Implement `label`, which is a no-op designed specifically to silence verifier errors about unreachable code.
2020-07-13 17:44:31 -04:00
David Wendt
da6a7c0723
Implement `kill`, at least a little.
...
I'm sure there's some other part of AVM2 that cares about killed registers, but I couldn't find it yet.
2020-07-13 17:44:30 -04:00
David Wendt
7253c091a2
Add tests for control flow instructions that use booleans or strict equality.
...
Other comparisons will have to wait until we have ECMA-compliant abstract comparison and coercion.
2020-07-13 17:44:30 -04:00
David Wendt
9c5ea1d30c
Implement `jump`, `iftrue`, `iffalse`, `ifstricteq`, and `ifstrictne`.
2020-07-13 17:44:30 -04:00
David Wendt
b33c246713
Implement `is_property_overwritable`.
2020-07-13 17:44:29 -04:00
David Wendt
ddc9aa4cca
Add a test for ES4 method binding of `this`.
2020-07-13 17:44:29 -04:00
David Wendt
915b2da42b
Allow binding a reciever to a function, and make all method traits bind themselves to the object they were constructed on.
...
Our already odd `super` handling throws up another subtlety regarding bound recievers. Since we have to construct an instance of a parent class in order to get traits on it, we also have to make sure that we initialize traits with the correct reciever. I'll demonstrate here:
```let mut base = base_proto.construct(avm, context, &[])?;
let name = base.resolve_multiname(&multiname).unwrap();
let value = base.get_property(object, &name, avm, context)?.resolve(avm, context)?```
In this case, if `name` is the name of a method, getter, or setter trait, then `get_property` will instantiate that trait on `base` but bound to `reciever`. This is correct behavior for this case, but more generally, trait instantiation is permenant and therefore there's potential for confusing shenanigans if you `get_property` with the wrong reciever.
To be very clear, `reciever` should *always* be the same object that is getting `get_property` et. all called on it. In the event that you need to instantiate traits with a different `reciever`, you should construct a one-off object and retrieve prototypes from that.
2020-07-13 17:44:28 -04:00
David Wendt
f042e453a3
Add a test for interactions between prototype and class-trait properties.
...
This is the test that broke the old object model's back, please see parent commit's description for more details.
2020-07-13 17:44:27 -04:00