-
-
Save anonymous/6e111a1914dfc938c644 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/env perl6 | |
use NativeCall; | |
constant TtyLIB = "/home/daryl/Documents/projets-prog/perl6/p6-IO-Handle-Tty/src/C/libTty.so"; | |
class winsize is repr('CStruct') { | |
has uint16 $.ws_row; | |
has uint16 $.ws_col; | |
has uint16 $.ws_xpixel; | |
has uint16 $.ws_ypixel; | |
} | |
class c_repr_pty is repr('CStruct') { | |
has int32 $!ptyfd; | |
has int32 $!ttyfd; | |
has Str $!name; | |
method ptyfd { $!ptyfd; } | |
method ttyfd { $!ttyfd; } | |
method name { $!name; } | |
} | |
sub pty_allocate() returns c_repr_pty is native(TtyLIB) { ... } | |
class IO::Tty { | |
has int32 $!ttyfd; | |
has winsize $!winsize; | |
method ttyfd { $!ttyfd; } | |
method set_ttyfd($new_ttyfd) { $!ttyfd = $new_ttyfd; } | |
} | |
class IO::Pty is IO::Handle { | |
has IO::Tty $.slave; | |
has int32 $ptyfd; | |
method allocate() { | |
my $c_pty = pty_allocate(); | |
} | |
} | |
# I want to be able to do that : | |
IO::Pty.new.allocate; | |
IO::Pty.new('/path/to/file'); | |
IO::Pty.new($pty); # $pty being IO::Pty | |
# but i don't known how i should create my BUILD/BUIDALL methods ... =( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment