Run make_class.pl

This commit is contained in:
Shahram Najm 2018-05-17 16:29:02 +01:00
parent 3f5177f1c7
commit 0c1b1df8d9
7 changed files with 89 additions and 88 deletions

View File

@ -143,9 +143,9 @@ typedef struct grib_accessor_bufr_data_array {
grib_trie_with_rank* dataAccessorsTrie; grib_trie_with_rank* dataAccessorsTrie;
grib_sarray* tempStrings; grib_sarray* tempStrings;
int change_ref_value_operand; int change_ref_value_operand;
size_t refValListSize; size_t refValListSize;
long* refValList; long* refValList;
long refValIndex; long refValIndex;
bufr_tableb_override* tableb_override; bufr_tableb_override* tableb_override;
} grib_accessor_bufr_data_array; } grib_accessor_bufr_data_array;

View File

@ -57,6 +57,7 @@ typedef struct grib_iterator_gaussian{
double angleOfRotation; double angleOfRotation;
double southPoleLat; double southPoleLat;
double southPoleLon; double southPoleLon;
long jPointsAreConsecutive;
/* Members defined in gaussian */ /* Members defined in gaussian */
} grib_iterator_gaussian; } grib_iterator_gaussian;

View File

@ -38,10 +38,10 @@ or edit "iterator.class" and rerun ./make_class.pl
static void init_class (grib_iterator_class*); 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 destroy (grib_iterator* i);
static int reset (grib_iterator* iter); static int reset (grib_iterator* i);
static long has_next (grib_iterator* iter); static long has_next (grib_iterator* i);
typedef struct grib_iterator_gen{ typedef struct grib_iterator_gen{

View File

@ -34,8 +34,8 @@ or edit "iterator.class" and rerun ./make_class.pl
static void init_class (grib_iterator_class*); 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 next (grib_iterator* iter, double *lat, double *lon, double *val); static int next (grib_iterator* i, double *lat, double *lon, double *val);
typedef struct grib_iterator_latlon{ typedef struct grib_iterator_latlon{
@ -48,12 +48,12 @@ typedef struct grib_iterator_latlon{
double *los; double *los;
long nap; long nap;
long nam; long nam;
long iScansNegatively; long iScansNegatively;
long isRotated; long isRotated;
double angleOfRotation; double angleOfRotation;
double southPoleLat; double southPoleLat;
double southPoleLon; double southPoleLon;
long jPointsAreConsecutive; long jPointsAreConsecutive;
/* Members defined in latlon */ /* Members defined in latlon */
} grib_iterator_latlon; } grib_iterator_latlon;

View File

@ -62,12 +62,12 @@ typedef struct grib_iterator_regular{
double *los; double *los;
long nap; long nap;
long nam; long nam;
long iScansNegatively; long iScansNegatively;
long isRotated; long isRotated;
double angleOfRotation; double angleOfRotation;
double southPoleLat; double southPoleLat;
double southPoleLon; double southPoleLon;
long jPointsAreConsecutive; long jPointsAreConsecutive;
} grib_iterator_regular; } grib_iterator_regular;
extern grib_iterator_class* grib_iterator_class_gen; extern grib_iterator_class* grib_iterator_class_gen;

View File

@ -1,8 +1,8 @@
/* This file is automatically generated by ./make_class.pl, do not edit */ /* 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_gen;
extern grib_nearest_class* grib_nearest_class_lambert_conformal; 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_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_reduced;
extern grib_nearest_class* grib_nearest_class_regular; extern grib_nearest_class* grib_nearest_class_regular;
extern grib_nearest_class* grib_nearest_class_sh; extern grib_nearest_class* grib_nearest_class_sh;

View File

@ -2,13 +2,13 @@
use strict; use strict;
use Data::Dumper; use Data::Dumper;
my $name; my $name;
my $verbose = 0;
foreach $name ( @ARGV ) foreach $name ( @ARGV )
{ {
next unless($name =~ /\.c$/); next unless($name =~ /\.c$/);
print "$name\n"; print "$name\n" if ($verbose);
open(IN,"<$name") or die "$name: $!"; open(IN,"<$name") or die "$name: $!";
open(OUT,">$name.tmp") or die "$name.tmp: $!"; open(OUT,">$name.tmp") or die "$name.tmp: $!";
@ -78,7 +78,7 @@ foreach $name ( @ARGV )
} }
else else
{ {
print "IGNORING file $name\n"; print "IGNORING file $name\n" if ($verbose);
} }
unlink("$name.tmp"); unlink("$name.tmp");
@ -111,7 +111,7 @@ sub output {
my ($file,$args) = @_; my ($file,$args) = @_;
local $_; local $_;
my %delegates; my %delegates;
my $class = cleanup($args->{CLASS}); my $class = cleanup($args->{CLASS});
@ -153,11 +153,11 @@ EOF
{ {
if(/^(static\s+\w+\s*\*?\s*(\w+)\s*\(.*);/) if(/^(static\s+\w+\s*\*?\s*(\w+)\s*\(.*);/)
{ {
if(exists $args->{DELEGATE}) if(exists $args->{DELEGATE})
{ {
$delegates{$2} = $1 unless($implements{$2}); $delegates{$2} = $1 unless($implements{$2});
$implements{$2} = 1; $implements{$2} = 1;
} }
next unless($implements{$2}); next unless($implements{$2});
} }
@ -252,87 +252,87 @@ EOF
# disabled for the moment # disabled for the moment
# the problem with this is that for pointers we need proper clone, not an assignement # the problem with this is that for pointers we need proper clone, not an assignement
if (0) { if (0) {
foreach my $proc ( grep { /clone/ } @procs ) { foreach my $proc ( grep { /clone/ } @procs ) {
my $done=0; my $done=0;
print OUT "static grib_$class* clone(grib_$class* s) {\n"; 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"; print OUT "\tgrib_${class}_$name* c=grib_context_alloc_clear(a->parent->h,sizeof(grib_${class}_$name));\n";
foreach my $m ( @members ) { foreach my $m ( @members ) {
if ( $m =~ /\/\*/ ) {next;} if ( $m =~ /\/\*/ ) {next;}
print OUT "\n\tgrib_${class}_$name* self=(grib_${class}_$name*)s;\n\n" unless ($done); print OUT "\n\tgrib_${class}_$name* self=(grib_${class}_$name*)s;\n\n" unless ($done);
$done=1; $done=1;
my $is_pointer=0; my $is_pointer=0;
my @ma=split(/ /,$m); my @ma=split(/ /,$m);
my $mname=pop @ma; my $mname=pop @ma;
if ($mname=~ /\*/) { $is_pointer=1; $mname =~ s/\*//; } if ($mname=~ /\*/) { $is_pointer=1; $mname =~ s/\*//; }
my $mtype=pop @ma; my $mtype=pop @ma;
if ($mtype=~ /\*/) { $is_pointer=1; $mtype =~ s/\*//; } if ($mtype=~ /\*/) { $is_pointer=1; $mtype =~ s/\*//; }
if ($is_pointer) { if ($is_pointer) {
if ($mtype =~ "\bchar\b") { if ($mtype =~ "\bchar\b") {
print OUT "\tif (self->$mname) \n\t\tc->$mname=grib_context_strdup(a->parent->h,self->$mname);\n\n"; 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") { if ($mtype =~ "\b(double|long|int|float)\b") {
print OUT "\tif (self->".$mname."_size) {\n"; print OUT "\tif (self->".$mname."_size) {\n";
print OUT "\tint i=0;\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 "\tc->$mname=grib_context_alloc_clear(a->parent->h,self->".$mname."_size*sizeof($mtype));";
print OUT "\tfor (i=0;i<self->${mname}_size;i++) c->".$mname."[i]=self->".$mname."[i];"; print OUT "\tfor (i=0;i<self->${mname}_size;i++) c->".$mname."[i]=self->".$mname."[i];";
print OUT "}\n"; print OUT "}\n";
} }
} else { print OUT "\tc->$mname=self->$mname;\n\n"; } } else { print OUT "\tc->$mname=self->$mname;\n\n"; }
} }
print OUT "\treturn (grib_$class*)c;\n}\n\n" print OUT "\treturn (grib_$class*)c;\n}\n\n"
} }
} }
delete $delegates{init}; delete $delegates{init};
delete $delegates{post_init}; delete $delegates{post_init};
delete $delegates{destroy}; delete $delegates{destroy};
if(%delegates) if(%delegates)
{ {
print OUT "\n/* Start delegate methods */ \n"; 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 ) foreach my $d ( sort keys %delegates )
{ {
$delegates{$d} =~ /static\s+(.*)\s+(\w+)\s*\((.*)\)/; $delegates{$d} =~ /static\s+(.*)\s+(\w+)\s*\((.*)\)/;
my $return = $1 eq "void" ? "" : "return "; my $return = $1 eq "void" ? "" : "return ";
my $ret = $1; my $ret = $1;
my @args = map { s/^ +//; s/ +$//; $_; } split(",",$3); my @args = map { s/^ +//; s/ +$//; $_; } split(",",$3);
my $i = 0; my $i = 0;
my @types; my @types;
local $" = " "; local $" = " ";
foreach my $a ( @args ) foreach my $a ( @args )
{ {
my @x = split(" ",$a); my @x = split(" ",$a);
$a = $x[-1]; $a = $x[-1];
if(@x == 1 || $a =~ /\*$/) if(@x == 1 || $a =~ /\*$/)
{ {
$a = "arg" . $i++ ; $a = "arg" . $i++ ;
push @x,$a; push @x,$a;
} }
push @types, join(" ",@x); push @types, join(" ",@x);
$a =~ s/^\*//; $a =~ s/^\*//;
} }
local $" = ","; local $" = ",";
print OUT <<"EOF"; print OUT <<"EOF";
static $ret $d(@types) static $ret $d(@types)
{ {
${return}target($args[0])->$d(@args); ${return}target($args[0])->$d(@args);
} }
EOF EOF
} }
print OUT "\n/* End delegate methods */ \n"; print OUT "\n/* End delegate methods */ \n";
} }
close(CLASS); close(CLASS);
} }