Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
stdc++: migrate nall::array to std::array
  • Loading branch information
rasky committed Oct 2, 2025
commit f28f7b82fd0b59648eee8891a2a95ae1a7a030a3
3 changes: 2 additions & 1 deletion ares/ares/ares.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
#include <vector>
#include <ranges>
#include <algorithm>
#include <array>
#include <unordered_map>

#include <nall/platform.hpp>
#include <nall/adaptive-array.hpp>
#include <nall/any.hpp>
#include <nall/array.hpp>
#include <nall/bump-allocator.hpp>
#include <nall/case-range.hpp>
#include <nall/chrono.hpp>
Expand Down
4 changes: 2 additions & 2 deletions ares/component/audio/ay38910/ay38910.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ namespace ares {

#include "serialization.cpp"

auto AY38910::clock() -> array<n4[3]> {
auto AY38910::clock() -> std::array<n4, 3> {
toneA.clock();
toneB.clock();
toneC.clock();
noise.clock();
envelope.clock();

array<n4[3]> output;
std::array<n4, 3> output{};
if((toneA.output | channelA.tone) & (noise.output | channelA.noise)) {
output[0] = channelA.envelope ? envelope.output : channelA.volume;
}
Expand Down
2 changes: 1 addition & 1 deletion ares/component/audio/ay38910/ay38910.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct AY38910 {
virtual auto writeIO(n1 port, n8 data) -> void {}

//ay38910.cpp
auto clock() -> array<n4[3]>;
auto clock() -> std::array<n4, 3>;
auto read() -> n8;
auto write(n8 data) -> void;
auto select(n4 data) -> void;
Expand Down
6 changes: 3 additions & 3 deletions ares/component/audio/sn76489/sn76489.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ namespace ares {

#include "serialization.cpp"

auto SN76489::clock() -> array<n4[4]> {
auto SN76489::clock() -> std::array<n4, 4> {
tone0.clock();
tone1.clock();
tone2.clock();
noise.clock();

array<n4[4]> output{15, 15, 15, 15};
std::array<n4, 4> output{15, 15, 15, 15};
if(tone0.output) output[0] = tone0.volume;
if(tone1.output) output[1] = tone1.volume;
if(tone2.output) output[2] = tone2.volume;
Expand All @@ -28,7 +28,7 @@ auto SN76489::Tone::clock() -> void {

auto SN76489::Noise::clock() -> void {
if(!counter || !--counter) {
counter = array<n10[4]>{0x10, 0x20, 0x40, pitch}[rate];
counter = std::array<n10, 4>{0x10, 0x20, 0x40, pitch}[rate];
if(flip ^= 1) { //0->1 transition
output = lfsr.bit(0);
lfsr = (lfsr.bit(0) ^ lfsr.bit(3) & enable) << 15 | lfsr >> 1;
Expand Down
2 changes: 1 addition & 1 deletion ares/component/audio/sn76489/sn76489.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ares {

struct SN76489 {
//sn76489.cpp
auto clock() -> array<n4[4]>;
auto clock() -> std::array<n4, 4>;
auto write(n8 data) -> void;
auto power() -> void;

Expand Down
6 changes: 3 additions & 3 deletions ares/component/audio/t6w28/t6w28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ namespace ares {

#include "serialization.cpp"

auto T6W28::clock() -> array<n4[8]> {
auto T6W28::clock() -> std::array<n4, 8> {
tone0.clock();
tone1.clock();
tone2.clock();
noise.clock();

array<n4[8]> output{15, 15, 15, 15, 15, 15, 15, 15};
std::array<n4, 8> output{15, 15, 15, 15, 15, 15, 15, 15};
if(tone0.output) output[0] = tone0.volume.left, output[4] = tone0.volume.right;
if(tone1.output) output[1] = tone1.volume.left, output[5] = tone1.volume.right;
if(tone2.output) output[2] = tone2.volume.left, output[6] = tone2.volume.right;
Expand All @@ -28,7 +28,7 @@ auto T6W28::Tone::clock() -> void {

auto T6W28::Noise::clock() -> void {
if(!counter--) {
counter = array<n10[4]>{0x10, 0x20, 0x40, pitch}[rate];
counter = std::array<n10, 4>{0x10, 0x20, 0x40, pitch}[rate];
if(flip ^= 1) { //0->1 transition
output = !lfsr.bit(0);
lfsr = (lfsr.bit(0) ^ lfsr.bit(2) & enable) << 14 | lfsr >> 1;
Expand Down
2 changes: 1 addition & 1 deletion ares/component/audio/t6w28/t6w28.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct T6W28 {
virtual auto writePitch(u32) -> void = 0;

//t6w28.cpp
auto clock() -> array<n4[8]>;
auto clock() -> std::array<n4, 8>;
auto writeLeft(n8 data) -> void;
auto writeRight(n8 data) -> void;
auto power() -> void;
Expand Down
4 changes: 2 additions & 2 deletions ares/component/audio/ym2149/ym2149.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ namespace ares {

#include "serialization.cpp"

auto YM2149::clock() -> array<n5[3]> {
auto YM2149::clock() -> std::array<n5, 3> {
toneA.clock();
toneB.clock();
toneC.clock();
noise.clock();
envelope.clock();

array<n5[3]> output;
std::array<n5, 3> output{};
if((toneA.output | channelA.tone) & (noise.output | channelA.noise)) {
output[0] = channelA.envelope ? envelope.output : n5(channelA.volume << 1 | 1);
}
Expand Down
2 changes: 1 addition & 1 deletion ares/component/audio/ym2149/ym2149.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ares {

struct YM2149 {
//ym2149.cpp
auto clock() -> array<n5[3]>;
auto clock() -> std::array<n5, 3>;
auto read() -> n8;
auto write(n8 data) -> void;
auto select(n4 data) -> void;
Expand Down
2 changes: 1 addition & 1 deletion ares/component/audio/ym2612/ym2612.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ares {
#include "constants.cpp"
#include "serialization.cpp"

auto YM2612::clock() -> array<i16[2]> {
auto YM2612::clock() -> std::array<i16, 2> {
s32 left = 0;
s32 right = 0;

Expand Down
2 changes: 1 addition & 1 deletion ares/component/audio/ym2612/ym2612.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace ares {

struct YM2612 {
//ym2612.cpp
auto clock() -> array<i16[2]>;
auto clock() -> std::array<i16, 2>;
auto power() -> void;

//io.cpp
Expand Down
8 changes: 4 additions & 4 deletions ares/component/processor/tlcs900h/disassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ NALL_NOINLINE auto TLCS900H::disassembleInstruction() -> string {
natural _immediate;
natural _displacement;

static auto lookup(natural size, n3 register) -> n8 {
if(size == 8) return from_array<0xe1,0xe0,0xe5,0xe4,0xe9,0xe8,0xed,0xec>(register);
if(size == 16) return from_array<0xe0,0xe4,0xe8,0xec,0xf0,0xf4,0xf8,0xfc>(register);
if(size == 32) return from_array<0xe0,0xe4,0xe8,0xec,0xf0,0xf4,0xf8,0xfc>(register);
static auto lookup(natural size, n3 reg) -> n8 {
if(size == 8) { static const u8 t[8] = {0xe1,0xe0,0xe5,0xe4,0xe9,0xe8,0xed,0xec}; return (n8)t[(u32)reg]; }
if(size == 16) { static const u8 t[8] = {0xe0,0xe4,0xe8,0xec,0xf0,0xf4,0xf8,0xfc}; return (n8)t[(u32)reg]; }
if(size == 32) { static const u8 t[8] = {0xe0,0xe4,0xe8,0xec,0xf0,0xf4,0xf8,0xfc}; return (n8)t[(u32)reg]; }
return 0;
}
} lhs, rhs;
Expand Down
4 changes: 2 additions & 2 deletions ares/n64/controller/gamepad/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ auto Gamepad::formatControllerPak() -> void {
n6 fieldA = random();
n19 fieldB = random();
n27 fieldC = random();
for(u32 area : array<u8[4]>{1,3,4,6}) {
for(u32 area : std::array<u8,4>{1,3,4,6}) {
ram.write<Byte>(area * 0x20 + 0x01, fieldA); //unknown
ram.write<Word>(area * 0x20 + 0x04, fieldB); //serial# hi
ram.write<Word>(area * 0x20 + 0x08, fieldC); //serial# lo
Expand All @@ -480,7 +480,7 @@ auto Gamepad::formatControllerPak() -> void {
u32 inodeTableCopyPage = 1 + nBanks;
for(u32 bank : range(0,nBanks)) {
u32 firstDataPage = bank == 0 ? (3 + nBanks * 2) : 1; //first bank has 3 + bank * 2 system pages, other banks have 127.
for(u32 page : array<u32[2]>{inodeTablePage + bank, inodeTableCopyPage + bank}) {
for(u32 page : std::array<u32,2>{inodeTablePage + bank, inodeTableCopyPage + bank}) {
for(u32 slot : range(firstDataPage,128)) {
ram.write<Byte>(0x100 * page + slot * 2 + 0x01, 0x03); //0x01 = stop, 0x03 = empty
}
Expand Down
4 changes: 2 additions & 2 deletions ares/n64/rsp/rsp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ struct RSP : Thread, Memory::RCP<RSP> {


auto reset() -> void {
context.fill();
context.fill(nullptr);
blocks.clear();
dirty = 0;
}
Expand Down Expand Up @@ -565,7 +565,7 @@ struct RSP : Thread, Memory::RCP<RSP> {
bool callInstructionPrologue = false;
Pipeline pipeline;
bump_allocator allocator;
array<Block*[1024]> context;
std::array<Block*, 1024> context;
std::unordered_map<u64, Block*> blocks;
u64 dirty;
} recompiler{*this};
Expand Down
2 changes: 1 addition & 1 deletion desktop-ui/settings/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ auto OptionSettings::construct() -> void {
nintendo64ExpansionPakLayout.setAlignment(1).setPadding(12_sx, 0);
nintendo64ExpansionPakHint.setText("Enable/Disable the 4MB Expansion Pak").setFont(Font().setSize(7.0)).setForegroundColor(SystemColor::Sublabel);

for (auto& opt : array<string[4]>{"32KiB (Default)", "128KiB (Datel 1Meg)", "512KiB (Datel 4Meg)", "1984KiB (Maximum)"}) {
for (auto& opt : std::array<string,4>{"32KiB (Default)", "128KiB (Datel 1Meg)", "512KiB (Datel 4Meg)", "1984KiB (Maximum)"}) {
ComboButtonItem item{&nintendo64ControllerPakBankOption};
item.setText(opt);
if (opt == settings.nintendo64.controllerPakBankString) {
Expand Down
88 changes: 0 additions & 88 deletions nall/nall/array.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion nall/nall/cmake/headers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <nall/algorithm.hpp>
#include <nall/any.hpp>
#include <nall/arithmetic.hpp>
#include <nall/array.hpp>
#include <array>
#include <nall/atoi.hpp>
#include <nall/bit.hpp>
#include <nall/chrono.hpp>
Expand Down
1 change: 0 additions & 1 deletion nall/nall/cmake/sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ target_sources(
any.hpp
arguments.hpp
arithmetic.hpp
array.hpp
atoi.hpp
bcd.hpp
bit.hpp
Expand Down
2 changes: 1 addition & 1 deletion nall/nall/encode/huffman.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ inline auto Huffman(std::span<const u8> input) -> std::vector<u8> {
u32 lhs = 0;
u32 rhs = 0;
};
array<Node[512]> nodes;
std::array<Node, 512> nodes;
for(u32 offset : range(input.size())) nodes[input[offset]].frequency++;

u32 count = 0;
Expand Down
3 changes: 2 additions & 1 deletion nall/nall/file-buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <nall/platform.hpp>
#include <span>
#include <array>
#include <nall/inode.hpp>
#include <nall/iterator.hpp>
#include <nall/range.hpp>
Expand Down Expand Up @@ -219,7 +220,7 @@ struct file_buffer {
}

private:
array<u8[4096]> buffer;
std::array<u8, 4096> buffer;
s64 bufferOffset = -1LL;
bool bufferDirty = false;
FILE* fileHandle = nullptr;
Expand Down
8 changes: 4 additions & 4 deletions nall/nall/galois-field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ struct GaloisField {

static auto log(u32 x) -> u32 {
enum : u32 { Size = bit::round(Elements), Mask = Size - 1 };
static array<field[Size]> log = [] {
static std::array<field, Size> log = [] {
u32 shift = 0, polynomial = Polynomial;
while(polynomial >>= 1) shift++;
shift--;

array<field[Size]> log;
std::array<field, Size> log;
field x = 1;
for(u32 n : range(Elements)) {
log[x] = n;
Expand All @@ -48,12 +48,12 @@ struct GaloisField {
}

static auto exp(u32 x) -> u32 {
static array<field[Elements]> exp = [] {
static std::array<field, Elements> exp = [] {
u32 shift = 0, polynomial = Polynomial;
while(polynomial >>= 1) shift++;
shift--;

array<field[Elements]> exp;
std::array<field, Elements> exp;
field x = 1;
for(u32 n : range(Elements)) {
exp[n] = x;
Expand Down
Loading