blob: 5b28e57c37b9c521ae2899ebe7f9201d21469f51 [file] [log] [blame]
Rich Lanea06d0c32013-03-25 08:52:03 -07001#!/usr/bin/python
2# Copyright 2013, Big Switch Networks, Inc.
3#
4# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
5# the following special exception:
6#
7# LOXI Exception
8#
9# As a special exception to the terms of the EPL, you may distribute libraries
10# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
11# that copyright and licensing notices generated by LoxiGen are not altered or removed
12# from the LoxiGen Libraries and the notice provided below is (i) included in
13# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
14# documentation for the LoxiGen Libraries, if distributed in binary form.
15#
16# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
17#
18# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
19# a copy of the EPL at:
20#
21# http://www.eclipse.org/legal/epl-v10.html
22#
23# Unless required by applicable law or agreed to in writing, software
24# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
25# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
26# EPL for the specific language governing permissions and limitations
27# under the EPL.
28
29#
30# Some test code for c_utils.py
31#
32
33import sys
34sys.path.append("../loxi_front_end")
35sys.path.append("..")
36
37from c_parse_utils import *
38
39for filename in [
40 '../canonical/openflow.h-1.0',
41 '../canonical/openflow.h-1.1',
42 '../canonical/openflow.h-1.2']:
43
44 f = open(filename, 'r')
45 all_lines = f.readlines()
46 contents = " ".join(all_lines)
47
48 print "clean_up"
49 print clean_up_input(contents)
50
51#print "structs"
52#for x in extract_structs(c):
53# print x
54
55 all_enums = extract_enums(contents)
56 print "Got %d enums for %s" % (len(all_enums), filename)
57 for x in all_enums:
58 name, entries = extract_enum_vals(x)
59 print "Enum name %s has %d entries" % (name, len(entries))
60 for item in entries:
61 print " key=%s, value=%s" % (item[0], str(item[1]))
62
63 all_defs = extract_defines(contents)
64 print "Got %d defines for %s" % (len(all_defs), filename)
65 for x in all_defs:
66 print " name=%s, value=%s" % (x[0], str(x[1]))