diff --git a/py3270.cbp b/py3270.cbp
index 0a011aa..a58e063 100644
--- a/py3270.cbp
+++ b/py3270.cbp
@@ -44,6 +44,7 @@
+
@@ -54,13 +55,13 @@
-
+
diff --git a/src/action/init.cc b/src/action/init.cc
index e16b8c9..1cd311b 100644
--- a/src/action/init.cc
+++ b/src/action/init.cc
@@ -36,6 +36,7 @@
#include
#include
+ #include
/*---[ Implement ]----------------------------------------------------------------------------------*/
@@ -43,3 +44,34 @@ void py3270_action_type_init(PyTypeObject *type) {
}
+
+static void cleanup(pyAction * self) {
+
+ if(self->action) {
+ delete self->action;
+ self->action = nullptr;
+ }
+
+}
+
+void py3270_action_dealloc(PyObject * self) {
+ debug("%s",__FUNCTION__);
+ cleanup((pyAction *) self);
+}
+
+void py3270_action_finalize(PyObject *self) {
+ debug("%s",__FUNCTION__);
+ cleanup((pyAction *) self);
+}
+
+PyObject * py3270_action_activatable(PyObject *self, PyObject *args) {
+
+ return py3270_action_call(self, [](TN3270::Action &action) {
+
+ return PyBool_FromLong(action.activatable());
+
+ });
+
+
+}
+
diff --git a/src/action/new.cc b/src/action/new.cc
index b501308..6eaa940 100644
--- a/src/action/new.cc
+++ b/src/action/new.cc
@@ -41,4 +41,10 @@
DLL_PRIVATE PyObject * py3270_action_new_from_session(PyObject *session, void *action) {
+ pyAction * object = (pyAction *) _PyObject_New(&py3270_action_type);
+
+ object->action = ((pySession *) session)->host->getAction((const LIB3270_ACTION *) action);
+
+ return (PyObject *) object;
+
}
diff --git a/src/action/tools.cc b/src/action/tools.cc
new file mode 100644
index 0000000..b962941
--- /dev/null
+++ b/src/action/tools.cc
@@ -0,0 +1,61 @@
+/*
+ * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
+ * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
+ * aplicativos mainframe. Registro no INPI sob o nome G3270.
+ *
+ * Copyright (C) <2008>
+ *
+ * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
+ * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
+ * Free Software Foundation.
+ *
+ * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
+ * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
+ * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
+ * obter mais detalhes.
+ *
+ * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
+ * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
+ * St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Este programa está nomeado como misc.cc e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ * Implementa métodos básicos inicio/final do objeto python
+ *
+ * Referências:
+ *
+ *
+ *
+ *
+ */
+
+ #include
+
+/*---[ Implement ]----------------------------------------------------------------------------------*/
+
+PyObject * py3270_action_call(PyObject *self, std::function worker) noexcept {
+
+ try {
+
+ TN3270::Action *action = ((pyAction * ) self)->action;
+ return worker(*action);
+
+ } catch(const exception &e) {
+
+ PyErr_SetString(PyExc_RuntimeError, e.what());
+
+ } catch( ... ) {
+
+ PyErr_SetString(PyExc_RuntimeError, "Unexpected error in action object");
+
+ }
+
+ return NULL;
+
+}
+
diff --git a/src/action/type.c b/src/action/type.c
index b0d476b..fe7fc9a 100644
--- a/src/action/type.c
+++ b/src/action/type.c
@@ -38,14 +38,12 @@
static PyMethodDef py3270_action_methods[] = {
- /*
{
"activatable",
(PyCFunction) py3270_action_activatable,
METH_NOARGS,
""
},
- */
{
NULL
@@ -58,13 +56,17 @@ PyTypeObject py3270_action_type = {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "tn3270.Session.Action",
- .tp_doc = "TN3270 Session Action Object",
+ .tp_doc = "TN3270 Action Object",
.tp_basicsize = sizeof(pyAction),
.tp_itemsize = 0,
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_methods = py3270_action_methods,
+ .tp_dealloc = py3270_action_dealloc,
+ .tp_finalize = py3270_action_finalize,
+
+
};
diff --git a/src/include/py3270.h b/src/include/py3270.h
index 822816f..2d32f0a 100644
--- a/src/include/py3270.h
+++ b/src/include/py3270.h
@@ -77,20 +77,25 @@
#include
#include
#include
+ #include
#include
using std::exception;
using std::runtime_error;
using TN3270::Host;
+ using TN3270::Action;
DLL_PRIVATE PyObject * py3270_session_call(PyObject *self, std::function worker) noexcept;
DLL_PRIVATE PyObject * py3270_session_call(PyObject *self, std::function worker) noexcept;
+ DLL_PRIVATE PyObject * py3270_action_call(PyObject *self, std::function worker) noexcept;
+
extern "C" {
#else
typedef void Host;
+ typedef void Action;
#endif
@@ -101,8 +106,7 @@
typedef struct {
PyObject_HEAD
- Host *host;
- const struct _lib3270_action * action;
+ Action *action;
} pyAction;
DLL_PRIVATE PyTypeObject py3270_session_type;
@@ -136,6 +140,10 @@
// Action object
DLL_PRIVATE PyObject * py3270_action_new_from_session(PyObject *session, void *action);
+ DLL_PRIVATE void py3270_action_dealloc(PyObject * self);
+ DLL_PRIVATE void py3270_action_finalize(PyObject *self);
+
+ DLL_PRIVATE PyObject * py3270_action_activatable(PyObject *self, PyObject *args);
/*
diff --git a/src/module/tools.cc b/src/module/tools.cc
deleted file mode 100644
index 29f6c50..0000000
--- a/src/module/tools.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como misc.cc e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- * Implementa métodos básicos inicio/final do objeto python
- *
- * Referências:
- *
- *
- *
- *
- */
-
- #include
-
-/*---[ Implement ]----------------------------------------------------------------------------------*/
-
-PyObject * py3270_session_call(PyObject *self, std::function worker) noexcept {
-
- try {
-
- TN3270::Host *host = ((pySession * ) self)->host;
- return worker(*host);
-
- } catch(const exception &e) {
-
- PyErr_SetString(PyExc_RuntimeError, e.what());
-
- } catch( ... ) {
-
- PyErr_SetString(PyExc_RuntimeError, "Unexpected error in core module");
-
- }
-
- return NULL;
-
-}
-
-PyObject * py3270_session_call(PyObject *self, std::function worker) noexcept {
-
- try {
-
- TN3270::Host *host = ((pySession * ) self)->host;
- return PyLong_FromLong(worker(*host));
-
- } catch(const exception &e) {
-
- PyErr_SetString(PyExc_RuntimeError, e.what());
-
- } catch( ... ) {
-
- PyErr_SetString(PyExc_RuntimeError, "Unexpected error in core module");
-
- }
-
- return NULL;
-
-}
-
diff --git a/src/session/init.cc b/src/session/init.cc
index 3e94c55..22ada57 100644
--- a/src/session/init.cc
+++ b/src/session/init.cc
@@ -70,7 +70,7 @@ void py3270_session_type_init(PyTypeObject *type) {
for(auto attribute : attributes) {
-// debug("Creating attribute %s",attribute->name);
+ debug("Creating attribute %s",attribute->name);
py3270_session_attribute_init(&type->tp_getset[ix], (const LIB3270_PROPERTY *) attribute);
diff --git a/src/session/tools.cc b/src/session/tools.cc
new file mode 100644
index 0000000..29f6c50
--- /dev/null
+++ b/src/session/tools.cc
@@ -0,0 +1,82 @@
+/*
+ * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
+ * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
+ * aplicativos mainframe. Registro no INPI sob o nome G3270.
+ *
+ * Copyright (C) <2008>
+ *
+ * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
+ * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
+ * Free Software Foundation.
+ *
+ * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
+ * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
+ * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
+ * obter mais detalhes.
+ *
+ * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
+ * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
+ * St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Este programa está nomeado como misc.cc e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ * Implementa métodos básicos inicio/final do objeto python
+ *
+ * Referências:
+ *
+ *
+ *
+ *
+ */
+
+ #include
+
+/*---[ Implement ]----------------------------------------------------------------------------------*/
+
+PyObject * py3270_session_call(PyObject *self, std::function worker) noexcept {
+
+ try {
+
+ TN3270::Host *host = ((pySession * ) self)->host;
+ return worker(*host);
+
+ } catch(const exception &e) {
+
+ PyErr_SetString(PyExc_RuntimeError, e.what());
+
+ } catch( ... ) {
+
+ PyErr_SetString(PyExc_RuntimeError, "Unexpected error in core module");
+
+ }
+
+ return NULL;
+
+}
+
+PyObject * py3270_session_call(PyObject *self, std::function worker) noexcept {
+
+ try {
+
+ TN3270::Host *host = ((pySession * ) self)->host;
+ return PyLong_FromLong(worker(*host));
+
+ } catch(const exception &e) {
+
+ PyErr_SetString(PyExc_RuntimeError, e.what());
+
+ } catch( ... ) {
+
+ PyErr_SetString(PyExc_RuntimeError, "Unexpected error in core module");
+
+ }
+
+ return NULL;
+
+}
+
diff --git a/testprograms/sample.py b/testprograms/sample.py
index e6fca32..f394373 100644
--- a/testprograms/sample.py
+++ b/testprograms/sample.py
@@ -20,10 +20,18 @@ print(session.url)
print(session.connected)
+#print('----------------------')
+#print(dir(session))
+#print('----------------------')
+
+test = session.reconnect
print('----------------------')
-print(dir(session))
+print(dir(test))
print('----------------------')
+print(test.activatable())
+
+
#print(session.get(14,22,38))
#print("-----------------------------------------------------------------------")
--
libgit2 0.21.2