*** empty log message ***

This commit is contained in:
hyung-hwan 2006-12-09 17:36:27 +00:00
parent a00c29b744
commit d330ad1734
12 changed files with 374 additions and 149 deletions

View File

@ -1,10 +1,10 @@
== Introduction ==
SSE is a collection of scriping engines for various programming languages.
ASE is a collection of scriping engines for various programming languages.
It has been written in the hopt that it will be useful for programmers.
== License ==
The toolkit is distributed under the SSE general license.
The toolkit is distributed under the ASE general license.
== Author ==
Chung, Hyung-Hwan, the sole author of SSE, is ...
Chung, Hyung-Hwan, the sole author of ASE, is ...

View File

@ -1,5 +1,5 @@
/*
* $Id: jni.c,v 1.36 2006-12-04 06:04:06 bacon Exp $
* $Id: jni.c,v 1.37 2006-12-09 17:36:27 bacon Exp $
*/
#include <ase/awk/jni.h>
@ -669,7 +669,7 @@ static ase_ssize_t __java_open_extio (
ret = -1;
}
if (ret != -1)
if (ret >= 0)
{
/* ret == -1 failed to open the stream
* ret == 0 opened the stream and reached its end
@ -713,7 +713,7 @@ static ase_ssize_t __java_close_extio (
ret = -1;
}
if (ret != -1)
if (ret >= 0)
{
/* ret == -1 failed to close the stream
* ret == 0 closed the stream */

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c,v 1.294 2006-12-05 02:54:22 bacon Exp $
* $Id: run.c,v 1.295 2006-12-09 17:36:27 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -790,12 +790,15 @@ static int __init_run (
}
else run->pattern_range_state = ASE_NULL;
run->extio.handler[ASE_AWK_EXTIO_PIPE] = runios->pipe;
run->extio.handler[ASE_AWK_EXTIO_COPROC] = runios->coproc;
run->extio.handler[ASE_AWK_EXTIO_FILE] = runios->file;
run->extio.handler[ASE_AWK_EXTIO_CONSOLE] = runios->console;
run->extio.custom_data = runios->custom_data;
run->extio.chain = ASE_NULL;
if (runios != ASE_NULL)
{
run->extio.handler[ASE_AWK_EXTIO_PIPE] = runios->pipe;
run->extio.handler[ASE_AWK_EXTIO_COPROC] = runios->coproc;
run->extio.handler[ASE_AWK_EXTIO_FILE] = runios->file;
run->extio.handler[ASE_AWK_EXTIO_CONSOLE] = runios->console;
run->extio.custom_data = runios->custom_data;
run->extio.chain = ASE_NULL;
}
run->global.rs = ASE_NULL;
run->global.fs = ASE_NULL;
@ -3279,78 +3282,73 @@ static ase_awk_val_t* __eval_binop_in (
static ase_awk_val_t* __eval_binop_bor (
ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right)
{
if (left->type == ASE_AWK_VAL_INT &&
right->type == ASE_AWK_VAL_INT)
{
ase_awk_val_t* res;
ase_long_t r =
((ase_awk_val_int_t*)left)->val |
((ase_awk_val_int_t*)right)->val;
int n1, n2, n3;
ase_long_t l1, l2;
ase_real_t r1, r2;
ase_awk_val_t* res;
res = ase_awk_makeintval (run, r);
n1 = ase_awk_valtonum (run, left, &l1, &r1);
n2 = ase_awk_valtonum (run, right, &l2, &r2);
if (res == ASE_NULL)
{
run->errnum = ASE_AWK_ENOMEM;
return ASE_NULL;
}
if (n1 == -1 || n2 == -1) PANIC (run, ASE_AWK_EOPERAND);
return res;
}
n3 = n1 + (n2 << 1);
ASE_AWK_ASSERT (run->awk, n3 >= 0 && n3 <= 3);
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1|(ase_long_t)l2):
(n3 == 1)? ase_awk_makeintval(run,(ase_long_t)r1|(ase_long_t)l2):
(n3 == 2)? ase_awk_makeintval(run,(ase_long_t)l1|(ase_long_t)r2):
ase_awk_makeintval(run,(ase_long_t)r1|(ase_long_t)r2);
run->errnum = ASE_AWK_EOPERAND;
return ASE_NULL;
if (res == ASE_NULL) PANIC (run, ASE_AWK_ENOMEM);
return res;
}
static ase_awk_val_t* __eval_binop_bxor (
ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right)
{
if (left->type == ASE_AWK_VAL_INT &&
right->type == ASE_AWK_VAL_INT)
{
ase_awk_val_t* res;
ase_long_t r =
((ase_awk_val_int_t*)left)->val ^
((ase_awk_val_int_t*)right)->val;
res = ase_awk_makeintval (run, r);
int n1, n2, n3;
ase_long_t l1, l2;
ase_real_t r1, r2;
ase_awk_val_t* res;
if (res == ASE_NULL)
{
run->errnum = ASE_AWK_ENOMEM;
return ASE_NULL;
}
n1 = ase_awk_valtonum (run, left, &l1, &r1);
n2 = ase_awk_valtonum (run, right, &l2, &r2);
return res;
}
if (n1 == -1 || n2 == -1) PANIC (run, ASE_AWK_EOPERAND);
run->errnum = ASE_AWK_EOPERAND;
return ASE_NULL;
n3 = n1 + (n2 << 1);
ASE_AWK_ASSERT (run->awk, n3 >= 0 && n3 <= 3);
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1^(ase_long_t)l2):
(n3 == 1)? ase_awk_makeintval(run,(ase_long_t)r1^(ase_long_t)l2):
(n3 == 2)? ase_awk_makeintval(run,(ase_long_t)l1^(ase_long_t)r2):
ase_awk_makeintval(run,(ase_long_t)r1^(ase_long_t)r2);
if (res == ASE_NULL) PANIC (run, ASE_AWK_ENOMEM);
return res;
}
static ase_awk_val_t* __eval_binop_band (
ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right)
{
if (left->type == ASE_AWK_VAL_INT &&
right->type == ASE_AWK_VAL_INT)
{
ase_awk_val_t* res;
int n1, n2, n3;
ase_long_t l1, l2;
ase_real_t r1, r2;
ase_awk_val_t* res;
ase_long_t r =
((ase_awk_val_int_t*)left)->val &
((ase_awk_val_int_t*)right)->val;
res = ase_awk_makeintval (run, r);
n1 = ase_awk_valtonum (run, left, &l1, &r1);
n2 = ase_awk_valtonum (run, right, &l2, &r2);
if (res == ASE_NULL)
{
run->errnum = ASE_AWK_ENOMEM;
return ASE_NULL;
}
if (n1 == -1 || n2 == -1) PANIC (run, ASE_AWK_EOPERAND);
return res;
}
n3 = n1 + (n2 << 1);
ASE_AWK_ASSERT (run->awk, n3 >= 0 && n3 <= 3);
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1&(ase_long_t)l2):
(n3 == 1)? ase_awk_makeintval(run,(ase_long_t)r1&(ase_long_t)l2):
(n3 == 2)? ase_awk_makeintval(run,(ase_long_t)l1&(ase_long_t)r2):
ase_awk_makeintval(run,(ase_long_t)r1&(ase_long_t)r2);
run->errnum = ASE_AWK_EOPERAND;
return ASE_NULL;
if (res == ASE_NULL) PANIC (run, ASE_AWK_ENOMEM);
return res;
}
static int __cmp_nil_nil (

View File

@ -1,10 +1,11 @@
/*
* $Id: Awk.cpp,v 1.1 2006-12-09 11:50:07 bacon Exp $
* $Id: Awk.cpp,v 1.2 2006-12-09 17:36:27 bacon Exp $
*/
#include "stdafx.h"
#include "ase.h"
#include "Awk.h"
#include "AwkExtio.h"
#include "Buffer.h"
#include <stdlib.h>
#include <string.h>
@ -28,7 +29,8 @@ STDMETHODIMP CAwk::InterfaceSupportsErrorInfo(REFIID riid)
}
CAwk::CAwk (): handle(NULL),
read_source_buf(NULL), write_source_buf(NULL)
read_source_buf(NULL), write_source_buf(NULL),
write_extio_buf(NULL)
{
#ifdef _DEBUG
TCHAR x[128];
@ -45,6 +47,11 @@ CAwk::~CAwk ()
MessageBox (NULL, x, x, MB_OK);
#endif
if (write_extio_buf != NULL)
{
write_extio_buf->Release ();
}
if (write_source_buf != NULL)
{
write_source_buf->Release ();
@ -185,11 +192,11 @@ MessageBox (NULL, _T("COCREATEINSTANCE FAILED"), _T("FUCK"), MB_OK);
if (awk->read_source_pos >= awk->read_source_len)
{
LONG n = awk->Fire_ReadSource (awk->read_source_buf);
INT n = awk->Fire_ReadSource (awk->read_source_buf);
if (n <= 0) return (ase_ssize_t)n;
awk->read_source_buf->get_Value (&val);
if (n > (LONG)val.Length()) return -1;
if (n > (INT)val.Length()) return -1;
awk->read_source_pos = 0;
awk->read_source_len = n;
@ -202,7 +209,7 @@ MessageBox (NULL, _T("COCREATEINSTANCE FAILED"), _T("FUCK"), MB_OK);
ASE_AWK_ASSERT (awk->handle,
awk->read_source_pos < awk->read_source_len);
LONG left = awk->read_source_len - awk->read_source_pos;
INT left = awk->read_source_len - awk->read_source_pos;
if (left > (ase_ssize_t)count)
{
memcpy (data,
@ -256,15 +263,9 @@ MessageBox (NULL, _T("COCREATEINSTANCE FAILED"), _T("FUCK"), MB_OK);
}
awk->write_source_buf->put_Value (CComBSTR(count,data));
LONG n = awk->Fire_WriteSource (awk->write_source_buf);
/*
ASE_AWK_ASSERTX (
awk->handle, n <= (LONG)count,
"the source code output stream should not return more than requested");
*/
if (n > (LONG)count) return -1;
INT n = awk->Fire_WriteSource (awk->write_source_buf);
if (n > (INT)count) return -1;
return (ase_ssize_t)n;
}
@ -333,7 +334,6 @@ HRESULT CAwk::Parse (int* ret)
srcios.out = __write_source;
srcios.custom_data = this;
if (ase_awk_parse (handle, &srcios) == -1)
{
*ret = -1;
@ -352,19 +352,83 @@ static ase_ssize_t __process_extio (
if (cmd == ASE_AWK_IO_OPEN)
{
IAwkExtio* extio;
CAwkExtio* extio2;
HRESULT hr = CoCreateInstance (
CLSID_AwkExtio, NULL, CLSCTX_ALL,
IID_IAwkExtio, (void**)&extio);
if (FAILED(hr)) return -1; /* TODO: better error handling.. */
extio2 = (CAwkExtio*)extio;
extio2->name = epa->name;
extio2->type = epa->type & 0xFF;
extio2->mode = epa->mode;
VariantClear (&extio2->handle);
INT n = awk->Fire_OpenExtio (extio);
if (n >= 0)
{
extio->AddRef ();
epa->handle = extio;
}
extio->Release ();
return n;
}
else if (cmd == ASE_AWK_IO_CLOSE)
{
IAwkExtio* extio = (IAwkExtio*)epa->handle;
ASE_AWK_ASSERT (ase_awk_getrunawk(epa->run), extio != NULL);
INT n = awk->Fire_CloseExtio (extio);
if (n >= 0)
{
extio->Release();
epa->handle = NULL;
}
return n;
}
else if (cmd == ASE_AWK_IO_READ)
{
/*
IAwkExtio* extio = (IAwkExtio*)epa->handle;
ASE_AWK_ASSERT (ase_awk_getrunawk(epa->run), extio != NULL);
if (awk->write_extio_buf == NULL)
{
HRESULT hr = CoCreateInstance (
CLSID_Buffer, NULL, CLSCTX_ALL,
IID_IBuffer, (void**)&awk->write_extio_buf);
if (FAILED(hr)) return -1;
}
INT n = awk->Fire_ReadExtio (extio, awk->write_extio_buf);
if (n > (INT)size) return -1;
return (ase_ssize_t)n;
*/
}
else if (cmd == ASE_AWK_IO_WRITE)
{
IAwkExtio* extio = (IAwkExtio*)epa->handle;
ASE_AWK_ASSERT (ase_awk_getrunawk(epa->run), extio != NULL);
if (awk->write_extio_buf == NULL)
{
HRESULT hr = CoCreateInstance (
CLSID_Buffer, NULL, CLSCTX_ALL,
IID_IBuffer, (void**)&awk->write_extio_buf);
if (FAILED(hr)) return -1;
}
awk->write_extio_buf->put_Value (CComBSTR(size,data));
INT n = awk->Fire_WriteExtio (extio, awk->write_extio_buf);
if (n > (INT)size) return -1;
return (ase_ssize_t)n;
}
else if (cmd == ASE_AWK_IO_FLUSH)
{
return 1;
}
else if (cmd == ASE_AWK_IO_NEXT)
{
@ -384,14 +448,16 @@ HRESULT CAwk::Run (int* ret)
}
ase_awk_runios_t runios;
runios.pipe = __process_extio;
runios.pipe = NULL;
runios.coproc = NULL;
runios.file = NULL;
runios.console = NULL;
runios.console = __process_extio;
runios.custom_data = this;
if (ase_awk_run (handle, NULL, &runios, NULL, NULL, this) == -1)
{
int err = ase_awk_geterrnum (handle);
MessageBox (NULL, ase_awk_geterrstr(err), ase_awk_geterrstr(err), MB_OK);
*ret = -1;
return S_OK;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.h,v 1.1 2006-12-09 11:50:07 bacon Exp $
* $Id: Awk.h,v 1.2 2006-12-09 17:36:27 bacon Exp $
*/
#ifndef _ASE_COM_AWK_H_
@ -30,12 +30,13 @@ class CAwk :
{
public:
ase_awk_t* handle;
IBuffer* read_source_buf;
IBuffer* write_source_buf;
ase_size_t read_source_pos;
ase_size_t read_source_len;
IBuffer* write_extio_buf;
public:
CAwk();
~CAwk ();

View File

@ -1,20 +1,31 @@
/*
* $Id: AwkExtio.cpp,v 1.1 2006-12-09 11:50:08 bacon Exp $
* $Id: AwkExtio.cpp,v 1.2 2006-12-09 17:36:27 bacon Exp $
*/
#include "stdafx.h"
#include "ase.h"
#include "AwkExtio.h"
#include <stdio.h>
/////////////////////////////////////////////////////////////////////////////
// CAwkExtio
CAwkExtio::CAwkExtio ()
{
#ifdef _DEBUG
TCHAR x[128];
_sntprintf (x, 128, _T("CAwkExtio::CAwkExtio %p"), this);
MessageBox (NULL, x, x, MB_OK);
#endif
}
CAwkExtio::~CAwkExtio ()
{
#ifdef _DEBUG
TCHAR x[128];
_sntprintf (x, 128, _T("CAwkExtio::~CAwkExtio %p"), this);
MessageBox (NULL, x, x, MB_OK);
#endif
}
STDMETHODIMP CAwkExtio::get_Name(BSTR *pVal)
@ -24,24 +35,12 @@ STDMETHODIMP CAwkExtio::get_Name(BSTR *pVal)
return S_OK;
}
STDMETHODIMP CAwkExtio::put_Name(BSTR newVal)
{
name = newVal;
return S_OK;
}
STDMETHODIMP CAwkExtio::get_Type(int *pVal)
{
*pVal = type;
return S_OK;
}
STDMETHODIMP CAwkExtio::put_Type(int newVal)
{
type = newVal;
return S_OK;
}
STDMETHODIMP CAwkExtio::get_Mode(int *pVal)
{
// TODO: Add your implementation code here
@ -49,9 +48,3 @@ STDMETHODIMP CAwkExtio::get_Mode(int *pVal)
return S_OK;
}
STDMETHODIMP CAwkExtio::put_Mode(int newVal)
{
// TODO: Add your implementation code here
return S_OK;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: AwkExtio.h,v 1.2 2006-12-09 12:01:26 bacon Exp $
* $Id: AwkExtio.h,v 1.3 2006-12-09 17:36:27 bacon Exp $
*/
#ifndef _ASE_COM_AWKEXTIO_H_
@ -18,6 +18,7 @@ public:
CComBSTR name;
int type;
int mode;
CComVariant handle;
CAwkExtio ();
~CAwkExtio ();
@ -34,11 +35,8 @@ END_COM_MAP()
// IAwkExtio
public:
STDMETHOD(get_Mode)(/*[out, retval]*/ int *pVal);
STDMETHOD(put_Mode)(/*[in]*/ int newVal);
STDMETHOD(get_Type)(/*[out, retval]*/ int *pVal);
STDMETHOD(put_Type)(/*[in]*/ int newVal);
STDMETHOD(get_Name)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Name)(/*[in]*/ BSTR newVal);
};
#endif //__AWKEXTIO_H_

View File

@ -1,5 +1,5 @@
/*
* $Id: Buffer.cpp,v 1.1 2006-12-09 11:50:08 bacon Exp $
* $Id: Buffer.cpp,v 1.2 2006-12-09 17:36:27 bacon Exp $
*/
#include "stdafx.h"
@ -9,7 +9,7 @@ CBuffer::CBuffer ()
{
#ifdef _DEBUG
TCHAR x[128];
_sntprintf (x, 128, _T("CBuffer::~CBuffer %p"), this);
_sntprintf (x, 128, _T("CBuffer::CBuffer %p"), this);
MessageBox (NULL, x, x, MB_OK);
#endif
}

View File

@ -51,7 +51,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo /o"debug/win32/vs60/ase.bsc"
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 aseawk.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"../debug/win32/vs60/ase.dll" /implib:"debug/win32/vs60/ase.lib" /pdbtype:sept /libpath:"$(OutDir)"
# ADD LINK32 aseawk.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /implib:"debug/win32/vs60/ase.lib" /pdbtype:sept /libpath:"$(OutDir)"
# Begin Custom Build - Performing registration
IntDir=.\debug/win32/vs60
OutDir=.\../debug/win32/vs60
@ -94,7 +94,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo /o"release/win32/vs60/awk.bsc"
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 aseawk.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"../release/win32/vs60/ase.dll" /implib:"release/win32/vs60/ase.lib" /libpath:"$(OutDir)"
# ADD LINK32 aseawk.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /implib:"release/win32/vs60/ase.lib" /libpath:"$(OutDir)"
# Begin Custom Build - Performing registration
IntDir=.\release/win32/vs60
OutDir=.\../release/win32/vs60
@ -186,6 +186,10 @@ SOURCE=.\resource.h
SOURCE=.\stdafx.h
# End Source File
# Begin Source File
SOURCE=.\xxx.h
# End Source File
# End Group
# Begin Group "Resource Files"

View File

@ -1,5 +1,5 @@
/*
* $Id: ase.idl,v 1.1 2006-12-09 11:50:08 bacon Exp $
* $Id: ase.idl,v 1.2 2006-12-09 17:36:27 bacon Exp $
*/
import "oaidl.idl";
@ -33,7 +33,6 @@ library ASELib
importlib("stdole32.tlb");
importlib("stdole2.tlb");
/* IBuffer */
[
object,
@ -51,28 +50,6 @@ library ASELib
HRESULT Value([in] BSTR newVal);
};
/* IAwkEvents */
[
uuid(1351DC8F-10AD-4C40-A2FA-9A2E89C27AC8),
helpstring("ASE Awk Events Interface")
]
dispinterface IAwkEvents
{
properties:
methods:
[id(1), helpstring("method OpenSource")]
int OpenSource([in] int mode);
[id(2), helpstring("method CloseSource")]
int CloseSource([in] int mode);
[id(3), helpstring("method ReadSource")]
int ReadSource([in] IBuffer* buf);
[id(4), helpstring("method WriteSource")]
int WriteSource([in] IBuffer* buf);
};
/* IAwkExtio */
[
object,
@ -86,20 +63,45 @@ library ASELib
[propget, id(1), helpstring("property Name")]
HRESULT Name([out, retval] BSTR *pVal);
/*[propput, id(1), helpstring("property Name")]
HRESULT Value([in] BSTR newVal); */
[propget, id(2), helpstring("property Type")]
HRESULT Type([out, retval] int *pVal);
/*[propput, id(2), helpstring("property Type")]
HRESULT Type([in] int newVal);*/
[propget, id(3), helpstring("property Mode")]
HRESULT Mode([out, retval] int *pVal);
};
/*[propput, id(3), helpstring("property Mode")]
HRESULT Mode([in] int newVal);*/
/* IAwkEvents */
[
uuid(1351DC8F-10AD-4C40-A2FA-9A2E89C27AC8),
helpstring("ASE Awk Events Interface")
]
dispinterface IAwkEvents
{
properties:
methods:
[id(1), helpstring("open the source code")]
int OpenSource([in] int mode);
[id(2), helpstring("close the source code")]
int CloseSource([in] int mode);
[id(3), helpstring("read the source code")]
int ReadSource([in] IBuffer* buf);
[id(4), helpstring("write the source code")]
int WriteSource([in] IBuffer* buf);
[id(5), helpstring("method OpenExtio")]
int OpenExtio([in] IAwkExtio* extio);
[id(6), helpstring("method CloseExtio")]
int CloseExtio([in] IAwkExtio* extio);
[id(7), helpstring("method ReadExtio")]
int ReadExtio([in] IAwkExtio* extio, [in] IBuffer* buf);
[id(8), helpstring("method WriteExtio")]
int WriteExtio([in] IAwkExtio* extio, [in] IBuffer* buf);
};
/* Awk */

View File

@ -1,5 +1,5 @@
/*
* $Id: awk_cp.h,v 1.2 2006-12-09 12:09:42 bacon Exp $
* $Id: awk_cp.h,v 1.3 2006-12-09 17:36:27 bacon Exp $
*/
#ifndef _AWK_CP_H_
@ -11,7 +11,7 @@ template <class T>
class CProxyIAwkEvents : public IConnectionPointImpl<T, &DIID_IAwkEvents, CComDynamicUnkArray>
{
public:
LONG Fire_OpenSource(LONG mode)
INT Fire_OpenSource(INT mode)
{
T* pT = static_cast<T*>(this);
int i, nconns = m_vec.GetSize();
@ -58,7 +58,7 @@ public:
return -1;
}
LONG Fire_CloseSource(LONG mode)
INT Fire_CloseSource(INT mode)
{
T* pT = static_cast<T*>(this);
int i, nconns = m_vec.GetSize();
@ -74,7 +74,6 @@ public:
reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch == NULL) continue;
VariantClear (&ret);
VariantClear (&args[0]);
@ -106,7 +105,7 @@ public:
return -1;
}
LONG Fire_ReadSource (IBuffer* buf)
INT Fire_ReadSource (IBuffer* buf)
{
T* pT = static_cast<T*>(this);
int i, nconns = m_vec.GetSize();
@ -158,7 +157,7 @@ public:
return -1;
}
LONG Fire_WriteSource (IBuffer* buf)
INT Fire_WriteSource (IBuffer* buf)
{
T* pT = static_cast<T*>(this);
int i, nconns = m_vec.GetSize();
@ -212,6 +211,152 @@ public:
buf->get_Value (&bstr);
return bstr.Length();
}
INT Fire_OpenExtio (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 (
0x5, 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_CloseExtio (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 (
0x6, 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)
{
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 (
0x8, 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

@ -19,7 +19,7 @@ function awk_ReadSource (buf)
WScript.echo ("ReadSource - buf: [" + buf.Value + "]");
if (first)
{
buf.Value = "BEGIN {print 1; print 2; print 3 > \"x\";}"
buf.Value = "BEGIN {print 1; print 2;}"
first = false
return buf.Value.length;
}
@ -33,6 +33,24 @@ function awk_WriteSource (buf)
return buf.Value.length;
}
function awk_OpenExtio (extio)
{
WScript.echo ("OpenExtio - type: " + extio.Type + " mode: " + extio.Mode + " name: [" + extio.Name + "]");
return 1;
}
function awk_CloseExtio (extio)
{
WScript.echo ("CloseExtio");
return 0;
}
function awk_WriteExtio (extio, buf)
{
WScript.echo (buf.Value);
return buf.Value.length;
}
awk = WScript.CreateObject("ASE.Awk");
WScript.ConnectObject (awk, "awk_");