From 7078548654065e519532bf2fb0e4f5e874006486 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Wed, 3 Apr 2013 14:00:54 +0000 Subject: [PATCH] Iniciando implementação da classe ooRexx --- src/plugins/rx3270/Makefile.in | 2 +- src/plugins/rx3270/local.cc | 11 +++++++++++ src/plugins/rx3270/rexx_methods.cc | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/plugins/rx3270/rx3270.cls | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/plugins/rx3270/rx3270.h | 9 +++++++++ src/plugins/rx3270/rxapimain.cc | 12 +++++++++++- src/plugins/rx3270/sample/object.rex | 20 ++++++++++++++++++++ src/plugins/rx3270/typed_routines.cc | 2 +- 8 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 src/plugins/rx3270/rexx_methods.cc create mode 100644 src/plugins/rx3270/rx3270.cls create mode 100644 src/plugins/rx3270/sample/object.rex diff --git a/src/plugins/rx3270/Makefile.in b/src/plugins/rx3270/Makefile.in index 80a0f8f..9c26baa 100644 --- a/src/plugins/rx3270/Makefile.in +++ b/src/plugins/rx3270/Makefile.in @@ -29,7 +29,7 @@ MODULE_NAME=rx3270 DEPENDS=*.h ../../include/*.h ../../include/lib3270/*.h Makefile PLUGIN_SRC=pluginmain.cc -EXTAPI_SRC=rxapimain.cc text.cc typed_routines.cc local.cc +EXTAPI_SRC=rxapimain.cc text.cc typed_routines.cc local.cc rexx_methods.cc #---[ Tools ]------------------------------------------------------------------ diff --git a/src/plugins/rx3270/local.cc b/src/plugins/rx3270/local.cc index d619b37..de9de19 100644 --- a/src/plugins/rx3270/local.cc +++ b/src/plugins/rx3270/local.cc @@ -139,6 +139,17 @@ rx3270::~rx3270() defSession = NULL; } +rx3270 * rx3270::create(const char *type) +{ + if(type && *type) + { + // Create remote session + return NULL; + } + return new dynamic(); +} + + rx3270 * rx3270::get_default(void) { if(defSession) diff --git a/src/plugins/rx3270/rexx_methods.cc b/src/plugins/rx3270/rexx_methods.cc new file mode 100644 index 0000000..a938ee9 --- /dev/null +++ b/src/plugins/rx3270/rexx_methods.cc @@ -0,0 +1,76 @@ +/* + * "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., 59 Temple + * Place, Suite 330, Boston, MA, 02111-1307, USA + * + * Este programa está nomeado como rexx_methods.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) + * + */ + + #include + #include + + #include "rx3270.h" + + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + +RexxMethod1(int, rx3270_method_init, CSTRING, type) +{ + // Set session class in rexx object + RexxPointerObject sessionPtr = context->NewPointer(rx3270::create(type)); + context->SetObjectVariable("CSELF", sessionPtr); + return 0; +} + +RexxMethod1(int, rx3270_method_uninit, CSELF, sessionPtr) +{ + rx3270 *hSession = (rx3270 *) sessionPtr; + if(hSession) + delete hSession; + return 0; +} + +RexxMethod3(int, rx3270_method_connect, CSELF, sessionPtr, CSTRING, uri, OPTIONAL_int, wait) +{ + rx3270 *hSession = (rx3270 *) sessionPtr; + if(!hSession) + return -1; + return hSession->connect(uri,wait != 0); +} + +RexxMethod1(int, rx3270_method_disconnect, CSELF, sessionPtr) +{ + rx3270 *hSession = (rx3270 *) sessionPtr; + if(!hSession) + return -1; + return hSession->disconnect(); +} + +RexxMethod2(int, rx3270_method_sleep, CSELF, sessionPtr, int, seconds) +{ + rx3270 *hSession = (rx3270 *) sessionPtr; + if(!hSession) + return -1; + return hSession->wait(seconds); +} diff --git a/src/plugins/rx3270/rx3270.cls b/src/plugins/rx3270/rx3270.cls new file mode 100644 index 0000000..e767d09 --- /dev/null +++ b/src/plugins/rx3270/rx3270.cls @@ -0,0 +1,44 @@ +/*-- REXX -----------------------------------------------------------------------*/ +/* */ +/* "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., 59 Temple */ +/* Place, Suite 330, Boston, MA, 02111-1307, USA */ +/* */ +/* Contatos: */ +/* */ +/* perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) */ +/* erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) */ +/* licinio@bb.com.br (Licínio Luis Branco) */ +/* */ +/*-------------------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------------------*/ +/* 3270 class */ +/*-------------------------------------------------------------------------------*/ + +::class rx3270 public subclass object + + +::METHOD INIT EXTERNAL "LIBRARY rx3270 rx3270_method_init" +::METHOD UNINIT EXTERNAL "LIBRARY rx3270 rx3270_method_uninit" + +::METHOD CONNECT EXTERNAL "LIBRARY rx3270 rx3270_method_connect" +::METHOD DISCONNECT EXTERNAL "LIBRARY rx3270 rx3270_method_disconnect" + +::METHOD SLEEP EXTERNAL "LIBRARY rx3270 rx3270_method_sleep" + diff --git a/src/plugins/rx3270/rx3270.h b/src/plugins/rx3270/rx3270.h index 3cecfe7..b65b80c 100644 --- a/src/plugins/rx3270/rx3270.h +++ b/src/plugins/rx3270/rx3270.h @@ -70,6 +70,12 @@ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270queryStringAt); REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SetStringAt); + REXX_METHOD_PROTOTYPE(rx3270_method_init); + REXX_METHOD_PROTOTYPE(rx3270_method_uninit); + REXX_METHOD_PROTOTYPE(rx3270_method_connect); + REXX_METHOD_PROTOTYPE(rx3270_method_disconnect); + REXX_METHOD_PROTOTYPE(rx3270_method_sleep); + /*---[ Globals ]---------------------------------------------------------------------------------------------*/ /*--[ 3270 Session ]-----------------------------------------------------------------------------------------*/ @@ -92,6 +98,7 @@ rx3270(); virtual ~rx3270(); + static rx3270 * create(const char *type = NULL); static rx3270 * get_default(void); static void set_plugin(void); @@ -121,4 +128,6 @@ }; + rx3270 * create_lib3270_instance(void); + #endif // RX3270_H_INCLUDED diff --git a/src/plugins/rx3270/rxapimain.cc b/src/plugins/rx3270/rxapimain.cc index f1de212..e3dbf8c 100644 --- a/src/plugins/rx3270/rxapimain.cc +++ b/src/plugins/rx3270/rxapimain.cc @@ -109,6 +109,16 @@ RexxRoutineEntry rx3270_functions[] = REXX_LAST_METHOD() }; +RexxMethodEntry rx3270_methods[] = +{ + REXX_METHOD(rx3270_method_init, rx3270_method_init ), + REXX_METHOD(rx3270_method_uninit, rx3270_method_uninit ), + REXX_METHOD(rx3270_method_connect, rx3270_method_connect ), + REXX_METHOD(rx3270_method_disconnect, rx3270_method_disconnect ), + REXX_METHOD(rx3270_method_sleep, rx3270_method_sleep ), + REXX_LAST_METHOD() +}; + RexxPackageEntry rx3270_package_entry = { STANDARD_PACKAGE_HEADER @@ -118,7 +128,7 @@ RexxPackageEntry rx3270_package_entry = NULL, // no load/unload functions NULL, rx3270_functions, // the exported functions - NULL // no methods in rx3270. + rx3270_methods // no methods in rx3270. }; // package loading stub. diff --git a/src/plugins/rx3270/sample/object.rex b/src/plugins/rx3270/sample/object.rex new file mode 100644 index 0000000..4281ce4 --- /dev/null +++ b/src/plugins/rx3270/sample/object.rex @@ -0,0 +1,20 @@ + +use arg uri + +host = .rx3270~new("") + +if host~connect(uri) <> 0 then +do + say "Erro ao conectar em "||uri + return -1 +end + +host~sleep(20) + +host~disconnect() + +return 0 + + +::requires "rx3270.cls" + diff --git a/src/plugins/rx3270/typed_routines.cc b/src/plugins/rx3270/typed_routines.cc index 1e8d2d1..8aa939d 100644 --- a/src/plugins/rx3270/typed_routines.cc +++ b/src/plugins/rx3270/typed_routines.cc @@ -18,7 +18,7 @@ * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA, 02111-1307, USA * - * Este programa está nomeado como text.cc e possui - linhas de código. + * Este programa está nomeado como typed_routines.cc e possui - linhas de código. * * Contatos: * -- libgit2 0.21.2