Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
60 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=false if l =~ /\}/    
35
    if (l =~ /;/ ) && start
36
         new << l
37
    end
38
 
39
  }
40
 
41
act_pos=0
42
name_pos=0
43
end_pos=0
44
@categorys=[]
45
@category={}
46
def to_cat(name,items)
47
@categorys << name
48
 
49
   @category[name]=[]   if !@category[name]
50
   @category[name] |= items
51
end
52
 
53
 
54
 
55
 
56
 new.each_line { |l|
57
 found=false
58
  function_hash.each_pair { |k,v|
59
    if l.scan(k)!=[]
60
      found=true
61
      p "found" + k
62
      puts v
63
   puts act_pos
64
 
65
      instance_eval(v)
66
 
67
    end
68
  }
69
  if !found
123 ligi 70
    p "Fatal: line not found " + l
71
#    p "stopping process"
72
#    exit
60 ligi 73
  end
74
 }
75
#p @category
76
 @categorys.uniq!
77
 @categorys.sort!
78
all_tabs << ["{\"" +  @categorys.join("\",\"") + "\"}"]
79
puts "[\"" +  @categorys.join("\",\"") + "\"]"
80
 
81
 
82
all_names << ["{"+@categorys.map { |c|
83
                "{\"" + @category[c].map { |e|
84
    e[:name]
85
                }.join("\",\"") + "\"}"
86
              }.join(",")+"}"]
87
 
88
all_positions << ["{"+@categorys.map { |c|
89
  "{" + @category[c].map { |e|
90
    e[:pos]
91
    }.join(",") + "}"
92
 }.join(",")+"}"]
93
 
94
all_types << ["{"+ @categorys.map { |c|
95
                "{PARAMTYPE_" + @category[c].map { |e|
96
    e[:typ]
97
                }.join(",PARAMTYPE_") + "}"
98
              }.join(",") + "}"]
99
 
100
all_namestarts << name_pos
101
all_lengths << end_pos
102
#rio(e+".new") <new 
103
 
104
 
105
 
106
 
107
 
108
 
109
}
110
 
111
puts "// -- start generated code --"
112
puts "public final static int PARAMTYPE_BYTE=0;"
113
puts "public final static int PARAMTYPE_BITSWITCH=1;"
114
puts "public final static int PARAMTYPE_STICK=2;"
115
puts "public final static String[][] all_tab_names={"+all_tabs.join(",")+"};"
116
puts "public final static String[][][] all_field_names={"+all_names.join(",")+"};"
117
puts "public final static int[][][] all_field_positions={"+all_positions.join(",")+"};"
118
puts "public final static int[][][] all_field_types={"+all_types.join(",")+"};"
119
 
120
 
121
puts "public final static int[] all_name_positions={"+all_namestarts.join(",")+"};"
122
puts "public final static int[] all_lengths={"+all_lengths.join(",")+"};"
123
puts "// -- end generated code --"