Guest User

Cannot invoke object with invocation handler in this context

a guest
Apr 2nd, 2016
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. module Select {
  2.  
  3. use NativeCall;
  4.  
  5. class Timeval is repr('CStruct') {
  6. has int64 $.seconds;
  7. has int64 $.microseconds;
  8. }
  9.  
  10. multi sub select(int64, CArray[int8], Pointer, Pointer, Timeval) is native returns int { * }
  11.  
  12. multi sub select (Int $fd, Numeric $timeout = 0) is export {
  13. my int64 $nfds = $fd;
  14. my CArray[int8] $readfds = CArray[int8].new;
  15. $readfds[0] = 0x1 +< ($fd - 1);
  16. my $tv = Timeval.new(seconds => $timeout.Int, microseconds => 0);
  17. my $res = select($nfds, $readfds, Pointer, Pointer, $tv);
  18. return $res;
  19. }
  20. }
  21.  
  22. ###
  23.  
  24. use Test;
  25.  
  26. use Select;
  27.  
  28. my $fd = 1;
  29. my $timeout = 5;
  30. ok(my $res = select($fd, $timeout), 'Called Select');
  31. warn $res;
Add Comment
Please, Sign In to add comment