|
Boost : |
From: Anton Gluck (gluc_at_[hidden])
Date: 2000-11-06 00:48:51
Dave,
This just might be the last problem I'll have to bother you with. Since
the problems with references as parameters to constructors have been
solved, I was surprised to run into one such problem again, this time with
a reference as a function parameter. This is the definition of the
function I need to wrap:
Model::Assign(RecordIterator& cases)
I am wrapping it like this:
Model_class.def(Model::Assign, "Assign");
And this is the error message:
d:\py_cpp/caller.h(43) : error C2665: 'from_python' : none of the 158
overloads can convert parameter 2 from type 'struct py::Type<class
AIterator<class Record> &>'
d:\py_cpp/functions.h(54) : see reference to function template
instantiation 'struct _object *__cdecl py::Caller<class
MCClass::MCStatus>::call(class MCClass::MCStatus (__thiscall
Model::*)(class AIterator<class Record> &),struct _object *,struct _object
*)' being compiled
I suppose this means that a custom from_python needs to be written, but to
what does the reference need to be converted?
As usual, I'll appreciate your help.
Now that I think of it, there is also this issue that I cast aside for
now: How do I access variables of wrapped classes? There is this settings
class, which has several default values defined. For example, Settings.h
defines:
enum Criterion {
kBIC = 1,
kAIC
};
In other C++ classes this can be accessed with:
Settings::kBIC
I have tried using the _getattr__<name>__ functions of your wrapper
classes, but could not access this variable (I received an
AttributeError). Also, when I listed __dict__ of a python Settings object
I did not see any attriutes. Do I need to expose these variables
explicitly? Do I need to do something like this:
Settings_class.def_readonly(&Settings::kBIC, "kBIC");
When I tried this I got an error about "'&' on constant" (but the & seems
required judging from your documentation), and an error "could not deduce
template argument for ' Settings::*' from 'enum Settings::Criterion'"
(although I already have a from_python that handles the Criterion
enumeration).
Thanks for your help,
Toni
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk