From d6b0035a325d060d7f175705c33b0a2d7b60e533 Mon Sep 17 00:00:00 2001 From: Eric Busboom Date: Mon, 15 May 2000 06:18:21 +0000 Subject: reparing damage from removing files svn path=/trunk/; revision=3042 --- libical/scripts/.cvsignore | 2 + libical/scripts/Makefile.am | 8 + libical/scripts/mkderivedcomponents.pl | 170 ++++++++++++++++ libical/scripts/mkderivedparameters.pl | 277 ++++++++++++++++++++++++++ libical/scripts/mkderivedproperties.pl | 286 +++++++++++++++++++++++++++ libical/scripts/mkderivedvalues.pl | 303 +++++++++++++++++++++++++++++ libical/scripts/mkparameterrestrictions.pl | 85 ++++++++ libical/scripts/mkrestrictionrecords.pl | 109 +++++++++++ libical/scripts/mkrestrictiontable.pl | 86 ++++++++ 9 files changed, 1326 insertions(+) create mode 100644 libical/scripts/.cvsignore create mode 100644 libical/scripts/Makefile.am create mode 100755 libical/scripts/mkderivedcomponents.pl create mode 100755 libical/scripts/mkderivedparameters.pl create mode 100755 libical/scripts/mkderivedproperties.pl create mode 100755 libical/scripts/mkderivedvalues.pl create mode 100755 libical/scripts/mkparameterrestrictions.pl create mode 100755 libical/scripts/mkrestrictionrecords.pl create mode 100755 libical/scripts/mkrestrictiontable.pl (limited to 'libical/scripts') diff --git a/libical/scripts/.cvsignore b/libical/scripts/.cvsignore new file mode 100644 index 0000000000..b840c21800 --- /dev/null +++ b/libical/scripts/.cvsignore @@ -0,0 +1,2 @@ +Makefile.in +Makefile \ No newline at end of file diff --git a/libical/scripts/Makefile.am b/libical/scripts/Makefile.am new file mode 100644 index 0000000000..fd1b053cb6 --- /dev/null +++ b/libical/scripts/Makefile.am @@ -0,0 +1,8 @@ +EXTRA_DIST = \ +mkderivedcomponents.pl \ +mkderivedparameters.pl \ +mkderivedproperties.pl \ +mkderivedvalues.pl \ +mkparameterrestrictions.pl \ +mkrestrictionrecords.pl \ +mkrestrictiontable.pl diff --git a/libical/scripts/mkderivedcomponents.pl b/libical/scripts/mkderivedcomponents.pl new file mode 100755 index 0000000000..ac4e472250 --- /dev/null +++ b/libical/scripts/mkderivedcomponents.pl @@ -0,0 +1,170 @@ +#!/usr/local/bin/perl + +use Getopt::Std; +getopts('chspi:'); + + +# ARG 0 is components.txt +open(PV,"$ARGV[0]") || die "Can't open components file $ARGV[0]:$!"; + +my @components; + +while (){ + + s/#.*//; + + chop; + + push(@components,$_); + +} + +close PV; + +# 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_i){ + 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 < /* for va_arg functions */ + +EOM + +} + +if ($opt_p and !$opt_i){ + +print <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 <){ + + 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 < generate c code file +# h-> generate header file +# s -> generate switch statement + +# Open with value-c-types.txt + + +open(F,"$ARGV[0]") || die "Can't open values data 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; + + } + + print "/* Everything below this line is machine generated. Do not edit. */\n"; + +} + + +if (($opt_c || $opt_h) and !$opt_i) { +print < 'int', + CALADDRESS=>'string', + DATE=>'time', + DATETIME=>'time', + DATETIMEDATE=>'time', + DATETIMEPERIOD=>'period', + DURATION=>'duration', + INTEGER=>'int', + TEXT=>'string', + URI=>'string', + UTCOFFSET=>'int', + QUERY=>'string', + BINARY=>'string' + ); + +while() +{ + + chop; + my @v = split(/\t+/,$_); + + my $value = shift @v; + my $type = shift @v; + my $comment = join(" ",@v); + + my $ucf = join("",map {ucfirst(lc($_));} split(/-/,$value)); + + my $lc = lc($ucf); + my $uc = uc($lc); + + my $pointer_check = "icalerror_check_arg_rz( (v!=0),\"v\");\n" if $type =~ /\*/; + my $pointer_check_rv = "icalerror_check_arg_rv( (v!=0),\"v\");\n" if $type =~ /\*/; + + my $assign; + + if ($type =~ /char/){ + $assign = "strdup(v);\n\n if (impl->data.v_string == 0){\n errno = ENOMEM;\n }\n"; + } else { + $assign = "v;"; + } + + my $union_data; + + if (exists $union_map{$uc} ){ + $union_data=$union_map{$uc}; + } else { + $union_data = $lc; + } + + if ($opt_c) { +print <data.v_${union_data} = $assign +} + +$type +icalvalue_get_${lc}(icalvalue* value) +{ + icalerror_check_arg( (value!=0),"value"); + icalerror_check_value_type(value, ICAL_${uc}_VALUE); + + return ((struct icalvalue_impl*)value)->data.v_${union_data}; +} + +EOM + +} elsif($opt_h) { + + print <data.v_${union_data} + + str = strdup(temp); + + return str; +} + +EOM + +} +} elsif ($opt_p) { # Generate perl code + +print <[0] = \$p; + + return \$self; +} + +sub set +{ + my \$self = shift; + my \$v = shift; + + my \$impl = \$self->_impl(); + + if (\$v) { + my \$new_value = ICal::icalvalue_new_from_string(\$ICal::ICAL_${uc}_VALUE,\$v); + if (\$new_value){ + ICal::icalvalue_free(\$self->[0]); + \$self->[0] = \$new_value; + } + + } + +} + +sub get +{ + my \$self = shift; + my \$impl = \$self->[0]; + + if (defined \$impl){ + + return ICal::icalvalue_as_ical_string(\$impl); + + } +} + +EOM +} + + + +} + +if ($opt_p) +{ + print "1;\n"; +} + + +if ($opt_h){ + +print < + + +# usually open params-in-prop.txt +open(F,"$ARGV[0]") || die "Can't open restriction file $ARGV[0]:$!"; + +print <) +{ + chop; + + # split line by whitespace + my @v = split(/\s+/,$_); + # property is first item on line + my $prop = shift @v; + my $prop_name = $prop; + if (substr($prop,0,1) eq "X") { $prop = "X"; } + $prop = join("",split(/-/,$prop)); + +print < + +# usually open restrictions.csv +open(F,"$ARGV[0]") || die "Can't open restriction file $ARGV[0]:$!"; + +print <) +{ + chop; + + # split line at commas + my ($method,$component,$property,$subcomponent,$restriction)=split(/\,/,$_); + + # + #put in code to generate comments here! + # + if ($method ne $last_method) + { + $need_header = 1; + $last_method = $method; + } + if ($component ne $last_component) + { + $need_header = 1; + $last_component = $component; + } + + if ($need_header) + { + print "\n\t/* METHOD: ${method}, COMPONENT: ${component} */\n"; + $need_header = 0; + } + + foreach $item ($component,$property,$subcomponent,$restriction) + { + # handle special cases. + if ($item eq "NONE") + { $item = "NO"; } + else { if (substr($item,0,1) eq "X") + { $item = "X"; }} + + # strip out dashes + $item = join("",split(/-/,$item)); + } + # strip leading V from component names + $component =~ s/^(V?)(\w+?)((SAVINGS)?)((TIME)?)$/$2/; + $subcomponent =~ s/^V(\w+)/$1/; + + print "\t\{ICAL_METHOD_${method},ICAL_${component}_COMPONENT,"; + print "ICAL_${property}_PROPERTY,ICAL_${subcomponent}_COMPONENT,"; + print "ICAL_RESTRICTION_${restriction}\},\n"; + +} + +print <){ + + if (/Do not edit/){ + last; + } + + print; + + } + + print "/* Everything below this line is machine generated. Do not edit. */\n"; + + + close IN; +} + +print "icalrestriction_property_record icalrestriction_property_records[] = {\n"; + +while() +{ + + chop; + + s/\#.*$//; + + my($method,$targetcomp,$prop,$subcomp,$restr,$sub) = split(/,/,$_); + + next if !$method; + + if(!$sub) { + $sub = "0"; + } + + if($prop ne "NONE"){ + print(" \{ICAL_METHOD_${method},ICAL_${targetcomp}_COMPONENT,ICAL_${prop}_PROPERTY,ICAL_RESTRICTION_${restr},$sub\},\n"); + } + +} + + +print " {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_PROPERTY,ICAL_RESTRICTION_NONE}\n"; + +print "};\n"; + +print "icalrestriction_component_record icalrestriction_component_records[] = {\n"; + + +close(F); +open(F,"$ARGV[0]") || die "Can't open restriction data file $ARGV[0]:$!"; + +while() +{ + + chop; + + s/\#.*$//; + + my($method,$targetcomp,$prop,$subcomp,$restr) = split(/,/,$_); + + next if !$method; + + + if($subcomp ne "NONE"){ + print(" \{ICAL_METHOD_${method},ICAL_${targetcomp}_COMPONENT,ICAL_${subcomp}_COMPONENT,ICAL_RESTRICTION_${restr}\},\n"); + } + +} + +print " {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_COMPONENT,ICAL_RESTRICTION_NONE}\n"; +print "};\n"; -- cgit