From 0c1b1df8d9319ba97995dbdd79dfc50ad48ae26a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 17 May 2018 16:29:02 +0100 Subject: [PATCH] Run make_class.pl --- src/grib_accessor_class_bufr_data_array.c | 6 +- src/grib_iterator_class_gaussian.c | 1 + src/grib_iterator_class_gen.c | 6 +- src/grib_iterator_class_latlon.c | 16 +-- src/grib_iterator_class_regular.c | 6 +- src/grib_nearest_class.h | 2 +- src/make_class.pl | 140 +++++++++++----------- 7 files changed, 89 insertions(+), 88 deletions(-) diff --git a/src/grib_accessor_class_bufr_data_array.c b/src/grib_accessor_class_bufr_data_array.c index d11c4db86..86f0bdc60 100644 --- a/src/grib_accessor_class_bufr_data_array.c +++ b/src/grib_accessor_class_bufr_data_array.c @@ -143,9 +143,9 @@ typedef struct grib_accessor_bufr_data_array { grib_trie_with_rank* dataAccessorsTrie; grib_sarray* tempStrings; int change_ref_value_operand; - size_t refValListSize; - long* refValList; - long refValIndex; + size_t refValListSize; + long* refValList; + long refValIndex; bufr_tableb_override* tableb_override; } grib_accessor_bufr_data_array; diff --git a/src/grib_iterator_class_gaussian.c b/src/grib_iterator_class_gaussian.c index 4a2cebd5f..b30f90e9a 100644 --- a/src/grib_iterator_class_gaussian.c +++ b/src/grib_iterator_class_gaussian.c @@ -57,6 +57,7 @@ typedef struct grib_iterator_gaussian{ double angleOfRotation; double southPoleLat; double southPoleLon; + long jPointsAreConsecutive; /* Members defined in gaussian */ } grib_iterator_gaussian; diff --git a/src/grib_iterator_class_gen.c b/src/grib_iterator_class_gen.c index 8ec599dc6..a65f9cd11 100644 --- a/src/grib_iterator_class_gen.c +++ b/src/grib_iterator_class_gen.c @@ -38,10 +38,10 @@ or edit "iterator.class" and rerun ./make_class.pl static void init_class (grib_iterator_class*); -static int init (grib_iterator* iter,grib_handle*,grib_arguments*); +static int init (grib_iterator* i,grib_handle*,grib_arguments*); static int destroy (grib_iterator* i); -static int reset (grib_iterator* iter); -static long has_next (grib_iterator* iter); +static int reset (grib_iterator* i); +static long has_next (grib_iterator* i); typedef struct grib_iterator_gen{ diff --git a/src/grib_iterator_class_latlon.c b/src/grib_iterator_class_latlon.c index c6042b5f7..9ba574036 100644 --- a/src/grib_iterator_class_latlon.c +++ b/src/grib_iterator_class_latlon.c @@ -34,8 +34,8 @@ or edit "iterator.class" and rerun ./make_class.pl static void init_class (grib_iterator_class*); -static int init (grib_iterator* iter,grib_handle*,grib_arguments*); -static int next (grib_iterator* iter, double *lat, double *lon, double *val); +static int init (grib_iterator* i,grib_handle*,grib_arguments*); +static int next (grib_iterator* i, double *lat, double *lon, double *val); typedef struct grib_iterator_latlon{ @@ -48,12 +48,12 @@ typedef struct grib_iterator_latlon{ double *los; long nap; long nam; - long iScansNegatively; - long isRotated; - double angleOfRotation; - double southPoleLat; - double southPoleLon; - long jPointsAreConsecutive; + long iScansNegatively; + long isRotated; + double angleOfRotation; + double southPoleLat; + double southPoleLon; + long jPointsAreConsecutive; /* Members defined in latlon */ } grib_iterator_latlon; diff --git a/src/grib_iterator_class_regular.c b/src/grib_iterator_class_regular.c index 9fe907972..769060746 100644 --- a/src/grib_iterator_class_regular.c +++ b/src/grib_iterator_class_regular.c @@ -62,12 +62,12 @@ typedef struct grib_iterator_regular{ double *los; long nap; long nam; - long iScansNegatively; - long isRotated; + long iScansNegatively; + long isRotated; double angleOfRotation; double southPoleLat; double southPoleLon; - long jPointsAreConsecutive; + long jPointsAreConsecutive; } grib_iterator_regular; extern grib_iterator_class* grib_iterator_class_gen; diff --git a/src/grib_nearest_class.h b/src/grib_nearest_class.h index 441e501a9..772129e18 100644 --- a/src/grib_nearest_class.h +++ b/src/grib_nearest_class.h @@ -1,8 +1,8 @@ /* This file is automatically generated by ./make_class.pl, do not edit */ extern grib_nearest_class* grib_nearest_class_gen; extern grib_nearest_class* grib_nearest_class_lambert_conformal; -extern grib_nearest_class* grib_nearest_class_polar_stereographic; extern grib_nearest_class* grib_nearest_class_latlon_reduced; +extern grib_nearest_class* grib_nearest_class_polar_stereographic; extern grib_nearest_class* grib_nearest_class_reduced; extern grib_nearest_class* grib_nearest_class_regular; extern grib_nearest_class* grib_nearest_class_sh; diff --git a/src/make_class.pl b/src/make_class.pl index 4d0834109..fc8a79f76 100755 --- a/src/make_class.pl +++ b/src/make_class.pl @@ -2,13 +2,13 @@ use strict; use Data::Dumper; - my $name; +my $verbose = 0; foreach $name ( @ARGV ) { next unless($name =~ /\.c$/); - print "$name\n"; + print "$name\n" if ($verbose); open(IN,"<$name") or die "$name: $!"; open(OUT,">$name.tmp") or die "$name.tmp: $!"; @@ -78,7 +78,7 @@ foreach $name ( @ARGV ) } else { - print "IGNORING file $name\n"; + print "IGNORING file $name\n" if ($verbose); } unlink("$name.tmp"); @@ -111,7 +111,7 @@ sub output { my ($file,$args) = @_; local $_; - my %delegates; + my %delegates; my $class = cleanup($args->{CLASS}); @@ -153,11 +153,11 @@ EOF { if(/^(static\s+\w+\s*\*?\s*(\w+)\s*\(.*);/) { - if(exists $args->{DELEGATE}) - { - $delegates{$2} = $1 unless($implements{$2}); - $implements{$2} = 1; - } + if(exists $args->{DELEGATE}) + { + $delegates{$2} = $1 unless($implements{$2}); + $implements{$2} = 1; + } next unless($implements{$2}); } @@ -252,87 +252,87 @@ EOF # disabled for the moment # the problem with this is that for pointers we need proper clone, not an assignement if (0) { - foreach my $proc ( grep { /clone/ } @procs ) { - my $done=0; - print OUT "static grib_$class* clone(grib_$class* s) {\n"; - print OUT "\tgrib_${class}_$name* c=grib_context_alloc_clear(a->parent->h,sizeof(grib_${class}_$name));\n"; - foreach my $m ( @members ) { - if ( $m =~ /\/\*/ ) {next;} - print OUT "\n\tgrib_${class}_$name* self=(grib_${class}_$name*)s;\n\n" unless ($done); - $done=1; - my $is_pointer=0; - my @ma=split(/ /,$m); - my $mname=pop @ma; - if ($mname=~ /\*/) { $is_pointer=1; $mname =~ s/\*//; } - my $mtype=pop @ma; - if ($mtype=~ /\*/) { $is_pointer=1; $mtype =~ s/\*//; } + foreach my $proc ( grep { /clone/ } @procs ) { + my $done=0; + print OUT "static grib_$class* clone(grib_$class* s) {\n"; + print OUT "\tgrib_${class}_$name* c=grib_context_alloc_clear(a->parent->h,sizeof(grib_${class}_$name));\n"; + foreach my $m ( @members ) { + if ( $m =~ /\/\*/ ) {next;} + print OUT "\n\tgrib_${class}_$name* self=(grib_${class}_$name*)s;\n\n" unless ($done); + $done=1; + my $is_pointer=0; + my @ma=split(/ /,$m); + my $mname=pop @ma; + if ($mname=~ /\*/) { $is_pointer=1; $mname =~ s/\*//; } + my $mtype=pop @ma; + if ($mtype=~ /\*/) { $is_pointer=1; $mtype =~ s/\*//; } - if ($is_pointer) { - if ($mtype =~ "\bchar\b") { - print OUT "\tif (self->$mname) \n\t\tc->$mname=grib_context_strdup(a->parent->h,self->$mname);\n\n"; + if ($is_pointer) { + if ($mtype =~ "\bchar\b") { + print OUT "\tif (self->$mname) \n\t\tc->$mname=grib_context_strdup(a->parent->h,self->$mname);\n\n"; } if ($mtype =~ "\b(double|long|int|float)\b") { - print OUT "\tif (self->".$mname."_size) {\n"; - print OUT "\tint i=0;\n"; - print OUT "\tc->$mname=grib_context_alloc_clear(a->parent->h,self->".$mname."_size*sizeof($mtype));"; - print OUT "\tfor (i=0;i${mname}_size;i++) c->".$mname."[i]=self->".$mname."[i];"; - print OUT "}\n"; - } - } else { print OUT "\tc->$mname=self->$mname;\n\n"; } - } - print OUT "\treturn (grib_$class*)c;\n}\n\n" - } + print OUT "\tif (self->".$mname."_size) {\n"; + print OUT "\tint i=0;\n"; + print OUT "\tc->$mname=grib_context_alloc_clear(a->parent->h,self->".$mname."_size*sizeof($mtype));"; + print OUT "\tfor (i=0;i${mname}_size;i++) c->".$mname."[i]=self->".$mname."[i];"; + print OUT "}\n"; + } + } else { print OUT "\tc->$mname=self->$mname;\n\n"; } + } + print OUT "\treturn (grib_$class*)c;\n}\n\n" + } } - delete $delegates{init}; - delete $delegates{post_init}; - delete $delegates{destroy}; + delete $delegates{init}; + delete $delegates{post_init}; + delete $delegates{destroy}; - if(%delegates) - { - print OUT "\n/* Start delegate methods */ \n"; + if(%delegates) + { + print OUT "\n/* Start delegate methods */ \n"; - print OUT "\nstatic grib_accessor_class* $args->{DELEGATE}(accessor*);\n\n"; + print OUT "\nstatic grib_accessor_class* $args->{DELEGATE}(accessor*);\n\n"; - foreach my $d ( sort keys %delegates ) - { - $delegates{$d} =~ /static\s+(.*)\s+(\w+)\s*\((.*)\)/; - my $return = $1 eq "void" ? "" : "return "; - my $ret = $1; + foreach my $d ( sort keys %delegates ) + { + $delegates{$d} =~ /static\s+(.*)\s+(\w+)\s*\((.*)\)/; + my $return = $1 eq "void" ? "" : "return "; + my $ret = $1; - my @args = map { s/^ +//; s/ +$//; $_; } split(",",$3); + my @args = map { s/^ +//; s/ +$//; $_; } split(",",$3); - my $i = 0; - my @types; - local $" = " "; + my $i = 0; + my @types; + local $" = " "; - foreach my $a ( @args ) - { - my @x = split(" ",$a); + foreach my $a ( @args ) + { + my @x = split(" ",$a); - $a = $x[-1]; - if(@x == 1 || $a =~ /\*$/) - { - $a = "arg" . $i++ ; - push @x,$a; - } - push @types, join(" ",@x); - $a =~ s/^\*//; - } + $a = $x[-1]; + if(@x == 1 || $a =~ /\*$/) + { + $a = "arg" . $i++ ; + push @x,$a; + } + push @types, join(" ",@x); + $a =~ s/^\*//; + } - local $" = ","; + local $" = ","; - print OUT <<"EOF"; + print OUT <<"EOF"; static $ret $d(@types) { - ${return}target($args[0])->$d(@args); + ${return}target($args[0])->$d(@args); } EOF - } + } - print OUT "\n/* End delegate methods */ \n"; - } + print OUT "\n/* End delegate methods */ \n"; + } close(CLASS); }