Skip to content

Commit 142b4cf

Browse files
committed
Added bool and size_t to NC doc. Also add a bit of words on typed pointer
1 parent 1bf67d6 commit 142b4cf

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

doc/Language/nativecall.pod

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ likely grow with time).
6969
Str (C string)
7070
CArray[int32] (int* in C, an array of integers)
7171
Pointer[void] (void* in C, can point to all other types)
72+
bool (bool from C99)
73+
size_t (size_t in C)
7274
7375
Note that the lack of a C<returns> trait is used to indicate void return type.
7476
Do I<not> use the 'void' type anywhere except in the Pointer parameterization.
@@ -271,7 +273,21 @@ instead:
271273
272274
=comment TODO
273275
274-
TBD
276+
TBD more
277+
278+
You can type your C<Pointer> with passing the type as parameter. It works with native type
279+
but also C<CArray> and C<CStruct> defined type. NativeCall will not implicitly alloc the memory for it
280+
even when calling new on them.
281+
It's mostly useful in the case of a C routine returning one or if emebeded in a C<CStruct>.
282+
283+
You have to call C<.deref> on it to access the embeded type.
284+
285+
my Pointer[int32] $p; #For a pointer on int32;
286+
my Pointer[MyCstruct] $p2 = some_c_routine();
287+
my MyCstruct $mc = $p2.deref;
288+
say $mc.field1;
289+
290+
275291
276292
=head1 Buffers and Blobs
277293

0 commit comments

Comments
 (0)