Re: new round
Alexander Nasonov <[email protected]>
| Newsgroups | gmane.comp.lib.boost.langbinding |
|---|---|
| Message-ID | <[email protected]> |
Alexander Nasonov wrote:
> def("member_function", &X::member_function)
> it's here ^^^
>
> Though, I don't know how to handle this: class_("X")<X,X_impl>[ /* ...
> */ ].
This shouldn't be a problem too. I've just found an example in
Boost.Python documentation:
using namespace boost::python;
BOOST_PYTHON_MODULE(my_module)
{
def("is_base", is_base);
class_<Base,Base_callback, noncopyable>("Base")
.def("class_name", &Base_callback::Base_name)
;
}
Good sign is that Base_callback is inside def.
May be you have something else in mind? For example, policies or
conversion T Base::* -> T Derived::*?
My model might look too minimalistic to you. All I need is a way to
prepare arguments for a call and then make a call. My object class is
just a pair of void* and type_info (extended).
For C++ HTTP binding I need a way to make raw object from a string for
built-in types. This can be done using from_ostream converter:
shared_ptr<void*> int_from_ostream(ostream&);
// ...
map<
type_info_ex,
shared_ptr<void*> (*)(ostream&)
> from_ostream_converters;
To create UDT (let's say X) I need init function:
shared_ptr<void*> X_ctor1(void* args);
// ...
// Caller must check that args point
// to properly initialized types.
I also need a function to find proper ctor.
vector<type_info_ex> arg_types(1);
arg_types[0] = typeid(int);
callable ctor = x_definition.find_ctor(arg_types);
vector<shared_ptr<void*> >args(1);
// Take int from cout:
args[0] = from_ostream_converters[typeid(int)](cout);
vector<shared_ptr<void*> > temporaries;
shared_ptr<void*> x_obj = ctor(temporaries, args);
Function can be called in a similar way.
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click