*** empty log message ***

This commit is contained in:
hyung-hwan 2006-12-11 14:58:25 +00:00
parent 80626d9d9a
commit d46e714d24
10 changed files with 293 additions and 75 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h,v 1.161 2006-12-08 06:02:41 bacon Exp $
* $Id: awk.h,v 1.162 2006-12-11 14:58:25 bacon Exp $
*/
#ifndef _ASE_AWK_AWK_H_
@ -170,11 +170,8 @@ enum
/* support blockless patterns */
ASE_AWK_BLOCKLESS = (1 << 9),
/* execution starts from main */
ASE_AWK_RUNMAIN = (1 << 10),
/* use 1 as the start index for string operations */
ASE_AWK_STRINDEXONE = (1 << 11),
ASE_AWK_STRINDEXONE = (1 << 10),
/* strip off leading and trailing spaces when splitting a record
* into fields with a regular expression.
@ -189,13 +186,13 @@ enum
* The program splits " a b c " into [a], [b], [c] when this
* option is on while into [], [a], [b], [c], [] when it is off.
*/
ASE_AWK_STRIPSPACES = (1 << 12),
ASE_AWK_STRIPSPACES = (1 << 11),
/* enable the nextoutfile keyword */
ASE_AWK_NEXTOFILE = (1 << 13),
ASE_AWK_NEXTOFILE = (1 << 12),
/* a newline terminates a statement */
ASE_AWK_NEWLINE = (1 << 14)
ASE_AWK_NEWLINE = (1 << 13)
};
/* error code */

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.6 2006-12-11 08:44:52 bacon Exp $
* $Id: Awk.cpp,v 1.7 2006-12-11 14:58:25 bacon Exp $
*/
#include "stdafx.h"
@ -37,6 +37,20 @@ CAwk::CAwk (): handle(NULL),
_sntprintf (x, 128, _T("CAwk::CAwk %p"), this);
MessageBox (NULL, x, x, MB_OK);
#endif
/* TODO: what is the best default option? */
option = ASE_AWK_IMPLICIT |
ASE_AWK_EXPLICIT |
ASE_AWK_UNIQUEAFN |
ASE_AWK_HASHSIGN |
/*ASE_AWK_IDIV |
ASE_AWK_SHADING |
ASE_AWK_SHIFT | */
ASE_AWK_EXTIO /*|
ASE_AWK_BLOCKLESS |
ASE_AWK_STRINDEXONE |
ASE_AWK_STRIPSPACES |
ASE_AWK_NEXTOFILE*/;
}
CAwk::~CAwk ()
@ -306,20 +320,7 @@ HRESULT CAwk::Parse (int* ret)
return S_OK;
}
int opt = ASE_AWK_IMPLICIT |
ASE_AWK_EXPLICIT |
ASE_AWK_UNIQUEAFN |
ASE_AWK_HASHSIGN |
/*ASE_AWK_IDIV |
ASE_AWK_SHADING |
ASE_AWK_SHIFT | */
ASE_AWK_EXTIO /*|
ASE_AWK_BLOCKLESS |
ASE_AWK_STRINDEXONE |
ASE_AWK_STRIPSPACES |
ASE_AWK_NEXTOFILE*/;
ase_awk_setopt (handle, opt);
ase_awk_setopt (handle, option);
}
ase_awk_srcios_t srcios;
@ -477,10 +478,15 @@ static ase_ssize_t __process_extio (
}
else if (cmd == ASE_AWK_IO_FLUSH)
{
return 1;
IAwkExtio* extio = (IAwkExtio*)epa->handle;
ASE_AWK_ASSERT (ase_awk_getrunawk(epa->run), extio != NULL);
return awk->Fire_FlushExtio (extio);
}
else if (cmd == ASE_AWK_IO_NEXT)
{
IAwkExtio* extio = (IAwkExtio*)epa->handle;
ASE_AWK_ASSERT (ase_awk_getrunawk(epa->run), extio != NULL);
return awk->Fire_NextExtio (extio);
}
return -1;
@ -514,3 +520,15 @@ MessageBox (NULL, ase_awk_geterrstr(err), ase_awk_geterrstr(err), MB_OK);
*ret = 0;
return S_OK;
}
STDMETHODIMP CAwk::get_Option (int *pVal)
{
*pVal = option;
return S_OK;
}
STDMETHODIMP CAwk::put_Option (int newVal)
{
newVal = option;
return S_OK;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.h,v 1.3 2006-12-11 06:29:19 bacon Exp $
* $Id: Awk.h,v 1.4 2006-12-11 14:58:25 bacon Exp $
*/
#ifndef _ASE_COM_AWK_H_
@ -29,6 +29,7 @@ class CAwk :
{
public:
int option;
ase_awk_t* handle;
IBuffer* read_src_buf;
@ -64,6 +65,8 @@ DECLARE_REGISTRY_RESOURCEID(IDR_AWK)
// IAwk
public:
STDMETHOD(get_Option)(/*[out, retval]*/ int *pVal);
STDMETHOD(put_Option)(/*[in]*/ int newVal);
HRESULT __stdcall Parse (int* ret);
HRESULT __stdcall Run (int* ret);
};

View File

@ -1,5 +1,5 @@
/*
* $Id: AwkExtio.cpp,v 1.3 2006-12-10 16:13:50 bacon Exp $
* $Id: AwkExtio.cpp,v 1.4 2006-12-11 14:58:25 bacon Exp $
*/
#include "stdafx.h"
@ -61,3 +61,14 @@ STDMETHODIMP CAwkExtio::get_Mode(int *pVal)
return S_OK;
}
STDMETHODIMP CAwkExtio::get_Handle (VARIANT *pVal)
{
*pVal = handle;
return S_OK;
}
STDMETHODIMP CAwkExtio::put_Handle (VARIANT newVal)
{
handle.Copy (&newVal);
return S_OK;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: AwkExtio.h,v 1.6 2006-12-11 08:44:52 bacon Exp $
* $Id: AwkExtio.h,v 1.7 2006-12-11 14:58:25 bacon Exp $
*/
#ifndef _ASE_COM_AWKEXTIO_H_
@ -41,6 +41,8 @@ END_COM_MAP()
// IAwkExtio
public:
STDMETHOD(get_Handle)(/*[out, retval]*/ VARIANT *pVal);
STDMETHOD(put_Handle)(/*[in]*/ VARIANT newVal);
STDMETHOD(get_Mode)(/*[out, retval]*/ int *pVal);
STDMETHOD(get_Type)(/*[out, retval]*/ int *pVal);
STDMETHOD(get_Name)(/*[out, retval]*/ BSTR *pVal);

View File

@ -1,5 +1,5 @@
/*
* $Id: ase.idl,v 1.2 2006-12-09 17:36:27 bacon Exp $
* $Id: ase.idl,v 1.3 2006-12-11 14:58:25 bacon Exp $
*/
import "oaidl.idl";
@ -20,6 +20,12 @@ interface IAwk : IDispatch
[id(2), helpstring("method Run")]
HRESULT Run([out, retval] int* ret);
[propget, id(3), helpstring("property Option")]
HRESULT Option([out, retval] int *pVal);
[propput, id(3), helpstring("property Option")]
HRESULT Option([in] int newVal);
};
/* ASELib */
@ -33,6 +39,51 @@ library ASELib
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[helpstring("Awk options")]
typedef [v1_enum] enum AwkOption
{
AWK_IMPLICIT = (1 << 0),
AWK_EXPLICIT = (1 << 1),
AWK_UNIQUEAFN = (1 << 2),
AWK_SHADING = (1 << 3),
AWK_SHIFT = (1 << 4),
AWK_IDIV = (1 << 5),
AWK_HASHSIGN = (1 << 6),
AWK_STRCONCAT = (1 << 7),
AWK_EXTIO = (1 << 8),
AWK_BLOCKLESS = (1 << 9),
AWK_STRINDEXONE = (1 << 10),
AWK_STRIPSPACES = (1 << 11),
AWK_NEXTOFILE = (1 << 12)
} AwkOption;
[helpstring("AwkExtio tpe")]
typedef [v1_enum] enum AwkExtioType
{
AWK_EXTIO_PIPE = 0,
AWK_EXTIO_COPROC = 1,
AWK_EXTIO_FILE = 2,
AWK_EXTIO_CONSOLE = 3
} AwkExtioType;
[helpstring("AwkExtio mode")]
typedef [v1_enum] enum AwkExtioMode
{
AWK_EXTIO_PIPE_READ = 0,
AWK_EXTIO_PIPE_WRITE = 1,
AWK_EXTIO_COPROC_READ = 0,
AWK_EXTIO_COPROC_WRITE = 1,
AWK_EXTIO_COPROC_RDWR = 2,
AWK_EXTIO_FILE_READ = 0,
AWK_EXTIO_FILE_WRITE = 1,
AWK_EXTIO_FILE_APPEND = 2,
AWK_EXTIO_CONSOLE_READ = 0,
AWK_EXTIO_CONSOLE_WRITE = 1
} AwkExtioMode;
/* IBuffer */
[
object,
@ -68,6 +119,11 @@ library ASELib
[propget, id(3), helpstring("property Mode")]
HRESULT Mode([out, retval] int *pVal);
[propget, id(4), helpstring("property Handle")]
HRESULT Handle([out, retval] VARIANT *pVal);
[propput, id(4), helpstring("property Handle")]
HRESULT Handle([in] VARIANT newVal);
};
/* IAwkEvents */
@ -102,6 +158,12 @@ library ASELib
[id(8), helpstring("method WriteExtio")]
int WriteExtio([in] IAwkExtio* extio, [in] IBuffer* buf);
[id(9), helpstring("method FlushExtio")]
int FlushExtio([in] IAwkExtio* extio);
[id(10), helpstring("method NextExtio")]
int NextExtio([in] IAwkExtio* extio);
};
/* Awk */

View File

@ -1,5 +1,5 @@
/*
* $Id: awk_cp.h,v 1.4 2006-12-11 08:44:52 bacon Exp $
* $Id: awk_cp.h,v 1.5 2006-12-11 14:58:25 bacon Exp $
*/
#ifndef _AWK_CP_H_
@ -408,6 +408,102 @@ public:
return -1;
}
INT Fire_FlushExtio (IAwkExtio* extio)
{
T* pT = static_cast<T*>(this);
int i, nconns = m_vec.GetSize();
CComVariant args[1], ret;
for (i = 0; i < nconns; i++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(i);
pT->Unlock();
IDispatch* pDispatch =
reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch == NULL) continue;
VariantClear (&ret);
VariantClear (&args[0]);
args[0] = (IUnknown*)extio;
DISPPARAMS disp = { args, NULL, 1, 0 };
HRESULT hr = pDispatch->Invoke (
0x9, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD, &disp, &ret, NULL, NULL);
if (FAILED(hr)) continue;
if (ret.vt == VT_EMPTY)
{
/* probably, the handler has not been implemeted*/
continue;
}
hr = ret.ChangeType (VT_I4);
if (FAILED(hr))
{
/* TODO: set the error code properly... */
/* invalid value returned... */
return -1;
}
return ret.lVal;
}
return -1;
}
INT Fire_NextExtio (IAwkExtio* extio)
{
T* pT = static_cast<T*>(this);
int i, nconns = m_vec.GetSize();
CComVariant args[1], ret;
for (i = 0; i < nconns; i++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(i);
pT->Unlock();
IDispatch* pDispatch =
reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch == NULL) continue;
VariantClear (&ret);
VariantClear (&args[0]);
args[0] = (IUnknown*)extio;
DISPPARAMS disp = { args, NULL, 1, 0 };
HRESULT hr = pDispatch->Invoke (
0xA, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD, &disp, &ret, NULL, NULL);
if (FAILED(hr)) continue;
if (ret.vt == VT_EMPTY)
{
/* probably, the handler has not been implemeted*/
continue;
}
hr = ret.ChangeType (VT_I4);
if (FAILED(hr))
{
/* TODO: set the error code properly... */
/* invalid value returned... */
return -1;
}
return ret.lVal;
}
return -1;
}
};
#endif

