- Added a new tool winapi_test for generating tests.
[wine] / tools / winapi / c_type.pm
1 #
2 # Copyright 2002 Patrik Stridvall
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 #
18
19 package c_type;
20
21 use strict;
22
23 sub new {
24     my $proto = shift;
25     my $class = ref($proto) || $proto;
26     my $self  = {};
27     bless ($self, $class);
28
29     return $self;
30 }
31
32 sub kind {
33     my $self = shift;
34     my $kind = \${$self->{KIND}};
35
36     local $_ = shift;
37
38     if(defined($_)) { $$kind = $_; }
39
40     return $$kind;
41 }
42
43 sub _name {
44     my $self = shift;
45     my $_name = \${$self->{_NAME}};
46
47     local $_ = shift;
48
49     if(defined($_)) { $$_name = $_; }
50
51     return $$_name;
52 }
53
54 sub name {
55     my $self = shift;
56     my $name = \${$self->{NAME}};
57
58     local $_ = shift;
59
60     if(defined($_)) { $$name = $_; }
61
62     if($$name) {
63         return $$name;
64     } else {
65         my $kind = \${$self->{KIND}};
66         my $_name = \${$self->{_NAME}};
67
68         return "$$kind $$_name";
69     }
70 }
71
72 sub fields {
73     my $self = shift;
74
75     my @field_types = @{$self->field_types};
76     my @field_names = @{$self->field_names};
77
78     my $count = scalar(@field_types);
79     
80     my @fields = ();
81     for (my $n = 0; $n < $count; $n++) {
82         push @fields, [$field_types[$n], $field_names[$n]];
83     }
84     return @fields;
85 }
86
87 sub field_names {
88     my $self = shift;
89     my $field_names = \${$self->{FIELD_NAMES}};
90
91     local $_ = shift;
92
93     if(defined($_)) { $$field_names = $_; }
94
95     return $$field_names;
96 }
97
98 sub field_types {
99     my $self = shift;
100     my $field_types = \${$self->{FIELD_TYPES}};
101
102     local $_ = shift;
103
104     if(defined($_)) { $$field_types = $_; }
105
106     return $$field_types;
107 }
108
109 1;