2 ### Class GateAOS4: Create a AmigaOS gatestub file ############################
11 my $class = ref($proto) || $proto;
12 my $self = $class->SUPER::new
( @_ );
13 bless ($self, $class);
19 my $sfd = $self->{SFD
};
21 $self->SUPER::header
(@_);
23 print "#define __NOLIBBASE__\n";
24 print "#include <proto/$sfd->{basename}.h>\n";
25 print "#undef __NOLIBBASE__\n";
26 print "#include <stdarg.h>\n";
33 my $prototype = $params{'prototype'};
34 my $sfd = $self->{SFD
};
36 if ($prototype->{type
} eq 'function' ||
37 $prototype->{type
} eq 'varargs' ) {
38 $self->function_proto (prototype => $prototype);
39 $self->function_start (prototype => $prototype);
40 for my $i (0 .. $$prototype{'numargs'} - 1 ) {
41 $self->function_arg (prototype => $prototype,
42 argtype
=> $$prototype{'argtypes'}[$i],
43 argname
=> $$prototype{'___argnames'}[$i],
44 argreg
=> $$prototype{'regs'}[$i],
47 $self->function_end (prototype => $prototype);
56 my $prototype = $params{'prototype'};
57 my $sfd = $self->{SFD
};
59 print "$prototype->{return}";
60 if ($prototype->{type
} eq 'varargs') {
64 print "$gateprefix$prototype->{funcname}(";
65 if ($prototype->{type
} eq 'function' &&
66 $prototype->{subtype
} =~ /^(library|device|boopsi)$/) {
67 # Special function prototype
69 if ($prototype->{bias
} == 0) {
72 elsif ($prototype->{subtype
} eq 'library' ||
73 $prototype->{subtype
} eq 'boopsi') {
74 print "struct LibraryManagerInterface* _iface";
76 elsif( $prototype->{subtype
} eq 'device') {
77 print "struct DeviceManagerInterface* _iface";
81 print "struct $sfd->{BaseName}IFace* _iface";
88 my $prototype = $params{'prototype'};
89 my $argtype = $params{'argtype'};
90 my $argname = $params{'argname'};
91 my $argreg = $params{'argreg'};
92 my $argnum = $params{'argnum'};
93 my $sfd = $self->{SFD
};
95 if ($prototype->{subtype
} ne 'tagcall' ||
96 $argnum ne $prototype->{numargs
} - 2) {
98 if ($argnum != 0 || $prototype->{bias
} != 0) {
102 if ($prototype->{subtype
} =~ /^(library|device|boopsi)$/ &&
103 $prototype->{bias
} == 0 &&
104 $argnum == $prototype->{numargs
} - 1 ) {
105 print " struct ExecIFace* _iface";
108 print " $prototype->{___args}[$argnum]";
116 my $prototype = $params{'prototype'};
117 my $sfd = $self->{SFD
};
119 if ($self->{PROTO
}) {
126 if ($prototype->{subtype
} =~ /^(library|device|boopsi)$/ &&
127 $prototype->{bias
} == 0) {
128 print " $prototype->{___args}[$prototype->{numargs} - 1] = ".
129 "($prototype->{argtypes}[$prototype->{numargs} - 1]) " .
130 "_iface->Data.LibBase;\n";
133 if ($prototype->{type
} ne 'varargs') {
134 print " return $libprefix$prototype->{funcname}(";
136 if ($libarg eq 'first' && !$prototype->{nb
}) {
137 print "($sfd->{basetype}) _iface->Data.LibBase";
138 print $prototype->{numargs
} > 0 ?
", " : "";
141 print join (', ', @
{$prototype->{___argnames
}});
143 if ($libarg eq 'last' && !$prototype->{nb
}) {
144 print $prototype->{numargs
} > 0 ?
", " : "";
145 print "($sfd->{basetype}) _iface->Data.LibBase";
151 if ($prototype->{subtype
} eq 'tagcall') {
152 $na = $prototype->{numargs
} - 3;
154 elsif ($prototype->{subtype
} eq 'printfcall') {
155 $na = $prototype->{numargs
} - 2;
158 # methodcall: first vararg is removed
159 $na = $prototype->{numargs
} - 3;
162 print " va_list _va;\n";
163 print " va_startlinear (_va, ";
165 print "$prototype->{___argnames}[$na]);\n";
171 print " return $libprefix$prototype->{real_funcname}(";
173 if ($libarg eq 'first' && !$prototype->{nb
}) {
174 print "($sfd->{basetype}) _iface->Data.LibBase";
175 print $prototype->{numargs
} > 0 ?
", " : "";
178 for (my $i = 0; $i <= $na; ++$i) {
179 print "@{$prototype->{___argnames}}[$i], ";
182 print "va_getlinearva (_va, " .
183 "$prototype->{argtypes}[$prototype->{numargs}-1])";
185 if ($libarg eq 'last' && !$prototype->{nb
}) {
186 print $prototype->{numargs
} > 0 ?
", " : "";
187 print "($sfd->{basetype}) _iface->Data.LibBase";
190 # varargs = va_getlinearva(ap, struct TagItem *);
191 # return AllocAudioA(
193 # (struct AHIBase *) IAHI->Data.LibBase);