-
Notifications
You must be signed in to change notification settings - Fork 9
/
StubAROS.pl
110 lines (91 loc) · 2.75 KB
/
StubAROS.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
### Class StubAROS: Create an AROS stub file ##################################
BEGIN {
package StubAROS;
use vars qw(@ISA);
@ISA = qw( Stub );
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = $class->SUPER::new( @_ );
bless ($self, $class);
return $self;
}
sub header {
my $self = shift;
$self->SUPER::header (@_);
print "#include <aros/libcall.h>\n";
print "\n";
}
sub function_start {
my $self = shift;
my %params = @_;
my $prototype = $params{'prototype'};
my $sfd = $self->{SFD};
if ($prototype->{type} eq 'function') {
print "\n";
print "{\n";
if (!$prototype->{nb}) {
print " BASE_EXT_DECL\n";
}
if (!$prototype->{nr}) {
print " $prototype->{return} _res = ($prototype->{return}) ";
}
else {
print " ";
}
printf "AROS_LC%d%s($prototype->{return}, $prototype->{funcname},\n",
$prototype->{numargs}, $prototype->{nb} ? "I" : "";
}
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') {
print " AROS_LCA($argtype, $argname, " . (uc $argreg) . "),\n";
}
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') {
if ($prototype->{nb}) {
my $bt = "/* bt */";
my $bn = "/* bn */";
for my $i (0 .. $#{$prototype->{regs}}) {
if ($prototype->{regs}[$i] eq 'a6') {
$bt = $prototype->{argtypes}[$i];
$bn =$prototype->{___argnames}[$i];
last;
}
}
printf " $bt, $bn, %d, $sfd->{Basename});\n",
$prototype->{bias} / 6;
}
else {
printf " $sfd->{basetype}, BASE_NAME, %d, $sfd->{Basename});\n",
$prototype->{bias} / 6;
}
if (!$prototype->{nr}) {
print " return _res;\n";
}
print "};\n";
}
else {
$self->SUPER::function_end (@_);
}
}
}