*** empty log message ***

This commit is contained in:
hyung-hwan 2006-12-11 08:44:52 +00:00
parent 108ec7863b
commit 80626d9d9a
9 changed files with 150 additions and 39 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: map.c,v 1.32 2006-11-29 02:54:15 bacon Exp $ * $Id: map.c,v 1.33 2006-12-11 08:44:52 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -79,6 +79,11 @@ void ase_awk_map_clear (ase_awk_map_t* map)
"the map should not contain any pairs of a key and a value after it has been cleared"); "the map should not contain any pairs of a key and a value after it has been cleared");
} }
ase_size_t ase_awk_map_getsize (ase_awk_map_t* map)
{
return map->size;
}
ase_awk_pair_t* ase_awk_map_get ( ase_awk_pair_t* ase_awk_map_get (
ase_awk_map_t* map, const ase_char_t* key, ase_size_t key_len) ase_awk_map_t* map, const ase_char_t* key, ase_size_t key_len)
{ {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: map.h,v 1.17 2006-10-24 04:10:12 bacon Exp $ * $Id: map.h,v 1.18 2006-12-11 08:44:52 bacon Exp $
*/ */
#ifndef _ASE_AWK_MAP_H_ #ifndef _ASE_AWK_MAP_H_
@ -43,6 +43,8 @@ void ase_awk_map_close (ase_awk_map_t* map);
void ase_awk_map_clear (ase_awk_map_t* map); void ase_awk_map_clear (ase_awk_map_t* map);
ase_size_t ase_awk_map_getsize (ase_awk_map_t* map);
ase_awk_pair_t* ase_awk_map_get ( ase_awk_pair_t* ase_awk_map_get (
ase_awk_map_t* map, const ase_char_t* key, ase_size_t key_len); ase_awk_map_t* map, const ase_char_t* key, ase_size_t key_len);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: parse.c,v 1.219 2006-12-09 11:51:01 bacon Exp $ * $Id: parse.c,v 1.220 2006-12-11 08:44:52 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -360,6 +360,7 @@ int ase_awk_parse (ase_awk_t* awk, ase_awk_srcios_t* srcios)
ASE_AWK_ASSERT (awk, awk->parse.depth.cur.loop == 0); ASE_AWK_ASSERT (awk, awk->parse.depth.cur.loop == 0);
ASE_AWK_ASSERT (awk, awk->parse.depth.cur.expr == 0); ASE_AWK_ASSERT (awk, awk->parse.depth.cur.expr == 0);
if (n == -1) ase_awk_clear (awk);
return n; return n;
} }
@ -4408,37 +4409,37 @@ static int __deparse (ase_awk_t* awk)
for (i = awk->tree.nbglobals; i < awk->tree.nglobals - 1; i++) for (i = awk->tree.nbglobals; i < awk->tree.nglobals - 1; i++)
{ {
/*
len = ase_awk_longtostr ((ase_long_t)i, len = ase_awk_longtostr ((ase_long_t)i,
10, ASE_T("__global"), tmp, ASE_COUNTOF(tmp)); 10, ASE_T("__global"), tmp, ASE_COUNTOF(tmp));
ASE_AWK_ASSERT (awk, len != (ase_size_t)-1); ASE_AWK_ASSERT (awk, len != (ase_size_t)-1);
if (ase_awk_putsrcstrx (awk, tmp, len) == -1) if (ase_awk_putsrcstrx (awk, tmp, len) == -1)
EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE);
/* */
if (ase_awk_putsrcstrx (awk, if (ase_awk_putsrcstrx (awk,
awk->parse.globals.buf[i].name, awk->parse.globals.buf[i].name,
awk->parse.globals.buf[i].name_len) == -1) awk->parse.globals.buf[i].name_len) == -1)
{ {
EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE);
} }
*/
if (ase_awk_putsrcstr (awk, ASE_T(", ")) == -1) if (ase_awk_putsrcstr (awk, ASE_T(", ")) == -1)
EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE);
} }
/*
len = ase_awk_longtostr ((ase_long_t)i, len = ase_awk_longtostr ((ase_long_t)i,
10, ASE_T("__global"), tmp, ASE_COUNTOF(tmp)); 10, ASE_T("__global"), tmp, ASE_COUNTOF(tmp));
ASE_AWK_ASSERT (awk, len != (ase_size_t)-1); ASE_AWK_ASSERT (awk, len != (ase_size_t)-1);
if (ase_awk_putsrcstrx (awk, tmp, len) == -1) if (ase_awk_putsrcstrx (awk, tmp, len) == -1)
EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE);
/* */
if (ase_awk_putsrcstrx (awk, if (ase_awk_putsrcstrx (awk,
awk->parse.globals.buf[i].name, awk->parse.globals.buf[i].name,
awk->parse.globals.buf[i].name_len) == -1) awk->parse.globals.buf[i].name_len) == -1)
{ {
EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE);
} }
*/
if (ase_awk_putsrcstr (awk, ASE_T(";\n\n")) == -1) if (ase_awk_putsrcstr (awk, ASE_T(";\n\n")) == -1)
EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c,v 1.295 2006-12-09 17:36:27 bacon Exp $ * $Id: run.c,v 1.296 2006-12-11 08:44:52 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -562,6 +562,16 @@ int ase_awk_run (ase_awk_t* awk,
awk->errnum = ASE_AWK_ENOERR; awk->errnum = ASE_AWK_ENOERR;
if (awk->tree.nglobals == 0 &&
awk->tree.begin == ASE_NULL &&
awk->tree.end == ASE_NULL &&
awk->tree.chain_size == 0 &&
ase_awk_map_getsize(&awk->tree.afns) == 0)
{
/* no code to execute */
return 0;
}
run = (ase_awk_run_t*) ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_run_t)); run = (ase_awk_run_t*) ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_run_t));
if (run == ASE_NULL) if (run == ASE_NULL)
{ {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: tree.c,v 1.94 2006-12-04 11:25:21 bacon Exp $ * $Id: tree.c,v 1.95 2006-12-11 08:44:52 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -380,12 +380,14 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
if (px->id.idxa != (ase_size_t)-1) if (px->id.idxa != (ase_size_t)-1)
{ {
/*
PUT_SRCSTR (awk, ASE_T("__global")); PUT_SRCSTR (awk, ASE_T("__global"));
n = ase_awk_longtostr ( n = ase_awk_longtostr (
px->id.idxa, 10, px->id.idxa, 10,
ASE_NULL, tmp, ASE_COUNTOF(tmp)); ASE_NULL, tmp, ASE_COUNTOF(tmp));
PUT_SRCSTRX (awk, tmp, n); PUT_SRCSTRX (awk, tmp, n);
/*PUT_SRCSTRX (awk, px->id.name, px->id.name_len);*/ */
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
} }
else else
{ {
@ -403,12 +405,14 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
if (px->id.idxa != (ase_size_t)-1) if (px->id.idxa != (ase_size_t)-1)
{ {
/*
PUT_SRCSTR (awk, ASE_T("__global")); PUT_SRCSTR (awk, ASE_T("__global"));
n = ase_awk_longtostr ( n = ase_awk_longtostr (
px->id.idxa, 10, px->id.idxa, 10,
ASE_NULL, tmp, ASE_COUNTOF(tmp)); ASE_NULL, tmp, ASE_COUNTOF(tmp));
PUT_SRCSTRX (awk, tmp, n); PUT_SRCSTRX (awk, tmp, n);
/*PUT_SRCSTRX (awk, px->id.name, px->id.name_len);*/ */
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
PUT_SRCSTR (awk, ASE_T("[")); PUT_SRCSTR (awk, ASE_T("["));
} }
else else

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.cpp,v 1.5 2006-12-11 06:29:18 bacon Exp $ * $Id: Awk.cpp,v 1.6 2006-12-11 08:44:52 bacon Exp $
*/ */
#include "stdafx.h" #include "stdafx.h"
@ -306,11 +306,11 @@ HRESULT CAwk::Parse (int* ret)
return S_OK; return S_OK;
} }
int opt = /*ASE_AWK_IMPLICIT | int opt = ASE_AWK_IMPLICIT |
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 /*|
@ -423,7 +423,7 @@ static ase_ssize_t __process_extio (
CBuffer* tmp = (CBuffer*)extio2->read_buf; CBuffer* tmp = (CBuffer*)extio2->read_buf;
if (extio2->read_buf_pos >= extio2->read_buf_len) if (extio2->read_buf_pos >= extio2->read_buf_len)
{ {
INT n = awk->Fire_ReadSource (extio2->read_buf); INT n = awk->Fire_ReadExtio (extio, extio2->read_buf);
if (n <= 0) return (ase_ssize_t)n; if (n <= 0) return (ase_ssize_t)n;
if (SysStringLen(tmp->str) < (UINT)n) return -1; if (SysStringLen(tmp->str) < (UINT)n) return -1;

View File

@ -1,11 +1,12 @@
/* /*
* $Id: AwkExtio.h,v 1.5 2006-12-11 06:29:19 bacon Exp $ * $Id: AwkExtio.h,v 1.6 2006-12-11 08:44:52 bacon Exp $
*/ */
#ifndef _ASE_COM_AWKEXTIO_H_ #ifndef _ASE_COM_AWKEXTIO_H_
#define _ASE_COM_AWKEXTIO_H_ #define _ASE_COM_AWKEXTIO_H_
#include "resource.h" #include "resource.h"
#include <ase/awk/awk.h>
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// CAwkExtio // CAwkExtio

View File

@ -1,14 +1,13 @@
/* /*
* $Id: awk_cp.h,v 1.3 2006-12-09 17:36:27 bacon Exp $ * $Id: awk_cp.h,v 1.4 2006-12-11 08:44:52 bacon Exp $
*/ */
#ifndef _AWK_CP_H_ #ifndef _AWK_CP_H_
#define _AWK_CP_H_ #define _AWK_CP_H_
/*#import "C:\projects\ase\debug\win32\vs60\aseawk.dll" raw_interfaces_only, raw_native_types, no_namespace, named_guids*/
template <class T> template <class T>
class CProxyIAwkEvents : public IConnectionPointImpl<T, &DIID_IAwkEvents, CComDynamicUnkArray> class CProxyIAwkEvents:
public IConnectionPointImpl<T, &DIID_IAwkEvents, CComDynamicUnkArray>
{ {
public: public:
INT Fire_OpenSource(INT mode) INT Fire_OpenSource(INT mode)
@ -306,6 +305,58 @@ public:
return -1; return -1;
} }
INT Fire_ReadExtio (IAwkExtio* extio, IBuffer* buf)
{
T* pT = static_cast<T*>(this);
int i, nconns = m_vec.GetSize();
CComVariant args[2], 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]);
VariantClear (&args[1]);
args[1] = (IUnknown*)extio;
args[0] = (IUnknown*)buf;
DISPPARAMS disp = { args, NULL, 2, 0 };
HRESULT hr = pDispatch->Invoke (
0x7, 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_WriteExtio (IAwkExtio* extio, IBuffer* buf) INT Fire_WriteExtio (IAwkExtio* extio, IBuffer* buf)
{ {
T* pT = static_cast<T*>(this); T* pT = static_cast<T*>(this);

View File

@ -1,13 +1,13 @@
VERSION 5.00 VERSION 5.00
Begin VB.Form AwkForm Begin VB.Form AwkForm
Caption = "ASE COM AWK" Caption = "ASE COM AWK"
ClientHeight = 7695 ClientHeight = 7770
ClientLeft = 60 ClientLeft = 60
ClientTop = 345 ClientTop = 345
ClientWidth = 9435 ClientWidth = 10335
LinkTopic = "AwkForm" LinkTopic = "AwkForm"
ScaleHeight = 7695 ScaleHeight = 7770
ScaleWidth = 9435 ScaleWidth = 10335
StartUpPosition = 3 'Windows Default StartUpPosition = 3 'Windows Default
Begin VB.TextBox ConsoleIn Begin VB.TextBox ConsoleIn
BeginProperty Font BeginProperty Font
@ -20,11 +20,11 @@ Begin VB.Form AwkForm
Strikethrough = 0 'False Strikethrough = 0 'False
EndProperty EndProperty
Height = 2895 Height = 2895
Left = 360 Left = 120
MultiLine = -1 'True MultiLine = -1 'True
TabIndex = 4 TabIndex = 4
Top = 3600 Top = 3600
Width = 4095 Width = 5055
End End
Begin VB.TextBox SourceIn Begin VB.TextBox SourceIn
BeginProperty Font BeginProperty Font
@ -37,11 +37,11 @@ Begin VB.Form AwkForm
Strikethrough = 0 'False Strikethrough = 0 'False
EndProperty EndProperty
Height = 2775 Height = 2775
Left = 480 Left = 120
MultiLine = -1 'True MultiLine = -1 'True
TabIndex = 3 TabIndex = 3
Top = 480 Top = 480
Width = 3975 Width = 5055
End End
Begin VB.TextBox SourceOut Begin VB.TextBox SourceOut
BeginProperty Font BeginProperty Font
@ -54,11 +54,11 @@ Begin VB.Form AwkForm
Strikethrough = 0 'False Strikethrough = 0 'False
EndProperty EndProperty
Height = 2775 Height = 2775
Left = 4680 Left = 5280
MultiLine = -1 'True MultiLine = -1 'True
TabIndex = 2 TabIndex = 2
Top = 480 Top = 480
Width = 4095 Width = 4935
End End
Begin VB.CommandButton Execute Begin VB.CommandButton Execute
Caption = "Execute" Caption = "Execute"
@ -79,11 +79,11 @@ Begin VB.Form AwkForm
Strikethrough = 0 'False Strikethrough = 0 'False
EndProperty EndProperty
Height = 2895 Height = 2895
Left = 4680 Left = 5280
MultiLine = -1 'True MultiLine = -1 'True
TabIndex = 0 TabIndex = 0
Top = 3600 Top = 3600
Width = 4095 Width = 4935
End End
End End
Attribute VB_Name = "AwkForm" Attribute VB_Name = "AwkForm"
@ -109,8 +109,12 @@ Private Sub Execute_Click()
SourceOut.Text = "" SourceOut.Text = ""
Set abc = New ASELib.Awk Set abc = New ASELib.Awk
Call abc.Parse If abc.Parse() = -1 Then
Call abc.Run MsgBox "PARSE ERROR OCCURRED!!!"
End If
If abc.Run() = -1 Then
MsgBox "RUN ERROR OCCURRED!!!"
End If
Set abc = Nothing Set abc = Nothing
End Sub End Sub
@ -159,8 +163,16 @@ End Function
Function abc_OpenExtio(ByVal extio As ASELib.AwkExtio) As Long Function abc_OpenExtio(ByVal extio As ASELib.AwkExtio) As Long
MsgBox "abc_OpenExtio" MsgBox "abc_OpenExtio"
extio_first = True If extio.mode = 0 Then
abc_OpenExtio = 1 extio_first = True
abc_OpenExtio = 1
Exit Function
ElseIf extio.mode = 1 Then
abc_OpenExtio = 1
Exit Function
End If
abc_OpenExtio = -1
End Function End Function
Function abc_CloseExtio(ByVal extio As ASELib.AwkExtio) As Long Function abc_CloseExtio(ByVal extio As ASELib.AwkExtio) As Long
@ -169,13 +181,33 @@ MsgBox "abc_CloseExtio"
End Function End Function
Function abc_ReadExtio(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long Function abc_ReadExtio(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long
Dim value As String Dim value As String, value2 As String
Dim l As Integer, i As Integer
If extio.mode <> 0 Then
abc_ReadExtio = -1
Exit Function
End If
If extio_first Then If extio_first Then
value = ConsoleIn.Text value = ConsoleIn.Text
l = Len(value)
For i = 1 To l - 1
If Mid(value, i, 2) = vbCrLf Then
value2 = value2 + vbLf
i = i + 1
Else
value2 = value2 + Mid(value, i, 1)
End If
Next
If i = l Then
value2 = value2 + Mid(value, i, 1)
End If
extio_first = False extio_first = False
buf.value = value buf.value = value2
abc_ReadExtio = Len(value) abc_ReadExtio = Len(value2)
Else Else
abc_ReadExtio = 0 abc_ReadExtio = 0
End If End If
@ -184,6 +216,11 @@ End Function
Function abc_WriteExtio(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long Function abc_WriteExtio(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, i As Long, value2 As String
If extio.mode <> 1 Then
abc_WriteExtio = -1
Exit Function
End If
value = buf.value value = buf.value
'For i = 0 To 5000000 'For i = 0 To 5000000