Compare commits

Author SHA1 Message Date
Anton Kochkov 9bee5c3771 Merge 'dev' branch into stable 2026-06-21 11:31:54 +04:00
Anton Kochkov dd35844550 Merge branch 'stable' into stable-merge 2026-06-21 11:31:42 +04:00
e4aef7d474 Merge dev into stable (#81)
* Add bindings for HtSP, HtSS, HtSU (#57)

* Format via black & fix lint check

* Revert "Format via black & fix lint check"

This reverts commit aa3340800e.

* Add missing HT types to lint.py (#58)

* ci: update used pypa/cibuildwheel version (#59)

* Add missing `ht_*` headers into cparser_header.py (#60)

* Fix SWIG snippet example (#61)

* Use `manylinux2014` base image instead (#62)

* Use `manylinux2014` base image instead
* Drop i686 support

* Uniquify artifact names (#63)

* Print filename when assert.

* Remove SdbList as it was removed in Rizin (#64)

* Remove lastline from RzCons bindings

* Update pypa/cibuildwheel to 2.22.0

* ci: use macOS 14 as macOS 12 is deprecated

* ci: support pip3 for python 3.12 and later

* Fix wrong check on nonnull args which are inner not outer.

* Revert "Fix wrong check on nonnull args which are inner not outer."

This reverts commit c527db8fcb.

* Ensure argument name never matches the function name

* Use `/` instead of `\\` in CMAKE_PREFIX_PATH for Windows (#72)

* ci/mypy: disable unnecessary warning (#73)

* ci: use corresponding rizin branch (#75)

* ci: use corresponding rizin branch

* Fix compilation (#77)

* Fix compilation due defines being redefined
* Add support for TypeKind.FUNCTIONNOPROTO

* ci: Upgrade to Ubuntu 24.04 (Noble) (#79)

* ci: Upgrade to Ubuntu 24.04 (Noble)
* Remove `pip3 --break-system-packages`
* Use `-include linux/limits.h` for Alpine build

* Cleanup inclusion of linux/limits.h (#80)

---------

Co-authored-by: pelijah <[email protected]>
Co-authored-by: wargio <[email protected]>
Co-authored-by: Anton Kochkov <[email protected]>
Co-authored-by: Khairul Azhar Kasmiran <[email protected]>
Co-authored-by: Anton Kochkov <[email protected]>
Co-authored-by: wargio <[email protected]>
Co-authored-by: Giovanni <[email protected]>
2025-04-22 23:49:20 +08:00
NOT XVilka a03d1f32f5 Merge branch 'stable' into update-stable 2025-04-22 23:25:16 +08:00
Anton Kochkov fc64be188f ci: use corresponding rizin branch 2024-12-21 20:45:37 +08:00
Anton Kochkov aabbf0df6b ci: use corresponding rizin branch (#75) 2024-12-21 20:18:02 +08:00
Anton Kochkov 5740a3770b ci/mypy: disable unnecessary warning (#73) 2024-12-21 20:18:02 +08:00
Khairul Azhar Kasmiran 878f562385 Use / instead of \\ in CMAKE_PREFIX_PATH for Windows (#72) 2024-12-21 20:18:02 +08:00
wargio a71ec49cf0 Ensure argument name never matches the function name 2024-12-21 20:18:02 +08:00
Anton Kochkov 48bc95c67a ci: support pip3 for python 3.12 and later 2024-12-21 20:18:02 +08:00
Anton Kochkov 4a15bfe470 ci: use macOS 14 as macOS 12 is deprecated 2024-12-21 20:18:02 +08:00
Anton Kochkov f9456f670c Update pypa/cibuildwheel to 2.22.0 2024-12-21 20:18:02 +08:00
wargio 961e34a258 Print filename when assert. 2024-12-21 20:18:02 +08:00
Khairul Azhar Kasmiran ad843b76d1 Uniquify artifact names (#63) 2024-12-21 20:18:02 +08:00
Khairul Azhar Kasmiran 00422160f1 Use manylinux2014 base image instead (#62)
* Use `manylinux2014` base image instead
* Drop i686 support
2024-12-21 20:18:02 +08:00
Anton Kochkov fadef06f39 ci: update used pypa/cibuildwheel version (#59) 2024-12-21 20:18:02 +08:00
5 changed files with 8 additions and 131 deletions

No files matched your search

-13
View File
@@ -42,7 +42,6 @@ class Class:
fields: OrderedDict[str, Field]
funcs: OrderedDict[str, Func]
methods: OrderedDict[str, Func]
python_methods: OrderedDict[str, List[str]]
constructor: Optional[Func]
destructor: Optional[Func]
@@ -83,7 +82,6 @@ class Class:
self.fields = OrderedDict()
self.funcs = OrderedDict()
self.methods = OrderedDict()
self.python_methods = OrderedDict()
self.constructor = None
self.destructor = None
@@ -194,17 +192,6 @@ class Class:
assert rename not in self.methods
self.methods[rename] = method
def add_python_method(self, decl: str, *lines: str) -> None:
"""
Add a pure-python method with the given declaration
Used for protocol methods such as __iter__ and __len__ which
have no direct C counterpart. The generated SWIG output wraps
these in a %pythoncode block inside the class %extend.
"""
assert decl not in self.python_methods
self.python_methods[decl] = [f"def {decl}:"] + [f" {line}" for line in lines]
def add_prefixed_methods(self, prefix: str) -> None:
"""
Add C functions with a given prefix, and that take a
+7 -57
View File
@@ -51,20 +51,6 @@ def run() -> None:
func(Header(translation_unit, builder))
def bind_ht_iterators(ht: Class, prefix: str) -> None:
"""
Bind the RzIterator-returning helpers shared by every hashtable type
(see ht_inc.h). These return an `RzIterator *`, which is bound as an
iterable class by ``bind_iterator``.
``as_iter``/``as_iter_keys`` yield immutable values/keys; ``as_iter_mut``
yields mutable values.
"""
ht.add_method(f"{prefix}as_iter", rename="as_iter")
ht.add_method(f"{prefix}as_iter_keys", rename="as_iter_keys")
ht.add_method(f"{prefix}as_iter_mut", rename="as_iter_mut")
############
# GENERICS #
############
@@ -151,35 +137,6 @@ def bind_vector(vector_h: Header) -> None:
rz_pvector.add_python_method("__iter__(self)", "return RzPVectorIterator(self)")
@threaded_header("rz_util/rz_iterator.h")
def bind_iterator(iterator_h: Header) -> None:
"""
RzIterator
The generic, lazy Rizin iterator (see rz_iterator.h / iterator.c).
Many Rizin functions return an `RzIterator *` (e.g. the hashtable
`as_iter*` helpers, `rz_set_*_as_iter`, graph traversals, ...).
`RzIterator` is type-erased in C: `rz_iterator_next` returns a borrowed
`void *`, so elements are yielded as opaque pointers. Binding it as a
class makes every such return value directly usable from a `for` loop
via the `RzIteratorIterator` python helper, and ties its lifetime to
`rz_iterator_free` through the destructor.
"""
# rz_iterator_new takes C callbacks and cannot be bound
iterator_h.ignore("rz_iterator_new")
rz_iterator = Class(
iterator_h,
typedef="RzIterator",
# Internal state and callbacks, not useful from the guest language
ignore_fields={"cur", "u", "next", "free", "free_u"},
)
rz_iterator.add_method("rz_iterator_next", rename="next")
rz_iterator.add_destructor("rz_iterator_free")
rz_iterator.add_python_method("__iter__(self)", "return RzIteratorIterator(self)")
###########
# HEADERS #
###########
@@ -477,8 +434,7 @@ def bind_ht_pp(ht_pp_h: Header) -> None:
"""
ht_pp
"""
ht_pp = Class(ht_pp_h, typedef="HtPP")
bind_ht_iterators(ht_pp, "ht_pp_")
Class(ht_pp_h, typedef="HtPP")
@threaded_header("rz_util/ht_pu.h")
@@ -486,8 +442,7 @@ def bind_ht_pu(ht_pu_h: Header) -> None:
"""
ht_pu
"""
ht_pu = Class(ht_pu_h, typedef="HtPU")
bind_ht_iterators(ht_pu, "ht_pu_")
Class(ht_pu_h, typedef="HtPU")
@threaded_header("rz_util/ht_up.h")
@@ -495,8 +450,7 @@ def bind_ht_up(ht_up_h: Header) -> None:
"""
ht_up
"""
ht_up = Class(ht_up_h, typedef="HtUP")
bind_ht_iterators(ht_up, "ht_up_")
Class(ht_up_h, typedef="HtUP")
@threaded_header("rz_util/ht_uu.h")
@@ -504,8 +458,7 @@ def bind_ht_uu(ht_uu_h: Header) -> None:
"""
ht_uu
"""
ht_uu = Class(ht_uu_h, typedef="HtUU")
bind_ht_iterators(ht_uu, "ht_uu_")
Class(ht_uu_h, typedef="HtUU")
@threaded_header("rz_util/ht_sp.h")
@@ -513,8 +466,7 @@ def bind_ht_sp(ht_sp_h: Header) -> None:
"""
ht_sp
"""
ht_sp = Class(ht_sp_h, typedef="HtSP")
bind_ht_iterators(ht_sp, "ht_sp_")
Class(ht_sp_h, typedef="HtSP")
@threaded_header("rz_util/ht_ss.h")
@@ -522,8 +474,7 @@ def bind_ht_ss(ht_ss_h: Header) -> None:
"""
ht_ss
"""
ht_ss = Class(ht_ss_h, typedef="HtSS")
bind_ht_iterators(ht_ss, "ht_ss_")
Class(ht_ss_h, typedef="HtSS")
@threaded_header("rz_util/ht_su.h")
@@ -531,5 +482,4 @@ def bind_ht_su(ht_su_h: Header) -> None:
"""
ht_su
"""
ht_su = Class(ht_su_h, typedef="HtSU")
bind_ht_iterators(ht_su, "ht_su_")
Class(ht_su_h, typedef="HtSU")
+1 -13
View File
@@ -221,13 +221,7 @@ def write_class(writer: Writer, cls: Class) -> None:
writer.line(f'%rename {cls.struct_name}::{field.name} "";')
# Extension
if (
len(cls.funcs) != 0
or len(cls.methods) != 0
or len(cls.python_methods) != 0
or cls.constructor
or cls.destructor
):
if len(cls.funcs) != 0 or len(cls.methods) != 0:
writer.line(f"%extend {cls.struct_name} {{")
with writer.indent():
if cls.constructor:
@@ -241,12 +235,6 @@ def write_class(writer: Writer, cls: Class) -> None:
for name, method in cls.methods.items():
write_func(writer, method, name, FuncKind.METHOD)
for python_lines in cls.python_methods.values():
writer.line("%pythoncode %{")
with writer.indent():
writer.line(*python_lines)
writer.line("%}")
writer.line("}")
-28
View File
@@ -114,26 +114,6 @@ generic_types = {"RzList", "RzListIter", "RzPVector", "RzVector", "RzGraph", "Ht
skip_files = {"ht_inc.c", "ht_inc.h", "rz_th_ht.h", "thread_hash_table.c"}
def check_iterator_comment(comment: str, location: SourceLocation) -> None:
"""
Validate an RzIterator /*<type>*/ comment.
RzIterator is type-erased and takes a single element-type parameter
(unlike the two-parameter RzGraph/HtPP form). The comment is optional in
rizin -- the element type is often not known statically -- so RzIterator is
deliberately kept out of `generic_types`. When present, the comment must
name exactly one type.
"""
inner = comment[1:-1].strip()
if not inner:
warn(f"Type comment at {stringify_location(location)} for RzIterator is empty")
elif "," in inner:
warn(
f"Type comment at {stringify_location(location)} for "
f"RzIterator must name exactly one type. Is: '{comment}'"
)
def cursor_get_comment(cursor: Cursor, *, packed: bool = False) -> Optional[str]:
"""
Get /*<type>*/ comment on a cursor
@@ -202,12 +182,6 @@ def cursor_get_comment(cursor: Cursor, *, packed: bool = False) -> Optional[str]
return None
comment = comment[2:-2]
# Normalize surrounding whitespace so both the compact `/*<T>*/` style and
# the space-padded `/* <T> */` style (used by RzIterator helpers) are
# recognized. Existing annotations have no padding, so this is a no-op for
# them.
comment = comment.strip()
if not comment.startswith("<") or not comment.endswith(">"):
if typeref_spelling in generic_types:
warn(
@@ -253,8 +227,6 @@ def cursor_get_comment(cursor: Cursor, *, packed: bool = False) -> Optional[str]
"SdbList",
}:
pass
elif typeref_spelling == "RzIterator":
check_iterator_comment(comment, cursor.location)
else:
warn(
f"Type comment at {stringify_location(cursor.location)} "
-20
View File
@@ -34,23 +34,3 @@ class RzPVectorIterator:
data = self.rzpvector.at(self.index)
self.index += 1
return data
class RzIteratorIterator:
def __init__(self, rziterator):
self.iter = rziterator
def __iter__(self):
return self
def __next__(self):
if self.iter is None:
raise StopIteration
data = self.iter.next()
if data is None:
# Iteration is done: hand ownership of the RzIterator to SWIG so
# rz_iterator_free is called once the last reference is dropped.
self.iter.thisown = True
self.iter = None
raise StopIteration
return data