From 17431be70162bfb3e4157011adb34ef84d4dffa8 Mon Sep 17 00:00:00 2001 From: bruno Date: Thu, 2 Apr 2015 16:05:00 -0300 Subject: [PATCH] retirando namespaces) --- Makefile | 1 - include/pyClip.h | 37 +++++++++++++++++-------------------- include/pyTradutor.h | 71 ++++++++++++++++++++++++++++++++++------------------------------------- plugin/corePlugin.h | 10 ++++------ src/pyClip.cpp | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------- src/pyTradutor.cpp | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------- src/testLibras.cpp | 26 ++++++++++++-------------- translate.log | 24 ++++++++++++++++++++++++ 8 files changed, 203 insertions(+), 181 deletions(-) create mode 100644 translate.log diff --git a/Makefile b/Makefile index 9b57544..a2612df 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,5 @@ test-plugin: $(CC) plugin\testPlugin.cpp -EHsc $(CLEAN_OBJ) - #Gera documentação doc: diff --git a/include/pyClip.h b/include/pyClip.h index e3f2683..32da305 100644 --- a/include/pyClip.h +++ b/include/pyClip.h @@ -3,27 +3,24 @@ #include "Python.h" -namespace Clipboard +class PyClip { - class PyClip - { - private: - PyObject * pName; - PyObject * pModule; - PyObject * pDict; - PyObject * pFunc; - PyObject * p_On; - PyObject * p_Off; - PyObject * pArgs; - PyObject * pResult; - public: - PyClip(); - ~PyClip(); - char* clip(); - void bdragOn(); - void bdragOff(); - }; -} + private: + PyObject * pName; + PyObject * pModule; + PyObject * pDict; + PyObject * pFunc; + PyObject * p_On; + PyObject * p_Off; + PyObject * pArgs; + PyObject * pResult; + public: + PyClip(); + ~PyClip(); + char* clip(); + void bdragOn(); + void bdragOff(); +}; #endif diff --git a/include/pyTradutor.h b/include/pyTradutor.h index 7bb4bbe..4be45e0 100644 --- a/include/pyTradutor.h +++ b/include/pyTradutor.h @@ -1,32 +1,30 @@ //***************************************************************** /* - VLibras: Automatic contents translator from Portuguese to LIBRAS +VLibras: Automatic contents translator from Portuguese to LIBRAS - Copyright (c) 2015 Gustavo Sobral, Erickson Silva, Leonardo Araújo - VLibras-Core group at LAViD, Federal University of Paraiba +Copyright (c) 2015 Gustavo Sobral, Erickson Silva, Leonardo Araújo +VLibras-Core group at LAViD, Federal University of Paraiba */ //***************************************************************** /** - * \file pyTradutor.hpp - * \authors Erickson Silva, Gustavo Sobral - * \date Janeiro 2015 - */ +* \file pyTradutor.hpp +* \authors Erickson Silva, Gustavo Sobral +* \date Janeiro 2015 +*/ #ifndef _PYTRADUTOR_H #define _PYTRADUTOR_H #include "Python.h" /** \brief Classe para execução do Tradutor - * - * Essa classe permite a execução e comunição do Tradutor - * (Português -> Glosa) do sistema escrito em Python - * permitindo sua utilização numa aplicação C++. - */ - namespace Tradutor - { - class PyTradutor - { +* +* Essa classe permite a execução e comunição do Tradutor +* (Português -> Glosa) do sistema escrito em Python +* permitindo sua utilização numa aplicação C++. +*/ +class PyTradutor +{ private: PyObject * pName; PyObject * pModule; @@ -35,28 +33,27 @@ PyObject * pArgs; PyObject * pResult; public: - /** \brief O construtor da classe - * - * O construtor inicia o ambiente Python para execução da tradução do tradutor. - */ - PyTradutor(); +/** \brief O construtor da classe +* +* O construtor inicia o ambiente Python para execução da tradução do tradutor. +*/ +PyTradutor(); - /** \brief O destrutor da classe - * - * O Destrutor finaliza o ambiente Python montado para execução da tradução. - */ - ~PyTradutor(); +/** \brief O destrutor da classe +* +* O Destrutor finaliza o ambiente Python montado para execução da tradução. +*/ +~PyTradutor(); - /** \brief Converte Português para Glosa - * - * Converte a string de entrada em Português para Glosa - * através da execução do Tradutor e retorna esse resultado - * - * \param input Ponteiro para char com o texto de entrada em Portugês - * \return Ponteiro para char com a tradução da entrada em Glosa - */ - char * convertStringToGlosa(const char * input); - }; -} +/** \brief Converte Português para Glosa +* +* Converte a string de entrada em Português para Glosa +* através da execução do Tradutor e retorna esse resultado +* +* \param input Ponteiro para char com o texto de entrada em Portugês +* \return Ponteiro para char com a tradução da entrada em Glosa +*/ +char * convertStringToGlosa(const char * input); +}; #endif \ No newline at end of file diff --git a/plugin/corePlugin.h b/plugin/corePlugin.h index 8b33d2a..cdc8f35 100644 --- a/plugin/corePlugin.h +++ b/plugin/corePlugin.h @@ -7,8 +7,6 @@ #include using namespace std; -using namespace Tradutor; -using namespace Clipboard; extern "C" { @@ -19,12 +17,12 @@ extern "C" PyClip clipboard; //Inicializa Objetos - EXPORT_API int coreInitize(void); + EXPORT_API int coreInitize(void); - //Faz tradução de Português para glosa - EXPORT_API char* coreExecute(void); + //Faz tradução de Português para glosa + EXPORT_API char* coreExecute(void); - //Libera Objetos utilizados + //Libera Objetos utilizados EXPORT_API int coreFinalize(void); } diff --git a/src/pyClip.cpp b/src/pyClip.cpp index 2118053..432f334 100644 --- a/src/pyClip.cpp +++ b/src/pyClip.cpp @@ -1,56 +1,59 @@ #include "pyClip.h" -namespace Clipboard +PyClip::PyClip() { - PyClip::PyClip() - { - // Initialize the Python interpreter - Py_Initialize(); - - // Type conversion between C++ string to Py string - pName = PyString_FromString("Clipboard"); - assert(pName!=NULL); - // Loads the script name saved in 'pName' - pModule = PyImport_Import(pName); - //PyErr_Print(); - assert(pModule!=NULL); - // Returns the dictionary object that implements the namespace pModule - pDict = PyModule_GetDict(pModule); - //PyErr_Print(); - assert(pDict!=NULL); - // Return the object from dictionary pDict which has a key 'iniciar' - pFunc = PyDict_GetItemString(pDict, "clip"); - p_On = PyDict_GetItemString(pDict, "bdragOn"); - p_Off = PyDict_GetItemString(pDict, "bdragOff"); - //PyErr_Print(); - assert(pFunc!=NULL); - } - - PyClip::~PyClip() - { - Py_Finalize(); - } - - char * PyClip::clip() - { - // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs' - pResult = PyObject_CallObject(pFunc,pArgs); - assert(pResult!=NULL); - - return PyString_AsString(pResult); - } - - void PyClip::bdragOn() - { - // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs' - PyObject_CallObject(p_On,pArgs); - - } - - void PyClip::bdragOff() - { - // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs' - PyObject_CallObject(p_Off,pArgs); - } - -} \ No newline at end of file + // Initialize the Python interpreter + Py_Initialize(); + + // Type conversion between C++ string to Py string + pName = PyString_FromString("Clipboard"); + assert(pName!=NULL); + + // Loads the script name saved in 'pName' + pModule = PyImport_Import(pName); + + //PyErr_Print(); + assert(pModule!=NULL); + + // Returns the dictionary object that implements the namespace pModule + pDict = PyModule_GetDict(pModule); + + //PyErr_Print(); + assert(pDict!=NULL); + + // Return the object from dictionary pDict which has a key 'iniciar' + pFunc = PyDict_GetItemString(pDict, "clip"); + p_On = PyDict_GetItemString(pDict, "bdragOn"); + p_Off = PyDict_GetItemString(pDict, "bdragOff"); + + //PyErr_Print(); + assert(pFunc!=NULL); +} + +PyClip::~PyClip() +{ + Py_Finalize(); +} + +char * PyClip::clip() +{ + // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs' + pResult = PyObject_CallObject(pFunc,pArgs); + assert(pResult!=NULL); + + return PyString_AsString(pResult); +} + +void PyClip::bdragOn() +{ + // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs' + PyObject_CallObject(p_On,pArgs); + +} + +void PyClip::bdragOff() +{ + // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs' + PyObject_CallObject(p_Off,pArgs); +} + diff --git a/src/pyTradutor.cpp b/src/pyTradutor.cpp index 2d1db63..e1ae984 100644 --- a/src/pyTradutor.cpp +++ b/src/pyTradutor.cpp @@ -1,62 +1,68 @@ //***************************************************************** /* - VLibras: Automatic contents translator from Portuguese to LIBRAS +VLibras: Automatic contents translator from Portuguese to LIBRAS - Copyright (c) 2015 Gustavo Sobral, Erickson Silva, Leonardo Araújo - VLibras-Core group at LAViD, Federal University of Paraiba +Copyright (c) 2015 Gustavo Sobral, Erickson Silva, Leonardo Araújo +VLibras-Core group at LAViD, Federal University of Paraiba */ //***************************************************************** /** - * \file pyTradutor.cpp - * \authors Erickson Silva, Gustavo Sobral - * \date Janeiro 2015 - */ +* \file pyTradutor.cpp +* \authors Erickson Silva, Gustavo Sobral +* \date Janeiro 2015 +*/ #include "pyTradutor.h" -namespace Tradutor +PyTradutor::PyTradutor() { - PyTradutor::PyTradutor() - { - // Initialize the Python interpreter - Py_Initialize(); - - // Type conversion between C++ string to Py string - pName = PyString_FromString("PortGlosa"); - assert(pName!=NULL); - // Loads the script name saved in 'pName' - pModule = PyImport_Import(pName); - //PyErr_Print(); - assert(pModule!=NULL); - // Returns the dictionary object that implements the namespace pModule - pDict = PyModule_GetDict(pModule); - //PyErr_Print(); - assert(pDict!=NULL); - // Return the object from dictionary pDict which has a key 'iniciar' - pFunc = PyDict_GetItemString(pDict, "traduzir"); - //PyErr_Print(); - assert(pFunc!=NULL); - } - - PyTradutor::~PyTradutor() - { - // Free the allocated memory and finalize the Python interpreter - Py_Finalize(); - } - - char * PyTradutor::convertStringToGlosa(const char * input) - { - // Generates a new Tuple object with size '1' and value 'input' (converted) - pArgs = PyTuple_Pack(1, PyString_FromString(input)); - PyErr_Print(); - assert(pArgs!=NULL); - // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs' - pResult = PyObject_CallObject(pFunc, pArgs); - PyErr_Print(); - assert(pResult!=NULL); - // Converts the string Python type to C++ - return PyString_AsString(pResult); - //return "Ambulancia"; - } + // Initialize the Python interpreter + Py_Initialize(); + + // Type conversion between C++ string to Py string + pName = PyString_FromString("PortGlosa"); + assert(pName!=NULL); + + // Loads the script name saved in 'pName' + pModule = PyImport_Import(pName); + + //PyErr_Print(); + assert(pModule!=NULL); + + // Returns the dictionary object that implements the namespace pModule + pDict = PyModule_GetDict(pModule); + + //PyErr_Print(); + assert(pDict!=NULL); + + // Return the object from dictionary pDict which has a key 'iniciar' + pFunc = PyDict_GetItemString(pDict, "traduzir"); + + //PyErr_Print(); + assert(pFunc!=NULL); } + +PyTradutor::~PyTradutor() +{ + // Free the allocated memory and finalize the Python interpreter + Py_Finalize(); +} + +char * PyTradutor::convertStringToGlosa(const char * input) +{ + // Generates a new Tuple object with size '1' and value 'input' (converted) + pArgs = PyTuple_Pack(1, PyString_FromString(input)); + PyErr_Print(); + assert(pArgs!=NULL); + + // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs' + pResult = PyObject_CallObject(pFunc, pArgs); + PyErr_Print(); + assert(pResult!=NULL); + + // Converts the string Python type to C++ + return PyString_AsString(pResult); + +} + diff --git a/src/testLibras.cpp b/src/testLibras.cpp index ceb575d..373b2bf 100644 --- a/src/testLibras.cpp +++ b/src/testLibras.cpp @@ -3,27 +3,25 @@ #include "pyTradutor.h" using namespace std; -using namespace Tradutor; -using namespace Clipboard; int main(int argc, char *argv[]) { - //Usado para traduzir português para glosa - PyTradutor *tradutor = new PyTradutor(); + //Usado para traduzir português para glosa + PyTradutor *tradutor = new PyTradutor(); - //Usado para copiar texto da área de transferência - PyClip *clipboard = new PyClip(); + //Usado para copiar texto da área de transferência + PyClip *clipboard = new PyClip(); - //Copia área de transferência para input - char *input = clipboard->clip(); + //Copia área de transferência para input + char *input = clipboard->clip(); - //Traduz de português para glosa - char* glosa = tradutor->convertStringToGlosa(input); + //Traduz de português para glosa + char* glosa = tradutor->convertStringToGlosa(input); - cout << glosa <