diff options
author | Hans Petter <hansp@src.gnome.org> | 2003-09-12 06:04:44 +0800 |
---|---|---|
committer | Hans Petter <hansp@src.gnome.org> | 2003-09-12 06:04:44 +0800 |
commit | 697761cc337aa77a47140c8df50ed84bc25e23f6 (patch) | |
tree | b785830f72e9938cceaa016a419c7b6d9892bada /libical/scripts/mkderivedparameters.pl | |
parent | 733d77e657516f9a59b5c1a7b62acb87b03ec86f (diff) | |
download | gsoc2013-evolution-697761cc337aa77a47140c8df50ed84bc25e23f6.tar gsoc2013-evolution-697761cc337aa77a47140c8df50ed84bc25e23f6.tar.gz gsoc2013-evolution-697761cc337aa77a47140c8df50ed84bc25e23f6.tar.bz2 gsoc2013-evolution-697761cc337aa77a47140c8df50ed84bc25e23f6.tar.lz gsoc2013-evolution-697761cc337aa77a47140c8df50ed84bc25e23f6.tar.xz gsoc2013-evolution-697761cc337aa77a47140c8df50ed84bc25e23f6.tar.zst gsoc2013-evolution-697761cc337aa77a47140c8df50ed84bc25e23f6.zip |
Import new libical from mainline HEAD and make appropriate changes to
Evolution.
svn path=/trunk/; revision=22538
Diffstat (limited to 'libical/scripts/mkderivedparameters.pl')
-rwxr-xr-x | libical/scripts/mkderivedparameters.pl | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/libical/scripts/mkderivedparameters.pl b/libical/scripts/mkderivedparameters.pl index 89f25306a5..5439509aa8 100755 --- a/libical/scripts/mkderivedparameters.pl +++ b/libical/scripts/mkderivedparameters.pl @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/env perl require "readvaluesfile.pl"; @@ -18,27 +18,24 @@ if ($opt_i) { open(IN,$opt_i) || die "Can't open input file $opt_i"; while(<IN>){ - - if (/Do not edit/){ - last; - } - - print; + if (/<insert_code_here>/){ + insert_code(); + } else { + print; + } } if($opt_p){ - print "# Everything below this line is machine generated. Do not edit. \n"; + print "# Everything below this line is machine generated. Do not edit. \n"; } else { print "/* Everything below this line is machine generated. Do not edit. */\n"; } } - -# Write parameter string map -if ($opt_c){ -} +sub insert_code +{ # Write parameter enumerations and datatypes @@ -108,21 +105,28 @@ if($opt_h){ if ($opt_c){ - # Create the icalparameter_value to icalvalue_kind conversion table - print "struct icalparameter_value_kind_map value_kind_map[] = {\n"; + # Create the icalparameter_value to icalvalue_kind conversion table + my $count = 0; + my $out; + foreach $enum (@{$params{'VALUE'}->{'enums'}}){ next if $enum eq 'NO' or $enum eq 'ERROR'; $uc = join("",map {uc(lc($_));} split(/-/,$enum)); - print " {ICAL_VALUE_${uc},ICAL_${uc}_VALUE},\n"; + $out.=" {ICAL_VALUE_${uc},ICAL_${uc}_VALUE},\n"; + $count++; } - + + $count+=2; + print "static struct icalparameter_value_kind_map value_kind_map[$count] = {\n"; + print $out; print " {ICAL_VALUE_X,ICAL_X_VALUE},\n"; print " {ICAL_VALUE_NONE,ICAL_NO_VALUE}\n};\n\n"; #Create the parameter Name map - print "static struct icalparameter_kind_map parameter_map[] = { \n"; + $out=""; + $count=0; foreach $param (sort keys %params) { next if !$param; @@ -132,18 +136,18 @@ if ($opt_c){ my $lc = join("",map {lc($_);} split(/-/,$param)); my $uc = join("",map {uc(lc($_));} split(/-/,$param)); - - print " {ICAL_${uc}_PARAMETER,\"$param\"},\n"; + $count++; + $out.=" {ICAL_${uc}_PARAMETER,\"$param\"},\n"; } - + $count+=1; + print "static struct icalparameter_kind_map parameter_map[$count] = { \n"; + print $out; print " { ICAL_NO_PARAMETER, \"\"}\n};\n\n"; # Create the parameter value map - - print "static struct icalparameter_map icalparameter_map[] = {\n"; - print "{ICAL_ANY_PARAMETER,0,\"\"},\n"; - + $out =""; + $count=0; foreach $param (sort keys %params) { next if !$param; @@ -159,12 +163,17 @@ if ($opt_c){ foreach $e (@enums){ my $uce = join("",map {uc(lc($_));} split(/-/,$e)); - print " {ICAL_${uc}_PARAMETER,ICAL_${uc}_${uce},\"$e\"},\n"; + $count++; + $out.=" {ICAL_${uc}_PARAMETER,ICAL_${uc}_${uce},\"$e\"},\n"; } } } + $count+=3; + print "static struct icalparameter_map icalparameter_map[] = {\n"; + print "{ICAL_ANY_PARAMETER,0,\"\"},\n"; + print $out; print " {ICAL_NO_PARAMETER,0,\"\"}};\n\n"; } @@ -186,20 +195,18 @@ foreach $param (keys %params){ if ($type=~/char/ ) { - $charorenum = " icalerror_check_arg_rz( (param!=0), \"param\");\n return ($type)((struct icalparameter_impl*)param)->string;"; + $charorenum = " icalerror_check_arg_rz( (param!=0), \"param\");\n return param->string;"; - $set_code = "if (((struct icalparameter_impl*)param)->string != 0)\n" . - " free((void *) ((struct icalparameter_impl*)param)->string);\n" . - " ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);"; + $set_code = "((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);"; $pointer_check = "icalerror_check_arg_rz( (v!=0),\"v\");"; $pointer_check_v = "icalerror_check_arg_rv( (v!=0),\"v\");"; } else { - $xrange =" if ( ((struct icalparameter_impl*)param)->string != 0){\n return ICAL_${uc}_X;\n }\n" if !exists $no_xname{$uc}; + $xrange =" if (param->string != 0){\n return ICAL_${uc}_X;\n }\n" if !exists $no_xname{$uc}; - $charorenum= "icalerror_check_arg( (param!=0), \"param\");\n$xrange\nreturn ($type)((struct icalparameter_impl*)param)->data;"; + $charorenum= "icalerror_check_arg( (param!=0), \"param\");\n$xrange\nreturn ($type)(param->data);"; $pointer_check = "icalerror_check_arg_rz(v >= ICAL_${uc}_X,\"v\");\n icalerror_check_arg_rz(v < ICAL_${uc}_NONE,\"v\");"; @@ -234,7 +241,7 @@ icalparameter* icalparameter_new_${lc}($type v) return (icalparameter*) impl; } -${type} icalparameter_get_${lc}(icalparameter* param) +${type} icalparameter_get_${lc}(const icalparameter* param) { icalerror_clear_errno(); $charorenum @@ -256,7 +263,7 @@ EOM print <<EOM; /* $param */ icalparameter* icalparameter_new_${lc}($type v); -${type} icalparameter_get_${lc}(icalparameter* value); +${type} icalparameter_get_${lc}(const icalparameter* value); void icalparameter_set_${lc}(icalparameter* value, ${type} v); EOM @@ -321,3 +328,5 @@ print <<EOM; EOM } + +} |