diff options
author | Eric Busboom <ericb@src.gnome.org> | 2000-05-15 14:18:21 +0800 |
---|---|---|
committer | Eric Busboom <ericb@src.gnome.org> | 2000-05-15 14:18:21 +0800 |
commit | d6b0035a325d060d7f175705c33b0a2d7b60e533 (patch) | |
tree | 2ee94e89f94b416cc04a3e8860b1205377397fde /libical/scripts | |
parent | f8ff932ae3149c285acea3977a50596749d38584 (diff) | |
download | gsoc2013-evolution-d6b0035a325d060d7f175705c33b0a2d7b60e533.tar gsoc2013-evolution-d6b0035a325d060d7f175705c33b0a2d7b60e533.tar.gz gsoc2013-evolution-d6b0035a325d060d7f175705c33b0a2d7b60e533.tar.bz2 gsoc2013-evolution-d6b0035a325d060d7f175705c33b0a2d7b60e533.tar.lz gsoc2013-evolution-d6b0035a325d060d7f175705c33b0a2d7b60e533.tar.xz gsoc2013-evolution-d6b0035a325d060d7f175705c33b0a2d7b60e533.tar.zst gsoc2013-evolution-d6b0035a325d060d7f175705c33b0a2d7b60e533.zip |
reparing damage from removing files
svn path=/trunk/; revision=3042
Diffstat (limited to 'libical/scripts')
-rw-r--r-- | libical/scripts/.cvsignore | 2 | ||||
-rw-r--r-- | libical/scripts/Makefile.am | 8 | ||||
-rwxr-xr-x | libical/scripts/mkderivedcomponents.pl | 170 | ||||
-rwxr-xr-x | libical/scripts/mkderivedparameters.pl | 277 | ||||
-rwxr-xr-x | libical/scripts/mkderivedproperties.pl | 286 | ||||
-rwxr-xr-x | libical/scripts/mkderivedvalues.pl | 303 | ||||
-rwxr-xr-x | libical/scripts/mkparameterrestrictions.pl | 85 | ||||
-rwxr-xr-x | libical/scripts/mkrestrictionrecords.pl | 109 | ||||
-rwxr-xr-x | libical/scripts/mkrestrictiontable.pl | 86 |
9 files changed, 1326 insertions, 0 deletions
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 (<PV>){ + + 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(<IN>){ + + 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 <<EOM; +/* -*- Mode: C -*- + ====================================================================== + FILE: icalderivedproperties.{c,h} + CREATOR: eric 09 May 1999 + + \044Id:\044 + + (C) COPYRIGHT 1999 Eric Busboom + http://www.softwarestudio.org + + The contents of this file are subject to the Mozilla Public License + Version 1.0 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and + limitations under the License. + + + ======================================================================*/ + +/* + * THIS FILE IS MACHINE GENERATED DO NOT EDIT + */ + +#include <stdarg.h> /* for va_arg functions */ + +EOM + +} + +if ($opt_p and !$opt_i){ + +print <<EOM; + +EOM + +} + + +foreach $comp (@components) { + + next if !$comp; + + my $ucf = join("",map {ucfirst(lc($_));} split(/-/,$comp)); + my $lc = lc($ucf); + my $uc = uc($lc); + + if($opt_c) { # Make C source + print<<EOM; + +/* $comp */ + +icalcomponent* icalcomponent_new_${lc}() +{ + return (icalcomponent*)icalcomponent_new_impl(ICAL_${uc}_COMPONENT); +} + +icalcomponent* icalcomponent_vanew_${lc}(...) +{ + va_list args; + struct icalcomponent_impl *impl = icalcomponent_new_impl(ICAL_${uc}_component); + + va_start(args,v); + icalcomponent_add_properties(impl, args); + va_end(args); + + return (icalcomponent*)impl; +} + +EOM + + + } elsif ($opt_h) { # Make a C header + print<<EOM; + +/* $comp */ +icalcomponent* icalcomponent_new_${lc}(); +icalcomponent* icalcomponent_vanew_${lc}(...); +EOM + +} elsif ($opt_s) { # Make something for a switch statement + +print <<EOM; +case ICAL_${uc}_PROPERTY: +EOM + +} elsif ($opt_p) { # make perl source + +print <<EOM; + +# $comp +package Net::ICal::Component::${ucf}; +\@ISA=qw(Net::ICal::Component); + +sub new +{ + my \$package = shift; + my \$c = Net::ICal::icalcomponent_new(\$Net::ICal::ICAL_${uc}_COMPONENT); + + my \$self = Net::ICal::Component::new_from_ref(\$c); + Net::ICal::Component::_add_elements(\$self,\\\@_); + + # Self is blessed in new_from_ref + + return \$self; + +} +EOM + +} + + + +} + + diff --git a/libical/scripts/mkderivedparameters.pl b/libical/scripts/mkderivedparameters.pl new file mode 100755 index 0000000000..2b505c878a --- /dev/null +++ b/libical/scripts/mkderivedparameters.pl @@ -0,0 +1,277 @@ +#!/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(<IN>){ + + 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 <<EOM; +/* -*- Mode: C -*- + ====================================================================== + FILE: icalderivedparameters.{c,h} + CREATOR: eric 09 May 1999 + + \044Id: mkderivedparameters.pl,v 1.1 1999/05/14 07:04:31 eric Exp eric \044 + \044Locker: eric \044 + + (C) COPYRIGHT 1999 Eric Busboom + http://www.softwarestudio.org + + The contents of this file are subject to the Mozilla Public License + Version 1.0 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and + limitations under the License. + + + ======================================================================*/ + +/* + * THIS FILE IS MACHINE GENERATED DO NOT EDIT + */ + + +EOM + +} + +if ($opt_p and !$opt_i){ + +print <<EOM; +# -*- Mode: Perl -*- +# ====================================================================== +# \044Id:\044 +# +# (C) COPYRIGHT 1999 Eric Busboom +# http://www.softwarestudio.org +# +# The contents of this file are subject to the Mozilla Public License +# Version 1.0 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and +# limitations under the License. +# +# The original author is Eric Busboom +# The original code is derivedparams.h +# +# ======================================================================*/ + +EOM + +} + + +while(<F>){ + + 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=<<EOM; + icalerror_check_arg( (param!=0), \"param\"); +$xrange + return ((struct icalparameter_impl*)param)->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 <<EOM; +/* $param */ +icalparameter* icalparameter_new_${lc}($type v) +{ + struct icalparameter_impl *impl; + icalerror_clear_errno(); + $new_pointer_check + impl = icalparameter_new_impl(ICAL_${uc}_PARAMETER); + if (impl == 0) { + return 0; + } + + icalparameter_set_${lc}((icalparameter*) impl,v); + if (icalerrno != ICAL_NO_ERROR) { + icalparameter_free((icalparameter*) impl); + return 0; + } + + return (icalparameter*) impl; +} + +${type} icalparameter_get_${lc}(icalparameter* param) +{ + icalerror_clear_errno(); +$charorenum +} + +void icalparameter_set_${lc}(icalparameter* param, ${type} v) +{ + $new_pointer_check_v + icalerror_check_arg_rv( (param!=0), "param"); + icalerror_clear_errno(); + + $set_code +} + +EOM + + } elsif( $opt_h) { + + print <<EOM; +/* $param */ +icalparameter* icalparameter_new_${lc}($type v); +${type} icalparameter_get_${lc}(icalparameter* value); +void icalparameter_set_${lc}(icalparameter* value, ${type} v); + +EOM + +} elsif ($opt_s) { + +next if $type =~ /char/; + +print<<EOM; +case ICAL_${uc}_PARAMETER: +{ + $print_code +} +EOM + +} + + if ($opt_p) { + + print <<EOM; + +# $param + +package Net::ICal::Parameter::${ucf}; +\@ISA=qw(Net::ICal::Parameter); + +sub new +{ + my \$self = []; + my \$package = shift; + my \$value = shift; + + bless \$self, \$package; + + my \$p; + + if (\$value) { + \$p = Net::ICal::icalparameter_new_from_string(\$Net::ICal::ICAL_${uc}_PARAMETER,\$value); + } else { + \$p = Net::ICal::icalparameter_new(\$Net::ICal::ICAL_${uc}_PARAMETER); + } + + \$self->[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 <<EOM; +#endif ICALPARAMETER_H +EOM +} diff --git a/libical/scripts/mkderivedproperties.pl b/libical/scripts/mkderivedproperties.pl new file mode 100755 index 0000000000..f3c94f2cfd --- /dev/null +++ b/libical/scripts/mkderivedproperties.pl @@ -0,0 +1,286 @@ +#!/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 (<PV>){ + + 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 (<F>){ + + 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(<IN>){ + + 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 <<EOM; +/* -*- Mode: C -*- + ====================================================================== + FILE: icalderivedproperties.{c,h} + CREATOR: eric 09 May 1999 + + \044Id:\044 + + (C) COPYRIGHT 1999 Eric Busboom + http://www.softwarestudio.org + + The contents of this file are subject to the Mozilla Public License + Version 1.0 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and + limitations under the License. + + + ======================================================================*/ + +/* + * THIS FILE IS MACHINE GENERATED. DO NOT EDIT + */ + + +EOM + +} + + +if ($opt_p and !$opt_i){ + +print <<EOM; + +EOM + +} + +foreach $prop (keys %propmap) { + + next if !$prop; + + my $value = $propmap{$prop}; + + if (!$value){ + die "Can't find value for property \"$prop\"\n"; + } + + my $ucf = join("",map {ucfirst(lc($_));} split(/-/,$prop)); + my $lc = lc($ucf); + my $uc = uc($lc); + + my $ucfvalue = join("",map {ucfirst(lc($_));} split(/-/,$value)); + my $lcvalue = lc($ucfvalue); + my $ucvalue = uc($lcvalue); + + my $type = $valuemap{$value}; + + my $pointer_check; + if ($type =~ /\*/){ + $pointer_check = "icalerror_check_arg_rz( (v!=0),\"v\");\n" if $type =~ /\*/; + } elsif ( $type eq "void" ){ + $pointer_check = "icalerror_check_arg_rv( (v!=0),\"v\");\n" if $type =~ /\*/; + + } + + my $set_pointer_check = "icalerror_check_arg_rv( (v!=0),\"v\");\n" if $type =~ /\*/; + + if($opt_c) { # Generate C source + print<<EOM; + +/* $prop */ + +icalproperty* icalproperty_new_${lc}($type v) +{ + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_${uc}_PROPERTY); + $pointer_check + + icalproperty_set_${lc}((icalproperty*)impl,v); + + return (icalproperty*)impl; +} + +icalproperty* icalproperty_vanew_${lc}($type v, ...) +{ + va_list args; + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_${uc}_PROPERTY); + $pointer_check + + icalproperty_set_${lc}((icalproperty*)impl,v); + + va_start(args,v); + icalproperty_add_parameters(impl, args); + va_end(args); + + return (icalproperty*)impl; +} + +void icalproperty_set_${lc}(icalproperty* prop, $type v) +{ + icalvalue *value; + + $set_pointer_check + icalerror_check_arg_rv( (prop!=0),"prop"); + + value = icalvalue_new_${lcvalue}(v); + + icalproperty_set_value(prop,value); + +} + +$type icalproperty_get_${lc}(icalproperty* prop) +{ + icalvalue *value; + icalerror_check_arg( (prop!=0),"prop"); + + value = icalproperty_get_value(prop); + + return icalvalue_get_${lcvalue}(value); +} +EOM + + + } elsif ($opt_h) { # Generate C Header file + print<<EOM; + +/* $prop */ +icalproperty* icalproperty_new_${lc}($type v); +icalproperty* icalproperty_vanew_${lc}($type v, ...); +void icalproperty_set_${lc}(icalproperty* prop, $type v); +$type icalproperty_get_${lc}(icalproperty* prop); +EOM + +} elsif ($opt_s) { # Generate case in a switch statement + +print <<EOM; +case ICAL_${uc}_PROPERTY: +EOM + + +} elsif ($opt_p) { # Generate perl code + +print <<EOM; + +package Net::ICal::Property::${ucf}; +use Net::ICal::Property; +\@ISA=qw(Net::ICal::Property); +sub new +{ + my \$package = shift; + + my \$p = Net::ICal::icalproperty_new(\$Net::ICal::ICAL_${uc}_PROPERTY); + my \$self = Net::ICal::Property::new_from_ref(\$p); + + \$self->_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 <<EOM; +#endif ICALPROPERTY_H +EOM +} + diff --git a/libical/scripts/mkderivedvalues.pl b/libical/scripts/mkderivedvalues.pl new file mode 100755 index 0000000000..a0909a6d94 --- /dev/null +++ b/libical/scripts/mkderivedvalues.pl @@ -0,0 +1,303 @@ +#!/usr/bin/perl + + +use Getopt::Std; +getopts('chspi:'); + +#Options +# c -> 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(<IN>){ + + 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 <<EOM; +/* -*- Mode: C -*- + ====================================================================== + FILE: icalderivedvalues.{c,h} + CREATOR: eric 09 May 1999 + + \044Id:\044 + + (C) COPYRIGHT 1999 Eric Busboom + http://www.softwarestudio.org + + The contents of this file are subject to the Mozilla Public License + Version 1.0 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and + limitations under the License. + + ======================================================================*/ + +/* + * THIS FILE IS MACHINE GENERATED DO NOT EDIT + */ + + + +EOM +} + +if ($opt_p and !$opt_i){ + +print <<EOM; +# -*- Mode: Perl -*- +# ====================================================================== +# \044Id:\044 +# +# (C) COPYRIGHT 1999 Eric Busboom +# http://www.softwarestudio.org +# +# The contents of this file are subject to the Mozilla Public License +# Version 1.0 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and +# limitations under the License. +# +# The original author is Eric Busboom +# The original code is derivedvalues.h +# +# ======================================================================*/ + +EOM + +} + +# Map type names to the value in the icalvalue_impl data union */ + +%union_map = ( + BOOLEAN => '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(<F>) +{ + + 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 <<EOM; + +icalvalue* +icalvalue_new_${lc} ($type v) +{ + struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_${uc}_VALUE); + + $pointer_check + icalvalue_set_${lc}((icalvalue*)impl,v); + + return (icalvalue*)impl; +} + +void +icalvalue_set_${lc}(icalvalue* value, $type v) +{ + struct icalvalue_impl* impl; + + icalerror_check_arg_rv( (value!=0),"value"); + $pointer_check_rv + icalerror_check_value_type(value, ICAL_${uc}_VALUE); + + impl = (struct icalvalue_impl*)value; + impl->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 <<EOM; +/* $value $comment */ +icalvalue* icalvalue_new_${lc}($type v); +$type icalvalue_get_${lc}(icalvalue* value); +void icalvalue_set_${lc}(icalvalue* value, ${type} v); + +EOM + +} elsif ($opt_s) { + +if ( $ud{$union_data}++ == 0) { + +print<<EOM; +char* icalvalue_${union_data}_as_ical_string(icalvalue* value) { + + $type data; + char temp[1024]; + char *str; + icalerror_check_arg( (value!=0),"value"); + data = ((struct icalvalue_impl*)value)->data.v_${union_data} + + str = strdup(temp); + + return str; +} + +EOM + +} +} elsif ($opt_p) { # Generate perl code + +print <<EOM; + +package ICal::Value::${ucf}; +use ICal::Value; +\@ISA=qw(ICal::Value); +sub new +{ + my \$self = []; + my \$package = shift; + my \$value = shift; + + bless \$self, \$package; + + my \$p; + + if (\$value){ + \$p = ICal::icalvalue_new_from_string(\$ICal::ICAL_${uc}_VALUE,\$value); + } else { + \$p = ICal::icalvalue_new(\$ICal::ICAL_${uc}_VALUE); + } + + \$self->[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 <<EOM; +#endif ICALVALUE_H +EOM +} + + +__END__ + diff --git a/libical/scripts/mkparameterrestrictions.pl b/libical/scripts/mkparameterrestrictions.pl new file mode 100755 index 0000000000..2c57eb4ca5 --- /dev/null +++ b/libical/scripts/mkparameterrestrictions.pl @@ -0,0 +1,85 @@ +#!/usr/bin/perl + +# Version: 1.0 +# Script last updated: 30May1999 GMD +# Change log: +# <none> + + +# usually open params-in-prop.txt +open(F,"$ARGV[0]") || die "Can't open restriction file $ARGV[0]:$!"; + +print <<EOM; +/* + ====================================================================== + File: parameterrestrictions.c + + (C) COPYRIGHT 1999 Graham Davison + mailto:g.m.davison\@computer.org + + The contents of this file are subject to the Mozilla Public License + Version 1.0 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and + limitations under the License. + + + ======================================================================*/ + +/* + * THIS FILE IS MACHINE GENERATED DO NOT EDIT + */ + + +int icalrestriction_is_parameter_allowed(icalproperty_kind prop,icalparameter_kind param) +{ + switch (prop) + { +EOM + +while(<F>) +{ + 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 <<EOM; + + /* ${prop_name} */ + case ICAL_${prop}_PROPERTY: + switch (param) + { +EOM + + foreach $param (@v) + { + $param = join("",split(/-/,$param)); + print "\t\t\t\tcase ICAL_${param}_PARAMETER:\n"; + } + +print <<EOM; + return 1; + default: + return 0; + } + +EOM + +} + +print <<EOM; + } + + return 0; +} +EOM diff --git a/libical/scripts/mkrestrictionrecords.pl b/libical/scripts/mkrestrictionrecords.pl new file mode 100755 index 0000000000..e2c62ae748 --- /dev/null +++ b/libical/scripts/mkrestrictionrecords.pl @@ -0,0 +1,109 @@ +#!/usr/bin/perl + +# Version: 1.0 +# Script last updated: 30May1999 GMD +# Change log: +# <none> + +# usually open restrictions.csv +open(F,"$ARGV[0]") || die "Can't open restriction file $ARGV[0]:$!"; + +print <<EOM; +/* + ====================================================================== + File: restrictionrecords.c + + (C) COPYRIGHT 1999 Graham Davison + mailto:g.m.davison\@computer.org + + The contents of this file are subject to the Mozilla Public License + Version 1.0 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and + limitations under the License. + + + ======================================================================*/ + + +/* + * THIS FILE IS MACHINE GENERATED DO NOT EDIT + */ + + +typedef struct icalrestriction_record { + icalproperty_method method; + icalcomponent_kind component; + icalproperty_kind property; + icalcomponent_kind subcomponent; + icalrestriction_kind restriction; +} icalrestriction_record; + + +icalrestriction_record icalrestriction_records[] = +{ +EOM + +my $last_method = ""; +my $last_component = ""; +my $last_property = ""; +my $need_header = 0; + +while(<F>) +{ + 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 <<EOM; + + /* END */ + {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_PROPERTY,ICAL_NO_COMPONENT,ICAL_RESTRICTION_NONE} +}; +EOM diff --git a/libical/scripts/mkrestrictiontable.pl b/libical/scripts/mkrestrictiontable.pl new file mode 100755 index 0000000000..c91f3d0bc4 --- /dev/null +++ b/libical/scripts/mkrestrictiontable.pl @@ -0,0 +1,86 @@ +#!/usr/bin/perl + +use Getopt::Std; +getopts('i:'); + +# the argument should be the path to the restriction datafile, usually +# design-data/restrictions.csv +open(F,"$ARGV[0]") || die "Can't open restriction 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(<IN>){ + + 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(<F>) +{ + + 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(<F>) +{ + + 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"; |