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/;
25 $type =~ s/bool/Bool/;
26 $type =~ s/ubyte/Octet/;
27 $type =~ s/Char\*/CString/;
34 $string =~ s/^\s+|\s+$//g;
41 foreach my $char(@a) {
42 $res .= $char if($char);
49 $string =~ s/(\w+)\s+\*\s*/$1* /g;
64 return ($string, "") if check_all_upper
($string);
65 my @a = split(//, $string);
69 for(my $i=0;$i<@a;$i++) {
70 if($lastChar && $a[$i] eq "_") {
82 foreach my $item(@del) {
86 return ($new, "(" . $string . ")") if ($new ne $string);
90 #exit check_all_upper("SOME_COaNST_NAME");
98 } elsif (/^\s*(\w+\**)\s+(\w*)\s*\(([\w|\*| |,|\.]*)\)\s*;/) {
99 #searching function declararions
100 my $return = converttype
($1);
101 #no need to declare void return type in ooc
102 if($return eq "Void") {
105 $return = "-> " . $return
107 my ($funcname, $externname) = ooccase
($2);
110 my $args_braced = "";
113 my @arga = split /,/, $args;
115 foreach my $item(@arga) {
116 my $expr = trim
($item);
118 my @exprel = split / /, $expr;
119 $expr = $exprel[1] . ": " . converttype
($exprel[0])
121 $expr = converttype
($expr);
123 $args_braced .= $expr;
124 $args_braced .= ", " if($counter != @arga -1);
128 $args_braced = "" if($args_braced eq "(Void)");
130 print("$funcname: extern$externname func$args_braced $return\n");
131 } elsif (/^\s*const\s+(\w+\**)\s+(\w+)\s*=\s*.+?;/) {
133 my $type = converttype
($1);
134 my ($name, $externname) = ooccase
($2);
135 print("$name: extern$externname $type\n");
136 } elsif (/^\s*(alias|typedef)\s+?(\w+\**)\s+?(\w+)\s*;/) {
137 #searching simple typedef. we dont cover function pointers and arrays.
138 my $type = converttype
($2);
140 print("$name: cover from $type\n");