Changeset 5955
- Timestamp:
- Jan 9, 2006, 2:38:15 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/glueforge/glueforge.in (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/glueforge/glueforge.in
r5951 r5955 3 3 # Copyright (C) 2005 Joshua Hoblitt 4 4 # 5 # $Id: glueforge.in,v 1.3 8 2006-01-07 04:46:56jhoblitt Exp $5 # $Id: glueforge.in,v 1.39 2006-01-10 00:38:15 jhoblitt Exp $ 6 6 7 7 use strict; … … 36 36 die "file doesn't not contain a valid config" unless defined $config->[0]; 37 37 38 my %data; 39 40 # find table name 41 my $table_name; 42 for (my $i = 0; $i < @{$config}; $i++) { 43 my $elem = $config->[$i]; 44 45 if ( $elem->{name} eq "table" ) { 46 $table_name = $elem->{value}; 47 48 # delete element from array 49 splice @$config, $i, 1; 50 51 last; 52 } 53 } 54 55 # global data 56 $data{pkg_name} = $table_name . "db"; 57 $data{pkg_namespace} = $table_name; 58 59 # per table data 60 my %table; 61 $table{name} = $table_name; 62 $table{namespace} = $table_name; 63 $table{object_name} = $table{namespace} . "Row"; 64 65 my @items; 66 67 # setup items 68 for (my $i = 0; $i < @{$config}; $i++) { 69 my $elem = $config->[$i]; 70 71 my $mdtypes = lookup_type( $elem->{type} ); 72 next if ! defined $mdtypes; 73 74 push @items, { 75 name => $elem->{name}, 76 type => $elem->{type}, 77 ctype => $mdtypes->{ctype}, 78 mtype => $mdtypes->{mtype}, 79 test => $mdtypes->{test}, 80 comment => $elem->{comment}, 81 value => $elem->{value}, 82 }; 83 } 84 85 $table{columns} = \@items; 86 $data{tables} = [ \%table ]; 87 88 $output = $data{pkg_name} unless defined $output; 38 # if the first hash has a class of "metadata" then this is a complex config. 39 # Otherwise it is a simple config. 40 my $complex = ($config->[0]->{class} eq "metadata") ? 1 : 0; 41 42 my $data; # hashref 43 if ($complex) { 44 # $data = complex_config($config); 45 } else { 46 $data = simple_config($config); 47 } 48 49 # determine output path 50 $output = $data->{pkg_name} unless defined $output; 89 51 90 52 my %tt = ( 91 53 'autogen_sh.tt' => "$output/autogen.sh", 92 54 'configure_ac.tt' => "$output/configure.ac", 93 'pkgconfig_pc_in.tt' => "$output/$data {pkg_name}.pc.in",55 'pkgconfig_pc_in.tt' => "$output/$data->{pkg_name}.pc.in", 94 56 'doxyfile_in.tt' => "$output/Doxyfile.in", 95 57 'top_makefile_am.tt' => "$output/Makefile.am", 96 58 'src_makefile_am.tt' => "$output/src/Makefile.am", 97 'header.tt' => "$output/src/$data {pkg_name}.h",98 'code.tt' => "$output/src/$data {pkg_name}.c",59 'header.tt' => "$output/src/$data->{pkg_name}.h", 60 'code.tt' => "$output/src/$data->{pkg_name}.c", 99 61 'tests_makefile_am.tt' => "$output/tests/Makefile.am", 100 62 'testsuite_at.tt' => "$output/tests/testsuite.at", … … 120 82 121 83 foreach my $t ( keys %tt ) { 122 $mangler->process( $t, \%data, $tt{$t})84 $mangler->process( $t, $data, $tt{$t}) 123 85 or die $mangler->error; 124 86 } … … 187 149 } 188 150 151 sub simple_config { 152 my $config = shift; 153 154 # find table name 155 my $table_name; 156 for (my $i = 0; $i < @{$config}; $i++) { 157 my $elem = $config->[$i]; 158 159 if ( $elem->{name} eq "table" ) { 160 $table_name = $elem->{value}; 161 162 # delete element from array 163 splice @$config, $i, 1; 164 165 last; 166 } 167 } 168 169 my %data; 170 171 # global data 172 $data{pkg_name} = $table_name . "db"; 173 $data{pkg_namespace} = $table_name; 174 175 # per table data 176 my %table; 177 $table{name} = $table_name; 178 $table{namespace} = $table_name; 179 $table{object_name} = $table{namespace} . "Row"; 180 181 my @items; 182 183 # setup items 184 for (my $i = 0; $i < @{$config}; $i++) { 185 my $elem = $config->[$i]; 186 187 my $mdtypes = lookup_type( $elem->{type} ); 188 next if ! defined $mdtypes; 189 190 push @items, { 191 name => $elem->{name}, 192 type => $elem->{type}, 193 ctype => $mdtypes->{ctype}, 194 mtype => $mdtypes->{mtype}, 195 test => $mdtypes->{test}, 196 comment => $elem->{comment}, 197 value => $elem->{value}, 198 }; 199 } 200 201 $table{columns} = \@items; 202 $data{tables} = [ \%table ]; 203 204 return \%data; 205 } 206 189 207 __END__ 190 208
Note:
See TracChangeset
for help on using the changeset viewer.
