*** empty log message ***

This commit is contained in:
hyung-hwan 2006-12-09 12:09:42 +00:00
parent b830f02540
commit a00c29b744
3 changed files with 159 additions and 32 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk_cp.h,v 1.1 2006-12-09 11:50:08 bacon Exp $ * $Id: awk_cp.h,v 1.2 2006-12-09 12:09:42 bacon Exp $
*/ */
#ifndef _AWK_CP_H_ #ifndef _AWK_CP_H_
@ -10,60 +10,102 @@
template <class T> template <class T>
class CProxyIAwkEvents : public IConnectionPointImpl<T, &DIID_IAwkEvents, CComDynamicUnkArray> class CProxyIAwkEvents : public IConnectionPointImpl<T, &DIID_IAwkEvents, CComDynamicUnkArray>
{ {
//Warning this class may be recreated by the wizard.
public: public:
LONG Fire_OpenSource(LONG mode) LONG Fire_OpenSource(LONG mode)
{ {
CComVariant varResult;
T* pT = static_cast<T*>(this); T* pT = static_cast<T*>(this);
int nConnectionIndex; int i, nconns = m_vec.GetSize();
CComVariant* pvars = new CComVariant[1]; CComVariant args[1], ret;
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++) for (i = 0; i < nconns; i++)
{ {
pT->Lock(); pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex); CComPtr<IUnknown> sp = m_vec.GetAt(i);
pT->Unlock(); pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[0] = mode;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
return varResult.lVal;
IDispatch* pDispatch =
reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch == NULL) continue;
VariantClear (&ret);
VariantClear (&args[0]);
args[0] = mode;
DISPPARAMS disp = { args, NULL, 1, 0 };
HRESULT hr = pDispatch->Invoke (
0x1, 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;
} }
LONG Fire_CloseSource(LONG mode) LONG Fire_CloseSource(LONG mode)
{ {
CComVariant varResult;
T* pT = static_cast<T*>(this); T* pT = static_cast<T*>(this);
int nConnectionIndex; int i, nconns = m_vec.GetSize();
CComVariant* pvars = new CComVariant[1]; CComVariant args[1], ret;
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++) for (i = 0; i < nconns; i++)
{ {
pT->Lock(); pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex); CComPtr<IUnknown> sp = m_vec.GetAt(i);
pT->Unlock(); pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[0] = mode;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
return varResult.lVal;
IDispatch* pDispatch =
reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch == NULL) continue;
VariantClear (&ret);
VariantClear (&args[0]);
args[0] = mode;
DISPPARAMS disp = { args, NULL, 1, 0 };
HRESULT hr = pDispatch->Invoke (
0x2, 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;
} }
LONG Fire_ReadSource (IBuffer* buf) LONG Fire_ReadSource (IBuffer* buf)
{ {
T* pT = static_cast<T*>(this); T* pT = static_cast<T*>(this);
@ -171,4 +213,5 @@ public:
return bstr.Length(); return bstr.Length();
} }
}; };
#endif #endif

54
ase/test/com/awk.js Normal file
View File

@ -0,0 +1,54 @@
var awk, first, n
first = true
function awk_OpenSource (mode)
{
WScript.echo ("OpenSource - mode:" + mode);
return 1;
}
function awk_CloseSource (mode)
{
WScript.echo ("CloseSource - mode:" + mode);
return 0;
}
function awk_ReadSource (buf)
{
WScript.echo ("ReadSource - buf: [" + buf.Value + "]");
if (first)
{
buf.Value = "BEGIN {print 1; print 2; print 3 > \"x\";}"
first = false
return buf.Value.length;
}
else return 0;
}
function awk_WriteSource (buf)
{
//WScript.echo ("WriteSource - cnt: " + cnt)
WScript.echo (buf.Value);
return buf.Value.length;
}
awk = WScript.CreateObject("ASE.Awk");
WScript.ConnectObject (awk, "awk_");
n = awk.Parse();
if (n == -1)
{
WScript.echo ("parse failed");
WScript.quit (1);
}
n = awk.Run ();
if (n == -1)
{
WScript.echo ("run failed");
WScript.quit (1);
}

30
ase/test/com/awk.vbs Normal file
View File

@ -0,0 +1,30 @@
dim awk, first
first = true
function awk_OpenSource (mode)
WScript.echo ("OpenSource - mode:" & mode)
awk_OpenSource = 1
end function
function awk_CloseSource (mode)
WScript.echo ("CloseSource - mode:" & mode)
awk_CloseSource = 0
end function
function awk_ReadSource (buf, cnt)
WScript.echo ("ReadSource - cnt: " & cnt)
if first then
buf.Value = "BEGIN {print 1;}"
first = false
awk_ReadSource = len(buf.Value)
else
awk_ReadSource = 0
end if
end function
set awk = WScript.CreateObject("ASE.Awk")
call WScript.ConnectObject (awk, "awk_")
WScript.echo awk.Parse
set awk = nothing