Compare commits

..
4 Commits
Author SHA1 Message Date
Ole André Vadla Ravnås 082c9dfbc9 subprojects: Prepare for release 2026-07-20 17:56:01 +02:00
Ole André Vadla Ravnås 274c52291b bindgen: Fix formatting 2026-07-20 17:54:25 +02:00
Ole André Vadla Ravnås b9e24033ed subprojects: Bump outdated 2026-07-20 17:47:03 +02:00
Ole André Vadla Ravnås 10aeb056c6 bindgen: Fix options kwargs marshalling
Skip None values instead of passing them to typed setters.

Map collection kwargs onto their select_/add_ methods, walking
the parent chain. Affects specs, omits, externals, pids and
identifiers.
2026-07-20 17:45:06 +02:00
4 changed files with 44 additions and 8 deletions

No files matched your search

+32 -5
View File
@@ -70,10 +70,18 @@ def _to_envp(value):
return value
def _make_options(cls, values):
def _make_options(cls, values, selectors):
options = cls()
for name, value in values.items():
setattr(options, name, value)
if value is None:
continue
select = selectors.get(name)
if select is None:
setattr(options, name, value)
else:
add = getattr(options, select)
for element in value:
add(element)
return options
@@ -156,10 +164,18 @@ def _to_envp(value):
return value
def _make_options(cls, values):
def _make_options(cls, values, selectors):
options = cls()
for name, value in values.items():
setattr(options, name, value)
if value is None:
continue
select = selectors.get(name)
if select is None:
setattr(options, name, value)
else:
add = getattr(options, select)
for element in value:
add(element)
return options
@@ -575,7 +591,7 @@ def build_facade_async_parts(method: Method, model: Model) -> Optional[Tuple[str
options = resolve_options_type(param.type, model)
if options is not None:
signature.append("**kwargs")
args.append(f"_make_options(_frida.{options.py_name}, kwargs)")
args.append(f"_make_options(_frida.{options.py_name}, kwargs, {build_option_selectors(options)})")
elif resolve_input_object_type(param.type, model) is not None:
signature.append(f"{param.name}=None")
args.append(f"_unwrap({param.name})")
@@ -590,6 +606,17 @@ def build_facade_async_parts(method: Method, model: Model) -> Optional[Tuple[str
return ", ".join(signature), "".join(arg + ", " for arg in args)
def build_option_selectors(options: ObjectType) -> str:
selectors = {}
otype = options
while otype is not None:
for method in otype.methods:
if method.is_select_method:
selectors[method.select_plural_noun] = method.name
otype = otype.parent
return repr(selectors)
def wrap_result(call: str, type: Type, model: Model) -> str:
if resolve_object_type(type, model) is not None:
return f"_wrap({call})"
+3 -2
View File
@@ -120,8 +120,9 @@ if aux:
"attach": MethodCustomizations(
param_typings=["target", "**kwargs"],
custom_logic=(
"pid = self._pid_of(target)\n" "options = _make_options(_frida.SessionOptions, kwargs)",
"pid = await self._pid_of(target)\n" "options = _make_options(_frida.SessionOptions, kwargs)",
"pid = self._pid_of(target)\n" "options = _make_options(_frida.SessionOptions, kwargs, {})",
"pid = await self._pid_of(target)\n"
"options = _make_options(_frida.SessionOptions, kwargs, {})",
),
),
},
+8
View File
@@ -107,6 +107,14 @@ class Method(core.Method):
def operation_type_name(self) -> str:
return f"Py{self.object_type.name}{to_pascal_case(self.name)}Operation"
@cached_property
def is_select_method(self) -> bool:
return self.name.startswith("select_") or self.name.startswith("add_")
@cached_property
def select_plural_noun(self) -> str:
return f"{self.name.split('_', maxsplit=1)[1]}s"
@cached_property
def customizations(self) -> Optional[MethodCustomizations]:
custom = self.object_type.customizations
+1 -1
View File
@@ -1,6 +1,6 @@
[wrap-git]
url = https://github.com/frida/frida-core.git
revision = 17.16.2
revision = 17.16.3
depth = 1
[provide]