Commit 09e4766341a132e302424b811cbb001fe55eea00

Authored by Perry Werneck
1 parent c9143205
Exists in master

Implementing the "str" method.

src/include/py3270.h
@@ -117,6 +117,7 @@ @@ -117,6 +117,7 @@
117 DLL_PRIVATE PyObject * py3270_session_disconnect(PyObject *self, PyObject *args); 117 DLL_PRIVATE PyObject * py3270_session_disconnect(PyObject *self, PyObject *args);
118 118
119 DLL_PRIVATE PyObject * py3270_session_get(PyObject *self, PyObject *args); 119 DLL_PRIVATE PyObject * py3270_session_get(PyObject *self, PyObject *args);
  120 + DLL_PRIVATE PyObject * py3270_session_str(PyObject *self);
120 121
121 /* 122 /*
122 123
src/module/init.c
@@ -114,6 +114,8 @@ static PyTypeObject SessionType = { @@ -114,6 +114,8 @@ static PyTypeObject SessionType = {
114 .tp_init = py3270_session_init, 114 .tp_init = py3270_session_init,
115 .tp_finalize = py3270_session_finalize, 115 .tp_finalize = py3270_session_finalize,
116 116
  117 + .tp_str = py3270_session_str,
  118 +
117 .tp_methods = py3270_session_methods, 119 .tp_methods = py3270_session_methods,
118 120
119 }; 121 };
src/terminal/get.cc
@@ -83,6 +83,16 @@ @@ -83,6 +83,16 @@
83 83
84 } 84 }
85 85
  86 + DLL_PRIVATE PyObject * py3270_session_str(PyObject *self) {
  87 +
  88 + return py3270_session_call(self, [](TN3270::Host &host){
  89 +
  90 + return PyUnicode_FromString(host.toString().c_str());
  91 +
  92 + });
  93 +
  94 + }
  95 +
86 96
87 /* 97 /*
88 DLL_PRIVATE PyObject * py3270_session_getattr(PyObject *self, char *attr_name) { 98 DLL_PRIVATE PyObject * py3270_session_getattr(PyObject *self, char *attr_name) {
testprograms/sample.py
@@ -4,8 +4,6 @@ @@ -4,8 +4,6 @@
4 import inspect 4 import inspect
5 import tn3270 5 import tn3270
6 6
7 -print("Teste extensão pw3270")  
8 -  
9 print("Using TN3270 Version " + tn3270.version()) 7 print("Using TN3270 Version " + tn3270.version())
10 print(tn3270.revision()) 8 print(tn3270.revision())
11 9
@@ -26,10 +24,10 @@ print(session.connected) @@ -26,10 +24,10 @@ print(session.connected)
26 #print(dir(session)) 24 #print(dir(session))
27 #print('----------------------') 25 #print('----------------------')
28 26
29 -print(session.get(14,22,38)) 27 +#print(session.get(14,22,38))
30 28
31 #print "-----------------------------------------------------------------------" 29 #print "-----------------------------------------------------------------------"
32 -#print term 30 +print(session)
33 #print "-----------------------------------------------------------------------" 31 #print "-----------------------------------------------------------------------"
34 32
35 del session 33 del session