replay: a message to nil (receiver 0, no result, no class named) plays nothing, as Objective-C does nothing for it; gb's stream holds such a replaceRegion
This commit is contained in:
1 parent
8cfda4b5e1
commit
d2fa098f0c
3 files changed
+38
No files matched your search
@@ -821,6 +821,11 @@ impl<'b, B: Backend> Player<'b, B> {
|
||||
call: Call,
|
||||
left_out: &mut Counters,
|
||||
) -> Result<(), PlayError> {
|
||||
// A message to nil does nothing: a call of receiver 0 that makes nothing and names no
|
||||
// class (a class's call is `MTLX.selector`, the host's `m2v.selector`).
|
||||
if call.receiver == 0 && call.result == 0 && !call.selector.contains('.') {
|
||||
return Ok(());
|
||||
}
|
||||
match &*call.selector {
|
||||
"m2v.write" => self.write(stream, &call),
|
||||
"m2v.check" => {
|
||||
|
||||
@@ -1063,6 +1063,37 @@ fn a_dispatch_plays_between_its_private_bytes() {
|
||||
assert!(total.values().all(|&value| value == 0), "{total:?}");
|
||||
}
|
||||
|
||||
/// A message to nil (receiver 0, no result, no class named) plays nothing and does not stop the
|
||||
/// play; the stream still counts it as a call.
|
||||
#[test]
|
||||
fn a_message_to_nil_does_nothing() {
|
||||
let mut kept = Kept::default();
|
||||
let (report, ended) = played(&mut kept, |w| {
|
||||
w.call("MTLCreateSystemDefaultDevice", 0, 1, &[], &[])?;
|
||||
let region = map(&[
|
||||
("origin", map(&[("x", Value::Uint(0))])),
|
||||
("size", map(&[("width", Value::Uint(1))])),
|
||||
]);
|
||||
let args = [
|
||||
region,
|
||||
Value::Uint(0),
|
||||
Value::Bytes(vec![0; 4]),
|
||||
Value::Uint(4),
|
||||
];
|
||||
w.call(
|
||||
"replaceRegion:mipmapLevel:withBytes:bytesPerRow:",
|
||||
0,
|
||||
0,
|
||||
&args,
|
||||
&[],
|
||||
)?;
|
||||
Ok(())
|
||||
});
|
||||
ended.unwrap();
|
||||
assert_eq!(kept.calls, ["#1 = MTLCreateSystemDefaultDevice"]);
|
||||
assert_eq!(report.total.stream["calls"], 2);
|
||||
}
|
||||
|
||||
/// On a backend that takes no snapshots, a dispatch an `m2v.privateBytes` record names plays as it
|
||||
/// is, with none of the player's own calls, and the report counts it.
|
||||
#[test]
|
||||
|
||||
@@ -83,6 +83,8 @@ and the (name id, value) answer pairs.
|
||||
(`MTLRenderPassDescriptor.new`), or an `m2v.` name for what Metal has no call for. Where two
|
||||
classes share a selector, the receiver's kind tells them apart.
|
||||
- **Receiver 0** is the host's platform: the device, descriptor and drawable records it makes.
|
||||
A call of receiver 0 that makes nothing and whose selector names no class (no `.`) is a message
|
||||
the program sent to nil: it does nothing, and a player plays nothing for it.
|
||||
- **Arguments:** one value per argument of the selector, in order; an encoder command's are its
|
||||
fields. Error out-parameters, blocks and handlers are left out: their effects reach the stream as
|
||||
later calls and writes.
|
||||
|
||||
Reference in new issue
Block a user