davemds pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=20f7d6f35fe5a9633451857bb2c79eb7dedbfc57

commit 20f7d6f35fe5a9633451857bb2c79eb7dedbfc57
Author: Dave Andreoli <[email protected]>
Date:   Thu Mar 1 16:35:22 2018 +0100

    Pyolian: new variable lookup APIs
    
    with adjusted tests
---
 src/scripts/pyolian/eolian.py      | 65 ++++++++++++++++++++++++--------------
 src/scripts/pyolian/eolian_lib.py  | 56 ++++++++++++++++++++------------
 src/scripts/pyolian/test_eolian.py | 14 ++++----
 3 files changed, 84 insertions(+), 51 deletions(-)

diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py
index 0ce750fb05..d181a0fc60 100644
--- a/src/scripts/pyolian/eolian.py
+++ b/src/scripts/pyolian/eolian.py
@@ -350,6 +350,23 @@ class Eolian_Unit(EolianBaseObject):
         return Class(c_cls) if c_cls else None
 
     @property
+    def constants(self):
+        return Iterator(Variable, lib.eolian_unit_constants_get(self._obj))
+
+    def constant_by_name_get(self, name):
+        c_var = lib.eolian_unit_constant_by_name_get(self._obj, 
_str_to_bytes(name))
+        return Variable(c_var) if c_var else None
+
+    @property
+    def globals(self):
+        return Iterator(Variable, lib.eolian_unit_globals_get(self._obj))
+
+    def global_by_name_get(self, name):
+        c_var = lib.eolian_unit_global_by_name_get(self._obj, 
_str_to_bytes(name))
+        return Variable(c_var) if c_var else None
+
+
+    @property
     def all_namespaces(self):
         # TODO find a better way to find namespaces (maybe inside eolian?)
         nspaces = set()
@@ -403,30 +420,6 @@ class Eolian_Unit(EolianBaseObject):
             lib.eolian_typedecl_aliases_get_by_file(self._obj, 
_str_to_bytes(fname)))
 
     @property
-    def variable_all_constants(self):
-        return Iterator(Variable, 
lib.eolian_variable_all_constants_get(self._obj))
-
-    def variable_constant_get_by_name(self, name):
-        c_var = lib.eolian_variable_constant_get_by_name(self._obj, 
_str_to_bytes(name))
-        return Variable(c_var) if c_var else None
-
-    def variable_constants_get_by_file(self, fname):
-        return Iterator(Variable,
-            lib.eolian_variable_constants_get_by_file(self._obj, 
_str_to_bytes(fname)))
-
-    @property
-    def variable_all_globals(self):
-        return Iterator(Variable, 
lib.eolian_variable_all_globals_get(self._obj))
-
-    def variable_global_get_by_name(self, name):
-        c_var = lib.eolian_variable_global_get_by_name(self._obj, 
_str_to_bytes(name))
-        return Variable(c_var) if c_var else None
-
-    def variable_globals_get_by_file(self, fname):
-        return Iterator(Variable,
-            lib.eolian_variable_globals_get_by_file(self._obj, 
_str_to_bytes(fname)))
-
-    @property
     def all_declarations(self):
         return Iterator(Declaration, 
lib.eolian_all_declarations_get(self._obj))
 
@@ -499,6 +492,30 @@ class Eolian_State(Eolian_Unit):
         c_cls = lib.eolian_state_class_by_file_get(self._obj, 
_str_to_bytes(file_name))
         return Class(c_cls) if c_cls else None
 
+    @property
+    def constants(self):
+        return Iterator(Variable, lib.eolian_state_constants_get(self._obj))
+
+    def constant_by_name_get(self, name):
+        c_var = lib.eolian_state_constant_by_name_get(self._obj, 
_str_to_bytes(name))
+        return Variable(c_var) if c_var else None
+
+    def constants_by_file_get(self, file_name):
+        return Iterator(Variable,
+            lib.eolian_state_constants_by_file_get(self._obj, 
_str_to_bytes(file_name)))
+
+    @property
+    def globals(self):
+        return Iterator(Variable, lib.eolian_state_globals_get(self._obj))
+
+    def global_by_name_get(self, name):
+        c_var = lib.eolian_state_global_by_name_get(self._obj, 
_str_to_bytes(name))
+        return Variable(c_var) if c_var else None
+
+    def globals_by_file_get(self, file_name):
+        return Iterator(Variable,
+            lib.eolian_state_globals_by_file_get(self._obj, 
_str_to_bytes(file_name)))
+
 
 ###  Namespace Utility Class  #################################################
 
diff --git a/src/scripts/pyolian/eolian_lib.py 
b/src/scripts/pyolian/eolian_lib.py
index afd747384a..75ab22246c 100644
--- a/src/scripts/pyolian/eolian_lib.py
+++ b/src/scripts/pyolian/eolian_lib.py
@@ -105,6 +105,30 @@ lib.eolian_state_class_by_file_get.restype = c_void_p
 lib.eolian_state_classes_get.argtypes = [c_void_p,]
 lib.eolian_state_classes_get.restype = c_void_p
 
+# EAPI const Eolian_Variable *eolian_state_global_by_name_get(const 
Eolian_State *state, const char *name);
+lib.eolian_state_global_by_name_get.argtypes = [c_void_p, c_char_p]
+lib.eolian_state_global_by_name_get.restype = c_void_p
+
+# EAPI const Eolian_Variable *eolian_state_constant_by_name_get(const 
Eolian_State *state, const char *name);
+lib.eolian_state_constant_by_name_get.argtypes = [c_void_p, c_char_p]
+lib.eolian_state_constant_by_name_get.restype = c_void_p
+
+# EAPI Eina_Iterator *eolian_state_globals_by_file_get(const Eolian_State 
*state, const char *file_name);
+lib.eolian_state_globals_by_file_get.argtypes = [c_void_p, c_char_p]
+lib.eolian_state_globals_by_file_get.restype = c_void_p
+
+# EAPI Eina_Iterator *eolian_state_constants_by_file_get(const Eolian_State 
*state, const char *file_name);
+lib.eolian_state_constants_by_file_get.argtypes = [c_void_p, c_char_p]
+lib.eolian_state_constants_by_file_get.restype = c_void_p
+
+# EAPI Eina_Iterator *eolian_state_constants_get(const Eolian_State *state);
+lib.eolian_state_constants_get.argtypes = [c_void_p,]
+lib.eolian_state_constants_get.restype = c_void_p
+
+# EAPI Eina_Iterator *eolian_state_globals_get(const Eolian_State *state);
+lib.eolian_state_globals_get.argtypes = [c_void_p,]
+lib.eolian_state_globals_get.restype = c_void_p
+
 # EAPI Eina_Iterator *eolian_declarations_get_by_file(const Eolian_State 
*state, const char *fname);
 lib.eolian_declarations_get_by_file.argtypes = [c_void_p, c_char_p]
 lib.eolian_declarations_get_by_file.restype = c_void_p
@@ -163,29 +187,21 @@ lib.eolian_typedecl_all_structs_get.restype = c_void_p
 lib.eolian_typedecl_all_enums_get.argtypes = [c_void_p,]
 lib.eolian_typedecl_all_enums_get.restype = c_void_p
 
-# EAPI const Eolian_Variable *eolian_variable_global_get_by_name(const 
Eolian_Unit *unit, const char *name);
-lib.eolian_variable_global_get_by_name.argtypes = [c_void_p, c_char_p]
-lib.eolian_variable_global_get_by_name.restype = c_void_p
-
-# EAPI const Eolian_Variable *eolian_variable_constant_get_by_name(const 
Eolian_Unit *unit, const char *name);
-lib.eolian_variable_constant_get_by_name.argtypes = [c_void_p, c_char_p]
-lib.eolian_variable_constant_get_by_name.restype = c_void_p
-
-# EAPI Eina_Iterator *eolian_variable_globals_get_by_file(const Eolian_Unit 
*unit, const char *fname);
-lib.eolian_variable_globals_get_by_file.argtypes = [c_void_p, c_char_p]
-lib.eolian_variable_globals_get_by_file.restype = c_void_p
+# EAPI const Eolian_Variable *eolian_unit_global_by_name_get(const Eolian_Unit 
*unit, const char *name);
+lib.eolian_unit_global_by_name_get.argtypes = [c_void_p, c_char_p]
+lib.eolian_unit_global_by_name_get.restype = c_void_p
 
-# EAPI Eina_Iterator *eolian_variable_constants_get_by_file(const Eolian_Unit 
*unit, const char *fname);
-lib.eolian_variable_constants_get_by_file.argtypes = [c_void_p, c_char_p]
-lib.eolian_variable_constants_get_by_file.restype = c_void_p
+# EAPI const Eolian_Variable *eolian_unit_constant_by_name_get(const 
Eolian_Unit *unit, const char *name);
+lib.eolian_unit_constant_by_name_get.argtypes = [c_void_p, c_char_p]
+lib.eolian_unit_constant_by_name_get.restype = c_void_p
 
