Commit 1bf62f405de2785d9c1683ab56edf9a23bce09b6

Authored by Perry Werneck
1 parent 0f291e32

Primeiro teste ok!

src/python/private.h 0 → 100644
@@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como main.cc e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 +#ifndef PRIVATE_H_INCLUDED
  31 +
  32 + #define PRIVATE_H_INCLUDED
  33 +
  34 + #include <Python.h>
  35 +
  36 + #include <lib3270/config.h>
  37 + #include <pw3270/class.h>
  38 +
  39 + typedef struct {
  40 +
  41 + PyObject_HEAD
  42 +
  43 + PW3270_NAMESPACE::session * session;
  44 +
  45 + } pw3270_TerminalObject;
  46 +
  47 +
  48 +#endif // PRIVATE_H_INCLUDED
src/python/py3270.cbp
@@ -11,6 +11,8 @@ @@ -11,6 +11,8 @@
11 <Option object_output=".obj/Debug/" /> 11 <Option object_output=".obj/Debug/" />
12 <Option type="3" /> 12 <Option type="3" />
13 <Option compiler="gcc" /> 13 <Option compiler="gcc" />
  14 + <Option host_application="./test.sh" />
  15 + <Option run_host_application_in_terminal="1" />
14 <Compiler> 16 <Compiler>
15 <Add option="-g" /> 17 <Add option="-g" />
16 <Add option="-DDEBUG=1" /> 18 <Add option="-DDEBUG=1" />
@@ -42,15 +44,18 @@ @@ -42,15 +44,18 @@
42 </Compiler> 44 </Compiler>
43 <Linker> 45 <Linker>
44 <Add option="`python2-config --libs`" /> 46 <Add option="`python2-config --libs`" />
  47 + <Add option="`pkg-config --libs dbus-1`" />
45 </Linker> 48 </Linker>
46 <Unit filename="../classlib/exception.cc" /> 49 <Unit filename="../classlib/exception.cc" />
47 <Unit filename="../classlib/local.cc" /> 50 <Unit filename="../classlib/local.cc" />
48 <Unit filename="../classlib/module.cc" /> 51 <Unit filename="../classlib/module.cc" />
49 <Unit filename="../classlib/remote.cc" /> 52 <Unit filename="../classlib/remote.cc" />
50 <Unit filename="../classlib/session.cc" /> 53 <Unit filename="../classlib/session.cc" />
  54 + <Unit filename="../include/lib3270/config.h" />
51 <Unit filename="../include/pw3270/class.h" /> 55 <Unit filename="../include/pw3270/class.h" />
52 - <Unit filename="main.cc" />  
53 <Unit filename="private.h" /> 56 <Unit filename="private.h" />
  57 + <Unit filename="py3270.cc" />
  58 + <Unit filename="sample.py" />
54 <Extensions> 59 <Extensions>
55 <code_completion /> 60 <code_completion />
56 <envvars /> 61 <envvars />
src/python/py3270.cc 0 → 100644
@@ -0,0 +1,68 @@ @@ -0,0 +1,68 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como main.cc e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + * Implementa métodos básicos para a extensão python.
  29 + *
  30 + * Referências:
  31 + *
  32 + * <https://docs.python.org/2/extending/newtypes.html>
  33 + * <https://docs.python.org/2.7/extending/extending.html#a-simple-example>
  34 + *
  35 + */
  36 +
  37 + #include "private.h"
  38 +
  39 +/*---[ Implement ]----------------------------------------------------------------------------------*/
  40 +
  41 +static PyObject * get_revision(PyObject *self, PyObject *args) {
  42 +
  43 + return PyLong_FromLong(atoi(PACKAGE_REVISION));
  44 +
  45 +}
  46 +
  47 +static PyMethodDef MyMethods[] = {
  48 +
  49 + { "revision", get_revision, METH_VARARGS, "Get module revision." },
  50 +
  51 + {NULL, NULL, 0, NULL} /* Sentinel */
  52 +
  53 +};
  54 +
  55 +PyMODINIT_FUNC initpy3270(void) {
  56 +
  57 + PyObject *m = Py_InitModule("py3270", MyMethods);
  58 +
  59 + if (m == NULL)
  60 + return;
  61 +
  62 +/*
  63 + SpamError = PyErr_NewException("spam.error", NULL, NULL);
  64 + Py_INCREF(SpamError);
  65 + PyModule_AddObject(m, "error", SpamError);
  66 +*/
  67 +
  68 +}
src/python/sample.py 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 +#!/usr/bin/python
  2 +#-*- coding: utf-8
  3 +
  4 +import py3270
  5 +
  6 +print "Teste extensão pw3270"
  7 +
  8 +print py3270.revision()
  9 +
  10 +
src/python/test.sh 0 → 100755
@@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
  1 +#!/bin/bash
  2 +
  3 +export PYTHONPATH=${PWD}/.bin/Debug:${PYTHONPATH}
  4 +
  5 +python ./sample.py
  6 +