Skip to content

Instantly share code, notes, and snippets.

@battleguard
Last active September 7, 2023 16:11
Show Gist options
  • Save battleguard/284b08c9054dbf7c43c0d199abfe0d39 to your computer and use it in GitHub Desktop.
Save battleguard/284b08c9054dbf7c43c0d199abfe0d39 to your computer and use it in GitHub Desktop.
struct FuncHolder
{
std::function<void(double)> mFunc;
};
py::class_<FuncHolder> funcHolder(aModule, "FuncHolder");
aModule.def("AddCallback", [](std::function<void(double)> func, py::list aHolder)
{
FuncHolder* holder = new FuncHolder{ func };
aHolder.append(holder);
});
def run_example2():
callback_list = []
def advance_time(sim_time: float):
print(callback_list)
afsim.AddCallback(advance_time, callback_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment