init.cc (13620:e0d9b09788f6) | init.cc (13662:3e072654ca86) |
---|---|
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 | 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 |
|
194void | 197void |
198#endif |
|
195EmbeddedPyBind::initAll() 196{ 197 std::list<EmbeddedPyBind *> pending; 198 199 py::module m_m5 = py::module("_m5"); 200 m_m5.attr("__package__") = py::cast("_m5"); 201 202 pybind_init_core(m_m5); --- 18 unchanged lines hidden (view full) --- 221 if (obj.depsReady()) { 222 obj.init(m_m5); 223 it = pending.erase(it); 224 } else { 225 ++it; 226 } 227 } 228 } | 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 |
|
229} 230 | 237} 238 |
231int 232initM5Python() | 239void 240registerNativeModules() |
233{ | 241{ |
234 EmbeddedPyBind::initAll(); 235 return EmbeddedPython::initAll(); | 242 auto result = PyImport_AppendInittab("_m5", EmbeddedPyBind::initAll); 243 if (result == -1) 244 panic("Failed to add _m5 to Python's inittab\n"); |
236} 237 238/* 239 * Make the commands array weak so that they can be overridden (used 240 * by unit tests to specify a different python main function. 241 */ 242const char * __attribute__((weak)) m5MainCommands[] = { 243 "import m5", --- 58 unchanged lines hidden (view full) --- 302 } 303 304#if HAVE_PROTOBUF 305 google::protobuf::ShutdownProtobufLibrary(); 306#endif 307 308 return 0; 309} | 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} |
310 311PyMODINIT_FUNC 312initm5(void) 313{ 314 initM5Python(); 315 PyImport_ImportModule(PyCC("m5")); 316} | |