@@ -17,7 +17,7 @@ The simplest imaginable use of NativeCall would look something like this:
17
17
The first line imports various traits and types. The next line looks like
18
18
a relatively ordinary Perl 6 sub declaration - with a twist. We use the
19
19
"native" trait in order to specify that the sub is actually defined in a
20
- native library. The platform-specific extension (e.g. .so or .dll) will be
20
+ native library. The platform-specific extension (e.g., ' .so' or ' .dll' ) will be
21
21
added for you.
22
22
23
23
The first time you call "some_argless_function", the "libsomething" will be
@@ -79,7 +79,7 @@ likely grow with time).
79
79
size_t (size_t in C)
80
80
81
81
Don't use Perl 6 native types like C < int > or C < num > , as they don't have to
82
- correspond to the local C equivalent (e.g. Perl 6's C < int > can be 8 bytes but
82
+ correspond to the local C equivalent (e.g., Perl 6's C < int > can be 8 bytes but
83
83
C's C < int > is only 4 bytes).
84
84
85
85
Note that the lack of a C < returns > trait is used to indicate void return type.
@@ -178,7 +178,7 @@ Once again, type objects are used to represent nulls.
178
178
= head1 Function Pointers
179
179
180
180
C libraries can expose pointers to C functions as return values of functions and as
181
- members of Structures like e.g. structs and unions.
181
+ members of Structures like, e.g., structs and unions.
182
182
183
183
Example of invoking a function pointer "$fptr" returned by a function "f", using a
184
184
signature defining the desired function parameters and return value:
@@ -194,7 +194,7 @@ signature defining the desired function parameters and return value:
194
194
195
195
NativeCall has some support for arrays. It is constrained to work with machine-size
196
196
integers, doubles and strings, sized numeric types, arrays of pointers, arrays of
197
- structs and arrays of arrays.
197
+ structs, and arrays of arrays.
198
198
199
199
Perl 6 arrays, which support amongst other things laziness, are laid out in memory
200
200
in a radically different way to C arrays. Therefore, the NativeCall library offers
@@ -226,7 +226,7 @@ use C<$> all the way when using NativeCall. :-)
226
226
Getting return values for arrays works out just the same.
227
227
228
228
Some library APIs may take an array as a buffer that will be populated by the
229
- C function and, for, instance, return the actual number of items populated:
229
+ C function and, for instance, return the actual number of items populated:
230
230
231
231
sub get_n_ints(CArray[int32], int32) returns int32 is native('ints') { * }
232
232
@@ -330,8 +330,8 @@ instead:
330
330
331
331
TBD more
332
332
333
- You can type your C < Pointer > with passing the type as parameter. It works with native type
334
- but also C < CArray > and C < CStruct > defined type . NativeCall will not implicitly alloc the memory for it
333
+ You can type your C < Pointer > by passing the type as a parameter. It works with the native type
334
+ but also with C < CArray > and C < CStruct > defined types . NativeCall will not implicitly alloc the memory for it
335
335
even when calling new on them.
336
336
It's mostly useful in the case of a C routine returning a pointer, or if it's a pointer
337
337
embedded in a C < CStruct > .
@@ -379,10 +379,10 @@ The C<native> trait accepts the library name or the full path.
379
379
sub mysql_affectied_rows( .. ) returns int32 is native(LIBMYSQL);
380
380
sub bar is native(LIBFOO);
381
381
382
- You can also put incomplete path like './foo', NativeCall will automaticly put
382
+ You can also put an incomplete path like './foo', NativeCall will automatically put
383
383
the right extension according to the plateform specification.
384
384
385
- BE CAREFUL: the C < native > trait and C < constant > are evalued at compile time. Don't write a constant
385
+ BE CAREFUL: the C < native > trait and C < constant > are evaluated at compile time. Don't write a constant
386
386
that depend on dynamic variable like:
387
387
388
388
constant LIBMYSQL = %*ENV < P6LIB_MYSQLCLIENT > || 'mysqlclient';
@@ -393,12 +393,12 @@ keep the value it get evaluated when the module get precompiled.
393
393
= head2 ABI/API Version
394
394
395
395
If you write C < native('foo') > NativeCall will search libfoo.so under Unix like system (libfoo.dynlib on Os X, foo.dll on win32).
396
- In most modern system it will requiere you or the user of your module to install
397
- the develepment package because it's recommanded to always provide an API/ABI version to a
396
+ In most modern system it will require you or the user of your module to install
397
+ the develepment package because it's recommended to always provide an API/ABI version to a
398
398
shared library, so libfoo.so ends often being a symbolic link provided only by a devel package.
399
399
400
- To avoid that, the C < native > trait allow you to specify the API/ABI version. It can be a full
401
- version or just a part of it (Try to stick to Major version, some BSD does not care for minor )
400
+ To avoid that, the C < native > trait allows you to specify the API/ABI version. It can be a full
401
+ version or just a part of it. (Try to stick to Major version, some BSD code does not care for Minor. )
402
402
403
403
sub foo is native('foo', v1); # Will try to load libfoo.so.1
404
404
sub foo is native('foo', v1.2.3); # Will try to load libfoo.so.1.2.3
0 commit comments