Re: How to use NativeCall with a libc function?

2016-04-04 Thread Tom Browder
On Mon, Apr 4, 2016 at 10:45 AM, Timo Paulssen wrote: > Hey Tom, > > in NativeCall, "is rw" has a very special meaning. For example, if you have > "int32 $foo is rw", you'll actually give the native function a pointer to an > int, and perl6 will make that work out for you properly if you have an "

Re: How to use NativeCall with a libc function?

2016-04-04 Thread Timo Paulssen
Hey Tom, in NativeCall, "is rw" has a very special meaning. For example, if you have "int32 $foo is rw", you'll actually give the native function a pointer to an int, and perl6 will make that work out for you properly if you have an "int" or an "Int" variable that you pass. Apparently we don

Re: How to use NativeCall with a libc function?

2016-04-04 Thread Tom Browder
On Sun, Apr 3, 2016 at 12:28 PM, Tom Browder wrote: > I have a module LIBCIO.pm6: I have pared all code down to a single test file located here: https://github.com/tbrowder/perl6-read-write-tests/blob/master/test-readline.pl6 with its input text file for reading here: https://github.com/t

Re: How to use NativeCall with a libc function?

2016-04-04 Thread Tom Browder
On Sun, Apr 3, 2016 at 1:26 PM, Timo Paulssen wrote: > When you have a sub that's not "our", it will not show up in the > module's namespace. Since you export the sub, it'll be available without > LIBCIO:: before its name. > > I suggest you pass Str (the String type object) instead of 'libc' for >

Re: How to use NativeCall with a libc function?

2016-04-03 Thread Timo Paulssen
When you have a sub that's not "our", it will not show up in the module's namespace. Since you export the sub, it'll be available without LIBCIO:: before its name. I suggest you pass Str (the String type object) instead of 'libc' for the native trait, as the symbol is pretty much guaranteed to alr

How to use NativeCall with a libc function?

2016-04-03 Thread Tom Browder
I have a module LIBCIO.pm6: unit module LIBCIO; use NativeCall; sub fopen(Str, Str) returns Pointer is native('libc') is export { * } I then try to use it in a Perl 6 sub: # try NativeCall use lib '.'; use LIBCIO; # get a file pointer my Str $mode = 'r'; my $fp = LIBCIO::fopen