*** empty log message ***

This commit is contained in:
hyung-hwan 2007-01-17 14:09:49 +00:00
parent ed0520bc4e
commit 22c923a5d4
5 changed files with 119 additions and 58 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.20 2007-01-17 03:45:59 bacon Exp $
* $Id: Awk.cpp,v 1.21 2007-01-17 14:09:49 bacon Exp $
*/
#include "stdafx.h"
@ -337,7 +337,7 @@ static int __handle_bfn (
}
else if (v->type == ASE_AWK_VAL_NIL)
{
arg.vt = VT_EMPTY;
arg.vt = VT_NULL;
}
HRESULT hr = SafeArrayPutElement (aa, &i, &arg);
@ -722,7 +722,6 @@ HRESULT CAwk::Run (int* ret)
return S_OK;
}
STDMETHODIMP CAwk::AddBuiltinFunction (
BSTR name, int min_args, int max_args, int* ret)
{
@ -786,6 +785,42 @@ STDMETHODIMP CAwk::AddBuiltinFunction (
return S_OK;
}
STDMETHODIMP CAwk::DeleteBuiltinFunction (BSTR name, int* ret)
{
size_t name_len = SysStringLen(name);
bfn_t* bfn, * next, * prev = NULL;
for (bfn = bfn_list; bfn != NULL; bfn = next)
{
next = bfn->next;
if (ase_awk_strxncmp (
bfn->name.ptr, bfn->name.len,
name, name_len) == 0)
{
free (bfn->name.ptr);
free (bfn);
if (prev == NULL) bfn_list = next;
else prev->next = next;
*ret = 0;
return S_OK;
}
prev = bfn;
}
errnum = ASE_AWK_ENOENT;
errlin = 0;
ase_awk_strxcpy (
errmsg, ASE_COUNTOF(errmsg),
ase_awk_geterrstr(errnum));
*ret = -1;
return S_OK;
}
STDMETHODIMP CAwk::get_ErrorCode(int *pVal)
{
*pVal = errnum;

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.h,v 1.13 2007-01-16 14:20:43 bacon Exp $
* $Id: Awk.h,v 1.14 2007-01-17 14:09:49 bacon Exp $
*/
#ifndef _ASE_COM_AWK_H_
@ -150,10 +150,11 @@ public:
STDMETHOD(get_ErrorMessage)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(get_ErrorLine)(/*[out, retval]*/ int *pVal);
STDMETHOD(get_ErrorCode)(/*[out, retval]*/ int *pVal);
STDMETHOD(DeleteBuiltinFunction)(/*[in]*/ BSTR name, /*[out, retval]*/ int* ret);
STDMETHOD(AddBuiltinFunction)(/*[in]*/ BSTR name, /*[in]*/ int min_args, /*[in]*/ int max_args, /*[out, retval]*/ int* ret);
STDMETHOD(get_UseLongLong)(/*[out, retval]*/ BOOL *pVal);
HRESULT __stdcall Parse (int* ret);
HRESULT __stdcall Run (int* ret);
HRESULT __stdcall Parse (/*[out, retval]*/ int* ret);
HRESULT __stdcall Run (/*[out, retval]*/ int* ret);
};
#endif

View File

@ -1,5 +1,5 @@
/*
* $Id: ase.idl,v 1.14 2007-01-16 14:20:43 bacon Exp $
* $Id: ase.idl,v 1.15 2007-01-17 14:09:49 bacon Exp $
*/
import "oaidl.idl";
@ -24,123 +24,126 @@ interface IAwk : IDispatch
[id(3), helpstring("method AddBuiltinFunction")]
HRESULT AddBuiltinFunction([in] BSTR name, [in] int min_args, [in] int max_args, [out, retval] int* ret);
[propget, id(4), helpstring("property ErrorCode")]
[id(4), helpstring("method DeleteBuiltinFunction")]
HRESULT DeleteBuiltinFunction([in] BSTR name, [out, retval] int* ret);
[propget, id(5), helpstring("property ErrorCode")]
HRESULT ErrorCode([out, retval] int *pVal);
[propget, id(5), helpstring("property ErrorLine")]
[propget, id(6), helpstring("property ErrorLine")]
HRESULT ErrorLine([out, retval] int *pVal);
[propget, id(6), helpstring("property ErrorMessage")]
[propget, id(7), helpstring("property ErrorMessage")]
HRESULT ErrorMessage([out, retval] BSTR *pVal);
[propget, id(7), helpstring("property ImplicitVariable")]
[propget, id(8), helpstring("property ImplicitVariable")]
HRESULT ImplicitVariable([out, retval] BOOL *pVal);
[propput, id(7), helpstring("property ImplicitVariable")]
[propput, id(8), helpstring("property ImplicitVariable")]
HRESULT ImplicitVariable([in] BOOL newVal);
[propget, id(8), helpstring("property ExplicitVariable")]
[propget, id(9), helpstring("property ExplicitVariable")]
HRESULT ExplicitVariable([out, retval] BOOL *pVal);
[propput, id(8), helpstring("property ExplicitVariable")]
[propput, id(9), helpstring("property ExplicitVariable")]
HRESULT ExplicitVariable([in] BOOL newVal);
[propget, id(9), helpstring("property UniqueFunction")]
[propget, id(10), helpstring("property UniqueFunction")]
HRESULT UniqueFunction([out, retval] BOOL *pVal);
[propput, id(9), helpstring("property UniqueFunction")]
[propput, id(10), helpstring("property UniqueFunction")]
HRESULT UniqueFunction([in] BOOL newVal);
[propget, id(10), helpstring("property VariableShading")]
[propget, id(11), helpstring("property VariableShading")]
HRESULT VariableShading([out, retval] BOOL *pVal);
[propput, id(10), helpstring("property VariableShading")]
[propput, id(11), helpstring("property VariableShading")]
HRESULT VariableShading([in] BOOL newVal);
[propget, id(11), helpstring("property ShiftOperators")]
[propget, id(12), helpstring("property ShiftOperators")]
HRESULT ShiftOperators([out, retval] BOOL *pVal);
[propput, id(11), helpstring("property ShiftOperators")]
[propput, id(12), helpstring("property ShiftOperators")]
HRESULT ShiftOperators([in] BOOL newVal);
[propget, id(12), helpstring("property IdivOperator")]
[propget, id(13), helpstring("property IdivOperator")]
HRESULT IdivOperator([out, retval] BOOL *pVal);
[propput, id(12), helpstring("property IdivOperator")]
[propput, id(13), helpstring("property IdivOperator")]
HRESULT IdivOperator([in] BOOL newVal);
[propget, id(13), helpstring("property ConcatString")]
[propget, id(14), helpstring("property ConcatString")]
HRESULT ConcatString([out, retval] BOOL *pVal);
[propput, id(13), helpstring("property ConcatString")]
[propput, id(14), helpstring("property ConcatString")]
HRESULT ConcatString([in] BOOL newVal);
[propget, id(14), helpstring("property SupportExtio")]
[propget, id(15), helpstring("property SupportExtio")]
HRESULT SupportExtio([out, retval] BOOL *pVal);
[propput, id(14), helpstring("property SupportExtio")]
[propput, id(15), helpstring("property SupportExtio")]
HRESULT SupportExtio([in] BOOL newVal);
[propget, id(15), helpstring("property SupportBlockless")]
[propget, id(16), helpstring("property SupportBlockless")]
HRESULT SupportBlockless([out, retval] BOOL *pVal);
[propput, id(15), helpstring("property SupportBlockless")]
[propput, id(16), helpstring("property SupportBlockless")]
HRESULT SupportBlockless([in] BOOL newVal);
[propget, id(16), helpstring("property StringIndexOne")]
[propget, id(17), helpstring("property StringIndexOne")]
HRESULT StringIndexOne([out, retval] BOOL *pVal);
[propput, id(16), helpstring("property StringIndexOne")]
[propput, id(17), helpstring("property StringIndexOne")]
HRESULT StringIndexOne([in] BOOL newVal);
[propget, id(17), helpstring("property StripSpaces")]
[propget, id(18), helpstring("property StripSpaces")]
HRESULT StripSpaces([out, retval] BOOL *pVal);
[propput, id(17), helpstring("property StripSpaces")]
[propput, id(18), helpstring("property StripSpaces")]
HRESULT StripSpaces([in] BOOL newVal);
[propget, id(18), helpstring("property Nextofile")]
[propget, id(19), helpstring("property Nextofile")]
HRESULT Nextofile([out, retval] BOOL *pVal);
[propput, id(18), helpstring("property Nextofile")]
[propput, id(19), helpstring("property Nextofile")]
HRESULT Nextofile([in] BOOL newVal);
[propget, id(19), helpstring("property UseCrlf")]
[propget, id(20), helpstring("property UseCrlf")]
HRESULT UseCrlf([out, retval] BOOL *pVal);
[propput, id(19), helpstring("property UseCrlf")]
[propput, id(20), helpstring("property UseCrlf")]
HRESULT UseCrlf([in] BOOL newVal);
[propget, id(20), helpstring("property MaxDepthForBlockParse")]
[propget, id(21), helpstring("property MaxDepthForBlockParse")]
HRESULT MaxDepthForBlockParse([out, retval] int *pVal);
[propput, id(20), helpstring("property MaxDepthForBlockParse")]
[propput, id(21), helpstring("property MaxDepthForBlockParse")]
HRESULT MaxDepthForBlockParse([in] int newVal);
[propget, id(21), helpstring("property MaxDepthForBlockRun")]
[propget, id(22), helpstring("property MaxDepthForBlockRun")]
HRESULT MaxDepthForBlockRun([out, retval] int *pVal);
[propput, id(21), helpstring("property MaxDepthForBlockRun")]
[propput, id(22), helpstring("property MaxDepthForBlockRun")]
HRESULT MaxDepthForBlockRun([in] int newVal);
[propget, id(22), helpstring("property MaxDepthForExprParse")]
[propget, id(23), helpstring("property MaxDepthForExprParse")]
HRESULT MaxDepthForExprParse([out, retval] int *pVal);
[propput, id(22), helpstring("property MaxDepthForExprParse")]
[propput, id(23), helpstring("property MaxDepthForExprParse")]
HRESULT MaxDepthForExprParse([in] int newVal);
[propget, id(23), helpstring("property MaxDepthForExprRun")]
[propget, id(24), helpstring("property MaxDepthForExprRun")]
HRESULT MaxDepthForExprRun([out, retval] int *pVal);
[propput, id(23), helpstring("property MaxDepthForExprRun")]
[propput, id(24), helpstring("property MaxDepthForExprRun")]
HRESULT MaxDepthForExprRun([in] int newVal);
[propget, id(24), helpstring("property MaxDepthForRexBuild")]
[propget, id(25), helpstring("property MaxDepthForRexBuild")]
HRESULT MaxDepthForRexBuild([out, retval] int *pVal);
[propput, id(24), helpstring("property MaxDepthForRexBuild")]
[propput, id(25), helpstring("property MaxDepthForRexBuild")]
HRESULT MaxDepthForRexBuild([in] int newVal);
[propget, id(25), helpstring("property MaxDepthForRexMatch")]
[propget, id(26), helpstring("property MaxDepthForRexMatch")]
HRESULT MaxDepthForRexMatch([out, retval] int *pVal);
[propput, id(25), helpstring("property MaxDepthForRexMatch")]
[propput, id(26), helpstring("property MaxDepthForRexMatch")]
HRESULT MaxDepthForRexMatch([in] int newVal);
[propget, id(26), helpstring("property EntryPoint")]
[propget, id(27), helpstring("property EntryPoint")]
HRESULT EntryPoint([out, retval] BSTR *pVal);
[propput, id(26), helpstring("property EntryPoint")]
[propput, id(27), helpstring("property EntryPoint")]
HRESULT EntryPoint([in] BSTR newVal);
[propget, id(27), helpstring("property Debug")]
[propget, id(28), helpstring("property Debug")]
HRESULT Debug([out, retval] BOOL *pVal);
[propput, id(27), helpstring("property Debug")]
[propput, id(28), helpstring("property Debug")]
HRESULT Debug([in] BOOL newVal);
[propget, id(28), helpstring("property UseLongLong")]
[propget, id(29), helpstring("property UseLongLong")]
HRESULT UseLongLong([out, retval] BOOL *pVal);
[propput, id(28), helpstring("property UseLongLong")]
[propput, id(29), helpstring("property UseLongLong")]
HRESULT UseLongLong([in] BOOL newVal);
};

