Skip to content

Commit

Permalink
Call Groovy from Perl
Browse files Browse the repository at this point in the history
  • Loading branch information
PyjaErskell committed Dec 12, 2019
1 parent 14edbad commit 6fc5582
Show file tree
Hide file tree
Showing 6 changed files with 567 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@ECHO OFF
SETLOCAL

SET SC_KAPA_HM=C:\ProgramData\Bichon Frise\Kapa
SET SC_JAVA_HM=%SC_KAPA_HM%\19.11.01\Vindue\x64\Amazon\Corretto\8.232.09.1
SET Path=%SC_JAVA_HM%\jre\bin\server;%Path%

PUSHD "%~DP0"
CD "%~DP0"

SET SC_MILO_PN=%CD%
CD "%SC_MILO_PN%\..\..\..\.."
SET SC_PYJA_HM=%CD%
FOR %%F IN (%SC_PYJA_HM%\..) DO SET SC_PYJA_NM=%%~NXF
FOR %%F IN (%SC_PYJA_HM%) DO SET SC_PYJA_VR=%%~NXF

POPD

SET SC_ECU_PN=%SC_MILO_PN%\ecu
SET PERL5LIB=%SC_MILO_PN%\src\k-09001-perl

"%SC_KAPA_HM%\19.01.22\Vindue\x64\Strawberry\5.28.1\perl\bin\perl5.28.1.exe" "%SC_MILO_PN%\src\k-01001-run-me\SToa.pl" %*
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

export SC_KAPA_HM="/Library/Application Support/Bichon Frise/Kapa"
export SC_JAVA_HM=$SC_KAPA_HM/19.11.01/Mushama/x64/Amazon/Corretto/8.232.09.1
export LD_LIBRARY_PATH=$SC_JAVA_HM/jre/lib/server

export SC_MILO_PN=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

export SC_PYJA_HM=$( cd "$SC_MILO_PN/../../../.." && pwd )
export SC_PYJA_NM=$( basename "$( cd "$SC_PYJA_HM/.." && pwd )" )
export SC_PYJA_VR=$( basename "${SC_PYJA_HM}" )

export SC_ECU_PN=$SC_MILO_PN/ecu

"/opt/local/bin/perl5.26.3" -I "$SC_MILO_PN/src/k-09001-perl" "$SC_MILO_PN/src/k-01001-run-me/SToa.pl" "$@"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//---------------------------------------------------------------
// Global
//---------------------------------------------------------------

gf_cls = { x_cls_nm -> Class .forName (x_cls_nm) } // find class from string

gp_make_globals = { -> this.binding.variables .each { x2_key, x2_value -> if ( ! x2_key .startsWith ('_') ) { Object.metaClass."$x2_key" = x2_value } } }
gp_make_globals ()

//---------------------------------------------------------------
// Your Source
//---------------------------------------------------------------

sf_hello = { x_str, x_no -> "Hello ${ x_str * x_no } !!!" }
sf_sum = { long ... x_args -> x_args*.value .sum () }

1
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#---------------------------------------------------------------
# Global
#---------------------------------------------------------------

use v5.26;
use strict;
use warnings;

use File::Basename;

BEGIN { $ENV {'SC_DUCK_PN'} = dirname (__FILE__); }

use i191210::G010;

#---------------------------------------------------------------
# Your Source
#---------------------------------------------------------------

package WMain;

use v5.26;
use strict;
use warnings;

use Config;
use utf8;
use Wx qw( wxDefaultPosition wxMAJOR_VERSION wxMINOR_VERSION );
use Wx::Event qw( EVT_ACTIVATE EVT_CLOSE );

use i191210::G010;

use base qw(Wx::App);

sub OnInit {
my ($self) = @_;
GC_LOG -> info ( "${\ ref $self } : Initializing ..." );
$self->{wu_fra} = Wx::Frame -> new ( undef, -1, "${\GC_OLIM_NM} : ${\GC_MILO_NM}", wxDefaultPosition, [ 660, 300 ] );
$self->{wu_lbx} = Wx::ListBox -> new ($self->{wu_fra});
EVT_ACTIVATE ( $self->{wu_fra}, \&wn_fra_activate );
EVT_CLOSE ( $self->{wu_fra}, \&wn_fra_close );
$self -> SetTopWindow ($self->{wu_fra});
$self->{wu_fra} -> Center ();
$self->{wu_fra} -> Show (1);
$self -> wn_init ();
1;
}

sub wn_init {
my ($self) = @_;
$self -> wn_say ( "\$^V => $^V" );
$self -> wn_say ( "wxPerl version => $Wx::VERSION" );
$self -> wn_say ( "wxWidgets version => ${\wxMAJOR_VERSION}.${\wxMINOR_VERSION}" );
$self -> wn_say ( "Java version => ${\ java::lang::System -> getProperty ('java.version') }" );
$self -> wn_say ( "Groovy version => ${\ jf_ge ('GroovySystem.version') }" );
$self -> wn_say ( "Perl hello (English) => ${\ main::sf_perl_hello ( 'PERL-', 6 ) }" );
$self -> wn_say ( "Perl hello (Korean) => ${\ main::sf_perl_hello ( '펄-', 25 ) }" );
$self -> wn_say ( "Java string format 'int : %,d, long : %,d' => ${\ jf_sf ( 'int : %,d, long : %,d', 314159265, 314159265358979 ) }" );
$self -> wn_say ( "Java string format 'English : %s, Korean : %s' => ${\ jf_sf ( 'English : %s, Korean : %s', 'JAVA', '자바' ) }" );
$self -> wn_say ( "Groovy hello (English) => ${\ jf_gf ( 'sf_hello', 'GROOVY-', 6 ) -> toString () }" );
$self -> wn_say ( "Groovy hello (Korean) => ${\ jf_gf ( 'sf_hello', '그루비-', 6 ) -> toString () }" );
$self -> wn_say ( "Groovy sum of numbers => ${\ jf_sf ( '%,d', jf_gf ( 'sf_sum', 700000000, 12, 49, 15, 51, 94, 21, 63 ) ) }" );
}

sub wn_say {
my ( $self, $x_line ) = @_;
$self->{wu_lbx} -> Append ($x_line);
}

sub wn_fra_activate {
my ( $self, $x_ev ) = @_;
GC_LOG -> debug ( "${\ ref $self } : Activated ..." );
$x_ev -> Skip;
}

sub wn_fra_close {
my ( $self, $x_ev ) = @_;
GC_LOG -> info ( "${\ ref $self } : Closing ..." );
$x_ev -> Skip;
}

package main;

sub sf_perl_hello {
my ( $x_it, $x_repeat ) = @_;
return 'Hello ' . $x_it x $x_repeat . ' !!!'
}

sub sp_body {
my $pu_m = WMain -> new ();
$pu_m -> MainLoop;
}

sub sp_main {
gp_run (\&sp_body);
}


sp_main ();
Loading

0 comments on commit 6fc5582

Please sign in to comment.