Commit Graph

256 Commits

Author SHA1 Message Date
Soeren Apel b6b4f03e40 Input: Add reset() function 2016-05-09 13:02:29 +02:00
Soeren Apel 0221cbdde3 Bindings: Check for empty opts also in Configurable::config_keys() 2016-05-09 12:55:04 +02:00
EJ 116670b15d Fix #786 by checking for opts in the bindings 2016-04-17 09:30:54 +02:00
Soeren Apel d9d57ceb28 Bindings: Update create_analog_packet() to the new analog format 2016-03-22 08:25:08 +01:00
Aurelien Jacobs 27d44cf6e0 Implement Ruby bindings on top of SWIG/C++ bindings. 2016-01-28 19:03:52 +01:00
Daniel Elstner 32ba0d8005 resource: Replace ssize_t with gssize to avoid unistd.h 2016-01-04 20:53:30 +01:00
Martin Ling c61e208d26 python: Provide sensible __str__ and __repr__ functions for enum values.
This fixes bug #668.
2016-01-04 20:49:35 +01:00
Daniel Elstner 8c52989811 C++: Avoid std::map::emplace() for GCC 4.7 compatibility
This fixes bug #720.
2016-01-03 00:51:37 +01:00
Uwe Hermann 8141a0325c Rename sr_driver_scan_options() to sr_driver_scan_options_list(). 2015-12-31 19:04:34 +01:00
Uwe Hermann 0c697a4b33 Rename sr_dev_config_capabilities() to sr_dev_config_capabilities_list(). 2015-12-31 19:04:28 +01:00
Martin Ling 36bb818d6f bindings: New configuration enumeration API.
The new methods wrap the new libsigrok C API helper functions and eliminate
the need to pass complex types back to the user and wrap them with SWIG.

Fixes bugs #479 and #480.
2015-12-31 19:00:16 +01:00
Martin Ling 12f2f640cb bindings: Wrap enum sr_configcap as Capability class. 2015-12-31 18:27:56 +01:00
Stefan Brüns 7cccc9155c bindings/cxx: make sure the config value reference is kept
fixes glib warning:
GLib-CRITICAL **: g_variant_unref: assertion 'value->ref_count > 0' failed
2015-12-04 23:18:14 +01:00
Marcus Comstedt 8eb4299c5b bindings: Fix doc extraction for enums
The source file enum.hpp was not found when not building in the source
tree.  Also, extraction of the brief description did not work correctly
when there was additional XML markup inside the <para> element.
2015-12-03 22:01:21 +01:00
Marcus Comstedt ee95d6bd8b Java: Remove explicit constructor deletes since SWIG 2 doesn't like them
bindings/java/org/sigrok/core/classes/classes.i:247: Error: \
    Syntax error in input(3).
2015-11-02 18:46:05 +01:00
Marcus Comstedt e13648d041 Java: Fix leaking global refs
This fixes issue #690.
2015-11-02 18:37:10 +01:00
Marcus Comstedt c470ae86da Java: Don't use JNIEnv* captured by lambdas, it may be invalid for the context 2015-11-02 18:37:10 +01:00
Marcus Comstedt 908aad3816 Java: Fill jlongs with 0 when doing SWIG style pointer marshalling
This prevents valgrind complaints and also makes pointer comparison
from the Java side work.
2015-11-02 18:37:10 +01:00
Marcus Comstedt 32fd1edc23 Revert "Java: Avoid dangerous writes via casted pointers"
This reverts commit 865de99391.

This fixes bug #688.
2015-11-02 18:37:10 +01:00
Martin Ling ae2cdde4d2 python: Fix string conversions for Python 3.
Fixes bug #478.
2015-11-02 18:35:18 +01:00
Daniel Elstner 014512254a C++: Declare std::default_delete friend as struct
std::default_delete<> is originally defined as struct, not class.
This does not really make much of a difference, but some compilers
complain when the struct/class tag is not consistent across all
declarations of the type.
2015-10-30 15:09:40 +01:00
Daniel Elstner cea8c3124f C++: Suppress deprecation warnings from glibmm
Ignore warnings due to use of std::auto_ptr<> in the glibmm headers.
This should be reverted once glibmm is fixed.
2015-10-30 12:51:16 +01:00
Daniel Elstner 8ebf1469a9 build: Use common SWIG defines for Python and Java
Make the Python and Java bindings use the same set of preprocessor
macros for the SWIG parsing stage, taken from a make variable. Add
G_GNUC_{BEGIN,END}_IGNORE_DEPRECATIONS to that set.
2015-10-30 12:51:16 +01:00
Daniel Elstner 865de99391 Java: Avoid dangerous writes via casted pointers
Writing to an object through a pointer of incompatible type is
really evil. Even when the data size matches, it is still a
violation of strict aliasing rules.

Replace all instances by direct casts of the value, without the
unnecessary and dangerous indirection.
2015-10-26 07:29:50 +01:00
Daniel Elstner b0b0e2009c SWIG: Avoid unseparated template closing brackets
SWIG 2.0.12 fails with a syntax error on ">>".
2015-10-26 07:18:55 +01:00
Martin Ling 4aa9a1e569 C++: Catch exceptions from stoi() and stod().
Fixes bug #483.
2015-10-26 07:17:50 +01:00
Martin Ling f2831ab35b java: Usable wrapping of Configurable.config_keys(). 2015-10-26 07:17:01 +01:00
Martin Ling df979d6dc6 python: Give all enum values __doc__ strings. 2015-10-26 07:17:01 +01:00
Martin Ling ef9643a2bb python: Add docstrings for enum constants. 2015-10-26 07:17:01 +01:00
Martin Ling 8fb7efe203 java: Add docstrings for enum constants. 2015-10-26 07:17:01 +01:00
Martin Ling 0bcdeb90c4 C++: Include enum classes when generating documentation. 2015-10-26 07:17:01 +01:00
Martin Ling ace872d529 C++: Declare namespace in enums.hpp so it can be used independently. 2015-10-26 07:17:01 +01:00
Martin Ling e5c22906e8 java: Make enum values available as normal constants. 2015-10-26 07:17:01 +01:00
Daniel Elstner 564d009e88 Java: Remove obsolete SourceCallback interface 2015-10-26 07:11:20 +01:00
Daniel Elstner 9e7176bd00 C++: Avoid const ref args to appease Java bindings
The Java bindings currently have some weird problem with function
arguments passed by const reference. Not all types are affected,
but the collection types that involve custom typemaps are.

For now, revert back to pass-by-value for the problematic types.
2015-10-26 07:04:10 +01:00
Daniel Elstner bf03d63565 C++: Use C++98 syntax for default arguments to appease SWIG
Looks like SWIG silently ignores default arguments specified via
aggregate initialization. This is rather unfortunate, especially
if the argument types are complex.
2015-10-26 06:45:56 +01:00
Daniel Elstner a98729a742 C++: Replace custom deleters with std::default_delete
Replace custom Deleter classes with std::default_delete<>, declared
as friend so it can invoke the private destructor. Inexplicably,
std::shared_ptr<> does not use default_delete<> by default, so it
is still necessary to explicitly specify the deleter when creating
shared_ptr instances.

With this, unique_ptr and shared_ptr instances now use the same
default delete mechanism.
2015-10-26 06:45:56 +01:00
Daniel Elstner f17b454655 C++: Use smart pointers instead of manual delete
Make use of std::unique_ptr<> to manage the lifetime of members
or container elements, so that manual invocations of delete can
be avoided. This also provides for exception safety.

Since std::unique_ptr<> is only movable but not copyable, adapt
the code to avoid copies and assignments of these pointers.
2015-10-26 06:45:56 +01:00
Daniel Elstner d5d7b09eb7 C++: Move C struct pointers out of ownership classes
Reduce needless over-generalization. There is no design need
for the ParentOwned and UserOwned classes to contain the C base
struct pointer. Instead, just make the _structure pointer a
private member of each class that needs one.
2015-10-26 06:45:56 +01:00
Daniel Elstner b6ab954d67 C++: Rename get_shared_pointer() to share_owned_by()
This makes it clearer that this method assigns the parent
(owner) reference.
2015-10-26 06:45:56 +01:00
Daniel Elstner 67b82fc9c9 C++: Use shared_from_this() exclusively on this
Never call shared_from_this() on any object other than "this".
Adapt the API so that it can be made protected.
2015-10-26 06:45:56 +01:00
Daniel Elstner 21d1bec60e C++: Make most members private instead of protected
Use protected only for members which are actually needed by
sub-classes. Declare all the rest private.
2015-10-26 06:45:56 +01:00
Daniel Elstner 4c9208a799 SWIG: Hack around SWIG segfault on private destructors
Apparently this problem has been fixed in SWIG 3.0.6. However,
until we can require that version, define "private" as "protected"
when running the SWIG parser.
2015-10-26 06:45:56 +01:00
Daniel Elstner 15bebf575d C++: Make value get accessors const
Declare accessor methods that return value members const. For now,
skip all cases where constness would have to be applied transitively
to shared objects.
2015-10-26 06:45:56 +01:00
Daniel Elstner a73d492636 C++: Make some methods static to match the C API
Context::package_version() and Context::lib_version() do not access
context state and should be static. However, leave the logging
related methods alone for now, as making them static would entail
making the callback data a global static, since the C API lacks
destroy notification callbacks.
2015-10-26 06:45:56 +01:00
Daniel Elstner 0ab8e5d22b C++: Declare all callbacks invoked from C noexcept
If one of these functions does throw an exception, std::terminate()
will be called. Without this, the behavior is undefined since the C
stack is not prepared to deal with exceptions.
2015-10-26 06:45:56 +01:00
Daniel Elstner 15914cdb0f C++: Use noexcept instead of throw()
Runtime-checked exception specifications via throw() are
deprecated in C++11.
2015-10-26 06:45:56 +01:00
Daniel Elstner c6e18e007a SWIG: Define "noexcept" empty to work around SWIG bug
The SWIG 2.0.12 on my system bails out with a syntax error on the
"noexcept" keyword in C++11 code. Define "noexcept" to nothing (for
the SWIG parser only) to work around this problem.
2015-10-26 06:45:56 +01:00
Daniel Elstner 6c11b49607 C++: Make most constructors explicit
Unless implicit conversion is desired, constructors that can be
called with one argument should be marked as "explicit".
2015-10-26 06:45:56 +01:00
Daniel Elstner ce3e1e6132 C++: Do not use C-style casts
Never ever.
2015-10-26 06:45:56 +01:00