@@ -31,7 +31,7 @@ so edit it there in the git repository if you would like to make changes.
31
31
use NativeCall;
32
32
33
33
sub native_function(int arg) is native('libsomething') { * }
34
- sub short_name() is native('libsomething') is symbol('long_and_complicated_name) { * }
34
+ sub short_name() is native('libsomething') is symbol('long_and_complicated_name' ) { * }
35
35
36
36
native_function(42);
37
37
@@ -43,10 +43,15 @@ Languages like Fortran and C++ require name mangling, which is
43
43
compiler-specific and thus falls well beyond the scope of this specification.
44
44
45
45
Hypotheticals:
46
- =for item
46
+
47
+ =over
48
+
49
+ =item
47
50
This is likely not an exhaustive list of showstoppers for C++/Fortran compat;
48
51
also, some platforms may be tricky simply in terms of C interop as well
49
52
53
+ =back
54
+
50
55
=head2 Calling foreign code
51
56
52
57
A sub is marked as a native routine with the C<is native> trait. A native sub
@@ -134,35 +139,50 @@ Numeric types, both native types and not, have obvious marshalling semantics
134
139
(as long as they are not arbitrary-precision types). A NativeCall
135
140
implementation should suport the following types:
136
141
142
+ =over
143
+
137
144
=item C<int8>, C<uint8> signed and unsigned byte
145
+
138
146
=item C<int16>, C<uint16> signed and unsigned two-byte integer
147
+
139
148
=item C<int32>, C<uint32> signed and unsigned four-byte integer
149
+
140
150
=item C<int64>, C<uint64> signed and unsigned eight-byte integer
151
+
141
152
=item C<int>, C<uint> signed and unsigned machine word
153
+
142
154
=item C<Int> largest available integer type
143
155
144
156
=item C<num32> four-byte floating point number
157
+
145
158
=item C<num>, C<num64> eight-byte floating point number
146
159
160
+ =back
161
+
147
162
Hypotheticals:
148
- =for item
163
+
164
+ =over
165
+
166
+ =item
149
167
This is a wider range of native types than what S02 mandates. We'll either
150
168
want to expand that list of natives, or find some other way of specifying
151
169
sizes.
152
170
153
- =for item
171
+ =item
154
172
There is no obvious mirror of C<Int> for largest available I<unsigned> type.
155
173
156
- =for item
174
+ =item
157
175
Should C<Num> be a synonym for C<num>/C<num64>?
158
176
159
- =for item
177
+ =item
160
178
If the Int or Num type object is passed, should it be silently converted to a
161
179
zero value, or cause an exception?
162
180
163
- =for item
181
+ =item
164
182
How should overflows be handled?
165
183
184
+ =back
185
+
166
186
=head3 Strings
167
187
168
188
multi explicitly-manage(Str $x is rw, :$encoding = 'utf8') is export(:DEFAULT, :utils) { ... }
@@ -180,11 +200,16 @@ the caller or callee owns the data can't be decided automatically, and freeing
180
200
by default risks causing later code to access freed memory.
181
201
182
202
Hypotheticals:
183
- =for item
203
+
204
+ =over
205
+
206
+ =item
184
207
We need better facilities for signalling when it's appropriate to free data.
185
208
The current facilities have the benefit that it won't cause memory-related
186
209
errors later on, but on the flip side, it will leak memory over time.
187
210
211
+ =back
212
+
188
213
=head3 The C<OpaquePointer> class
189
214
190
215
class OpaquePointer is repr('CPointer') { }
@@ -276,6 +301,7 @@ One option is an API similar to the C99 C<stdarg.h> macros and explicitly get
276
301
arguments off an opaque object. For example C<my $arg = va_arg($args, Type)>.
277
302
278
303
=head2 Miscellaneous helper functions
304
+
279
305
=head3 Refreshing outdated objects
280
306
281
307
multi refresh($obj) is export(:DEFAULT, :utils) { { ... }
@@ -290,7 +316,12 @@ the user will have to use C<refresh> to invalidate any outdated objects in the
290
316
cache.
291
317
292
318
Hypotheticals:
293
- =for item
319
+
320
+ =over
321
+
322
+ =item
294
323
Sometimes it will be necessary to reinterpret a pointer-valued object as a
295
324
different kind of pointer. One way to provide this would be a function a la:
296
325
C<my $val = reinterpret($ptr, Type)>.
326
+
327
+ =back
0 commit comments