Affix
view release on metacpan or search on metacpan
infix/src/core/loader.c view on Meta::CPAN
return nullptr;
#if defined(INFIX_OS_WINDOWS)
return (void *)GetProcAddress((HMODULE)lib->handle, symbol_name);
#else
return dlsym(lib->handle, symbol_name);
#endif
}
/**
* @brief Reads the value of an exported global variable from a library into a buffer.
*
* This function first looks up the symbol's address. It then uses the `infix`
* signature parser (`infix_type_from_signature`) to determine the size of the
* variable. This ensures that the correct number of bytes are copied from the
* library's data segment into the user's buffer, preventing buffer overflows.
*
* @param[in] lib The library handle.
* @param[in] symbol_name The name of the global variable.
* @param[in] type_signature The `infix` signature string describing the variable's type (e.g., `"int32"`,
* `"{double,double}"`).
* @param[out] buffer A pointer to the destination buffer to receive the data. This buffer must be large enough to hold
* the type described by the signature.
lib/Affix/Build.pod view on Meta::CPAN
Returns a L<Path::Tiny> object pointing to the generated shared library. Dies with a detailed error message (including
STDOUT/STDERR of the failed command) if compilation fails.
=head2 C<link( )>
An alias for C<compile_and_link()>. Safe to call multiple times; it will return the cached library handle if the build
has already completed.
=head1 SUPPORTED LANGUAGES
20+ languages supported. The builder looks for compilers in your system C<PATH>.
=head3 C / C++
Automatically handles C<-fPIC> on non-Windows platforms.
=over
=item * B<Extensions:> C<.c>, C<.cpp>, C<.cxx>, C<.cc>
=item * B<Known Compilers:> C<cc>, C<gcc>, C<clang>, C<cl> (MSVC), C<c++>, C<g++>, C<icx>.
t/025_affix_wrap.t view on Meta::CPAN
for my $good_pkg (@ns_pkgs) {
my $code = eval {
my ( $c, $n ) = $binder->_generate_code( 'good_lib', $good_pkg );
$c;
};
ok defined $code, "accepts namespace $good_pkg";
like $code, qr/package\s+\Q$good_pkg\E\s*\{/, "Package decl for $good_pkg";
}
};
# Malicious $pkg that looks valid but isn't must be rejected
subtest 'Borderline pkg names rejected' => sub {
my @borderline = (
[ 'Evil; system("echo PWNED")', 'semicolon, no ::' ],
[ 'Evil pkg', 'space, no ::' ],
[ 'Evil::system("echo PWNED")', 'parens in name' ],
[ 'Evil->pkg', 'arrow instead of ::' ],
);
for my $t (@borderline) {
my ( $bad, $desc ) = @$t;
ok dies { $binder->generate( 'lib', $bad, '/dev/null' ) }, "rejects $desc: $bad";
( run in 2.986 seconds using v1.01-cache-2.11-cpan-8dfa8b56332 )