Skip to content

Commit

Permalink
Reflows and link nativetype → nativecall
Browse files Browse the repository at this point in the history
And the other way round. Refs #1512
  • Loading branch information
JJ committed May 30, 2018
1 parent 0bfe6e6 commit 0e6e6d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 45 deletions.
50 changes: 8 additions & 42 deletions doc/Language/nativecall.pod6
Expand Up @@ -8,7 +8,7 @@
X<|nativecall>
The simplest imaginable use of NativeCall would look something like this:
The simplest imaginable use of C<NativeCall> would look something like this:
use NativeCall;
sub some_argless_function() is native('something') { * }
Expand Down Expand Up @@ -59,47 +59,13 @@ an example.
use NativeCall;
sub add(int32, int32) returns int32 is native("calculator") { * }
Here, we have declared that the function takes two 32-bit integers and returns
a 32-bit integer. Here are some of the other types that you may pass (this will
likely grow with time).
X<|int8>X<|int16>X<|int32>X<|int64>X<|uint8>X<|uint16>X<|uint32>X<|uint64>X<|long>X<|longlong>X<|ulong>X<|ulonglong>X<|num32>X<|num64>X<|Str>X<|Pointer>X<|bool>X<|size_t>X<|ssize_t>
=begin table
int (long in C)
int8 (int8_t in C, also used for char)
int16 (int16_t in C, also used for short)
int32 (int32_t in C, also used for int)
int64 (int64_t in C)
uint (ulong in C)
uint8 (uint8_t in C, also used for unsigned char)
uint16 (uint16_t in C, also used for unsigned short)
uint32 (uint32_t in C, also used for unsigned int)
uint64 (uint64_t in C)
long (long in C)
longlong (long long in C, at least 64-bit)
ulong (unsigned long in C)
ulonglong (unsigned long long in C, at least 64-bit)
longdouble (longdouble in C)
Num, num (double in C)
num32 (float in C)
num64 (double in C)
Str (C string)
CArray[int32] (int32_t* in C, an array of 32-bit ints)
Pointer[void] (void* in C, can point to all other types)
bool (bool from C99)
size_t (size_t in C)
ssize_t (ssize_t in C)
Callable (callback in C)
=end table
Don't use Perl 6 native types like C<int> or C<num> in native calls, as they
don't have to correspond to the local C equivalent (e.g., Perl 6's C<int> can be
8 bytes but C's C<int> is only 4 bytes).
Note that the lack of a C<returns> trait is used to indicate C<void> return type.
Do I<not> use the C<void> type anywhere except in the Pointer parameterization.
For strings, there is an additional "encoded" trait to give some extra hints on
Here, we have declared that the function takes two 32-bit integers and returns a
32-bit integer. You can find the other types that you may pass in the
L<native types|/language/nativetypes> page. Note that the lack of a C<returns>
trait is used to indicate C<void> return type. Do I<not> use the C<void> type
anywhere except in the Pointer parameterization.
For strings, there is an additional C<encoded> trait to give some extra hints on
how to do the marshaling.
use NativeCall;
Expand Down
6 changes: 3 additions & 3 deletions doc/Language/nativetypes.pod6
Expand Up @@ -15,9 +15,9 @@ X<|int>X<|uint>X<|num>X<|str>
=end table
However, these types do not necessarily have the size that is required by the
NativeCall interface (e.g., Perl 6's C<int> can be 8 bytes but C's C<int> is
only 4 bytes). Instead, the types below will have to be used instead of the
types C<int> or C<num> listed above.
L<NativeCall|/lang/nativecall> interface (e.g., Perl 6's C<int> can be 8 bytes
but C's C<int> is only 4 bytes). Instead, the types below will have to be used
instead of the types C<int> or C<num> listed above.
X<|int8>X<|int16>X<|int32>X<|int64>X<|uint8>X<|uint16>X<|uint32>X<|uint64>X<|num32>X<|num64>
=begin table
Expand Down

0 comments on commit 0e6e6d2

Please sign in to comment.