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

Re: stolen uint's

Thread Previous | Thread Next
From:
ToddAndMargo via perl6-users
Date:
January 29, 2020 02:50
Subject:
Re: stolen uint's
Message ID:
2f88c71f-6d57-2e40-5bf4-8406a8587a22@zoho.com
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!

-T

This all came up when I tried to match

       RegSetValueExW(
           _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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About