Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. We have a c source file: something.c
  2.  
  3. [source, c]
  4. ------------------
  5. int xmode(char** str)
  6. {
  7. (*str)[0] = 'X';
  8. (*str) ++; // xmode modified *str
  9. return 0;
  10. }
  11. ------------------
  12.  
  13. Setup a perl6 file, use NativeCall call function xmode: something.p6
  14.  
  15. [source, perl6]
  16. -----------------
  17. #!/usr/bin/env perl6
  18.  
  19. use v6;
  20. use NativeCall;
  21.  
  22. sub xmode(CArray[Str]) returns int32 is native('xmode') { * }
  23.  
  24. my CArray[Str] $astr .= new;
  25.  
  26. $astr[0] = "54654";
  27.  
  28. say xmode($astr);
  29.  
  30. say $astr[0]; // rakudo output -> "4654"
  31. -----------------
  32.  
  33. So, how to get orignal string "X4654" in pelr6 side .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement