*** empty log message ***
This commit is contained in:
		@ -15,7 +15,7 @@ Package=<4>
 | 
			
		||||
 | 
			
		||||
###############################################################################
 | 
			
		||||
 | 
			
		||||
Project: "awk.com"=.\com\awk\awk.dsp - Package Owner=<4>
 | 
			
		||||
Project: "ase.com"=.\com\ase.dsp - Package Owner=<4>
 | 
			
		||||
 | 
			
		||||
Package=<5>
 | 
			
		||||
{{{
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: extio.c,v 1.65 2006-11-29 02:54:15 bacon Exp $
 | 
			
		||||
 * $Id: extio.c,v 1.66 2006-12-09 11:49:03 bacon Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <ase/awk/awk_i.h>
 | 
			
		||||
@ -143,7 +143,7 @@ int ase_awk_readextio (
 | 
			
		||||
		p->in.eos = ase_false;
 | 
			
		||||
 | 
			
		||||
		n = handler (ASE_AWK_IO_OPEN, p, ASE_NULL, 0);
 | 
			
		||||
		if (n == -1)
 | 
			
		||||
		if (n <= -1)
 | 
			
		||||
		{
 | 
			
		||||
			ASE_AWK_FREE (run->awk, p->name);
 | 
			
		||||
			ASE_AWK_FREE (run->awk, p);
 | 
			
		||||
@ -226,7 +226,7 @@ int ase_awk_readextio (
 | 
			
		||||
 | 
			
		||||
			n = handler (ASE_AWK_IO_READ, p, 
 | 
			
		||||
				p->in.buf, ASE_COUNTOF(p->in.buf));
 | 
			
		||||
			if (n == -1) 
 | 
			
		||||
			if (n <= -1) 
 | 
			
		||||
			{
 | 
			
		||||
				/* handler error. getline should return -1 */
 | 
			
		||||
				/* TODO: use meaningful error code */
 | 
			
		||||
@ -477,7 +477,7 @@ int ase_awk_writeextio_str (
 | 
			
		||||
		p->out.eos = ase_false;
 | 
			
		||||
 | 
			
		||||
		n = handler (ASE_AWK_IO_OPEN, p, ASE_NULL, 0);
 | 
			
		||||
		if (n == -1)
 | 
			
		||||
		if (n <= -1)
 | 
			
		||||
		{
 | 
			
		||||
			ASE_AWK_FREE (run->awk, p->name);
 | 
			
		||||
			ASE_AWK_FREE (run->awk, p);
 | 
			
		||||
@ -524,7 +524,7 @@ int ase_awk_writeextio_str (
 | 
			
		||||
	{
 | 
			
		||||
		n = handler (ASE_AWK_IO_WRITE, p, str, len);
 | 
			
		||||
 | 
			
		||||
		if (n == -1) 
 | 
			
		||||
		if (n <= -1) 
 | 
			
		||||
		{
 | 
			
		||||
			/* TODO: use meaningful error code */
 | 
			
		||||
			if (ase_awk_setglobal (
 | 
			
		||||
@ -584,7 +584,7 @@ int ase_awk_flushextio (
 | 
			
		||||
		{
 | 
			
		||||
			n = handler (ASE_AWK_IO_FLUSH, p, ASE_NULL, 0);
 | 
			
		||||
 | 
			
		||||
			if (n == -1) 
 | 
			
		||||
			if (n <= -1) 
 | 
			
		||||
			{
 | 
			
		||||
				/* TODO: use meaningful error code */
 | 
			
		||||
				if (ase_awk_setglobal (
 | 
			
		||||
@ -662,7 +662,7 @@ int ase_awk_nextextio_read (
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	n = handler (ASE_AWK_IO_NEXT, p, ASE_NULL, 0);
 | 
			
		||||
	if (n == -1)
 | 
			
		||||
	if (n <= -1)
 | 
			
		||||
	{
 | 
			
		||||
		/* TODO: is this errnum correct? */
 | 
			
		||||
		run->errnum = ASE_AWK_EIOHANDLER;
 | 
			
		||||
@ -741,7 +741,7 @@ int ase_awk_nextextio_write (
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	n = handler (ASE_AWK_IO_NEXT, p, ASE_NULL, 0);
 | 
			
		||||
	if (n == -1)
 | 
			
		||||
	if (n <= -1)
 | 
			
		||||
	{
 | 
			
		||||
		/* TODO: is this errnum correct? */
 | 
			
		||||
		run->errnum = ASE_AWK_EIOHANDLER;
 | 
			
		||||
@ -802,7 +802,7 @@ int ase_awk_closeextio_read (
 | 
			
		||||
			handler = run->extio.handler[p->type & __MASK_CLEAR];
 | 
			
		||||
			if (handler != ASE_NULL)
 | 
			
		||||
			{
 | 
			
		||||
				if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) == -1)
 | 
			
		||||
				if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) <= -1)
 | 
			
		||||
				{
 | 
			
		||||
					/* this is not a run-time error.*/
 | 
			
		||||
					/* TODO: set ERRNO */
 | 
			
		||||
@ -865,7 +865,7 @@ int ase_awk_closeextio_write (
 | 
			
		||||
			handler = run->extio.handler[p->type & __MASK_CLEAR];
 | 
			
		||||
			if (handler != ASE_NULL)
 | 
			
		||||
			{
 | 
			
		||||
				if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) == -1)
 | 
			
		||||
				if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) <= -1)
 | 
			
		||||
				{
 | 
			
		||||
					/* this is not a run-time error.*/
 | 
			
		||||
					/* TODO: set ERRNO */
 | 
			
		||||
@ -907,7 +907,7 @@ int ase_awk_closeextio (ase_awk_run_t* run, const ase_char_t* name)
 | 
			
		||||
			handler = run->extio.handler[p->type & __MASK_CLEAR];
 | 
			
		||||
			if (handler != ASE_NULL)
 | 
			
		||||
			{
 | 
			
		||||
				if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) == -1)
 | 
			
		||||
				if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) <= -1)
 | 
			
		||||
				{
 | 
			
		||||
					/* this is not a run-time error.*/
 | 
			
		||||
					/* TODO: set ERRNO */
 | 
			
		||||
@ -949,7 +949,7 @@ void ase_awk_clearextio (ase_awk_run_t* run)
 | 
			
		||||
		if (handler != ASE_NULL)
 | 
			
		||||
		{
 | 
			
		||||
			n = handler (ASE_AWK_IO_CLOSE, run->extio.chain, ASE_NULL, 0);
 | 
			
		||||
			if (n == -1)
 | 
			
		||||
			if (n <= -1)
 | 
			
		||||
			{
 | 
			
		||||
				/* TODO: 
 | 
			
		||||
				 * some warning actions need to be taken */
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: parse.c,v 1.217 2006-12-08 06:02:41 bacon Exp $
 | 
			
		||||
 * $Id: parse.c,v 1.218 2006-12-09 11:49:03 bacon Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <ase/awk/awk_i.h>
 | 
			
		||||
@ -371,7 +371,7 @@ static int __parse (ase_awk_t* awk)
 | 
			
		||||
 | 
			
		||||
	op = awk->src.ios.in (
 | 
			
		||||
		ASE_AWK_IO_OPEN, awk->src.ios.custom_data, ASE_NULL, 0);
 | 
			
		||||
	if (op == -1)
 | 
			
		||||
	if (op <= -1)
 | 
			
		||||
	{
 | 
			
		||||
		/* cannot open the source file.
 | 
			
		||||
		 * it doesn't even have to call CLOSE */
 | 
			
		||||
@ -431,9 +431,9 @@ static int __parse (ase_awk_t* awk)
 | 
			
		||||
 | 
			
		||||
exit_parse:
 | 
			
		||||
	if (awk->src.ios.in (
 | 
			
		||||
		ASE_AWK_IO_CLOSE, awk->src.ios.custom_data, ASE_NULL, 0) == -1)
 | 
			
		||||
		ASE_AWK_IO_CLOSE, awk->src.ios.custom_data, ASE_NULL, 0) != 0)
 | 
			
		||||
	{
 | 
			
		||||
		if (n != -1)
 | 
			
		||||
		if (n == 0)
 | 
			
		||||
		{
 | 
			
		||||
			/* this is to keep the earlier error above
 | 
			
		||||
			 * that might be more critical than this */
 | 
			
		||||
@ -4161,7 +4161,7 @@ static int __get_char (ase_awk_t* awk)
 | 
			
		||||
		n = awk->src.ios.in (
 | 
			
		||||
			ASE_AWK_IO_READ, awk->src.ios.custom_data,
 | 
			
		||||
			awk->src.shared.buf, ASE_COUNTOF(awk->src.shared.buf));
 | 
			
		||||
		if (n == -1)
 | 
			
		||||
		if (n <= -1)
 | 
			
		||||
		{
 | 
			
		||||
			awk->errnum = ASE_AWK_ESRCINREAD;
 | 
			
		||||
			return -1;
 | 
			
		||||
@ -4372,7 +4372,7 @@ static int __deparse (ase_awk_t* awk)
 | 
			
		||||
 | 
			
		||||
	op = awk->src.ios.out (
 | 
			
		||||
		ASE_AWK_IO_OPEN, awk->src.ios.custom_data, ASE_NULL, 0);
 | 
			
		||||
	if (op == -1)
 | 
			
		||||
	if (op <= -1)
 | 
			
		||||
	{
 | 
			
		||||
		awk->errnum = ASE_AWK_ESRCOUTOPEN;
 | 
			
		||||
		return -1;
 | 
			
		||||
@ -4509,9 +4509,9 @@ static int __deparse (ase_awk_t* awk)
 | 
			
		||||
 | 
			
		||||
exit_deparse:
 | 
			
		||||
	if (awk->src.ios.out (
 | 
			
		||||
		ASE_AWK_IO_CLOSE, awk->src.ios.custom_data, ASE_NULL, 0) == -1)
 | 
			
		||||
		ASE_AWK_IO_CLOSE, awk->src.ios.custom_data, ASE_NULL, 0) != 0)
 | 
			
		||||
	{
 | 
			
		||||
		if (n != -1)
 | 
			
		||||
		if (n == 0)
 | 
			
		||||
		{
 | 
			
		||||
			awk->errnum = ASE_AWK_ESRCOUTCLOSE;
 | 
			
		||||
			n = -1;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										401
									
								
								ase/com/Awk.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										401
									
								
								ase/com/Awk.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,401 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: Awk.cpp,v 1.1 2006-12-09 11:50:07 bacon Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "stdafx.h"
 | 
			
		||||
#include "ase.h"
 | 
			
		||||
#include "Awk.h"
 | 
			
		||||
#include "Buffer.h"
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <wctype.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
STDMETHODIMP CAwk::InterfaceSupportsErrorInfo(REFIID riid)
 | 
			
		||||
{
 | 
			
		||||
	static const IID* arr[] = 
 | 
			
		||||
	{
 | 
			
		||||
		&IID_IAwk,
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
 | 
			
		||||
	{
 | 
			
		||||
		if (/*Inline*/IsEqualGUID(*arr[i],riid))
 | 
			
		||||
			return S_OK;
 | 
			
		||||
	}
 | 
			
		||||
	return S_FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CAwk::CAwk (): handle(NULL), 
 | 
			
		||||
	read_source_buf(NULL), write_source_buf(NULL)
 | 
			
		||||
{
 | 
			
		||||
#ifdef _DEBUG
 | 
			
		||||
	TCHAR x[128];
 | 
			
		||||
	_sntprintf (x, 128, _T("CAwk::CAwk %p"), this);
 | 
			
		||||
	MessageBox (NULL, x, x, MB_OK);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CAwk::~CAwk ()
 | 
			
		||||
{
 | 
			
		||||
#ifdef _DEBUG
 | 
			
		||||
	TCHAR x[128];
 | 
			
		||||
	_sntprintf (x, 128, _T("CAwk::~CAwk %p"), this);
 | 
			
		||||
	MessageBox (NULL, x, x, MB_OK);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	if (write_source_buf != NULL)
 | 
			
		||||
	{
 | 
			
		||||
		write_source_buf->Release ();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (read_source_buf != NULL)
 | 
			
		||||
	{
 | 
			
		||||
		read_source_buf->Release ();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (handle != NULL) 
 | 
			
		||||
	{
 | 
			
		||||
		ase_awk_close (handle);
 | 
			
		||||
		handle = NULL;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void* __awk_malloc (ase_size_t n, void* custom_data)
 | 
			
		||||
{
 | 
			
		||||
	return malloc (n);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void* __awk_realloc (void* ptr, ase_size_t n, void* custom_data)
 | 
			
		||||
{
 | 
			
		||||
	return realloc (ptr, n);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void __awk_free (void* ptr, void* custom_data)
 | 
			
		||||
{
 | 
			
		||||
	free (ptr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static ase_real_t __awk_pow (ase_real_t x, ase_real_t y)
 | 
			
		||||
{
 | 
			
		||||
	return pow (x, y);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int __awk_sprintf (
 | 
			
		||||
	ase_char_t* buf, ase_size_t len, const ase_char_t* fmt, ...)
 | 
			
		||||
{
 | 
			
		||||
	int n;
 | 
			
		||||
	va_list ap;
 | 
			
		||||
 | 
			
		||||
	va_start (ap, fmt);
 | 
			
		||||
#if defined(_WIN32)
 | 
			
		||||
	n = _vsntprintf (buf, len, fmt, ap);
 | 
			
		||||
	if (n < 0 || (ase_size_t)n >= len)
 | 
			
		||||
	{
 | 
			
		||||
		if (len > 0) buf[len-1] = ASE_T('\0');
 | 
			
		||||
		n = -1;
 | 
			
		||||
	}
 | 
			
		||||
#elif defined(__MSDOS__)
 | 
			
		||||
	/* TODO: check buffer overflow */
 | 
			
		||||
	n = vsprintf (buf, fmt, ap);
 | 
			
		||||
#else
 | 
			
		||||
	n = xp_vsprintf (buf, len, fmt, ap);
 | 
			
		||||
#endif
 | 
			
		||||
	va_end (ap);
 | 
			
		||||
	return n;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void __awk_aprintf (const ase_char_t* fmt, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list ap;
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
	int n;
 | 
			
		||||
	ase_char_t buf[1024];
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	va_start (ap, fmt);
 | 
			
		||||
#if defined(_WIN32)
 | 
			
		||||
	n = _vsntprintf (buf, ASE_COUNTOF(buf), fmt, ap);
 | 
			
		||||
	if (n < 0) buf[ASE_COUNTOF(buf)-1] = ASE_T('\0');
 | 
			
		||||
 | 
			
		||||
	#if defined(_MSC_VER) && (_MSC_VER<1400)
 | 
			
		||||
	MessageBox (NULL, buf, 
 | 
			
		||||
		ASE_T("Assertion Failure"), MB_OK|MB_ICONERROR);
 | 
			
		||||
	#else
 | 
			
		||||
	MessageBox (NULL, buf, 
 | 
			
		||||
		ASE_T("\uB2DD\uAE30\uB9AC \uC870\uB610"), MB_OK|MB_ICONERROR);
 | 
			
		||||
	#endif
 | 
			
		||||
#elif defined(__MSDOS__)
 | 
			
		||||
	vprintf (fmt, ap);
 | 
			
		||||
#else
 | 
			
		||||
	xp_vprintf (fmt, ap);
 | 
			
		||||
#endif
 | 
			
		||||
	va_end (ap);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void __awk_dprintf (const ase_char_t* fmt, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list ap;
 | 
			
		||||
	va_start (ap, fmt);
 | 
			
		||||
 | 
			
		||||
#if defined(_WIN32)
 | 
			
		||||
	_vftprintf (stderr, fmt, ap);
 | 
			
		||||
#elif defined(__MSDOS__)
 | 
			
		||||
	vfprintf (stderr, fmt, ap);
 | 
			
		||||
#else
 | 
			
		||||
	xp_vfprintf (stderr, fmt, ap);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	va_end (ap);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static ase_ssize_t __read_source (
 | 
			
		||||
	int cmd, void* arg, ase_char_t* data, ase_size_t count)
 | 
			
		||||
{
 | 
			
		||||
	CAwk* awk = (CAwk*)arg;
 | 
			
		||||
 | 
			
		||||
	if (cmd == ASE_AWK_IO_OPEN) 
 | 
			
		||||
	{
 | 
			
		||||
		return (ase_ssize_t)awk->Fire_OpenSource (0);
 | 
			
		||||
	}
 | 
			
		||||
	else if (cmd == ASE_AWK_IO_CLOSE)
 | 
			
		||||
	{
 | 
			
		||||
		return (ase_ssize_t)awk->Fire_CloseSource (0);
 | 
			
		||||
	}
 | 
			
		||||
	else if (cmd == ASE_AWK_IO_READ)
 | 
			
		||||
	{
 | 
			
		||||
		HRESULT hr;
 | 
			
		||||
		CComBSTR val;
 | 
			
		||||
 | 
			
		||||
		if (awk->read_source_buf == NULL)
 | 
			
		||||
		{
 | 
			
		||||
			hr = CoCreateInstance (
 | 
			
		||||
				CLSID_Buffer, NULL, CLSCTX_ALL, 
 | 
			
		||||
				IID_IBuffer, (void**)&awk->read_source_buf);
 | 
			
		||||
			if (FAILED(hr))
 | 
			
		||||
			{	
 | 
			
		||||
MessageBox (NULL, _T("COCREATEINSTANCE FAILED"), _T("FUCK"), MB_OK);
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			awk->read_source_pos = 0;
 | 
			
		||||
			awk->read_source_len = 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (awk->read_source_pos >= awk->read_source_len)
 | 
			
		||||
		{
 | 
			
		||||
			LONG 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;
 | 
			
		||||
 | 
			
		||||
			awk->read_source_pos = 0;
 | 
			
		||||
			awk->read_source_len = n;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			awk->read_source_buf->get_Value (&val);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		ASE_AWK_ASSERT (awk->handle, 
 | 
			
		||||
			awk->read_source_pos < awk->read_source_len);
 | 
			
		||||
 | 
			
		||||
		LONG left = awk->read_source_len - awk->read_source_pos;
 | 
			
		||||
		if (left > (ase_ssize_t)count)
 | 
			
		||||
		{
 | 
			
		||||
			memcpy (data,
 | 
			
		||||
				((TCHAR*)(BSTR)val)+awk->read_source_pos, 
 | 
			
		||||
				count * ASE_SIZEOF(ase_char_t));
 | 
			
		||||
			awk->read_source_pos += count;
 | 
			
		||||
			return count;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			memcpy (data, 
 | 
			
		||||
				((TCHAR*)(BSTR)val)+awk->read_source_pos, 
 | 
			
		||||
				left * ASE_SIZEOF(ase_char_t));
 | 
			
		||||
			awk->read_source_pos = 0;
 | 
			
		||||
			awk->read_source_len = 0;
 | 
			
		||||
			return (ase_ssize_t)left;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static ase_ssize_t __write_source (
 | 
			
		||||
	int cmd, void* arg, ase_char_t* data, ase_size_t count)
 | 
			
		||||
{
 | 
			
		||||
	CAwk* awk = (CAwk*)arg;
 | 
			
		||||
 | 
			
		||||
	if (cmd == ASE_AWK_IO_OPEN) 
 | 
			
		||||
	{
 | 
			
		||||
		return (ase_ssize_t)awk->Fire_OpenSource (1);
 | 
			
		||||
	}
 | 
			
		||||
	else if (cmd == ASE_AWK_IO_CLOSE)
 | 
			
		||||
	{
 | 
			
		||||
		return (ase_ssize_t)awk->Fire_CloseSource (1);
 | 
			
		||||
	}
 | 
			
		||||
	else if (cmd == ASE_AWK_IO_WRITE)
 | 
			
		||||
	{
 | 
			
		||||
		HRESULT hr;
 | 
			
		||||
 | 
			
		||||
		if (awk->write_source_buf == NULL)
 | 
			
		||||
		{
 | 
			
		||||
			hr = CoCreateInstance (
 | 
			
		||||
				CLSID_Buffer, NULL, CLSCTX_ALL, 
 | 
			
		||||
				IID_IBuffer, (void**)&awk->write_source_buf);
 | 
			
		||||
			if (FAILED(hr))
 | 
			
		||||
			{	
 | 
			
		||||
MessageBox (NULL, _T("COCREATEINSTANCE FAILED"), _T("FUCK"), MB_OK);
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		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; 
 | 
			
		||||
 | 
			
		||||
		return (ase_ssize_t)n;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
HRESULT CAwk::Parse (int* ret)
 | 
			
		||||
{
 | 
			
		||||
 	if (handle == NULL)
 | 
			
		||||
	{
 | 
			
		||||
		ase_awk_syscas_t syscas;
 | 
			
		||||
 | 
			
		||||
		memset (&syscas, 0, sizeof(syscas));
 | 
			
		||||
		syscas.malloc = __awk_malloc;
 | 
			
		||||
		syscas.realloc = __awk_realloc;
 | 
			
		||||
		syscas.free = __awk_free;
 | 
			
		||||
 | 
			
		||||
		syscas.is_upper  = iswupper;
 | 
			
		||||
		syscas.is_lower  = iswlower;
 | 
			
		||||
		syscas.is_alpha  = iswalpha;
 | 
			
		||||
		syscas.is_digit  = iswdigit;
 | 
			
		||||
		syscas.is_xdigit = iswxdigit;
 | 
			
		||||
		syscas.is_alnum  = iswalnum;
 | 
			
		||||
		syscas.is_space  = iswspace;
 | 
			
		||||
		syscas.is_print  = iswprint;
 | 
			
		||||
		syscas.is_graph  = iswgraph;
 | 
			
		||||
		syscas.is_cntrl  = iswcntrl;
 | 
			
		||||
		syscas.is_punct  = iswpunct;
 | 
			
		||||
		syscas.to_upper  = towupper;
 | 
			
		||||
		syscas.to_lower  = towlower;
 | 
			
		||||
 | 
			
		||||
		syscas.memcpy = memcpy;
 | 
			
		||||
		syscas.memset = memset;
 | 
			
		||||
		syscas.pow = __awk_pow;
 | 
			
		||||
		syscas.sprintf = __awk_sprintf;
 | 
			
		||||
		syscas.aprintf = __awk_aprintf;
 | 
			
		||||
		syscas.dprintf = __awk_dprintf;
 | 
			
		||||
		syscas.abort = abort;
 | 
			
		||||
 | 
			
		||||
		handle = ase_awk_open (&syscas);
 | 
			
		||||
		if (handle == NULL)
 | 
			
		||||
		{
 | 
			
		||||
			*ret = -1;
 | 
			
		||||
			return S_OK;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		int opt = /*ASE_AWK_IMPLICIT | 
 | 
			
		||||
		      ASE_AWK_EXPLICIT | 
 | 
			
		||||
			  ASE_AWK_UNIQUEAFN | 
 | 
			
		||||
		      ASE_AWK_HASHSIGN | 
 | 
			
		||||
		      ASE_AWK_IDIV |
 | 
			
		||||
		      ASE_AWK_SHADING | 
 | 
			
		||||
		      ASE_AWK_SHIFT | */
 | 
			
		||||
		      ASE_AWK_EXTIO /*| 
 | 
			
		||||
		      ASE_AWK_BLOCKLESS | 
 | 
			
		||||
		      ASE_AWK_STRINDEXONE | 
 | 
			
		||||
		      ASE_AWK_STRIPSPACES | 
 | 
			
		||||
		      ASE_AWK_NEXTOFILE*/;
 | 
			
		||||
 | 
			
		||||
		ase_awk_setopt (handle, opt);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ase_awk_srcios_t srcios;
 | 
			
		||||
 | 
			
		||||
	srcios.in = __read_source;
 | 
			
		||||
	srcios.out = __write_source;
 | 
			
		||||
	srcios.custom_data = this;
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	if (ase_awk_parse (handle, &srcios) == -1)
 | 
			
		||||
	{
 | 
			
		||||
		*ret = -1;
 | 
			
		||||
		return S_OK;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	*ret = 0;
 | 
			
		||||
	return S_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static ase_ssize_t __process_extio (
 | 
			
		||||
	int cmd, void* arg, ase_char_t* data, ase_size_t size)
 | 
			
		||||
{
 | 
			
		||||
	ase_awk_extio_t* epa = (ase_awk_extio_t*)arg;
 | 
			
		||||
	CAwk* awk = (CAwk*)epa->custom_data;
 | 
			
		||||
 | 
			
		||||
	if (cmd == ASE_AWK_IO_OPEN)
 | 
			
		||||
	{
 | 
			
		||||
				
 | 
			
		||||
	}
 | 
			
		||||
	else if (cmd == ASE_AWK_IO_CLOSE)
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
	else if (cmd == ASE_AWK_IO_READ)
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
	else if (cmd == ASE_AWK_IO_WRITE)
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
	else if (cmd == ASE_AWK_IO_FLUSH)
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
	else if (cmd == ASE_AWK_IO_NEXT)
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
HRESULT CAwk::Run (int* ret)
 | 
			
		||||
{
 | 
			
		||||
	if (handle == NULL)
 | 
			
		||||
	{
 | 
			
		||||
		/* TODO: better error handling... */
 | 
			
		||||
		/* call parse first... */
 | 
			
		||||
		*ret = -1;
 | 
			
		||||
		return S_OK;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ase_awk_runios_t runios;
 | 
			
		||||
	runios.pipe = __process_extio;
 | 
			
		||||
	runios.coproc = NULL;
 | 
			
		||||
	runios.file = NULL;
 | 
			
		||||
	runios.console = NULL;
 | 
			
		||||
	runios.custom_data = this;
 | 
			
		||||
 | 
			
		||||
	if (ase_awk_run (handle, NULL, &runios, NULL, NULL, this) == -1)
 | 
			
		||||
	{
 | 
			
		||||
		*ret = -1;
 | 
			
		||||
		return S_OK;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	*ret = 0;
 | 
			
		||||
	return S_OK;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										70
									
								
								ase/com/Awk.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								ase/com/Awk.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,70 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: Awk.h,v 1.1 2006-12-09 11:50:07 bacon Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _ASE_COM_AWK_H_
 | 
			
		||||
#define _ASE_COM_AWK_H_
 | 
			
		||||
 | 
			
		||||
#if _MSC_VER > 1000
 | 
			
		||||
#pragma once
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "resource.h" 
 | 
			
		||||
#include "ase.h"
 | 
			
		||||
#include "awk_cp.h"
 | 
			
		||||
#include <ase/awk/awk.h>
 | 
			
		||||
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// CAwk
 | 
			
		||||
 | 
			
		||||
class CAwk : 
 | 
			
		||||
	public IDispatchImpl<IAwk, &IID_IAwk, &LIBID_ASELib>, 
 | 
			
		||||
	public ISupportErrorInfo,
 | 
			
		||||
	/*public CComObjectRoot,*/
 | 
			
		||||
	public CComObjectRootEx<CComSingleThreadModel>,
 | 
			
		||||
	public CComCoClass<CAwk,&CLSID_Awk>,
 | 
			
		||||
	public IConnectionPointContainerImpl<CAwk>,
 | 
			
		||||
	public IProvideClassInfo2Impl<&CLSID_Awk, &DIID_IAwkEvents, &LIBID_ASELib>,
 | 
			
		||||
	public CProxyIAwkEvents< 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;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	CAwk();
 | 
			
		||||
	~CAwk ();
 | 
			
		||||
	
 | 
			
		||||
BEGIN_COM_MAP(CAwk)
 | 
			
		||||
	COM_INTERFACE_ENTRY(IDispatch)
 | 
			
		||||
	COM_INTERFACE_ENTRY(IAwk)
 | 
			
		||||
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
 | 
			
		||||
	COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
 | 
			
		||||
	COM_INTERFACE_ENTRY(IProvideClassInfo)
 | 
			
		||||
	COM_INTERFACE_ENTRY(IProvideClassInfo2)
 | 
			
		||||
END_COM_MAP()
 | 
			
		||||
 | 
			
		||||
BEGIN_CONNECTION_POINT_MAP(CAwk)
 | 
			
		||||
CONNECTION_POINT_ENTRY(DIID_IAwkEvents)
 | 
			
		||||
END_CONNECTION_POINT_MAP()
 | 
			
		||||
 | 
			
		||||
//DECLARE_NOT_AGGREGATABLE(CAwk) 
 | 
			
		||||
// Remove the comment from the line above if you don't want your object to 
 | 
			
		||||
// support aggregation. 
 | 
			
		||||
 | 
			
		||||
DECLARE_REGISTRY_RESOURCEID(IDR_AWK)
 | 
			
		||||
// ISupportsErrorInfo
 | 
			
		||||
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
 | 
			
		||||
 | 
			
		||||
// IAwk
 | 
			
		||||
public:
 | 
			
		||||
	HRESULT __stdcall Parse (int* ret);
 | 
			
		||||
	HRESULT __stdcall Run (int* ret);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										25
									
								
								ase/com/Awk.rgs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								ase/com/Awk.rgs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
			
		||||
HKCR
 | 
			
		||||
{
 | 
			
		||||
	ASE.Awk.1 = s 'ASE Awk Class'
 | 
			
		||||
	{
 | 
			
		||||
		CLSID = s '{AD863B53-F5EC-45C3-8B1C-6AC678227DC8}'
 | 
			
		||||
	}
 | 
			
		||||
	ASE.Awk = s 'ASE Awk Class'
 | 
			
		||||
	{
 | 
			
		||||
		CLSID = s '{AD863B53-F5EC-45C3-8B1C-6AC678227DC8}'
 | 
			
		||||
	}
 | 
			
		||||
	NoRemove CLSID
 | 
			
		||||
	{
 | 
			
		||||
		ForceRemove {AD863B53-F5EC-45C3-8B1C-6AC678227DC8} = s 'ASE Awk Class'
 | 
			
		||||
		{
 | 
			
		||||
			ProgID = s 'ASE.Awk.1'
 | 
			
		||||
			VersionIndependentProgID = s 'ASE.Awk'
 | 
			
		||||
			ForceRemove 'Programmable'
 | 
			
		||||
			InprocServer32 = s '%MODULE%'
 | 
			
		||||
			{
 | 
			
		||||
				val ThreadingModel = s 'Apartment'
 | 
			
		||||
			}
 | 
			
		||||
			'TypeLib' = s '{F9C69806-16A1-4162-998A-876B33C470BF}'
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										57
									
								
								ase/com/AwkExtio.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								ase/com/AwkExtio.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,57 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: AwkExtio.cpp,v 1.1 2006-12-09 11:50:08 bacon Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "stdafx.h"
 | 
			
		||||
#include "ase.h"
 | 
			
		||||
#include "AwkExtio.h"
 | 
			
		||||
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// CAwkExtio
 | 
			
		||||
 | 
			
		||||
CAwkExtio::CAwkExtio ()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CAwkExtio::~CAwkExtio ()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
STDMETHODIMP CAwkExtio::get_Name(BSTR *pVal)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	*pVal = name;
 | 
			
		||||
	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
 | 
			
		||||
 | 
			
		||||
	return S_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
STDMETHODIMP CAwkExtio::put_Mode(int newVal)
 | 
			
		||||
{
 | 
			
		||||
	// TODO: Add your implementation code here
 | 
			
		||||
 | 
			
		||||
	return S_OK;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										42
									
								
								ase/com/AwkExtio.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								ase/com/AwkExtio.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,42 @@
 | 
			
		||||
// AwkExtio.h : Declaration of the CAwkExtio
 | 
			
		||||
 | 
			
		||||
#ifndef __AWKEXTIO_H_
 | 
			
		||||
#define __AWKEXTIO_H_
 | 
			
		||||
 | 
			
		||||
#include "resource.h"       // main symbols
 | 
			
		||||
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// CAwkExtio
 | 
			
		||||
class ATL_NO_VTABLE CAwkExtio : 
 | 
			
		||||
	public CComObjectRootEx<CComSingleThreadModel>,
 | 
			
		||||
	public CComCoClass<CAwkExtio, &CLSID_AwkExtio>,
 | 
			
		||||
	public IDispatchImpl<IAwkExtio, &IID_IAwkExtio, &LIBID_ASELib>
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
	CComBSTR name;
 | 
			
		||||
	int type;
 | 
			
		||||
	int mode;
 | 
			
		||||
 | 
			
		||||
	CAwkExtio ();
 | 
			
		||||
	~CAwkExtio ();
 | 
			
		||||
 | 
			
		||||
DECLARE_REGISTRY_RESOURCEID(IDR_AWKEXTIO)
 | 
			
		||||
 | 
			
		||||
DECLARE_PROTECT_FINAL_CONSTRUCT()
 | 
			
		||||
 | 
			
		||||
BEGIN_COM_MAP(CAwkExtio)
 | 
			
		||||
	COM_INTERFACE_ENTRY(IAwkExtio)
 | 
			
		||||
	COM_INTERFACE_ENTRY(IDispatch)
 | 
			
		||||
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_
 | 
			
		||||
							
								
								
									
										26
									
								
								ase/com/AwkExtio.rgs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								ase/com/AwkExtio.rgs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,26 @@
 | 
			
		||||
HKCR
 | 
			
		||||
{
 | 
			
		||||
	ASE.AwkExtio.1 = s 'ASE AwkExtio Class'
 | 
			
		||||
	{
 | 
			
		||||
		CLSID = s '{F52F065A-5FD4-4F4D-AFEA-F5E446B16383}'
 | 
			
		||||
	}
 | 
			
		||||
	ASE.AwkExtio = s 'ASE AwkExtio Class'
 | 
			
		||||
	{
 | 
			
		||||
		CLSID = s '{F52F065A-5FD4-4F4D-AFEA-F5E446B16383}'
 | 
			
		||||
		CurVer = s 'ASE.AwkExtio.1'
 | 
			
		||||
	}
 | 
			
		||||
	NoRemove CLSID
 | 
			
		||||
	{
 | 
			
		||||
		ForceRemove {F52F065A-5FD4-4F4D-AFEA-F5E446B16383} = s 'ASE AwkExtio Class'
 | 
			
		||||
		{
 | 
			
		||||
			ProgID = s 'ASE.AwkExtio.1'
 | 
			
		||||
			VersionIndependentProgID = s 'ASE.AwkExtio'
 | 
			
		||||
			ForceRemove 'Programmable'
 | 
			
		||||
			InprocServer32 = s '%MODULE%'
 | 
			
		||||
			{
 | 
			
		||||
				val ThreadingModel = s 'Apartment'
 | 
			
		||||
			}
 | 
			
		||||
			'TypeLib' = s '{F9C69806-16A1-4162-998A-876B33C470BF}'
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										36
									
								
								ase/com/Buffer.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								ase/com/Buffer.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,36 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: Buffer.cpp,v 1.1 2006-12-09 11:50:08 bacon Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "stdafx.h"
 | 
			
		||||
#include "Buffer.h"
 | 
			
		||||
 | 
			
		||||
CBuffer::CBuffer ()
 | 
			
		||||
{
 | 
			
		||||
#ifdef _DEBUG
 | 
			
		||||
	TCHAR x[128];
 | 
			
		||||
	_sntprintf (x, 128, _T("CBuffer::~CBuffer %p"), this);
 | 
			
		||||
	MessageBox (NULL, x, x, MB_OK);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CBuffer::~CBuffer ()
 | 
			
		||||
{
 | 
			
		||||
#ifdef _DEBUG
 | 
			
		||||
	TCHAR x[128];
 | 
			
		||||
	_sntprintf (x, 128, _T("CBuffer::~CBuffer %p"), this);
 | 
			
		||||
	MessageBox (NULL, x, x, MB_OK);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
STDMETHODIMP CBuffer::get_Value(BSTR *pVal)
 | 
			
		||||
{
 | 
			
		||||
	*pVal = str;
 | 
			
		||||
	return S_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
STDMETHODIMP CBuffer::put_Value(BSTR newVal)
 | 
			
		||||
{
 | 
			
		||||
	str = newVal;
 | 
			
		||||
	return S_OK;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										37
									
								
								ase/com/Buffer.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								ase/com/Buffer.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,37 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: Buffer.h,v 1.1 2006-12-09 11:50:08 bacon Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _ASE_COM_BUFFER_H_
 | 
			
		||||
#define _ASE_COM_BUFFER_H_
 | 
			
		||||
 | 
			
		||||
#include "resource.h"
 | 
			
		||||
#include "ase.h"
 | 
			
		||||
 | 
			
		||||
class ATL_NO_VTABLE CBuffer : 
 | 
			
		||||
	public CComObjectRootEx<CComSingleThreadModel>,
 | 
			
		||||
	public CComCoClass<CBuffer, &CLSID_Buffer>,
 | 
			
		||||
	public IDispatchImpl<IBuffer, &IID_IBuffer, &LIBID_ASELib>
 | 
			
		||||
{
 | 
			
		||||
private:
 | 
			
		||||
	CComBSTR str;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	CBuffer ();
 | 
			
		||||
	~CBuffer ();
 | 
			
		||||
	
 | 
			
		||||
DECLARE_REGISTRY_RESOURCEID(IDR_AWKBUFFER)
 | 
			
		||||
 | 
			
		||||
DECLARE_PROTECT_FINAL_CONSTRUCT()
 | 
			
		||||
 | 
			
		||||
BEGIN_COM_MAP(CBuffer)
 | 
			
		||||
	COM_INTERFACE_ENTRY(IBuffer)
 | 
			
		||||
	COM_INTERFACE_ENTRY(IDispatch)
 | 
			
		||||
END_COM_MAP()
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	STDMETHOD(get_Value)(/*[out, retval]*/ BSTR *pVal);
 | 
			
		||||
	STDMETHOD(put_Value)(/*[in]*/ BSTR newVal);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										26
									
								
								ase/com/Buffer.rgs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								ase/com/Buffer.rgs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,26 @@
 | 
			
		||||
HKCR
 | 
			
		||||
{
 | 
			
		||||
	ASE.Buffer.1 = s 'ASE Buffer Class'
 | 
			
		||||
	{
 | 
			
		||||
		CLSID = s '{866B79A7-7628-4808-8AE7-784BE2491C80}'
 | 
			
		||||
	}
 | 
			
		||||
	ASE.Buffer = s 'ASE Buffer Class'
 | 
			
		||||
	{
 | 
			
		||||
		CLSID = s '{866B79A7-7628-4808-8AE7-784BE2491C80}'
 | 
			
		||||
		CurVer = s 'ASE.Buffer.1'
 | 
			
		||||
	}
 | 
			
		||||
	NoRemove CLSID
 | 
			
		||||
	{
 | 
			
		||||
		ForceRemove {866B79A7-7628-4808-8AE7-784BE2491C80} = s 'ASE Buffer Class'
 | 
			
		||||
		{
 | 
			
		||||
			ProgID = s 'ASE.Buffer.1'
 | 
			
		||||
			VersionIndependentProgID = s 'ASE.Buffer'
 | 
			
		||||
			ForceRemove 'Programmable'
 | 
			
		||||
			InprocServer32 = s '%MODULE%'
 | 
			
		||||
			{
 | 
			
		||||
				val ThreadingModel = s 'Apartment'
 | 
			
		||||
			}
 | 
			
		||||
			'TypeLib' = s '{F9C69806-16A1-4162-998A-876B33C470BF}'
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										76
									
								
								ase/com/ase.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								ase/com/ase.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,76 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: ase.cpp,v 1.1 2006-12-09 11:50:08 bacon Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// Note: Proxy/Stub Information
 | 
			
		||||
//      To build a separate proxy/stub DLL, 
 | 
			
		||||
//      run nmake -f aseps.mk in the project directory.
 | 
			
		||||
 | 
			
		||||
#include "stdafx.h"
 | 
			
		||||
#include "resource.h"
 | 
			
		||||
#include <initguid.h>
 | 
			
		||||
#include "ase.h"
 | 
			
		||||
 | 
			
		||||
#include "ase_i.c"
 | 
			
		||||
#include "Awk.h"
 | 
			
		||||
#include "Buffer.h"
 | 
			
		||||
#include "AwkExtio.h"
 | 
			
		||||
 | 
			
		||||
CComModule _Module;
 | 
			
		||||
 | 
			
		||||
BEGIN_OBJECT_MAP(ObjectMap)
 | 
			
		||||
OBJECT_ENTRY(CLSID_Awk, CAwk)
 | 
			
		||||
OBJECT_ENTRY(CLSID_Buffer, CBuffer)
 | 
			
		||||
OBJECT_ENTRY(CLSID_AwkExtio, CAwkExtio)
 | 
			
		||||
END_OBJECT_MAP()
 | 
			
		||||
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// DLL Entry Point
 | 
			
		||||
 | 
			
		||||
extern "C"
 | 
			
		||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
 | 
			
		||||
{
 | 
			
		||||
    if (dwReason == DLL_PROCESS_ATTACH)
 | 
			
		||||
    {
 | 
			
		||||
        _Module.Init(ObjectMap, hInstance, &LIBID_ASELib);
 | 
			
		||||
        DisableThreadLibraryCalls(hInstance);
 | 
			
		||||
    }
 | 
			
		||||
    else if (dwReason == DLL_PROCESS_DETACH)
 | 
			
		||||
        _Module.Term();
 | 
			
		||||
    return TRUE;    // ok
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// Used to determine whether the DLL can be unloaded by OLE
 | 
			
		||||
 | 
			
		||||
STDAPI DllCanUnloadNow(void)
 | 
			
		||||
{
 | 
			
		||||
    return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// Returns a class factory to create an object of the requested type
 | 
			
		||||
 | 
			
		||||
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
 | 
			
		||||
{
 | 
			
		||||
    return _Module.GetClassObject(rclsid, riid, ppv);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// DllRegisterServer - Adds entries to the system registry
 | 
			
		||||
 | 
			
		||||
STDAPI DllRegisterServer(void)
 | 
			
		||||
{
 | 
			
		||||
    // registers object, typelib and all interfaces in typelib
 | 
			
		||||
    return _Module.RegisterServer(TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// DllUnregisterServer - Removes entries from the system registry
 | 
			
		||||
 | 
			
		||||
STDAPI DllUnregisterServer(void)
 | 
			
		||||
{
 | 
			
		||||
    return _Module.UnregisterServer(TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										135
									
								
								ase/com/ase.idl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										135
									
								
								ase/com/ase.idl
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,135 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: ase.idl,v 1.1 2006-12-09 11:50:08 bacon Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import "oaidl.idl";
 | 
			
		||||
import "ocidl.idl";
 | 
			
		||||
	
 | 
			
		||||
/* IAwk */
 | 
			
		||||
[
 | 
			
		||||
	object,
 | 
			
		||||
	uuid(05BC1C9F-7C4E-4F77-B186-2E0FD26C0641),
 | 
			
		||||
	dual,
 | 
			
		||||
	helpstring("ASE Awk Interface"),
 | 
			
		||||
	pointer_default(unique)
 | 
			
		||||
]
 | 
			
		||||
interface IAwk : IDispatch
 | 
			
		||||
{
 | 
			
		||||
	[id(1), helpstring("method Parse")] 
 | 
			
		||||
	HRESULT Parse([out, retval] int* ret);
 | 
			
		||||
 | 
			
		||||
	[id(2), helpstring("method Run")] 
 | 
			
		||||
	HRESULT Run([out, retval] int* ret);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* ASELib */
 | 
			
		||||
[
 | 
			
		||||
	uuid(F9C69806-16A1-4162-998A-876B33C470BF),
 | 
			
		||||
	version(1.0),
 | 
			
		||||
	helpstring("ASE 1.0 Type Library")
 | 
			
		||||
]
 | 
			
		||||
library ASELib
 | 
			
		||||
{
 | 
			
		||||
	importlib("stdole32.tlb");
 | 
			
		||||
	importlib("stdole2.tlb");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/* IBuffer */
 | 
			
		||||
	[
 | 
			
		||||
		object,
 | 
			
		||||
		uuid(AD5EA986-37E9-410E-A78E-21799104293A),
 | 
			
		||||
		dual,
 | 
			
		||||
		helpstring("IBuffer Interface"),
 | 
			
		||||
		pointer_default(unique)
 | 
			
		||||
	]
 | 
			
		||||
	interface IBuffer : IDispatch
 | 
			
		||||
	{
 | 
			
		||||
		[propget, id(1), helpstring("property Value")]
 | 
			
		||||
		HRESULT Value([out, retval] BSTR *pVal);
 | 
			
		||||
 | 
			
		||||
		[propput, id(1), helpstring("property Value")]
 | 
			
		||||
		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,
 | 
			
		||||
		uuid(BE0B91FF-9944-4DFC-A55B-1FE14E24AFEE),
 | 
			
		||||
		dual,
 | 
			
		||||
		helpstring("IAwkExtio Interface"),
 | 
			
		||||
		pointer_default(unique)
 | 
			
		||||
	]
 | 
			
		||||
	interface IAwkExtio : IDispatch
 | 
			
		||||
	{
 | 
			
		||||
		[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);*/
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	/* Awk */
 | 
			
		||||
	[
 | 
			
		||||
		uuid(AD863B53-F5EC-45C3-8B1C-6AC678227DC8),
 | 
			
		||||
		helpstring("ASE Awk Class")
 | 
			
		||||
	]
 | 
			
		||||
	coclass Awk
 | 
			
		||||
	{
 | 
			
		||||
		[default] interface IAwk;
 | 
			
		||||
		[default,source] dispinterface IAwkEvents;
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	/* AwkExtio */
 | 
			
		||||
	[
 | 
			
		||||
		uuid(F52F065A-5FD4-4F4D-AFEA-F5E446B16383),
 | 
			
		||||
		helpstring("ASE AwkExtio Class")
 | 
			
		||||
	]
 | 
			
		||||
	coclass AwkExtio
 | 
			
		||||
	{
 | 
			
		||||
		[default] interface IAwkExtio;
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	/* Buffer */
 | 
			
		||||
	[
 | 
			
		||||
		uuid(866B79A7-7628-4808-8AE7-784BE2491C80),
 | 
			
		||||
		helpstring("ASE Buffer Class")
 | 
			
		||||
	]
 | 
			
		||||
	coclass Buffer
 | 
			
		||||
	{
 | 
			
		||||
		[default] interface IBuffer;
 | 
			
		||||
	};
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										126
									
								
								ase/com/ase.rc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										126
									
								
								ase/com/ase.rc
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,126 @@
 | 
			
		||||
//Microsoft Developer Studio generated resource script.
 | 
			
		||||
//
 | 
			
		||||
#include "resource.h"
 | 
			
		||||
 | 
			
		||||
#define APSTUDIO_READONLY_SYMBOLS
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// Generated from the TEXTINCLUDE 2 resource.
 | 
			
		||||
//
 | 
			
		||||
#include "winres.h"
 | 
			
		||||
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
#undef APSTUDIO_READONLY_SYMBOLS
 | 
			
		||||
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// English (U.S.) resources
 | 
			
		||||
 | 
			
		||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
 | 
			
		||||
#pragma code_page(1252)
 | 
			
		||||
#endif //_WIN32
 | 
			
		||||
 | 
			
		||||
#ifdef APSTUDIO_INVOKED
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// TEXTINCLUDE
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
1 TEXTINCLUDE DISCARDABLE 
 | 
			
		||||
BEGIN
 | 
			
		||||
    "resource.h\0"
 | 
			
		||||
END
 | 
			
		||||
 | 
			
		||||
2 TEXTINCLUDE DISCARDABLE 
 | 
			
		||||
BEGIN
 | 
			
		||||
    "#include ""winres.h""\r\n"
 | 
			
		||||
    "\0"
 | 
			
		||||
END
 | 
			
		||||
 | 
			
		||||
3 TEXTINCLUDE DISCARDABLE 
 | 
			
		||||
BEGIN
 | 
			
		||||
    "1 TYPELIB ""ase.tlb""\r\n"
 | 
			
		||||
    "\0"
 | 
			
		||||
END
 | 
			
		||||
 | 
			
		||||
#endif    // APSTUDIO_INVOKED
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifndef _MAC
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// Version
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
VS_VERSION_INFO VERSIONINFO
 | 
			
		||||
 FILEVERSION 1,0,0,1
 | 
			
		||||
 PRODUCTVERSION 1,0,0,1
 | 
			
		||||
 FILEFLAGSMASK 0x3fL
 | 
			
		||||
#ifdef _DEBUG
 | 
			
		||||
 FILEFLAGS 0x1L
 | 
			
		||||
#else
 | 
			
		||||
 FILEFLAGS 0x0L
 | 
			
		||||
#endif
 | 
			
		||||
 FILEOS 0x4L
 | 
			
		||||
 FILETYPE 0x2L
 | 
			
		||||
 FILESUBTYPE 0x0L
 | 
			
		||||
BEGIN
 | 
			
		||||
    BLOCK "StringFileInfo"
 | 
			
		||||
    BEGIN
 | 
			
		||||
        BLOCK "040904B0"
 | 
			
		||||
        BEGIN
 | 
			
		||||
            VALUE "CompanyName", "\0"
 | 
			
		||||
            VALUE "FileDescription", "ASE Module\0"
 | 
			
		||||
            VALUE "FileVersion", "1, 0, 0, 1\0"
 | 
			
		||||
            VALUE "InternalName", "ASE\0"
 | 
			
		||||
            VALUE "LegalCopyright", "Copyright 2006\0"
 | 
			
		||||
            VALUE "OriginalFilename", "ase.dll\0"
 | 
			
		||||
            VALUE "ProductName", "ASE Module\0"
 | 
			
		||||
            VALUE "ProductVersion", "1, 0, 0, 1\0"
 | 
			
		||||
            VALUE "OLESelfRegister", "\0"
 | 
			
		||||
        END
 | 
			
		||||
    END
 | 
			
		||||
    BLOCK "VarFileInfo"
 | 
			
		||||
    BEGIN
 | 
			
		||||
        VALUE "Translation", 0x409, 1200
 | 
			
		||||
    END
 | 
			
		||||
END
 | 
			
		||||
 | 
			
		||||
#endif    // !_MAC
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// REGISTRY
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
IDR_AWK                 REGISTRY DISCARDABLE    "Awk.rgs"
 | 
			
		||||
IDR_AWKBUFFER           REGISTRY DISCARDABLE    "Buffer.rgs"
 | 
			
		||||
IDR_AWKEXTIO            REGISTRY DISCARDABLE    "AwkExtio.rgs"
 | 
			
		||||
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// String Table
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
STRINGTABLE DISCARDABLE 
 | 
			
		||||
BEGIN
 | 
			
		||||
    IDS_PROJNAME            "ASE COM Project"
 | 
			
		||||
END
 | 
			
		||||
 | 
			
		||||
#endif    // English (U.S.) resources
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifndef APSTUDIO_INVOKED
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// Generated from the TEXTINCLUDE 3 resource.
 | 
			
		||||
//
 | 
			
		||||
1 TYPELIB "ase.tlb"
 | 
			
		||||
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
#endif    // not APSTUDIO_INVOKED
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										174
									
								
								ase/com/awk_cp.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										174
									
								
								ase/com/awk_cp.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,174 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: awk_cp.h,v 1.1 2006-12-09 11:50:08 bacon Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _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>
 | 
			
		||||
class CProxyIAwkEvents : public IConnectionPointImpl<T, &DIID_IAwkEvents, CComDynamicUnkArray>
 | 
			
		||||
{
 | 
			
		||||
	//Warning this class may be recreated by the wizard.
 | 
			
		||||
public:
 | 
			
		||||
	LONG Fire_OpenSource(LONG mode)
 | 
			
		||||
	{
 | 
			
		||||
		CComVariant varResult;
 | 
			
		||||
		T* pT = static_cast<T*>(this);
 | 
			
		||||
		int nConnectionIndex;
 | 
			
		||||
		CComVariant* pvars = new CComVariant[1];
 | 
			
		||||
		int nConnections = m_vec.GetSize();
 | 
			
		||||
		
 | 
			
		||||
		for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
 | 
			
		||||
		{
 | 
			
		||||
			pT->Lock();
 | 
			
		||||
			CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
 | 
			
		||||
			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;
 | 
			
		||||
	
 | 
			
		||||
	}
 | 
			
		||||
	LONG Fire_CloseSource(LONG mode)
 | 
			
		||||
	{
 | 
			
		||||
		CComVariant varResult;
 | 
			
		||||
		T* pT = static_cast<T*>(this);
 | 
			
		||||
		int nConnectionIndex;
 | 
			
		||||
		CComVariant* pvars = new CComVariant[1];
 | 
			
		||||
		int nConnections = m_vec.GetSize();
 | 
			
		||||
		
 | 
			
		||||
		for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
 | 
			
		||||
		{
 | 
			
		||||
			pT->Lock();
 | 
			
		||||
			CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
 | 
			
		||||
			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;
 | 
			
		||||
	
 | 
			
		||||
	}
 | 
			
		||||
	LONG Fire_ReadSource (IBuffer* buf)
 | 
			
		||||
	{
 | 
			
		||||
		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*)buf;
 | 
			
		||||
 | 
			
		||||
			DISPPARAMS disp = { args, NULL, 1, 0 };
 | 
			
		||||
			HRESULT hr = pDispatch->Invoke (
 | 
			
		||||
				0x3, 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;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* no event handler attached for the source code read. */
 | 
			
		||||
		/* TODO: set error code ... */
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	LONG Fire_WriteSource (IBuffer* buf)
 | 
			
		||||
	{
 | 
			
		||||
		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*)buf;
 | 
			
		||||
 | 
			
		||||
			DISPPARAMS disp = { args, NULL, 1, 0 };
 | 
			
		||||
			HRESULT hr = pDispatch->Invoke (
 | 
			
		||||
				0x4, 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;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* no event handler attached for the source code write.
 | 
			
		||||
		 * make the operation succeed by returning the reqested 
 | 
			
		||||
		 * data length. */ 
 | 
			
		||||
		CComBSTR bstr;
 | 
			
		||||
		buf->get_Value (&bstr);
 | 
			
		||||
		return bstr.Length();
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										19
									
								
								ase/com/resource.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								ase/com/resource.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
//{{NO_DEPENDENCIES}}
 | 
			
		||||
// Microsoft Developer Studio generated include file.
 | 
			
		||||
// Used by ase.rc
 | 
			
		||||
//
 | 
			
		||||
#define IDS_PROJNAME                    100
 | 
			
		||||
#define IDR_AWK                         101
 | 
			
		||||
#define IDR_AWKBUFFER                   102
 | 
			
		||||
#define IDR_AWKEXTIO                    104
 | 
			
		||||
 | 
			
		||||
// Next default values for new objects
 | 
			
		||||
// 
 | 
			
		||||
#ifdef APSTUDIO_INVOKED
 | 
			
		||||
#ifndef APSTUDIO_READONLY_SYMBOLS
 | 
			
		||||
#define _APS_NEXT_RESOURCE_VALUE        201
 | 
			
		||||
#define _APS_NEXT_COMMAND_VALUE         32768
 | 
			
		||||
#define _APS_NEXT_CONTROL_VALUE         201
 | 
			
		||||
#define _APS_NEXT_SYMED_VALUE           105
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										12
									
								
								ase/com/stdafx.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								ase/com/stdafx.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
// stdafx.cpp : source file that includes just the standard includes
 | 
			
		||||
//  stdafx.pch will be the pre-compiled header
 | 
			
		||||
//  stdafx.obj will contain the pre-compiled type information
 | 
			
		||||
 | 
			
		||||
#include "stdafx.h"
 | 
			
		||||
 | 
			
		||||
#ifdef _ATL_STATIC_REGISTRY
 | 
			
		||||
#include <statreg.h>
 | 
			
		||||
#include <statreg.cpp>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <atlimpl.cpp>
 | 
			
		||||
							
								
								
									
										27
									
								
								ase/com/stdafx.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								ase/com/stdafx.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,27 @@
 | 
			
		||||
// stdafx.h : include file for standard system include files,
 | 
			
		||||
//      or project specific include files that are used frequently,
 | 
			
		||||
//      but are changed infrequently
 | 
			
		||||
 | 
			
		||||
#if !defined(AFX_STDAFX_H__D5DBF84D_6B4D_4C38_AD19_6B4208C02215__INCLUDED_)
 | 
			
		||||
#define AFX_STDAFX_H__D5DBF84D_6B4D_4C38_AD19_6B4208C02215__INCLUDED_
 | 
			
		||||
 | 
			
		||||
#if _MSC_VER > 1000
 | 
			
		||||
#pragma once
 | 
			
		||||
#endif // _MSC_VER > 1000
 | 
			
		||||
 | 
			
		||||
#define STRICT
 | 
			
		||||
#ifndef _WIN32_WINNT
 | 
			
		||||
#define _WIN32_WINNT 0x0400
 | 
			
		||||
#endif
 | 
			
		||||
#define _ATL_APARTMENT_THREADED
 | 
			
		||||
 | 
			
		||||
#include <atlbase.h>
 | 
			
		||||
//You may derive a class from CComModule and use it if you want to override
 | 
			
		||||
//something, but do not change the name of _Module
 | 
			
		||||
extern CComModule _Module;
 | 
			
		||||
#include <atlcom.h>
 | 
			
		||||
 | 
			
		||||
//{{AFX_INSERT_LOCATION}}
 | 
			
		||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
 | 
			
		||||
 | 
			
		||||
#endif // !defined(AFX_STDAFX_H__D5DBF84D_6B4D_4C38_AD19_6B4208C02215__INCLUDED)
 | 
			
		||||
		Reference in New Issue
	
	Block a user