-
-
Save Skarsnik/c4bc15b75b883f69fde1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use NativeCall; | |
# First arg is just a 'key' name, second is basename of the lib. You will need etheir :version or :no-version | |
# ENV argument is optionnal. the corresponding ENV variable will be used instead of the rest if defined. | |
# The value returned is a NC-Library-Handle object (it's a 'hidden' role) | |
my NC-Library-Name $GUMBO_LIB = register-native-library('Gumbo', 'gumbo', :version(v1), :ENV<PERL6_LIBGUMBO>); | |
sub piko is native($GUMBO_LIB) { * } | |
#This is some other way to call it | |
register-native-library('Gumbo', 'gumbo'); # Die, because no version information given | |
register-native-library('Gumbo', 'gumbo', :no-version); # explicitly tell to not care about the version | |
register-native-library('Gumbo', '/usr/lib/gumbo.so.1'); # Work, if it's an existing path like if you do a helper wrapping lib | |
#and use it with RESOURCE | |
#Compile time version, it give a callable | |
constant GUMBO_LIB = callable-register-native-library('Gumbo', 'gumbo', :version(v1)); | |
#There is some utils, name can be changed | |
use NativeCall :utils; | |
say "Gumbo :"; | |
say get-native-library('Gumbo'); # return the lib handle | |
#There part are made 'public' mainly for people wanting to write Module to handle lib in another way | |
# than the default | |
my NC-Library-Handle $lhfoo = NC-Library-Handle.new(:library-name</lib/foo.so.1>); | |
add-native-library('Foo', $lhfoo); | |
say "All :"; | |
say list-native-libraries; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment