Skip to content

Commit

Permalink
avm2: Skip attempting to serialize methods
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian17 authored and torokati44 committed Sep 7, 2024
1 parent 43f5aaa commit 7d07eb2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/avm2/amf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,15 @@ pub fn recursive_serialize<'gc>(
) -> Result<(), Error<'gc>> {
if let Some(static_properties) = static_properties {
let vtable = obj.vtable();
// TODO: respect versioning
let mut props = vtable.public_properties();
// Flash appears to use vtable iteration order, but we sort ours
// to make our test output consistent.
props.sort_by_key(|(name, _)| name.to_utf8_lossy().to_string());
for (name, prop) in props {
if let Property::Method { .. } = prop {
continue;
}
if let Property::Virtual { get, set } = prop {
if !(get.is_some() && set.is_some()) {
continue;
Expand Down
19 changes: 19 additions & 0 deletions tests/tests/swfs/avm2/bytearray_method_serialization/Test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// compiled with mxmlc (and modified to SWF v9)

import flash.utils.ByteArray;
import flash.geom.Point;

var p = new Point(4.5, 5.5);
var b = new ByteArray();
b.writeObject(p);
trace(b.length);

package {
import flash.display.MovieClip;

public class Test extends MovieClip {
public function Test() {
return;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
25
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_frames = 1

0 comments on commit 7d07eb2

Please sign in to comment.