1 ###################################################
2 # Common Samba4 functions
3 # Copyright jelmer@samba.org 2006
4 # released under the GNU GPL
6 package Parse::Pidl::Samba4;
10 @EXPORT = qw(is_intree choose_header NumStars ElementStars ArrayBrackets DeclLong);
12 use Parse::Pidl::Util qw(has_property is_constant);
13 use Parse::Pidl::NDR qw(GetNextLevel);
14 use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
15 use Parse::Pidl qw(fatal);
18 use vars qw($VERSION);
23 my $srcdir = $ENV{srcdir};
24 $srcdir = $srcdir ? "$srcdir/" : "";
25 return 4 if (-f "${srcdir}kdc/kdc.c");
26 return 3 if (-f "${srcdir}include/smb.h");
30 # Return an #include line depending on whether this build is an in-tree
35 return "#include \"$in\"" if (is_intree());
36 return "#include <$out>";
42 $d = 0 unless defined($d);
45 foreach my $l (@{$e->{LEVELS}}) {
46 next unless ($l->{TYPE} eq "POINTER");
48 my $nl = GetNextLevel($e, $l);
49 next if (defined($nl) and $nl->{TYPE} eq "ARRAY");
55 $n-- if (scalar_is_reference($e->{TYPE}));
58 foreach my $l (@{$e->{LEVELS}}) {
59 next unless ($l->{TYPE} eq "ARRAY");
60 next if ($l->{IS_FIXED}) and not has_property($e, "charset");
64 fatal($e->{ORIGINAL}, "Too few pointers $n < $d") if ($n < $d);
77 $n = NumStars($e, $d);
78 $res .= "*" foreach (1..$n);
88 foreach my $l (@{$e->{LEVELS}}) {
89 next unless ($l->{TYPE} eq "ARRAY");
90 next unless ($l->{IS_FIXED}) and not has_property($e, "charset");
91 $res .= "[$l->{SIZE_IS}]";
102 if (has_property($e, "represent_as")) {
103 $res .= mapTypeName($e->{PROPERTIES}->{represent_as})." ";
105 if (has_property($e, "charset")) {
106 $res .= "const char ";
108 $res .= mapTypeName($e->{TYPE})." ";
111 $res .= ElementStars($e);
114 $res .= ArrayBrackets($e);