11 changed files with 130 additions and 87 deletions
@ -1,47 +1,80 @@ |
|||||||
#include "api.h" |
#include "api.h" |
||||||
namespace juci_api{ |
|
||||||
|
|
||||||
void cpp::ReplaceWord(const std::string word) { |
std::shared_ptr<Menu::Controller> libjuci::ApiServiceProvider::menu_; |
||||||
//TODO implement api::ReplaceWord / change string to iter?
|
std::shared_ptr<Notebook::Controller> libjuci::ApiServiceProvider::notebook_; |
||||||
//some_namespace::controller::replaceWord(word_*);
|
|
||||||
std::cout << "unimplemented function: 'api::ReplaceWord()' called" |
|
||||||
<< std::endl; |
|
||||||
|
|
||||||
std::cout << "The string: " << g_test_string << std::endl; |
/////////////////////////////
|
||||||
} |
//// API ServiceProvider ////
|
||||||
|
/////////////////////////////
|
||||||
|
libjuci::ApiServiceProvider::ApiServiceProvider( ){ |
||||||
|
std::cout << "Apiservice std.ctor" << std::endl; |
||||||
|
} |
||||||
|
void libjuci::ApiServiceProvider::ReplaceWord(std::string word){ |
||||||
|
std::cout << word << std::endl; |
||||||
|
} |
||||||
|
void libjuci::ApiServiceProvider::ReplaceLine(std::string line){} |
||||||
|
|
||||||
void cpp::ReplaceLine(const std::string line) { |
void libjuci::ApiServiceProvider::AddKeybinding() { |
||||||
//TODO implement api::ReplaceLine / change string to iter?
|
|
||||||
//some_namespace::controller::replaceLine(line_);
|
libjuci::ApiServiceProvider::menu_->keybindings_.action_group_menu() |
||||||
std::cout << "unimplemented function: 'api::ReplaceLine()' called" |
->add(Gtk::Action::create("PluginAddSnippet", |
||||||
<< std::endl; |
"Add snippet"), |
||||||
}
|
Gtk::AccelKey("<control><alt>space"), |
||||||
|
[]() { |
||||||
//helpers
|
std::cout << "ctrl alt space" << std::endl; |
||||||
boost::python::api::object py::openPythonScript(const std::string path, |
libjuci::LoadPlugin("juci_api_test"); |
||||||
boost::python::api::object python_name_space) { |
}); |
||||||
std::string temp = g_project_root + path + ".py"; |
std::cout << "addkeybinding" << std::endl; |
||||||
boost::python::str the_path(temp); |
} |
||||||
return boost::python::exec_file(the_path, python_name_space);//, python_name_space);
|
|
||||||
} |
///////////////////////
|
||||||
|
//// Api to python ////
|
||||||
|
///////////////////////
|
||||||
|
void libjuci::ReplaceWord(const std::string word_) { |
||||||
|
//TODO implement libjuci::ReplaceWord / change string to iter?
|
||||||
|
//some_namespace::controller::replaceWord(word_*);
|
||||||
|
//std::cout << "unimplemented function: 'libjuci::ReplaceWord()' called"
|
||||||
|
// << std::endl;
|
||||||
|
|
||||||
|
//libjuci::ApiServiceProvider::ReplaceWord(word);
|
||||||
|
|
||||||
void py::LoadPlugin(const std::string& plugin_name) { |
std::cout << "The string: " << word_ << std::endl; |
||||||
try{ |
} |
||||||
/* initialize python interpreter */ |
|
||||||
Py_Initialize(); |
void libjuci::ReplaceLine(const std::string line) { |
||||||
boost::python::api::object main_module = boost::python::import("__main__"); |
//TODO implement libjuci::ReplaceLine / change string to iter?
|
||||||
boost::python::api::object main_namespace = main_module.attr("__dict__"); |
//some_namespace::controller::replaceLine(line_);
|
||||||
|
std::cout << "unimplemented function: 'libjuci::ReplaceLine()' called" |
||||||
/* runs script from python */ |
<< std::endl; |
||||||
//boost::python::object ignored1 = setPythonVar("word", word, main_namespace);
|
} |
||||||
boost::python::api::object ignored2 = openPythonScript(plugin_name, main_namespace);
|
//////////////////////////////
|
||||||
/* extracts desired values */
|
//// Boost.Python methods ////
|
||||||
//boost::python::object pySnippet = boost::python::eval("getSnippet()", main_namespace);
|
//////////////////////////////
|
||||||
//word = boost::python::extract<std::string>(pySnippet);
|
|
||||||
/* add snippet to textView */ |
boost::python::api::object libjuci::openPythonScript(const std::string path, |
||||||
//TODO add snippet
|
boost::python::api::object python_name_space) { |
||||||
}catch(boost::python::error_already_set const&) { |
std::string temp = g_project_root + path + ".py"; |
||||||
PyErr_Print(); |
boost::python::str the_path(temp); |
||||||
} |
return boost::python::exec_file(the_path, python_name_space);//, python_name_space);
|
||||||
|
} |
||||||
|
|
||||||
|
void libjuci::LoadPlugin(const std::string& plugin_name) { |
||||||
|
try{ |
||||||
|
/* initialize python interpreter */ |
||||||
|
Py_Initialize(); |
||||||
|
boost::python::api::object main_module = boost::python::import("__main__"); |
||||||
|
boost::python::api::object main_namespace = main_module.attr("__dict__"); |
||||||
|
|
||||||
|
/* runs script from python */ |
||||||
|
//boost::python::object ignored1 = setPythonVar("word", word, main_namespace);
|
||||||
|
boost::python::api::object ignored2 = openPythonScript(plugin_name, main_namespace); |
||||||
|
/* extracts desired values */ |
||||||
|
//boost::python::object pySnippet = boost::python::eval("getSnippet()", main_namespace);
|
||||||
|
//word = boost::python::extract<std::string>(pySnippet);
|
||||||
|
/* add snippet to textView */ |
||||||
|
//TODO add snippet
|
||||||
|
}catch(boost::python::error_already_set const&) { |
||||||
|
PyErr_Print(); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,8 @@ |
|||||||
#include "api.h" |
#include "api.h" |
||||||
|
|
||||||
BOOST_PYTHON_MODULE(juci_to_python_api) { |
BOOST_PYTHON_MODULE(juci_to_python_api) { |
||||||
using namespace boost::python; |
using namespace boost::python; |
||||||
// text editing
|
// text editing
|
||||||
def("replaceLine", &juci_api::cpp::ReplaceLine); |
def("replaceLine", &libjuci::ReplaceLine); |
||||||
def("replaceWord", &juci_api::cpp::ReplaceWord); |
def("replaceWord", &libjuci::ReplaceWord); |
||||||
}// module::juci
|
}// module::juci
|
||||||
Loading…
Reference in new issue