View File

@ -93,57 +93,57 @@ Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public WithEvents abc As ASELib.Awk
Attribute abc.VB_VarHelpID = -1
Public WithEvents Awk As ASELib.Awk
Attribute Awk.VB_VarHelpID = -1
Private first As Boolean
Private extio_first As Boolean
Private Sub Execute_Click()
Dim a As Long
Dim x As Object
first = True
ConsoleOut.Text = ""
SourceOut.Text = ""
Set abc = New ASELib.Awk
If abc.Parse() = -1 Then
Set Awk = New ASELib.Awk
Awk.Option = Awk.Option Or ASELib.AWK_SHADING Or ASELib.AWK_IDIV
If Awk.Parse() = -1 Then
MsgBox "PARSE ERROR OCCURRED!!!"
End If
If abc.Run() = -1 Then
If Awk.Run() = -1 Then
MsgBox "RUN ERROR OCCURRED!!!"
End If
Set abc = Nothing
Set Awk = Nothing
End Sub
Function abc_OpenSource(ByVal mode As Long) As Long
abc_OpenSource = 1
Function Awk_OpenSource(ByVal mode As Long) As Long
Awk_OpenSource = 1
End Function
Function abc_CloseSource(ByVal mode As Long) As Long
abc_CloseSource = 0
Function Awk_CloseSource(ByVal mode As Long) As Long
Awk_CloseSource = 0
End Function
Function abc_ReadSource(ByVal buf As ASELib.Buffer) As Long
Function Awk_ReadSource(ByVal buf As ASELib.Buffer) As Long
If first Then
buf.value = SourceIn.Text
abc_ReadSource = Len(buf.value)
Awk_ReadSource = Len(buf.value)
first = False
Else
abc_ReadSource = 0
Awk_ReadSource = 0
End If
End Function
Function abc_WriteSource(ByVal buf As ASELib.Buffer) As Long
Function Awk_WriteSource(ByVal buf As ASELib.Buffer) As Long
Dim value As String, value2 As String, c As String
Dim i As Integer, l As Integer
value = buf.value
If value = vbLf Then
SourceOut.Text = SourceOut.Text + vbCrLf
abc_WriteSource = 1
Awk_WriteSource = 1
Else
l = Len(value)
For i = 1 To l
@ -156,40 +156,67 @@ Function abc_WriteSource(ByVal buf As ASELib.Buffer) As Long
Next i
SourceOut.Text = SourceOut.Text + value2
abc_WriteSource = l
Awk_WriteSource = l
End If
End Function
Function abc_OpenExtio(ByVal extio As ASELib.AwkExtio) As Long
MsgBox "abc_OpenExtio"
If extio.mode = 0 Then
extio_first = True
abc_OpenExtio = 1
Exit Function
ElseIf extio.mode = 1 Then
abc_OpenExtio = 1
Exit Function
End If
Function Awk_OpenExtio(ByVal extio As ASELib.AwkExtio) As Long
Dim console As AwkExtioConsole
Awk_OpenExtio = -1
Select Case extio.Type
Case ASELib.AWK_EXTIO_CONSOLE
If extio.mode = ASELib.AWK_EXTIO_CONSOLE_READ Then
extio_first = True
extio.Handle = 1234
Awk_OpenExtio = 1
ElseIf extio.mode = ASELib.AWK_EXTIO_CONSOLE_WRITE Then
extio_first = True
Set console = New AwkExtioConsole
console.Active = True
console.Count = 0
extio.Handle = console
Awk_OpenExtio = 1
End If
Case ASELib.AWK_EXTIO_FILE
Case ASELib.AWK_EXTIO_PIPE
Case ASELib.AWK_EXTIO_COPROC
End Select
abc_OpenExtio = -1
End Function
Function abc_CloseExtio(ByVal extio As ASELib.AwkExtio) As Long
MsgBox "abc_CloseExtio"
abc_CloseExtio = 0
Function Awk_CloseExtio(ByVal extio As ASELib.AwkExtio) As Long
Awk_CloseExtio = -1
Select Case extio.Type
Case ASELib.AWK_EXTIO_CONSOLE
If extio.mode = ASELib.AWK_EXTIO_CONSOLE_READ Then
Awk_CloseExtio = 0
ElseIf extio.mode = ASELib.AWK_EXTIO_CONSOLE_WRITE Then
Awk_CloseExtio = 0
End If
Case ASELib.AWK_EXTIO_FILE
Case ASELib.AWK_EXTIO_PIPE
Case ASELib.AWK_EXTIO_COPROC
End Select
End Function
Function abc_ReadExtio(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long
Function Awk_ReadExtio(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long
Dim console As AwkExtioConsole
Dim value As String, value2 As String
Dim l As Integer, i As Integer
If extio.mode <> 0 Then
abc_ReadExtio = -1
Awk_ReadExtio = -1
Exit Function
End If
If extio_first Then
Let console = extio.Handle
If console.Count = 0 Then
value = ConsoleIn.Text
l = Len(value)
@ -205,19 +232,19 @@ Function abc_ReadExtio(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffe
value2 = value2 + Mid(value, i, 1)
End If
extio_first = False
console.Count = console.Count + 1
buf.value = value2
abc_ReadExtio = Len(value2)
Awk_ReadExtio = Len(value2)
Else
abc_ReadExtio = 0
Awk_ReadExtio = 0
End If
End Function
Function abc_WriteExtio(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long
Function Awk_WriteExtio(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long
Dim value As String, i As Long, value2 As String
If extio.mode <> 1 Then
abc_WriteExtio = -1
Awk_WriteExtio = -1
Exit Function
End If
@ -230,10 +257,10 @@ Function abc_WriteExtio(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buff
If value = vbLf Then
ConsoleOut.Text = ConsoleOut.Text + vbCrLf
abc_WriteExtio = 1
Awk_WriteExtio = 1
Else
ConsoleOut.Text = ConsoleOut.Text + value
abc_WriteExtio = Len(value)
Awk_WriteExtio = Len(value)
End If
End Function

View File

@ -1,10 +1,11 @@
Type=Exe
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\WINDOWS\System32\stdole2.tlb#OLE Automation
Reference=*\G{F9C69806-16A1-4162-998A-876B33C470BF}#1.0#0#..\..\debug\win32\vs60\ase.dll#ASE Awk 1.0 Type Library
Reference=*\G{F9C69806-16A1-4162-998A-876B33C470BF}#1.0#0#..\..\release\win32\vs60\ase.dll#ASE Awk 1.0 Type Library
Form=AwkForm.frm
Class=AwkExtioConsole; AwkExtioConsole.cls
Startup="AwkForm"
Command32=""
Name="ASE COM"
Name="ASECOM"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1

View File

@ -1 +1,2 @@
AwkForm = 44, 44, 591, 504, , 22, 22, 738, 641, C
AwkForm = 44, 44, 644, 582, , 22, 22, 738, 641, C
AwkExtioConsole = 0, 0, 547, 460, C