3 # convert C or D (suggested, since "preprocessed") headerfile to ooc
6 # why not use babbisch ? well i dont want to use python and figure out
7 # how its package management system works.
15 $type =~ s/uint/UInt/;
17 $type =~ s/char/Char/;
18 $type =~ s/void/Void/;
19 $type =~ s/Void\*/Pointer/;
20 $type =~ s/ushort/UShort/;
21 $type =~ s/short/Short/;
22 $type =~ s/size_t/SizeT/;
23 $type =~ s/ssize_t/SSizeT/;
24 $type =~ s/ptrdiff_t/SSizeT/;
31 $string =~ s/^\s+|\s+$//g;
38 foreach my $char(@a) {
39 $res .= $char if($char);
46 $string =~ s/(\w+)\s+\*\s*/$1* /g;
61 return ($string, "") if check_all_upper
($string);
62 my @a = split(//, $string);
66 for(my $i=0;$i<@a;$i++) {
67 if($lastChar && $a[$i] eq "_") {
79 foreach my $item(@del) {
83 return ($new, "(" . $string . ")") if ($new ne $string);
87 #exit check_all_upper("SOME_COaNST_NAME");
95 } elsif (/^\s*(\w+\**)\s+(\w*)\s*\(([\w|\*| |,|\.]*)\)\s*;/) {
96 #searching function declararions
97 my $return = converttype
($1);
98 #no need to declare void return type in ooc
99 if($return eq "Void") {
102 $return = "-> " . $return
104 my ($funcname, $externname) = ooccase
($2);
107 my $args_braced = "";
110 my @arga = split /,/, $args;
112 foreach my $item(@arga) {
113 my $expr = trim
($item);
115 my @exprel = split / /, $expr;
116 $expr = $exprel[1] . ": " . converttype
($exprel[0])
118 $expr = converttype
($expr);
120 $args_braced .= $expr;
121 $args_braced .= ", " if($counter != @arga -1);
126 print("$funcname: extern$externname func$args_braced $return\n");
127 } elsif (/^\s*const\s+(\w+\**)\s+(\w+)\s*=\s*.+?;/) {
129 my $type = converttype
($1);
130 my ($name, $externname) = ooccase
($2);
131 print("$name: extern$externname $type\n");
132 } elsif (/^\s*(alias|typedef)\s+?(\w+\**)\s+?(\w+)\s*;/) {
133 #searching simple typedef. we dont cover function pointers and arrays.
134 my $type = converttype
($2);
136 print("$name: cover from $type\n");