Ext/LuaFuncs.pm

filter: Statementstmt 44.7% 17 / 38 Branchbran 0.0% 0 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 57.1% 4 / 7 Podpod 100% 2 / 2 totaltotal 40.0% 24 / 60 CC 6 SCAR 21.2
CC
6
Cov
37%
call
20.0
AUTOLOAD
6.0
new
2.1
CRAP 8.3
« Ext/Plugin/Host.pm ↑ Summary Ext/MsgPack/RPC/Session.pm »
1 package Neovim::Ext::LuaFuncs;
2 55 $Neovim::Ext::LuaFuncs::VERSION = '0.01';
3 55 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 55 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 55 ▶use base qw/Class::Accessor/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 55 __PACKAGE__->mk_accessors (qw/nvim name/);
8  
9  
10 sub new
11 {
12 11 ▶ my ($this, $nvim, $name) = @_;
Subroutine new: called CC=2 SCAR=7.4
Pod documented
13  
14 11 ▶ my $class = ref ($this) || $this;
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0110
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
15 11 my $self =
16 {
17 nvim => $nvim,
18 name => $name,
19 };
20  
21 11 return bless $self, $class;
22 }
23  
24  
25  
26 sub call
27 {
28 0 ▶ my ($this, @args) = @_;
Subroutine call: not called CC=4 SCAR=30.0
Pod documented
29  
30 0 my $async = 0;
31  
32 0 my @filtered;
33 0 ▶ while (my $value = shift @args)
Branch: 1 branch
BranchTrueFalseTotal
if (my $value = shift @args) 0 0 0
34 {
35 0 push @filtered, $value;
36  
37 0 ▶ if ($value eq 'async_')
Branch: 1 branch
BranchTrueFalseTotal
if ($value eq "async_") 0 0 0
38 {
39 0 my $tmp = shift @args;
40 0 $async = !!$tmp;
41 0 push @filtered, $tmp;
42 }
43 }
44  
45 0 @args = @filtered;
46  
47 0 my $code = $this->name."(...)";
48 0 ▶ if (!$async)
Branch: 1 branch
BranchTrueFalseTotal
unless ($async) 0 0 0
49 {
50 0 $code = "return $code";
51 }
52  
53 0 $this->nvim->exec_lua ($code, @args);
54 }
55  
56  
57  
58 sub DESTROY
59 ▶{
Subroutine DESTROY: not called CC=1 SCAR=0.0
60 }
61  
62  
63 55 our $AUTOLOAD;
64  
65 sub AUTOLOAD
66 {
67 0 ▶ my $methodName;
Subroutine AUTOLOAD: not called CC=2 SCAR=17.9
68 0 ($methodName = $AUTOLOAD) =~ s/.*:://;
69  
70 0 my $this = shift;
71 0 my $prefix = '';
72 0 ▶ $prefix = $this->name.'.' if ($this->name);
Branch: 1 branch
BranchTrueFalseTotal
if $this->name 0 0 0
73  
74 0 my $name = $prefix.$methodName;
75 0 return __PACKAGE__->new ($this->nvim, $name);
76 }
77  
78 =head1 NAME
79  
80 Neovim::Ext::LuaFuncs - Neovim LuaFuncs class
81  
82 =head1 VERSION
83  
84 version 0.01
85  
86 =head1 SYNOPSIS
87  
88 use Neovim::Ext;
89  
90 my $result = $lua->lua_function->call (123);
91  
92 =head1 DESCRIPTION
93  
94 Helper pacakge to allow lua functions to be called like perl methods.
95  
96 =head1 METHODS
97  
98 =head2 call( @args )
99  
100 Call a lua function.
101  
102 =cut
103  
104 55 1;
« Ext/Plugin/Host.pm ↑ Summary Ext/MsgPack/RPC/Session.pm »