[aspectc-user] Problems with aspect inheritance

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Thu Nov 9 11:36:41 CET 2006


Hi,

you should always use include guards in your aspect header files, e.g.

#ifndef __AspectA0_ah__
#define __AspectA0_ah__
...
#endif

This should solve your current problem.

Regarding the semantics of virtual and pure virtual pointcuts: This is a
compile time concept. It is not related to dynamic dispatch. Its only
purpose is the postponement of the decision *where* some advice should
affect the component code. This allows programmers to write more
abstract aspects. You are right that syntax and semantics of this
language feature do not fit very well. It was introduced, because this
is the way how AspectJ implements this feature, too. Today, I would
prefer a different syntax, e.g. support for aspect templates that accept
pointcuts as template arguments (-> compile time!), but now it is as it
is...

Olaf

Panu Bloigu schrieb:
> Hello again you all!
>
> This time my question concerns aspect inheritance. I have hard time getting
> a project with the following aspects to compile.
>
>
> =================
> File: AspectA0.ah
> =================
> aspect AspectA0
> {
>         pointcut virtual pc() = 0;
> };
>
> =================
> File: AspectA1.ah
> =================
> #include <iostream>
> #include "AspectA0.ah"
> aspect AspectA1 : public AspectA0
> {
>
>         pointcut pc() = "% ClassA0::%(...)";
>
>         advice call(pc()) : around()
>         {
>                 std::cout<<"Before...\n";
>                 tjp->proceed();
>                 std::cout<<"\nAfter...\n";
>         }
> };
>
> In addition to these I have the declaration of ClassA0 in ClassA0.h and and
> the definition in ClassA0.cpp. Then, of course, I have a main.cpp in which I
> call one of the ClassA0's methods. I'm trying to compile this project in
> Eclipse 3.1.2 with the latest AspectC++ plugin. This is what the compiler
> leaves me with:
>
> =================
> **** Full rebuild of configuration Debug for project Demo ****
>
> make -k clean all
> rm -rf  ./ClassA0.o ./main.o  ./ClassA0.d ./main.d Demo repo.acp puma.config
>
> Building puma.config
> "/opt/eclipse-3.1.2/plugins/org.aspectc.compiler.linux_0.9.93/AC/ag++"
> --gen_config -o puma.config
>
> Building file: ../ClassA0.cpp
> Invoking: GCC C++ Compiler
> /opt/eclipse-3.1.2/plugins/org.aspectc.compiler.linux_0.9.93/AC/ag++
> --c_compiler g++ --keep_acc -k -r repo.acp -p .. -c ../ClassA0.cpp
> --Xcompiler -o ClassA0.o -D_useAC -O0 -g3 -Wall -fmessage-length=0 -I..
> .../AspectA0.ah:1: error: redefinition of `AspectA0'
> .../AspectA0.ah:1: previously defined here
> .../AspectA0.ah:1: error: wrong use of `AspectA0'
> error: Execution failed:
> "/opt/eclipse-3.1.2/plugins/org.aspectc.compiler.linux_0.9.93/AC/ac++"
> --config "puma.config"  -k -rrepo.acp -p".." -D"_useAC" -I".." -c
> "../ClassA0.cpp" -o "ClassA0.acc"
> make: *** [ClassA0.o] Error 1
> Building file: ../main.cpp
> Invoking: GCC C++ Compiler
> /opt/eclipse-3.1.2/plugins/org.aspectc.compiler.linux_0.9.93/AC/ag++
> --c_compiler g++ --keep_acc -k -r repo.acp -p .. -c ../main.cpp --Xcompiler
> -o main.o -D_useAC -O0 -g3 -Wall -fmessage-length=0 -I..
> .../AspectA0.ah:1: error: redefinition of `AspectA0'
> .../AspectA0.ah:1: previously defined here
> .../AspectA0.ah:1: error: wrong use of `AspectA0'
> error: Execution failed:
> "/opt/eclipse-3.1.2/plugins/org.aspectc.compiler.linux_0.9.93/AC/ac++"
> --config "puma.config"  -k -rrepo.acp -p".." -D"_useAC" -I".." -c
> "../main.cpp" -o "main.acc"
> make: *** [main.o] Error 1
> make: Target `all' not remade because of errors.
> Build complete for project Demo
> =================
>
> What is the problem here? I presume there's probably just some little detail
> I'm missing, but I just don't seem to be able to figure it out.
>
> Also, what it the exact semantics of virtual, pure virtual and regular
> pointcuts in relation to aspect inheritance? I understand that in C++ the
> essence of virtual methods lies in dynamic binding, but I fail to see how
> dynamic binding would relate to pointcut definitions. After all, they seem
> like something that does not exist in runtime, no? Or do I understand some
> very basic thing very wrong here?
>
> Thank you for your answers.
>
> Panu.
>
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user
>   




More information about the aspectc-user mailing list