Add support for common-refs and double arrays.
Fix error message line and type parsing.
Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
$size = $tlv_get{$prefix};
die "Unknown size element type '$prefix'" if not defined $size;
+ my $curvar = "$var\_n";
+ if (rindex($var,"]") == length($var)-1) {
+ $curvar = substr($var, 0, index($var, "["))."\_i";
+ $data .= $indent."$curvar = 0;\n";
+ }
($var_data, $var_iterator) =
- gen_tlv_parse_field($var."[$var\_n]", $elem->{"array-element"}, $n_indent + 1, "i$iterator");
+ gen_tlv_parse_field($var."[$curvar]", $elem->{"array-element"}, $n_indent + 1, "i$iterator");
- $var_data .= $indent."\t$var\_n++;\n";
+ $var_data .= $indent."\t$curvar++;\n";
$data .= $indent."$iterator = $size;\n";
$data .= $indent."$var = __qmi_alloc_static($iterator * sizeof($var\[0]));\n";
$data .= $indent."while($iterator\-- > 0) {\n";
switch(tlv->type) {
EOF
foreach my $field (@$data) {
+ $field = gen_common_ref($field);
my $cname = gen_cname($field->{name});
gen_tlv_type($cname, $field, $i++);
}
EOF
foreach my $field (@$fields) {
+ $field = gen_common_ref($field);
my $cname = gen_cname($field->{name});
gen_tlv_attr_set($cname, $field);
}
gfloat => "float",
gboolean => "bool",
);
+our %common_ref = ();
$prefix eq 'ctl_' and $ctl = 1;
my $data = shift;
foreach my $field (@$data) {
+ $field = gen_common_ref($field);
my $type = $field->{"format"};
$type and return 1;
}
}
}
+sub gen_common_ref($$) {
+ my $field = shift;
+ $field = $common_ref{$field->{'common-ref'}} if $field->{'common-ref'} ne '';
+ return $field;
+}
+
sub gen_foreach_message_type($$$)
{
my $data = shift;
my $args = [];
my $fields = [];
+ $common_ref{$entry->{'common-ref'}} = $entry if $entry->{'common-ref'} ne '';
+
next if $entry->{type} ne 'Message';
next if not defined $entry->{input} and not defined $entry->{output};
};
undef $doc_start;
- $line =~ /^\s*\*\s*@(.+): (.+)\./ and push @errors, [ $1, $2 ];
+ $line =~ /^.*@([A-Z0-9_]+): ([A-z0-9 ]+)[.].*$/ and push @errors, [ $1, $2 ];
}
@errors > 0 or die "No data found\n";
if ($tlv_types{$ptype}) {
return $indent.$tlv_types{$ptype}." $cname;";
} elsif ($tlv_types{$type}) {
- return $indent."$ptype $cname;";
+ return $indent.$tlv_types{$type}." $cname;";
} elsif ($type eq "string") {
return $indent."char *$cname;", 1;
} elsif ($type eq "array") {
}
my ($type, $no_set_field) = gen_tlv_type("*$cname", $elem->{"array-element"}, $indent);
return undef if not defined $type;
+ return $indent."unsigned int ".substr($cname,1)."\_i;$type", 1 if (!rindex($cname,"*",0));
return $indent."unsigned int $cname\_n;$type", 1;
} elsif ($type eq "sequence" or $type eq "struct") {
my $contents = $elem->{"contents"};
my $data = "struct {";
foreach my $field (@$contents) {
+ $field = gen_common_ref($field);
my $_cname = gen_cname($field->{name});
my ($_data, $no_set_field) = gen_tlv_type($_cname, $field, "$indent\t");
$data .= $_data;
my $_data = "";
foreach my $field (@$data) {
+ $field = gen_common_ref($field);
my $cname = gen_cname($field->{name});
my ($data, $no_set_field) = gen_tlv_type($cname, $field, "\n\t\t");