summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2012-11-25 12:13:23 +0200
committerYakov Goldberg <yakov.g@samsung.com>2012-11-26 09:59:34 +0200
commitb689af240664e1d98c96c4ebd13269faff5be624 (patch)
tree0f1948e247920b258c7d076919b1233fc5ef47d1
parent7fdd74de204676d1594ae38297fe62ed8ee7bdb4 (diff)
Added xml_parsing_version tag;
- to keep track compatability between xml generating and xml parsing Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
-rw-r--r--eoparser/cparser.py2
-rw-r--r--eoparser/helper.py3
-rw-r--r--eoparser/xmlparser.py9
3 files changed, 14 insertions, 0 deletions
diff --git a/eoparser/cparser.py b/eoparser/cparser.py
index 6e6f85e..97ebe49 100644
--- a/eoparser/cparser.py
+++ b/eoparser/cparser.py
@@ -331,6 +331,8 @@ class Cparser(object):
331 331
332 module = Element(const.MODULE) 332 module = Element(const.MODULE)
333 module.set(const.NAME, cl_data[const.C_NAME]) 333 module.set(const.NAME, cl_data[const.C_NAME])
334
335 SubElement(module, const.PARSE_VERSION, {const.NUM : const.VER_NUM} )
334 SubElement(module, const.INCLUDE, {const.NAME: os.path.split(cl_data[const.H_FILE])[1]}) 336 SubElement(module, const.INCLUDE, {const.NAME: os.path.split(cl_data[const.H_FILE])[1]})
335 337
336 cl_parent = "" 338 cl_parent = ""
diff --git a/eoparser/helper.py b/eoparser/helper.py
index 1c2215b..3dfb86d 100644
--- a/eoparser/helper.py
+++ b/eoparser/helper.py
@@ -18,6 +18,9 @@ class _const:
18 self.C_NAME = "c_name" #used as xml-tag 18 self.C_NAME = "c_name" #used as xml-tag
19 self.MODIFIER = "modifier" #used as xml-tag 19 self.MODIFIER = "modifier" #used as xml-tag
20 self.MODULE = "module" #used as xml-tag 20 self.MODULE = "module" #used as xml-tag
21 self.PARSE_VERSION = "parse_version" #used as xml-tag
22 self.NUM = "num" #used as xml-tag
23 self.VER_NUM = "1.0.0"
21 self.TYPE = "type" #used as xml-tag 24 self.TYPE = "type" #used as xml-tag
22 self.CLASS_CONSTRUCTOR = "class_constructor" 25 self.CLASS_CONSTRUCTOR = "class_constructor"
23 self.BASE_ID = "base_id" 26 self.BASE_ID = "base_id"
diff --git a/eoparser/xmlparser.py b/eoparser/xmlparser.py
index 6dd72a0..187cc6f 100644
--- a/eoparser/xmlparser.py
+++ b/eoparser/xmlparser.py
@@ -1127,6 +1127,7 @@ class XMLparser(object):
1127 self.ev_ids = [] 1127 self.ev_ids = []
1128 self.op_ids = [] 1128 self.op_ids = []
1129 self.extern_funcs = [] 1129 self.extern_funcs = []
1130 self.xml_ver = False
1130 1131
1131 self.class_data = {} 1132 self.class_data = {}
1132 self.functions = {} #function names with parameters 1133 self.functions = {} #function names with parameters
@@ -1143,6 +1144,9 @@ class XMLparser(object):
1143 if name == const.METHOD: 1144 if name == const.METHOD:
1144 self.current_func = attrs[const.NAME] 1145 self.current_func = attrs[const.NAME]
1145 self.functions.setdefault(self.current_func, {const.OP_ID : attrs[const.OP_ID], const.C_MACRO : attrs[const.C_MACRO], const.PARAMETERS:[]}) 1146 self.functions.setdefault(self.current_func, {const.OP_ID : attrs[const.OP_ID], const.C_MACRO : attrs[const.C_MACRO], const.PARAMETERS:[]})
1147 elif name == const.PARSE_VERSION:
1148 if attrs[const.NUM] == const.VER_NUM:
1149 self.xml_ver = True
1146 1150
1147 elif name == const.PARAMETER: 1151 elif name == const.PARAMETER:
1148 func_att = self.functions[self.current_func] 1152 func_att = self.functions[self.current_func]
@@ -1186,6 +1190,10 @@ class XMLparser(object):
1186 1190
1187 if self.class_data == {}: 1191 if self.class_data == {}:
1188 return 1192 return
1193
1194 if self.xml_ver == False:
1195 print "Wrong xml file version: %s"%(fName)
1196 exit()
1189 mod_name = normalize_names([self.class_data[const.C_NAME]])[0].lower() 1197 mod_name = normalize_names([self.class_data[const.C_NAME]])[0].lower()
1190 #defining _id function 1198 #defining _id function
1191 if self.class_data[const.BASE_ID] != "": 1199 if self.class_data[const.BASE_ID] != "":
@@ -1257,6 +1265,7 @@ class XMLparser(object):
1257 self.ev_ids = [] 1265 self.ev_ids = []
1258 self.extern_funcs = [] 1266 self.extern_funcs = []
1259 self.class_data = {} 1267 self.class_data = {}
1268 self.xml_ver = False
1260 1269
1261 1270
1262 #For each class(object) in current tree, checks if parent is also in current tree. 1271 #For each class(object) in current tree, checks if parent is also in current tree.