Просмотр исходного кода

PythonEntry改成PythonInterpreter

tanghai 14 лет назад
Родитель
Сommit
891f6a3320

+ 5 - 5
Src/Egametang/Python/CMakeLists.txt

@@ -1,20 +1,20 @@
 SET(PythonSrc 
 	PythonInit.cc 
-	PythonEntry.cc
+	PythonInterpreter.cc
 )
-ADD_LIBRARY(PythonEntry ${PythonSrc})
+ADD_LIBRARY(PythonInterpreter ${PythonSrc})
 
 ADD_EXECUTABLE(PythonInitTest PythonInitTest.cc)
-ADD_EXECUTABLE(PythonEntryTest PythonEntryTest.cc)
+ADD_EXECUTABLE(PythonInterpreterTest PythonInterpreterTest.cc)
 
 SET(Excutes 
 	PythonInitTest 
-	PythonEntryTest
+	PythonInterpreterTest
 )
 
 FOREACH(Excute ${Excutes})
 	TARGET_LINK_LIBRARIES(${Excute}
-		PythonEntry
+		PythonInterpreter
 		Glog
 		Gflags
 		Gtest

+ 6 - 6
Src/Egametang/Python/PythonEntry.cc → Src/Egametang/Python/PythonInterpreter.cc

@@ -2,27 +2,27 @@
 #include <boost/format.hpp>
 #include <boost/python.hpp>
 #include <glog/logging.h>
-#include "Python/PythonEntry.h"
+#include "Python/PythonInterpreter.h"
 
 namespace Egametang {
 
-PythonEntry::PythonEntry():
+PythonInterpreter::PythonInterpreter():
 		python_init_()
 {
 	main_ns_ = boost::python::import("__main__").attr("__dict__");
 }
 
-void PythonEntry::ImportPath(std::string path)
+void PythonInterpreter::ImportPath(std::string path)
 {
 	python_paths_.insert(path);
 }
 
-void PythonEntry::ImportModule(std::string module)
+void PythonInterpreter::ImportModule(std::string module)
 {
 	python_modules_.insert(module);
 }
 
-bool PythonEntry::GetExecString(const std::string& main_fun, std::string& exec_string)
+bool PythonInterpreter::GetExecString(const std::string& main_fun, std::string& exec_string)
 {
 	exec_string = "import sys\n";
 	if (python_paths_.size() == 0)
@@ -49,7 +49,7 @@ bool PythonEntry::GetExecString(const std::string& main_fun, std::string& exec_s
 	return true;
 }
 
-void PythonEntry::Execute(std::string main_fun)
+void PythonInterpreter::Execute(std::string main_fun)
 {
 	std::string exec_string;
 	if (!GetExecString(main_fun, exec_string))

+ 5 - 5
Src/Egametang/Python/PythonEntry.h → Src/Egametang/Python/PythonInterpreter.h

@@ -1,5 +1,5 @@
-#ifndef PYTHON_PYTHON_ENTRY_H
-#define PYTHON_PYTHON_ENTRY_H
+#ifndef PYTHON_PYTHONINTERPRETER_H
+#define PYTHON_PYTHONINTERPRETER_H
 
 #include <boost/noncopyable.hpp>
 #include <boost/unordered_set.hpp>
@@ -9,7 +9,7 @@
 
 namespace Egametang {
 
-class PythonEntry: private boost::noncopyable
+class PythonInterpreter: private boost::noncopyable
 {
 private:
 	PythonInit python_init_;
@@ -24,7 +24,7 @@ private:
 	bool GetExecString(const std::string& main_fun, std::string& exec_string);
 
 public:
-	PythonEntry();
+	PythonInterpreter();
 
 	void ImportPath(std::string path);
 
@@ -41,4 +41,4 @@ public:
 
 } // namespace Egametang
 
-#endif // PYTHON_PYTHON_ENTRY_H
+#endif // PYTHON_PYTHONINTERPRETER_H

+ 9 - 9
Src/Egametang/Python/PythonEntryTest.cc → Src/Egametang/Python/PythonInterpreterTest.cc

@@ -2,17 +2,17 @@
 #include <gflags/gflags.h>
 #include <glog/logging.h>
 #include <boost/python.hpp>
-#include "Python/PythonEntry.h"
+#include "Python/PythonInterpreter.h"
 
 namespace Egametang {
 
-class PythonEntryTest: public testing::Test
+class PythonInterpreterTest: public testing::Test
 {
 protected:
-	PythonEntry python_entry_;
+	PythonInterpreter python_interpreter_;
 
 public:
-	PythonEntryTest(): python_entry_()
+	PythonInterpreterTest(): python_interpreter_()
 	{}
 };
 
@@ -60,19 +60,19 @@ BOOST_PYTHON_MODULE(PersonTest)
 	boost::python::register_ptr_to_python<PersonTestPtr>();
 }
 
-TEST_F(PythonEntryTest, EnterPythonScript)
+TEST_F(PythonInterpreterTest, EnterPythonScript)
 {
 	initPersonTest();
-	python_entry_.ImportPath("../../../Src/Egametang/Python/");
-	python_entry_.ImportModule("PythonEntryTest");
+	python_interpreter_.ImportPath("../../../Src/Egametang/Python/");
+	python_interpreter_.ImportModule("PythonInterpreterTest");
 
 	PersonTestPtr person(new PersonTest);
-	python_entry_.RegisterObjectPtr("person", person);
+	python_interpreter_.RegisterObjectPtr("person", person);
 
 	ASSERT_EQ(0, person->Guid());
 
 	// 进到python脚本层设置person的值为2
-	python_entry_.Execute("PythonEntryTest.fun(person)");
+	python_interpreter_.Execute("PythonInterpreterTest.fun(person)");
 
 	ASSERT_EQ(2, person->Guid());
 	ASSERT_EQ(std::string("tanghai"), person->Name());

+ 0 - 0
Src/Egametang/Python/PythonEntryTest.py → Src/Egametang/Python/PythonInterpreterTest.py