@@ -448,11 +448,12 @@ def generate_custom_facade_method(
448448 method : Method , logic : Union [str , Tuple [str , str ]], model : Model , awaitable : bool
449449) -> str :
450450 signature = ", " .join (["self" ] + method .custom_facade_params )
451+ args = facade_call_args (method , model )
451452 if method .is_async :
452- invoke = f"_invoke(self._impl.{ method .name } , ({ method . facade_call_args } ))"
453+ invoke = f"_invoke(self._impl.{ method .name } , ({ args } ))"
453454 call = f"await { invoke } " if awaitable else invoke
454455 else :
455- call = f"self._impl.{ method .name } ({ method . facade_call_args } )"
456+ call = f"self._impl.{ method .name } ({ args } )"
456457 if method .return_value is not None :
457458 call = wrap_result (call , method .return_value .type , model )
458459
@@ -468,6 +469,20 @@ def generate_custom_facade_method(
468469 return { call } """
469470
470471
472+ def facade_call_args (method : Method , model : Model ) -> str :
473+ takes_kwargs = any (param .split (":" )[0 ].strip () == "**kwargs" for param in method .custom_facade_params )
474+ args = []
475+ for param in method .input_parameters :
476+ if param .type .name == "Gio.Cancellable" :
477+ continue
478+ options = resolve_options_type (param .type , model )
479+ if options is not None and takes_kwargs :
480+ args .append (make_options_expr (options ))
481+ else :
482+ args .append (param .name )
483+ return "" .join (arg + ", " for arg in args )
484+
485+
471486def generate_py_exception_reexports (model : Model ) -> List [str ]:
472487 names = [f"{ name } Error" for _ , name in error_members (model )]
473488 names .append ("OperationCancelledError" )
@@ -703,7 +718,7 @@ def build_facade_async_parts(method: Method, model: Model) -> Optional[Tuple[str
703718 options = resolve_options_type (param .type , model )
704719 if options is not None :
705720 params .append ("**kwargs" )
706- args .append (f"_make_options(_frida. { options . py_name } , kwargs, { build_option_selectors ( options ) } )" )
721+ args .append (make_options_expr ( options ) )
707722 elif resolve_input_object_type (param .type , model ) is not None :
708723 params .append (f"{ param .name } : Optional[{ pyi_type (param .type , model )} ] = None" )
709724 args .append (f"_unwrap({ param .name } )" )
@@ -718,6 +733,10 @@ def build_facade_async_parts(method: Method, model: Model) -> Optional[Tuple[str
718733 return facade_signature (method , params ), "" .join (arg + ", " for arg in args )
719734
720735
736+ def make_options_expr (options : ObjectType ) -> str :
737+ return f"_make_options(_frida.{ options .py_name } , kwargs, { build_option_selectors (options )} )"
738+
739+
721740def build_option_selectors (options : ObjectType ) -> str :
722741 selectors = {}
723742 otype = options
0 commit comments