*** empty log message ***

This commit is contained in:
hyung-hwan 2006-12-15 06:47:09 +00:00
parent b50cd52bbc
commit cc019d0416
6 changed files with 163 additions and 74 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.cpp,v 1.8 2006-12-14 07:55:51 bacon Exp $ * $Id: Awk.cpp,v 1.9 2006-12-15 06:47:07 bacon Exp $
*/ */
#include "stdafx.h" #include "stdafx.h"
@ -43,14 +43,14 @@ CAwk::CAwk (): handle(NULL),
ASE_AWK_EXPLICIT | ASE_AWK_EXPLICIT |
ASE_AWK_UNIQUEAFN | ASE_AWK_UNIQUEAFN |
ASE_AWK_HASHSIGN | ASE_AWK_HASHSIGN |
/*ASE_AWK_IDIV | ASE_AWK_IDIV |
ASE_AWK_SHADING | ASE_AWK_SHADING |
ASE_AWK_SHIFT | */ ASE_AWK_SHIFT |
ASE_AWK_EXTIO /*| ASE_AWK_EXTIO |
ASE_AWK_BLOCKLESS | ASE_AWK_BLOCKLESS |
ASE_AWK_STRINDEXONE | ASE_AWK_STRINDEXONE |
ASE_AWK_STRIPSPACES | ASE_AWK_STRIPSPACES |
ASE_AWK_NEXTOFILE*/; ASE_AWK_NEXTOFILE;
} }
CAwk::~CAwk () CAwk::~CAwk ()
@ -505,7 +505,7 @@ HRESULT CAwk::Run (int* ret)
ase_awk_runios_t runios; ase_awk_runios_t runios;
runios.pipe = NULL; runios.pipe = NULL;
runios.coproc = NULL; runios.coproc = NULL;
runios.file = NULL; runios.file = __process_extio;
runios.console = __process_extio; runios.console = __process_extio;
runios.custom_data = this; runios.custom_data = this;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: AwkExtio.cpp,v 1.6 2006-12-14 07:55:52 bacon Exp $ * $Id: AwkExtio.cpp,v 1.7 2006-12-15 06:47:08 bacon Exp $
*/ */
#include "stdafx.h" #include "stdafx.h"
@ -10,23 +10,25 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// CAwkExtio // CAwkExtio
CAwkExtio::CAwkExtio (): name (NULL)/*, handle (NULL)*/ CAwkExtio::CAwkExtio (): name (NULL)
{ {
//#ifdef _DEBUG #ifdef _DEBUG
TCHAR x[128]; TCHAR x[128];
_sntprintf (x, 128, _T("CAwkExtio::CAwkExtio %p"), this); _sntprintf (x, 128, _T("CAwkExtio::CAwkExtio %p"), this);
MessageBox (NULL, x, x, MB_OK); MessageBox (NULL, x, x, MB_OK);
//#endif #endif
VariantInit (&handle);
} }
CAwkExtio::~CAwkExtio () CAwkExtio::~CAwkExtio ()
{ {
//#ifdef _DEBUG #ifdef _DEBUG
TCHAR x[128]; TCHAR x[128];
_sntprintf (x, 128, _T("CAwkExtio::~CAwkExtio %p"), this); _sntprintf (x, 128, _T("CAwkExtio::~CAwkExtio %p"), this);
MessageBox (NULL, x, x, MB_OK); MessageBox (NULL, x, x, MB_OK);
//#endif #endif
if (name != NULL) SysFreeString (name); if (name != NULL) SysFreeString (name);
VariantClear (&handle);
} }
STDMETHODIMP CAwkExtio::get_Name (BSTR *pVal) STDMETHODIMP CAwkExtio::get_Name (BSTR *pVal)
@ -35,7 +37,7 @@ STDMETHODIMP CAwkExtio::get_Name (BSTR *pVal)
else else
{ {
BSTR tmp = SysAllocStringLen (name, SysStringLen(name)); BSTR tmp = SysAllocStringLen (name, SysStringLen(name));
if (tmp = NULL) return E_OUTOFMEMORY; if (tmp == NULL) return E_OUTOFMEMORY;
*pVal = tmp; *pVal = tmp;
} }
@ -63,12 +65,14 @@ STDMETHODIMP CAwkExtio::get_Mode(int *pVal)
STDMETHODIMP CAwkExtio::get_Handle (VARIANT *pVal) STDMETHODIMP CAwkExtio::get_Handle (VARIANT *pVal)
{ {
VariantClear (pVal);
VariantCopy (pVal, &handle); VariantCopy (pVal, &handle);
return S_OK; return S_OK;
} }
STDMETHODIMP CAwkExtio::put_Handle (VARIANT newVal) STDMETHODIMP CAwkExtio::put_Handle (VARIANT newVal)
{ {
handle.Copy (&newVal); VariantClear (&handle);
VariantCopy (&handle, &newVal);
return S_OK; return S_OK;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: AwkExtio.h,v 1.7 2006-12-11 14:58:25 bacon Exp $ * $Id: AwkExtio.h,v 1.8 2006-12-15 06:47:08 bacon Exp $
*/ */
#ifndef _ASE_COM_AWKEXTIO_H_ #ifndef _ASE_COM_AWKEXTIO_H_
@ -19,7 +19,7 @@ public:
BSTR name; BSTR name;
int type; int type;
int mode; int mode;
CComVariant handle; VARIANT handle;
IBuffer* read_buf; IBuffer* read_buf;
ase_size_t read_buf_pos; ase_size_t read_buf_pos;

View File

@ -11,36 +11,22 @@ Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False Attribute VB_Exposed = False
Private m_active As Boolean Private m_eof As Boolean
Private m_count As Long
Public Enum Status
STATUS_ON = 1
STATUS_OFF = 2
End Enum
Private Sub Class_Initialize() Private Sub Class_Initialize()
m_active = False m_eof = False
m_count = 0 'MsgBox "AwkExtio Initializeing"
MsgBox "AwkExtio Initializeing"
End Sub End Sub
Private Sub Class_Terminate() Private Sub Class_Terminate()
MsgBox "AwkExtio Terminating..." 'MsgBox "AwkExtio Terminating..."
End Sub End Sub
Public Property Let Active(v As Boolean) Public Property Let EOF(v As Boolean)
m_active = v m_eof = v
End Property End Property
Public Property Get Active() As Boolean Public Property Get EOF() As Boolean
Active = m_active EOF = m_eof
End Property End Property
Public Property Let Count(v As Long)
m_count = v
End Property
Public Property Get Count() As Long
Count = m_count
End Property

View File

@ -12,7 +12,7 @@ Begin VB.Form AwkForm
Begin VB.TextBox ConsoleIn Begin VB.TextBox ConsoleIn
BeginProperty Font BeginProperty Font
Name = "Courier New" Name = "Courier New"
Size = 8.25 Size = 9
Charset = 0 Charset = 0
Weight = 400 Weight = 400
Underline = 0 'False Underline = 0 'False
@ -29,7 +29,7 @@ Begin VB.Form AwkForm
Begin VB.TextBox SourceIn Begin VB.TextBox SourceIn
BeginProperty Font BeginProperty Font
Name = "Courier New" Name = "Courier New"
Size = 8.25 Size = 9
Charset = 0 Charset = 0
Weight = 400 Weight = 400
Underline = 0 'False Underline = 0 'False
@ -46,7 +46,7 @@ Begin VB.Form AwkForm
Begin VB.TextBox SourceOut Begin VB.TextBox SourceOut
BeginProperty Font BeginProperty Font
Name = "Courier New" Name = "Courier New"
Size = 8.25 Size = 9
Charset = 0 Charset = 0
Weight = 400 Weight = 400
Underline = 0 'False Underline = 0 'False
@ -71,7 +71,7 @@ Begin VB.Form AwkForm
Begin VB.TextBox ConsoleOut Begin VB.TextBox ConsoleOut
BeginProperty Font BeginProperty Font
Name = "Courier New" Name = "Courier New"
Size = 8.25 Size = 9
Charset = 0 Charset = 0
Weight = 400 Weight = 400
Underline = 0 'False Underline = 0 'False
@ -104,7 +104,7 @@ Private Sub Execute_Click()
SourceOut.Text = "" SourceOut.Text = ""
Set Awk = New ASELib.Awk Set Awk = New ASELib.Awk
Awk.Option = Awk.Option Or ASELib.AWK_SHADING Or ASELib.AWK_IDIV 'Awk.Option = Awk.Option Or ASELib.AWK_SHADING Or ASELib.AWK_IDIV
If Awk.Parse() = -1 Then If Awk.Parse() = -1 Then
MsgBox "PARSE ERROR OCCURRED!!!" MsgBox "PARSE ERROR OCCURRED!!!"
@ -167,23 +167,46 @@ Function Awk_OpenExtio(ByVal extio As ASELib.AwkExtio) As Long
If extio.mode = ASELib.AWK_EXTIO_CONSOLE_READ Then If extio.mode = ASELib.AWK_EXTIO_CONSOLE_READ Then
extio.Handle = New AwkExtioConsole extio.Handle = New AwkExtioConsole
With extio.Handle With extio.Handle
.Active = True .EOF = False
.Count = 0
End With End With
Awk_OpenExtio = 1 Awk_OpenExtio = 1
ElseIf extio.mode = ASELib.AWK_EXTIO_CONSOLE_WRITE Then ElseIf extio.mode = ASELib.AWK_EXTIO_CONSOLE_WRITE Then
extio.Handle = New AwkExtioConsole extio.Handle = New AwkExtioConsole
With extio.Handle With extio.Handle
.Active = True .EOF = False
.Count = 0
End With End With
Awk_OpenExtio = 1 Awk_OpenExtio = 1
End If End If
Case ASELib.AWK_EXTIO_FILE Case ASELib.AWK_EXTIO_FILE
If extio.mode = ASELib.AWK_EXTIO_FILE_READ Then
extio.Handle = FreeFile
On Error GoTo ErrorTrap
Open extio.Name For Input As #extio.Handle
On Error GoTo 0
Awk_OpenExtio = 1
ElseIf extio.mode = ASELib.AWK_EXTIO_FILE_WRITE Then
extio.Handle = FreeFile
On Error GoTo ErrorTrap
Open extio.Name For Output As #extio.Handle
On Error GoTo 0
Awk_OpenExtio = 1
ElseIf extio.mode = ASELib.AWK_EXTIO_FILE_APPEND Then
extio.Handle = FreeFile
On Error GoTo ErrorTrap
Open extio.Name For Append As #extio.Handle
On Error GoTo 0
Awk_OpenExtio = 1
End If
Case ASELib.AWK_EXTIO_PIPE Case ASELib.AWK_EXTIO_PIPE
Case ASELib.AWK_EXTIO_COPROC Case ASELib.AWK_EXTIO_COPROC
End Select End Select
Exit Function
ErrorTrap:
Exit Function
End Function End Function
Function Awk_CloseExtio(ByVal extio As ASELib.AwkExtio) As Long Function Awk_CloseExtio(ByVal extio As ASELib.AwkExtio) As Long
@ -191,14 +214,18 @@ Function Awk_CloseExtio(ByVal extio As ASELib.AwkExtio) As Long
Select Case extio.Type Select Case extio.Type
Case ASELib.AWK_EXTIO_CONSOLE Case ASELib.AWK_EXTIO_CONSOLE
If extio.mode = ASELib.AWK_EXTIO_CONSOLE_READ Then If extio.mode = ASELib.AWK_EXTIO_CONSOLE_READ Or _
extio.Handle = Nothing extio.mode = ASELib.AWK_EXTIO_CONSOLE_WRITE Then
Awk_CloseExtio = 0
ElseIf extio.mode = ASELib.AWK_EXTIO_CONSOLE_WRITE Then
extio.Handle = Nothing extio.Handle = Nothing
Awk_CloseExtio = 0 Awk_CloseExtio = 0
End If End If
Case ASELib.AWK_EXTIO_FILE Case ASELib.AWK_EXTIO_FILE
If extio.mode = ASELib.AWK_EXTIO_FILE_READ Or _
extio.mode = ASELib.AWK_EXTIO_FILE_WRITE Or _
extio.mode = ASELib.AWK_EXTIO_FILE_APPEND Then
Close #extio.Handle
Awk_CloseExtio = 0
End If
Case ASELib.AWK_EXTIO_PIPE Case ASELib.AWK_EXTIO_PIPE
Case ASELib.AWK_EXTIO_COPROC Case ASELib.AWK_EXTIO_COPROC
End Select End Select
@ -211,19 +238,43 @@ Function Awk_ReadExtio(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffe
Select Case extio.Type Select Case extio.Type
Case ASELib.AWK_EXTIO_CONSOLE Case ASELib.AWK_EXTIO_CONSOLE
If extio.mode = ASELib.AWK_EXTIO_CONSOLE_READ Then If extio.mode = ASELib.AWK_EXTIO_CONSOLE_READ Then
Awk_ReadExtio = Awk_ReadExtioConsole(extio, buf) Awk_ReadExtio = ReadExtioConsole(extio, buf)
End If
Case ASELib.AWK_EXTIO_FILE
If extio.mode = ASELib.AWK_EXTIO_FILE_READ Then
Awk_ReadExtio = ReadExtioFile(extio, buf)
End If
Case ASELib.AWK_EXTIO_PIPE
Case ASELib.AWK_EXTIO_COPROC
End Select
End Function
Function Awk_WriteExtio(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long
Awk_WriteExtio = -1
Select Case extio.Type
Case ASELib.AWK_EXTIO_CONSOLE
If extio.mode = ASELib.AWK_EXTIO_CONSOLE_WRITE Then
Awk_WriteExtio = WriteExtioConsole(extio, buf)
End If End If
Case ASELib.AWK_EXTIO_FILE Case ASELib.AWK_EXTIO_FILE
If extio.mode = ASELib.AWK_EXTIO_FILE_WRITE Or _
extio.mode = ASELib.AWK_EXTIO_FILE_APPEND Then
Awk_WriteExtio = WriteExtioFile(extio, buf)
End If
Case ASELib.AWK_EXTIO_PIPE Case ASELib.AWK_EXTIO_PIPE
Case ASELib.AWK_EXTIO_COPROC Case ASELib.AWK_EXTIO_COPROC
End Select End Select
End Function End Function
Function Awk_ReadExtioConsole(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long Function ReadExtioConsole(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long
Dim value As String, value2 As String Dim value As String, value2 As String
Dim l As Integer, i As Integer Dim l As Integer, i As Integer
If extio.Handle.Count = 0 Then If Not extio.Handle.EOF Then
value = ConsoleIn.Text value = ConsoleIn.Text
l = Len(value) l = Len(value)
@ -239,30 +290,41 @@ Function Awk_ReadExtioConsole(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELi
value2 = value2 + Mid(value, i, 1) value2 = value2 + Mid(value, i, 1)
End If End If
extio.Handle.Count = extio.Handle.Count + 1 extio.Handle.EOF = True
buf.value = value2 buf.value = value2
Awk_ReadExtioConsole = Len(value2) ReadExtioConsole = Len(value2)
Else Else
Awk_ReadExtioConsole = 0 ReadExtioConsole = 0
End If End If
End Function End Function
Function Awk_WriteExtio(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long Function ReadExtioFile(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long
Awk_WriteExtio = -1 Dim value As String
Select Case extio.Type If EOF(extio.Handle) Then
Case ASELib.AWK_EXTIO_CONSOLE ReadExtioFile = 0
If extio.mode = ASELib.AWK_EXTIO_CONSOLE_WRITE Then Exit Function
Awk_WriteExtio = Awk_WriteExtioConsole(extio, buf) End If
End If
Case ASELib.AWK_EXTIO_FILE On Error GoTo ErrorTrap
Case ASELib.AWK_EXTIO_PIPE Line Input #extio.Handle, value
Case ASELib.AWK_EXTIO_COPROC On Error GoTo 0
End Select
value = value + vbCrLf
buf.value = value
ReadExtioFile = Len(buf.value)
Exit Function
ErrorTrap:
ReadExtioFile = -1
Exit Function
End Function End Function
Function Awk_WriteExtioConsole(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long Function WriteExtioConsole(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long
Dim value As String, i As Long, value2 As String Dim value As String
'Dim value2 As String
'Dim i As Long
value = buf.value value = buf.value
@ -273,18 +335,55 @@ Function Awk_WriteExtioConsole(ByVal extio As ASELib.AwkExtio, ByVal buf As ASEL
If value = vbLf Then If value = vbLf Then
ConsoleOut.Text = ConsoleOut.Text + vbCrLf ConsoleOut.Text = ConsoleOut.Text + vbCrLf
Awk_WriteExtioConsole = 1 WriteExtioConsole = 1
Else Else
ConsoleOut.Text = ConsoleOut.Text + value ConsoleOut.Text = ConsoleOut.Text + value
Awk_WriteExtioConsole = Len(value) WriteExtioConsole = Len(value)
End If End If
End Function End Function
Function WriteExtioFile(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long
Dim value As String
WriteExtioFile = -1
value = buf.value
On Error GoTo ErrorTrap
Print #extio.Handle, value;
On Error GoTo 0
WriteExtioFile = Len(value)
Exit Function
ErrorTrap:
Exit Function
End Function
Private Sub Form_Load() Private Sub Form_Load()
Dim x As Variant 'Dim x As ASELib.AwkExtio
'Dim i As Long
SourceIn.Text = "BEGIN { print 123.12; print 995; print 5432.1; }" SourceIn.Text = "BEGIN { print 123.12; print 995; print 5432.1; }"
SourceOut.Text = "" SourceOut.Text = ""
ConsoleIn.Text = "" ConsoleIn.Text = ""
ConsoleOut.Text = "" ConsoleOut.Text = ""
'Set x = New ASELib.AwkExtio
'For i = 0 To 50000
' x.Handle = New AwkExtioConsole
'Next i
'Set x = Nothing
'i = FreeFile
'On Error GoTo ErrorHandler
'Open "c:/projects/ase/ase.xdg" For Input As #i
'On Error GoTo 0
'MsgBox Input(LOF(i), i)
'Close #i
'Exit Sub
'ErrorHandler:
' MsgBox "fuck"
' Exit Sub
End Sub End Sub

View File

@ -1,2 +1,2 @@
AwkForm = 44, 44, 644, 582, , 22, 22, 738, 641, C AwkForm = 13, 12, 545, 559, , 22, 22, 738, 641, C
AwkExtioConsole = 0, 0, 547, 460, C AwkExtioConsole = 0, 0, 547, 460, C