Author: jelmer Date: 2006-05-13 19:15:31 +0000 (Sat, 13 May 2006) New Revision: 15574
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15574 Log: Keep information about which scalar types are references in a separate data structure Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Typelist.pm Changeset: Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm =================================================================== --- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm 2006-05-13 19:14:12 UTC (rev 15573) +++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm 2006-05-13 19:15:31 UTC (rev 15574) @@ -180,7 +180,7 @@ pidl_code ""; - pidl_code "if(parent_tree) {"; + pidl_code "if (parent_tree) {"; indent; pidl_code "item = proto_tree_add_item(parent_tree, hf_index, tvb, offset, $e->{ALIGN}, TRUE);"; pidl_code "tree = proto_item_add_subtree(item,ett_$ifname\_$name);"; @@ -224,7 +224,7 @@ pidl_code ""; } - pidl_code "if(flags){"; + pidl_code "if (flags) {"; pidl_code "\tproto_item_append_text(item, \"Unknown bitmap value 0x%x\", flags);"; pidl_code "}\n"; pidl_code "return offset;"; @@ -489,7 +489,7 @@ pidl_code "old_offset = offset;"; pidl_code ""; - pidl_code "if(parent_tree){"; + pidl_code "if (parent_tree) {"; indent; pidl_code "item = proto_tree_add_item(parent_tree, hf_index, tvb, offset, -1, TRUE);"; pidl_code "tree = proto_item_add_subtree(item, ett_$ifname\_$name);"; @@ -553,7 +553,7 @@ pidl_code ""; pidl_code "old_offset = offset;"; - pidl_code "if(parent_tree){"; + pidl_code "if (parent_tree) {"; indent; pidl_code "item = proto_tree_add_text(parent_tree, tvb, offset, -1, \"$name\");"; pidl_code "tree = proto_item_add_subtree(item, ett_$ifname\_$name);"; Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Typelist.pm =================================================================== --- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Typelist.pm 2006-05-13 19:14:12 UTC (rev 15573) +++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Typelist.pm 2006-05-13 19:15:31 UTC (rev 15574) @@ -16,130 +16,109 @@ my %typedefs = (); +my @reference_scalars = ( + "string", "string_array", "nbt_string", + "wrepl_nbt_name", "ipv4address" +); + # a list of known scalar types my $scalars = { # 0 byte types "void" => { C_TYPE => "void", - IS_REFERENCE => 0, }, # 1 byte types "char" => { C_TYPE => "char", - IS_REFERENCE => 0, }, "int8" => { C_TYPE => "int8_t", - IS_REFERENCE => 0, }, "uint8" => { C_TYPE => "uint8_t", - IS_REFERENCE => 0, }, # 2 byte types "int16" => { C_TYPE => "int16_t", - IS_REFERENCE => 0, }, "uint16" => { C_TYPE => "uint16_t", - IS_REFERENCE => 0, }, # 4 byte types "int32" => { C_TYPE => "int32_t", - IS_REFERENCE => 0, }, "uint32" => { C_TYPE => "uint32_t", - IS_REFERENCE => 0, }, # 8 byte types "hyper" => { C_TYPE => "uint64_t", - IS_REFERENCE => 0, }, "dlong" => { C_TYPE => "int64_t", - IS_REFERENCE => 0, }, "udlong" => { C_TYPE => "uint64_t", - IS_REFERENCE => 0, }, "udlongr" => { C_TYPE => "uint64_t", - IS_REFERENCE => 0, }, # assume its a 8 byte type, but cope with either "pointer" => { C_TYPE => "void*", - IS_REFERENCE => 0, }, # DATA_BLOB types "DATA_BLOB" => { C_TYPE => "DATA_BLOB", - IS_REFERENCE => 0, }, # string types "string" => { C_TYPE => "const char *", - IS_REFERENCE => 1, }, "string_array" => { C_TYPE => "const char **", - IS_REFERENCE => 1, }, # time types "time_t" => { C_TYPE => "time_t", - IS_REFERENCE => 0, }, "NTTIME" => { C_TYPE => "NTTIME", - IS_REFERENCE => 0, }, "NTTIME_1sec" => { C_TYPE => "NTTIME", - IS_REFERENCE => 0, }, "NTTIME_hyper" => { C_TYPE => "NTTIME", - IS_REFERENCE => 0, }, # error code types "WERROR" => { C_TYPE => "WERROR", - IS_REFERENCE => 0, }, "NTSTATUS" => { C_TYPE => "NTSTATUS", - IS_REFERENCE => 0, }, "COMRESULT" => { C_TYPE => "COMRESULT", - IS_REFERENCE => 0, }, # special types "nbt_string" => { C_TYPE => "const char *", - IS_REFERENCE => 1, }, "wrepl_nbt_name"=> { C_TYPE => "struct nbt_name *", - IS_REFERENCE => 1, }, "ipv4address" => { C_TYPE => "const char *", - IS_REFERENCE => 1, } }; @@ -200,8 +179,8 @@ sub scalar_is_reference($) { my $name = shift; - - return $scalars->{$name}{IS_REFERENCE} if defined($scalars->{$name}) and defined($scalars->{$name}{IS_REFERENCE}); + + return 1 if (grep(/^$name$/, @reference_scalars)); return 0; }