#!/usr/local/bin/perl use Getopt::Std; getopts('chspi:'); %no_xname = (RELATED=>1,RANGE=>1,RSVP=>1,XLICERRORTYPE=>1,XLICCOMPARETYPE=>1); # Usually, open param-c-types.txt open(F,"$ARGV[0]") || die "Can't open C parameter types file $ARGV[0]:$!"; # Write the file inline by copying everything before a demarcation # line, and putting the generated data after the demarcation if ($opt_i) { open(IN,$opt_i) || die "Can't open input file $opt_i"; while(){ if (/Do not edit/){ last; } print; } if($opt_p){ 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"; } } if (($opt_c or $opt_h) and !$opt_i) { print <){ chop; my ($param,$type) = split(/\s{2,}/,$_); my $ucf = join("",map {ucfirst(lc($_));} split(/-/,$param)); my $lc = lc($ucf); my $uc = uc($lc); my $lctype = lc($type); my $charorenum; my $set_code; my $pointer_check; my $new_pointer_check; my $new_pointer_check_v; my $xrange; if ($type=~/char/){ $new_pointer_check = "icalerror_check_arg_rz( (v!=0),\"v\");"; $new_pointer_check_v = "icalerror_check_arg_rv( (v!=0),\"v\");"; } if ($type=~/char/ ) { $charorenum = " icalerror_check_arg_rz( (param!=0), \"param\");\n return ((struct icalparameter_impl*)param)->string;"; $pointer_check = "icalerror_check_arg_rz( (v!=0),\"v\");"; $set_code = "((struct icalparameter_impl*)param)->string = strdup(v);" } else { $xrange =" if ( ((struct icalparameter_impl*)param)->string != 0){\n return ICAL_${uc}_XNAME;\n }\n" if !exists $no_xname{$uc}; $charorenum=<data.v_${lc}; EOM $pointer_check = "icalerror_check_arg( (v!=0),\"v\");"; $set_code = "((struct icalparameter_impl*)param)->data.v_${lc} = v;"; $print_code = "switch (impl->data.v_${lc}) {\ncase ICAL_${uc}_: {\n}\ncase ICAL_${uc}_XNAME: /* Fall Through */\n}\n"; } if ($opt_c) { print <[0] = \$p; return \$self; } sub get { my \$self = shift; my \$impl = \$self->_impl(); return Net::ICal::icalparameter_as_ical_string(\$impl); } sub set { # This is hard to implement, so I've punted for now. die "Set is not implemented"; } EOM } } if ($opt_h){ print <