NAME

SystemC::Vregs::Rules - Rules for outputting class headers

SYNOPSIS

    In a I<package>__rules.pl file:

    before_file_body    (replace => 1,
	                 text => "#include \"myinclude.h\"\n",);
    before_enum_begin (  name => qr/_mine$/,
	                 text => "    static const bool  MINE = true\n", );
    after_enum_end (     name => 'Foo',
	                 prog => sub { fprint "   // enum foo\n"; }, );

DESCRIPTION

This package is used to execute Vregs rule files. These files describe execptions and additional text to be included in Vregs outputs.

RULE DECLARATIONS

These functions are used to describe a rule. A rule has a number of rule parameters, generally a name which must match, and a text or prog parameter.

after_file_body

Specifies a rule to be invoked at the bottom of the file.

before_file_body

Specifies a rule to be invoked to produce the #include and other text at the top of the file.

after_class_begin

Specifies a rule to be invoked right after the 'class foo {' line.

before_class_end

Specifies a rule to be invoked right before the '}' ending a class declaration.

after_class_end

Specifies a rule to be invoked right after the '}' ending a class declaration.

after_enum_begin

Specifies a rule to be invoked right after the 'enum foo {' line.

before_enum_end

Specifies a rule to be invoked right before the '}' ending a enum declaration.

after_enum_end

Specifies a rule to be invoked right after the '}' ending a enum declaration.

RULE PARAMETERS

name => 'string' =item name => qr/regexp/

Must be either a string which must match for the rule to be invoked, or a rexexp reference (qr/regexp/) which if matches will invoke the rule.

replace => 1

Generally rules are cumulative, in that defining additional rules will place additional cases to be tested. With the replace flag, the rule will replace all existing rules, including default rules. This is generally useful for replacing the default #include section with the before_file_body rule.

text => 'text'

A text string to output to the file.

prog => sub { subroutine }

A reference to a subroutine that generates the code for the file.

RULE SUBROUTINES

These functions and variables are useful when writing prog=> subroutines.

$self

Reference to a SystemC::Vregs::Enum or SystemC::Vregs::Type, as appropriate. This can be used to get information about the thing to be printed, for example $self->{name} is the name of the object, and $self->{attributes}{foo} checks for a specific attribute.

fprint

Print to the file.

fprintf

Formatted print to the file.

SEE ALSO

vreg, SystemC::Vregs

AUTHORS

Wilson Snyder <wsnyder@wsnyder.org>