Skip to content

avm2: Introduce ParametersExt and use it inside bitmapdata #9930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 14, 2023

Conversation

Dinnerbone
Copy link
Contributor

We currently have so many different ways of pulling out parameters from the function, and almost every single one is wrong. The "correct" way to do it tends to be extremely verbose.

This introduces common methods for correctly getting the value of a given type from the function parameters slice, and converts BitmapData to use it as an initial proof of concept.

It's still missing more useful functions like getting native object types (DisplayObject from an arg, for example), but it's already a significant improvement.

@Lord-McSweeney
Copy link
Collaborator

Does this PR obsolete/supersede #7895?

@Dinnerbone
Copy link
Contributor Author

I'd say no. That PR is on hold until everyone can agree on the design, and I think makes a nicer end goal, but this works for today.

Value::Null | Value::Undefined => None,
Value::Object(o) => Some(o),
primitive => Some(
PrimitiveObject::from_primitive(primitive, activation)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in most places we don't actually expect a primitive (matrix, color_transform, etc), so I'd consider making it a default? (just documenting it well).

On that note, I'd also add get_value(idx) just for a consistent api.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added get_value which is this[index] for now.
Good point about non-primitives, I think I'll need to consider that a bit though. Will handle it in a future PR if that's ok!

@Dinnerbone Dinnerbone enabled auto-merge (rebase) March 14, 2023 06:28
@Dinnerbone Dinnerbone merged commit 74d424e into ruffle-rs:master Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants