-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMacroAOS4.pl
72 lines (62 loc) · 1.74 KB
/
MacroAOS4.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
### Class MacroAOS4: Create a AOS4-style macro file ###########################
BEGIN {
package MacroAOS4;
use vars qw(@ISA);
@ISA = qw( Macro );
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = $class->SUPER::new( @_ );
bless ($self, $class);
return $self;
}
sub function_start {
my $self = shift;
my %params = @_;
my $prototype = $params{'prototype'};
my $sfd = $self->{SFD};
if ($prototype->{type} eq 'function' ||
$prototype->{type} eq 'varargs') {
printf " I$sfd->{BaseName}->$prototype->{funcname}(";
}
else {
$self->SUPER::function_start (@_);
}
}
sub function_arg {
my $self = shift;
my %params = @_;
my $prototype = $params{'prototype'};
my $argtype = $params{'argtype'};
my $argname = $params{'argname'};
my $argreg = $params{'argreg'};
my $argnum = $params{'argnum'};
my $sfd = $self->{SFD};
if ($prototype->{type} eq 'function' ||
$prototype->{type} eq 'varargs') {
print ", " unless $argnum == 0;
if ($argname ne '...') {
print "$argname";
}
else {
print "__VA_ARGS__";
}
}
else {
$self->SUPER::function_arg (@_);
}
}
sub function_end {
my $self = shift;
my %params = @_;
my $prototype = $params{'prototype'};
my $sfd = $self->{SFD};
if ($prototype->{type} eq 'function' ||
$prototype->{type} eq 'varargs') {
print ")\n";
}
else {
$self->SUPER::function_end (@_);
}
}
}