#!/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(){ 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 || $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 = Net::ICal::icalvalue_new_from_string(\$Net::ICal::ICAL_${uc}_VALUE,\$v); if (\$new_value){ Net::ICal::icalvalue_free(\$self->[0]); \$self->[0] = \$new_value; } } } sub get { my \$self = shift; my \$impl = \$self->[0]; if (defined \$impl){ return Net::ICal::icalvalue_as_ical_string(\$impl); } } EOM } } if ($opt_p) { print "1;\n"; } if ($opt_h){ print <stats
Commit message (Expand)AuthorAgeFilesLines
* accessibility/accerciser: fix packaging with python 3.7rm2018-12-131-0/+14
* The FreeBSD GNOME team proudly presents GNOME 3.28 for FreeBSD.kwm2018-09-304-34/+10
* - Add LICENSEamdmi32018-02-141-3/+4
* Cleanup Mk/Uses/gnome.mk.mat2018-01-031-1/+1
* Convert Python ports to FLAVORS.mat2017-11-30