From a275ce873827bd4b374d3d036a85d2da3577148e Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Sat, 11 Jan 2014 17:26:57 +0800 Subject: [PATCH] delete cpp codes --- PyWinAlfred.Test/PyWinAlfred.Test.vcxproj | 155 ----------------- .../PyWinAlfred.Test.vcxproj.filters | 22 --- PyWinAlfred.Test/Source.cpp | 125 -------------- PyWinAlfred/Main.cpp | 103 ------------ PyWinAlfred/PyWinAlfred.vcxproj | 156 ------------------ PyWinAlfred/PyWinAlfred.vcxproj.filters | 22 --- 6 files changed, 583 deletions(-) delete mode 100644 PyWinAlfred.Test/PyWinAlfred.Test.vcxproj delete mode 100644 PyWinAlfred.Test/PyWinAlfred.Test.vcxproj.filters delete mode 100644 PyWinAlfred.Test/Source.cpp delete mode 100644 PyWinAlfred/Main.cpp delete mode 100644 PyWinAlfred/PyWinAlfred.vcxproj delete mode 100644 PyWinAlfred/PyWinAlfred.vcxproj.filters diff --git a/PyWinAlfred.Test/PyWinAlfred.Test.vcxproj b/PyWinAlfred.Test/PyWinAlfred.Test.vcxproj deleted file mode 100644 index 008dae7f0a..0000000000 --- a/PyWinAlfred.Test/PyWinAlfred.Test.vcxproj +++ /dev/null @@ -1,155 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {05D72D92-4010-4F92-A147-906930241573} - Win32Proj - PyWinAlfredTest - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - C:\Python27\include;$(IncludePath) - C:\Python27\libs;$(LibraryPath) - - - true - C:\Python27\include;$(IncludePath) - C:\Python27\libs;$(LibraryPath) - - - false - - - false - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - - - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/PyWinAlfred.Test/PyWinAlfred.Test.vcxproj.filters b/PyWinAlfred.Test/PyWinAlfred.Test.vcxproj.filters deleted file mode 100644 index 395e675b59..0000000000 --- a/PyWinAlfred.Test/PyWinAlfred.Test.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - \ No newline at end of file diff --git a/PyWinAlfred.Test/Source.cpp b/PyWinAlfred.Test/Source.cpp deleted file mode 100644 index 66596489ed..0000000000 --- a/PyWinAlfred.Test/Source.cpp +++ /dev/null @@ -1,125 +0,0 @@ -#include -#include -#include "Python.h" -#include -#include - -char* GetErrorMessage() -{ - char *pStrErrorMessage = NULL; - - if(PyErr_Occurred()){ - PyObject *ptype, *pvalue, *ptraceback; - PyErr_Fetch(&ptype, &pvalue, &ptraceback); - pStrErrorMessage = PyString_AsString(pvalue); - } - - return pStrErrorMessage; -} - - -char* Exec(char* directory, char* file, char* method, char* para) -{ - PyObject *pName, *pModule, *pDict, *pFunc, *pValue, *pClass, *pInstance; - char *error; - - // Æô¶¯×ÓÏß³ÌǰִÐУ¬ÎªÁËÊÍ·ÅPyEval_InitThreads»ñµÃµÄÈ«¾ÖËø£¬·ñÔò×ÓÏ߳̿ÉÄÜÎÞ·¨»ñÈ¡µ½È«¾ÖËø¡£ - PyEval_ReleaseLock(); - PyGILState_STATE gstate = PyGILState_Ensure(); - - // Initialise the Python interpreter - - - // Build the name object - PyObject *sys = PyImport_ImportModule("sys"); - PyObject *path = PyObject_GetAttrString(sys, "path"); - PyList_Append(path, PyString_FromString(directory)); - - pName = PyString_FromString(file); - error = GetErrorMessage(); - if(error != NULL){ - char* err =new char[5000](); - sprintf(error, "%s:%s","PYTHONERROR",error); - return err; - } - - pModule = PyImport_Import(pName); - error = GetErrorMessage(); - if(error != NULL){ - char* err =new char[5000](); - sprintf(err, "%s:%s","PYTHONERROR",error); - return err; - } - - pDict = PyModule_GetDict(pModule); - error = GetErrorMessage(); - if(error != NULL){ - char* err =new char[5000](); - sprintf(err, "%s:%s","PYTHONERROR",error); - return err; - } - - pClass = PyDict_GetItemString(pDict,"PyWinAlfred"); - error = GetErrorMessage(); - if(error != NULL){ - char* err =new char[5000](); - sprintf(err, "%s:%s","PYTHONERROR",error); - return err; - } - - pInstance = PyObject_CallObject(pClass, NULL); - error = GetErrorMessage(); - if(error != NULL){ - char* err =new char[5000](); - sprintf(err, "%s:%s","PYTHONERROR",error); - return err; - } - - // Call a method of the class with two parameters - pValue = PyObject_CallMethod(pInstance,method, "(s)",para); - error = GetErrorMessage(); - if(error != NULL){ - char* err =new char[5000](); - sprintf(err, "%s:%s","PYTHONERROR",error); - return err; - } - - char * str_ret = PyString_AsString(pValue); - - //PyEval_SaveThread(); - - // Finish the Python Interpreter - - //PyErr_Clear(); - - printf("My thread is finishing... %s \n",para); - PyGILState_Release(gstate); - return str_ret; -} - -int main(int argc, char *argv[]) -{ - char* directory = "d:\\github\\WinAlfred\\Plugins\\WinAlfred.Plugin.DouBan\\"; - char* file = "main"; - char* method = "query"; - char* para1 = "movie 1"; - char* para2 = "movie 2"; - char* para3 = "movie 3"; - char* para4 = "movie 4"; - int i = 0; - // ³õʼ»¯ - Py_Initialize(); - // ³õʼ»¯Ïß³ÌÖ§³Ö - PyEval_InitThreads(); - - //std::async(Exec,directory,file,method,para); - std::async(Exec,directory,file,method,para1); - std::async(Exec,directory,file,method,para2); - std::async(Exec,directory,file,method,para3); - std::async(Exec,directory,file,method,para4); - // ±£Ö¤×ÓÏ̵߳÷Óö¼½áÊøºó - //PyGILState_Ensure(); - getchar(); - Py_Finalize(); - return 0; -} \ No newline at end of file diff --git a/PyWinAlfred/Main.cpp b/PyWinAlfred/Main.cpp deleted file mode 100644 index 9ba66cbb36..0000000000 --- a/PyWinAlfred/Main.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include "Python.h" -#include -#include - -int i = 0; - -extern "C" __declspec(dllexport) void InitPythonEnv() -{ - Py_Initialize(); - PyEval_InitThreads(); - // Æô¶¯×ÓÏß³ÌǰִÐУ¬ÎªÁËÊÍ·ÅPyEval_InitThreads»ñµÃµÄÈ«¾ÖËø£¬·ñÔò×ÓÏ߳̿ÉÄÜÎÞ·¨»ñÈ¡µ½È«¾ÖËø¡£ -} - -char* GetErrorMessage() -{ - char *pStrErrorMessage = NULL; - - if(PyErr_Occurred()){ - PyObject *ptype, *pvalue, *ptraceback; - PyErr_Fetch(&ptype, &pvalue, &ptraceback); - pStrErrorMessage = PyString_AsString(pvalue); - } - - return pStrErrorMessage; -} - - -char* Exec(char* directory, char* file, char* method, char* para) -{ - PyObject *pName, *pModule, *pDict, *pFunc, *pValue, *pClass, *pInstance; - char *error; - - PyEval_ReleaseLock(); - PyGILState_STATE gstate = PyGILState_Ensure(); - // Build the name object - PyObject *path = PySys_GetObject("path"); - PyList_Append(path, PyString_FromString(directory)); - - pName = PyString_FromString(file); - error = GetErrorMessage(); - if(error != NULL){ - char* err =new char[5000](); - sprintf(error, "%s:%s","PYTHONERROR",error); - return err; - } - - pModule = PyImport_Import(pName); - error = GetErrorMessage(); - if(error != NULL){ - char* err =new char[5000](); - sprintf(err, "%s:%s","PYTHONERROR",error); - return err; - } - - pDict = PyModule_GetDict(pModule); - error = GetErrorMessage(); - if(error != NULL){ - char* err =new char[5000](); - sprintf(err, "%s:%s","PYTHONERROR",error); - return err; - } - - pClass = PyDict_GetItemString(pDict,"PyWinAlfred"); - error = GetErrorMessage(); - if(error != NULL){ - char* err =new char[5000](); - sprintf(err, "%s:%s","PYTHONERROR",error); - return err; - } - - pInstance = PyObject_CallObject(pClass, NULL); - error = GetErrorMessage(); - if(error != NULL){ - char* err =new char[5000](); - sprintf(err, "%s:%s","PYTHONERROR",error); - return err; - } - - // Call a method of the class with two parameters - pValue = PyObject_CallMethod(pInstance,method, "(s)",para); - error = GetErrorMessage(); - if(error != NULL){ - char* err =new char[5000](); - sprintf(err, "%s:%s","PYTHONERROR",error); - return err; - } - - char * str_ret = PyString_AsString(pValue); - - //PyErr_Clear(); - PyGILState_Release(gstate); - return str_ret; -} - -extern "C" __declspec(dllexport) char* ExecPython(char* directory, char* file, char* method, char* para) -{ - //PyEval_ReleaseLock(); - char* s = Exec(directory,file,method,para); - return s; - //auto future = std::async(Exec,directory,file,method,para); - //return future.get(); -} \ No newline at end of file diff --git a/PyWinAlfred/PyWinAlfred.vcxproj b/PyWinAlfred/PyWinAlfred.vcxproj deleted file mode 100644 index 6251ad6ae4..0000000000 --- a/PyWinAlfred/PyWinAlfred.vcxproj +++ /dev/null @@ -1,156 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA} - Win32Proj - PyWinAlfred - - - - DynamicLibrary - true - v110 - Unicode - - - DynamicLibrary - true - v110 - MultiByte - - - DynamicLibrary - false - v110 - true - Unicode - - - DynamicLibrary - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - C:\Python27\include;$(IncludePath) - C:\Python27\libs;$(LibraryPath) - - - true - C:\Python27\include;$(IncludePath) - C:\Python27\libs;$(LibraryPath) - $(SolutionDir)WinAlfred\bin\Debug\ - - - false - - - false - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;PYWINALFRED_EXPORTS;%(PreprocessorDefinitions) - true - - - Windows - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;PYWINALFRED_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - - - Windows - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;PYWINALFRED_EXPORTS;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;PYWINALFRED_EXPORTS;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/PyWinAlfred/PyWinAlfred.vcxproj.filters b/PyWinAlfred/PyWinAlfred.vcxproj.filters deleted file mode 100644 index 3b076d1fc7..0000000000 --- a/PyWinAlfred/PyWinAlfred.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - \ No newline at end of file