Last active
March 10, 2017 08:25
-
-
Save samcv/0f84ddcac905b40d57b0cfd7ffb72b45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl6 | |
#`{ | |
Note: Fedora need the following for NativeCall to work: | |
# ln /usr/lib64/libX11.so.6 /usr/lib64/libX11.so | |
# ln /usr/lib/libX11.so.6 /usr/lib/libX11.so | |
https://rt.perl.org/Search/Simple.html?q=nativecall any of these bugs yours? | |
<samcv> if they are not, then send the bug report by email to rakudobug@perl.org | |
paste over at http://vpaste.net | |
https://linux.die.net/man/3/xfetchbytes | |
https://www.cs.bham.ac.uk/research/projects/poplog/doc/popxref/XBuffers | |
Str:D means a "defined" string. Str:U means "undefined" | |
https://docs.perl6.org/language/nativecall#Passing_and_Returning_Values | |
} | |
use NativeCall; | |
# char *XDisplayName(char *string); | |
sub XDisplayName(Str:D $name) is native('X11') returns Str { * }; | |
# char *XFetchBytes(Display *display, int *nbytes_return) | |
sub XFetchBytes(Pointer $display, int32 $length) is native('X11') returns Str { * }; | |
# XStoreBytes(displayptr, string, numbytes) | |
sub XStoreBytes(Str:D $display, Str:D $str, int32:D $len) is native('X11') { * } | |
#Display *XOpenDisplay(char *display_name); | |
sub XOpenDisplay(Str:D $display_name) is native('X11') returns Pointer { * } | |
my Str $Display; | |
my $NullStr; # Do not initialize this guy! | |
$Display = XDisplayName( $NullStr ); | |
my Pointer $displayptr = XOpenDisplay($Display); | |
print "\$Display = <$Display> \$displayptr = $displayptr.gist()\n"; | |
#XFetchBytes($displayptr, 2).say; crashes | |
#1 change; before #1 4 seconds ago |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment