]>
git.saurik.com Git - apple/security.git/blob - SecurityServer/generate.pl
7 my $disclaimer = "Automatically generated - do not edit on penalty of futility!";
11 my ($configfile, $out_h, $out_cpp, $types) = @ARGV;
14 # open configuration file
15 open(CFG
, "$configfile") || die "$configfile: $!";
17 # open and load cssmtypes file
18 open(TYPES
, "$types") || die "$types: $!";
20 my $types_h = <TYPES
>;
21 close(TYPES
); $/="\n";
24 open(H
, ">$out_h") || die "$out_h: $!";
25 open(CPP
, ">$out_cpp") || die "$out_cpp: $!";
27 # cautionary headings to each file
30 // Flipping bytes for SecurityServer transition.
37 // Flipping bytes for SecurityServer transition.
42 # process generation instructions
50 my ($cssmName, @aliases) = split /\//;
52 print H
"void flip($cssmName &obj);\n";
53 for my $alias (@aliases) {
54 print H
"inline void flip($alias &obj) { flip(static_cast<$cssmName &>(obj)); }\n";
57 next if ($args[0] eq 'CUSTOM');
59 if ($args[0] eq '*') {
60 # extract definition from types file
61 my ($list) = $types_h =~ /{\s+([^}]+)\s+}\s*$cssmName,/;
62 die "cannot find struct definition for $cssmName in $types" unless $list;
63 @args = $list =~ /([A-Za-z0-9_]+);/gm;
66 print CPP
"void flip($cssmName &obj)\n{\n";
67 for my $field (@args) {
68 print CPP
"\tflip(obj.$field);\n";