@@ -278,7 +278,8 @@ TBD more
278
278
You can type your C < Pointer > with passing the type as parameter. It works with native type
279
279
but also C < CArray > and C < CStruct > defined type. NativeCall will not implicitly alloc the memory for it
280
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 > .
281
+ It's mostly useful in the case of a C routine returning a pointer, or if it's a pointer
282
+ embeded in a C < CStruct > .
282
283
283
284
You have to call C < .deref > on it to access the embeded type.
284
285
@@ -313,7 +314,39 @@ to callbacks.
313
314
314
315
= comment TODO
315
316
316
- TBD
317
+ TBD more
318
+
319
+ The C < native > trait accept simple lib name or a full path. It's common to
320
+ have the lib parameter defined as a constant than can be modified via an
321
+ environment variable. This is an example from the mysql binding in C < DBIIsh >
322
+
323
+ constant LIB = %*ENV < DBIISH_MYSQL_LIB > || 'libmysqlclient';
324
+ # and later
325
+ sub mysql_affectied_rows( .. ) returns int32 is native(LIB)
326
+
327
+ = head2 ABI/API Version
328
+
329
+ If you write C < native('libfoo') > NativeCall will search libfoo.so under Unix like system (libfoo.dynlib on Os X).
330
+ In most modern system it will requiere you or the user of your module to install
331
+ the develepment package because it's recommanded to always provide an API/ABI version to a
332
+ shared library, so libfoo.so ends often being a symbolic link provided only by a devel package.
333
+
334
+ To avoid that, the C < native > trait allow you to specify the API/ABI version. It can be a full
335
+ version or just a part of it (Try to stick to Major version, some BSD does not care for minor)
336
+
337
+ sub foo is native('libfoo', 1); # Will try to load libfoo.so.1
338
+ sub foo is native('libfoo', v1.2.3); # Will try to load libfoo.so.1.2.3
339
+
340
+ #From DBIish Pg driver
341
+ constant LIB = %*ENV < DBIISH_PG_LIB > || ('libpq', 5);
342
+
343
+
344
+ = head2 Routine
345
+
346
+ the C < native > trait also accept a C < Callable > as argument, allowing you to provide your
347
+ own way to handle the way it will find the library file to load.
348
+
349
+ sub foo is native(sub {'libfoo.so.42'});
317
350
318
351
= head2 Calling into the standard library
319
352
0 commit comments