|
@@ -105,6 +105,7 @@ def parse_schema(fp):
|
|
if expr_eval.has_key('enum'):
|
|
if expr_eval.has_key('enum'):
|
|
add_enum(expr_eval['enum'])
|
|
add_enum(expr_eval['enum'])
|
|
elif expr_eval.has_key('union'):
|
|
elif expr_eval.has_key('union'):
|
|
|
|
+ add_union(expr_eval)
|
|
add_enum('%sKind' % expr_eval['union'])
|
|
add_enum('%sKind' % expr_eval['union'])
|
|
elif expr_eval.has_key('type'):
|
|
elif expr_eval.has_key('type'):
|
|
add_struct(expr_eval)
|
|
add_struct(expr_eval)
|
|
@@ -188,6 +189,7 @@ def type_name(name):
|
|
|
|
|
|
enum_types = []
|
|
enum_types = []
|
|
struct_types = []
|
|
struct_types = []
|
|
|
|
+union_types = []
|
|
|
|
|
|
def add_struct(definition):
|
|
def add_struct(definition):
|
|
global struct_types
|
|
global struct_types
|
|
@@ -200,6 +202,17 @@ def find_struct(name):
|
|
return struct
|
|
return struct
|
|
return None
|
|
return None
|
|
|
|
|
|
|
|
+def add_union(definition):
|
|
|
|
+ global union_types
|
|
|
|
+ union_types.append(definition)
|
|
|
|
+
|
|
|
|
+def find_union(name):
|
|
|
|
+ global union_types
|
|
|
|
+ for union in union_types:
|
|
|
|
+ if union['union'] == name:
|
|
|
|
+ return union
|
|
|
|
+ return None
|
|
|
|
+
|
|
def add_enum(name):
|
|
def add_enum(name):
|
|
global enum_types
|
|
global enum_types
|
|
enum_types.append(name)
|
|
enum_types.append(name)
|