History

big IO binary mode update; now support reading/writing signed and unsigned integers

Ge Wang committed 3 years ago

Commit 52e11991 parent f45b9f77 files · +769 −199Browse files

Unified · Split

7 files
  1. examples/io/read-byte.ck +4 −1
  2. examples/io/read-wav-raw.ck +149 −0
  3. notes/VERSIONS +22 −8
  4. src/core/chuck_io.cpp +300 −115
  5. src/core/chuck_io.h +9 −2
  6. src/core/chuck_oo.cpp +263 −71
  7. src/core/chuck_oo.h +22 −2
examples/io/read-byte.ck+4−1
@@ -28,8 +28,11 @@ int val; · 27 unmodified lines
2828 while( fio.more() )
2929 {
3030 // read the next byte
31− // (other options include IO.INT16 and IO.INT32)
3231 fio.readInt( IO.INT8 ) => val;
32+ // optionsss ^^^^^^^ | requires chuck-1.5.0.1 or higher
33+ // IO.INT8, IO.INT16, IO.INT32 (default to unsigned)
34+ // IO.UINT8, IO.UINT16, IO.UINT32 (explicitly unsigned)
35+ // IO.SINT6, IO.SINT16, IO.SINT32 (explicitly signed)
3336
3437 // print the value
3538 cherr <= val <= IO.newline();
examples/io/read-wav-raw.ck+149−0
@@ -0,0 +1,149 @@
1+//---------------------------------------------------------------------
2+// name: read-wav-raw.ck
3+// desc: example that illustrates manually parsing and rendering a
4+// mono WAV file. This demonstrates using FileIO in binary mode.
5+// FYI in practice, use SndBuf for easier audio file playback!
6+// requires: chuck-1.5.0.1 or higher
7+//
8+// author: Perry R. Cook
9+// date: Summer 2023
10+// credit "saigon44.wav": opening words from /Apocalypse Now/
11+//---------------------------------------------------------------------
12+
13+// warn people what is about to happen
14+<<< "raw mono WAV file reader!!", "" >>>;
15+
16+// default file
17+me.dir() + "saigon44.wav" => string filename;
18+// look at command line
19+if( me.args() > 0 ) me.arg(0) => filename;
20+
21+// instantiate a file IO object
22+FileIO fio;
23+
24+// open a file for reading in BINARY mode
25+fio.open( filename, IO.READ | IO.BINARY );
26+// ensure it's ok
27+if( !fio.good() )
28+{
29+ // print error message
30+ cherr <= "can't open file: " <= filename <= " for reading..."
31+ <= IO.newline();
32+ // bail
33+ me.exit();
34+}
35+
36+// variable to read into
37+int val;
38+// header
39+"0123456789abcdefghijklmnopqrstuvwxyzABCD" @=> string header;
40+
41+// .wav header details:
42+// struct wavhdr {
43+// char riff[4]; /* "RIFF" */
44+// int flength; /* file length in bytes */
45+// char wave[4]; /* "WAVE" */
46+// char fmt[4]; /* "fmt " */
47+// int block_size; /* in bytes (generally 16) */
48+// short format_tag; /* 1=PCM, 257=Mu-Law, 258=A-Law, 259=ADPCM */
49+// short num_chans; /* 1=mono, 2=stereo */
50+// int srate; /* Sampling rate in samples per second */
51+// int bytes_per_sec; /* bytes per second */
52+// short bytes_per_samp; /* 2=16-bit mono, 4=16-bit stereo */
53+// short bits_per_samp; /* Number of bits per sample */
54+// char data[4]; /* "data" */
55+// int dlength; /* data length in bytes (filelength - 44) */
56+// };
57+
58+// read in the WAV file header, field by field
59+// FYI since chuck-1.5.0.1, in binary mode, readInt() for IO.INT8,
60+// IO.INT16, or IO.INT32 by default returns unsigned integers; to read
61+// signed integers, call readInt() with IO.SINT8, IO.SINT16, or IO.SINT32
62+// e.g., IO.SINT16 is used below when reading signed 16-bits samples
63+
64+// "RIFF"
65+fio.readInt( IO.INT8 ) => val; header.setCharAt(0,val);
66+fio.readInt( IO.INT8 ) => val; header.setCharAt(1,val);
67+fio.readInt( IO.INT8 ) => val; header.setCharAt(2,val);
68+fio.readInt( IO.INT8 ) => val; header.setCharAt(3,val);
69+// file length
70+fio.readInt( IO.INT32 ) => int flength;
71+// "WAVE"
72+fio.readInt( IO.INT8 ) => val; header.setCharAt(8,val);
73+fio.readInt( IO.INT8 ) => val; header.setCharAt(9,val);
74+fio.readInt( IO.INT8 ) => val; header.setCharAt(10,val);
75+fio.readInt( IO.INT8 ) => val; header.setCharAt(11,val);
76+// "fmt "
77+fio.readInt( IO.INT8 ) => val; header.setCharAt(12,val);
78+fio.readInt( IO.INT8 ) => val; header.setCharAt(13,val);
79+fio.readInt( IO.INT8 ) => val; header.setCharAt(14,val);
80+fio.readInt( IO.INT8 ) => val; header.setCharAt(15,val);
81+// file info
82+fio.readInt( IO.INT32 ) => int blockSize;
83+fio.readInt( IO.INT16 ) => int format;
84+fio.readInt( IO.INT16 ) => int numChannels;
85+fio.readInt( IO.INT32 ) => int sRate;
86+fio.readInt( IO.INT32 ) => int bytesPerSecond;
87+fio.readInt( IO.INT16 ) => int bytesPerSample;
88+fio.readInt( IO.INT16 ) => int bitsPerSample;
89+// "data"
90+fio.readInt( IO.INT8 ) => val; header.setCharAt(36,val);
91+fio.readInt( IO.INT8 ) => val; header.setCharAt(37,val);
92+fio.readInt( IO.INT8 ) => val; header.setCharAt(38,val);
93+fio.readInt( IO.INT8 ) => val; header.setCharAt(39,val);
94+// size of data region in bytes
95+fio.readInt( IO.INT32 ) => int dLength;
96+
97+<<< "***", header, "***" >>>;
98+<<< "---------------------", "" >>>;
99+<<< "File Length =", flength >>>;
100+<<< "Block Size =", blockSize >>>;
101+<<< "Format =", format >>>;
102+<<< "Num Chans =", numChannels >>>;
103+<<< "Sample Rate =", sRate >>>;
104+<<< "Bytes/Sec =", bytesPerSecond >>>;
105+<<< "Bytes/Sample =", bytesPerSample >>>;
106+<<< "Bits/Sample =", bitsPerSample >>>;
107+<<< "Data Length =", dLength >>>;
108+<<< "---------------------", "" >>>;
109+
110+// check
111+if( numChannels > 1 )
112+{
113+ // print error message
114+ <<< "WAV file contains", numChannels, "channels..." >>>;
115+ <<< "this examples only supports mono WAV files...", "" >>>;
116+ // bail
117+ me.exit();
118+}
119+
120+// render the waveform
121+Impulse imp => dac;
122+// number of samples
123+dLength / bytesPerSample => int numSamples;
124+// array
125+float samples[numSamples];
126+// sample number
127+0 => int n;
128+
129+// loop until end
130+while( n < numSamples )
131+// while( fio.more() )
132+// (^ this may not always work; WAV files may contain debris beyond data region)
133+{
134+ // read the next sample: signed 16-bit integer
135+ fio.readInt( IO.SINT16 ) => int sample;
136+ // map sample value from [-32768,32767] to [-1,1]
137+ Math.remap(sample, -32768, 32767, -1, 1) => samples[n++] => imp.next;
138+ // print dot every 1000 samples
139+ if( n % 1000 == 0 ) {
140+ chout <= "."; chout.flush();
141+ }
142+ // print marker every second
143+ if( n % sRate == 0 ) {
144+ chout <= "|"; chout.flush();
145+ }
146+
147+ // advance one sample
148+ samp => now;
149+}
notes/VERSIONS+22−8
@@ -6,21 +6,35 @@ ChucK VERSIONS log · 5 unmodified lines
66 ---
77 * (added) WvOut support for multiple bit-depths: 16-bit signed int,
88 24-bit signed int, 32-bit signed int, 32-bit float, 64-bit float
9−* these can optionally specified in the newly overloaded WvOut methods:
9+* (added) the above can be optionally specified in new overloaded WvOut methods:
1010 string aifFilename( string value, int datatype );
1111 Open an AIFF file for writing, with datatype (e.g., IO.INT16,
1212 IO.INT24, IO.INT32, IO.FLOAT32, IO.FLOAT64).
13− string matFilename( string value, int datatype );
14− Open MATLAB file for writing; datatype for MATLAB files can
15− only be IO.FLOAT64.
1613 string sndFilename( string value, int datatype );
17− Open SND file for writing, with datatype (e.g., IO.INT16, IO.INT24, IO.INT32, IO.FLOAT32, IO.FLOAT64).
14+ Open SND file for writing, with datatype (e.g., IO.INT16, IO.INT24, IO.INT32,
15+ IO.FLOAT32, IO.FLOAT64).
1816 string wavFilename( string value, int datatype );
1917 Open WAVE file for writing, with datatype (e.g., IO.INT16, IO.INT24, IO.INT32, IO.FLOAT32, IO.FLOAT64).
18+ string matFilename( string value, int datatype );
19+ Open MATLAB file for writing; NOTE: datatype for MATLAB files can
20+ only be IO.FLOAT64.
2021 string rawFilename( string value, int datatype );
21− Open a RAW file for writing; datatype for raw files can
22− only be IO.INT16.
23−* (added) IO.INT24, IO.INT64, IO.FLOAT32, IO.FLOAT64 IO flags
22+ Open a RAW file for writing; NOTE: datatype for raw files can
23+ only be IO.INT16
24+* (added) examples/stk/wvout-24bit.ck shows writing to a 24-bit audio file
25+* (added) new IO flags: IO.INT24, IO.INT64, IO.FLOAT32, IO.FLOAT64
26+ IO.UINT8, IO.SINT8, IO.UINT16, IO.SINT16, IO.UINT32, IO.SINT32,
27+ IO.UINT64, IO.SINT64
28+* (updated) BINARY mode for IO now able to read signed vs. unsigned integers,
29+ specified using using .readtInt( flags ), where 'flags' is one of the above
30+ IO flags; in BINARY mode, IO.INT8/16/32 now returns unsigned integers, same as
31+ IO.UINT8/16/32; to read in signed two's complement integers, use the new
32+ IO.SINT8/16/32/64 flags
33+* (added) FileIO.readFloat( int flags) and FileIO.write( float val, int flags )
34+ these overloaded versions of readFloat() and write() respectively have a 'flags'
35+ argument to specify the kind of float (IO.FLOAT32 or IO.FLOAT64)
36+* (added) examples/io/read-wav-raw.ck -- illustrates directly parsing a WAV file
37+ using FileIO in binary mode (author: Perry R. Cook)
2438 * (added) examples/special/scream-o-matic/ -- using LiSa + granular
2539 synthesis for a scream texture generator.
2640 * (updated) on Linux, better default runtime driver selection for
src/core/chuck_io.cpp+300−115
@@ -105,93 +105,78 @@ t_CKBOOL init_class_io( Chuck_Env * env, Chuck_Type * type ) · 104 unmodified lines
105105 return FALSE;
106106
107107 // add good()
108− func = make_new_mfun( "int", "good", io_dummy );
108+ func = make_new_mfun( "int", "good", io_dummy_int );
109109 func->doc = "Returns whether IO is ready for reading.";
110110 if( !type_engine_import_mfun( env, func ) ) goto error;
111111
112112 // add close()
113− func = make_new_mfun( "void", "close", io_dummy );
113+ func = make_new_mfun( "void", "close", io_dummy_void );
114114 func->doc = "Close the currently open IO.";
115115 if( !type_engine_import_mfun( env, func ) ) goto error;
116116
117117 // add flush()
118− func = make_new_mfun( "void", "flush", io_dummy );
118+ func = make_new_mfun( "void", "flush", io_dummy_void );
119119 func->doc = "Write any buffered output.";
120120 if( !type_engine_import_mfun( env, func ) ) goto error;
121121
122122 // add mode(int)
123− func = make_new_mfun( "int", "mode", io_dummy );
123+ func = make_new_mfun( "int", "mode", io_dummy_int );
124124 func->add_arg( "int", "flag" );
125125 func->doc = "Set the current IO mode; either IO.MODE_ASYNC or IO.MODE_SYNC.";
126126 if( !type_engine_import_mfun( env, func ) ) goto error;
127127
128128 // add mode()
129− func = make_new_mfun( "int", "mode", io_dummy );
129+ func = make_new_mfun( "int", "mode", io_dummy_int );
130130 func->doc = "Get the current IO mode; either IO.MODE_ASYNC or IO.MODE_SYNC.";
131131 if( !type_engine_import_mfun( env, func ) ) goto error;
132132
133133 // TODO: add this later?
134134 // add read()
135− // func = make_new_mfun( "string", "read", io_dummy );
135+ // func = make_new_mfun( "string", "read", io_dummy_string );
136136 // func->add_arg( "int", "length" );
137137 // if( !type_engine_import_mfun( env, func ) ) goto error;
138138
139139 // add readLine()
140− func = make_new_mfun( "string", "readLine", io_dummy );
140+ func = make_new_mfun( "string", "readLine", io_dummy_string );
141141 func->doc = "Read until an end-of-line character.";
142142 if( !type_engine_import_mfun( env, func ) ) goto error;
143143
144144 // add readInt()
145− func = make_new_mfun( "int", "readInt", io_dummy );
145+ func = make_new_mfun( "int", "readInt", io_dummy_int );
146146 func->add_arg( "int", "flags" );
147− func->doc = "Read and return the next integer (binary mode); 'flags' denotes the bit-size of int (IO.INT8, IO.INT16, or IO.INT32).";
147+ func->doc = "Read and return the next integer; binary mode: 'flags' denotes the bit-size of int (IO.INT8, IO.INT16, or IO.INT32).";
148148 if( !type_engine_import_mfun( env, func ) ) goto error;
149149
150− /*
151− // add readInt()
152− func = make_new_mfun( "int", "readInt8", io_dummy );
153− func->add_arg( "int", "flags" );
154− if( !type_engine_import_mfun( env, func ) ) goto error;
155−
156− // add readInt()
157− func = make_new_mfun( "int", "readInt16", io_dummy );
158− func->add_arg( "int", "flags" );
159− if( !type_engine_import_mfun( env, func ) ) goto error;
160−
161− // add readInt()
162− func = make_new_mfun( "int", "readInt32", io_dummy );
150+ // add readFloat()
151+ func = make_new_mfun( "float", "readFloat", io_dummy_float );
163152 func->add_arg( "int", "flags" );
153+ func->doc = "Read and return the next floating point value; binary mode: 'flags' denotes the size of float to read (IO.FLOAT32 or IO.FLOAT64).";
164154 if( !type_engine_import_mfun( env, func ) ) goto error;
165− */
166−
167− // add readFloat()
168− // func = make_new_mfun( "float", "readFloat", io_dummy );
169− // if( !type_engine_import_mfun( env, func ) ) goto error;
170155
171156 // add eof()
172− func = make_new_mfun( "int", "eof", io_dummy );
157+ func = make_new_mfun( "int", "eof", io_dummy_int );
173158 func->doc = "Return whether end-of-file has been reached; the opposite of .more().";
174159 if( !type_engine_import_mfun( env, func ) ) goto error;
175160
176161 // add more()
177− func = make_new_mfun( "int", "more", io_dummy );
162+ func = make_new_mfun( "int", "more", io_dummy_int );
178163 func->doc = "Return whether there is more to read; the opposite of .eof().";
179164 if( !type_engine_import_mfun( env, func ) ) goto error;
180165
181166 // add write(string)
182− func = make_new_mfun( "void", "write", io_dummy );
167+ func = make_new_mfun( "void", "write", io_dummy_void );
183168 func->add_arg( "string", "val" );
184169 func->doc = "Write string 'val'.";
185170 if( !type_engine_import_mfun( env, func ) ) goto error;
186171
187172 // add write(int)
188− func = make_new_mfun( "void", "write", io_dummy );
173+ func = make_new_mfun( "void", "write", io_dummy_void );
189174 func->add_arg( "int", "val" );
190175 func->doc = "Write integer 'val'.";
191176 if( !type_engine_import_mfun( env, func ) ) goto error;
192177
193178 // add write(float)
194− func = make_new_mfun( "void", "write", io_dummy );
179+ func = make_new_mfun( "void", "write", io_dummy_void );
195180 func->add_arg( "float", "val" );
196181 func->doc = "Write floating point number 'val'.";
197182 if( !type_engine_import_mfun( env, func ) ) goto error;
@@ -233,21 +218,42 @@ t_CKBOOL init_class_io( Chuck_Env * env, Chuck_Type * type ) · 35 unmodified lines
233218 // add INT64 | 1.5.0.1 (ge) added
234219 if( !type_engine_import_svar( env, "int", "INT64",
235220 TRUE, (t_CKUINT)&Chuck_IO::INT64, "Flag denoting 64-bit integer type." ) ) goto error;
221+ // add SINT8 | 1.5.0.1 (ge) added
222+ if( !type_engine_import_svar( env, "int", "SINT8",
223+ TRUE, (t_CKUINT)&Chuck_IO::SINT8, "Flag denoting 8-bit signed integer type." ) ) goto error;
224+ // add SINT16 | 1.5.0.1 (ge) added
225+ if( !type_engine_import_svar( env, "int", "SINT16",
226+ TRUE, (t_CKUINT)&Chuck_IO::SINT16, "Flag denoting 16-bit signed integer type." ) ) goto error;
227+ // add SINT24 | 1.5.0.1 (ge) added
228+ if( !type_engine_import_svar( env, "int", "SINT24",
229+ TRUE, (t_CKUINT)&Chuck_IO::SINT24, "Flag denoting 24-bit signed integer type." ) ) goto error;
230+ // add SINT32 | 1.5.0.1 (ge) added
231+ if( !type_engine_import_svar( env, "int", "SINT32",
232+ TRUE, (t_CKUINT)&Chuck_IO::SINT32, "Flag denoting 32-bit signed integer type." ) ) goto error;
233+ // add SINT64 | 1.5.0.1 (ge) added
234+ if( !type_engine_import_svar( env, "int", "SINT64",
235+ TRUE, (t_CKUINT)&Chuck_IO::SINT64, "Flag denoting 64-bit signed integer type." ) ) goto error;
236+ // add UINT8 | 1.5.0.1 (ge) added
237+ if( !type_engine_import_svar( env, "int", "UINT8",
238+ TRUE, (t_CKUINT)&Chuck_IO::UINT8, "Flag denoting 8-bit unsigned integer type." ) ) goto error;
239+ // add UINT16 | 1.5.0.1 (ge) added
240+ if( !type_engine_import_svar( env, "int", "UINT16",
241+ TRUE, (t_CKUINT)&Chuck_IO::UINT16, "Flag denoting 16-bit unsigned integer type." ) ) goto error;
242+ // add UINT24 | 1.5.0.1 (ge) added
243+ if( !type_engine_import_svar( env, "int", "UINT24",
244+ TRUE, (t_CKUINT)&Chuck_IO::UINT24, "Flag denoting 24-bit unsigned integer type." ) ) goto error;
245+ // add UINT32 | 1.5.0.1 (ge) added
246+ if( !type_engine_import_svar( env, "int", "UINT32",
247+ TRUE, (t_CKUINT)&Chuck_IO::UINT32, "Flag denoting 32-bit unsigned integer type." ) ) goto error;
248+ // add UINT64 | 1.5.0.1 (ge) added
249+ if( !type_engine_import_svar( env, "int", "UINT64",
250+ TRUE, (t_CKUINT)&Chuck_IO::UINT64, "Flag denoting 64-bit unsigned integer type." ) ) goto error;
236251 // add FLOAT32 | 1.5.0.1 (ge) added
237252 if( !type_engine_import_svar( env, "int", "FLOAT32",
238253 TRUE, (t_CKUINT)&Chuck_IO::FLOAT32, "Flag denoting 32-bit floating point type." ) ) goto error;
239254 // add FLOAT64 | 1.5.0.1 (ge) added
240255 if( !type_engine_import_svar( env, "int", "FLOAT64",
241256 TRUE, (t_CKUINT)&Chuck_IO::FLOAT64, "Flag denoting 64-bit floating point type." ) ) goto error;
242−// // add READ_INT8
243−// if( !type_engine_import_svar( env, "int", "READ_INT8",
244−// TRUE, (t_CKUINT)&Chuck_IO::INT8, "Flag denoting 8-bit integer type (same as INT8)." ) ) goto error;
245−// // add READ_INT16
246−// if( !type_engine_import_svar( env, "int", "READ_INT16",
247−// TRUE, (t_CKUINT)&Chuck_IO::INT16, "Flag denoting 16-bit integer type (same as INT16)." ) ) goto error;
248−// // add READ_INT32
249−// if( !type_engine_import_svar( env, "int", "READ_INT32",
250−// TRUE, (t_CKUINT)&Chuck_IO::INT32, "Flag denoting 32-bit integer type (same as INT32)." ) ) goto error;
251257 // add MODE_SYNC
252258 if( !type_engine_import_svar( env, "int", "MODE_SYNC",
253259 TRUE, (t_CKUINT)&Chuck_IO::MODE_SYNC, "Flag denoting synchronous IO." ) ) goto error;
@@ -387,34 +393,19 @@ t_CKBOOL init_class_fileio( Chuck_Env * env, Chuck_Type * type ) · 133 unmodified lines
387393 // add readInt(int)
388394 func = make_new_mfun( "int", "readInt", fileio_readintflags );
389395 func->add_arg( "int", "flags" );
390− func->doc = "Read and return an integer by size (binary mode) as specified in 'flags' (IO.INT8, IO.INT16, IO.INT32).";
391− if( !type_engine_import_mfun( env, func ) ) goto error;
392−
393− /*
394− // add readByte()
395− func = make_new_mfun( "int", "readByte", fileio_readint8 );
396− func->add_arg( "int", "flags" );
397− if( !type_engine_import_mfun( env, func ) ) goto error;
398−
399− // add readInt8()
400− func = make_new_mfun( "int", "readInt8", fileio_readint8 );
401− func->add_arg( "int", "flags" );
396+ func->doc = "Read and return an integer; binary mode: 'flags' specifies int size to read (IO.INT8, IO.INT16, IO.INT32 default to unsigned values; for signed integers use IO.SINT8, IO.SINT16, IO.SINT32).";
402397 if( !type_engine_import_mfun( env, func ) ) goto error;
403398
404− // add readInt16()
405− func = make_new_mfun( "int", "readInt16", fileio_readint16 );
406− func->add_arg( "int", "flags" );
399+ // add readFloat()
400+ func = make_new_mfun( "float", "readFloat", fileio_readfloat );
401+ func->doc = "Read and return the next floating point value.";
407402 if( !type_engine_import_mfun( env, func ) ) goto error;
408403
409− // add readInt32()
410− func = make_new_mfun( "int", "readInt32", fileio_readint32 );
404+ // add readFloat()
405+ func = make_new_mfun( "float", "readFloat", fileio_readfloatflags );
411406 func->add_arg( "int", "flags" );
407+ func->doc = "Read and return the next floating point value; if binary mode: 'flags' denotes the size of float to read (IO.FLOAT32 or IO.FLOAT64).";
412408 if( !type_engine_import_mfun( env, func ) ) goto error;
413− */
414−
415− // add readFloat()
416− // func = make_new_mfun( "float", "readFloat", fileio_readfloat );
417− // if( !type_engine_import_mfun( env, func ) ) goto error;
418409
419410 // add eof()
420411 func = make_new_mfun( "int", "eof", fileio_eof );
@@ -442,13 +433,20 @@ t_CKBOOL init_class_fileio( Chuck_Env * env, Chuck_Type * type ) · 21 unmodified lines
442433 func = make_new_mfun( "void", "write", fileio_writeintflags );
443434 func->add_arg( "int", "val" );
444435 func->add_arg( "int", "flags" );
445− func->doc = "Write integer to file (binary mode) by size as specified by 'flags' (IO.INT8, IO.INT16, IO.INT32).";
436+ func->doc = "Write integer value to file; binary mode: int size specified by 'flags' (IO.INT8, IO.INT16, IO.INT32).";
446437 if( !type_engine_import_mfun( env, func ) ) goto error;
447438
448439 // add write(float)
449440 func = make_new_mfun( "void", "write", fileio_writefloat );
450441 func->add_arg( "float", "val" );
451− func->doc = "Write integer to file.";
442+ func->doc = "Write floating point value to file.";
443+ if( !type_engine_import_mfun( env, func ) ) goto error;
444+
445+ // add write(float)
446+ func = make_new_mfun( "void", "write", fileio_writefloatflags );
447+ func->add_arg( "float", "val" );
448+ func->add_arg( "int", "flags" );
449+ func->doc = "Write floating point value to file; binary mode: flags indicate float size (IO.FLOAT32 or IO.FLOAT64).";
452450 if( !type_engine_import_mfun( env, func ) ) goto error;
453451
454452 // add examples
@@ -522,10 +520,6 @@ t_CKBOOL init_class_chout( Chuck_Env * env, Chuck_Type * type ) · 67 unmodified lines
522520 func = make_new_mfun( "string", "readLine", chout_readline );
523521 if( !type_engine_import_mfun( env, func ) ) goto error;
524522
525− // add readInt()
526− // func = make_new_mfun( "int", "readInt", chout_readint );
527− // if( !type_engine_import_mfun( env, func ) ) goto error;
528−
529523 // add readInt(int)
530524 func = make_new_mfun( "int", "readInt", chout_readintflags );
531525 func->add_arg( "int", "flags" );
@@ -533,6 +527,7 @@ t_CKBOOL init_class_chout( Chuck_Env * env, Chuck_Type * type ) · 1 unmodified line
533527
534528 // add readFloat()
535529 // func = make_new_mfun( "float", "readFloat", chout_readfloat );
530+ // func->add_arg( "int", "flags" );
536531 // if( !type_engine_import_mfun( env, func ) ) goto error;
537532
538533 // add eof()
@@ -615,17 +610,14 @@ t_CKBOOL init_class_cherr( Chuck_Env * env, Chuck_Type * type ) · 76 unmodified lines
615610 func = make_new_mfun( "string", "readLine", cherr_readline );
616611 if( !type_engine_import_mfun( env, func ) ) goto error;
617612
618− // add readInt()
619− // func = make_new_mfun( "int", "readInt", cherr_readint );
620− // if( !type_engine_import_mfun( env, func ) ) goto error;
621−
622613 // add readInt(int)
623− func = make_new_mfun( "int", "readInt", cherr_readintflags );
624− func->add_arg( "int", "flags" );
625− if( !type_engine_import_mfun( env, func ) ) goto error;
614+ // func = make_new_mfun( "int", "readInt", cherr_readintflags );
615+ // func->add_arg( "int", "flags" );
616+ // if( !type_engine_import_mfun( env, func ) ) goto error;
626617
627618 // add readFloat()
628619 // func = make_new_mfun( "float", "readFloat", cherr_readfloat );
620+ // func->add_arg( "int", "flags" );
629621 // if( !type_engine_import_mfun( env, func ) ) goto error;
630622
631623 // add eof()
@@ -1507,14 +1499,31 @@ error: · 875 unmodified lines
15071499 //-----------------------------------------------------------------------------
15081500 // IO API
15091501 //-----------------------------------------------------------------------------
1510−CK_DLL_MFUN( io_dummy )
1502+CK_DLL_MFUN( io_dummy_int )
15111503 {
1512− EM_error3( "(IO): internal error! inside an abstract function! help!" );
1513− EM_error3( " note: please hunt down someone (e.g., Ge) to fix this..." );
1514− assert( FALSE );
1504+ // EM_error3( "(IO): internal error! inside an abstract function! help!" );
1505+ // EM_error3( " note: please hunt down someone (e.g., Ge) to fix this..." );
1506+ // assert( FALSE );
15151507 RETURN->v_int = 0;
15161508 }
15171509
1510+CK_DLL_MFUN( io_dummy_float )
1511+{
1512+ // return 0.0
1513+ RETURN->v_float = 0;
1514+}
1515+
1516+CK_DLL_MFUN( io_dummy_string )
1517+{
1518+ // return NULL
1519+ RETURN->v_string = NULL;
1520+}
1521+
1522+CK_DLL_MFUN( io_dummy_void )
1523+{
1524+ // do nothing
1525+}
1526+
15181527 CK_DLL_SFUN( io_newline )
15191528 {
15201529 RETURN->v_string = g_newline;
@@ -1681,21 +1690,18 @@ CK_DLL_MFUN( fileio_readintflags ) · 160 unmodified lines
16811690
16821691 CK_DLL_MFUN( fileio_readint8 )
16831692 {
1684− t_CKINT flags = GET_NEXT_INT(ARGS);
16851693 Chuck_IO_File * f = (Chuck_IO_File *)SELF;
16861694 RETURN->v_int = f->readInt( Chuck_IO::INT8 );
16871695 }
16881696
16891697 CK_DLL_MFUN( fileio_readint16 )
16901698 {
1691− t_CKINT flags = GET_NEXT_INT(ARGS);
16921699 Chuck_IO_File * f = (Chuck_IO_File *)SELF;
16931700 RETURN->v_int = f->readInt( Chuck_IO::INT16 );
16941701 }
16951702
16961703 CK_DLL_MFUN( fileio_readint32 )
16971704 {
1698− t_CKINT flags = GET_NEXT_INT(ARGS);
16991705 Chuck_IO_File * f = (Chuck_IO_File *)SELF;
17001706 RETURN->v_int = f->readInt( Chuck_IO::INT32 );
17011707 }
@@ -1703,8 +1709,14 @@ CK_DLL_MFUN( fileio_readint32 ) · 1 unmodified line
17031709 CK_DLL_MFUN( fileio_readfloat )
17041710 {
17051711 Chuck_IO_File * f = (Chuck_IO_File *)SELF;
1706− t_CKFLOAT ret = f->readFloat();
1707− RETURN->v_float = ret;
1712+ RETURN->v_float = f->readFloat();
1713+}
1714+
1715+CK_DLL_MFUN( fileio_readfloatflags )
1716+{
1717+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
1718+ t_CKINT flags = GET_NEXT_INT(ARGS);
1719+ RETURN->v_float = f->readFloat( flags );
17081720 }
17091721
17101722 CK_DLL_MFUN( fileio_eof )
@@ -1835,6 +1847,7 @@ CK_DLL_MFUN( fileio_writeintflags ) · 124 unmodified lines
18351847 CK_DLL_MFUN( fileio_writefloat )
18361848 {
18371849 t_CKFLOAT val = GET_NEXT_FLOAT(ARGS);
1850+ t_CKINT flagsDefault = Chuck_IO::FLOAT32;
18381851 Chuck_IO_File * f = (Chuck_IO_File *)SELF;
18391852
18401853 #ifndef __DISABLE_FILEIO__ // 1.5.0.0 (ge) | made more granular (e.g., for WebChucK)
@@ -1845,6 +1858,7 @@ CK_DLL_MFUN( fileio_writefloat ) · 4 unmodified lines
18451858 args->RETURN = (void *)RETURN;
18461859 args->fileio_obj = f;
18471860 args->floatArg = val;
1861+ args->intArg = flagsDefault; // 1.5.0.1 (ge) add default
18481862 // set shred to wait for I/O completion
18491863 assert( SHRED != NULL );
18501864 f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
@@ -1861,10 +1875,48 @@ CK_DLL_MFUN( fileio_writefloat ) · 10 unmodified lines
18611875 }
18621876 }
18631877 } else {
1864− f->write(val);
1878+ f->write( val, flagsDefault );
18651879 }
18661880 #else
1867− f->write(val);
1881+ f->write( val, flagsDefault );
1882+#endif //__DISABLE_FILEIO__
1883+}
1884+
1885+CK_DLL_MFUN( fileio_writefloatflags )
1886+{
1887+ t_CKFLOAT val = GET_NEXT_FLOAT(ARGS);
1888+ t_CKINT flags = GET_NEXT_INT(ARGS);
1889+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
1890+
1891+#ifndef __DISABLE_FILEIO__ // 1.5.0.0 (ge) | made more granular (e.g., for WebChucK)
1892+ if (f->mode() == Chuck_IO::MODE_ASYNC)
1893+ {
1894+ // set up arguments
1895+ Chuck_IO::async_args *args = new Chuck_IO::async_args;
1896+ args->RETURN = (void *)RETURN;
1897+ args->fileio_obj = f;
1898+ args->floatArg = val;
1899+ args->intArg = flags; // 1.5.0.1 (ge) added
1900+ // set shred to wait for I/O completion
1901+ assert( SHRED != NULL );
1902+ f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
1903+ // start thread
1904+ bool ret = f->m_thread->start( f->writeFloat_thread, (void *)args );
1905+ if (!ret) {
1906+ // for some reason, the XThread object needs to be
1907+ // deleted and reconstructed every time after call #375
1908+ delete f->m_thread;
1909+ f->m_thread = new XThread;
1910+ ret = f->m_thread->start( f->writeFloat_thread, (void *)args );
1911+ if (!ret) {
1912+ EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
1913+ }
1914+ }
1915+ } else {
1916+ f->write( val,flags );
1917+ }
1918+#else
1919+ f->write( val,flags );
18681920 #endif //__DISABLE_FILEIO__
18691921 }
18701922
@@ -3123,7 +3175,7 @@ t_CKINT Chuck_IO_Serial::readInt( t_CKINT flags ) · 1252 unmodified lines
31233175
31243176 if( m_flags & Chuck_IO::TYPE_BINARY )
31253177 {
3126− if( flags & INT8 )
3178+ if( flags & Chuck_IO::INT8 || flags & Chuck_IO::UINT8 ) // 1.5.0.1 (ge) added UINT
31273179 {
31283180 uint8_t byte = 0;
31293181 if(!fread(&byte, 1, 1, m_cfd))
@@ -3131,7 +3183,7 @@ t_CKINT Chuck_IO_Serial::readInt( t_CKINT flags ) · 1 unmodified line
31313183
31323184 i = byte;
31333185 }
3134− else if( flags & INT16 )
3186+ else if( flags & Chuck_IO::INT16 || flags & Chuck_IO::UINT16 ) // 1.5.0.1 (ge) added UINT
31353187 {
31363188 uint16_t word = 0;
31373189 if(!fread(&word, 2, 1, m_cfd))
@@ -3139,7 +3191,7 @@ t_CKINT Chuck_IO_Serial::readInt( t_CKINT flags ) · 1 unmodified line
31393191
31403192 i = word;
31413193 }
3142− else if( flags & INT32 )
3194+ else if( flags & Chuck_IO::INT32 || flags & Chuck_IO::UINT32 ) // 1.5.0.1 (ge) added UINT
31433195 {
31443196 uint32_t dword = 0;
31453197 if(!fread(&dword, 4, 1, m_cfd))
@@ -3147,6 +3199,46 @@ t_CKINT Chuck_IO_Serial::readInt( t_CKINT flags ) · 1 unmodified line
31473199
31483200 i = dword;
31493201 }
3202+ else if( flags & Chuck_IO::INT64 || flags & Chuck_IO::UINT64 ) // 1.5.0.1 (ge) added UINT and 64-bit
3203+ {
3204+ uint64_t val = 0;
3205+ if(!fread(&val, 8, 1, m_cfd))
3206+ EM_log(CK_LOG_WARNING, "(Serial.readInt): error: read failed");
3207+
3208+ i = val;
3209+ }
3210+ else if( flags & Chuck_IO::SINT8 ) // 1.5.0.1 (ge) added SINT
3211+ {
3212+ int8_t byte = 0;
3213+ if(!fread(&byte, 1, 1, m_cfd))
3214+ EM_log(CK_LOG_WARNING, "(Serial.readInt): error: read failed");
3215+
3216+ i = byte;
3217+ }
3218+ else if( flags & Chuck_IO::SINT16 ) // 1.5.0.1 (ge) added SINT
3219+ {
3220+ int16_t word = 0;
3221+ if(!fread(&word, 2, 1, m_cfd))
3222+ EM_log(CK_LOG_WARNING, "(Serial.readInt): error: read failed");
3223+
3224+ i = word;
3225+ }
3226+ else if( flags & Chuck_IO::SINT32 ) // 1.5.0.1 (ge) added SINT
3227+ {
3228+ int32_t dword = 0;
3229+ if(!fread(&dword, 4, 1, m_cfd))
3230+ EM_log(CK_LOG_WARNING, "(Serial.readInt): error: read failed");
3231+
3232+ i = dword;
3233+ }
3234+ else if( flags & Chuck_IO::SINT64 ) // 1.5.0.1 (ge) added SINT and 64-bit
3235+ {
3236+ int64_t val = 0;
3237+ if(!fread(&val, 8, 1, m_cfd))
3238+ EM_log(CK_LOG_WARNING, "(Serial.readInt): error: read failed");
3239+
3240+ i = val;
3241+ }
31503242 }
31513243 else
31523244 {
@@ -3157,7 +3249,13 @@ t_CKINT Chuck_IO_Serial::readInt( t_CKINT flags ) · 4 unmodified lines
31573249 return i;
31583250 }
31593251
3160−t_CKFLOAT Chuck_IO_Serial::readFloat()
3252+t_CKFLOAT Chuck_IO_Serial::readFloat( )
3253+{
3254+ // 1.5.0.1 (ge) redirect
3255+ return readFloat( Chuck_IO::FLOAT32 );
3256+}
3257+
3258+t_CKFLOAT Chuck_IO_Serial::readFloat( t_CKINT flags )
31613259 {
31623260 if( !good() )
31633261 {
@@ -3175,8 +3273,26 @@ t_CKFLOAT Chuck_IO_Serial::readFloat() · 11 unmodified lines
31753273
31763274 if( m_flags & Chuck_IO::TYPE_BINARY )
31773275 {
3178− if(!fread(&f, 4, 1, m_cfd))
3179− EM_log(CK_LOG_WARNING, "(Serial.readFloat): error: read failed");
3276+ // check size
3277+ if( flags & Chuck_IO::FLOAT32 )
3278+ {
3279+ float v = 0.0f;
3280+ if(!fread(&v, 4, 1, m_cfd))
3281+ EM_log(CK_LOG_WARNING, "(Serial.readFloat): error: read failed");
3282+ f = v;
3283+ }
3284+ else if( flags & Chuck_IO::FLOAT64 )
3285+ {
3286+ double v = 0.0;
3287+ if( !fread(&v, 8, 1, m_cfd) )
3288+ EM_log(CK_LOG_WARNING, "(Serial.readFloat): error: read failed");
3289+ f = v;
3290+ }
3291+ else
3292+ {
3293+ // error message
3294+ EM_log(CK_LOG_WARNING, "(Serial.readFloat): invalid or unsupported size flag");
3295+ }
31803296 }
31813297 else
31823298 {
@@ -3213,7 +3329,7 @@ t_CKBOOL Chuck_IO_Serial::readString( std::string & str ) · 30 unmodified lines
32133329 return FALSE;
32143330 }
32153331
3216− str = (char *) m_tmp_buf;
3332+ str = (char *) m_tmp_buf;
32173333
32183334 return TRUE;
32193335 }
@@ -3304,11 +3420,11 @@ void Chuck_IO_Serial::write( const std::string & val ) · 84 unmodified lines
33043420
33053421 void Chuck_IO_Serial::write( t_CKINT val )
33063422 {
3307− write( val, 4 );
3423+ write( val, Chuck_IO::INT32 );
33083424 }
33093425
33103426
3311−void Chuck_IO_Serial::write( t_CKINT val, t_CKINT size )
3427+void Chuck_IO_Serial::write( t_CKINT val, t_CKINT flags )
33123428 {
33133429 if( !good() )
33143430 {
@@ -3316,9 +3432,11 @@ void Chuck_IO_Serial::write( t_CKINT val, t_CKINT size ) · 1 unmodified line
33163432 return;
33173433 }
33183434
3319− if(!(size == 1 || size == 2 || size == 4 || size == 8))
3435+ // check flags
3436+ if( (flags & Chuck_IO::INT8 ) || (flags & Chuck_IO::INT16) ||
3437+ (flags & Chuck_IO::INT32) || (flags & Chuck_IO::INT64) )
33203438 {
3321− EM_log(CK_LOG_WARNING, "(Serial.write): warning: invalid int size %li, ignoring write request", size);
3439+ EM_log( CK_LOG_WARNING, "(Serial.write): warning: invalid int size flag, ignoring write request" );
33223440 return;
33233441 }
33243442
@@ -3350,11 +3468,23 @@ void Chuck_IO_Serial::write( t_CKINT val, t_CKINT size ) · 25 unmodified lines
33503468 }
33513469 else
33523470 {
3353− char * buf = (char *)&val;
3354−
3355− // assume 4-byte int
3471+ // 1.5.0.1 (ge) check and handle individually
3472+ uint8_t v8 = (uint8_t)val;
3473+ uint16_t v16 = (uint16_t)val;
3474+ uint32_t v32 = (uint32_t)val;
3475+ uint64_t v64 = (uint64_t)val;
3476+ char * buf = NULL;
3477+ t_CKINT size = 0;
3478+
3479+ if( flags & Chuck_IO::INT8 ) { buf = (char *)&v8; size = 1; }
3480+ else if( flags & Chuck_IO::INT16 ) { buf = (char *)&v16; size = 2; }
3481+ else if( flags & Chuck_IO::INT32 ) { buf = (char *)&v32; size = 4; }
3482+ else if( flags & Chuck_IO::INT64 ) { buf = (char *)&v64; size = 8; }
3483+ // other size values should be caught above
3484+
3485+ // put into write buffer
33563486 for(int i = 0; i < size; i++)
3357− m_writeBuffer.put(buf[i]);
3487+ m_writeBuffer.put( buf[i] );
33583488
33593489 Request r;
33603490 r.m_type = TYPE_WRITE;
@@ -3373,14 +3503,38 @@ void Chuck_IO_Serial::write( t_CKINT val, t_CKINT size ) · 12 unmodified lines
33733503 }
33743504 else
33753505 {
3376− // assume 4-byte int
3377− char * buf = (char *) &val;
3378− fwrite(buf, 1, size, m_cfd);
3506+ // 1.5.0.1 (ge) check and handle individually
3507+ if( flags & Chuck_IO::INT8 )
3508+ {
3509+ uint8_t v = (uint8_t)val;
3510+ fwrite( (char*)&v, 1, 1, m_cfd );
3511+ }
3512+ else if( flags & Chuck_IO::INT16 )
3513+ {
3514+ uint16_t v = (uint16_t)val;
3515+ fwrite( (char*)&v, 1, 2, m_cfd );
3516+ }
3517+ else if( flags & Chuck_IO::INT32 )
3518+ {
3519+ uint32_t v = (uint32_t)val;
3520+ fwrite( (char*)&v, 1, 4, m_cfd );
3521+ }
3522+ else if( flags & Chuck_IO::INT64 )
3523+ {
3524+ uint64_t v = (uint64_t)val;
3525+ fwrite( (char*)&v, 1, 8, m_cfd );
3526+ }
3527+ // other size values should be caught above
33793528 }
33803529 }
33813530 }
33823531
33833532 void Chuck_IO_Serial::write( t_CKFLOAT val )
3533+{
3534+ this->write( val, Chuck_IO::FLOAT32 );
3535+}
3536+
3537+void Chuck_IO_Serial::write( t_CKFLOAT val, t_CKINT flags )
33843538 {
33853539 if( !good() )
33863540 {
@@ -3416,11 +3570,26 @@ void Chuck_IO_Serial::write( t_CKFLOAT val ) · 29 unmodified lines
34163570 }
34173571 else
34183572 {
3419− char * buf = (char *) &val;
3420−
3421− // assume 4-byte float
3422− for(int i = 0; i < 4; i++)
3423− m_writeBuffer.put(buf[i]);
3573+ // 1.5.0.1 (ge) check datatype size flag
3574+ if( flags & Chuck_IO::FLOAT32 )
3575+ {
3576+ float v = (float)val;
3577+ char * buf = (char *)&v;
3578+ for(int i = 0; i < sizeof(v); i++)
3579+ m_writeBuffer.put(buf[i]);
3580+ }
3581+ else if( flags & Chuck_IO::FLOAT64 )
3582+ {
3583+ double v = (double)val;
3584+ char * buf = (char *)&v;
3585+ for(int i = 0; i < sizeof(v); i++)
3586+ m_writeBuffer.put(buf[i]);
3587+ }
3588+ else
3589+ {
3590+ // error message
3591+ EM_log(CK_LOG_WARNING, "(Serial.write): invalid or unsupported size flag");
3592+ }
34243593
34253594 Request r;
34263595 r.m_type = TYPE_WRITE;
@@ -3437,12 +3606,28 @@ void Chuck_IO_Serial::write( t_CKFLOAT val ) · 10 unmodified lines
34373606 {
34383607 fprintf( m_cfd, "%f", val );
34393608 }
3440− else
3609+ else // BINARY
34413610 {
3442− // assume 4-byte int
3443− char * buf = (char *) &val;
3444− // 1.5.0.0 (ge) | fixed from size to sizeof
3445− fwrite(buf, 1, sizeof(val), m_cfd);
3611+ // 1.5.0.1 (ge) check datatype size flag
3612+ if( flags & Chuck_IO::FLOAT32 )
3613+ {
3614+ float v = (float)val;
3615+ char * buf = (char *)&v;
3616+ for(int i = 0; i < sizeof(v); i++)
3617+ m_writeBuffer.put(buf[i]);
3618+ }
3619+ else if( flags & Chuck_IO::FLOAT64 )
3620+ {
3621+ double v = (double)val;
3622+ char * buf = (char *)&v;
3623+ for(int i = 0; i < sizeof(v); i++)
3624+ m_writeBuffer.put(buf[i]);
3625+ }
3626+ else
3627+ {
3628+ // error message
3629+ EM_log(CK_LOG_WARNING, "(Serial.write): invalid or unsupported size flag");
3630+ }
34463631 }
34473632 }
34483633 }
src/core/chuck_io.h+9−2
@@ -72,7 +72,10 @@ t_CKBOOL init_class_serialio( Chuck_Env * env ); · 71 unmodified lines
7272 //-----------------------------------------------------------------------------
7373 // io API
7474 //-----------------------------------------------------------------------------
75−CK_DLL_MFUN( io_dummy );
75+CK_DLL_MFUN( io_dummy_int );
76+CK_DLL_MFUN( io_dummy_float );
77+CK_DLL_MFUN( io_dummy_string );
78+CK_DLL_MFUN( io_dummy_void );
7679 CK_DLL_SFUN( io_newline );
7780 CK_DLL_SFUN( io_openfile );
7881
@@ -103,12 +106,14 @@ CK_DLL_MFUN( fileio_readint8 ); · 24 unmodified lines
103106 CK_DLL_MFUN( fileio_readint16 );
104107 CK_DLL_MFUN( fileio_readint32 );
105108 CK_DLL_MFUN( fileio_readfloat );
109+CK_DLL_MFUN( fileio_readfloatflags );
106110 CK_DLL_MFUN( fileio_eof );
107111 CK_DLL_MFUN( fileio_more );
108112 CK_DLL_MFUN( fileio_writestring );
109113 CK_DLL_MFUN( fileio_writeint );
110114 CK_DLL_MFUN( fileio_writeintflags );
111115 CK_DLL_MFUN( fileio_writefloat );
116+CK_DLL_MFUN( fileio_writefloatflags );
112117 // #endif // __DISABLE_FILEIO__
113118
114119
@@ -312,15 +317,17 @@ public: · 197 unmodified lines
312317 virtual Chuck_String * readLine();
313318 virtual t_CKINT readInt( t_CKINT flags );
314319 virtual t_CKFLOAT readFloat();
320+ virtual t_CKFLOAT readFloat( t_CKINT flags );
315321 virtual t_CKBOOL readString( std::string & str );
316322 virtual t_CKBOOL eof();
317323
318324 // writing
319325 virtual void write( const std::string & val );
320326 virtual void write( t_CKINT val );
321− virtual void write( t_CKINT val, t_CKINT size );
327+ virtual void write( t_CKINT val, t_CKINT flags );
322328 virtual void writeBytes( Chuck_Array4 * arr );
323329 virtual void write( t_CKFLOAT val );
330+ virtual void write( t_CKFLOAT val, t_CKINT flags );
324331
325332 // serial stuff
326333 virtual t_CKBOOL setBaudRate( t_CKUINT rate );
src/core/chuck_oo.cpp+263−71
@@ -55,18 +55,28 @@ using namespace std; · 54 unmodified lines
5555 t_CKBOOL Chuck_VM_Object::our_locks_in_effect = TRUE;
5656
5757 // constants
58−const t_CKINT Chuck_IO::TYPE_ASCII = 0x1;
58+const t_CKINT Chuck_IO::TYPE_ASCII = 0x1;
5959 const t_CKINT Chuck_IO::TYPE_BINARY = 0x2;
60−const t_CKINT Chuck_IO::INT8 = 0x10;
61−const t_CKINT Chuck_IO::INT16 = 0x20;
62−const t_CKINT Chuck_IO::INT24 = 0x40;
63−const t_CKINT Chuck_IO::INT32 = 0x80;
64−const t_CKINT Chuck_IO::INT64 = 0x100;
65−const t_CKINT Chuck_IO::FLOAT32 = 0x200;
66−const t_CKINT Chuck_IO::FLOAT64 = 0x400;
67−const t_CKINT Chuck_IO::FLAG_READ_WRITE = 0x100;
68−const t_CKINT Chuck_IO::FLAG_READONLY = 0x200;
69−const t_CKINT Chuck_IO::FLAG_WRITEONLY = 0x400;
60+const t_CKINT Chuck_IO::FLOAT32 = 0x10;
61+const t_CKINT Chuck_IO::FLOAT64 = 0x20;
62+const t_CKINT Chuck_IO::INT8 = 0x100;
63+const t_CKINT Chuck_IO::INT16 = 0x200;
64+const t_CKINT Chuck_IO::INT24 = 0x400;
65+const t_CKINT Chuck_IO::INT32 = 0x800;
66+const t_CKINT Chuck_IO::INT64 = 0x1000;
67+const t_CKINT Chuck_IO::SINT8 = 0x2000;
68+const t_CKINT Chuck_IO::SINT16 = 0x4000;
69+const t_CKINT Chuck_IO::SINT24 = 0x8000;
70+const t_CKINT Chuck_IO::SINT32 = 0x10000;
71+const t_CKINT Chuck_IO::SINT64 = 0x20000;
72+const t_CKINT Chuck_IO::UINT8 = 0x40000;
73+const t_CKINT Chuck_IO::UINT16 = 0x80000;
74+const t_CKINT Chuck_IO::UINT24 = 0x100000;
75+const t_CKINT Chuck_IO::UINT32 = 0x200000;
76+const t_CKINT Chuck_IO::UINT64 = 0x400000;
77+const t_CKINT Chuck_IO::FLAG_READONLY = 0x100;
78+const t_CKINT Chuck_IO::FLAG_WRITEONLY = 0x200;
79+const t_CKINT Chuck_IO::FLAG_READ_WRITE = 0x400;
7080 const t_CKINT Chuck_IO::FLAG_APPEND = 0x800;
7181
7282 #ifndef __DISABLE_THREADS__
@@ -3470,36 +3480,54 @@ t_CKINT Chuck_IO_File::readInt( t_CKINT flags ) · 3397 unmodified lines
34703480 else if( m_flags & TYPE_BINARY )
34713481 {
34723482 // binary
3473− if( flags & Chuck_IO::INT32 )
3483+ if( flags & Chuck_IO::INT8 || flags & Chuck_IO::UINT8 ) // 1.5.0.1 (ge) added UINT
34743484 {
3475− // 32-bit
3476− t_CKINT i;
3485+ // unsigned 8-bit
3486+ uint8_t i; // 1.5.0.1 (ge) changed to int8_t from unsigned char
3487+ m_io.read( (char *)&i, 1 );
3488+ if( m_io.gcount() != 1 )
3489+ EM_error3( "[chuck](via FileIO): cannot readInt: not enough bytes left" );
3490+ else if( m_io.fail() )
3491+ EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
3492+ return (t_CKINT)i;
3493+ }
3494+ else if( flags & Chuck_IO::INT16 || flags & Chuck_IO::UINT16 ) // 1.5.0.1 (ge) added UINT
3495+ {
3496+ // unsigned 16-bit
3497+ uint16_t i; // 1.5.0.1 (ge) changed to uint16_t from t_CKINT
3498+ m_io.read( (char *)&i, 2 );
3499+ if( m_io.gcount() != 2 )
3500+ EM_error3( "[chuck](via FileIO): cannot readInt: not enough bytes left" );
3501+ else if (m_io.fail())
3502+ EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
3503+ return (t_CKINT)i;
3504+ }
3505+ else if( flags & Chuck_IO::INT32 || flags & Chuck_IO::UINT32 ) // 1.5.0.1 (ge) added UINT
3506+ {
3507+ // unsigned 32-bit
3508+ uint32_t i; // 1.5.0.1 (ge) changed to uint32_t from t_CKINT
34773509 m_io.read( (char *)&i, 4 );
34783510 if (m_io.gcount() != 4)
34793511 EM_error3( "[chuck](via FileIO): cannot readInt: not enough bytes left" );
34803512 else if (m_io.fail())
34813513 EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
3482− return i;
3514+ return (t_CKINT)i;
34833515 }
3484− else if( flags & Chuck_IO::INT16 )
3516+ else if( flags & Chuck_IO::INT64 || flags & Chuck_IO::UINT64 ) // 1.5.0.1 (ge) added 64-bit
34853517 {
3486− // 16-bit
3487− // int16_t i;
3488− // issue: 64-bit
3489− short i;
3490− m_io.read( (char *)&i, 2 );
3491− if( m_io.gcount() != 2 )
3518+ // unsigned 64-bit
3519+ uint64_t i; // 1.5.0.1 (ge) added
3520+ m_io.read( (char *)&i, 8 );
3521+ if (m_io.gcount() != 8)
34923522 EM_error3( "[chuck](via FileIO): cannot readInt: not enough bytes left" );
34933523 else if (m_io.fail())
34943524 EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
3495− return (t_CKINT) i;
3525+ return (t_CKINT)i; // TODO: handle signed vs unsigned
34963526 }
3497− else if( flags & Chuck_IO::INT8 )
3527+ else if( flags & Chuck_IO::SINT8 ) // 1.5.0.1 (ge) added SINT
34983528 {
3499− // 8-bit
3500− // int8_t i;
3501− // issue: 64-bit
3502− unsigned char i;
3529+ // signed 8-bit
3530+ int8_t i;
35033531 m_io.read( (char *)&i, 1 );
35043532 if( m_io.gcount() != 1 )
35053533 EM_error3( "[chuck](via FileIO): cannot readInt: not enough bytes left" );
@@ -3507,9 +3535,42 @@ t_CKINT Chuck_IO_File::readInt( t_CKINT flags ) · 1 unmodified line
35073535 EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
35083536 return (t_CKINT)i;
35093537 }
3538+ else if( flags & Chuck_IO::SINT16 ) // 1.5.0.1 (ge) added SINT
3539+ {
3540+ // signed 16-bit
3541+ int16_t i;
3542+ m_io.read( (char *)&i, 2 );
3543+ if( m_io.gcount() != 2 )
3544+ EM_error3( "[chuck](via FileIO): cannot readInt: not enough bytes left" );
3545+ else if (m_io.fail())
3546+ EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
3547+ return (t_CKINT)i;
3548+ }
3549+ else if( flags & Chuck_IO::SINT32 ) // 1.5.0.1 (ge) added SINT
3550+ {
3551+ // signed 32-bit
3552+ int32_t i;
3553+ m_io.read( (char *)&i, 4 );
3554+ if (m_io.gcount() != 4)
3555+ EM_error3( "[chuck](via FileIO): cannot readInt: not enough bytes left" );
3556+ else if (m_io.fail())
3557+ EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
3558+ return (t_CKINT)i;
3559+ }
3560+ else if( flags & Chuck_IO::SINT64 ) // 1.5.0.1 (ge) added SINT
3561+ {
3562+ // signed 64-bit
3563+ int64_t i;
3564+ m_io.read( (char *)&i, 4 );
3565+ if (m_io.gcount() != 8)
3566+ EM_error3( "[chuck](via FileIO): cannot readInt: not enough bytes left" );
3567+ else if (m_io.fail())
3568+ EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
3569+ return (t_CKINT)i;
3570+ }
35103571 else
35113572 {
3512− EM_error3( "[chuck](via FileIO): readInt error: invalid int size flag" );
3573+ EM_error3( "[chuck](via FileIO): readInt error: invalid/unsupported int size flag" );
35133574 return 0;
35143575 }
35153576 }
@@ -3525,33 +3586,43 @@ t_CKINT Chuck_IO_File::readInt( t_CKINT flags ) · 9 unmodified lines
35253586
35263587 //-----------------------------------------------------------------------------
35273588 // name: readFloat()
3528−// desc: read next as (ascii) floating point value
3589+// desc: read next as floating point value; could be ASCII or BINARY
35293590 //-----------------------------------------------------------------------------
35303591 t_CKFLOAT Chuck_IO_File::readFloat()
3592+{
3593+ return this->readFloat( Chuck_IO::FLOAT32 );
3594+}
3595+
3596+
3597+
3598+
3599+//-----------------------------------------------------------------------------
3600+// name: readFloat()
3601+// desc: read next as floating point value; could be ASCII or BINARY
3602+//-----------------------------------------------------------------------------
3603+t_CKFLOAT Chuck_IO_File::readFloat( t_CKINT flags )
35313604 {
35323605 // sanity
3533− if (!(m_io.is_open())) {
3606+ if( !(m_io.is_open()) ) {
35343607 EM_error3( "[chuck](via FileIO): cannot readFloat: no file open" );
35353608 return 0;
35363609 }
3537−
3538− if (m_io.eof()) {
3610+ if( m_io.eof() ) {
35393611 EM_error3( "[chuck](via FileIO): cannot readFloat: EOF reached" );
35403612 return 0;
35413613 }
3542−
3543− if (m_io.fail()) {
3614+ if( m_io.fail() ) {
35443615 EM_error3( "[chuck](via FileIO): cannot readFloat: I/O stream failed" );
35453616 return 0;
35463617 }
3547−
3548− if ( m_dir )
3549− {
3618+ if( m_dir ) {
35503619 EM_error3( "[chuck](via FileIO): cannot read a directory" );
35513620 return 0;
35523621 }
35533622
3554− if (m_flags & TYPE_ASCII) {
3623+ // check mode
3624+ if( m_flags & TYPE_ASCII )
3625+ {
35553626 // ASCII
35563627 t_CKFLOAT val = 0;
35573628 m_io >> val;
@@ -3559,17 +3630,38 @@ t_CKFLOAT Chuck_IO_File::readFloat() · 1 unmodified line
35593630 // EM_error3( "[chuck](via FileIO): cannot readFloat: I/O stream failed" );
35603631 return val;
35613632
3562− } else if (m_flags & TYPE_BINARY) {
3563− // binary
3564− t_CKFLOAT i;
3565− m_io.read( (char *)&i, sizeof(t_CKFLOAT) );
3566− if (m_io.gcount() != sizeof(t_CKFLOAT) )
3567− EM_error3( "[chuck](via FileIO): cannot readFloat: not enough bytes left" );
3568− else if (m_io.fail())
3569− EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
3570− return i;
3571−
3572− } else {
3633+ }
3634+ else if( m_flags & TYPE_BINARY )
3635+ {
3636+ // 1.5.0.1
3637+ if( flags & Chuck_IO::FLOAT32 )
3638+ {
3639+ float i;
3640+ m_io.read( (char *)&i, sizeof(float) );
3641+ if (m_io.gcount() != sizeof(float) )
3642+ EM_error3( "[chuck](via FileIO): cannot readFloat: not enough bytes left" );
3643+ else if (m_io.fail())
3644+ EM_error3( "[chuck](via FileIO): cannot readFloat: I/O stream failed" );
3645+ return (t_CKFLOAT)i;
3646+ }
3647+ else if( flags & Chuck_IO::FLOAT64 )
3648+ {
3649+ double i;
3650+ m_io.read( (char *)&i, sizeof(double) );
3651+ if (m_io.gcount() != sizeof(double) )
3652+ EM_error3( "[chuck](via FileIO): cannot readFloat: not enough bytes left" );
3653+ else if (m_io.fail())
3654+ EM_error3( "[chuck](via FileIO): cannot readFloat: I/O stream failed" );
3655+ return (t_CKFLOAT)i;
3656+ }
3657+ else
3658+ {
3659+ EM_error3( "[chuck](via FileIO): readFloat error: invalid/unsupported datatype size flag" );
3660+ return 0;
3661+ }
3662+ }
3663+ else
3664+ {
35733665 EM_error3( "[chuck](via FileIO): readFloat error: invalid ASCII/binary flag" );
35743666 return 0;
35753667 }
@@ -3794,14 +3886,64 @@ void Chuck_IO_File::write( t_CKINT val, t_CKINT flags ) · 218 unmodified lines
37943886 return;
37953887 }
37963888
3797− if (m_flags & TYPE_ASCII) {
3889+ // check file mode
3890+ if( m_flags & TYPE_ASCII ) // ASCII mode
3891+ {
3892+ // insert into file stream
37983893 m_io << val;
3799− } else if (m_flags & TYPE_BINARY) {
3800− int nBytes = 4;
3801− if(flags & INT8) nBytes = 1;
3802− else if(flags & INT16) nBytes = 2;
3803− else if(flags & INT32) nBytes = 4;
3804− m_io.write( (char *)&val, nBytes );
3894+ }
3895+ else if( m_flags & TYPE_BINARY ) // BINARY mode
3896+ {
3897+ // check datatype size flags
3898+ // 1.5.0.1 (ge) modified to new signed/unsigned handling
3899+ if( flags & Chuck_IO::INT8 || flags & Chuck_IO::UINT8 )
3900+ {
3901+ // unsigned 8-bit
3902+ uint8_t v = val;
3903+ m_io.write( (char *)&v, 1 );
3904+ }
3905+ else if( flags & Chuck_IO::INT16 || flags & Chuck_IO::UINT16 )
3906+ {
3907+ // unsigned 16-bit
3908+ uint16_t v = val;
3909+ m_io.write( (char *)&v, 2 );
3910+ }
3911+ else if( flags & Chuck_IO::INT32 || flags & Chuck_IO::UINT32 )
3912+ {
3913+ // unsigned 32-bit
3914+ uint32_t v = val;
3915+ m_io.write( (char *)&v, 4 );
3916+ }
3917+ else if( flags & Chuck_IO::INT64 || flags & Chuck_IO::UINT64 )
3918+ {
3919+ // unsigned 64-bit
3920+ uint64_t v = val;
3921+ m_io.write( (char *)&v, 8 );
3922+ }
3923+ else if( flags & Chuck_IO::SINT8 )
3924+ {
3925+ // signed 8-bit
3926+ int8_t v = val;
3927+ m_io.write( (char *)&v, 1 );
3928+ }
3929+ else if( flags & Chuck_IO::SINT16 )
3930+ {
3931+ // signed 16-bit
3932+ int16_t v = val;
3933+ m_io.write( (char *)&v, 2 );
3934+ }
3935+ else if( flags & Chuck_IO::SINT32 )
3936+ {
3937+ // signed 32-bit
3938+ int32_t v = val;
3939+ m_io.write( (char *)&v, 4 );
3940+ }
3941+ else if( flags & Chuck_IO::SINT64 )
3942+ {
3943+ // signed 32-bit
3944+ int64_t v = val;
3945+ m_io.write( (char *)&v, 8 );
3946+ }
38053947 } else {
38063948 EM_error3( "[chuck](via FileIO): write error: invalid ASCII/binary flag" );
38073949 }
@@ -3816,32 +3958,64 @@ void Chuck_IO_File::write( t_CKINT val, t_CKINT flags ) · 8 unmodified lines
38163958
38173959 //-----------------------------------------------------------------------------
38183960 // name: write( t_CKFLOAT val )
3819−// desc: ...
3961+// desc: write a floating point value
38203962 //-----------------------------------------------------------------------------
38213963 void Chuck_IO_File::write( t_CKFLOAT val )
3964+{
3965+ this->write( val, Chuck_IO::FLOAT32 );
3966+}
3967+
3968+
3969+
3970+
3971+//-----------------------------------------------------------------------------
3972+// name: write( t_CKFLOAT val, t_CKINT flags )
3973+// desc: write a floating point value; binary mode will heed flags for size
3974+//-----------------------------------------------------------------------------
3975+void Chuck_IO_File::write( t_CKFLOAT val, t_CKINT flags )
38223976 {
38233977 // sanity
3824− if (!(m_io.is_open())) {
3978+ if( !(m_io.is_open()) ) {
38253979 EM_error3( "[chuck](via FileIO): cannot write: no file open" );
38263980 return;
38273981 }
3828−
3829− if (m_io.fail()) {
3982+ if( m_io.fail() ) {
38303983 EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
38313984 return;
38323985 }
3833−
3834− if ( m_dir )
3835− {
3986+ if( m_dir ) {
38363987 EM_error3( "[chuck](via FileIO): cannot write to a directory" );
38373988 return;
38383989 }
38393990
3840− if (m_flags & TYPE_ASCII) {
3991+ // check ASCII or BINARY
3992+ if( m_flags & TYPE_ASCII )
3993+ {
3994+ // insert into stream
38413995 m_io << val;
3842− } else if (m_flags & TYPE_BINARY) {
3843− m_io.write( (char *)&val, sizeof(t_CKFLOAT) );
3844− } else {
3996+ }
3997+ else if( m_flags & TYPE_BINARY )
3998+ {
3999+ // 1.5.0.1 (ge) add distinction between different float sizes
4000+ if( flags & Chuck_IO::FLOAT32 )
4001+ {
4002+ // 32-bit
4003+ float v = (float)val;
4004+ m_io.write( (char *)&v, 4 );
4005+ }
4006+ else if( flags & Chuck_IO::FLOAT64 )
4007+ {
4008+ // 64-bit
4009+ double v = (double)val;
4010+ m_io.write( (char *)&v, 8 );
4011+ }
4012+ else
4013+ {
4014+ EM_error3( "[chuck](via FileIO): writeFloat error: invalid/unsupport datatype size flag" );
4015+ }
4016+ }
4017+ else
4018+ {
38454019 EM_error3( "[chuck](via FileIO): write error: invalid ASCII/binary flag" );
38464020 }
38474021
@@ -3881,7 +4055,7 @@ THREAD_RETURN ( THREAD_TYPE Chuck_IO_File::writeInt_thread ) ( void *data ) · 33 unmodified lines
38814055 THREAD_RETURN ( THREAD_TYPE Chuck_IO_File::writeFloat_thread ) ( void *data )
38824056 {
38834057 async_args *args = (async_args *)data;
3884− args->fileio_obj->write ( args->floatArg );
4058+ args->fileio_obj->write( args->floatArg, args->intArg );
38854059 args->fileio_obj->m_asyncEvent->broadcast_local(); // wake up
38864060 args->fileio_obj->m_asyncEvent->broadcast_global();
38874061 delete args;
@@ -3960,7 +4134,10 @@ t_CKINT Chuck_IO_Chout::readInt( t_CKINT flags ) · 72 unmodified lines
39604134 { return 0; }
39614135
39624136 t_CKFLOAT Chuck_IO_Chout::readFloat()
3963−{ return 0.0f; }
4137+{ return 0; }
4138+
4139+t_CKFLOAT Chuck_IO_Chout::readFloat( t_CKINT flags )
4140+{ return 0; }
39644141
39654142 t_CKBOOL Chuck_IO_Chout::readString( std::string & str )
39664143 {
@@ -3993,6 +4170,11 @@ void Chuck_IO_Chout::write( t_CKFLOAT val ) · 26 unmodified lines
39934170 m_buffer << val;
39944171 }
39954172
4173+void Chuck_IO_Chout::write( t_CKFLOAT val, t_CKINT flags )
4174+{
4175+ // ignore flags for chout
4176+ m_buffer << val;
4177+}
39964178
39974179
39984180
@@ -4062,7 +4244,10 @@ t_CKINT Chuck_IO_Cherr::readInt( t_CKINT flags ) · 63 unmodified lines
40624244 { return 0; }
40634245
40644246 t_CKFLOAT Chuck_IO_Cherr::readFloat()
4065−{ return 0.0f; }
4247+{ return 0; }
4248+
4249+t_CKFLOAT Chuck_IO_Cherr::readFloat( t_CKINT flags )
4250+{ return 0; }
40664251
40674252 t_CKBOOL Chuck_IO_Cherr::readString( std::string & str )
40684253 {
@@ -4097,3 +4282,10 @@ void Chuck_IO_Cherr::write( t_CKFLOAT val ) · 28 unmodified lines
40974282 m_buffer << val;
40984283 flush(); // always flush for cerr | 1.5.0.0 (ge) added
40994284 }
4285+
4286+void Chuck_IO_Cherr::write( t_CKFLOAT val, t_CKINT flags )
4287+{
4288+ // ignore flags for cherr
4289+ m_buffer << val;
4290+ flush(); // always flush for cerr | 1.5.0.0 (ge) added
4291+}
src/core/chuck_oo.h+22−2
@@ -617,6 +617,7 @@ public: · 616 unmodified lines
617617 virtual Chuck_String * readLine() = 0;
618618 virtual t_CKINT readInt( t_CKINT flags ) = 0;
619619 virtual t_CKFLOAT readFloat() = 0;
620+ virtual t_CKFLOAT readFloat( t_CKINT flags ) = 0;
620621 virtual t_CKBOOL readString( std::string & str ) = 0;
621622 virtual t_CKBOOL eof() = 0;
622623
@@ -625,6 +626,7 @@ public: · 2 unmodified lines
625626 virtual void write( t_CKINT val ) = 0;
626627 virtual void write( t_CKINT val, t_CKINT flags ) = 0;
627628 virtual void write( t_CKFLOAT val ) = 0;
629+ virtual void write( t_CKFLOAT val, t_CKINT flags ) = 0;
628630
629631 public:
630632 // type | moved to IO in 1.5.0.0 (ge)
@@ -636,8 +638,20 @@ public: · 5 unmodified lines
636638 static const t_CKINT INT24; // 1.5.0.1 (ge) added
637639 static const t_CKINT INT32;
638640 static const t_CKINT INT64; // 1.5.0.1 (ge) added
639− static const t_CKINT FLOAT32; // 1.5.0.1 (ge) added
640− static const t_CKINT FLOAT64; // 1.5.0.1 (ge) added
641+ // 1.5.0.1 (ge) added SINT and UINT type flags
642+ static const t_CKINT SINT8;
643+ static const t_CKINT SINT16;
644+ static const t_CKINT SINT24;
645+ static const t_CKINT SINT32;
646+ static const t_CKINT SINT64;
647+ static const t_CKINT UINT8;
648+ static const t_CKINT UINT16;
649+ static const t_CKINT UINT24;
650+ static const t_CKINT UINT32;
651+ static const t_CKINT UINT64;
652+ // 1.5.0.1 (ge) added FLOAT type flags
653+ static const t_CKINT FLOAT32;
654+ static const t_CKINT FLOAT64;
641655 // flags | moved to IO in 1.5.0.0 (ge)
642656 static const t_CKINT FLAG_READ_WRITE;
643657 static const t_CKINT FLAG_READONLY;
@@ -698,6 +712,7 @@ public: · 54 unmodified lines
698712 virtual Chuck_String * readLine();
699713 virtual t_CKINT readInt( t_CKINT flags );
700714 virtual t_CKFLOAT readFloat();
715+ virtual t_CKFLOAT readFloat( t_CKINT flags );
701716 virtual t_CKBOOL readString( std::string & str );
702717 virtual t_CKBOOL eof();
703718
@@ -714,6 +729,7 @@ public: · 10 unmodified lines
714729 virtual void write( t_CKINT val );
715730 virtual void write( t_CKINT val, t_CKINT flags );
716731 virtual void write( t_CKFLOAT val );
732+ virtual void write( t_CKFLOAT val, t_CKINT flags );
717733
718734 #ifndef __DISABLE_THREADS__
719735 // writing -- async
@@ -765,6 +781,7 @@ public: · 45 unmodified lines
765781 virtual Chuck_String * readLine();
766782 virtual t_CKINT readInt( t_CKINT flags );
767783 virtual t_CKFLOAT readFloat();
784+ virtual t_CKFLOAT readFloat( t_CKINT flags );
768785 virtual t_CKBOOL readString( std::string & str );
769786 virtual t_CKBOOL eof();
770787
@@ -773,6 +790,7 @@ public: · 2 unmodified lines
773790 virtual void write( t_CKINT val );
774791 virtual void write( t_CKINT val, t_CKINT flags );
775792 virtual void write( t_CKFLOAT val );
793+ virtual void write( t_CKFLOAT val, t_CKINT flags );
776794
777795 public: // REFACTOR-2017
778796 // set callback
@@ -810,6 +828,7 @@ public: · 31 unmodified lines
810828 virtual Chuck_String * readLine();
811829 virtual t_CKINT readInt( t_CKINT flags );
812830 virtual t_CKFLOAT readFloat();
831+ virtual t_CKFLOAT readFloat( t_CKINT flags );
813832 virtual t_CKBOOL readString( std::string & str );
814833 virtual t_CKBOOL eof();
815834
@@ -818,6 +837,7 @@ public: · 2 unmodified lines
818837 virtual void write( t_CKINT val );
819838 virtual void write( t_CKINT val, t_CKINT flags );
820839 virtual void write( t_CKFLOAT val );
840+ virtual void write( t_CKFLOAT val, t_CKINT flags );
821841
822842 public:
823843 // set callback | REFACTOR-2017

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t