[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

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 ();


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
#ifndef _C_H_
#define _C_H_

class C
    class D { };

    void foo ();
    void foo (D *pD);

#include "C.h"

void C::foo ()
  D d;
  foo (&d);

void C::foo (D *pD) { }
#ifndef _C_AH_
#define _C_AH_

aspect AspC
    pointcut methods () = call ("% C::%(...)");

    advice methods () : before () { }

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.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