From: Martin Ling Date: Tue, 20 Oct 2015 20:05:36 +0000 (+0100) Subject: java: Fix SWIG warnings due to dodgy %extend redefinitions. X-Git-Tag: libsigrok-0.4.0~211 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=85aa1b599fdb40d8a8df65744186688f85e53dd7;p=libsigrok.git java: Fix SWIG warnings due to dodgy %extend redefinitions. If we're going to %extend these methods, we need to firstly ignore the originals, and secondly implement all possible argument combinations. This fixes the rest of bug #417. --- diff --git a/bindings/java/org/sigrok/core/classes/classes.i b/bindings/java/org/sigrok/core/classes/classes.i index 5cf25836..34323b16 100644 --- a/bindings/java/org/sigrok/core/classes/classes.i +++ b/bindings/java/org/sigrok/core/classes/classes.i @@ -208,31 +208,69 @@ MAP_COMMON(const sigrok::ConfigKey *, Glib::VariantBase, ConfigKey, Variant) } /* Support Driver.scan() with no arguments. */ +%ignore sigrok::Driver::scan; + %extend sigrok::Driver { std::vector > scan() { std::map options; return $self->scan(options); } + + std::vector > scan( + std::map options) + { + return $self->scan(options); + } } -/* Support InputFormat.create_input() with no options. */ +/* Support InputFormat.create_input() with or without options. */ +%ignore sigrok::InputFormat::create_input; + %extend sigrok::InputFormat { std::shared_ptr create_input() { - std::map options; + return $self->create_input(); + } + + std::shared_ptr create_input( + std::map options) + { return $self->create_input(options); } } -/* Support OutputFormat.create_output(device) with no options. */ +/* Support OutputFormat.create_output() with or without options. */ +%ignore sigrok::OutputFormat::create_output; + %extend sigrok::OutputFormat { std::shared_ptr create_output( std::shared_ptr device) { - std::map options; + return $self->create_output(device); + } + + std::shared_ptr create_output( + std::shared_ptr device, + std::map options) + { return $self->create_output(device, options); } + + std::shared_ptr create_output( + std::string filename, + std::shared_ptr device) + { + return $self->create_output(filename, device); + } + + std::shared_ptr create_output( + std::string filename, + std::shared_ptr device, + std::map options) + { + return $self->create_output(filename, device, options); + } } /* Pass JNIEnv parameter to C++ extension methods requiring it. */