www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - std.stream Patch

reply Trevor Parscal <Trevor_member pathlink.com> writes:
On line 2313 (in the EndianStream class), the list of read functions that are
wrapped is incomplete, specificly missing char, byte, and ubyte.

The completed list is as follow, where the // New comment is indicative of the
added functions. The comments should be removed in the actual source IMHO.

:   Line 2313 :
void read(out byte x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); } // New
void read(out ubyte x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); } // New
void read(out short x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ushort x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out int x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out uint x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out long x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ulong x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out float x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out double x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out real x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ifloat x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out idouble x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ireal x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out cfloat x) { readExact(&x, x.sizeof);
fixBlockBO(&x,float.sizeof,2); }
void read(out cdouble x) { readExact(&x, x.sizeof);
fixBlockBO(&x,double.sizeof,2); }
void read(out creal x) { readExact(&x, x.sizeof); fixBlockBO(&x,real.sizeof,2);
}
void read(out wchar x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out char x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); } // New
void read(out dchar x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }

Thanks,
Trevor Parscal
Feb 01 2006
parent reply Trevor Parscal <Trevor_member pathlink.com> writes:
In article <drps5k$7l8$1 digitaldaemon.com>, Trevor Parscal says...
On line 2313 (in the EndianStream class), the list of read functions that are
wrapped is incomplete, specificly missing char, byte, and ubyte.

The completed list is as follow, where the // New comment is indicative of the
added functions. The comments should be removed in the actual source IMHO.

:   Line 2313 :
void read(out byte x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); } // New
void read(out ubyte x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); } // New
void read(out short x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ushort x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out int x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out uint x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out long x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ulong x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out float x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out double x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out real x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ifloat x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out idouble x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ireal x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out cfloat x) { readExact(&x, x.sizeof);
fixBlockBO(&x,float.sizeof,2); }
void read(out cdouble x) { readExact(&x, x.sizeof);
fixBlockBO(&x,double.sizeof,2); }
void read(out creal x) { readExact(&x, x.sizeof); fixBlockBO(&x,real.sizeof,2);
}
void read(out wchar x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out char x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); } // New
void read(out dchar x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }

Thanks,
Trevor Parscal
Or is this stupid - cause I just realize, while it is true that the types need to be there, so if you want to grab a raw byte from an EndianStream, you can without it throwing errors - there is no need to byte swap a char, byte, or ubyte.. so.. the new lines should probably just say.. void read(out byte x) { readExact(&x, x.sizeof); } // New void read(out ubyte x) { readExact(&x, x.sizeof); } // New .. void read(out char x) { readExact(&x, x.sizeof); } // New Thoughts? Thanks, Trevor Parscal
Feb 01 2006
parent reply "Ben Hinkle" <ben.hinkle gmail.com> writes:
"Trevor Parscal" <Trevor_member pathlink.com> wrote in message 
news:drpt4s$947$1 digitaldaemon.com...
 In article <drps5k$7l8$1 digitaldaemon.com>, Trevor Parscal says...
On line 2313 (in the EndianStream class), the list of read functions that 
are
wrapped is incomplete, specificly missing char, byte, and ubyte.

The completed list is as follow, where the // New comment is indicative of 
the
added functions. The comments should be removed in the actual source IMHO.

:   Line 2313 :
void read(out byte x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); } // 
New
void read(out ubyte x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); } // 
New
void read(out short x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ushort x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out int x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out uint x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out long x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ulong x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out float x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out double x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out real x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ifloat x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out idouble x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ireal x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out cfloat x) { readExact(&x, x.sizeof);
fixBlockBO(&x,float.sizeof,2); }
void read(out cdouble x) { readExact(&x, x.sizeof);
fixBlockBO(&x,double.sizeof,2); }
void read(out creal x) { readExact(&x, x.sizeof); 
fixBlockBO(&x,real.sizeof,2);
}
void read(out wchar x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out char x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); } // 
New
void read(out dchar x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }

Thanks,
Trevor Parscal
Or is this stupid - cause I just realize, while it is true that the types need to be there, so if you want to grab a raw byte from an EndianStream, you can without it throwing errors - there is no need to byte swap a char, byte, or ubyte.. so.. the new lines should probably just say.. void read(out byte x) { readExact(&x, x.sizeof); } // New void read(out ubyte x) { readExact(&x, x.sizeof); } // New .. void read(out char x) { readExact(&x, x.sizeof); } // New Thoughts? Thanks, Trevor Parscal
Which is what the super class implementation already does. EndianStream only needs to override those methods of Stream that require endianness handling. The rest are inherited.
Feb 01 2006
parent Trevor Parscal <Trevor_member pathlink.com> writes:
In article <drqcfp$rc7$1 digitaldaemon.com>, Ben Hinkle says...
"Trevor Parscal" <Trevor_member pathlink.com> wrote in message 
news:drpt4s$947$1 digitaldaemon.com...
 In article <drps5k$7l8$1 digitaldaemon.com>, Trevor Parscal says...
On line 2313 (in the EndianStream class), the list of read functions that 
are
wrapped is incomplete, specificly missing char, byte, and ubyte.

The completed list is as follow, where the // New comment is indicative of 
the
added functions. The comments should be removed in the actual source IMHO.

:   Line 2313 :
void read(out byte x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); } // 
New
void read(out ubyte x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); } // 
New
void read(out short x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ushort x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out int x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out uint x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out long x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ulong x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out float x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out double x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out real x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ifloat x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out idouble x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out ireal x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out cfloat x) { readExact(&x, x.sizeof);
fixBlockBO(&x,float.sizeof,2); }
void read(out cdouble x) { readExact(&x, x.sizeof);
fixBlockBO(&x,double.sizeof,2); }
void read(out creal x) { readExact(&x, x.sizeof); 
fixBlockBO(&x,real.sizeof,2);
}
void read(out wchar x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
void read(out char x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); } // 
New
void read(out dchar x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }

Thanks,
Trevor Parscal
Or is this stupid - cause I just realize, while it is true that the types need to be there, so if you want to grab a raw byte from an EndianStream, you can without it throwing errors - there is no need to byte swap a char, byte, or ubyte.. so.. the new lines should probably just say.. void read(out byte x) { readExact(&x, x.sizeof); } // New void read(out ubyte x) { readExact(&x, x.sizeof); } // New .. void read(out char x) { readExact(&x, x.sizeof); } // New Thoughts? Thanks, Trevor Parscal
Which is what the super class implementation already does. EndianStream only needs to override those methods of Stream that require endianness handling. The rest are inherited.
Well - the compiler wasn't bringing the super class functions down for some reason.. I agree with what you said, and looked at it long and hard wondering why the hell it was working... But - this is the fix for now.. Thanks, Trevor Parscal
Feb 02 2006