WhatsThis update
[mussa.git] / py / python.hpp
index fc210c33369ba71e36e56525e2605a1b93014d2a..4312f9cc0df070ef21c0fdf6830a94605bf26516 100644 (file)
@@ -2,28 +2,42 @@
 #define _MUSSA_PYTHON_HPP_
 #include <boost/python.hpp>
 #include <string>
-
-extern "C" void initmussa();
+#include <list>
+#include <utility>
 
 //! Create a singleton class to manage our reference to the python interpreter
 class MussaPython {
   public:
+    typedef void (*python_module_init)(void);
     MussaPython();
 
+    //! initalize interpreter
+    void init_interpreter();
+    //! add a python module that was statically compiled into this executable
+    void add_module(const std::string& name, python_module_init); 
+    //! return main python namespace(initializing the interpreter if needed)
+    boost::python::object get_namespace();
     //! pass multi-statement code block to the python interpreter
     void run(std::string);
     //! pass single expression to the python interpreter and return the result
     boost::python::object eval(std::string);
-    //! launch read-eval-print loop tied to the provided FILE pointer
-    void interpreter(FILE *fp=stdin);
+    //! use InteractiveConsole for readloop
+    void interpreter();
+    //! launch fgets based read-eval-print loop tied to the provided FILE pointer
+    void simple_interpreter(FILE *fp=stdin);
     //! return an object in the python namespace
     boost::python::object operator[](std::string);
-
   protected:
+    typedef std::pair<std::string, python_module_init> module_item;
+    typedef std::list<module_item> module_list;
+    module_list python_modules;
     boost::python::object main_namespace;
+    
+    static void AppendInittab(const module_item &item);
 };
 
 //! return a reference to a single mussa python interpreter
-MussaPython& get_py();
+MussaPython *get_py_ptr();
+MussaPython &get_py();
 
 #endif // _MUSSA_PYTHON_HPP_