Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 36 additions & 22 deletions core/src/avm1/globals/sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,23 +206,27 @@
}

const PROTO_DECLS: &[Declaration] = declare_properties! {
"attachSound" => method(attach_sound; DONT_ENUM | DONT_DELETE | READ_ONLY);
"duration" => property(duration; DONT_ENUM | DONT_DELETE | READ_ONLY);
"getDuration" => method(duration; DONT_ENUM | DONT_DELETE | READ_ONLY);
"setDuration" => method(set_duration; DONT_ENUM | DONT_DELETE | READ_ONLY);
"id3" => method(id3; DONT_ENUM | DONT_DELETE | READ_ONLY);
"getBytesLoaded" => method(get_bytes_loaded; DONT_ENUM | DONT_DELETE | READ_ONLY);
"getBytesTotal" => method(get_bytes_total; DONT_ENUM | DONT_DELETE | READ_ONLY);
"getPan" => method(get_pan; DONT_ENUM | DONT_DELETE | READ_ONLY);
"getTransform" => method(get_transform; DONT_ENUM | DONT_DELETE | READ_ONLY);
"getVolume" => method(get_volume; DONT_ENUM | DONT_DELETE | READ_ONLY);
"loadSound" => method(load_sound; DONT_ENUM | DONT_DELETE | READ_ONLY);
"position" => property(position; DONT_ENUM | DONT_DELETE | READ_ONLY);
"setPan" => method(set_pan; DONT_ENUM | DONT_DELETE | READ_ONLY);
"setTransform" => method(set_transform; DONT_ENUM | DONT_DELETE | READ_ONLY);
"setVolume" => method(set_volume; DONT_ENUM | DONT_DELETE | READ_ONLY);
"start" => method(start; DONT_ENUM | DONT_DELETE | READ_ONLY);
"stop" => method(stop; DONT_ENUM | DONT_DELETE | READ_ONLY);
"attachSound" => method(attach_sound; DONT_ENUM | DONT_DELETE | READ_ONLY);
"start" => method(start; DONT_ENUM | DONT_DELETE | READ_ONLY);
"getDuration" => method(duration; DONT_ENUM | DONT_DELETE | READ_ONLY | VERSION_6);
"setDuration" => method(set_duration; DONT_ENUM | DONT_DELETE | READ_ONLY | VERSION_6);
"getPosition" => method(get_position; DONT_ENUM | DONT_DELETE | READ_ONLY | VERSION_6);
"setPosition" => method(set_position; DONT_ENUM | DONT_DELETE | READ_ONLY | VERSION_6);
"loadSound" => method(load_sound; DONT_ENUM | DONT_DELETE | READ_ONLY | VERSION_6);
"getBytesLoaded" => method(get_bytes_loaded; DONT_ENUM | DONT_DELETE | READ_ONLY | VERSION_6);
"getBytesTotal" => method(get_bytes_total; DONT_ENUM | DONT_DELETE | READ_ONLY | VERSION_6);

// TODO The following 3 probably should not be declared here. See avm1/sound_props_swf*
"duration" => property(duration; DONT_ENUM | DONT_DELETE);
"id3" => property(id3; DONT_ENUM | DONT_DELETE);
"position" => property(position; DONT_ENUM | DONT_DELETE);
};

pub fn create_class<'gc>(
Expand Down Expand Up @@ -320,25 +324,17 @@
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
if activation.swf_version() >= 6 {
avm1_stub!(activation, "Sound", "getBytesLoaded");
Ok(1.into())
} else {
Ok(Value::Undefined)
}
avm1_stub!(activation, "Sound", "getBytesLoaded");
Ok(1.into())

Check warning on line 328 in core/src/avm1/globals/sound.rs

View workflow job for this annotation

GitHub Actions / Coverage Report

Coverage

Uncovered lines (327–328)
}

fn get_bytes_total<'gc>(
activation: &mut Activation<'_, 'gc>,
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
if activation.swf_version() >= 6 {
avm1_stub!(activation, "Sound", "getBytesTotal");
Ok(1.into())
} else {
Ok(Value::Undefined)
}
avm1_stub!(activation, "Sound", "getBytesTotal");
Ok(1.into())

Check warning on line 337 in core/src/avm1/globals/sound.rs

View workflow job for this annotation

GitHub Actions / Coverage Report

Coverage

Uncovered lines (336–337)
}

fn get_pan<'gc>(
Expand Down Expand Up @@ -625,3 +621,21 @@

Ok(Value::Undefined)
}

fn set_position<'gc>(
activation: &mut Activation<'_, 'gc>,
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm1_stub!(activation, "Sound", "setPosition");
Ok(Value::Undefined)
}

Check warning on line 632 in core/src/avm1/globals/sound.rs

View workflow job for this annotation

GitHub Actions / Coverage Report

Coverage

Uncovered lines (625–632)

fn get_position<'gc>(
activation: &mut Activation<'_, 'gc>,
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm1_stub!(activation, "Sound", "getPosition");
Ok(Value::Undefined)
}

Check warning on line 641 in core/src/avm1/globals/sound.rs

View workflow job for this annotation

GitHub Actions / Coverage Report

Coverage

Uncovered lines (634–641)
68 changes: 68 additions & 0 deletions tests/tests/swfs/avm1/sound_props_swf5/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[type Function]
function
[object Object]
object
[object Object]
object
Enumerated
Enumerated prototype
Props
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
After set
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
After delete
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
Binary file added tests/tests/swfs/avm1/sound_props_swf5/test.swf
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/tests/swfs/avm1/sound_props_swf5/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true
68 changes: 68 additions & 0 deletions tests/tests/swfs/avm1/sound_props_swf6/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[type Function]
function
[object Object]
object
[object Object]
object
Enumerated
Enumerated prototype
Props
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
undefined
undefined
undefined
After set
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
After delete
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
[type Function]
undefined
undefined
undefined
120 changes: 120 additions & 0 deletions tests/tests/swfs/avm1/sound_props_swf6/test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
var o = new Sound();

trace(Sound);
trace(typeof Sound);
trace(Sound.prototype);
trace(typeof Sound.prototype);

trace(o);
trace(typeof o);

trace("Enumerated");
for (var p in o) {
trace(p);
}

trace("Enumerated prototype");
for (var p in Sound.prototype) {
trace(p);
}

trace("Props");
trace(o.getPan);
trace(o.getTransform);
trace(o.getVolume);
trace(o.setPan);
trace(o.setTransform);
trace(o.setVolume);
trace(o.stop);
trace(o.attachSound);
trace(o.start);
trace(o.getDuration);
trace(o.setDuration);
trace(o.getPosition);
trace(o.setPosition);
trace(o.loadSound);
trace(o.getBytesLoaded);
trace(o.getBytesTotal);
trace(o.duration);
trace(o.id3);
trace(o.position);

trace("After set");
o.getPan = "test";
o.getTransform = "test";
o.getVolume = "test";
o.setPan = "test";
o.setTransform = "test";
o.setVolume = "test";
o.stop = "test";
o.attachSound = "test";
o.start = "test";
o.getDuration = "test";
o.setDuration = "test";
o.getPosition = "test";
o.setPosition = "test";
o.loadSound = "test";
o.getBytesLoaded = "test";
o.getBytesTotal = "test";
o.duration = "test";
o.id3 = "test";
o.position = "test";
trace(o.getPan);
trace(o.getTransform);
trace(o.getVolume);
trace(o.setPan);
trace(o.setTransform);
trace(o.setVolume);
trace(o.stop);
trace(o.attachSound);
trace(o.start);
trace(o.getDuration);
trace(o.setDuration);
trace(o.getPosition);
trace(o.setPosition);
trace(o.loadSound);
trace(o.getBytesLoaded);
trace(o.getBytesTotal);
trace(o.duration);
trace(o.id3);
trace(o.position);

trace("After delete");
delete o.getPan;
delete o.getTransform;
delete o.getVolume;
delete o.setPan;
delete o.setTransform;
delete o.setVolume;
delete o.stop;
delete o.attachSound;
delete o.start;
delete o.getDuration;
delete o.setDuration;
delete o.getPosition;
delete o.setPosition;
delete o.loadSound;
delete o.getBytesLoaded;
delete o.getBytesTotal;
delete o.duration;
delete o.id3;
delete o.position;
trace(o.getPan);
trace(o.getTransform);
trace(o.getVolume);
trace(o.setPan);
trace(o.setTransform);
trace(o.setVolume);
trace(o.stop);
trace(o.attachSound);
trace(o.start);
trace(o.getDuration);
trace(o.setDuration);
trace(o.getPosition);
trace(o.setPosition);
trace(o.loadSound);
trace(o.getBytesLoaded);
trace(o.getBytesTotal);
trace(o.duration);
trace(o.id3);
trace(o.position);
Binary file added tests/tests/swfs/avm1/sound_props_swf6/test.swf
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/tests/swfs/avm1/sound_props_swf6/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true
Loading