develooper Front page | perl.perl6.users | Postings from January 2020

Re: stolen uint's

Thread Previous | Thread Next
ToddAndMargo via perl6-users
January 29, 2020 02:50
Re: stolen uint's
Message ID:
On 2020-01-28 18:18, Trey Harris wrote:
> my uint $z = -32;
> 224

Another misunderstanding on my part.  I thought it
would barf.

All I really need to know is what is expected.
To me I am getting wrong answers back, but as
long as they are consistent answers I can deal
with it:

if $ValueData.^name  ne "Int"  || $ValueData < 0  {   # UInt gets "boxed 
to an Int

Thank you for all the time you have spent with me on this!


This all came up when I tried to match

           _In_ HKEY hKey,
           _In_opt_ LPCWSTR lpValueName,
           _Reserved_ DWORD Reserved,
           _In_ DWORD dwType,
           _In_reads_bytes_opt_(cbData) CONST BYTE * lpData,
           _In_ DWORD cbData

where CbData can either be a UTF little endian C string,
terminated by a nul or a four byte little endian
unsigned integer (no two's complement allowed) depending
on the value of lpValueName (REG_SZ, REG_DWORD, etc.)

I wound up doing this:

subset StrOrDword where Str | UInt;
sub WinRegSetValue( WinRegHives $Hive, Str $SubKey, Str $KeyName, 
ValueNames $ValueType, StrOrDword $ValueData, Bool $Debug = False )
                     returns DWORD is export( :WinRegSetValue ) {

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About