[aspectc-user] one more bug (private classes)
Leandro Costa
leandro.costa at gmail.com
Wed Dec 3 22:14:07 CET 2008
Now I have problems with private classes:
* C is my main class;
* D is a private class declared inside C;
* if, inside a method of class C, I declare an object of class D and use it
as parameter for another method, AspectC++ will generate invalid source
code.
The problem is that AspectC++ generates a procedure to be called inside the
first method, and this procedure can't access the private class D:
__attribute__((always_inline)) inline void __call__ZN1C3fooEv_0_0 (::C
*srcthis, void (::C::* fptr)(::C::D *), ::C *dstthis, ::C::D * arg0){
AC::invoke_AspC_AspC_a0_before ();
(dstthis->*fptr)(arg0);
}
---
The workaround is don't include methods that receive private classes as
paremeters in your pointcuts:
...
pointcut methods () = call ("% C::%(...)" && ! "void C::foo (C::D*)");
...
---
leandro.costa at hydrus:~/personal/aspects/bug2> more C.h C.cc C.ah
::::::::::::::
C.h
::::::::::::::
#ifndef _C_H_
#define _C_H_
class C
{
private:
class D { };
void foo ();
void foo (D *pD);
};
#endif
::::::::::::::
C.cc
::::::::::::::
#include "C.h"
void C::foo ()
{
D d;
foo (&d);
}
void C::foo (D *pD) { }
::::::::::::::
C.ah
::::::::::::::
#ifndef _C_AH_
#define _C_AH_
aspect AspC
{
public:
pointcut methods () = call ("% C::%(...)");
advice methods () : before () { }
};
#endif
leandro.costa at hydrus:~/personal/aspects/bug2> ac++ -v1 -k -p . --config
puma.config -c C.cc -o C.acc -a C.ah
* Running ac++ 1.0pre4 svn
* Handling Translation Unit `C.cc'.
* Inserting unit pro- and epilogues
* Updating #line directives of generated code fragments
* Saving
* Done
leandro.costa at hydrus:~/personal/aspects/bug2> g++ -O -x c++ -g -Wall -Werror
-c C.acc -o C.o
C.h: In function `void __call__ZN1C3fooEv_0_0(C*, void (C::*)(C::D*), C*,
C::D*)':
C.h:7: error: `class C::D' is private
C.acc:134: error: within this context
C.h:7: error: `class C::D' is private
C.acc:134: error: within this context
leandro.costa at hydrus:~/personal/aspects/bug2>
--
_____________________________________________
Leandro Souza Costa
"A vitória se encastela em jardins encantadores,
mas para se chegar a ela não há caminho de flores"
_____________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.aspectc.org/pipermail/aspectc-user/attachments/20081203/a54b5a54/attachment.html>
More information about the aspectc-user
mailing list