Commit fbc822058b03211a75586627e760d9a335cb4fc4

Authored by Perry Werneck
1 parent b6f8c26c
Exists in master

Adding "str" method in the Action object.

src/action/methods.cc
... ... @@ -93,7 +93,7 @@ PyObject * py3270_action_get_activatable(PyObject *self, void *dunno) {
93 93  
94 94 }
95 95  
96   -DLL_PRIVATE PyObject * py3270_action_wait(PyObject *self, PyObject *args) {
  96 +PyObject * py3270_action_wait(PyObject *self, PyObject *args) {
97 97  
98 98 return py3270_action_call(self, [args, self](TN3270::Action &action) {
99 99  
... ... @@ -106,5 +106,15 @@ DLL_PRIVATE PyObject * py3270_action_wait(PyObject *self, PyObject *args) {
106 106  
107 107 }
108 108  
  109 +PyObject * py3270_action_str(PyObject *self) {
  110 +
  111 + return py3270_action_call(self, [](TN3270::Action &action) {
  112 +
  113 + return PyUnicode_FromString(action.getSummary());
  114 +
  115 + });
  116 +
  117 +}
  118 +
109 119  
110 120  
... ...
src/action/type.c
... ... @@ -86,6 +86,7 @@ PyTypeObject py3270_action_type = {
86 86  
87 87 .tp_methods = py3270_action_methods,
88 88 .tp_getset = py3270_action_attributes,
  89 + .tp_str = py3270_action_str,
89 90  
90 91 .tp_dealloc = py3270_action_dealloc,
91 92  
... ...
src/include/py3270.h
... ... @@ -122,7 +122,6 @@
122 122 DLL_PRIVATE void py3270_action_type_init(PyTypeObject *type);
123 123 DLL_PRIVATE void py3270_session_type_init(PyTypeObject *type);
124 124  
125   -
126 125 // Session object
127 126 DLL_PRIVATE PyObject * py3270_session_alloc(PyTypeObject *type, PyObject *args, PyObject *kwds);
128 127 DLL_PRIVATE void py3270_session_dealloc(PyObject * self);
... ... @@ -150,6 +149,7 @@
150 149 DLL_PRIVATE PyObject * py3270_action_wait(PyObject *self, PyObject *args);
151 150  
152 151 DLL_PRIVATE PyObject * py3270_action_get_activatable(PyObject *self, void *dunno);
  152 + DLL_PRIVATE PyObject * py3270_action_str(PyObject *self);
153 153  
154 154 /*
155 155  
... ...
src/module/init.c
... ... @@ -70,30 +70,6 @@ static struct PyModuleDef definition = {
70 70 .m_free = (freefunc) cleanup
71 71 };
72 72  
73   -/*
74   -static PyTypeObject ActionType = {
75   -
76   - PyVarObject_HEAD_INIT(NULL, 0)
77   -
78   - .tp_name = "tn3270.Action",
79   - .tp_doc = "TN3270 Action Object",
80   - .tp_basicsize = sizeof(pyAction),
81   - .tp_itemsize = 0,
82   - .tp_flags = Py_TPFLAGS_DEFAULT,
83   -
84   -// .tp_new = py3270_session_alloc,
85   -// .tp_dealloc = py3270_session_dealloc,
86   -
87   -// .tp_init = py3270_session_init,
88   -// .tp_finalize = py3270_session_finalize,
89   -
90   -// .tp_str = py3270_session_str,
91   -
92   -// .tp_methods = py3270_session_methods,
93   -
94   -};
95   -*/
96   -
97 73 /*---[ Implement ]----------------------------------------------------------------------------------*/
98 74  
99 75 PyMODINIT_FUNC PyInit_tn3270(void)
... ...
testprograms/sample.py
... ... @@ -23,6 +23,7 @@ if session.reconnect.activatable:
23 23 print("Reconnecting...")
24 24 session.reconnect().wait(10)
25 25  
  26 +print(session.reconnect)
26 27 print(session.connected)
27 28  
28 29 #print('----------------------')
... ...