1 ###################################################
2 # Samba4 parser generator for IDL structures
3 # Copyright jelmer@samba.org 2005
4 # released under the GNU GPL
15 $typedefs{$t->{NAME}} = $t;
21 return undef unless(defined($typedefs{$t}));
30 return 1 if (hasType($t) and getType($t)->{DATA}->{TYPE} eq $tt);
37 return 1 if defined($typedefs{$t});
41 sub RegisterPrimitives()
44 "char", "int8", "uint8", "short", "wchar_t",
45 "int16", "uint16", "long", "int32", "uint32",
46 "dlong", "udlong", "udlongr", "NTTIME", "NTTIME_1sec",
47 "time_t", "DATA_BLOB", "error_status_t", "WERROR",
48 "NTSTATUS", "boolean32", "unsigned32", "ipv4address",
49 "hyper", "NTTIME_hyper");
51 foreach my $k (@primitives) {
66 if (util::has_property($enum->{PARENT}, "enum8bit")) {
68 } elsif (util::has_property($enum->{PARENT}, "v1_enum")) {
78 if (util::has_property($bitmap, "bitmap8bit")) {
80 } elsif (util::has_property($bitmap, "bitmap16bit")) {
82 } elsif (util::has_property($bitmap, "bitmap64bit")) {
88 # provide mappings between IDL base types and types in our headers
89 my %scalar_type_mappings =
94 "wchar_t" => "uint16_t",
96 "uint16" => "uint16_t",
98 "uint32" => "uint32_t",
100 "uint64" => "uint64_t",
101 "dlong" => "int64_t",
102 "udlong" => "uint64_t",
103 "udlongr" => "uint64_t",
104 "hyper" => "uint64_t",
105 "NTTIME_1sec" => "NTTIME",
106 "NTTIME_hyper" => "NTTIME",
107 "ipv4address" => "const char *",
108 "nbt_string" => "const char *"
111 # map from a IDL type to a C header type
115 if (my $ret = $scalar_type_mappings{$name}) {
126 return "const char *" if ($e->{TYPE} =~ "string");
128 if ($e->{TYPE} eq "ENUM" or $e->{TYPE} eq "BITMAP") {
129 $dt = getType($e->{PARENT}->{NAME});
132 unless ($dt or $dt = getType($e->{TYPE})) {
134 return "struct $e->{TYPE}";
136 return mapScalarType($e->{TYPE}) if ($dt->{DATA}->{TYPE} eq "SCALAR");
137 return "enum $dt->{NAME}" if ($dt->{DATA}->{TYPE} eq "ENUM");
138 return "struct $dt->{NAME}" if ($dt->{DATA}->{TYPE} eq "STRUCT");
139 return "struct $dt->{NAME}" if ($dt->{DATA}->{TYPE} eq "INTERFACE");
140 return "union $dt->{NAME}" if ($dt->{DATA}->{TYPE} eq "UNION");
141 return mapScalarType(bitmap_type_fn($dt->{DATA})) if ($dt->{DATA}->{TYPE} eq "BITMAP");
143 die("Unknown type $dt->{DATA}->{TYPE}");
150 foreach my $x (@{$idl}) {
151 next if $x->{TYPE} ne "INTERFACE";
153 # DCOM interfaces can be types as well
158 }) if (util::has_property($x, "object"));
160 foreach my $y (@{$x->{DATA}}) {
162 $y->{TYPE} eq "TYPEDEF"
163 or $y->{TYPE} eq "DECLARE");
168 RegisterPrimitives();