#!/usr/local/bin/perl use Getopt::Std; getopts('chsypmi:'); # ARG 0 is prop-to-value open(PV,"$ARGV[0]") || die "Can't open prop to value file $ARGV[0]:$!"; while (){ chop; my @v = split(/\s+/,$_); my $prop = shift @v; my $value = shift @v; my $comment = join(" ",@v); $propmap{$prop} = $value; } close PV; # ARG 1 is value-c-types.txt open(F,"$ARGV[1]") || die "Can't open C parameter types file $ARGV[1 ]:$!"; while (){ chop; my @v = split(/\t+/,$_); my $value = shift @v; my $type = shift @v; my $comment = join(" ",@v); $valuemap{$value} = $type; } close F; # 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; } print "/* Everything below this line is machine generated. Do not edit. */\n"; } if ( ($opt_h or $opt_s) and !$opt_i ){ print <_add_elements(\\\@_); return bless \$self, \$package; } sub set_value { my \$self = shift; my \$v = shift; my \$impl = \$self->_impl(); if ( ref \$v && Net::ICal::icalvalue_isa_value(\$v->_impl())){ Net::ICal::icalproperty_set_value(\$impl,\$v->_impl); } else { my \$value = Net::ICal::icalvalue_new_from_string(\$Net::ICal::ICAL_${ucvalue}_VALUE,\$v); die if !\$impl; Net::ICal::icalproperty_set_value(\$impl,\$value) unless !\$value; } } sub get_value { my \$self = shift; my \$impl = \$self->_impl(); if (defined \$impl){ my \$value = Net::ICal::icalproperty_get_value(\$impl); return "" if !\$value; return Net::ICal::icalvalue_as_ical_string(\$value); } else { return ""; } } EOM } elsif ($opt_m) { # Generate a map print "\'${uc}\' => \'Net::ICal::Property::${ucf},\'\n"; } } # This brace terminates the main loop # Add things to the end of the output. if ($opt_p) { print "1;\n"; } if ($opt_h){ print <