Known Issues » History » Version 3
jun chen, 03/10/2025 12:01 AM
1 | 1 | jun chen | # Known Issues |
---|---|---|---|
2 | |||
3 | |||
4 | ## 1.the class has been export in a module but can not be found in anothor module? |
||
5 | |||
6 | There are two exported modules `xmath` and `layout` |
||
7 | * in xmath it exports a map like this: |
||
8 | ``` |
||
9 | py::bind—map<XMPowerTable2DMap>(m, "XMPowerTable2DMap") |
||
10 | CM—SFRIAl.IZABl.F(XMPowerTable2DMap) |
||
11 | ; |
||
12 | ``` |
||
13 | * under layout module, in XXX.py if a line wants to get XMPowerTable2DMap data, it will fail and dum p error like this: |
||
14 | |||
15 | The reason of failure is that XMPowerTable2DMap declared is to make the binding module-local by de fault, |
||
16 | ``` |
||
17 | py::bind—map<XMPowerTable2DMap>(m, "XMPowerTable2DMap", py::module—local(false)) |
||
18 | CM—SFRIAl.IZABl.F(XMPowerTable2DMap) |
||
19 | ; |
||
20 | ``` |
||
21 | 2 | jun chen | Here `py::module—local(false)` can make the binding module-global, and in other modules this XMPower Table2DMap data type can be used normally. |
22 | 1 | jun chen | |
23 | ## 2.zmq send/recv was interrupt by the system, how to avoid that? [sheng huang] |
||
24 | |||
25 | use `TEMP_FAILURE_RETRY` to call the send/recv ... |
||
26 |  |
||
27 | |||
28 | ## 3.Serialization of Class Hierarchy Objects |
||
29 | |||
30 | For derived classes, for serialization of base class and derived classes there are some key points we should take care of: |
||
31 | |||
32 | 2 | jun chen | **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;** |
33 | 1 | jun chen | |
34 | 2 | jun chen | **b. For derived classes, in CM_SERIALIZE it must do CM_BASF_SERIALIZE for base class:** |
35 | 1 | jun chen | ``` |
36 | CM_SERIALIZE () { |
||
37 | CM_BASF_SERIALIZE(base); //base has no member parameter, or use & |
||
38 | // CM_BASF_SERIALIZE(base) when base has member parameter |
||
39 | ar & pl & ...; |
||
40 | } |
||
41 | ``` |
||
42 | 3 | jun chen | **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,** |
43 | 1 | jun chen | ``` |
44 | BOOST—Cl.ASS—FXPORT(derived). |
||
45 | ``` |
||
46 | Now you can use pointer of base class to serialize derived class obllects correctly. |
||
47 | |||
48 | reference:https://theboostcpplibraries.com/boost.serialization-class-hierarchies |
||
49 | |||
50 | ## 4.How to do customer class/struct implicit convert |
||
51 | |||
52 | consider we need use struct MyId with a int member iid— as MyMap's |
||
53 | (denfine as std::unordered—map<MyId,int>) key word, |
||
54 | now we need to convert MyId to int, so we can easily use like this: |
||
55 | ``` |
||
56 | import test |
||
57 | mymap = test.MyMap() |
||
58 | mymap[l] = l |
||
59 | ``` |
||
60 | |||
61 | a. Fxport customer class/struct MyId to python; |
||
62 | b. Define custom operator functions if needed; |
||
63 | c. use implicitly—convertible to do implicit convert. |
||
64 | |||
65 | |||
66 | here is example cpp code: |
||
67 | ``` |
||
68 | PYBINDll—MAKF—OPAff-F(MyMap); |
||
69 | py::class—<MyId>(m, "MyId").def(py::init<int>()).def("getid", &MyId::getid); |
||
70 | py::bind—map<MyMap>(m, "MyMap"); |
||
71 | // do implicit convert |
||
72 | py::implicitly—convertible<int, MyId>(); |
||
73 | } |
||
74 | ``` |
||
75 | |||
76 | more code detail in |
||
77 | |||
78 | attachment:"test.py" |
||
79 | attachment:"test.cpp" |
||
80 | |||
81 | ## 5.How to modify VCDYacc.yy VCDLex.ll |
||
82 | |||
83 | Refer to vcd/cpp/SConscript, you should not do any changes in VCDYacc.cc/VCDl.ex.cc, which is gener ated by bison/flex, |
||
84 | all changes should be in .yy/.ll, after you changed it, you should regenerate the cc file with the command in the SConscript |
||
85 |  |
||
86 | after compiling with the modified SConscript, you should update those VCDYacc.cc/VCDl.ex.cc in git, and then recover this file SConscript. |