line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of App-PythonToPerl |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2023 by Auto-Parallel Technologies, Inc. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# [[[ HEADER ]]] |
11
|
|
|
|
|
|
|
# ABSTRACT: a function decorator |
12
|
|
|
|
|
|
|
#use RPerl; |
13
|
|
|
|
|
|
|
package Python::FunctionDecorator; |
14
|
1
|
|
|
1
|
|
11
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
15
|
1
|
|
|
1
|
|
11
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
43
|
|
16
|
|
|
|
|
|
|
our $VERSION = 0.001_000; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# [[[ OO INHERITANCE ]]] |
19
|
1
|
|
|
1
|
|
11
|
use parent qw(Python::Component); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
20
|
1
|
|
|
1
|
|
68
|
use Python::Component; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# [[[ CRITICS ]]] |
23
|
|
|
|
|
|
|
## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print op |
24
|
|
|
|
|
|
|
## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils |
25
|
|
|
|
|
|
|
## no critic qw(ProhibitConstantPragma ProhibitMagicNumbers) # USER DEFAULT 3: allow constants |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# [[[ INCLUDES ]]] |
28
|
1
|
|
|
1
|
|
4
|
use Perl::Types; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
366
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# DEV NOTE: not actually used in this class, but needed so python_preparsed_to_perl_source() |
31
|
|
|
|
|
|
|
# can accept the same args as all Python::Component classes |
32
|
1
|
|
|
1
|
|
9
|
use OpenAI::API; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
226
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# [[[ OO PROPERTIES ]]] |
35
|
|
|
|
|
|
|
our hashref $properties = { |
36
|
|
|
|
|
|
|
component_type => my string $TYPED_component_type = 'Python::FunctionDecorator', |
37
|
|
|
|
|
|
|
# all other properties inherited from Python::Component |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# [[[ SUBROUTINES & OO METHODS ]]] |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# PYFD01x |
43
|
|
|
|
|
|
|
sub python_preparsed_to_perl_source { |
44
|
|
|
|
|
|
|
# return translated Perl source code for pre-parsed Python component |
45
|
0
|
|
|
0
|
0
|
|
{ my string $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
( my Python::FunctionDecorator $self, my OpenAI::API $openai ) = @ARG; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# error if no OpenAI API |
49
|
0
|
0
|
|
|
|
|
if (not defined $openai) { |
50
|
0
|
|
|
|
|
|
croak 'ERROR EPYFD010: undefined OpenAI API, croaking'; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# error or warning if no Python source code |
54
|
0
|
0
|
0
|
|
|
|
if ((not exists $self->{python_source_code}) or |
|
|
|
0
|
|
|
|
|
55
|
|
|
|
|
|
|
(not defined $self->{python_source_code}) or |
56
|
|
|
|
|
|
|
($self->{python_source_code} eq q{})) { |
57
|
0
|
|
|
|
|
|
croak 'ERROR EPYFD011: non-existent or undefined or empty Python source code, croaking'; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# START HERE: translate function decorators, including indentation as appropriate |
61
|
|
|
|
|
|
|
# START HERE: translate function decorators, including indentation as appropriate |
62
|
|
|
|
|
|
|
# START HERE: translate function decorators, including indentation as appropriate |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# $self->{perl_source_code} = '# ' . $self->{python_source_code} . ' # DUMMY PERL SOURCE CODE, NEED TRANSLATE!'; |
65
|
0
|
|
|
|
|
|
$self->{perl_source_code} = $self->python_source_code_indentation() . '# ' . $self->python_source_code_without_indentation() . ' # DUMMY PERL SOURCE CODE, NEED TRANSLATE!'; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
print 'in Function::Decorator->python_preparsed_to_perl_source(), about to return $self->{perl_source_code} = \'', $self->{perl_source_code}, '\'', "\n"; |
68
|
|
|
|
|
|
|
#die 'TMP DEBUG'; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# return Perl source code |
71
|
0
|
|
|
|
|
|
return $self->{perl_source_code}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |