blob: f0c6ae38e8fcccf6d560f9523c727a832072e383 (
plain)
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
|
###################################################
# Common Samba4 functions
# Copyright jelmer@samba.org 2006
# released under the GNU GPL
package Parse::Pidl::Samba4;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(is_intree choose_header DeclLong);
use Parse::Pidl::Util qw(has_property is_constant);
use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
use strict;
use vars qw($VERSION);
$VERSION = '0.01';
sub is_intree()
{
return 4 if (-f "kdc/kdc.c");
return 3 if (-f "include/smb.h");
return 0;
}
# Return an #include line depending on whether this build is an in-tree
# build or not.
sub choose_header($$)
{
my ($in,$out) = @_;
return "#include \"$in\"" if (is_intree());
return "#include <$out>";
}
sub DeclLong($)
{
my($element) = shift;
my $ret = "";
if (has_property($element, "represent_as")) {
$ret.=mapTypeName($element->{PROPERTIES}->{represent_as})." ";
} else {
if (has_property($element, "charset")) {
$ret.="const char";
} else {
$ret.=mapTypeName($element->{TYPE});
}
$ret.=" ";
my $numstar = $element->{ORIGINAL}->{POINTERS};
if ($numstar >= 1) {
$numstar-- if scalar_is_reference($element->{TYPE});
}
foreach (@{$element->{ORIGINAL}->{ARRAY_LEN}})
{
next if is_constant($_) and
not has_property($element, "charset");
$numstar++;
}
$ret.="*" foreach (1..$numstar);
}
$ret.=$element->{NAME};
foreach (@{$element->{ARRAY_LEN}}) {
next unless (is_constant($_) and not has_property($element, "charset"));
$ret.="[$_]";
}
return $ret;
}
1;
|