implements PLN-0126 asset backlog public api
This commit is contained in:
@@ -757,6 +757,64 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
||||
ret.push_int(status as i64);
|
||||
Ok(())
|
||||
}
|
||||
Syscall::AssetBacklogInfo => {
|
||||
let info = platform.assets().backlog_info();
|
||||
ret.push_int(info.status as i64);
|
||||
ret.push_int(info.pending_count as i64);
|
||||
ret.push_int(info.active_handle as i64);
|
||||
ret.push_int(info.active_asset_id.unwrap_or(0) as i64);
|
||||
ret.push_int(info.active_bank_type.map(|bank| bank as i64).unwrap_or(0));
|
||||
ret.push_int(info.active_slot.map(|slot| slot as i64).unwrap_or(0));
|
||||
ret.push_int(info.active_progress as i64);
|
||||
Ok(())
|
||||
}
|
||||
Syscall::AssetBacklogPosition => {
|
||||
let position = platform.assets().backlog_position(expect_int(args, 0)? as u32);
|
||||
ret.push_int(position.status as i64);
|
||||
ret.push_int(position.state as i64);
|
||||
ret.push_int(position.position as i64);
|
||||
ret.push_int(position.progress as i64);
|
||||
Ok(())
|
||||
}
|
||||
Syscall::AssetBacklogMove => {
|
||||
let new_position = expect_non_negative_usize(args, 1, "new_position")?;
|
||||
let status =
|
||||
platform.assets().backlog_move(expect_int(args, 0)? as u32, new_position);
|
||||
ret.push_int(status as i64);
|
||||
Ok(())
|
||||
}
|
||||
Syscall::AssetBacklogPromote => {
|
||||
let status = platform.assets().backlog_promote(expect_int(args, 0)? as u32);
|
||||
ret.push_int(status as i64);
|
||||
Ok(())
|
||||
}
|
||||
Syscall::AssetBacklogDemote => {
|
||||
let status = platform.assets().backlog_demote(expect_int(args, 0)? as u32);
|
||||
ret.push_int(status as i64);
|
||||
Ok(())
|
||||
}
|
||||
Syscall::AssetTargetStatus => {
|
||||
let bank_type = match expect_int(args, 0)? {
|
||||
0 => BankType::GLYPH,
|
||||
1 => BankType::SOUNDS,
|
||||
2 => BankType::SCENE,
|
||||
other => {
|
||||
return Err(VmFault::Trap(
|
||||
TRAP_TYPE,
|
||||
format!("Invalid asset bank type: {}", other),
|
||||
));
|
||||
}
|
||||
};
|
||||
let slot = expect_non_negative_usize(args, 1, "slot")?;
|
||||
let target = platform.assets().target_status(bank_type, slot);
|
||||
ret.push_int(target.status as i64);
|
||||
ret.push_int(target.asset_id.unwrap_or(0) as i64);
|
||||
ret.push_int(target.handle as i64);
|
||||
ret.push_int(target.state as i64);
|
||||
ret.push_int(target.position as i64);
|
||||
ret.push_int(target.progress as i64);
|
||||
Ok(())
|
||||
}
|
||||
Syscall::BankInfo => {
|
||||
let asset_type = match expect_int(args, 0)? as u32 {
|
||||
0 => BankType::GLYPH,
|
||||
|
||||
Reference in New Issue
Block a user