|
Boost : |
Subject: Re: [boost] JNI library
From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2012-06-16 14:02:58
Hello,
I'm attaching the library source code. It is in Boost license 1.0.
The library is based on luabind ideas, which is based on Boost.Python.
The JNI interface makes a few things much harder, and makes mismatches
almost always fatal and almost impossible to discover beforehand,
which makes developing for JNI much harder.
I'm implementing the features as I need it, so it is very incomplete.
But it is possible to register a class like this:
javabind::class_ component_class = env.find_class("java/awt/Component");
javabind::register_class
(
javabind::reg::class_<awt::component>(component_class)
.constructor(boost::bind(boost::value_factory<awt::component>(), _1, _2
, jvm))
.def<javabind::int_(awt::component const&)>
("nativeGetWidth", boost::bind(&awt::component::width, _1))
.def("nativeGetHeight", &awt::component::height)
.def("nativeSetX", &awt::component::set_x)
.def("nativeSetY", &awt::component::set_y)
.def("nativeSetWidth", &awt::component::set_width)
.def("nativeSetHeight", &awt::component::set_height)
.def("nativeGetX", &awt::component::get_x)
.def("nativeGetY", &awt::component::get_y)
.def("nativeSetVisible", &awt::component::set_visible)
.def("nativeIsVisible", &awt::component::is_visible)
.def("nativeSetPreferredSize", &awt::component::set_preferred_size)
.def("nativeSetDelay", &awt::component::set_delay)
.def("nativeGetPreferredSize", &awt::component::get_preferred_size
, "java/awt/Dimension")
.def("nativeSetFocus", &awt::component::set_focus)
);
And to call a method like this:
javabind::method<void(javabind::object)> initxlet = jtv_xlet_class.method
<void(javabind::object)>("initXlet", "javax/tv/xlet/XletContext");
initxlet(user_xlet, xlet_context);
Any comments are appreciated,
Regards,
-- Felipe Magno de Almeida
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk