MCPcopy Create free account
hub / github.com/BabitMF/bmf / packet_get

Function packet_get

bmf/python/py_module_sdk.cpp:105–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105py::object packet_get(bmf_sdk::Packet &pkt, const py::object &cls) {
106 std::string cls_name;
107 if (cls.is_none()) {
108 cls_name = "bmf.lib._bmf.sdk.PythonObject";
109 } else {
110 cls_name = get_py_class_name(cls);
111 if (s_packet_casters.find(cls_name) == s_packet_casters.end()) {
112 cls_name = "bmf.lib._bmf.sdk.PythonObject";
113 }
114 }
115
116 auto obj = s_packet_casters.at(cls_name).from(pkt);
117 if (cls_name == "bmf.lib._bmf.sdk.PythonObject") {
118 obj = obj.cast<bmf_sdk::PythonObject>().obj();
119 if (cls.is_none() || obj.get_type().is(cls)) {
120 return obj;
121 } else {
122 throw std::runtime_error("class type is not matched");
123 }
124 } else {
125 return obj;
126 }
127}
128
129bool packet_is(bmf_sdk::Packet &pkt, const py::object &cls) {
130 try {

Callers 2

packet_isFunction · 0.85
module_sdk_bindFunction · 0.85

Calls 4

get_py_class_nameFunction · 0.85
is_noneMethod · 0.80
endMethod · 0.80
get_typeMethod · 0.45

Tested by

no test coverage detected