Rev 252 | 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! |
||
255 | ligi | 79 | mod_cats=@categorys.map {|e| "STRINGID_"+e } |
80 | all_tabs << ["{" + mod_cats.join(",") + "}"] |
||
206 | ligi | 81 | puts "[\"" + @categorys.join("\",\"") + "\"]" |
82 | |||
83 | |||
84 | all_names << ["{"+@categorys.map { |c| |
||
85 | "{\"" + @category[c].map { |e| |
||
86 | e[:name] |
||
87 | }.join("\",\"") + "\"}" |
||
88 | }.join(",")+"}"] |
||
89 | |||
90 | all_positions << ["{"+@categorys.map { |c| |
||
91 | "{" + @category[c].map { |e| |
||
92 | e[:pos] |
||
93 | }.join(",") + "}" |
||
94 | }.join(",")+"}"] |
||
95 | |||
96 | all_types << ["{"+ @categorys.map { |c| |
||
97 | "{PARAMTYPE_" + @category[c].map { |e| |
||
98 | e[:typ] |
||
99 | }.join(",PARAMTYPE_") + "}" |
||
100 | }.join(",") + "}"] |
||
101 | |||
102 | all_namestarts << name_pos |
||
103 | all_lengths << end_pos |
||
104 | #rio(e+".new") <new |
||
105 | |||
106 | |||
107 | |||
108 | |||
109 | |||
110 | |||
111 | } |
||
112 | |||
113 | puts "// -- start generated code --" |
||
255 | ligi | 114 | puts "public final static int[][] all_tab_stringids={"+all_tabs.join(",")+"};" |
206 | ligi | 115 | puts "public final static String[][][] all_field_names={"+all_names.join(",")+"};" |
116 | puts "public final static int[][][] all_field_positions={"+all_positions.join(",")+"};" |
||
117 | puts "public final static int[][][] all_field_types={"+all_types.join(",")+"};" |
||
118 | |||
119 | |||
120 | puts "public final static int[] all_name_positions={"+all_namestarts.join(",")+"};" |
||
121 | puts "public final static int[] all_lengths={"+all_lengths.join(",")+"};" |
||
122 | puts "// -- end generated code --" |