[Xcb] [PATCH libxcb 1/1] move symbol lookup of sumof expr to the parser
Christian Linhart
chris at demorecorder.com
Fri Jan 20 14:16:34 UTC 2017
replace the complicated symboltable lookup for sumof expr
by accessing the lenfield of the expr-object.
This requires the corresponding patch for xcb/proto
which sets the lenfield accordingly.
This should be OK because for official releases we define
that dependency in the build system.
For getting versions off the HEAD of the git repo, it should
be obvious that xcb/proto and xcb/libxcb have to be updated together.
I have tested this patch and it generates exactly the same code
as before.
Tested-by: Christian Linhart <chris at demorecorder.com>
Signed-off-by: Christian Linhart <chris at demorecorder.com>
---
src/c_client.py | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/src/c_client.py b/src/c_client.py
index 043338d..b0eb47c 100644
--- a/src/c_client.py
+++ b/src/c_client.py
@@ -1657,22 +1657,15 @@ def _c_accessor_get_expr(expr, field_mapping):
elif expr.op == 'enumref':
enum_name = expr.lenfield_type.name
constant_name = expr.lenfield_name
c_name = _n(enum_name + (constant_name,)).upper()
return c_name
elif expr.op == 'sumof':
# locate the referenced list object
- field = None
- for f in expr.lenfield_parent.fields:
- if f.field_name == expr.lenfield_name:
- field = f
- break
-
- if field is None:
- raise Exception("list field '%s' referenced by sumof not found" % expr.lenfield_name)
+ field = expr.lenfield
list_name = field_mapping[field.c_field_name][0]
c_length_func = "%s(%s)" % (field.c_length_name, list_name)
c_length_func = _c_accessor_get_expr(field.type.expr, field_mapping)
# create explicit code for computing the sum.
# This works for all C-types which can be added to int64_t with +=
_c_pre.start()
lengthvar = _c_pre.get_tempvarname()
--
2.1.4
More information about the Xcb
mailing list