Boost logo

Boost :

Subject: Re: [boost] JNI library
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-06-17 15:50:55


on Sat Jun 16 2012, Felipe Magno de Almeida <felipe.m.almeida-AT-gmail.com> wrote:

> 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,

1. Last time I looked, it was impossible to do this without a textual
   'C' code generation layer. I don't remember enough about the details
   to describe the reasons, but I'd be interested to know how you get
   around this if you recognize the limitation to which I'm referring.

2. I know I've been saying this for years, but we really ought to get
the langbinding project going rather than adding new variants of
Boost.Python for every language to which we might want to bind.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk