[aspectc-user] aspect inheritance
Jamal Siadat
siadat at cpsc.ucalgary.ca
Thu Jul 14 09:15:29 CEST 2005
Hi,
Thanks for the reply. But I thought that if the base C++ code is correct
and the aspect written is correct. Then the woven/compiled code in ac++
would be correct as well. And in this case I actually have the ac++
compiler compiling it. But its g++ which picks up the errors ( so
basically the ac++ compiler is not generating the correct code). I would
imagine that in these scenarios either the ac++ compiler would:
A) Not compile/weave my code in the base code Or
B) Somehow it would produce an explicit constructor for the aspect which
makes use of the super class's constructor
It's just a suggestion..
Thanks again fabian :)
P.S: did anyone have a look at the bug I posted earlier? do you get the
some output too? because I was thinking may be because of the different
ac++ versions...
> Hi,
>
> the explanation for the error message is as follows:
> AspectC++ transforms aspects into classes and by default such a class
> is instantiated once in global scope, so the constructor of the
> particular aspect class has to be called. In your aspect you did not
> specify any constructor at all, so the default constructor is used for
> this purpose. Now your aspects inherits from class A, t.m. the
> constructor of class A has to be executed, too, again the default
> constructor is used (how should the C++-compiler know which
> constructor to use, if you did not specify it, and you did not specify
> it, because your aspect does not provide a constructor). And this
> default constructor of class A is not available, because you defined
> another one with a different signature (t.m. your constructor takes an
> argument, while the default constructor does not).
>
> possible solution:
> - define a constructor for your aspect 'asp'
> - specify the constructor to be used for the construction of
> 'A'-Objects within the constructor of aspect 'asp'
> - define a method 'asp* asp:aspectof()' that instantiates your aspect
> using the user-defined constructor
>
> Ciao, Fabian
>
> On 7/14/05, Jamal Siadat <siadat at cpsc.ucalgary.ca> wrote:
>> Hi,
>> I have tried to add a methods to a class using aspects. It works really
>> fine when the constructor of the class that I'm adding the methods to
>> does
>> not take any arguments. But When the constructor is taking arguments for
>> some reason the weaving process is not performed correctly. Here is an
>> example of what I mean:
>>
>> aspect file (asp.ah):
>>
>>
>> aspect asp :public A {
>> pointcut calls()= "A" ;
>> advice calls() : void initialize () {p=0;j=0;}
>> };
>>
>> A.h:
>> class A {
>> public:
>> A(int x);
>> int j;
>> int a(const char *name, float b);
>> private:
>> int p;
>> };
>>
>> A.cc:
>>
>> A::A(int x) {j=x; }
>>
>> int A::a( const char *name, float b) {
>> int jam=7;
>> return jam;
>> }
>>
>> int main (){
>> A b(5);
>> return 0;}
>>
>> now if you run "ag++ -o t A.cc -a asp.ah" the weaving process works fine
>> but you'll have the following c++ errors:
>>
>> asp.ah:7: error: base `A' with only non-default constructor in class
>> without a constructor
>> : In static member function `static asp* asp::aspectof()':
>> :4: error: no matching function for call to `asp::asp()'
>> asp.ah:7: error: candidates are: asp::asp(const asp&)
>>
>> does anyone know how to get around this? I know you can remove public A
>> and then it wont give you this error but you wont be able to access the
>> variables in A! so I need to inherite A.
>>
>> Thanks in advance
>>
>>
>>
>>
>> _______________________________________________
>> 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