FFI-Platypus

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

     my $n = notify_notification_new('Platypus Hello World', $message, 'dialog-information');
     notify_notification_show($n, undef);
     notify_uninit();

  Execute

     $ perl notify.pl

  Discussion

    The GNOME project provides an API to send notifications to its desktop
    environment. Nothing here is particularly new: all of the types and
    techniques are ones that we have seen before, except we are using a
    third party library, instead of using our own C code or the standard C
    library functions.

    When using a third party library you have to know the name or location
    of it, which is not typically portable, so here we use FFI::CheckLib's
    find_lib_or_die function. If the library is not found the script will
    die with a useful diagnostic. FFI::CheckLib has a number of useful
    features and will integrate nicely with Alien::Build based Aliens.

README  view on Meta::CPAN

    standard C library. It also provides a rats nest of type aliases.
    Finally if you want to talk Unicode to any of the Windows API you will
    need to use UTF-16LE instead of UTF-8 which is native to Perl. (The
    Win32 API refers to these as LPWSTR and LPCWSTR types). As much as
    possible the Win32 "language" plugin attempts to handle these
    challenges transparently. For more details see
    FFI::Platypus::Lang::Win32.

  Discussion

    The libnotify library is a desktop GUI notification system for the
    GNOME Desktop environment. This script sends a notification event that
    should show up as a balloon, for me it did so in the upper right hand
    corner of my screen.

 Structured Data Records (by pointer or by reference)

  C API

    cppreference - localtime
    <https://en.cppreference.com/w/c/chrono/localtime>

examples/win32_getSystemTime.pl  view on Meta::CPAN


#find the Kernel32.dll
my $libPath = find_lib(lib=>'Kernel32');
#Create FFI Object
my $ffiObj = FFI::Platypus->new();
$ffiObj->lib($libPath);

#Import the GetLocalTime function
$ffiObj->attach('GetLocalTime',['record(16)'],'void');

#Define SYSTEMTIME Struct as per https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
#As per, C:\MinGW\include\windef.h, WORD id unsigned short
my $c = Convert::Binary::C->new->parse(<<ENDC);

struct SYSTEMTIME {
  unsigned short wYear;
  unsigned short wMonth;
  unsigned short wDayOfWeek;
  unsigned short wDay;
  unsigned short wHour;
  unsigned short wMinute;

lib/FFI/Platypus.pm  view on Meta::CPAN


=for html <p>And this is what it will look like:</p>
<div style="display: flex">
<div style="margin: 3px; flex: 1 1 50%">
<img alt="Test" src="/examples//notify.png">
</div>
</div>

=head3 Discussion

The GNOME project provides an API to send notifications to its desktop environment.
Nothing here is particularly new: all of the types and techniques are ones that we
have seen before, except we are using a third party library, instead of using our
own C code or the standard C library functions.

When using a third party library you have to know the name or location of it, which
is not typically portable, so here we use L<FFI::CheckLib>'s
L<find_lib_or_die function|FFI::CheckLib/find_lib_or_die>.  If the library is not
found the script will die with a useful diagnostic.  L<FFI::CheckLib> has a number
of useful features and will integrate nicely with L<Alien::Build> based L<Alien>s.

lib/FFI/Platypus.pm  view on Meta::CPAN

is used by the standard C library.  It also provides a rats nest of
type aliases.  Finally if you want to talk Unicode to any of the
Windows API you will need to use C<UTF-16LE> instead of C<UTF-8>
which is native to Perl.  (The Win32 API refers to these as
C<LPWSTR> and C<LPCWSTR> types).  As much as possible the Win32
"language" plugin attempts to handle these challenges transparently.
For more details see L<FFI::Platypus::Lang::Win32>.

=head3 Discussion

The libnotify library is a desktop GUI notification system for the
GNOME Desktop environment. This script sends a notification event that
should show up as a balloon, for me it did so in the upper right hand
corner of my screen.

=head2 Structured Data Records (by pointer or by reference)

=head3 C API

L<cppreference - localtime|https://en.cppreference.com/w/c/chrono/localtime>



( run in 0.641 second using v1.01-cache-2.11-cpan-299005ec8e3 )