File: Enum.pm

package info (click to toggle)
libextutils-xspp-perl 0.1800-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 992 kB
  • sloc: perl: 8,324; cpp: 125; makefile: 2
file content (78 lines) | stat: -r--r--r-- 1,562 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package ExtUtils::XSpp::Node::Enum;
use strict;
use warnings;
use base 'ExtUtils::XSpp::Node';

=head1 NAME

ExtUtils::XSpp::Node::Enum - Node representing an enum declaration

=head1 DESCRIPTION

An L<ExtUtils::XSpp::Node> subclass representing an C<enum> declaration.
As an example

    enum Bool
    {
        FALSE = 0,
        TRUE
    };

will create an C<ExtUtils::XSpp::Node::Enum> object with C<name>
C<Bool> and two L<ExtUtils::XSpp::Node::EnumValue> values in the
C<arguments> array.

Enumerations do not affect the generated code.

=head1 METHODS

=head2 new

    my $e = ExtUtils::XSpp::Node::Enum->new( name     => 'Bool',
                                             elements => [ ... ],
                                             );

Creates a new C<ExtUtils::XSpp::Node::Enum>.

C<name> gives the name of the enumeration, C<undef> for anonymous
enumerations.  C<elements> should only contain
L<ExtUtils::XSpp::Node::EnumValue> or L<ExtUtils::XSpp::Node::Raw>
objects.

=cut

sub init {
  my $this = shift;
  my %args = @_;

  $this->{NAME}      = $args{name};
  $this->{ELEMENTS}  = $args{elements};
  $this->{CONDITION} = $args{condition};
}

sub print {
  my( $this, $state ) = @_;

  # no standard way of emitting an enum
  ''
}

=head1 ACCESSORS

=head2 name

Returns the name of the enumeration, or C<undef> for anonymous
enumerations.

=head2 elements

An array reference containing mostly
L<ExtUtils::XSpp::Node::EnumValue> (it can contain other kinds of
nodes).

=cut

sub name { $_[0]->{NAME} }
sub elements { $_[0]->{ELEMENTS} }

1;