From e5c22906e804f540647ab182d9538499964eb633 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Sun, 25 Oct 2015 01:39:16 +0000 Subject: [PATCH] java: Make enum values available as normal constants. --- bindings/cxx/enums.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bindings/cxx/enums.py b/bindings/cxx/enums.py index 0d2887bc..4e6be7ba 100644 --- a/bindings/cxx/enums.py +++ b/bindings/cxx/enums.py @@ -134,11 +134,19 @@ for enum, (classname, classbrief) in classes.items(): classname, classname, trimmed_name, classname, name, trimmed_name), file=code) + print('%%typemap(javacode) sigrok::%s %%{' % classname, file=swig) + # Define public pointers for each enum value for trimmed_name in trimmed_names: print('const %s * const %s::%s = &%s::_%s;' % ( classname, classname, trimmed_name, classname, trimmed_name), file=code) + print('public static final %s %s = new %s(classesJNI.%s_%s_get(), false);' % ( + classname, trimmed_name, classname, classname, trimmed_name), + file=swig) + + print ('%}', file=swig) + # Define map of enum values to constants print('template<> const SR_API std::map EnumValue<%s, enum %s>::_values = {' % (