Commit 271f665853c5dbe8aa0bb6d8beabee1593044dda

Authored by Perry Werneck
1 parent 3202b9c0
Exists in master

Testando em VB.NET

Makefile.in
... ... @@ -26,6 +26,7 @@
26 26  
27 27 GLUELIB=lib3270-mono@DLLEXT@
28 28 LIBNAME=pw3270-sharp.dll
  29 +TESTPROGRAM?=vbtest
29 30  
30 31 #---[ Configuration values ]-------------------------------------------------------------
31 32  
... ... @@ -223,9 +224,9 @@ Debug: \
223 224 run: \
224 225 $(BINDBG)/$(GLUELIB) \
225 226 $(BINDBG)/$(LIBNAME) \
226   - $(BINDBG)/sample.exe
  227 + $(BINDBG)/$(TESTPROGRAM).exe
227 228  
228   - @$(MONO) $(BINDBG)/sample.exe
  229 + @$(MONO) $(BINDBG)/$(TESTPROGRAM).exe
229 230  
230 231 $(BINDBG)/$(GLUELIB): \
231 232 src/native/*.cc \
... ...
src/native/private.h
... ... @@ -54,6 +54,14 @@
54 54  
55 55 #endif
56 56  
  57 + #include <cstdio>
  58 +
  59 + #ifdef DEBUG
  60 + #define debug( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n" , __FILE__, (int) __LINE__, __VA_ARGS__ ); fflush(stderr);
  61 + #else
  62 + #define debug( fmt, ... ) /* */
  63 + #endif // DEBUG
  64 +
57 65 #include <pw3270cpp.h>
58 66 #include <cerrno>
59 67 #include <cstring>
... ...
testprograms/vbtest.vb
... ... @@ -7,29 +7,43 @@ Imports System.Runtime.InteropServices
7 7 Public Module modmain
8 8  
9 9  
10   - <DllImport("lib3270-mono")> _
  10 + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _
11 11 Private Shared Function tn3270_create_session(ByVal Name As String) As IntPtr
12 12 End Function
13 13  
14   - <DllImport("lib3270-mono")> _
  14 + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _
15 15 Private Shared Function tn3270_destroy_session(ByVal hSession As IntPtr) as Long
16 16 End Function
17 17  
18   - <DllImport("lib3270-mono")> _
19   - Private Shared Function tn3270_get_version(ByVal hSession As IntPtr, ByRef buffer As StringBuilder, ByVal strlen as Integer) as Long
  18 + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _
  19 + Private Shared Function tn3270_get_version(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Long
20 20 End Function
21 21  
22   - ' Main is the application's entry point.
  22 + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _
  23 + Private Shared Function tn3270_get_revision(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Long
  24 + End Function
  25 +
  26 + ' Application's entry point.
23 27 Sub Main()
24 28  
25 29 dim host as IntPtr = tn3270_create_session("")
  30 + dim buffer As New StringBuilder(1024)
  31 +
  32 + ' Get library version
  33 + tn3270_get_version(host, buffer, 1024)
  34 + dim vrs as String = buffer.toString
  35 +
  36 + ' Get Library revision
  37 + tn3270_get_revision(host, buffer, 1024)
  38 + dim rev as String = buffer.toString
26 39  
27 40 ' Write text to the console.
28   - Console.WriteLine ("Hello World using Visual Basic!")
  41 + Console.WriteLine ("Using pw3270 version " + vrs + " revision " + rev)
  42 +
29 43  
30 44  
  45 + tn3270_destroy_session(host)
31 46  
32 47 End Sub
33 48  
34 49 End Module
35   -
... ...