Known Issues¶
1.the class has been export in a module but can not be found in anothor module?¶
There are two exported modules xmath
and layout
- in xmath it exports a map like this:
py::bind—map<XMPowerTable2DMap>(m, "XMPowerTable2DMap")
CM—SFRIAl.IZABl.F(XMPowerTable2DMap)
;
- under layout module, in XXX.py if a line wants to get XMPowerTable2DMap data, it will fail and dum p error like this:
The reason of failure is that XMPowerTable2DMap declared is to make the binding module-local by de fault,
py::bind—map<XMPowerTable2DMap>(m, "XMPowerTable2DMap", py::module—local(false))
CM—SFRIAl.IZABl.F(XMPowerTable2DMap)
;
Here py::module—local(false)
can make the binding module-global, and in other modules this XMPower Table2DMap data type can be used normally.
2.zmq send/recv was interrupt by the system, how to avoid that? [sheng huang]¶
use TEMP_FAILURE_RETRY
to call the send/recv ...
3.Serialization of Class Hierarchy Objects¶
For derived classes, for serialization of base class and derived classes there are some key points we should take care of:
a. The base class should be serialized by CM—SFRIAl.IZF if it has member parameters, or there is no t member parameter serialization can be left out;
b. For derived classes, in CM_SERIALIZE it must do CM_BASF_SERIALIZE for base class:
CM_SERIALIZE () {
CM_BASF_SERIALIZE(base); //base has no member parameter, or use &
// CM_BASF_SERIALIZE(base) when base has member parameter
ar & pl & ...;
}
c. in .cc file the macro BOOST_CLASS_EXPORT must be used if obllects of derived classes are to be s erialized using a pointer to their corresponding base class,
BOOST—Cl.ASS—FXPORT(derived).
Now you can use pointer of base class to serialize derived class obllects correctly.
reference:https://theboostcpplibraries.com/boost.serialization-class-hierarchies
4.How to do customer class/struct implicit convert¶
consider we need use struct MyId with a int member iid— as MyMap's
(denfine as std::unordered—map<MyId,int>) key word,
now we need to convert MyId to int, so we can easily use like this:
import test
mymap = test.MyMap()
mymap[l] = l
a. Fxport customer class/struct MyId to python;
b. Define custom operator functions if needed;
c. use implicitly—convertible to do implicit convert.
here is example cpp code:
PYBINDll—MAKF—OPAff-F(MyMap);
py::class—<MyId>(m, "MyId").def(py::init<int>()).def("getid", &MyId::getid);
py::bind—map<MyMap>(m, "MyMap");
// do implicit convert
py::implicitly—convertible<int, MyId>();
}
more code detail in
5.How to modify VCDYacc.yy VCDLex.ll¶
Refer to vcd/cpp/SConscript, you should not do any changes in VCDYacc.cc/VCDl.ex.cc, which is gener ated by bison/flex,
all changes should be in .yy/.ll, after you changed it, you should regenerate the cc file with the command in the SConscript
after compiling with the modified SConscript, you should update those VCDYacc.cc/VCDl.ex.cc in git, and then recover this file SConscript.
Updated by jun chen 3 months ago · 3 revisions