r21433: Get rid of the COM support code - it's not used and unmaintained. We can
[Samba/ekacnet.git] / source / pidl / lib / Parse / Pidl / Samba4.pm
blobf0c6ae38e8fcccf6d560f9523c727a832072e383
1 ###################################################
2 # Common Samba4 functions
3 # Copyright jelmer@samba.org 2006
4 # released under the GNU GPL
6 package Parse::Pidl::Samba4;
8 require Exporter;
9 @ISA = qw(Exporter);
10 @EXPORT = qw(is_intree choose_header DeclLong);
12 use Parse::Pidl::Util qw(has_property is_constant);
13 use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
14 use strict;
16 use vars qw($VERSION);
17 $VERSION = '0.01';
19 sub is_intree()
21 return 4 if (-f "kdc/kdc.c");
22 return 3 if (-f "include/smb.h");
23 return 0;
26 # Return an #include line depending on whether this build is an in-tree
27 # build or not.
28 sub choose_header($$)
30 my ($in,$out) = @_;
31 return "#include \"$in\"" if (is_intree());
32 return "#include <$out>";
35 sub DeclLong($)
37 my($element) = shift;
38 my $ret = "";
40 if (has_property($element, "represent_as")) {
41 $ret.=mapTypeName($element->{PROPERTIES}->{represent_as})." ";
42 } else {
43 if (has_property($element, "charset")) {
44 $ret.="const char";
45 } else {
46 $ret.=mapTypeName($element->{TYPE});
49 $ret.=" ";
50 my $numstar = $element->{ORIGINAL}->{POINTERS};
51 if ($numstar >= 1) {
52 $numstar-- if scalar_is_reference($element->{TYPE});
54 foreach (@{$element->{ORIGINAL}->{ARRAY_LEN}})
56 next if is_constant($_) and
57 not has_property($element, "charset");
58 $numstar++;
60 $ret.="*" foreach (1..$numstar);
62 $ret.=$element->{NAME};
63 foreach (@{$element->{ARRAY_LEN}}) {
64 next unless (is_constant($_) and not has_property($element, "charset"));
65 $ret.="[$_]";
68 return $ret;