aboutsummaryrefslogtreecommitdiffstats
path: root/libical/scripts/mkderivedproperties.pl
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2001-04-18 01:54:48 +0800
committerJP Rosevear <jpr@src.gnome.org>2001-04-18 01:54:48 +0800
commite6f1da7f4681def1f8b0472a504dda549f9f4b89 (patch)
tree20975542002d583663c5c728e9f3cde0bd61573f /libical/scripts/mkderivedproperties.pl
parent3a49d3e43d8e752162e5c4a098e1c0991a7611db (diff)
downloadgsoc2013-evolution-e6f1da7f4681def1f8b0472a504dda549f9f4b89.tar
gsoc2013-evolution-e6f1da7f4681def1f8b0472a504dda549f9f4b89.tar.gz
gsoc2013-evolution-e6f1da7f4681def1f8b0472a504dda549f9f4b89.tar.bz2
gsoc2013-evolution-e6f1da7f4681def1f8b0472a504dda549f9f4b89.tar.lz
gsoc2013-evolution-e6f1da7f4681def1f8b0472a504dda549f9f4b89.tar.xz
gsoc2013-evolution-e6f1da7f4681def1f8b0472a504dda549f9f4b89.tar.zst
gsoc2013-evolution-e6f1da7f4681def1f8b0472a504dda549f9f4b89.zip
Finish merge of new libical 0.23a version
2001-04-17 JP Rosevear <jpr@ximian.com> * Finish merge of new libical 0.23a version svn path=/trunk/; revision=9420
Diffstat (limited to 'libical/scripts/mkderivedproperties.pl')
-rwxr-xr-xlibical/scripts/mkderivedproperties.pl308
1 files changed, 117 insertions, 191 deletions
diff --git a/libical/scripts/mkderivedproperties.pl b/libical/scripts/mkderivedproperties.pl
index 9778c30a77..4e011e112e 100755
--- a/libical/scripts/mkderivedproperties.pl
+++ b/libical/scripts/mkderivedproperties.pl
@@ -1,44 +1,16 @@
#!/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;
-}
+require "readvaluesfile.pl";
-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 $mode = shift @v;
- my $type = shift @v;
- my $comment = join(" ",@v);
+use Getopt::Std;
+getopts('chspmi:');
- $valuemap{$value} = $type;
+# ARG 0 is properties.csv
+%propmap = read_properties_file($ARGV[0]);
-}
+# ARG 1 is value-types.txt
+%valuemap = read_values_file($ARGV[1]);
-close F;
# Write the file inline by copying everything before a demarcation
# line, and putting the generated data after the demarcation
@@ -57,78 +29,128 @@ if ($opt_i) {
}
- 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_h or $opt_s) and !$opt_i ){
+sub fudge_data {
+ my $prop = shift;
+
+ my $value = $propmap{$prop}->{'lic_value'};
+
+ 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);
-print <<EOM;
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalderivedproperties.{c,h}
- CREATOR: eric 09 May 1999
+ my $type = $valuemap{$value}->{C}->[1];
+
+ return ($uc,$lc,$lcvalue,$ucvalue,$type);
+
+}
+
+# Create the property map data
+if($opt_c){
+
+ print "static struct icalproperty_map property_map[] = {\n";
- \044Id:\044
+ foreach $prop (sort keys %propmap) {
+
+ next if !$prop;
+
+ next if $prop eq 'NO';
+
+ my ($uc,$lc,$lcvalue,$ucvalue,$type) = fudge_data($prop);
+
+ print "{ICAL_${uc}_PROPERTY,\"$prop\",ICAL_${ucvalue}_VALUE},\n";
- (C) COPYRIGHT 1999 Eric Busboom
- http://www.softwarestudio.org
+ }
+
+ $prop = "NO";
+
+ my ($uc,$lc,$lcvalue,$ucvalue,$type) = fudge_data($prop);
+
+ print "{ICAL_${uc}_PROPERTY,\"\",ICAL_NO_VALUE}};\n\n";
- 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.
-
- ======================================================================*/
+ print "static struct icalproperty_enum_map enum_map[] = {\n";
-/*
- * THIS FILE IS MACHINE GENERATED. DO NOT EDIT
- */
+ $idx = 10000;
+ foreach $value (sort keys %valuemap) {
+
+ next if !$value;
+ next if $value eq 'NO' or $prop eq 'ANY';
-EOM
+ my $ucv = join("",map {uc(lc($_));} split(/-/,$value));
+ my @enums = @{$valuemap{$value}->{'enums'}};
-}
+ if(@enums){
+ my ($c_autogen,$c_type) = @{$valuemap{$value}->{'C'}};
+
+ unshift(@enums,"X");
+ push(@enums,"NONE");
-if ($opt_p and !$opt_i){
+ foreach $e (@enums) {
-print <<EOM;
+ my $uce = join("",map {uc(lc($_));} split(/-/,$e));
+
+ if($e ne "X" and $e ne "NONE"){
+ $str = $e;
+ } else {
+ $str = "";
+ }
+
+ print " {ICAL_${ucv}_PROPERTY,ICAL_${ucv}_${uce},\"$str\" }, /*$idx*/\n";
+
+ $idx++;
+ }
+
+ }
+ }
+ print " {ICAL_NO_PROPERTY,0,\"\"}\n};\n\n";
-EOM
}
-foreach $prop (keys %propmap) {
- next if !$prop;
+if($opt_h){
- my $value = $propmap{$prop};
+ # Create the property enumerations list
+ print "typedef enum icalproperty_kind {\n ICAL_ANY_PROPERTY = 0,\n";
+ foreach $prop (sort keys %propmap) {
+
+ next if !$prop;
+
+ next if $prop eq 'NO' or $prop eq 'ANY';
+
+ my ($uc,$lc,$lcvalue,$ucvalue,$type) = fudge_data($prop);
+
+ print " ICAL_${uc}_PROPERTY, \n";
+
+ }
+ print " ICAL_NO_PROPERTY\n} icalproperty_kind;\n\n";
- 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};
+foreach $prop (sort keys %propmap) {
+
+ next if !$prop;
+
+ next if $prop eq 'NO' or $prop eq 'ANY';
+
+ my ($uc,$lc,$lcvalue,$ucvalue,$type) = fudge_data($prop);
+
my $pointer_check;
if ($type =~ /\*/){
@@ -142,150 +164,54 @@ foreach $prop (keys %propmap) {
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* 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, ...)
-{
+icalproperty* icalproperty_vanew_${lc}($type v, ...){
va_list args;
- struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_${uc}_PROPERTY);
- $pointer_check
-
+ 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)
-{
+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)
-{
+$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
+ print "\
+/* $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);";
-} 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
+print "\n\n#endif /*ICALPROPERTY_H*/\n"
}