[aspectc-user] intercepting flow of execution of the method declared inside aspect

Bartosz Blimke masb at chorwacja.com
Wed May 26 16:34:21 CEST 2004


Hi,

I have been trying instead of calling tjp->proceed() in advice,
to call the function(which takes an AC::Action argument) inside advice,
and then call action.trigger() inside this function.
This works.
Then I tried to intercept the flow of this function
I found the problem.

Problem exists when I try to intercept the flow
of a method declared inside aspect.

Here is the simplified example:

main.cpp

int main()
{
	return 0;
}

aspect.ah

#ifndef _Aspect_
#define _Aspect_

aspect Aspect
{
	void function2()
	{
	}

	advice
		execution( "% main(...)" )
		|| cflow (execution( "% %function2(...)" ) )
	: around()
	{
		tjp->proceed();
	}
};
#endif //_Aspect_


The problem is with cflow (execution( "% %function2(...)" ))  pointcut.
If I will remove cflow pointcut everything works ok.

weaving ... .\main.cpp -> Debug\main.cpp
compiling ... main.cpp
generating ... Debug/TestAspectProject_LinkOnce.cpp
compiling ... TestAspectProject_LinkOnce.cpp
Linking...
main.obj : error LNK2005: "public: __thiscall `private: static void
__cdecl Aspect::__action_exec__ZN6Aspect9function2Ev_0(struct AC::Action
&)'::`3'::Trigger::Trigger(void)"
(??0Trigger@?2??__action_exec__ZN6Aspect9function2Ev_0 at Aspect@@CAXAAUAction at AC@@@Z at QAE@XZ)
already defined in TestAspectProject_LinkOnce.obj
main.obj : error LNK2005: "public: __thiscall `private: static void
__cdecl Aspect::__action_exec__ZN6Aspect9function2Ev_0(struct AC::Action
&)'::`3'::Trigger::~Trigger(void)"
(??1Trigger@?2??__action_exec__ZN6Aspect9function2Ev_0 at Aspect@@CAXAAUAction at AC@@@Z at QAE@XZ)
already defined in TestAspectProject_LinkOnce.obj
Debug\TestAspectProject.exe : fatal error LNK1169: one or more multiply
defined symbols found


If I will put the function2() outside the aspect
it throws another errors:

Aspect.ah(39) : error C2027: use of undefined type 'Aspect'
Aspect.ah(5) : see declaration of 'Aspect'
Aspect.ah(39) : error C2065: '__cflow_a0_around_0' : undeclared identifier
Aspect.ah(42) : error C2027: use of undefined type 'Aspect'
Aspect.ah(5) : see declaration of 'Aspect'
Aspect.ah(42) : error C3861: '__cflow_a0_around_0': identifier not found,
even with argument-dependent lookup
Compiler failed for main.cpp


If function2() is declared in main.cpp everything works ok.

The problem is that I want to call this function
from advice, so I need it inside the aspect.
And then I want to intercept the flow of execution
of this function.


Bartosz Blimke
masb at chorwacja.com






More information about the aspectc-user mailing list