winapi: Simplify and improve the readability of the C parsers.
Specifically, clean up parameter passing, and remove unneeded intermediate variable references. Remove uninformative comments.
This commit is contained in:
parent
df055b2d2c
commit
a4ed46d398
|
@ -22,7 +22,7 @@ use strict;
|
||||||
|
|
||||||
sub new($)
|
sub new($)
|
||||||
{
|
{
|
||||||
my $proto = shift;
|
my ($proto) = @_;
|
||||||
my $class = ref($proto) || $proto;
|
my $class = ref($proto) || $proto;
|
||||||
my $self = {};
|
my $self = {};
|
||||||
bless ($self, $class);
|
bless ($self, $class);
|
||||||
|
@ -37,170 +37,100 @@ sub new($)
|
||||||
|
|
||||||
sub file($;$)
|
sub file($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $filename) = @_;
|
||||||
my $file = \${$self->{FILE}};
|
$self->{file} = $filename if (defined $filename);
|
||||||
|
return $self->{file};
|
||||||
local $_ = shift;
|
|
||||||
|
|
||||||
if(defined($_)) { $$file = $_; }
|
|
||||||
|
|
||||||
return $$file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub begin_line($;$)
|
sub begin_line($$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $begin_line) = @_;
|
||||||
my $begin_line = \${$self->{BEGIN_LINE}};
|
$self->{begin_line} = $begin_line if (defined $begin_line);
|
||||||
|
return $self->{begin_line};
|
||||||
local $_ = shift;
|
|
||||||
|
|
||||||
if(defined($_)) { $$begin_line = $_; }
|
|
||||||
|
|
||||||
return $$begin_line;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub begin_column($;$)
|
sub begin_column($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $begin_column) = @_;
|
||||||
my $begin_column = \${$self->{BEGIN_COLUMN}};
|
$self->{begin_column} = $begin_column if (defined $begin_column);
|
||||||
|
return $self->{begin_column};
|
||||||
local $_ = shift;
|
|
||||||
|
|
||||||
if(defined($_)) { $$begin_column = $_; }
|
|
||||||
|
|
||||||
return $$begin_column;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub end_line($;$)
|
sub end_line($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $end_line) = @_;
|
||||||
my $end_line = \${$self->{END_LINE}};
|
$self->{end_line} = $end_line if (defined $end_line);
|
||||||
|
return $self->{end_line};
|
||||||
local $_ = shift;
|
|
||||||
|
|
||||||
if(defined($_)) { $$end_line = $_; }
|
|
||||||
|
|
||||||
return $$end_line;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub end_column($;$)
|
sub end_column($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $end_column) = @_;
|
||||||
my $end_column = \${$self->{END_COLUMN}};
|
$self->{end_column} = $end_column if (defined $end_column);
|
||||||
|
return $self->{end_column};
|
||||||
local $_ = shift;
|
|
||||||
|
|
||||||
if(defined($_)) { $$end_column = $_; }
|
|
||||||
|
|
||||||
return $$end_column;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub linkage($;$)
|
sub linkage($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $linkage) = @_;
|
||||||
my $linkage = \${$self->{LINKAGE}};
|
$self->{linkage} = $linkage if (defined $linkage);
|
||||||
|
return $self->{linkage};
|
||||||
local $_ = shift;
|
|
||||||
|
|
||||||
if(defined($_)) { $$linkage = $_; }
|
|
||||||
|
|
||||||
return $$linkage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub return_type($;$)
|
sub return_type($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $return_type) = @_;
|
||||||
my $return_type = \${$self->{RETURN_TYPE}};
|
$self->{return_type} = $return_type if (defined $return_type);
|
||||||
|
return $self->{return_type};
|
||||||
local $_ = shift;
|
|
||||||
|
|
||||||
if(defined($_)) { $$return_type = $_; }
|
|
||||||
|
|
||||||
return $$return_type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub calling_convention($;$)
|
sub calling_convention($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $calling_convention) = @_;
|
||||||
my $calling_convention = \${$self->{CALLING_CONVENTION}};
|
$self->{calling_convention} = $calling_convention if (defined $calling_convention);
|
||||||
|
return $self->{calling_convention};
|
||||||
local $_ = shift;
|
|
||||||
|
|
||||||
if(defined($_)) { $$calling_convention = $_; }
|
|
||||||
|
|
||||||
return $$calling_convention;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub name($;$)
|
sub name($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $name) = @_;
|
||||||
my $name = \${$self->{NAME}};
|
$self->{name} = $name if (defined $name);
|
||||||
|
return $self->{name};
|
||||||
local $_ = shift;
|
|
||||||
|
|
||||||
if(defined($_)) { $$name = $_; }
|
|
||||||
|
|
||||||
return $$name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub argument_types($;$)
|
sub argument_types($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $argument_types) = @_;
|
||||||
my $argument_types = \${$self->{ARGUMENT_TYPES}};
|
$self->{argument_types} = $argument_types if (defined $argument_types);
|
||||||
|
return $self->{argument_types};
|
||||||
local $_ = shift;
|
|
||||||
|
|
||||||
if(defined($_)) { $$argument_types = $_; }
|
|
||||||
|
|
||||||
return $$argument_types;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub argument_names($;$)
|
sub argument_names($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $argument_names) = @_;
|
||||||
my $argument_names = \${$self->{ARGUMENT_NAMES}};
|
$self->{argument_names} = $argument_names if (defined $argument_names);
|
||||||
|
return $self->{argument_names};
|
||||||
local $_ = shift;
|
|
||||||
|
|
||||||
if(defined($_)) { $$argument_names = $_; }
|
|
||||||
|
|
||||||
return $$argument_names;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub statements_line($;$)
|
sub statements_line($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $statements_line) = @_;
|
||||||
my $statements_line = \${$self->{STATEMENTS_LINE}};
|
$self->{statements_line} = $statements_line if (defined $statements_line);
|
||||||
|
return $self->{statements_line};
|
||||||
local $_ = shift;
|
|
||||||
|
|
||||||
if(defined($_)) { $$statements_line = $_; }
|
|
||||||
|
|
||||||
return $$statements_line;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub statements_column($;$)
|
sub statements_column($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $statements_column) = @_;
|
||||||
my $statements_column = \${$self->{STATEMENTS_COLUMN}};
|
$self->{statements_column} = $statements_column if (defined $statements_column);
|
||||||
|
return $self->{statements_column};
|
||||||
local $_ = shift;
|
|
||||||
|
|
||||||
if(defined($_)) { $$statements_column = $_; }
|
|
||||||
|
|
||||||
return $$statements_column;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub statements($;$)
|
sub statements($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $statements) = @_;
|
||||||
my $statements = \${$self->{STATEMENTS}};
|
$self->{statements} = $statements if (defined $statements);
|
||||||
|
return $self->{statements};
|
||||||
local $_ = shift;
|
|
||||||
|
|
||||||
if(defined($_)) { $$statements = $_; }
|
|
||||||
|
|
||||||
return $$statements;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -50,155 +50,96 @@ sub parse_c_typedef($$$$);
|
||||||
sub parse_c_variable($$$$$$$);
|
sub parse_c_variable($$$$$$$);
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
sub new($$)
|
||||||
# new
|
{
|
||||||
#
|
my ($proto, $filename) = @_;
|
||||||
sub new($$) {
|
|
||||||
my $proto = shift;
|
|
||||||
my $class = ref($proto) || $proto;
|
my $class = ref($proto) || $proto;
|
||||||
my $self = {};
|
my $self = {FILE => $filename,
|
||||||
|
CREATE_FUNCTION => sub { return new c_function; },
|
||||||
|
CREATE_TYPE => sub { return new c_type; },
|
||||||
|
FOUND_COMMENT => sub { return 1; },
|
||||||
|
FOUND_DECLARATION => sub { return 1; },
|
||||||
|
FOUND_FUNCTION => sub { return 1; },
|
||||||
|
FOUND_FUNCTION_CALL => sub { return 1; },
|
||||||
|
FOUND_LINE => sub { return 1; },
|
||||||
|
FOUND_PREPROCESSOR => sub { return 1; },
|
||||||
|
FOUND_STATEMENT => sub { return 1; },
|
||||||
|
FOUND_TYPE => sub { return 1; },
|
||||||
|
FOUND_VARIABLE => sub { return 1; }
|
||||||
|
};
|
||||||
bless ($self, $class);
|
bless ($self, $class);
|
||||||
|
|
||||||
my $file = \${$self->{FILE}};
|
|
||||||
my $create_function = \${$self->{CREATE_FUNCTION}};
|
|
||||||
my $create_type = \${$self->{CREATE_TYPE}};
|
|
||||||
my $found_comment = \${$self->{FOUND_COMMENT}};
|
|
||||||
my $found_declaration = \${$self->{FOUND_DECLARATION}};
|
|
||||||
my $found_function = \${$self->{FOUND_FUNCTION}};
|
|
||||||
my $found_function_call = \${$self->{FOUND_FUNCTION_CALL}};
|
|
||||||
my $found_line = \${$self->{FOUND_LINE}};
|
|
||||||
my $found_preprocessor = \${$self->{FOUND_PREPROCESSOR}};
|
|
||||||
my $found_statement = \${$self->{FOUND_STATEMENT}};
|
|
||||||
my $found_type = \${$self->{FOUND_TYPE}};
|
|
||||||
my $found_variable = \${$self->{FOUND_VARIABLE}};
|
|
||||||
|
|
||||||
$$file = shift;
|
|
||||||
|
|
||||||
$$create_function = sub { return new c_function; };
|
|
||||||
$$create_type = sub { return new c_type; };
|
|
||||||
$$found_comment = sub { return 1; };
|
|
||||||
$$found_declaration = sub { return 1; };
|
|
||||||
$$found_function = sub { return 1; };
|
|
||||||
$$found_function_call = sub { return 1; };
|
|
||||||
$$found_line = sub { return 1; };
|
|
||||||
$$found_preprocessor = sub { return 1; };
|
|
||||||
$$found_statement = sub { return 1; };
|
|
||||||
$$found_type = sub { return 1; };
|
|
||||||
$$found_variable = sub { return 1; };
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# set_found_comment_callback
|
#
|
||||||
|
# Callback setters
|
||||||
#
|
#
|
||||||
sub set_found_comment_callback($$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $found_comment = \${$self->{FOUND_COMMENT}};
|
sub set_found_comment_callback($$)
|
||||||
|
{
|
||||||
$$found_comment = shift;
|
my ($self, $found_comment) = @_;
|
||||||
|
$self->{FOUND_COMMENT} = $found_comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub set_found_declaration_callback($$)
|
||||||
# set_found_declaration_callback
|
{
|
||||||
#
|
my ($self, $found_declaration) = @_;
|
||||||
sub set_found_declaration_callback($$) {
|
$self->{FOUND_DEClARATION} = $found_declaration;
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $found_declaration = \${$self->{FOUND_DECLARATION}};
|
|
||||||
|
|
||||||
$$found_declaration = shift;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub set_found_function_callback($$)
|
||||||
# set_found_function_callback
|
{
|
||||||
#
|
my ($self, $found_function) = @_;
|
||||||
sub set_found_function_callback($$) {
|
$self->{FOUND_FUNCTION} = $found_function;
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $found_function = \${$self->{FOUND_FUNCTION}};
|
|
||||||
|
|
||||||
$$found_function = shift;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub set_found_function_call_callback($$)
|
||||||
# set_found_function_call_callback
|
{
|
||||||
#
|
my ($self, $found_function_call) = @_;
|
||||||
sub set_found_function_call_callback($$) {
|
$self->{FOUND_FUNCTION_CALL} = $found_function_call;
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $found_function_call = \${$self->{FOUND_FUNCTION_CALL}};
|
|
||||||
|
|
||||||
$$found_function_call = shift;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub set_found_line_callback($$)
|
||||||
# set_found_line_callback
|
{
|
||||||
#
|
my ($self, $found_line) = @_;
|
||||||
sub set_found_line_callback($$) {
|
$self->{FOUND_LINE} = $found_line;
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $found_line = \${$self->{FOUND_LINE}};
|
|
||||||
|
|
||||||
$$found_line = shift;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub set_found_preprocessor_callback($$)
|
||||||
# set_found_preprocessor_callback
|
{
|
||||||
#
|
my ($self, $found_preprocessor) = @_;
|
||||||
sub set_found_preprocessor_callback($$) {
|
$self->{FOUND_PREPROCESSOR} = $found_preprocessor;
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $found_preprocessor = \${$self->{FOUND_PREPROCESSOR}};
|
|
||||||
|
|
||||||
$$found_preprocessor = shift;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub set_found_statement_callback($$)
|
||||||
# set_found_statement_callback
|
{
|
||||||
#
|
my ($self, $found_statement) = @_;
|
||||||
sub set_found_statement_callback($$) {
|
$self->{FOUND_STATEMENT} = $found_statement;
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $found_statement = \${$self->{FOUND_STATEMENT}};
|
|
||||||
|
|
||||||
$$found_statement = shift;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub set_found_type_callback($$)
|
||||||
# set_found_type_callback
|
{
|
||||||
#
|
my ($self, $found_type) = @_;
|
||||||
sub set_found_type_callback($$) {
|
$self->{FOUND_TYPE} = $found_type;
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $found_type = \${$self->{FOUND_TYPE}};
|
|
||||||
|
|
||||||
$$found_type = shift;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub set_found_variable_callback($$)
|
||||||
# set_found_variable_callback
|
{
|
||||||
#
|
my ($self, $found_variable) = @_;
|
||||||
sub set_found_variable_callback($$) {
|
$self->{FOUND_VARIABLE} = $found_variable;
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $found_variable = \${$self->{FOUND_VARIABLE}};
|
|
||||||
|
|
||||||
$$found_variable = shift;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# _format_c_type
|
# _format_c_type
|
||||||
|
sub _format_c_type($$)
|
||||||
|
{
|
||||||
|
my ($self, $type) = @_;
|
||||||
|
|
||||||
sub _format_c_type($$) {
|
$type =~ s/^\s*(.*?)\s*$/$1/;
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
local $_ = shift;
|
if ($type =~ /^(\w+(?:\s*\*)*)\s*\(\s*\*\s*\)\s*\(\s*(.*?)\s*\)$/s) {
|
||||||
s/^\s*(.*?)\s*$/$1/;
|
|
||||||
|
|
||||||
if (/^(\w+(?:\s*\*)*)\s*\(\s*\*\s*\)\s*\(\s*(.*?)\s*\)$/s) {
|
|
||||||
my $return_type = $1;
|
my $return_type = $1;
|
||||||
my @arguments = split(/\s*,\s*/, $2);
|
my @arguments = split(/\s*,\s*/, $2);
|
||||||
foreach my $argument (@arguments) {
|
foreach my $argument (@arguments) {
|
||||||
|
@ -209,10 +150,10 @@ sub _format_c_type($$) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$_ = "$return_type (*)(" . join(", ", @arguments) . ")";
|
$type = "$return_type (*)(" . join(", ", @arguments) . ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_;
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -220,46 +161,33 @@ sub _format_c_type($$) {
|
||||||
# _parse_c_warning
|
# _parse_c_warning
|
||||||
#
|
#
|
||||||
# FIXME: Use caller (See man perlfunc)
|
# FIXME: Use caller (See man perlfunc)
|
||||||
|
sub _parse_c_warning($$$$$$)
|
||||||
sub _parse_c_warning($$$$$$) {
|
{
|
||||||
my $self = shift;
|
my ($self, $curlines, $line, $column, $context, $message) = @_;
|
||||||
|
|
||||||
local $_ = shift;
|
|
||||||
my $line = shift;
|
|
||||||
my $column = shift;
|
|
||||||
my $context = shift;
|
|
||||||
my $message = shift;
|
|
||||||
|
|
||||||
my $file = \${$self->{FILE}};
|
|
||||||
|
|
||||||
$message = "warning" if !$message;
|
$message = "warning" if !$message;
|
||||||
|
|
||||||
my $current = "";
|
my $current = "";
|
||||||
if($_) {
|
if ($curlines) {
|
||||||
my @lines = split(/\n/, $_);
|
my @lines = split(/\n/, $curlines);
|
||||||
|
|
||||||
$current .= $lines[0] . "\n" if $lines[0];
|
$current .= $lines[0] . "\n" if $lines[0];
|
||||||
$current .= $lines[1] . "\n" if $lines[1];
|
$current .= $lines[1] . "\n" if $lines[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($current) {
|
if($current) {
|
||||||
$output->write("$$file:$line." . ($column + 1) . ": $context: $message: \\\n$current");
|
$output->write("$self->{FILE}:$line." . ($column + 1) . ": $context: $message: \\\n$current");
|
||||||
} else {
|
} else {
|
||||||
$output->write("$$file:$line." . ($column + 1) . ": $context: $message\n");
|
$output->write("$self->{FILE}:$line." . ($column + 1) . ": $context: $message\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# _parse_c_error
|
# _parse_c_error
|
||||||
|
|
||||||
sub _parse_c_error($$$$$$) {
|
sub _parse_c_error($$$$$$)
|
||||||
my $self = shift;
|
{
|
||||||
|
my ($self, $curlines, $line, $column, $context, $message) = @_;
|
||||||
local $_ = shift;
|
|
||||||
my $line = shift;
|
|
||||||
my $column = shift;
|
|
||||||
my $context = shift;
|
|
||||||
my $message = shift;
|
|
||||||
|
|
||||||
$message = "parse error" if !$message;
|
$message = "parse error" if !$message;
|
||||||
|
|
||||||
|
@ -269,7 +197,7 @@ sub _parse_c_error($$$$$$) {
|
||||||
$output->prefix("");
|
$output->prefix("");
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->_parse_c_warning($_, $line, $column, $context, $message);
|
$self->_parse_c_warning($curlines, $line, $column, $context, $message);
|
||||||
|
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
@ -277,59 +205,72 @@ sub _parse_c_error($$$$$$) {
|
||||||
########################################################################
|
########################################################################
|
||||||
# _update_c_position
|
# _update_c_position
|
||||||
|
|
||||||
sub _update_c_position($$$$) {
|
sub _update_c_position($$$$)
|
||||||
my $self = shift;
|
{
|
||||||
|
my ($self, $source, $refline, $refcolumn) = @_;
|
||||||
local $_ = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
my $column = $$refcolumn;
|
my $column = $$refcolumn;
|
||||||
|
|
||||||
while($_) {
|
while ($source)
|
||||||
if(s/^[^\n\t\'\"]*//s) {
|
{
|
||||||
|
if ($source =~ s/^[^\n\t\'\"]*//s)
|
||||||
|
{
|
||||||
$column += length($&);
|
$column += length($&);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s/^\'//) {
|
if ($source =~ s/^\'//)
|
||||||
|
{
|
||||||
$column++;
|
$column++;
|
||||||
while(/^./ && !s/^\'//) {
|
while ($source =~ /^./ && $source !~ s/^\'//)
|
||||||
s/^([^\'\\]*)//s;
|
{
|
||||||
|
$source =~ s/^([^\'\\]*)//s;
|
||||||
$column += length($1);
|
$column += length($1);
|
||||||
if(s/^\\//) {
|
if ($source =~ s/^\\//)
|
||||||
|
{
|
||||||
$column++;
|
$column++;
|
||||||
if(s/^(.)//s) {
|
if ($source =~ s/^(.)//s)
|
||||||
|
{
|
||||||
$column += length($1);
|
$column += length($1);
|
||||||
if($1 eq "0") {
|
if ($1 eq "0")
|
||||||
s/^(\d{0,3})//s;
|
{
|
||||||
|
$source =~ s/^(\d{0,3})//s;
|
||||||
$column += length($1);
|
$column += length($1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$column++;
|
$column++;
|
||||||
} elsif(s/^\"//) {
|
}
|
||||||
|
elsif ($source =~ s/^\"//)
|
||||||
|
{
|
||||||
$column++;
|
$column++;
|
||||||
while(/^./ && !s/^\"//) {
|
while ($source =~ /^./ && $source !~ s/^\"//)
|
||||||
s/^([^\"\\]*)//s;
|
{
|
||||||
|
$source =~ s/^([^\"\\]*)//s;
|
||||||
$column += length($1);
|
$column += length($1);
|
||||||
if(s/^\\//) {
|
if ($source =~ s/^\\//)
|
||||||
|
{
|
||||||
$column++;
|
$column++;
|
||||||
if(s/^(.)//s) {
|
if ($source =~ s/^(.)//s)
|
||||||
|
{
|
||||||
$column += length($1);
|
$column += length($1);
|
||||||
if($1 eq "0") {
|
if ($1 eq "0")
|
||||||
s/^(\d{0,3})//s;
|
{
|
||||||
|
$source =~ s/^(\d{0,3})//s;
|
||||||
$column += length($1);
|
$column += length($1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$column++;
|
$column++;
|
||||||
} elsif(s/^\n//) {
|
}
|
||||||
|
elsif ($source =~ s/^\n//)
|
||||||
|
{
|
||||||
$line++;
|
$line++;
|
||||||
$column = 0;
|
$column = 0;
|
||||||
} elsif(s/^\t//) {
|
}
|
||||||
|
elsif ($source =~ s/^\t//)
|
||||||
|
{
|
||||||
$column = $column + 8 - $column % 8;
|
$column = $column + 8 - $column % 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -461,33 +402,15 @@ sub __parse_c_until_one_of($$$$$$$) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub _parse_c_until_one_of($$$$$$)
|
||||||
# _parse_c_until_one_of
|
{
|
||||||
|
my ($self, $characters, $refcurrent, $refline, $refcolumn, $match) = @_;
|
||||||
sub _parse_c_until_one_of($$$$$$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $characters = shift;
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
my $match = shift;
|
|
||||||
|
|
||||||
return $self->__parse_c_until_one_of($characters, 0, $refcurrent, $refline, $refcolumn, $match);
|
return $self->__parse_c_until_one_of($characters, 0, $refcurrent, $refline, $refcolumn, $match);
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub _parse_c_on_same_level_until_one_of($$$$$$)
|
||||||
# _parse_c_on_same_level_until_one_of
|
{
|
||||||
|
my ($self, $characters, $refcurrent, $refline, $refcolumn, $match) = @_;
|
||||||
sub _parse_c_on_same_level_until_one_of($$$$$$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $characters = shift;
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
my $match = shift;
|
|
||||||
|
|
||||||
return $self->__parse_c_until_one_of($characters, 1, $refcurrent, $refline, $refcolumn, $match);
|
return $self->__parse_c_until_one_of($characters, 1, $refcurrent, $refline, $refcolumn, $match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,16 +478,10 @@ sub parse_c_block($$$$$$$) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# parse_c_declaration
|
|
||||||
|
|
||||||
sub parse_c_declaration($$$$)
|
sub parse_c_declaration($$$$)
|
||||||
{
|
{
|
||||||
my ($self, $refcurrent, $refline, $refcolumn) = @_;
|
my ($self, $refcurrent, $refline, $refcolumn) = @_;
|
||||||
|
|
||||||
my $found_declaration = \${$self->{FOUND_DECLARATION}};
|
|
||||||
my $found_function = \${$self->{FOUND_FUNCTION}};
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
my $column = $$refcolumn;
|
my $column = $$refcolumn;
|
||||||
|
@ -578,7 +495,7 @@ sub parse_c_declaration($$$$)
|
||||||
my $end_column = $begin_column;
|
my $end_column = $begin_column;
|
||||||
$self->_update_c_position($_, \$end_line, \$end_column);
|
$self->_update_c_position($_, \$end_line, \$end_column);
|
||||||
|
|
||||||
if(!&$$found_declaration($begin_line, $begin_column, $end_line, $end_column, $_)) {
|
if(!$self->{FOUND_DECLARATION}($begin_line, $begin_column, $end_line, $end_column, $_)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,7 +540,7 @@ sub parse_c_declaration($$$$)
|
||||||
} elsif($self->parse_c_variable(\$_, \$line, \$column, \$linkage, \$type, \$name)) {
|
} elsif($self->parse_c_variable(\$_, \$line, \$column, \$linkage, \$type, \$name)) {
|
||||||
# Nothing
|
# Nothing
|
||||||
} elsif($self->parse_c_function(\$_, \$line, \$column, \$function)) {
|
} elsif($self->parse_c_function(\$_, \$line, \$column, \$function)) {
|
||||||
if(&$$found_function($function))
|
if($self->{FOUND_FUNCTION}($function))
|
||||||
{
|
{
|
||||||
my $statements = $function->statements;
|
my $statements = $function->statements;
|
||||||
my $statements_line = $function->statements_line;
|
my $statements_line = $function->statements_line;
|
||||||
|
@ -646,18 +563,9 @@ sub parse_c_declaration($$$$)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub _parse_c($$$$$$)
|
||||||
# _parse_c
|
{
|
||||||
|
my ($self, $pattern, $refcurrent, $refline, $refcolumn, $refmatch) = @_;
|
||||||
sub _parse_c($$$$$$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $pattern = shift;
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
my $refmatch = shift;
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
|
@ -682,15 +590,9 @@ sub _parse_c($$$$$$) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub parse_c_enum($$$$)
|
||||||
# parse_c_enum
|
{
|
||||||
|
my ($self, $refcurrent, $refline, $refcolumn) = @_;
|
||||||
sub parse_c_enum($$$$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
|
@ -755,18 +657,9 @@ sub parse_c_enum($$$$) {
|
||||||
$$refcolumn = $column;
|
$$refcolumn = $column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub parse_c_expression($$$$)
|
||||||
########################################################################
|
{
|
||||||
# parse_c_expression
|
my ($self, $refcurrent, $refline, $refcolumn) = @_;
|
||||||
|
|
||||||
sub parse_c_expression($$$$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
my $found_function_call = \${$self->{FOUND_FUNCTION_CALL}};
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
|
@ -789,7 +682,7 @@ sub parse_c_expression($$$$) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(&$$found_function_call($begin_line, $begin_column, $line, $column, $name, \@arguments))
|
if($self->{FOUND_FUNCTION_CALL}($begin_line, $begin_column, $line, $column, $name, \@arguments))
|
||||||
{
|
{
|
||||||
while(defined(my $argument = shift @arguments) &&
|
while(defined(my $argument = shift @arguments) &&
|
||||||
defined(my $argument_line = shift @argument_lines) &&
|
defined(my $argument_line = shift @argument_lines) &&
|
||||||
|
@ -812,18 +705,9 @@ sub parse_c_expression($$$$) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub parse_c_file($$$$)
|
||||||
# parse_c_file
|
{
|
||||||
|
my ($self, $refcurrent, $refline, $refcolumn) = @_;
|
||||||
sub parse_c_file($$$$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $found_comment = \${$self->{FOUND_COMMENT}};
|
|
||||||
my $found_line = \${$self->{FOUND_LINE}};
|
|
||||||
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
|
@ -848,9 +732,9 @@ sub parse_c_file($$$$) {
|
||||||
$self->_parse_c_until_one_of("#/\\(\\)\\[\\]\\{\\};", \$_, \$line, \$column, \$match);
|
$self->_parse_c_until_one_of("#/\\(\\)\\[\\]\\{\\};", \$_, \$line, \$column, \$match);
|
||||||
|
|
||||||
if($line != $previous_line) {
|
if($line != $previous_line) {
|
||||||
&$$found_line($line);
|
$self->{FOUND_LINE}($line);
|
||||||
} else {
|
} else {
|
||||||
# &$$found_line("$line.$column");
|
# $self->{FOUND_LINE}("$line.$column");
|
||||||
}
|
}
|
||||||
$previous_line = $line;
|
$previous_line = $line;
|
||||||
$previous_column = $column;
|
$previous_column = $column;
|
||||||
|
@ -1002,7 +886,7 @@ sub parse_c_file($$$$) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s/^\/\*.*?\*\///s) {
|
if(s/^\/\*.*?\*\///s) {
|
||||||
&$$found_comment($line, $column + 1, $&);
|
$self->{FOUND_COMMENT}($line, $column + 1, $&);
|
||||||
local $_ = $&;
|
local $_ = $&;
|
||||||
while(s/^.*?\n//) {
|
while(s/^.*?\n//) {
|
||||||
$blank_lines++;
|
$blank_lines++;
|
||||||
|
@ -1011,7 +895,7 @@ sub parse_c_file($$$$) {
|
||||||
$column += length($_);
|
$column += length($_);
|
||||||
}
|
}
|
||||||
} elsif(s/^\/\/(.*?)\n//) {
|
} elsif(s/^\/\/(.*?)\n//) {
|
||||||
&$$found_comment($line, $column + 1, $&);
|
$self->{FOUND_COMMENT}($line, $column + 1, $&);
|
||||||
$blank_lines++;
|
$blank_lines++;
|
||||||
} elsif(s/^\///) {
|
} elsif(s/^\///) {
|
||||||
if(!$if0) {
|
if(!$if0) {
|
||||||
|
@ -1116,20 +1000,9 @@ sub parse_c_file($$$$) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub parse_c_function($$$$$)
|
||||||
# parse_c_function
|
{
|
||||||
|
my ($self, $refcurrent, $refline, $refcolumn, $reffunction) = @_;
|
||||||
sub parse_c_function($$$$$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $file = \${$self->{FILE}};
|
|
||||||
my $create_function = \${$self->{CREATE_FUNCTION}};
|
|
||||||
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
my $reffunction = shift;
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
|
@ -1236,9 +1109,9 @@ sub parse_c_function($$$$$) {
|
||||||
$$refline = $line;
|
$$refline = $line;
|
||||||
$$refcolumn = $column;
|
$$refcolumn = $column;
|
||||||
|
|
||||||
my $function = &$$create_function;
|
my $function = $self->{CREATE_FUNCTION}();
|
||||||
|
|
||||||
$function->file($$file);
|
$function->file($self->{FILE});
|
||||||
$function->begin_line($begin_line);
|
$function->begin_line($begin_line);
|
||||||
$function->begin_column($begin_column);
|
$function->begin_column($begin_column);
|
||||||
$function->end_line($end_line);
|
$function->end_line($end_line);
|
||||||
|
@ -1262,20 +1135,9 @@ sub parse_c_function($$$$$) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub parse_c_function_call($$$$$$$$)
|
||||||
# parse_c_function_call
|
{
|
||||||
|
my ($self, $refcurrent, $refline, $refcolumn, $refname, $refarguments, $refargument_lines, $refargument_columns) = @_;
|
||||||
sub parse_c_function_call($$$$$$$$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
my $refname = shift;
|
|
||||||
my $refarguments = shift;
|
|
||||||
my $refargument_lines = shift;
|
|
||||||
my $refargument_columns = shift;
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
|
@ -1310,17 +1172,10 @@ sub parse_c_function_call($$$$$$$$) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# parse_c_preprocessor
|
|
||||||
|
|
||||||
sub parse_c_preprocessor($$$$) {
|
sub parse_c_preprocessor($$$$)
|
||||||
my $self = shift;
|
{
|
||||||
|
my ($self, $refcurrent, $refline, $refcolumn) = @_;
|
||||||
my $found_preprocessor = \${$self->{FOUND_PREPROCESSOR}};
|
|
||||||
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
|
@ -1331,7 +1186,7 @@ sub parse_c_preprocessor($$$$) {
|
||||||
my $begin_line = $line;
|
my $begin_line = $line;
|
||||||
my $begin_column = $column + 1;
|
my $begin_column = $column + 1;
|
||||||
|
|
||||||
if(!&$$found_preprocessor($begin_line, $begin_column, "$_")) {
|
if(!$self->{FOUND_PREPROCESSOR}($begin_line, $begin_column, "$_")) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1358,17 +1213,9 @@ sub parse_c_preprocessor($$$$) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub parse_c_statement($$$$)
|
||||||
# parse_c_statement
|
{
|
||||||
|
my ($self, $refcurrent, $refline, $refcolumn) = @_;
|
||||||
sub parse_c_statement($$$$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
my $found_function_call = \${$self->{FOUND_FUNCTION_CALL}};
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
|
@ -1442,17 +1289,9 @@ sub parse_c_statement($$$$) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub parse_c_statements($$$$)
|
||||||
# parse_c_statements
|
{
|
||||||
|
my ($self, $refcurrent, $refline, $refcolumn) = @_;
|
||||||
sub parse_c_statements($$$$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
my $found_function_call = \${$self->{FOUND_FUNCTION_CALL}};
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
|
@ -1539,21 +1378,9 @@ sub parse_c_statements($$$$) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub parse_c_struct_union($$$$$$$$$)
|
||||||
# parse_c_struct_union
|
{
|
||||||
|
my ($self, $refcurrent, $refline, $refcolumn, $refkind, $ref_name, $reffield_type_names, $reffield_names, $refnames) = @_;
|
||||||
sub parse_c_struct_union($$$$$$$$$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
my $refkind = shift;
|
|
||||||
my $ref_name = shift;
|
|
||||||
my $reffield_type_names = shift;
|
|
||||||
my $reffield_names = shift;
|
|
||||||
my $refnames = shift;
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
|
@ -1567,15 +1394,13 @@ sub parse_c_struct_union($$$$$$$$$) {
|
||||||
|
|
||||||
$self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
|
$self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
|
||||||
|
|
||||||
if (!s/^(interface\s+|struct\s+|union\s+)((?:MSVCRT|WS)\(\s*\w+\s*\)|\w+)?\s*\{\s*//s) {
|
if (!s/^(interface|struct|union)\s+((?:MSVCRT|WS)\(\s*\w+\s*\)|\w+)?\s*\{\s*//s) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$kind = $1;
|
$kind = $1;
|
||||||
$_name = $2 || "";
|
$_name = $2 || "";
|
||||||
|
|
||||||
$self->_update_c_position($&, \$line, \$column);
|
$self->_update_c_position($&, \$line, \$column);
|
||||||
|
|
||||||
$kind =~ s/\s+//g;
|
|
||||||
|
|
||||||
my $match;
|
my $match;
|
||||||
while ($_ && $self->_parse_c_on_same_level_until_one_of(';', \$_, \$line, \$column, \$match))
|
while ($_ && $self->_parse_c_on_same_level_until_one_of(';', \$_, \$line, \$column, \$match))
|
||||||
|
@ -1637,20 +1462,11 @@ sub parse_c_struct_union($$$$$$$$$) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub parse_c_tuple($$$$$$$)
|
||||||
# parse_c_tuple
|
{
|
||||||
|
my ($self, $refcurrent, $refline, $refcolumn,
|
||||||
sub parse_c_tuple($$$$$$$) {
|
# FIXME: Should not write directly
|
||||||
my $self = shift;
|
$items, $item_lines, $item_columns) = @_;
|
||||||
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
# FIXME: Should not write directly
|
|
||||||
my $items = shift;
|
|
||||||
my $item_lines = shift;
|
|
||||||
my $item_columns = shift;
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
|
|
||||||
|
@ -1713,17 +1529,9 @@ sub parse_c_tuple($$$$$$$) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub parse_c_type($$$$$)
|
||||||
# parse_c_type
|
{
|
||||||
|
my ($self, $refcurrent, $refline, $refcolumn, $reftype) = @_;
|
||||||
sub parse_c_type($$$$$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
my $reftype = shift;
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
|
@ -1753,19 +1561,9 @@ sub parse_c_type($$$$$) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub parse_c_typedef($$$$)
|
||||||
# parse_c_typedef
|
{
|
||||||
|
my ($self, $refcurrent, $refline, $refcolumn) = @_;
|
||||||
sub parse_c_typedef($$$$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $create_type = \${$self->{CREATE_TYPE}};
|
|
||||||
my $found_type = \${$self->{FOUND_TYPE}};
|
|
||||||
my $preprocessor_condition = \${$self->{PREPROCESSOR_CONDITION}};
|
|
||||||
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
|
@ -1808,7 +1606,7 @@ sub parse_c_typedef($$$$) {
|
||||||
$base_name=$kind if (!defined $base_name);
|
$base_name=$kind if (!defined $base_name);
|
||||||
foreach my $name (@names) {
|
foreach my $name (@names) {
|
||||||
if ($name =~ /^\w+$/) {
|
if ($name =~ /^\w+$/) {
|
||||||
my $type = &$$create_type();
|
my $type = $self->{CREATE_TYPE}();
|
||||||
|
|
||||||
$type->kind($kind);
|
$type->kind($kind);
|
||||||
$type->_name($_name);
|
$type->_name($_name);
|
||||||
|
@ -1816,19 +1614,19 @@ sub parse_c_typedef($$$$) {
|
||||||
$type->field_type_names([@field_type_names]);
|
$type->field_type_names([@field_type_names]);
|
||||||
$type->field_names([@field_names]);
|
$type->field_names([@field_names]);
|
||||||
|
|
||||||
&$$found_type($type);
|
$self->{FOUND_TYPE}($type);
|
||||||
} elsif ($name =~ /^(\*+)\s*(?:RESTRICTED_POINTER\s+)?(\w+)$/) {
|
} elsif ($name =~ /^(\*+)\s*(?:RESTRICTED_POINTER\s+)?(\w+)$/) {
|
||||||
my $type_name = "$base_name $1";
|
my $type_name = "$base_name $1";
|
||||||
$name = $2;
|
$name = $2;
|
||||||
|
|
||||||
my $type = &$$create_type();
|
my $type = $self->{CREATE_TYPE}();
|
||||||
|
|
||||||
$type->kind("");
|
$type->kind("");
|
||||||
$type->name($name);
|
$type->name($name);
|
||||||
$type->field_type_names([$type_name]);
|
$type->field_type_names([$type_name]);
|
||||||
$type->field_names([""]);
|
$type->field_names([""]);
|
||||||
|
|
||||||
&$$found_type($type);
|
$self->{FOUND_TYPE}($type);
|
||||||
} else {
|
} else {
|
||||||
$self->_parse_c_error($_, $line, $column, "typedef 2");
|
$self->_parse_c_error($_, $line, $column, "typedef 2");
|
||||||
}
|
}
|
||||||
|
@ -1846,7 +1644,7 @@ sub parse_c_typedef($$$$) {
|
||||||
$type_name =~ s/\s+/ /g;
|
$type_name =~ s/\s+/ /g;
|
||||||
|
|
||||||
if(defined($type_name) && defined($name)) {
|
if(defined($type_name) && defined($name)) {
|
||||||
my $type = &$$create_type();
|
my $type = $self->{CREATE_TYPE}();
|
||||||
|
|
||||||
if (length($name) == 0) {
|
if (length($name) == 0) {
|
||||||
$self->_parse_c_error($_, $line, $column, "typedef");
|
$self->_parse_c_error($_, $line, $column, "typedef");
|
||||||
|
@ -1857,7 +1655,7 @@ sub parse_c_typedef($$$$) {
|
||||||
$type->field_type_names([$type_name]);
|
$type->field_type_names([$type_name]);
|
||||||
$type->field_names([""]);
|
$type->field_names([""]);
|
||||||
|
|
||||||
&$$found_type($type);
|
$self->{FOUND_TYPE}($type);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$self->_parse_c_error($_, $line, $column, "typedef");
|
$self->_parse_c_error($_, $line, $column, "typedef");
|
||||||
|
@ -1870,21 +1668,9 @@ sub parse_c_typedef($$$$) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub parse_c_variable($$$$$$$)
|
||||||
# parse_c_variable
|
{
|
||||||
|
my ($self, $refcurrent, $refline, $refcolumn, $reflinkage, $reftype, $refname) = @_;
|
||||||
sub parse_c_variable($$$$$$$) {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $found_variable = \${$self->{FOUND_VARIABLE}};
|
|
||||||
|
|
||||||
my $refcurrent = shift;
|
|
||||||
my $refline = shift;
|
|
||||||
my $refcolumn = shift;
|
|
||||||
|
|
||||||
my $reflinkage = shift;
|
|
||||||
my $reftype = shift;
|
|
||||||
my $refname = shift;
|
|
||||||
|
|
||||||
local $_ = $$refcurrent;
|
local $_ = $$refcurrent;
|
||||||
my $line = $$refline;
|
my $line = $$refline;
|
||||||
|
@ -2056,10 +1842,7 @@ sub parse_c_variable($$$$$$$) {
|
||||||
$$reftype = $type;
|
$$reftype = $type;
|
||||||
$$refname = $name;
|
$$refname = $name;
|
||||||
|
|
||||||
if(&$$found_variable($begin_line, $begin_column, $linkage, $type, $name))
|
$self->{FOUND_VARIABLE}($begin_line, $begin_column, $linkage, $type, $name);
|
||||||
{
|
|
||||||
# Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,57 +24,42 @@ use output qw($output);
|
||||||
|
|
||||||
sub _refresh($);
|
sub _refresh($);
|
||||||
|
|
||||||
sub new($) {
|
sub new($)
|
||||||
my $proto = shift;
|
{
|
||||||
|
my ($proto) = @_;
|
||||||
my $class = ref($proto) || $proto;
|
my $class = ref($proto) || $proto;
|
||||||
my $self = {};
|
my $self = {};
|
||||||
bless ($self, $class);
|
bless $self, $class;
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# set_find_align_callback
|
|
||||||
#
|
#
|
||||||
sub set_find_align_callback($$) {
|
# Callback setters
|
||||||
my $self = shift;
|
#
|
||||||
|
|
||||||
my $find_align = \${$self->{FIND_ALIGN}};
|
sub set_find_align_callback($$)
|
||||||
|
{
|
||||||
$$find_align = shift;
|
my ($self, $find_align) = @_;
|
||||||
|
$self->{FIND_ALIGN} = $find_align;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub set_find_kind_callback($$)
|
||||||
# set_find_kind_callback
|
{
|
||||||
#
|
my ($self, $find_kind) = @_;
|
||||||
sub set_find_kind_callback($$) {
|
$self->{FIND_KIND} = $find_kind;
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $find_kind = \${$self->{FIND_KIND}};
|
|
||||||
|
|
||||||
$$find_kind = shift;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub set_find_size_callback($$)
|
||||||
# set_find_size_callback
|
{
|
||||||
#
|
my ($self, $find_size) = @_;
|
||||||
sub set_find_size_callback($$) {
|
$self->{FIND_SIZE} = $find_size;
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $find_size = \${$self->{FIND_SIZE}};
|
|
||||||
|
|
||||||
$$find_size = shift;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
sub set_find_count_callback($$)
|
||||||
# set_find_count_callback
|
{
|
||||||
#
|
my ($self, $find_count) = @_;
|
||||||
sub set_find_count_callback($$) {
|
$self->{FIND_COUNT} = $find_count;
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $find_count = \${$self->{FIND_COUNT}};
|
|
||||||
|
|
||||||
$$find_count = shift;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,79 +69,60 @@ sub set_find_count_callback($$) {
|
||||||
|
|
||||||
sub kind($;$)
|
sub kind($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $kind) = @_;
|
||||||
my $kind = \${$self->{KIND}};
|
if (defined $kind)
|
||||||
my $dirty = \${$self->{DIRTY}};
|
{
|
||||||
|
$self->{KIND} = $kind;
|
||||||
local $_ = shift;
|
$self->{DIRTY} = 1;
|
||||||
|
|
||||||
if(defined($_)) { $$kind = $_; $$dirty = 1; }
|
|
||||||
|
|
||||||
if (!defined($$kind)) {
|
|
||||||
$self->_refresh();
|
|
||||||
}
|
}
|
||||||
|
$self->_refresh() if (!defined $self->{KIND});
|
||||||
return $$kind;
|
return $self->{KIND};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _name($;$)
|
sub _name($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $_name) = @_;
|
||||||
my $_name = \${$self->{_NAME}};
|
if (defined $_name)
|
||||||
my $dirty = \${$self->{DIRTY}};
|
{
|
||||||
|
$self->{_NAME} = $_name;
|
||||||
local $_ = shift;
|
$self->{DIRTY} = 1;
|
||||||
|
}
|
||||||
if(defined($_)) { $$_name = $_; $$dirty = 1; }
|
return $self->{_NAME};
|
||||||
|
|
||||||
return $$_name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub name($;$)
|
sub name($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $name) = @_;
|
||||||
my $name = \${$self->{NAME}};
|
if (defined $name)
|
||||||
my $dirty = \${$self->{DIRTY}};
|
{
|
||||||
|
$self->{NAME} = $name;
|
||||||
local $_ = shift;
|
$self->{DIRTY} = 1;
|
||||||
|
|
||||||
if(defined($_)) { $$name = $_; $$dirty = 1; }
|
|
||||||
|
|
||||||
if($$name) {
|
|
||||||
return $$name;
|
|
||||||
} else {
|
|
||||||
my $kind = \${$self->{KIND}};
|
|
||||||
my $_name = \${$self->{_NAME}};
|
|
||||||
|
|
||||||
return "$$kind $$_name";
|
|
||||||
}
|
}
|
||||||
|
return $self->{NAME} if ($self->{NAME});
|
||||||
|
return "$self->{KIND} $self->{_NAME}";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub pack($;$)
|
sub pack($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $pack) = @_;
|
||||||
my $pack = \${$self->{PACK}};
|
if (defined $pack)
|
||||||
my $dirty = \${$self->{DIRTY}};
|
{
|
||||||
|
$self->{PACK} = $pack;
|
||||||
local $_ = shift;
|
$self->{DIRTY} = 1;
|
||||||
|
}
|
||||||
if(defined($_)) { $$pack = $_; $$dirty = 1; }
|
return $self->{PACK};
|
||||||
|
|
||||||
return $$pack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub align($) {
|
sub align($)
|
||||||
my $self = shift;
|
{
|
||||||
|
my ($self) = @_;
|
||||||
my $align = \${$self->{ALIGN}};
|
|
||||||
|
|
||||||
$self->_refresh();
|
$self->_refresh();
|
||||||
|
return $self->{ALIGN};
|
||||||
return $$align;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub fields($) {
|
sub fields($)
|
||||||
my $self = shift;
|
{
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
my $count = $self->field_count;
|
my $count = $self->field_count;
|
||||||
|
|
||||||
|
@ -168,107 +134,73 @@ sub fields($) {
|
||||||
return @fields;
|
return @fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub field_base_sizes($) {
|
sub field_base_sizes($)
|
||||||
my $self = shift;
|
{
|
||||||
my $field_base_sizes = \${$self->{FIELD_BASE_SIZES}};
|
my ($self) = @_;
|
||||||
|
|
||||||
$self->_refresh();
|
$self->_refresh();
|
||||||
|
return $self->{FIELD_BASE_SIZES};
|
||||||
return $$field_base_sizes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub field_aligns($) {
|
sub field_aligns($)
|
||||||
my $self = shift;
|
{
|
||||||
my $field_aligns = \${$self->{FIELD_ALIGNS}};
|
my ($self) = @_;
|
||||||
|
|
||||||
$self->_refresh();
|
$self->_refresh();
|
||||||
|
return $self->{FIELD_ALIGNS};
|
||||||
return $$field_aligns;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub field_count($) {
|
sub field_count($)
|
||||||
my $self = shift;
|
{
|
||||||
my $field_type_names = \${$self->{FIELD_TYPE_NAMES}};
|
my ($self) = @_;
|
||||||
|
return scalar @{$self->{FIELD_TYPE_NAMES}};
|
||||||
my @field_type_names = @{$$field_type_names};
|
|
||||||
my $count = scalar(@field_type_names);
|
|
||||||
|
|
||||||
return $count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub field_names($;$)
|
sub field_names($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $field_names) = @_;
|
||||||
my $field_names = \${$self->{FIELD_NAMES}};
|
if (defined $field_names)
|
||||||
my $dirty = \${$self->{DIRTY}};
|
{
|
||||||
|
$self->{FIELD_NAMES} = $field_names;
|
||||||
local $_ = shift;
|
$self->{DIRTY} = 1;
|
||||||
|
}
|
||||||
if(defined($_)) { $$field_names = $_; $$dirty = 1; }
|
return $self->{FIELD_NAMES};
|
||||||
|
|
||||||
return $$field_names;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub field_offsets($) {
|
sub field_offsets($)
|
||||||
my $self = shift;
|
{
|
||||||
my $field_offsets = \${$self->{FIELD_OFFSETS}};
|
my ($self) = @_;
|
||||||
|
|
||||||
$self->_refresh();
|
$self->_refresh();
|
||||||
|
return $self->{FIELD_OFFSETS};
|
||||||
return $$field_offsets;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub field_sizes($) {
|
sub field_sizes($)
|
||||||
my $self = shift;
|
{
|
||||||
my $field_sizes = \${$self->{FIELD_SIZES}};
|
my ($self) = @_;
|
||||||
|
|
||||||
$self->_refresh();
|
$self->_refresh();
|
||||||
|
return $self->{FIELD_SIZES};
|
||||||
return $$field_sizes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub field_type_names($;$)
|
sub field_type_names($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my ($self, $field_type_names) = @_;
|
||||||
my $field_type_names = \${$self->{FIELD_TYPE_NAMES}};
|
if (defined $field_type_names)
|
||||||
my $dirty = \${$self->{DIRTY}};
|
{
|
||||||
|
$self->{FIELD_TYPE_NAMES} = $field_type_names;
|
||||||
local $_ = shift;
|
$self->{DIRTY} = 1;
|
||||||
|
}
|
||||||
if(defined($_)) { $$field_type_names = $_; $$dirty = 1; }
|
return $self->{FIELD_TYPE_NAMES};
|
||||||
|
|
||||||
return $$field_type_names;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub size($) {
|
sub size($)
|
||||||
my $self = shift;
|
{
|
||||||
|
my ($self) = @_;
|
||||||
my $size = \${$self->{SIZE}};
|
|
||||||
|
|
||||||
$self->_refresh();
|
$self->_refresh();
|
||||||
|
return $self->{SIZE};
|
||||||
return $$size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _refresh($) {
|
sub _refresh($)
|
||||||
my $self = shift;
|
{
|
||||||
|
my ($self) = @_;
|
||||||
my $dirty = \${$self->{DIRTY}};
|
return if (!$self->{DIRTY});
|
||||||
|
|
||||||
return if !$$dirty;
|
|
||||||
|
|
||||||
my $find_align = \${$self->{FIND_ALIGN}};
|
|
||||||
my $find_kind = \${$self->{FIND_KIND}};
|
|
||||||
my $find_size = \${$self->{FIND_SIZE}};
|
|
||||||
my $find_count = \${$self->{FIND_COUNT}};
|
|
||||||
|
|
||||||
my $align = \${$self->{ALIGN}};
|
|
||||||
my $kind = \${$self->{KIND}};
|
|
||||||
my $size = \${$self->{SIZE}};
|
|
||||||
my $field_aligns = \${$self->{FIELD_ALIGNS}};
|
|
||||||
my $field_base_sizes = \${$self->{FIELD_BASE_SIZES}};
|
|
||||||
my $field_offsets = \${$self->{FIELD_OFFSETS}};
|
|
||||||
my $field_sizes = \${$self->{FIELD_SIZES}};
|
|
||||||
|
|
||||||
my $pack = $self->pack;
|
my $pack = $self->pack;
|
||||||
$pack = 8 if !defined($pack);
|
$pack = 8 if !defined($pack);
|
||||||
|
@ -280,7 +212,8 @@ sub _refresh($) {
|
||||||
my $bitfield_bits = 0;
|
my $bitfield_bits = 0;
|
||||||
|
|
||||||
my $n = 0;
|
my $n = 0;
|
||||||
foreach my $field ($self->fields) {
|
foreach my $field ($self->fields())
|
||||||
|
{
|
||||||
my $type_name = $field->type_name;
|
my $type_name = $field->type_name;
|
||||||
|
|
||||||
my $bits;
|
my $bits;
|
||||||
|
@ -295,17 +228,18 @@ sub _refresh($) {
|
||||||
{
|
{
|
||||||
$declspec_align=$1;
|
$declspec_align=$1;
|
||||||
}
|
}
|
||||||
my $base_size = &$$find_size($type_name);
|
my $base_size = $self->{FIND_SIZE}($type_name);
|
||||||
my $type_size=$base_size;
|
my $type_size=$base_size;
|
||||||
if (defined $count)
|
if (defined $count)
|
||||||
{
|
{
|
||||||
$count=&$$find_count($count) if ($count !~ /^\d+$/);
|
$count=$self->{FIND_COUNT}($count) if ($count !~ /^\d+$/);
|
||||||
if (!defined $count)
|
if (!defined $count)
|
||||||
{
|
{
|
||||||
$type_size=undef;
|
$type_size=undef;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
print STDERR "$type_name -> type_size=undef, count=$count\n" if (!defined $type_size);
|
||||||
$type_size *= int($count);
|
$type_size *= int($count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,35 +262,35 @@ sub _refresh($) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$$align = &$$find_align($type_name);
|
$self->{ALIGN} = $self->{FIND_ALIGN}($type_name);
|
||||||
$$align=$declspec_align if (defined $declspec_align);
|
$self->{ALIGN} = $declspec_align if (defined $declspec_align);
|
||||||
|
|
||||||
if (defined $$align)
|
if (defined $self->{ALIGN})
|
||||||
{
|
{
|
||||||
$$align = $pack if $$align > $pack;
|
$self->{ALIGN} = $pack if ($self->{ALIGN} > $pack);
|
||||||
$max_field_align = $$align if $$align > $max_field_align;
|
$max_field_align = $self->{ALIGN} if ($self->{ALIGN}) > $max_field_align;
|
||||||
|
|
||||||
if ($offset % $$align != 0) {
|
if ($offset % $self->{ALIGN} != 0) {
|
||||||
$offset = (int($offset / $$align) + 1) * $$align;
|
$offset = (int($offset / $self->{ALIGN}) + 1) * $self->{ALIGN};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($$kind !~ /^(?:struct|union)$/)
|
if ($self->{KIND} !~ /^(?:struct|union)$/)
|
||||||
{
|
{
|
||||||
$$kind = &$$find_kind($type_name) || "";
|
$self->{KIND} = $self->{FIND_KIND}($type_name) || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$type_size)
|
if (!$type_size)
|
||||||
{
|
{
|
||||||
$$align = undef;
|
$self->{ALIGN} = undef;
|
||||||
$$size = undef;
|
$self->{SIZE} = undef;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$$$field_aligns[$n] = $$align;
|
$self->{FIELD_ALIGNS}->[$n] = $self->{ALIGN};
|
||||||
$$$field_base_sizes[$n] = $base_size;
|
$self->{FIELD_BASE_SIZES}->[$n] = $base_size;
|
||||||
$$$field_offsets[$n] = $offset;
|
$self->{FIELD_OFFSETS}->[$n] = $offset;
|
||||||
$$$field_sizes[$n] = $type_size;
|
$self->{FIELD_SIZES}->[$n] = $type_size;
|
||||||
$offset += $type_size;
|
$offset += $type_size;
|
||||||
|
|
||||||
if ($bits)
|
if ($bits)
|
||||||
|
@ -367,94 +301,66 @@ sub _refresh($) {
|
||||||
$n++;
|
$n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$$align = $pack;
|
$self->{ALIGN} = $pack;
|
||||||
$$align = $max_field_align if $max_field_align < $pack;
|
$self->{ALIGN} = $max_field_align if ($max_field_align < $pack);
|
||||||
|
|
||||||
$$size = $offset;
|
$self->{SIZE} = $offset;
|
||||||
if ($$kind =~ /^(?:struct|union)$/) {
|
if ($self->{KIND} =~ /^(?:struct|union)$/) {
|
||||||
if ($$size % $$align != 0) {
|
if ($self->{SIZE} % $self->{ALIGN} != 0) {
|
||||||
$$size = (int($$size / $$align) + 1) * $$align;
|
$self->{SIZE} = (int($self->{SIZE} / $self->{ALIGN}) + 1) * $self->{ALIGN};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$$dirty = 0;
|
$self->{DIRTY} = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
package c_type_field;
|
package c_type_field;
|
||||||
|
|
||||||
sub new($$$) {
|
sub new($$$)
|
||||||
my $proto = shift;
|
{
|
||||||
|
my ($proto, $type, $number) = @_;
|
||||||
my $class = ref($proto) || $proto;
|
my $class = ref($proto) || $proto;
|
||||||
my $self = {};
|
my $self = {TYPE=> $type,
|
||||||
bless ($self, $class);
|
NUMBER => $number
|
||||||
|
};
|
||||||
my $type = \${$self->{TYPE}};
|
bless $self, $class;
|
||||||
my $number = \${$self->{NUMBER}};
|
|
||||||
|
|
||||||
$$type = shift;
|
|
||||||
$$number = shift;
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub align($) {
|
sub align($)
|
||||||
my $self = shift;
|
{
|
||||||
my $type = \${$self->{TYPE}};
|
my ($self) = @_;
|
||||||
my $number = \${$self->{NUMBER}};
|
return $self->{TYPE}->field_aligns()->[$self->{NUMBER}];
|
||||||
|
|
||||||
my $field_aligns = $$type->field_aligns;
|
|
||||||
|
|
||||||
return $$field_aligns[$$number];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub base_size($) {
|
sub base_size($)
|
||||||
my $self = shift;
|
{
|
||||||
my $type = \${$self->{TYPE}};
|
my ($self) = @_;
|
||||||
my $number = \${$self->{NUMBER}};
|
return $self->{TYPE}->field_base_sizes()->[$self->{NUMBER}];
|
||||||
|
|
||||||
my $field_base_sizes = $$type->field_base_sizes;
|
|
||||||
|
|
||||||
return $$field_base_sizes[$$number];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub name($) {
|
sub name($)
|
||||||
my $self = shift;
|
{
|
||||||
my $type = \${$self->{TYPE}};
|
my ($self) = @_;
|
||||||
my $number = \${$self->{NUMBER}};
|
return $self->{TYPE}->field_names()->[$self->{NUMBER}];
|
||||||
|
|
||||||
my $field_names = $$type->field_names;
|
|
||||||
|
|
||||||
return $$field_names[$$number];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub offset($) {
|
sub offset($)
|
||||||
my $self = shift;
|
{
|
||||||
my $type = \${$self->{TYPE}};
|
my ($self) = @_;
|
||||||
my $number = \${$self->{NUMBER}};
|
return $self->{TYPE}->field_offsets()->[$self->{NUMBER}];
|
||||||
|
|
||||||
my $field_offsets = $$type->field_offsets;
|
|
||||||
|
|
||||||
return $$field_offsets[$$number];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub size($) {
|
sub size($)
|
||||||
my $self = shift;
|
{
|
||||||
my $type = \${$self->{TYPE}};
|
my ($self) = @_;
|
||||||
my $number = \${$self->{NUMBER}};
|
return $self->{TYPE}->field_sizes()->[$self->{NUMBER}];
|
||||||
|
|
||||||
my $field_sizes = $$type->field_sizes;
|
|
||||||
|
|
||||||
return $$field_sizes[$$number];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub type_name($) {
|
sub type_name($)
|
||||||
my $self = shift;
|
{
|
||||||
my $type = \${$self->{TYPE}};
|
my ($self) = @_;
|
||||||
my $number = \${$self->{NUMBER}};
|
return $self->{TYPE}->field_type_names()->[$self->{NUMBER}];
|
||||||
|
|
||||||
my $field_type_names = $$type->field_type_names;
|
|
||||||
|
|
||||||
return $$field_type_names[$$number];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
Loading…
Reference in New Issue