Skip to content

Commit

Permalink
Renaming ioendian to endianness (chapel-lang#23945)
Browse files Browse the repository at this point in the history
Based on the discussion about the name change for `ioendian`.

Resolves chapel-lang#23868

[Reviewed by @DanilaFe]
  • Loading branch information
ShreyasKhandekar authored Nov 29, 2023
2 parents 0e3be7d + f2f387b commit 1d9fc08
Show file tree
Hide file tree
Showing 25 changed files with 174 additions and 176 deletions.
8 changes: 4 additions & 4 deletions modules/packages/ProtobufProtocolSupport.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,22 @@ module ProtobufProtocolSupport {
}

proc fixed32AppendBase(val: uint(32), ch: writingChannel) throws {
ch.writeBinary(val, ioendian.little);
ch.writeBinary(val, endianness.little);
}

proc fixed32ConsumeBase(ch: readingChannel): uint(32) throws {
var val: uint(32);
ch.readBinary(val, ioendian.little);
ch.readBinary(val, endianness.little);
return val;
}

proc fixed64AppendBase(val: uint(64), ch: writingChannel) throws {
ch.writeBinary(val, ioendian.little);
ch.writeBinary(val, endianness.little);
}

proc fixed64ConsumeBase(ch: readingChannel): uint(64) throws {
var val: uint(64);
ch.readBinary(val, ioendian.little);
ch.readBinary(val, endianness.little);
return val;
}

Expand Down
146 changes: 73 additions & 73 deletions modules/standard/IO.chpl

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions test/exercises/Mandelbrot/MPlot.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,23 @@ const header_size = 14;

// Write the BMP image header
outfile.writef("BM");
outfile.writeBinary(size:uint(32), ioendian.little);
outfile.writeBinary(0:uint(16), ioendian.little); /* reserved1 */
outfile.writeBinary(0:uint(16), ioendian.little); /* reserved2 */
outfile.writeBinary(offset_to_pixel_data:uint(32), ioendian.little);
outfile.writeBinary(size:uint(32), endianness.little);
outfile.writeBinary(0:uint(16), endianness.little); /* reserved1 */
outfile.writeBinary(0:uint(16), endianness.little); /* reserved2 */
outfile.writeBinary(offset_to_pixel_data:uint(32), endianness.little);

// Write the DIB header BITMAPINFOHEADER
outfile.writeBinary(dib_header_size:uint(32), ioendian.little);
outfile.writeBinary(cols:int(32), ioendian.little);
outfile.writeBinary(-rows:int(32), ioendian.little); /*neg for swap*/
outfile.writeBinary(1:uint(16), ioendian.little); /* 1 color plane */
outfile.writeBinary(bits_per_pixel:uint(16), ioendian.little);
outfile.writeBinary(0:uint(32), ioendian.little); /* no compression */
outfile.writeBinary(pixels_size:uint(32), ioendian.little);
outfile.writeBinary(2835:uint(32), ioendian.little); /*pixels/meter print resolution=72dpi*/
outfile.writeBinary(2835:uint(32), ioendian.little); /*pixels/meter print resolution=72dpi*/
outfile.writeBinary(0:uint(32), ioendian.little); /* colors in palette */
outfile.writeBinary(0:uint(32), ioendian.little); /* "important" colors */
outfile.writeBinary(dib_header_size:uint(32), endianness.little);
outfile.writeBinary(cols:int(32), endianness.little);
outfile.writeBinary(-rows:int(32), endianness.little); /*neg for swap*/
outfile.writeBinary(1:uint(16), endianness.little); /* 1 color plane */
outfile.writeBinary(bits_per_pixel:uint(16), endianness.little);
outfile.writeBinary(0:uint(32), endianness.little); /* no compression */
outfile.writeBinary(pixels_size:uint(32), endianness.little);
outfile.writeBinary(2835:uint(32), endianness.little); /*pixels/meter print resolution=72dpi*/
outfile.writeBinary(2835:uint(32), endianness.little); /*pixels/meter print resolution=72dpi*/
outfile.writeBinary(0:uint(32), endianness.little); /* colors in palette */
outfile.writeBinary(0:uint(32), endianness.little); /* "important" colors */

//
// compute the maximum number of steps that were taken, just in case
Expand Down
30 changes: 15 additions & 15 deletions test/exercises/c-ray/Image.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,23 @@ proc writeImageBMP(outfile, pixels) {

// Write the BMP image header
outfile.writef("BM");
outfile.writeBinary(size:uint(32), ioendian.little);
outfile.writeBinary(0:uint(16), ioendian.little); /* reserved1 */
outfile.writeBinary(0:uint(16), ioendian.little); /* reserved2 */
outfile.writeBinary(offsetToPixelData:uint(32), ioendian.little);
outfile.writeBinary(size:uint(32), endianness.little);
outfile.writeBinary(0:uint(16), endianness.little); /* reserved1 */
outfile.writeBinary(0:uint(16), endianness.little); /* reserved2 */
outfile.writeBinary(offsetToPixelData:uint(32), endianness.little);

// Write the DIB header BITMAPINFOHEADER
outfile.writeBinary(dibHeaderSize:uint(32), ioendian.little);
outfile.writeBinary(cols:int(32), ioendian.little);
outfile.writeBinary(-rows:int(32), ioendian.little); /*neg for swap*/
outfile.writeBinary(1:uint(16), ioendian.little); /* 1 color plane */
outfile.writeBinary(bitsPerPixel:uint(16), ioendian.little);
outfile.writeBinary(0:uint(32), ioendian.little); /* no compression */
outfile.writeBinary(pixelsSize:uint(32), ioendian.little);
outfile.writeBinary(2835:uint(32), ioendian.little); /*pixels/meter print resolution=72dpi*/
outfile.writeBinary(2835:uint(32), ioendian.little); /*pixels/meter print resolution=72dpi*/
outfile.writeBinary(0:uint(32), ioendian.little); /* colors in palette */
outfile.writeBinary(0:uint(32), ioendian.little); /* "important" colors */
outfile.writeBinary(dibHeaderSize:uint(32), endianness.little);
outfile.writeBinary(cols:int(32), endianness.little);
outfile.writeBinary(-rows:int(32), endianness.little); /*neg for swap*/
outfile.writeBinary(1:uint(16), endianness.little); /* 1 color plane */
outfile.writeBinary(bitsPerPixel:uint(16), endianness.little);
outfile.writeBinary(0:uint(32), endianness.little); /* no compression */
outfile.writeBinary(pixelsSize:uint(32), endianness.little);
outfile.writeBinary(2835:uint(32), endianness.little); /*pixels/meter print resolution=72dpi*/
outfile.writeBinary(2835:uint(32), endianness.little); /*pixels/meter print resolution=72dpi*/
outfile.writeBinary(0:uint(32), endianness.little); /* colors in palette */
outfile.writeBinary(0:uint(32), endianness.little); /* "important" colors */

for i in pixels.domain.dim(0) {
var nbits = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/exercises/duplicates/forStudents/FileHashing.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ module FileHashing {

var f = open(path, ioMode.r);
var len = f.size;
var r = f.reader(deserializer=new binaryDeserializer(ioendian.big), locking=false,
var r = f.reader(deserializer=new binaryDeserializer(endianness.big), locking=false,
region=0..#len);


Expand Down
5 changes: 2 additions & 3 deletions test/io/diten/checkpoint.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ proc readArrayCheckpoint(filename: string, A:[] ?t, nTasks: int = dataParTasksPe
const eltSize = numBytes(A.eltType);
const start = eltSize * if idx == offsetDom.low then 0 else cumulativeOffsets[idx-1];
const end = eltSize * cumulativeOffsets[idx];
var ch = f.reader(region = start..#end, deserializer=new binaryDeserializer(ioendian.native));
var ch = f.reader(region = start..#end, deserializer=new binaryDeserializer(endianness.native));

for sub in A.localSubdomains(targetLocs(idx)) {

ch.read(A[sub]);
}
}
Expand All @@ -43,7 +42,7 @@ proc checkpointArray(filename: string, A:[] ?t, nTasks: int = dataParTasksPerLoc
const start = eltSize * if idx == offsetDom.low then 0 else cumulativeOffsets[idx-1];
const end = eltSize * cumulativeOffsets[idx];
var ch = f.writer(region = start..#end,
serializer=new binarySerializer(ioendian.native));
serializer=new binarySerializer(endianness.native));
for sub in A.localSubdomains(targetLocs(idx)) {
ch.write(A[sub]);
}
Expand Down
8 changes: 4 additions & 4 deletions test/io/ferguson/channel-changing-type.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ proc test1() {
{
var ch = f.writer(); // defaults to dynamic, text, locking
// make a binary, unlocked channel using same buffer as ch
var cha = ch.withSerializer(new binarySerializer(ioendian.big));
var cha = ch.withSerializer(new binarySerializer(endianness.big));
cha.write(1);
}

// check the output
{
var i: int;
f.reader().readBinary(i, ioendian.big);
f.reader().readBinary(i, endianness.big);
assert(i == 1);
}
}
Expand All @@ -25,14 +25,14 @@ proc test2() {
{
var ch = f.writer(); // defaults to dynamic, text, locking
// make a binary, unlocked channel using same buffer as ch
var cha = ch.withSerializer(new binarySerializer(ioendian.big));
var cha = ch.withSerializer(new binarySerializer(endianness.big));
cha.write(1);
}

// check the output
{
var i: int;
f.reader().readBinary(i, ioendian.big);
f.reader().readBinary(i, endianness.big);
assert(i == 1);
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/io/ferguson/writebinaryarray.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ var f = open("binary-output.bin", ioMode.cwr);

var A = [1,2,3,4,5];
{
var w = f.writer(serializer=new binarySerializer(ioendian.big));
var w = f.writer(serializer=new binarySerializer(endianness.big));
writeln("Writing ", A);
w.write(A);
w.close();
}

{
var r = f.reader(deserializer=new binaryDeserializer(ioendian.big));
var r = f.reader(deserializer=new binaryDeserializer(endianness.big));
var B = [0,0,0,0,0];
r.read(B);
writeln("Read ", B);
Expand All @@ -20,7 +20,7 @@ var A = [1,2,3,4,5];


{
var r = f.reader(deserializer=new binaryDeserializer(ioendian.big));
var r = f.reader(deserializer=new binaryDeserializer(endianness.big));
var num:int;
var B = [0,0,0,0,0];
var i=0;
Expand Down
6 changes: 3 additions & 3 deletions test/io/ferguson/writebinaryclass.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ var ownA = new owned R(1,2,3,4,5);
var A = ownA.borrow();

{
var w = f.writer(serializer=new binarySerializer(ioendian.big));
var w = f.writer(serializer=new binarySerializer(endianness.big));
writeln("Writing ", A);
w.write(A);
w.close();
}

{
var r = f.reader(deserializer=new binaryDeserializer(ioendian.big));
var r = f.reader(deserializer=new binaryDeserializer(endianness.big));
var ownB = new owned R(0,0,0,0,0);
var B = ownB.borrow();

Expand All @@ -36,7 +36,7 @@ var A = ownA.borrow();


{
var r = f.reader(deserializer=new binaryDeserializer(ioendian.big));
var r = f.reader(deserializer=new binaryDeserializer(endianness.big));
var ownB = new owned R(0,0,0,0,0);
var B = ownB.borrow();

Expand Down
6 changes: 3 additions & 3 deletions test/io/ferguson/writebinaryrecord.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ var f = open("binary-output.bin", ioMode.cwr);

var A = new R(1,2,3,4,5);
{
var w = f.writer(serializer=new binarySerializer(ioendian.big));
var w = f.writer(serializer=new binarySerializer(endianness.big));
writeln("Writing ", A);
w.write(A);
w.close();
}

{
var r = f.reader(deserializer=new binaryDeserializer(ioendian.big));
var r = f.reader(deserializer=new binaryDeserializer(endianness.big));
var B = new R(0,0,0,0,0);
r.read(B);
writeln("Read ", B);
Expand All @@ -28,7 +28,7 @@ var A = new R(1,2,3,4,5);


{
var r = f.reader(deserializer=new binaryDeserializer(ioendian.big));
var r = f.reader(deserializer=new binaryDeserializer(endianness.big));
var B = new R(0,0,0,0,0);
assert(r.read(B.a));
assert(r.read(B.b));
Expand Down
6 changes: 3 additions & 3 deletions test/io/ferguson/writebinarytuple.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ var f = open("binary-output.bin", ioMode.cwr);

var A = (1,2,3,4,5);
{
var w = f.writer(serializer=new binarySerializer(ioendian.big));
var w = f.writer(serializer=new binarySerializer(endianness.big));
writeln("Writing ", A);
w.write(A);
w.close();
}

{
var r = f.reader(deserializer=new binaryDeserializer(ioendian.big));
var r = f.reader(deserializer=new binaryDeserializer(endianness.big));
var B = (0,0,0,0,0);
r.read(B);
writeln("Read ", B);
Expand All @@ -20,7 +20,7 @@ var A = (1,2,3,4,5);


{
var r = f.reader(deserializer=new binaryDeserializer(ioendian.big));
var r = f.reader(deserializer=new binaryDeserializer(endianness.big));
var num:int;
var B = (0,0,0,0,0);
var i=0;
Expand Down
4 changes: 2 additions & 2 deletions test/io/ferguson/zerosatend.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var n = sz / 8;
{
var tmp = open(testfile, ioMode.cwr);

var och = tmp.writer(serializer=new binarySerializer(ioendian.big));
var och = tmp.writer(serializer=new binarySerializer(endianness.big));
for i in 0..#n {
var x:uint(64) = i:uint(64);
och.write(x);
Expand All @@ -24,7 +24,7 @@ var n = sz / 8;
{
var tmp = open(testfile, ioMode.r);

var ich = tmp.reader(deserializer=new binaryDeserializer(ioendian.big));
var ich = tmp.reader(deserializer=new binaryDeserializer(endianness.big));
for i in 0..#n {
var x:uint(64);
var got = ich.read(x);
Expand Down
6 changes: 3 additions & 3 deletions test/io/jhh/readbinary.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ var x64:complex(64) = 3.14159 + 2.718i;
var x128:complex(128) = 3.14159 + 2.718i;


var endians = [ioendian.native, ioendian.little, ioendian.big];
proc readone(expected:numeric, endian:ioendian=ioendian.native) {
var endians = [endianness.native, endianness.little, endianness.big];

proc readone(expected:numeric, endian:endianness=endianness.native) {
var inp: expected.type;
stdin.readBinary(inp, endian);
assert(inp == expected, inp.type:string, inp, expected);
Expand Down
2 changes: 1 addition & 1 deletion test/io/jhh/writebinary.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var im64:imag(64) = 3.14159i;
var x64:complex(64) = 3.14159 + 2.718i;
var x128:complex(128) = 3.14159 + 2.718i;

var endians = [ioendian.native, ioendian.little, ioendian.big];
var endians = [endianness.native, endianness.little, endianness.big];

proc output(arg:numeric) {
for endian in endians {
Expand Down
8 changes: 4 additions & 4 deletions test/io/serializers/FormatHelper.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ module FormatHelper {
else return new jsonDeserializer();
}
when FormatKind.little {
if writing then return new binarySerializer(endian=IO.ioendian.little);
else return new binaryDeserializer(endian=IO.ioendian.little);
if writing then return new binarySerializer(endian=IO.endianness.little);
else return new binaryDeserializer(endian=IO.endianness.little);
}
when FormatKind.big {
if writing then return new binarySerializer(endian=IO.ioendian.big);
else return new binaryDeserializer(endian=IO.ioendian.big);
if writing then return new binarySerializer(endian=IO.endianness.big);
else return new binaryDeserializer(endian=IO.endianness.big);
}
when FormatKind.syntax {
if writing then return new chplSerializer();
Expand Down
26 changes: 13 additions & 13 deletions test/library/standard/IO/readBinary/arrayOfValues.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ use IO;

testBinaryRead("./input/tu8.bin", makeUnsignedArray(8));

testBinaryRead("./input/tu16.bin", makeUnsignedArray(16), ioendian.big);
testBinaryRead("./input/tu32.bin", makeUnsignedArray(32), ioendian.big);
testBinaryRead("./input/tu64.bin", makeUnsignedArray(64), ioendian.big);
testBinaryRead("./input/tu16.bin", makeUnsignedArray(16), endianness.big);
testBinaryRead("./input/tu32.bin", makeUnsignedArray(32), endianness.big);
testBinaryRead("./input/tu64.bin", makeUnsignedArray(64), endianness.big);

testBinaryRead("./input/tu16le.bin", makeUnsignedArray(16), ioendian.little);
testBinaryRead("./input/tu32le.bin", makeUnsignedArray(32), ioendian.little);
testBinaryRead("./input/tu64le.bin", makeUnsignedArray(64), ioendian.little);
testBinaryRead("./input/tu16le.bin", makeUnsignedArray(16), endianness.little);
testBinaryRead("./input/tu32le.bin", makeUnsignedArray(32), endianness.little);
testBinaryRead("./input/tu64le.bin", makeUnsignedArray(64), endianness.little);

testBinaryRead("./input/ti8.bin", makeSignedArray(8));

testBinaryRead("./input/ti16.bin", makeSignedArray(16), ioendian.big);
testBinaryRead("./input/ti32.bin", makeSignedArray(32), ioendian.big);
testBinaryRead("./input/ti64.bin", makeSignedArray(64), ioendian.big);
testBinaryRead("./input/ti16.bin", makeSignedArray(16), endianness.big);
testBinaryRead("./input/ti32.bin", makeSignedArray(32), endianness.big);
testBinaryRead("./input/ti64.bin", makeSignedArray(64), endianness.big);

testBinaryRead("./input/ti16le.bin", makeSignedArray(16), ioendian.little);
testBinaryRead("./input/ti32le.bin", makeSignedArray(32), ioendian.little);
testBinaryRead("./input/ti64le.bin", makeSignedArray(64), ioendian.little);
testBinaryRead("./input/ti16le.bin", makeSignedArray(16), endianness.little);
testBinaryRead("./input/ti32le.bin", makeSignedArray(32), endianness.little);
testBinaryRead("./input/ti64le.bin", makeSignedArray(64), endianness.little);

proc testBinaryRead(path: string, expected_values, endian: ioendian = ioendian.native) {
proc testBinaryRead(path: string, expected_values, endian: endianness = endianness.native) {
var reader = openReader(path);
var values : expected_values.type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on Locales[0] {
var a : [0..<8] uint(8);

on Locales[2] {
const numRead = reader.readBinary(a, ioendian.native),
const numRead = reader.readBinary(a, endianness.native),
correct = && reduce (a == a_expected);
writeln(numRead, " ", correct);
}
Expand Down
Loading

0 comments on commit 1d9fc08

Please sign in to comment.