1/* 2 * Copyright 2018 Google, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer; 8 * redistributions in binary form must reproduce the above copyright --- 26 unchanged lines hidden (view full) --- 35#include "sim/init.hh" 36 37namespace sc_gem5 38{ 39 40namespace 41{ 42 |
43PythonReadyFunc *& 44firstReadyFunc() 45{ 46 static PythonReadyFunc *first = nullptr; 47 return first; 48} |
49 |
50PythonInitFunc *& 51firstInitFunc() 52{ 53 static PythonInitFunc *first = nullptr; 54 return first; 55} 56 |
57void 58python_ready(pybind11::args args) 59{ |
60 for (auto ptr = firstReadyFunc(); ptr; ptr = ptr->next) 61 ptr->run(); |
62} 63 64void 65systemc_pybind(pybind11::module &m_internal) 66{ 67 pybind11::module m = m_internal.def_submodule("systemc"); 68 m.def("python_ready", &python_ready); |
69 for (auto ptr = firstInitFunc(); ptr; ptr = ptr->next) 70 ptr->run(m); |
71} 72EmbeddedPyBind embed_("systemc", &systemc_pybind); 73 74} // anonymous namespace 75 |
76PythonReadyFunc::PythonReadyFunc() : next(firstReadyFunc()) |
77{ |
78 firstReadyFunc() = this; |
79} 80 |
81PythonInitFunc::PythonInitFunc() : next(firstInitFunc()) |
82{ |
83 firstInitFunc() = this; |
84} 85 86} // namespace sc_gem5 |