jlong value;
for (auto entry : $1)
{
- *(CValue **) &value = new CValue(entry);
+ value = reinterpret_cast<intptr_t>(new CValue(entry));
jenv->CallObjectMethod($result, Vector_add,
jenv->NewObject(Value, Value_init, value, true));
}
jlong value;
for (auto entry : $1)
{
- *(std::shared_ptr< sigrok::ClassName > **)&value =
- new std::shared_ptr< sigrok::ClassName>(entry.second);
+ value = reinterpret_cast<intptr_t>(new std::shared_ptr< sigrok::ClassName>(entry.second));
jenv->CallObjectMethod($result, HashMap_put,
jenv->NewStringUTF(entry.first.c_str()),
jenv->NewObject(Value, Value_init, value, true));
jlong value;
for (auto entry : $1)
{
- *(const sigrok::ConfigKey **) &key = entry.first;
- *(Glib::VariantBase **) &value = new Glib::VariantBase(entry.second);
+ key = reinterpret_cast<intptr_t>(entry.first);
+ value = reinterpret_cast<intptr_t>(new Glib::VariantBase(entry.second));
jenv->CallObjectMethod($result, HashMap_put,
jenv->NewObject(ConfigKey, ConfigKey_init, key, false));
jenv->NewObject(Variant, Variant_init, value, true));
}
}
-/* Support Driver.scan() with no arguments. */
-%ignore sigrok::Driver::scan;
+/* Specialisation for ConfigKey->set<Capability> maps */
-%extend sigrok::Driver {
- std::vector<std::shared_ptr<sigrok::HardwareDevice> > scan()
- {
- std::map<const sigrok::ConfigKey *, Glib::VariantBase> options;
- return $self->scan(options);
- }
-
- std::vector<std::shared_ptr<sigrok::HardwareDevice> > scan(
- std::map<const sigrok::ConfigKey *, Glib::VariantBase> options)
- {
- return $self->scan(options);
- }
-}
+MAP_COMMON(const sigrok::ConfigKey *, std::set<enum sigrok::Capability>,
+ ConfigKey, java.util.Set<Capability>)
-/* Support InputFormat.create_input() with or without options. */
-%ignore sigrok::InputFormat::create_input;
+%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>>"
-%extend sigrok::InputFormat {
- std::shared_ptr<sigrok::Input> create_input()
- {
- return $self->create_input();
- }
-
- std::shared_ptr<sigrok::Input> create_input(
- std::map<std::string, Glib::VariantBase> options)
- {
- return $self->create_input(options);
- }
-}
-
-/* Support OutputFormat.create_output() with or without options. */
-%ignore sigrok::OutputFormat::create_output;
-
-%extend sigrok::OutputFormat {
- std::shared_ptr<sigrok::Output> create_output(
- std::shared_ptr<sigrok::Device> device)
- {
- return $self->create_output(device);
- }
-
- std::shared_ptr<sigrok::Output> create_output(
- std::shared_ptr<sigrok::Device> device,
- std::map<std::string, Glib::VariantBase> options)
- {
- return $self->create_output(device, options);
- }
-
- std::shared_ptr<sigrok::Output> create_output(
- std::string filename,
- std::shared_ptr<sigrok::Device> device)
- {
- return $self->create_output(filename, device);
- }
-
- std::shared_ptr<sigrok::Output> create_output(
- std::string filename,
- std::shared_ptr<sigrok::Device> device,
- std::map<std::string, Glib::VariantBase> options)
+%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;
+ for (auto map_entry : $1)
{
- return $self->create_output(filename, device, options);
+ key = reinterpret_cast<intptr_t>(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);
}
}
std::string message)
{
jlong loglevel_addr;
- *(const sigrok::LogLevel **) &loglevel_addr = loglevel;
+ loglevel_addr = reinterpret_cast<intptr_t>(loglevel);
jobject loglevel_obj = env->NewObject(
LogLevel, LogLevel_init, loglevel_addr, false);
jobject message_obj = env->NewStringUTF(message.c_str());
{
jlong device_addr;
jlong packet_addr;
- *(std::shared_ptr<sigrok::Device> **) &device_addr =
- new std::shared_ptr<sigrok::Device>(device);
- *(std::shared_ptr<sigrok::Packet> **) &packet_addr =
- new std::shared_ptr<sigrok::Packet>(packet);
+ device_addr = reinterpret_cast<intptr_t>(new std::shared_ptr<sigrok::Device>(device));
+ packet_addr = reinterpret_cast<intptr_t>(new std::shared_ptr<sigrok::Packet>(packet));
jobject device_obj = env->NewObject(
Device, Device_init, device_addr, true);
jobject packet_obj = env->NewObject(
%include "doc.i"
-%define %attributevector(Class, Type, Name, Get)
-%attributeval(sigrok::Class, Type, Name, Get);
-%enddef
-
-%define %attributemap(Class, Type, Name, Get)
-%attributeval(sigrok::Class, Type, Name, Get);
-%enddef
-
%define %enumextras(Class)
%enddef
/* Ignore these for now, need fixes. */
%ignore sigrok::Context::create_analog_packet;
%ignore sigrok::Context::create_meta_packet;
+%ignore sigrok::Meta::config;
%include "bindings/swig/classes.i"