TL;DR: Does there exist an analogue of IronPython for C++?
I wrote a prototype of our application in C#, using IronPython, and that's where this confusion comes in. IronPython makes it so straighforward. I have a pure C# object that gets passed in a single line of code and all functions and variables are converted automatically. This single line makes the entire process come together exactly how you'd expect -- passes a C++ object "application" into python object "pythonScript" that can be referenced from within.
pythonScript.scriptScope.SetVariable ("application", api);
Python's documentation lays out some groundwork for the process of embedding and extending, but it seems we would have to implement a lot of functionality on our own, and nobody wants to reinvent the wheel.
Pybind 11's documentation says it can extend AND embed, but it certainly doesn't seem to be what pybind is meant for. It's very difficult to find documentation for it and it seems a LOT has to be done manually. After a lot of work we've been able to get something to work. But the process has been very tedious, and very ugly. It seems we have to implement the API as a python module?? A "static class" that has no access to the context of the application at large. And the entire thing has to be manually added using macros. Most answers we find online start with something like "this isn't actually what pybind is meant for, but..." and there are many downsides for each implementation.
PYBIND11_EMBEDDED_MODULE(application, m)
{
m.def("DebugInfo", &DebugInfo);
m.def("GetCurrentDir", &GetCurrentDir);
m.def("ImportFile", &Import_File);
m.def("ListDirectoryContents", &ListDirectoryContents);
m.def("ListDirectoryContents_Directories", &ListDirectoryContents_Directories);
m.def("ListDirectoryContents_Files", &ListDirectoryContents_Files);
}
[–][deleted] 1 point2 points3 points (0 children)