-# EAPI Eina_Iterator *eolian_variable_all_constants_get(const Eolian_Unit 
*unit);
-lib.eolian_variable_all_constants_get.argtypes = [c_void_p,]
-lib.eolian_variable_all_constants_get.restype = c_void_p
+# EAPI Eina_Iterator *eolian_unit_constants_get(const Eolian_Unit *unit);
+lib.eolian_unit_constants_get.argtypes = [c_void_p,]
+lib.eolian_unit_constants_get.restype = c_void_p
 
-# EAPI Eina_Iterator *eolian_variable_all_globals_get(const Eolian_Unit *unit);
-lib.eolian_variable_all_globals_get.argtypes = [c_void_p,]
-lib.eolian_variable_all_globals_get.restype = c_void_p
+# EAPI Eina_Iterator *eolian_unit_globals_get(const Eolian_Unit *unit);
+lib.eolian_unit_globals_get.argtypes = [c_void_p,]
+lib.eolian_unit_globals_get.restype = c_void_p
 
 # EAPI Eina_Iterator *eolian_all_declarations_get(const Eolian_Unit *unit);
 lib.eolian_all_declarations_get.argtypes = [c_void_p,]
diff --git a/src/scripts/pyolian/test_eolian.py 
b/src/scripts/pyolian/test_eolian.py
index 25615993df..13c7b2aaf0 100755
--- a/src/scripts/pyolian/test_eolian.py
+++ b/src/scripts/pyolian/test_eolian.py
@@ -139,19 +139,19 @@ class TestEolianUnit(unittest.TestCase):
         self.assertGreater(all_count, 10)
 
     def test_variable_listing(self):
-        l = list(eolian_db.variable_all_constants)
+        l = list(eolian_db.constants)
         self.assertGreater(len(l), 2)
         self.assertIsInstance(l[0], eolian.Variable)
 
-        l = list(eolian_db.variable_all_globals)
+        l = list(eolian_db.globals)
         self.assertGreater(len(l), 20)
         self.assertIsInstance(l[0], eolian.Variable)
 
-        l = list(eolian_db.variable_constants_get_by_file('efl_gfx_stack.eo'))
+        l = list(eolian_db.constants_by_file_get('efl_gfx_stack.eo'))
         self.assertGreater(len(l), 1)
         self.assertIsInstance(l[0], eolian.Variable)
 
-        l = 
list(eolian_db.variable_globals_get_by_file('efl_net_http_types.eot'))
+        l = list(eolian_db.globals_by_file_get('efl_net_http_types.eot'))
         self.assertGreater(len(l), 10)
         self.assertIsInstance(l[0], eolian.Variable)
 
@@ -393,7 +393,7 @@ class TestEolianDocumentation(unittest.TestCase):
 
 class TestEolianVariable(unittest.TestCase):
     def test_variable_global(self):
-        var = 
eolian_db.variable_global_get_by_name('Efl.Net.Http.Error.BAD_CONTENT_ENCODING')
+        var = 
eolian_db.global_by_name_get('Efl.Net.Http.Error.BAD_CONTENT_ENCODING')
         self.assertIsInstance(var, eolian.Variable)
         self.assertEqual(var.full_name, 
'Efl.Net.Http.Error.BAD_CONTENT_ENCODING')
         self.assertEqual(var.name, 'BAD_CONTENT_ENCODING')
@@ -406,7 +406,7 @@ class TestEolianVariable(unittest.TestCase):
         self.assertIsNone(var.value)  # TODO is None correct here? no value?
 
     def test_variable_constant(self):
-        var = eolian_db.variable_constant_get_by_name('Efl.Gfx.Size.Hint.Fill')
+        var = eolian_db.constant_by_name_get('Efl.Gfx.Size.Hint.Fill')
         self.assertIsInstance(var, eolian.Variable)
         self.assertEqual(var.full_name, 'Efl.Gfx.Size.Hint.Fill')
         self.assertEqual(var.name, 'Fill')
@@ -575,7 +575,7 @@ class TestEolianExpression(unittest.TestCase):
         self.assertEqual(exp.serialize, '100')
 
     def test_expression_unary(self):
-        var = eolian_db.variable_constant_get_by_name('Efl.Gfx.Size.Hint.Fill')
+        var = eolian_db.constant_by_name_get('Efl.Gfx.Size.Hint.Fill')
         exp = var.value
         self.assertIsInstance(exp, eolian.Expression)
         self.assertEqual(exp.type, eolian.Eolian_Expression_Type.UNARY)

-- 


Reply via email to