Recovered from cvs revision 2007-06-30 03:05:00

This commit is contained in:
2007-07-02 23:04:00 +00:00
parent 26a9dfe8f4
commit 8064c884fb
11 changed files with 300 additions and 173 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.4 2007/06/27 15:27:21 bacon Exp $
* $Id: Awk.cpp,v 1.5 2007/06/29 11:24:27 bacon Exp $
*
* {License}
*/
@ -47,6 +47,7 @@ CAwk::CAwk ():
write_src_buf (NULL),
write_extio_buf (NULL),
bfn_list (NULL),
word_list (NULL),
entry_point (NULL),
debug (FALSE),
use_longlong (FALSE)
@ -74,11 +75,16 @@ CAwk::CAwk ():
CAwk::~CAwk ()
{
while (word_list != NULL)
{
word_t* next = word_list->next;
free (word_list);
word_list = next;
}
while (bfn_list != NULL)
{
bfn_t* next = bfn_list->next;
free (bfn_list->name.ptr);
free (bfn_list);
bfn_list = next;
}
@ -566,6 +572,25 @@ HRESULT CAwk::Parse (VARIANT_BOOL* ret)
}
}
ase_awk_setword (handle, NULL, 0, NULL, 0);
for (word_t* word = word_list; word != NULL; word = word->next)
{
if (ase_awk_setword (handle,
word->ow.ptr, word->ow.len,
word->nw.ptr, word->nw.len) == -1)
{
const ase_char_t* msg;
DBGOUT (_T("cannot set the word"));
ase_awk_geterror (handle, &errnum, &errlin, &msg);
ase_strxcpy (errmsg, ASE_COUNTOF(errmsg), msg);
*ret = VARIANT_FALSE;
return S_OK;
}
}
ase_awk_srcios_t srcios;
srcios.in = __read_source;
@ -906,7 +931,7 @@ STDMETHODIMP CAwk::AddFunction (
}
}
bfn = (bfn_t*)malloc (sizeof(bfn_t));
bfn = (bfn_t*)malloc (sizeof(bfn_t) + name_len*sizeof(TCHAR));
if (bfn == NULL)
{
errnum = ASE_AWK_ENOMEM;
@ -920,20 +945,7 @@ STDMETHODIMP CAwk::AddFunction (
}
bfn->name.len = name_len;
bfn->name.ptr = (TCHAR*)malloc (bfn->name.len * sizeof(TCHAR));
if (bfn->name.ptr == NULL)
{
free (bfn);
errnum = ASE_AWK_ENOMEM;
errlin = 0;
ase_strxcpy (
errmsg, ASE_COUNTOF(errmsg),
ase_awk_geterrstr(NULL, errnum));
*ret = VARIANT_FALSE;
return S_OK;
}
bfn->name.ptr = (TCHAR*)(bfn + 1);
memcpy (bfn->name.ptr, name, sizeof(TCHAR) * bfn->name.len);
bfn->min_args = minArgs;
@ -958,7 +970,6 @@ STDMETHODIMP CAwk::DeleteFunction (BSTR name, VARIANT_BOOL* ret)
bfn->name.ptr, bfn->name.len,
name, name_len) == 0)
{
free (bfn->name.ptr);
free (bfn);
if (prev == NULL) bfn_list = next;
@ -983,12 +994,88 @@ STDMETHODIMP CAwk::DeleteFunction (BSTR name, VARIANT_BOOL* ret)
STDMETHODIMP CAwk::SetWord (BSTR ow, BSTR nw, VARIANT_BOOL* ret)
{
word_t* word;
size_t ow_len = SysStringLen(ow);
size_t nw_len = SysStringLen(nw);
// TODO:
*ret = (ase_awk_setword (handle, ow, ow_len, nw, nw_len) == -1)?
VARIANT_FALSE: VARIANT_TRUE;
for (word = word_list; word != NULL; word = word->next)
{
if (ase_strxncmp (
word->ow.ptr, word->ow.len,
ow, ow_len) == 0)
{
errnum = ASE_AWK_EEXIST;
errlin = 0;
_sntprintf (
errmsg, ASE_COUNTOF(errmsg),
_T("'%.*s' added already"),
word->ow.len, word->ow.ptr);
*ret = VARIANT_FALSE;
return S_OK;
}
}
word = (word_t*)malloc (sizeof(word_t)+(ow_len+nw_len)*sizeof(TCHAR));
if (word == NULL)
{
errnum = ASE_AWK_ENOMEM;
errlin = 0;
ase_strxcpy (
errmsg, ASE_COUNTOF(errmsg),
ase_awk_geterrstr(NULL, errnum));
*ret = VARIANT_FALSE;
return S_OK;
}
word->ow.len = ow_len;
word->ow.ptr = (TCHAR*)(word+1);
word->nw.len = nw_len;
word->nw.ptr = word->ow.ptr + word->ow.len;
memcpy (word->ow.ptr, ow, sizeof(TCHAR)*word->ow.len);
memcpy (word->nw.ptr, nw, sizeof(TCHAR)*word->nw.len);
word->next = word_list;
word_list = word;
*ret = VARIANT_TRUE;
return S_OK;
}
STDMETHODIMP CAwk::UnsetWord (BSTR ow, VARIANT_BOOL* ret)
{
size_t ow_len = SysStringLen(ow);
word_t* word, * next, * prev = NULL;
for (word = word_list; word != NULL; word = next)
{
next = word->next;
if (ase_strxncmp (
word->ow.ptr, word->ow.len,
ow, ow_len) == 0)
{
free (word);
if (prev == NULL) word_list = next;
else prev->next = next;
*ret = VARIANT_TRUE;
return S_OK;
}
prev = word;
}
errnum = ASE_AWK_ENOENT;
errlin = 0;
ase_strxcpy (
errmsg, ASE_COUNTOF(errmsg),
ase_awk_geterrstr(NULL, errnum));
*ret = VARIANT_FALSE;
return S_OK;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.h,v 1.4 2007/06/27 15:27:21 bacon Exp $
* $Id: Awk.h,v 1.5 2007/06/29 11:24:27 bacon Exp $
*
* {License}
*/
@ -76,6 +76,23 @@ public:
struct bfn_t* next;
} * bfn_list;
struct word_t
{
struct
{
TCHAR* ptr;
size_t len;
} ow;
struct
{
TCHAR* ptr;
size_t len;
} nw;
struct word_t* next;
} * word_list;
BSTR entry_point;
VARIANT_BOOL debug;
VARIANT_BOOL use_longlong;
@ -156,6 +173,8 @@ public:
STDMETHOD(get_ErrorLine)(/*[out, retval]*/ int *pVal);
STDMETHOD(get_ErrorCode)(/*[out, retval]*/ int *pVal);
HRESULT __stdcall UnsetWord (
/*[in]*/ BSTR ow, /*[out, retval]*/ VARIANT_BOOL* ret);
HRESULT __stdcall SetWord (
/*[in]*/ BSTR ow, /*[in]*/ BSTR nw, /*[out, retval]*/ VARIANT_BOOL* ret);

View File

@ -1,5 +1,5 @@
/*
* $Id: asecom.idl,v 1.4 2007/06/27 15:27:21 bacon Exp $
* $Id: asecom.idl,v 1.5 2007/06/29 11:24:27 bacon Exp $
*/
import "oaidl.idl";
@ -30,128 +30,131 @@ interface IAwk : IDispatch
[id(5), helpstring("method SetWord")]
HRESULT SetWord([in] BSTR ow, [in] BSTR nw, [out,retval] VARIANT_BOOL* ret);
[propget, id(6), helpstring("property ErrorCode")]
[id(6), helpstring("method UnsetWord")]
HRESULT UnsetWord([in] BSTR ow, [out,retval] VARIANT_BOOL* ret);
[propget, id(7), helpstring("property ErrorCode")]
HRESULT ErrorCode([out,retval] int *pVal);
[propget, id(7), helpstring("property ErrorLine")]
[propget, id(8), helpstring("property ErrorLine")]
HRESULT ErrorLine([out,retval] int *pVal);
[propget, id(8), helpstring("property ErrorMessage")]
[propget, id(9), helpstring("property ErrorMessage")]
HRESULT ErrorMessage([out,retval] BSTR *pVal);
[propget, id(9), helpstring("property ImplicitVariable")]
[propget, id(10), helpstring("property ImplicitVariable")]
HRESULT ImplicitVariable([out,retval] VARIANT_BOOL *pVal);
[propput, id(9), helpstring("property ImplicitVariable")]
[propput, id(10), helpstring("property ImplicitVariable")]
HRESULT ImplicitVariable([in] VARIANT_BOOL newVal);
[propget, id(10), helpstring("property ExplicitVariable")]
[propget, id(11), helpstring("property ExplicitVariable")]
HRESULT ExplicitVariable([out,retval] VARIANT_BOOL *pVal);
[propput, id(10), helpstring("property ExplicitVariable")]
[propput, id(11), helpstring("property ExplicitVariable")]
HRESULT ExplicitVariable([in] VARIANT_BOOL newVal);
[propget, id(11), helpstring("property UniqueFunction")]
[propget, id(12), helpstring("property UniqueFunction")]
HRESULT UniqueFunction([out,retval] VARIANT_BOOL *pVal);
[propput, id(11), helpstring("property UniqueFunction")]
[propput, id(12), helpstring("property UniqueFunction")]
HRESULT UniqueFunction([in] VARIANT_BOOL newVal);
[propget, id(12), helpstring("property VariableShading")]
[propget, id(13), helpstring("property VariableShading")]
HRESULT VariableShading([out,retval] VARIANT_BOOL *pVal);
[propput, id(12), helpstring("property VariableShading")]
[propput, id(13), helpstring("property VariableShading")]
HRESULT VariableShading([in] VARIANT_BOOL newVal);
[propget, id(13), helpstring("property ShiftOperators")]
[propget, id(14), helpstring("property ShiftOperators")]
HRESULT ShiftOperators([out,retval] VARIANT_BOOL *pVal);
[propput, id(13), helpstring("property ShiftOperators")]
[propput, id(14), helpstring("property ShiftOperators")]
HRESULT ShiftOperators([in] VARIANT_BOOL newVal);
[propget, id(14), helpstring("property IdivOperator")]
[propget, id(15), helpstring("property IdivOperator")]
HRESULT IdivOperator([out,retval] VARIANT_BOOL *pVal);
[propput, id(14), helpstring("property IdivOperator")]
[propput, id(15), helpstring("property IdivOperator")]
HRESULT IdivOperator([in] VARIANT_BOOL newVal);
[propget, id(15), helpstring("property ConcatString")]
[propget, id(16), helpstring("property ConcatString")]
HRESULT ConcatString([out,retval] VARIANT_BOOL *pVal);
[propput, id(15), helpstring("property ConcatString")]
[propput, id(16), helpstring("property ConcatString")]
HRESULT ConcatString([in] VARIANT_BOOL newVal);
[propget, id(16), helpstring("property SupportExtio")]
[propget, id(17), helpstring("property SupportExtio")]
HRESULT SupportExtio([out,retval] VARIANT_BOOL *pVal);
[propput, id(16), helpstring("property SupportExtio")]
[propput, id(17), helpstring("property SupportExtio")]
HRESULT SupportExtio([in] VARIANT_BOOL newVal);
[propget, id(17), helpstring("property SupportBlockless")]
[propget, id(18), helpstring("property SupportBlockless")]
HRESULT SupportBlockless([out,retval] VARIANT_BOOL *pVal);
[propput, id(17), helpstring("property SupportBlockless")]
[propput, id(18), helpstring("property SupportBlockless")]
HRESULT SupportBlockless([in] VARIANT_BOOL newVal);
[propget, id(18), helpstring("property StringBaseOne")]
[propget, id(19), helpstring("property StringBaseOne")]
HRESULT StringBaseOne([out,retval] VARIANT_BOOL *pVal);
[propput, id(18), helpstring("property StringBaseOne")]
[propput, id(19), helpstring("property StringBaseOne")]
HRESULT StringBaseOne([in] VARIANT_BOOL newVal);
[propget, id(19), helpstring("property StripSpaces")]
[propget, id(20), helpstring("property StripSpaces")]
HRESULT StripSpaces([out,retval] VARIANT_BOOL *pVal);
[propput, id(19), helpstring("property StripSpaces")]
[propput, id(20), helpstring("property StripSpaces")]
HRESULT StripSpaces([in] VARIANT_BOOL newVal);
[propget, id(20), helpstring("property Nextofile")]
[propget, id(21), helpstring("property Nextofile")]
HRESULT Nextofile([out,retval] VARIANT_BOOL *pVal);
[propput, id(20), helpstring("property Nextofile")]
[propput, id(21), helpstring("property Nextofile")]
HRESULT Nextofile([in] VARIANT_BOOL newVal);
[propget, id(21), helpstring("property UseCrlf")]
[propget, id(22), helpstring("property UseCrlf")]
HRESULT UseCrlf([out,retval] VARIANT_BOOL *pVal);
[propput, id(21), helpstring("property UseCrlf")]
[propput, id(22), helpstring("property UseCrlf")]
HRESULT UseCrlf([in] VARIANT_BOOL newVal);
[propget, id(22), helpstring("property ArgumentsToEntryPoint")]
[propget, id(23), helpstring("property ArgumentsToEntryPoint")]
HRESULT ArgumentsToEntryPoint([out,retval] VARIANT_BOOL *pVal);
[propput, id(22), helpstring("property ArgumentsToEntryPoint")]
[propput, id(23), helpstring("property ArgumentsToEntryPoint")]
HRESULT ArgumentsToEntryPoint([in] VARIANT_BOOL newVal);
[propget, id(23), helpstring("property MaxDepthForBlockParse")]
[propget, id(24), helpstring("property MaxDepthForBlockParse")]
HRESULT MaxDepthForBlockParse([out,retval] int *pVal);
[propput, id(23), helpstring("property MaxDepthForBlockParse")]
[propput, id(24), helpstring("property MaxDepthForBlockParse")]
HRESULT MaxDepthForBlockParse([in] int newVal);
[propget, id(24), helpstring("property MaxDepthForBlockRun")]
[propget, id(25), helpstring("property MaxDepthForBlockRun")]
HRESULT MaxDepthForBlockRun([out,retval] int *pVal);
[propput, id(24), helpstring("property MaxDepthForBlockRun")]
[propput, id(25), helpstring("property MaxDepthForBlockRun")]
HRESULT MaxDepthForBlockRun([in] int newVal);
[propget, id(25), helpstring("property MaxDepthForExprParse")]
[propget, id(26), helpstring("property MaxDepthForExprParse")]
HRESULT MaxDepthForExprParse([out,retval] int *pVal);
[propput, id(25), helpstring("property MaxDepthForExprParse")]
[propput, id(26), helpstring("property MaxDepthForExprParse")]
HRESULT MaxDepthForExprParse([in] int newVal);
[propget, id(26), helpstring("property MaxDepthForExprRun")]
[propget, id(27), helpstring("property MaxDepthForExprRun")]
HRESULT MaxDepthForExprRun([out,retval] int *pVal);
[propput, id(26), helpstring("property MaxDepthForExprRun")]
[propput, id(27), helpstring("property MaxDepthForExprRun")]
HRESULT MaxDepthForExprRun([in] int newVal);
[propget, id(27), helpstring("property MaxDepthForRexBuild")]
[propget, id(28), helpstring("property MaxDepthForRexBuild")]
HRESULT MaxDepthForRexBuild([out,retval] int *pVal);
[propput, id(27), helpstring("property MaxDepthForRexBuild")]
[propput, id(28), helpstring("property MaxDepthForRexBuild")]
HRESULT MaxDepthForRexBuild([in] int newVal);
[propget, id(28), helpstring("property MaxDepthForRexMatch")]
[propget, id(29), helpstring("property MaxDepthForRexMatch")]
HRESULT MaxDepthForRexMatch([out,retval] int *pVal);
[propput, id(28), helpstring("property MaxDepthForRexMatch")]
[propput, id(29), helpstring("property MaxDepthForRexMatch")]
HRESULT MaxDepthForRexMatch([in] int newVal);
[propget, id(29), helpstring("property EntryPoint")]
[propget, id(30), helpstring("property EntryPoint")]
HRESULT EntryPoint([out,retval] BSTR *pVal);
[propput, id(29), helpstring("property EntryPoint")]
[propput, id(30), helpstring("property EntryPoint")]
HRESULT EntryPoint([in] BSTR newVal);
[propget, id(30), helpstring("property Debug")]
[propget, id(31), helpstring("property Debug")]
HRESULT Debug([out,retval] VARIANT_BOOL *pVal);
[propput, id(30), helpstring("property Debug")]
[propput, id(31), helpstring("property Debug")]
HRESULT Debug([in] VARIANT_BOOL newVal);
[propget, id(31), helpstring("property UseLongLong")]
[propget, id(32), helpstring("property UseLongLong")]
HRESULT UseLongLong([out,retval] VARIANT_BOOL *pVal);
[propput, id(31), helpstring("property UseLongLong")]
[propput, id(32), helpstring("property UseLongLong")]
HRESULT UseLongLong([in] VARIANT_BOOL newVal);
};