From fbc822058b03211a75586627e760d9a335cb4fc4 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Fri, 27 Sep 2019 10:49:06 -0300 Subject: [PATCH] Adding "str" method in the Action object. --- src/action/methods.cc | 12 +++++++++++- src/action/type.c | 1 + src/include/py3270.h | 2 +- src/module/init.c | 24 ------------------------ testprograms/sample.py | 1 + 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/action/methods.cc b/src/action/methods.cc index c0e8c4b..702cacb 100644 --- a/src/action/methods.cc +++ b/src/action/methods.cc @@ -93,7 +93,7 @@ PyObject * py3270_action_get_activatable(PyObject *self, void *dunno) { } -DLL_PRIVATE PyObject * py3270_action_wait(PyObject *self, PyObject *args) { +PyObject * py3270_action_wait(PyObject *self, PyObject *args) { return py3270_action_call(self, [args, self](TN3270::Action &action) { @@ -106,5 +106,15 @@ DLL_PRIVATE PyObject * py3270_action_wait(PyObject *self, PyObject *args) { } +PyObject * py3270_action_str(PyObject *self) { + + return py3270_action_call(self, [](TN3270::Action &action) { + + return PyUnicode_FromString(action.getSummary()); + + }); + +} + diff --git a/src/action/type.c b/src/action/type.c index 6929ac9..5d36c4a 100644 --- a/src/action/type.c +++ b/src/action/type.c @@ -86,6 +86,7 @@ PyTypeObject py3270_action_type = { .tp_methods = py3270_action_methods, .tp_getset = py3270_action_attributes, + .tp_str = py3270_action_str, .tp_dealloc = py3270_action_dealloc, diff --git a/src/include/py3270.h b/src/include/py3270.h index 3a2ceef..5d7398e 100644 --- a/src/include/py3270.h +++ b/src/include/py3270.h @@ -122,7 +122,6 @@ DLL_PRIVATE void py3270_action_type_init(PyTypeObject *type); DLL_PRIVATE void py3270_session_type_init(PyTypeObject *type); - // Session object DLL_PRIVATE PyObject * py3270_session_alloc(PyTypeObject *type, PyObject *args, PyObject *kwds); DLL_PRIVATE void py3270_session_dealloc(PyObject * self); @@ -150,6 +149,7 @@ DLL_PRIVATE PyObject * py3270_action_wait(PyObject *self, PyObject *args); DLL_PRIVATE PyObject * py3270_action_get_activatable(PyObject *self, void *dunno); + DLL_PRIVATE PyObject * py3270_action_str(PyObject *self); /* diff --git a/src/module/init.c b/src/module/init.c index cf721de..ae4a6db 100644 --- a/src/module/init.c +++ b/src/module/init.c @@ -70,30 +70,6 @@ static struct PyModuleDef definition = { .m_free = (freefunc) cleanup }; -/* -static PyTypeObject ActionType = { - - PyVarObject_HEAD_INIT(NULL, 0) - - .tp_name = "tn3270.Action", - .tp_doc = "TN3270 Action Object", - .tp_basicsize = sizeof(pyAction), - .tp_itemsize = 0, - .tp_flags = Py_TPFLAGS_DEFAULT, - -// .tp_new = py3270_session_alloc, -// .tp_dealloc = py3270_session_dealloc, - -// .tp_init = py3270_session_init, -// .tp_finalize = py3270_session_finalize, - -// .tp_str = py3270_session_str, - -// .tp_methods = py3270_session_methods, - -}; -*/ - /*---[ Implement ]----------------------------------------------------------------------------------*/ PyMODINIT_FUNC PyInit_tn3270(void) diff --git a/testprograms/sample.py b/testprograms/sample.py index e21c9af..db47556 100644 --- a/testprograms/sample.py +++ b/testprograms/sample.py @@ -23,6 +23,7 @@ if session.reconnect.activatable: print("Reconnecting...") session.reconnect().wait(10) +print(session.reconnect) print(session.connected) #print('----------------------') -- libgit2 0.21.2