From 7bf5378bec2ed162969b82f53b1cd6611842ef0a Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:13:22 +0000 Subject: Utilisateur : Fcolin Date : 3/10/02 Heure : 10:55 Créé Commentaire: (vss 1) --- comIvy/Expression.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 comIvy/Expression.cpp (limited to 'comIvy/Expression.cpp') diff --git a/comIvy/Expression.cpp b/comIvy/Expression.cpp new file mode 100644 index 0000000..468a431 --- /dev/null +++ b/comIvy/Expression.cpp @@ -0,0 +1,65 @@ +// Expression.cpp : implémentation de CExpression + +#include "stdafx.h" +#include "Bus.h" +#include "Ivy.h" +#include "IvyApplication.h" + +#include "Expression.h" + + +char * ConvBSTR( BSTR str ); +BSTR ConvCSTR( const char *str ); + +// CExpression + + +STDMETHODIMP CExpression::Unbind(void) +{ + if ( !bus ) return E_FAIL; + if ( bus->bus ) + bus->bus->UnbindMsg( id ); + bus->Release(); + return S_OK; +} + +void CExpression::OnMessage(IvyApplication * app, int argc, const char ** argv) +{ + BSTR appname = ConvCSTR( app->GetName() ); + SAFEARRAY *pArrayVal = NULL; + HRESULT hr = S_OK; + + //Create the safe array for the arguments string. + pArrayVal = SafeArrayCreateVector( VT_VARIANT, 0, argc ); + + if (!(pArrayVal == NULL) ) + { + // Set the values for each element of the array + for( long i = 0 ; i < argc && SUCCEEDED( hr );i++) + { + hr = SafeArrayPutElement(pArrayVal, &i, new CComVariant(ConvCSTR(argv[i]))); + } + + } + VARIANT args; + args.vt = VT_ARRAY | VT_VARIANT; + args.parray = pArrayVal; + + Received( appname, args ); + + SafeArrayDestroy(pArrayVal); +} +// CExpression +CExpression::CExpression() +{ + id = -1; + bus = 0; + ATLTRACE("CExpression created\n"); +} +CExpression::~CExpression() +{ + Unbind(); + id = -1; + bus = 0; + ATLTRACE("CExpression destroyed\n"); +} -- cgit v1.1 From ee1d4ac1c341aa9cdecbab89933c0658228d38c4 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:13:23 +0000 Subject: Utilisateur : Fcolin Date : 18/04/03 Heure : 15:43 Archivé dans $/Bus/comIvy Commentaire: ajout GetDomain (vss 2) --- comIvy/Expression.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'comIvy/Expression.cpp') diff --git a/comIvy/Expression.cpp b/comIvy/Expression.cpp index 468a431..9a856a7 100644 --- a/comIvy/Expression.cpp +++ b/comIvy/Expression.cpp @@ -28,7 +28,7 @@ void CExpression::OnMessage(IvyApplication * app, int argc, const char ** argv) BSTR appname = ConvCSTR( app->GetName() ); SAFEARRAY *pArrayVal = NULL; HRESULT hr = S_OK; - + // pour assurer la compatibilite avec VBSCript pouah horreur //Create the safe array for the arguments string. pArrayVal = SafeArrayCreateVector( VT_VARIANT, 0, argc ); @@ -43,12 +43,13 @@ void CExpression::OnMessage(IvyApplication * app, int argc, const char ** argv) } VARIANT args; args.vt = VT_ARRAY | VT_VARIANT; - args.parray = pArrayVal; + V_ARRAY(&args) = pArrayVal; Received( appname, args ); SafeArrayDestroy(pArrayVal); } + // CExpression CExpression::CExpression() { -- cgit v1.1 From ef9c20abbfe852cc90c7bbd17c04549f7de3dad3 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:13:25 +0000 Subject: Utilisateur : Fcolin Date : 7/06/04 Heure : 10:56 Archivé dans $/Bus/comIvy Commentaire: (vss 3) --- comIvy/Expression.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'comIvy/Expression.cpp') diff --git a/comIvy/Expression.cpp b/comIvy/Expression.cpp index 9a856a7..9287bae 100644 --- a/comIvy/Expression.cpp +++ b/comIvy/Expression.cpp @@ -12,13 +12,28 @@ char * ConvBSTR( BSTR str ); BSTR ConvCSTR( const char *str ); // CExpression - +STDMETHODIMP CExpression::Bind(char* regex, CBus* _bus) +{ + if ( !_bus ) return E_FAIL; + bus = _bus; + bus->AddRef(); + if ( id != -1 ) + return E_FAIL; + if ( bus->bus ) + id = bus->bus->BindMsg( regex, this ); + else return E_FAIL; + return S_OK; +} STDMETHODIMP CExpression::Unbind(void) { if ( !bus ) return E_FAIL; - if ( bus->bus ) + if ( bus->bus && id != -1 ) + { bus->bus->UnbindMsg( id ); + id = -1; + } + else return E_FAIL; bus->Release(); return S_OK; } @@ -59,7 +74,8 @@ CExpression::CExpression() } CExpression::~CExpression() { - Unbind(); + if ( id != -1 ) + Unbind(); id = -1; bus = 0; ATLTRACE("CExpression destroyed\n"); -- cgit v1.1