Rev 206 | Rev 255 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
206 | ligi | 1 | require 'rio' |
2 | |||
3 | |||
4 | all_tabs=[] |
||
5 | |||
6 | all_names=[] |
||
7 | all_positions=[] |
||
8 | all_types=[] |
||
9 | |||
10 | all_namestarts=[] |
||
11 | all_lengths=[] |
||
12 | |||
13 | function_hash={} |
||
14 | act_name="" |
||
15 | rio("definitions").read.each_line { |line| |
||
16 | |||
17 | if line =~ /--/ |
||
18 | act_name=line.split("--")[1].delete!("\r\n") |
||
19 | function_hash[act_name]="" |
||
20 | else |
||
21 | function_hash[act_name] << line |
||
22 | end |
||
23 | } |
||
24 | |||
25 | #puts function_hash.inspect |
||
26 | #exit |
||
27 | |||
28 | Dir["header_files/*.h"].sort.each { |e| |
||
29 | puts "----------------" + e |
||
30 | new="" |
||
31 | start=false |
||
32 | rio(e).each_line { |l| |
||
33 | start=true if l =~ /struct\r/ |
||
34 | start=true if l =~ /struct\n/ |
||
35 | start=false if l =~ /\}/ |
||
36 | if (l =~ /;/ ) && start |
||
37 | new << l |
||
38 | end |
||
39 | |||
40 | } |
||
41 | |||
42 | act_pos=0 |
||
43 | name_pos=0 |
||
44 | end_pos=0 |
||
45 | @categorys=[] |
||
46 | @category={} |
||
47 | def to_cat(name,items) |
||
48 | @categorys << name |
||
49 | |||
50 | @category[name]=[] if !@category[name] |
||
51 | @category[name] |= items |
||
52 | end |
||
53 | |||
54 | |||
55 | |||
56 | |||
57 | new.each_line { |l| |
||
58 | found=false |
||
59 | function_hash.each_pair { |k,v| |
||
60 | if l.scan(k)!=[] |
||
61 | found=true |
||
62 | p "found" + k |
||
63 | puts v |
||
64 | puts act_pos |
||
65 | |||
66 | instance_eval(v) |
||
67 | |||
68 | end |
||
69 | } |
||
70 | if !found |
||
71 | p "Fatal: line not found " + l |
||
72 | p "stopping process" |
||
73 | exit |
||
74 | end |
||
75 | } |
||
76 | #p @category |
||
77 | @categorys.uniq! |
||
78 | @categorys.sort! |
||
79 | all_tabs << ["{\"" + @categorys.join("\",\"") + "\"}"] |
||
80 | puts "[\"" + @categorys.join("\",\"") + "\"]" |
||
81 | |||
82 | |||
83 | all_names << ["{"+@categorys.map { |c| |
||
84 | "{\"" + @category[c].map { |e| |
||
85 | e[:name] |
||
86 | }.join("\",\"") + "\"}" |
||
87 | }.join(",")+"}"] |
||
88 | |||
89 | all_positions << ["{"+@categorys.map { |c| |
||
90 | "{" + @category[c].map { |e| |
||
91 | e[:pos] |
||
92 | }.join(",") + "}" |
||
93 | }.join(",")+"}"] |
||
94 | |||
95 | all_types << ["{"+ @categorys.map { |c| |
||
96 | "{PARAMTYPE_" + @category[c].map { |e| |
||
97 | e[:typ] |
||
98 | }.join(",PARAMTYPE_") + "}" |
||
99 | }.join(",") + "}"] |
||
100 | |||
101 | all_namestarts << name_pos |
||
102 | all_lengths << end_pos |
||
103 | #rio(e+".new") <new |
||
104 | |||
105 | |||
106 | |||
107 | |||
108 | |||
109 | |||
110 | } |
||
111 | |||
112 | puts "// -- start generated code --" |
||
113 | puts "public final static String[][] all_tab_names={"+all_tabs.join(",")+"};" |
||
114 | puts "public final static String[][][] all_field_names={"+all_names.join(",")+"};" |
||
115 | puts "public final static int[][][] all_field_positions={"+all_positions.join(",")+"};" |
||
116 | puts "public final static int[][][] all_field_types={"+all_types.join(",")+"};" |
||
117 | |||
118 | |||
119 | puts "public final static int[] all_name_positions={"+all_namestarts.join(",")+"};" |
||
120 | puts "public final static int[] all_lengths={"+all_lengths.join(",")+"};" |
||
121 | puts "// -- end generated code --" |