This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch eolian/improvements
in repository efl.
View the commit online.
commit 2114e166d2bae1ce19073ed8e7a8ad24e3f7785f
Author: Cedric BAIL <[email protected]>
AuthorDate: Tue Aug 18 23:11:18 2026 -0600
scripts: audit that every global function is declared @static
A function with no Eo * receiver is a global, eolian records that as @static,
and eolian_function_is_static() is how a binding generator is supposed to
learn it. Generators have not trusted that: ego carries a hand-written
globalFunctionSet of 26 C function names to route around the database.
The script decides the question from the generated prototypes instead of
from a list, comparing each function's first C parameter against what its
.eo says, and reporting disagreements in both directions. EFL passes: 2056
functions audited, 26 declared @static, none undeclared and none annotated
that actually takes a receiver.
Which makes ego's list not just redundant but wrong in both directions. 25
of its 26 entries are genuinely @static and need no special case; the 26th,
efl_net_ip_address_sockaddr_set, is an ordinary instance method that takes
Eo *obj and does not belong there at all; and real statics are missing
from it, among them efl_ui_focus_util_focus and the three
efl_access_object_event_* calls. Reading the bit fixes all three at once.
Co-Authored-By: Claude Opus 5 <[email protected]>
---
scripts/check-static-decl.py | 130 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 130 insertions(+)
diff --git a/scripts/check-static-decl.py b/scripts/check-static-decl.py
new file mode 100755
index 0000000000..e03aa154b7
--- /dev/null
+++ b/scripts/check-static-decl.py
@@ -0,0 +1,130 @@
+#!/usr/bin/env python3
+"""Check that every global EFL function is declared @static in its .eo.
+
+A function with no `Eo *obj` receiver is a global. Eolian records that as
+@static, and `eolian_function_is_static()` tells a binding generator which
+codegen path to take. Where the .eo forgets the keyword the generator sees a
+method whose C prototype has no object to pass, and historically each generator
+grew a hand-maintained list of names to special-case instead -- ego's
+`globalFunctionSet` is one such list, with 27 entries.
+
+This script decides the question from the generated prototypes rather than from
+a list. For every declared function it compares:
+
+ the first parameter of the generated C prototype (Eo *obj / const Eo *obj?)
+ what the .eo says (@static or not)
+
+and reports every disagreement in either direction:
+
+ global but not @static the generator cannot know without being told
+ @static but has a receiver the annotation is wrong
+
+Both are defects. A clean run means a generator can rely on the database alone.
+
+Usage: scripts/check-static-decl.py [build-dir] (default: build)
+"""
+
+import glob
+import os
+import re
+import sys
+
+BUILD = sys.argv[1] if len(sys.argv) > 1 else 'build'
+ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+sys.path.insert(0, os.path.join(ROOT, 'src', 'scripts', 'pyolian'))
+os.environ.setdefault('EOLIAN_LIB', os.path.join(BUILD, 'src/lib/eolian/libeolian.so.1'))
+
+import eolian # noqa: E402
+from eolian import Eolian_Function_Type as FT # noqa: E402
+
+
+def load_state():
+ st = eolian.Eolian_State()
+ dirs = set(os.path.dirname(p)
+ for p in glob.glob(os.path.join(ROOT, 'src/lib/**/*.eo*'), recursive=True))
+ for d in dirs:
+ st.directory_add(d)
+ if not st.all_eot_files_parse() or not st.all_eo_files_parse():
+ sys.exit('eolian failed to parse the tree')
+ return st
+
+
+PROTO_RE = re.compile(
+ r'\b[A-Z][A-Z0-9_]*API(?:\s+[A-Z][A-Z0-9_]*API_WEAK)?\s+[^;()]*?'
+ r'\b([a-z][a-z0-9_]*)\s*\(([^;]*?)\)\s*(?:EINA_[A-Z_]+\s*)*;', re.S)
+
+RECEIVER_RE = re.compile(r'^\s*(?:const\s+)?Eo\s*\*')
+
+
+def load_receivers():
+ """Whether each generated prototype takes an Eo * receiver first."""
+ receivers = {}
+ for header in glob.glob(os.path.join(BUILD, 'src/lib/**/*.eo.h'), recursive=True):
+ text = open(header, encoding='utf-8', errors='replace').read()
+ text = re.sub(r'/\*.*?\*/', '', text, flags=re.S)
+ for match in PROTO_RE.finditer(text):
+ name, args = match.group(1), match.group(2).strip()
+ if args in ('void', ''):
+ receivers[name] = False
+ else:
+ receivers[name] = bool(RECEIVER_RE.match(args.split(',')[0]))
+ return receivers
+
+
+FTYPES = {
+ FT.METHOD: [FT.METHOD],
+ FT.PROPERTY: [FT.PROP_GET, FT.PROP_SET],
+ FT.PROP_GET: [FT.PROP_GET],
+ FT.PROP_SET: [FT.PROP_SET],
+}
+
+
+def main():
+ state = load_state()
+ receivers = load_receivers()
+
+ audited = 0
+ statics = 0
+ undeclared = []
+ spurious = []
+
+ seen = set()
+ for cls in state.classes:
+ funcs = list(cls.functions_get(FT.METHOD)) + list(cls.functions_get(FT.PROPERTY))
+ for func in funcs:
+ for ftype in FTYPES.get(func.type, []):
+ cname = func.full_c_name_get(ftype)
+ if not cname or cname in seen or cname not in receivers:
+ continue
+ seen.add(cname)
+ audited += 1
+
+ has_receiver = receivers[cname]
+ if func.is_static:
+ statics += 1
+ if has_receiver:
+ spurious.append((cname, cls.name))
+ elif not has_receiver:
+ undeclared.append((cname, cls.name))
+
+ print('audited %d functions, %d declared @static' % (audited, statics))
+
+ if undeclared:
+ print(' %4d global functions NOT declared @static:' % len(undeclared))
+ for cname, cls in sorted(undeclared):
+ print(' %-56s %s' % (cname, cls))
+ if spurious:
+ print(' %4d @static functions that take a receiver:' % len(spurious))
+ for cname, cls in sorted(spurious):
+ print(' %-56s %s' % (cname, cls))
+
+ if undeclared or spurious:
+ return 1
+
+ print('every global function is declared @static')
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.