forked from Emill/Npgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNpgsqlBuffer.cs
More file actions
720 lines (637 loc) · 25.1 KB
/
NpgsqlBuffer.cs
File metadata and controls
720 lines (637 loc) · 25.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using AsyncRewriter;
namespace Npgsql
{
internal partial class NpgsqlBuffer
{
internal Stream Underlying { get; set; }
internal int Size { get; private set; }
internal Encoding TextEncoding { get; private set; }
internal int ReadPosition { get; private set; }
internal int ReadBytesLeft { get { return _filledBytes - ReadPosition; } }
internal int WritePosition { get { return _writePosition; } set { _writePosition = value; } }
internal int WriteSpaceLeft { get { return Size - _writePosition; } }
internal long TotalBytesFlushed { get; private set; }
internal byte[] _buf;
int _filledBytes;
readonly Decoder _textDecoder;
readonly Encoder _textEncoder;
readonly byte[] _workspace;
int _writePosition;
/// <summary>
/// Used for internal temporary purposes
/// </summary>
char[] _tempCharBuf;
BitConverterUnion _bitConverterUnion = new BitConverterUnion();
/// <summary>
/// The minimum buffer size possible.
/// </summary>
internal const int MinimumBufferSize = 4096;
internal const int DefaultBufferSize = 8192;
#region Constructors
internal NpgsqlBuffer(Stream underlying)
: this(underlying, DefaultBufferSize, PGUtil.UTF8Encoding) {}
internal NpgsqlBuffer(Stream underlying, int size, Encoding textEncoding)
{
if (size < MinimumBufferSize) {
throw new ArgumentOutOfRangeException("size", size, "Buffer size must be at least " + MinimumBufferSize);
}
Contract.EndContractBlock();
Underlying = underlying;
Size = size;
_buf = new byte[Size];
TextEncoding = textEncoding;
_textDecoder = TextEncoding.GetDecoder();
_textEncoder = TextEncoding.GetEncoder();
_tempCharBuf = new char[1024];
_workspace = new byte[8];
}
#endregion
[RewriteAsync]
internal void Ensure(int count)
{
Contract.Requires(count <= Size);
count -= ReadBytesLeft;
if (count <= 0) { return; }
if (ReadPosition == _filledBytes) {
Clear();
} else if (count > Size - _filledBytes) {
Array.Copy(_buf, ReadPosition, _buf, 0, ReadBytesLeft);
_filledBytes = ReadBytesLeft;
ReadPosition = 0;
}
while (count > 0)
{
var toRead = Size - _filledBytes;
var read = Underlying.Read(_buf, _filledBytes, toRead);
if (read == 0) { throw new EndOfStreamException(); }
count -= read;
_filledBytes += read;
}
}
[RewriteAsync]
internal void ReadMore()
{
Ensure(ReadBytesLeft + 1);
}
/// <summary>
/// Reads in the requested bytes into the buffer, or if the buffer isn't big enough, allocates a new
/// temporary buffer and reads into it. Returns the buffer that contains the data (either itself or the
/// temp buffer). Used in cases where we absolutely have to have an entire value in memory and cannot
/// read it in sequentially.
/// </summary>
[RewriteAsync]
internal NpgsqlBuffer EnsureOrAllocateTemp(int count)
{
if (count <= Size) {
Ensure(count);
return this;
}
// Worst case: our buffer isn't big enough. For now, allocate a new buffer
// and copy into it
// TODO: Optimize with a pool later?
var tempBuf = new NpgsqlBuffer(Underlying, count, TextEncoding);
CopyTo(tempBuf);
Clear();
tempBuf.Ensure(count);
return tempBuf;
}
internal void CopyTo(NpgsqlBuffer other)
{
Contract.Assert(other.Size - other._filledBytes >= ReadBytesLeft);
Array.Copy(_buf, ReadPosition, other._buf, other._filledBytes, ReadBytesLeft);
other._filledBytes += ReadBytesLeft;
}
internal void Clear()
{
WritePosition = 0;
ReadPosition = 0;
_filledBytes = 0;
}
/// <summary>
/// Seeks within the current in-memory data. Does not read any data from the underlying.
/// </summary>
/// <param name="offset"></param>
/// <param name="origin"></param>
internal void Seek(int offset, SeekOrigin origin)
{
int absoluteOffset;
switch (origin)
{
case SeekOrigin.Begin:
absoluteOffset = offset;
break;
case SeekOrigin.Current:
absoluteOffset = ReadPosition + offset;
break;
case SeekOrigin.End:
throw new NotImplementedException();
default:
throw new ArgumentOutOfRangeException("origin");
}
Contract.Assert(absoluteOffset >= 0 && absoluteOffset <= _filledBytes);
ReadPosition = absoluteOffset;
}
#region Read Simple
internal byte ReadByte()
{
Contract.Requires(ReadBytesLeft >= sizeof(byte));
return _buf[ReadPosition++];
}
internal short ReadInt16()
{
Contract.Requires(ReadBytesLeft >= sizeof(short));
var result = IPAddress.NetworkToHostOrder(BitConverter.ToInt16(_buf, ReadPosition));
ReadPosition += 2;
return result;
}
internal int ReadInt32()
{
Contract.Requires(ReadBytesLeft >= sizeof(int));
var result = IPAddress.NetworkToHostOrder(BitConverter.ToInt32(_buf, ReadPosition));
ReadPosition += 4;
return result;
}
internal uint ReadUInt32()
{
Contract.Requires(ReadBytesLeft >= sizeof(int));
var result = (uint)IPAddress.NetworkToHostOrder(BitConverter.ToInt32(_buf, ReadPosition));
ReadPosition += 4;
return result;
}
internal long ReadInt64()
{
Contract.Requires(ReadBytesLeft >= sizeof(long));
var result = IPAddress.NetworkToHostOrder(BitConverter.ToInt64(_buf, ReadPosition));
ReadPosition += 8;
return result;
}
internal float ReadSingle()
{
Contract.Requires(ReadBytesLeft >= sizeof(float));
if (BitConverter.IsLittleEndian)
{
_workspace[3] = _buf[ReadPosition++];
_workspace[2] = _buf[ReadPosition++];
_workspace[1] = _buf[ReadPosition++];
_workspace[0] = _buf[ReadPosition++];
return BitConverter.ToSingle(_workspace, 0);
}
else
{
var result = BitConverter.ToSingle(_buf, ReadPosition);
ReadPosition += 4;
return result;
}
}
internal double ReadDouble()
{
Contract.Requires(ReadBytesLeft >= sizeof(double));
if (BitConverter.IsLittleEndian)
{
_workspace[7] = _buf[ReadPosition++];
_workspace[6] = _buf[ReadPosition++];
_workspace[5] = _buf[ReadPosition++];
_workspace[4] = _buf[ReadPosition++];
_workspace[3] = _buf[ReadPosition++];
_workspace[2] = _buf[ReadPosition++];
_workspace[1] = _buf[ReadPosition++];
_workspace[0] = _buf[ReadPosition++];
return BitConverter.ToDouble(_workspace, 0);
}
else
{
var result = BitConverter.ToDouble(_buf, ReadPosition);
ReadPosition += 8;
return result;
}
}
#endregion
/// <summary>
/// Converts a given number of bytes into a char array and returns it. Expects the required bytes
/// to already be in the buffer
/// </summary>
internal char[] ReadChars(int byteCount)
{
if (byteCount <= Size)
{
Ensure(byteCount);
var result = TextEncoding.GetChars(_buf, ReadPosition, byteCount);
ReadPosition += byteCount;
return result;
}
// Worst case: our buffer isn't big enough. For now, pessimistically allocate a char buffer
// that will hold the maximum number of characters for the column length
// TODO: Optimize
var pessimisticNumChars = TextEncoding.GetMaxCharCount(byteCount);
var pessimisticOutput = new char[pessimisticNumChars];
var actualNumChars = PopulateCharArray(pessimisticOutput, byteCount);
if (actualNumChars == pessimisticNumChars)
return pessimisticOutput;
var output = new char[actualNumChars];
Array.Copy(pessimisticOutput, 0, output, 0, actualNumChars);
return output;
}
internal string ReadStringSimple(int len)
{
Contract.Requires(len <= ReadBytesLeft);
var result = TextEncoding.GetString(_buf, ReadPosition, len);
ReadPosition += len;
return result;
}
internal char[] ReadCharsSimple(int len)
{
Contract.Requires(len <= ReadBytesLeft);
var result = TextEncoding.GetChars(_buf, ReadPosition, len);
ReadPosition += len;
return result;
}
internal void ReadStringChunked(char[] chars, int charIndex, int charCount, int byteCount,
bool flush, out int charsUsed, out bool completed)
{
Contract.Requires(byteCount <= ReadBytesLeft);
int bytesUsed;
_textDecoder.Convert(_buf, ReadPosition, byteCount, chars, charIndex, charCount,
flush, out bytesUsed, out charsUsed, out completed);
ReadPosition += bytesUsed;
}
/// <summary>
/// Note that unlike the primitive readers, this reader can read any length, looping internally
/// and reading directly from the underlying stream
/// </summary>
internal string ReadString(int byteCount)
{
if (byteCount <= Size)
{
Ensure(byteCount);
var result = TextEncoding.GetString(_buf, ReadPosition, byteCount);
ReadPosition += byteCount;
return result;
}
// Worst case: our buffer isn't big enough. For now, allocate a byte buffer
// that will hold the bytes of the string.
// TODO: Optimize, for example use a buffer pool
var byteArr = new byte[byteCount];
ReadBytes(byteArr, 0, byteCount, true);
return TextEncoding.GetString(byteArr);
}
int PopulateCharArray(char[] output, int byteCount)
{
try
{
var totalBytesRead = 0;
var totalCharsRead = 0;
var outputOffset = 0;
while (true)
{
int bytesRead, charsRead;
bool completed;
var maxBytes = Math.Min(byteCount - totalBytesRead, ReadBytesLeft);
_textDecoder.Convert(_buf, ReadPosition, maxBytes, output, outputOffset, output.Length - totalCharsRead, false,
out bytesRead, out charsRead, out completed);
ReadPosition += bytesRead;
totalBytesRead += bytesRead;
totalCharsRead += charsRead;
if (totalBytesRead == byteCount)
{
return totalCharsRead;
}
outputOffset += charsRead;
Clear();
Ensure(1); // Read in more data
}
}
finally
{
_textDecoder.Reset();
}
}
internal string ReadNullTerminatedString()
{
int i;
for (i = ReadPosition; _buf[i] != 0; i++) {
Contract.Assume(i <= ReadPosition + ReadBytesLeft);
}
Contract.Assert(i >= ReadPosition);
var result = TextEncoding.GetString(_buf, ReadPosition, i - ReadPosition);
ReadPosition = i + 1;
return result;
}
internal void ReadBytesSimple(byte[] output, int outputOffset, int len)
{
Contract.Requires(len <= ReadBytesLeft);
Array.Copy(_buf, ReadPosition, output, outputOffset, len);
ReadPosition += len;
}
internal int ReadBytes(byte[] output, int outputOffset, int len, bool readAll=false)
{
if (len <= ReadBytesLeft)
{
Array.Copy(_buf, ReadPosition, output, outputOffset, len);
ReadPosition += len;
return len;
}
Array.Copy(_buf, ReadPosition, output, outputOffset, ReadBytesLeft);
var offset = outputOffset + ReadBytesLeft;
var totalRead = ReadBytesLeft;
Clear();
while (totalRead < len)
{
var read = Underlying.Read(output, offset, len - totalRead);
if (read == 0) { throw new EndOfStreamException(); }
totalRead += read;
if (!readAll) { return totalRead; }
offset += read;
}
return len;
}
/// <summary>
/// Note that unlike the primitive readers, this reader can read any length, looping internally
/// and reading directly from the underlying stream.
/// </summary>
/// <param name="output">output buffer to fill</param>
/// <param name="outputOffset">offset in the output buffer in which to start writing</param>
/// <param name="charCount">number of character to be read into the output buffer</param>
/// <param name="byteCount">number of bytes left in the field. This method will not read bytes
/// beyond this count</param>
/// <param name="bytesRead">The number of bytes actually read.</param>
/// <param name="charsRead">The number of characters actually read.</param>
/// <returns>the number of bytes read</returns>
internal void ReadChars(char[] output, int outputOffset, int charCount, int byteCount, out int bytesRead, out int charsRead)
{
Contract.Requires(charCount <= output.Length - outputOffset);
bytesRead = 0;
charsRead = 0;
if (charCount == 0) { return; }
if (ReadBytesLeft == 0) {
// If there are no bytes in the buffer, read some before starting the loop
Ensure(1);
}
try
{
while (true)
{
int bytesUsed, charsUsed;
bool completed;
var maxBytes = Math.Min(byteCount - bytesRead, ReadBytesLeft);
_textDecoder.Convert(_buf, ReadPosition, maxBytes, output, outputOffset, charCount - charsRead, false,
out bytesUsed, out charsUsed, out completed);
ReadPosition += bytesUsed;
bytesRead += bytesUsed;
charsRead += charsUsed;
if (charsRead == charCount || bytesRead == byteCount) {
return;
}
outputOffset += charsUsed;
Clear();
Ensure(1); // Read in more data
}
}
finally
{
_textDecoder.Reset();
}
}
/// <summary>
/// Skips over characters in the buffer, reading from the underlying stream as necessary.
/// </summary>
/// <param name="charCount">the number of characters to skip over.
/// int.MaxValue means all available characters (limited only by <paramref name="byteCount"/>).
/// </param>
/// <param name="byteCount">the maximal number of bytes to process</param>
/// <param name="bytesSkipped">The number of bytes actually skipped.</param>
/// <param name="charsSkipped">The number of characters actually skipped.</param>
/// <returns>the number of bytes read</returns>
internal void SkipChars(int charCount, int byteCount, out int bytesSkipped, out int charsSkipped)
{
charsSkipped = bytesSkipped = 0;
while (charsSkipped < charCount && bytesSkipped < byteCount)
{
int bSkipped, cSkipped;
ReadChars(_tempCharBuf, 0, Math.Min(charCount, _tempCharBuf.Length), byteCount, out bSkipped, out cSkipped);
charsSkipped += cSkipped;
bytesSkipped += bSkipped;
}
}
[RewriteAsync]
internal void Skip(long len)
{
Contract.Requires(len >= 0);
if (len > ReadBytesLeft)
{
len -= ReadBytesLeft;
while (len > Size)
{
Clear();
Ensure(Size);
len -= Size;
}
Clear();
Ensure((int)len);
}
ReadPosition += (int)len;
}
public void WriteBytesSimple(byte[] buf)
{
WriteBytesSimple(buf, 0, buf.Length);
}
public void WriteBytesSimple(byte[] buf, int offset, int count)
{
Contract.Requires(count <= WriteSpaceLeft);
Buffer.BlockCopy(buf, offset, _buf, _writePosition, count);
_writePosition += count;
}
[RewriteAsync]
public void Write(byte[] buf, int offset, int count)
{
if (count <= WriteSpaceLeft)
{
Buffer.BlockCopy(buf, offset, _buf, _writePosition, count);
_writePosition += count;
return;
}
if (_writePosition != 0)
{
Buffer.BlockCopy(buf, offset, _buf, _writePosition, WriteSpaceLeft);
offset += WriteSpaceLeft;
count -= WriteSpaceLeft;
Underlying.Write(_buf, 0, Size);
_writePosition = 0;
}
if (count >= Size)
{
Underlying.Write(buf, offset, count);
}
else
{
Buffer.BlockCopy(buf, offset, _buf, 0, count);
_writePosition = count;
}
}
[RewriteAsync]
public void Flush()
{
if (_writePosition != 0)
{
Contract.Assert(ReadBytesLeft == 0, "There cannot be read bytes buffered while a write operation is going on.");
Underlying.Write(_buf, 0, _writePosition);
Underlying.Flush();
TotalBytesFlushed += _writePosition;
_writePosition = 0;
}
}
internal void ResetTotalBytesFlushed()
{
TotalBytesFlushed = 0;
}
[RewriteAsync]
public NpgsqlBuffer WriteBytes(byte[] buf)
{
Write(buf, 0, buf.Length);
return this;
}
public NpgsqlBuffer WriteBytesNullTerminated(byte[] buf)
{
Contract.Requires(WriteSpaceLeft >= buf.Length + 1);
WriteBytes(buf);
WriteByte(0);
return this;
}
public NpgsqlBuffer WriteByte(byte b)
{
Contract.Requires(WriteSpaceLeft >= sizeof(byte));
_buf[_writePosition++] = b;
return this;
}
public NpgsqlBuffer WriteInt64(long i)
{
Contract.Requires(WriteSpaceLeft >= sizeof(long));
var pos = _writePosition;
_buf[pos++] = (byte)(i >> 56);
_buf[pos++] = (byte)(i >> 48);
_buf[pos++] = (byte)(i >> 40);
_buf[pos++] = (byte)(i >> 32);
_buf[pos++] = (byte)(i >> 24);
_buf[pos++] = (byte)(i >> 16);
_buf[pos++] = (byte)(i >> 8);
_buf[pos++] = (byte)i;
_writePosition = pos;
return this;
}
public NpgsqlBuffer WriteInt32(int i)
{
Contract.Requires(WriteSpaceLeft >= sizeof(int));
var pos = _writePosition;
_buf[pos++] = (byte)(i >> 24);
_buf[pos++] = (byte)(i >> 16);
_buf[pos++] = (byte)(i >> 8);
_buf[pos++] = (byte)i;
_writePosition = pos;
return this;
}
public NpgsqlBuffer WriteInt16(int i)
{
Contract.Requires(WriteSpaceLeft >= sizeof(short));
_buf[_writePosition++] = (byte)(i >> 8);
_buf[_writePosition++] = (byte)i;
return this;
}
public NpgsqlBuffer WriteSingle(float f)
{
Contract.Requires(WriteSpaceLeft >= sizeof(float));
_bitConverterUnion.float4 = f;
var pos = _writePosition;
if (BitConverter.IsLittleEndian)
{
_buf[pos++] = _bitConverterUnion.b3;
_buf[pos++] = _bitConverterUnion.b2;
_buf[pos++] = _bitConverterUnion.b1;
_buf[pos++] = _bitConverterUnion.b0;
}
else
{
_buf[pos++] = _bitConverterUnion.b0;
_buf[pos++] = _bitConverterUnion.b1;
_buf[pos++] = _bitConverterUnion.b2;
_buf[pos++] = _bitConverterUnion.b3;
}
_writePosition = pos;
return this;
}
public NpgsqlBuffer WriteDouble(double d)
{
Contract.Requires(WriteSpaceLeft >= sizeof(double));
_bitConverterUnion.float8 = d;
var pos = _writePosition;
if (BitConverter.IsLittleEndian)
{
_buf[pos++] = _bitConverterUnion.b7;
_buf[pos++] = _bitConverterUnion.b6;
_buf[pos++] = _bitConverterUnion.b5;
_buf[pos++] = _bitConverterUnion.b4;
_buf[pos++] = _bitConverterUnion.b3;
_buf[pos++] = _bitConverterUnion.b2;
_buf[pos++] = _bitConverterUnion.b1;
_buf[pos++] = _bitConverterUnion.b0;
}
else
{
_buf[pos++] = _bitConverterUnion.b0;
_buf[pos++] = _bitConverterUnion.b1;
_buf[pos++] = _bitConverterUnion.b2;
_buf[pos++] = _bitConverterUnion.b3;
_buf[pos++] = _bitConverterUnion.b4;
_buf[pos++] = _bitConverterUnion.b5;
_buf[pos++] = _bitConverterUnion.b6;
_buf[pos++] = _bitConverterUnion.b7;
}
_writePosition = pos;
return this;
}
internal void WriteStringSimple(string s, int len=0)
{
Contract.Requires(TextEncoding.GetByteCount(s) <= WriteSpaceLeft);
WritePosition += TextEncoding.GetBytes(s, 0, len == 0 ? s.Length : len, _buf, WritePosition);
}
internal void WriteCharsSimple(char[] chars, int len=0)
{
Contract.Requires(TextEncoding.GetByteCount(chars) <= WriteSpaceLeft);
WritePosition += TextEncoding.GetBytes(chars, 0, len == 0 ? chars.Length : len, _buf, WritePosition);
}
internal void WriteStringChunked(char[] chars, int charIndex, int charCount,
bool flush, out int charsUsed, out bool completed)
{
int bytesUsed;
_textEncoder.Convert(chars, charIndex, charCount, _buf, WritePosition, WriteSpaceLeft,
flush, out charsUsed, out bytesUsed, out completed);
WritePosition += bytesUsed;
}
internal MemoryStream GetMemoryStream(int len)
{
return new MemoryStream(_buf, ReadPosition, len, false, false);
}
[StructLayout(LayoutKind.Explicit, Size = 8)]
struct BitConverterUnion
{
[FieldOffset(0)] public byte b0;
[FieldOffset(1)] public byte b1;
[FieldOffset(2)] public byte b2;
[FieldOffset(3)] public byte b3;
[FieldOffset(4)] public byte b4;
[FieldOffset(5)] public byte b5;
[FieldOffset(6)] public byte b6;
[FieldOffset(7)] public byte b7;
[FieldOffset(0)] public float float4;
[FieldOffset(0)] public double float8;
}
}
}