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

Extracting 4 wchar_t's from int64

Thread Next
From:
Paul Procacci
Date:
January 14, 2021 23:42
Subject:
Extracting 4 wchar_t's from int64
Message ID:
CAFbbPuinkH-TO68S43z4FhA1O5SpVNDdZBF3-QbcCxMyuvdDDA@mail.gmail.com
Let me preface this by saying if I were using a lower level language (like
C) I wouldn't have this problem; as I know how to shift and mask
accordingly.

On raku however, how to do so *eloquantly* eludes me.

I've defined a CStruct as follows:

class test is repr('CStruct') {

  has int64 $.a1;

  has int64 $.a2;

  ...

  has int64 $.a65;

}

Under normal circumstances I would have defined the member as:
`HAS int16 @.a[260] is CArray` however that seems to be broken. See:

https://github.com/rakudo/rakudo/issues/3633

The function that gets called with these members $.a1 .. $.a65 should get
filled with a wchar_t character array.

Does raku employ a simple method of decoding the 4 wchar_t's that get
placed into a int64 structure?  The characters I'd like to extract are at
bit positions [15:0], [31.16], [47:32], [63:48]

I'm imagining something along the lines of:

buf16.new( $.a1, ... $.a64);

... but that doesn't quite work like I would expect.

Thanks,
~Paul

-- 
__________________

:(){ :|:& };:

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