summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-07-15 15:20:57 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-08-16 17:04:59 -0300
commit2ab48a7c1667e38ba41ec11135d04b1677b755d7 (patch)
tree74e5a3a75c2f21bd8c3ae52e560c0314fc8a531e
parentf3b1df8ec4126dea3befec27a4ebe0a8f80d0557 (diff)
downloadefl-2ab48a7c1667e38ba41ec11135d04b1677b755d7.tar.gz
Use a flag to track wanted kind of functions
-rw-r--r--src/scripts/testgen/ekeys.py21
-rw-r--r--src/scripts/testgen/suitegen.py116
2 files changed, 82 insertions, 55 deletions
diff --git a/src/scripts/testgen/ekeys.py b/src/scripts/testgen/ekeys.py
index 64b6a20081..1a0d6a4d51 100644
--- a/src/scripts/testgen/ekeys.py
+++ b/src/scripts/testgen/ekeys.py
@@ -1,15 +1,16 @@
#!/usr/bin/env python3
# encoding: utf-8
-from enum import IntEnum
+from enum import IntEnum, IntFlag
from testgen import name_helpers
-class Function_List_Type(IntEnum):
- INHERITS = 1
- INHERITS_FULL = 2
- CLASS_IMPLEMENTS = 3
- CLASS_ONLY = 4
+class Function_List_Type(IntFlag):
+ OWN = 1
+ IMPLEMENTS = 2 # Overrides
+ EXTENSIONS = 4 # Interfaces/Mixins
+ INHERITED = 8 # Inherited but not overriden methods and classes
+ INHERITS_FULL = 4 & 8
class EKeys:
@@ -21,7 +22,7 @@ class EKeys:
self.blacklist = ["efl_constructor"]
self.keyloads = ["init", "shutdown", "custom"]
self.implementsbl = ["construtor", "destructor", "finalize"]
- self.funclist = Function_List_Type.CLASS_IMPLEMENTS
+ self.funclist = Function_List_Type.OWN | Function_List_Type.IMPLEMENTS
def type_convert(self, eotype):
return eotype.name
@@ -39,7 +40,11 @@ class EKeys:
class EMonoKeys(EKeys):
def __init__(self, ext):
super().__init__(ext)
- self.funclist = Function_List_Type.INHERITS_FULL
+ self.funclist = (
+ Function_List_Type.OWN
+ | Function_List_Type.IMPLEMENTS
+ | Function_List_Type.EXTENSIONS
+ )
self.dicttypes = {
"byte": "sbyte",
"llong": "long",
diff --git a/src/scripts/testgen/suitegen.py b/src/scripts/testgen/suitegen.py
index 7047104dae..493421b500 100644
--- a/src/scripts/testgen/suitegen.py
+++ b/src/scripts/testgen/suitegen.py
@@ -121,45 +121,26 @@ class ClassItem(ComItem):
return True
- def get_all_inherited(leaf, getter):
- print("Getting all items for leaf", leaf)
- names = set()
- for item in getter(leaf):
- print("Adding item", item.full_c_method_name)
- names.add(item.full_c_method_name)
- yield item
-
- for inherit in leaf.inherits_full:
- print("Inherit", inherit)
- for item in getter(inherit):
- print("Checking item", item.full_c_method_name)
- if item.full_c_method_name not in names:
- print("Adding item", item.full_c_method_name)
- names.add(item.full_c_method_name)
- yield item
-
- self.methods = [
- FuncItem(m, self.path, keys) for m in filter(mfilter, self.comp.methods)
- ]
- self._properties = [
- FuncItem(p, self.path, keys) for p in filter(mfilter, self.comp.properties)
- ]
- self.events = [EventItem(s, self.path, keys) for s in self.comp.events]
-
- if self.keys.funclist in (
- Function_List_Type.INHERITS,
- Function_List_Type.INHERITS_FULL,
- ):
- for eoclass in (
- self.comp.inherits
- if self.keys.funclist == Function_List_Type.INHERITS
- else self.comp.inherits_full
- ):
- for f in filter(mfilter, eoclass.methods):
- self.methods.append(FuncItem(f, self.path, keys))
- for f in filter(mfilter, eoclass.properties):
- self._properties.append(FuncItem(f, self.path, keys))
- elif self.keys.funclist == Function_List_Type.CLASS_IMPLEMENTS:
+ if self.keys.funclist & Function_List_Type.OWN:
+ self._methods = {
+ m.name: FuncItem(m, self.path, keys)
+ for m in self.comp.methods
+ if mfilter(m)
+ }
+ self._properties = {
+ p.name: FuncItem(p, self.path, keys)
+ for p in self.comp.properties
+ if mfilter(p)
+ }
+ self._events = {
+ e.name: EventItem(e, self.path, keys) for e in self.comp.events
+ }
+ else:
+ self._methods = {}
+ self._properties = {}
+ self._events = {}
+
+ if self.keys.funclist & Function_List_Type.IMPLEMENTS:
for imp in comp.implements:
if (
@@ -169,26 +150,67 @@ class ClassItem(ComItem):
continue
f = imp.function
- if f.type == Eolian_Function_Type.METHOD and mfilter(f):
- self.methods.append(FuncItem(f, self.path, keys))
- if f.type in (
+
+ if not mfilter(f):
+ continue
+
+ if f.type == Eolian_Function_Type.METHOD:
+ if f.name in self._methods:
+ continue
+ self._methods[f.name] = FuncItem(f, self.path, keys)
+ elif f.type in (
Eolian_Function_Type.PROPERTY,
Eolian_Function_Type.PROP_GET,
Eolian_Function_Type.PROP_SET,
- ) and mfilter(f):
- self._properties.append(FuncItem(f, self.path, keys))
+ ):
+ if f.name in self._properties:
+ continue
+ self._properties[f.name] = FuncItem(f, self.path, keys)
+
+ parents = []
+
+ if self.keys.funclist & Function_List_Type.INHERITS_FULL:
+ # Use inherits full to get inherited interfaces too
+ parents = self.comp.inherits_full
+ else:
+ if self.keys.funclist & Function_List_Type.EXTENSIONS:
+ parents = self.comp.extensions_hierarchy
+
+ if self.keys.funclist & Function_List_Type.INHERITED:
+ if parents:
+ parents = itertools.chain(self.comp.hierarchy, parents)
+ else:
+ parents = self.comp.hierarchy
+
+ for eoclass in parents:
+ for f in filter(mfilter, eoclass.methods):
+ if f.name in self._methods:
+ continue
+ self._methods[f.name] = FuncItem(f, self.path, keys)
+ for f in filter(mfilter, eoclass.properties):
+ if f.name in self._properties:
+ continue
+ self._properties[f.name] = FuncItem(f, self.path, keys)
@property
def properties(self):
- return filter(lambda p: p.has_setter or p.has_getter, self._properties)
+ return filter(lambda p: p.has_setter or p.has_getter, self._properties.values())
@property
def properties_get(self):
- return filter(lambda p: p.has_getter, self._properties)
+ return filter(lambda p: p.has_getter, self._properties.values())
@property
def properties_set(self):
- return filter(lambda p: p.has_setter, self._properties)
+ return filter(lambda p: p.has_setter, self._properties.values())
+
+ @property
+ def methods(self):
+ return self._methods.values()
+
+ @property
+ def events(self):
+ return self._events.values()
def __iter__(self):
return itertools.chain(self.methods, self.properties)