1/* 2 * Copyright (c) 2012, 2017 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 177 unchanged lines hidden (view full) --- 186 187std::map<std::string, EmbeddedPyBind *> & 188EmbeddedPyBind::getMap() 189{ 190 static std::map<std::string, EmbeddedPyBind *> objs; 191 return objs; 192} 193 |
194#if PY_MAJOR_VERSION >= 3 195PyObject * 196#else |
197void |
198#endif |
199EmbeddedPyBind::initAll() 200{ 201 std::list<EmbeddedPyBind *> pending; 202 203 py::module m_m5 = py::module("_m5"); 204 m_m5.attr("__package__") = py::cast("_m5"); 205 206 pybind_init_core(m_m5); --- 18 unchanged lines hidden (view full) --- 225 if (obj.depsReady()) { 226 obj.init(m_m5); 227 it = pending.erase(it); 228 } else { 229 ++it; 230 } 231 } 232 } |
233 234#if PY_MAJOR_VERSION >= 3 235 return m_m5.ptr(); 236#endif |
237} 238 |
239void 240registerNativeModules() |
241{ |
242 auto result = PyImport_AppendInittab("_m5", EmbeddedPyBind::initAll); 243 if (result == -1) 244 panic("Failed to add _m5 to Python's inittab\n"); |
245} 246 247/* 248 * Make the commands array weak so that they can be overridden (used 249 * by unit tests to specify a different python main function. 250 */ 251const char * __attribute__((weak)) m5MainCommands[] = { 252 "import m5", --- 58 unchanged lines hidden (view full) --- 311 } 312 313#if HAVE_PROTOBUF 314 google::protobuf::ShutdownProtobufLibrary(); 315#endif 316 317 return 0; 318} |