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 if not hasType($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 "dlong" => "int64_t",
101 "udlong" => "uint64_t",
102 "udlongr" => "uint64_t",
103 "hyper" => "uint64_t",
104 "NTTIME" => "NTTIME",
105 "NTTIME_1sec" => "NTTIME",
106 "time_t" => "time_t",
107 "NTTIME_hyper" => "NTTIME",
108 "NTSTATUS" => "NTSTATUS",
109 "WERROR" => "WERROR",
110 "DATA_BLOB" => "DATA_BLOB",
111 "ipv4address" => "const char *",
112 "nbt_string" => "const char *"
115 # map from a IDL type to a C header type
119 die("Undef passed to mapScalarType") unless defined($name);
120 if (defined($scalar_type_mappings{$name})) {
121 return $scalar_type_mappings{$name};
123 die("Tried to map non-scalar type $name");
129 die("Undef passed to mapType") unless defined($t);
132 return "void" if ($t eq "void");
133 return "const char *" if ($t =~ "string");
135 unless ($dt or ($dt = getType($t))) {
139 return mapScalarType($t) if ($dt->{DATA}->{TYPE} eq "SCALAR");
140 return "enum $dt->{NAME}" if ($dt->{DATA}->{TYPE} eq "ENUM");
141 return "struct $dt->{NAME}" if ($dt->{DATA}->{TYPE} eq "STRUCT");
142 return "struct $dt->{NAME}" if ($dt->{DATA}->{TYPE} eq "INTERFACE");
143 return "union $dt->{NAME}" if ($dt->{DATA}->{TYPE} eq "UNION");
145 if ($dt->{DATA}->{TYPE} eq "BITMAP") {
146 return mapScalarType(bitmap_type_fn($dt->{DATA}));
149 die("Unknown type $dt->{DATA}->{TYPE}");
156 foreach my $x (@{$idl}) {
157 next if $x->{TYPE} ne "INTERFACE";
159 # DCOM interfaces can be types as well
164 }) if (util::has_property($x, "object"));
166 foreach my $y (@{$x->{DATA}}) {
168 $y->{TYPE} eq "TYPEDEF"
169 or $y->{TYPE} eq "DECLARE");
174 RegisterPrimitives();