summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/trace32
1 files changed, 25 insertions, 7 deletions
diff --git a/bin/trace b/bin/trace
index c1a1acc..3ab902e 100755
--- a/bin/trace
+++ b/bin/trace
@@ -80,7 +80,7 @@ sub errmesg ($$@) {
#
sub argstring ($$$) {
my ($file, $func, $atype) = @_;
- my ($ptr, $tstr) = (0,"!");
+ my ($ptr, $tstr, $array) = (0, "!", "");
my ($fq_atype);
# Normalize the data type by removing redundant white space,
@@ -91,8 +91,12 @@ sub argstring ($$$) {
$ptr = length $1 if $atype =~ s/(\*+)//;
$atype =~ s/^\s+//;
$atype =~ s/\s+$//;
+ if ($atype =~ /(.*)\[(.*)\]$/) {
+ ($array, $atype) = ($2, $1);
+ }
$fq_atype = $atype . ('*' x $ptr);
+
if ($ptr>0 && exists $TypeString{$fq_atype}) {
$ptr = 0;
$tstr = $TypeString{$fq_atype};
@@ -104,7 +108,7 @@ sub argstring ($$$) {
} else {
$tstr = $TypeString{$atype};
}
- return ("*" x $ptr) . $tstr;
+ return ("*" x $ptr) . ($array?"[$array]":"") . $tstr;
}
##############################################################################
@@ -129,15 +133,18 @@ sub rewrite_func ($$$$$) {
# comma, then split the arguments on commas.
$args =~ s/(\/\*\s*in),\s*(out\s*\*\/)/$1_$2/g;
my @args = split /,[\s\n]*/, $args;
+ my $argno = 0;
+ my %names;
for $arg (@args) {
unless ($arg=~/^(([a-z_A-Z]\w*\s+)+\**)
- ([a-z_A-Z]\w*)(\[\])?
+ ([a-z_A-Z]\w*)(\[.*?\])?
(\s*\/\*\s*(in|out|in_out)\s*\*\/)?\s*$/x) {
errmesg $file, $name, "unable to parse \`$arg\'";
goto error;
} else {
my ($atype, $aname, $array, $adir) = ($1, $3, $4, $6);
+ $names{$aname} = $argno++;
$adir ||= "in";
$atype =~ s/\s+$//;
push @arg_name, $aname;
@@ -145,7 +152,18 @@ sub rewrite_func ($$$$$) {
if ($adir eq "out") {
push @arg_str, "x";
} else {
- $atype .= "*" if $array;
+ if (defined $array) {
+ $atype .= "*";
+ if ($array =~ /^\[\/\*([a-z_A-Z]\w*)\*\/\]$/) {
+ my $asize = $1;
+ if (exists $names{$asize}) {
+ $atype .= '[a' . $names{$asize} . ']';
+ } else {
+ warn "bad array size: $asize";
+ $atype .= "*";
+ }
+ }
+ }
push @arg_str, argstring $file, $name, $atype;
}
}
@@ -185,7 +203,7 @@ sub rewrite_func ($$$$$) {
error:
- return "\n$type\n$name ($args)$body";
+ return "\n$type\n$name ($args)\n$body";
}
##############################################################################
@@ -203,8 +221,8 @@ for $file (@ARGV) {
my $original = $Source;
my $napi = $Source =~ s/\n([A-Za-z]\w*(\s+[a-z]\w*)*)\s*\n #type
(H5[A-Z]{1,2}[^_A-Z]\w*) #name
- \s*\((.*?)\) #args
- (.*?\n\}[^\n]*) #body
+ \s*\((.*?)\)\s* #args
+ (\{.*?\n\}[^\n]*) #body
/rewrite_func($file,$1,$3,$4,$5)/segx;
$total_api += $napi;