summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2012-11-18 12:17:07 +0200
committerYakov Goldberg <yakov.g@samsung.com>2012-11-18 19:02:13 +0200
commit7c1cf756853a644a9ad80a07a1b79b5e7f9d44d6 (patch)
tree949952da10eec253936f0d7572d4b80a5736316d
parent4cf9f6acc1cea5fd19171f7749d3f4251c5f0560 (diff)
get_param_dir_from_comment() func added to cparcer and tests
- types added to typedef Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
-rw-r--r--eoparser/cparser.py24
-rw-r--r--tests/tests.py20
2 files changed, 37 insertions, 7 deletions
diff --git a/eoparser/cparser.py b/eoparser/cparser.py
index 77476d0..4eb79d2 100644
--- a/eoparser/cparser.py
+++ b/eoparser/cparser.py
@@ -34,6 +34,13 @@ class Cparser(object):
34 self.typedefs = {"Evas_Coord" : "int", 34 self.typedefs = {"Evas_Coord" : "int",
35 "Evas_Angle":"int", 35 "Evas_Angle":"int",
36 "Evas_Font_Size" : "int", 36 "Evas_Font_Size" : "int",
37 "Evas_Object" : "Eo",
38 "Evas_Smart" : "Eo",
39 "Evas_Map" : "Eo",
40 "Evas_Text_Style_Type" : "Eo",
41 "Evas_Colorspace" : "Eo",
42 "Evas_Render_Op" : "Eo",
43 "Evas_Aspect_Control" : "Eo",
37 "Eina_Bool" : "bool", 44 "Eina_Bool" : "bool",
38 "Eo_Callback_Priority": "short"} 45 "Eo_Callback_Priority": "short"}
39 46
@@ -381,6 +388,15 @@ class Cparser(object):
381 f.write(res) 388 f.write(res)
382 f.close() 389 f.close()
383 390
391 def get_param_dir_from_comment(self, com):
392 res = re.findall("@param.*", com)
393 l_tmp = []
394 for s in res:
395 s = s.replace(" ", "")
396 ret = re.match("@param\[([inout,]*)\]", s)
397 l_tmp.append(ret.group(1) if (ret != None and ret.group(1) in ["in", "out", "in,out"]) else "in,out");
398 return l_tmp
399
384 #parsing header file 400 #parsing header file
385 def h_file_data_get(self, filename): 401 def h_file_data_get(self, filename):
386 f = open (filename, 'r') 402 f = open (filename, 'r')
@@ -409,14 +425,8 @@ class Cparser(object):
409 continue 425 continue
410 426
411 macro_name = res.group(1) 427 macro_name = res.group(1)
412
413 #looking for parameters direction in comment 428 #looking for parameters direction in comment
414 res = re.findall("@param[\[]*([inout,]*)[\]]*", comment_tmp) 429 macro[macro_name] = self.get_param_dir_from_comment(comment_tmp)
415 l_tmp = []
416 for l in res:
417 l_tmp.append(l if len(l) else "in,out");
418
419 macro[macro_name] = l_tmp
420 430
421 #looking for class_get function to get class macro 431 #looking for class_get function to get class macro
422 current_class = "" 432 current_class = ""
diff --git a/tests/tests.py b/tests/tests.py
index 1c0f709..0567a8c 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -61,6 +61,26 @@ class testP(unittest.TestCase):
61 self.assertEqual(normalize_names(_in), _out) 61 self.assertEqual(normalize_names(_in), _out)
62 62
63 63
64 def test_get_param_dir_from_comment(self):
65 s = """
66 @param[in,out] a
67 @param[in] a
68 @param[out] a
69 parem[in]
70 @param [in] a
71 @param [out] a
72 @param[in, out] a
73 @param in
74 @param [ in ]
75 @param [ out, in ]
76 @param sdf [ out ]
77 """
78 _out = ["in,out", "in", "out", "in", "out", "in,out", "in,out", "in", "in,out", "in,out"]
79 ret = self.c_parser.get_param_dir_from_comment(s)
80 self.assertEqual(ret, _out)
81
82
83
64def suite(): 84def suite():
65 suite = unittest.TestSuite() 85 suite = unittest.TestSuite()
66 suite.addTest(unittest.makeSuite(testP)) 86 suite.addTest(unittest.makeSuite(testP))