blob: 91c89a74ac40452b0bfba07f350581e43472b5a2 [file] [log] [blame]
Andreas Wundsam40e14f72013-05-06 14:49:08 -07001import of_g
2import pdb
3import os
4
5import lang_java
6
7import loxi_utils.loxi_utils as loxi_utils
8
9import java_gen.msgs as msgs
10import java_gen.java_utils as java_utils
11
12def gen_all_java(out, name):
13 """ Generate all of the java files
14
15 @param out is an open file handle to a file called README
16 @param name should be 'README' and is ignored for the java
17 driver
18 """
19 messages = list()
20 actions = list()
21 instructions = list()
22 matches = list()
23 stat_types = list()
24 queue_prop = list()
25 lists = list()
26 for cls in of_g.unified:
27 print "! Classifying %s" % cls
28 if cls in [ 'of_stats_reply', 'of_flow_mod', 'of_stats_request' ] :
29 continue # doesn't work?!
30 if loxi_utils.class_is_stats_message(cls):
31 stat_types.append(cls)
32 elif loxi_utils.class_is_message(cls):
33 messages.append(cls)
34 elif loxi_utils.class_is_action(cls):
35 actions.append(cls)
36 elif loxi_utils.class_is_instruction(cls):
37 instructions.append(cls)
38 elif loxi_utils.class_is_oxm(cls):
39 matches.append(cls)
40 elif loxi_utils.class_is_queue_prop(cls):
41 queue_prop.append(cls)
42 elif loxi_utils.class_is_list(cls):
43 lists.append(cls)
44 else:
45 print "Skipping Unknown class object %s" % str(cls)
46 print "Parsed "
47 print " Messages: %d" % len(messages)
48 print " Actions: %d" % len(actions)
49 print " Instructions: %d" % len(instructions)
50 print " OXM matches: %d" % len(matches)
51 print " Stat types: %d" % len(stat_types)
52 print " Queue properties: %d" % len(queue_prop)
53 print " Lists: %d" % len(lists)
54 target_dir='loxi_output/openflowj'
55 basedir="%s/%s/" % (
56 target_dir,
57 lang_java.file_to_subdir_map['base_java'])
58 srcdir = "%s/src/main/java/org/openflow/protocol" % basedir
59 print "Outputting to %s" % basedir
60 if not os.path.exists(basedir):
61 os.makedirs(basedir)
62 java_utils.copy_prewrite_tree(basedir)
63 msgs.create_message_interfaces(messages,srcdir)
64 msgs.create_message_by_version(messages,srcdir)
65 msgs.create_of_type_enum(messages,srcdir)
66 with open('README.java-lang') as readme_src:
67 out.writelines(readme_src.readlines())
68 out.close()