![]() |
AW: Re: C++ pointer to byte array --> Delphi
Zitat:
You must invent some construct for the C-Case, bcse the Delphi case has implicit C-"break"s. Perhaps like:
Delphi-Quellcode:
if length = 11 then ...
if length >= 10 then ... if length >= 9 then ... ... |
AW: C++ pointer to byte array --> Delphi
Looks mostly good to me, but I would pay some extra attention to the type casts. I am not sure if
Delphi-Quellcode:
always gives the correct result here. In some places the type cast might be done to truncate a value. For example,
ord()
Delphi-Quellcode:
gives us the lowest 16 bits of
(ushort)foo
Delphi-Quellcode:
.
foo
And in the top code, I think you can get rid of
Delphi-Quellcode:
entirely, if you've correctly translated char as byte.
ord()
|
Re: C++ pointer to byte array --> Delphi
I completely don't understand what for is type casts from byte :o Variables whare are moved results can store entire data without truncating or something alse. What do you think?
Ord() is used, because AValue is string, I plan change it to TBytes. |
AW: Re: C++ pointer to byte array --> Delphi
Zitat:
I assume you wanted to say that the typecasts are unnecessary, which may be true. I didn't examine the code that closely, I was just saying that you should pay attention to that. |
Re: AW: Re: C++ pointer to byte array --> Delphi
Zitat:
Zitat:
|
AW: C++ pointer to byte array --> Delphi
You ignored me :(
I believe I explained why the upcast is necessary. |
AW: C++ pointer to byte array --> Delphi
Zitat:
Delphi-Quellcode:
var
b: Byte; i: integer; begin b := 255; i := b shl 2; // i should now hold the value 510 end |
Re: AW: C++ pointer to byte array --> Delphi
Zitat:
You explained, but I still don't understand. I checked it in this sample:
Delphi-Quellcode:
Could you check in C++ what it returns? In Delphi I have 2901454111 for 'Delphi' string and 4357 seed.
const
C: Char = 'X'; var B: Byte absolute C; begin ShowMessage(IntToStr(B shl 8)); // 22528 ShowMessage(IntToStr((256*Byte(C)) shl 8)); // 5767168 ShowMessage(IntToStr(Cardinal(Ord(C) shl 8))); // 22528 end;
Code:
#define mix(a,b,c) \
{ \ a -= b; a -= c; a ^= ( c >> 13 ); \ b -= c; b -= a; b ^= ( a << 8 ); \ c -= a; c -= b; c ^= ( b >> 13 ); \ a -= b; a -= c; a ^= ( c >> 12 ); \ b -= c; b -= a; b ^= ( a << 16 ); \ c -= a; c -= b; c ^= ( b >> 5 ); \ a -= b; a -= c; a ^= ( c >> 3 ); \ b -= c; b -= a; b ^= ( a << 10 ); \ c -= a; c -= b; c ^= ( b >> 15 ); \ } |
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:50 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz