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