%pragma(java) jniclassimports=%{
/**
* @mainpage API Reference
- *
+ *
* Introduction
* ------------
- *
+ *
* The sigrok-java API provides an object-oriented Java interface to the
* functionality in libsigrok. It is built on top of the libsigrokcxx C++ API.
- *
+ *
* Getting started
* ---------------
- *
+ *
* Usage of the sigrok-java API needs to begin with a call to Context.create().
* This will create the global libsigrok context and returns a Context object.
* Methods on this object provide access to the hardware drivers, input and
* output formats supported by the library, as well as means of creating other
* objects such as sessions and triggers.
- *
+ *
* Error handling
* --------------
- *
+ *
* When any libsigrok C API call returns an error, an Error exception is raised,
* which provides access to the error code and description.
*/
for (auto entry : $1)
{
*(CValue **) &value = new CValue(entry);
- jenv->CallObjectMethod($result, Vector_add,
+ jenv->CallBooleanMethod($result, Vector_add,
jenv->NewObject(Value, Value_init, value, true));
}
}
}
}
-/* Specialisation for ConfigKey->set<Capability> maps */
-
-MAP_COMMON(const sigrok::ConfigKey *, std::set<enum sigrok::Capability>,
- ConfigKey, java.util.Set<Capability>)
-
-%typemap(jni) std::map<const sigrok::ConfigKey *, std::set<enum sigrok::Capability> > "jobject"
-%typemap(jtype) std::map<const sigrok::ConfigKey *, std::set<enum sigrok::Capability> >
- "java.util.Map<ConfigKey,java.util.Set<Capability>>"
-
-%typemap(out) std::map<const sigrok::ConfigKey *, std::set<enum sigrok::Capability> > {
- jclass HashMap = jenv->FindClass("java/util/HashMap");
- jmethodID HashMap_init = jenv->GetMethodID(HashMap, "<init>", "()V");
- jmethodID HashMap_put = jenv->GetMethodID(HashMap, "put",
- "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
- jclass HashSet = jenv->FindClass("java/util/HashSet");
- jmethodID HashSet_init = jenv->GetMethodID(HashSet, "<init>", "()V");
- jmethodID HashSet_add = jenv->GetMethodID(HashSet, "add",
- "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
- jclass ConfigKey = jenv->FindClass("org/sigrok/core/classes/ConfigKey");
- jmethodID ConfigKey_init = jenv->GetMethodID(ConfigKey, "<init>", "(JZ)V");
- jclass Capability = jenv->FindClass("org/sigrok/core/classes/Capability");
- jmethodID Capability_swigToEnum = jenv->GetStaticMethodID(Capability,
- "swigToEnum", "(I)Lorg/sigrok/core/classes/Capability;");
- $result = jenv->NewObject(HashMap, HashMap_init);
- jlong key = 0;
- for (auto map_entry : $1)
- {
- *(const sigrok::ConfigKey **) &key = map_entry.first;
- jobject value = jenv->NewObject(HashSet, HashSet_init);
- for (auto &set_entry : map_entry.second)
- jenv->CallObjectMethod(value, HashSet_add,
- jenv->CallStaticObjectMethod(Capability,
- Capability_swigToEnum, set_entry));
- jenv->CallObjectMethod($result, HashMap_put,
- jenv->NewObject(ConfigKey, ConfigKey_init, key, false), value);
- }
-}
-
/* Pass JNIEnv parameter to C++ extension methods requiring it. */
%typemap(in, numinputs=0) JNIEnv * %{
$1 = jenv;
-%}
+%}
/* Thread safe JNIEnv handling */
class ScopedEnv {
public:
ScopedEnv(JavaVM *jvm);
- ScopedEnv(const ScopedEnv &ref) = delete;
~ScopedEnv();
JNIEnv* operator-> () { return env; }
operator bool () const { return (bool)env; }
{
protected:
GlobalRefBase (JavaVM *jvm, jobject ref);
- GlobalRefBase (const GlobalRefBase &ref) = delete;
~GlobalRefBase ();
JavaVM *jvm;
jobject jref;