View File

@ -1,5 +1,5 @@
/*
* $Id: awk_cp.h,v 1.7 2007-01-16 06:09:07 bacon Exp $
* $Id: awk_cp.h,v 1.8 2007-01-17 14:09:49 bacon Exp $
*/
#ifndef _AWK_CP_H_
@ -577,6 +577,9 @@ public:
v = ase_awk_makerealval (run, ret.dblVal);
else if (ret.vt == VT_BSTR)
v = ase_awk_makestrval (run, ret.bstrVal, SysStringLen(ret.bstrVal));
else if (ret.vt == VT_NULL)
v = ase_awk_val_nil;
else return 3; /* wrong return value */
if (v == ASE_NULL) return 1; /* out of memory */

View File

@ -185,6 +185,7 @@ Private Sub Execute_Click()
End If
Call Awk.AddBuiltinFunction("tan", 1, 1)
Call Awk.AddBuiltinFunction("trim", 1, 1)
'Call Awk.DeleteBuiltinFunction("tan")
If Awk.Parse() = -1 Then
MsgBox "PARSE ERROR [" + Str(Awk.ErrorLine) + "]" + Awk.ErrorMessage
@ -410,11 +411,29 @@ End Function
Function Awk_HandleBuiltinFunction(ByVal name As String, ByVal args As Variant) As Variant
If name = "sin" Then
Awk_HandleBuiltinFunction = Sin(args(0))
If TypeName(args(0)) = "Long" Or TypeName(args(0)) = "Double" Then
Awk_HandleBuiltinFunction = Sin(args(0))
ElseIf TypeName(args(0)) = "String" Then
Awk_HandleBuiltinFunction = Sin(Val(args(0)))
ElseIf TypeName(args(0)) = "Null" Then
Awk_HandleBuiltinFunction = Sin(0)
End If
ElseIf name = "cos" Then
Awk_HandleBuiltinFunction = Cos(args(0))
If TypeName(args(0)) = "Long" Or TypeName(args(0)) = "Double" Then
Awk_HandleBuiltinFunction = Cos(args(0))
ElseIf TypeName(args(0)) = "String" Then
Awk_HandleBuiltinFunction = Cos(Val(args(0)))
ElseIf TypeName(args(0)) = "Null" Then
Awk_HandleBuiltinFunction = Cos(0)
End If
ElseIf name = "tan" Then
Awk_HandleBuiltinFunction = Tan(args(0))
If TypeName(args(0)) = "Long" Or TypeName(args(0)) = "Double" Then
Awk_HandleBuiltinFunction = Tan(args(0))
ElseIf TypeName(args(0)) = "String" Then
Awk_HandleBuiltinFunction = Tan(Val(args(0)))
ElseIf TypeName(args(0)) = "Null" Then
Awk_HandleBuiltinFunction = Tan(0)
End If
ElseIf name = "trim" Then
Awk_HandleBuiltinFunction = Trim(args(0))
End If