[aspectc-user] Re: Error "1><anonymous unit>(1): error: invalid declaration near token `:'"
Olaf Spinczyk
Olaf.Spinczyk at informatik.uni-erlangen.de
Fri Jan 12 10:00:01 CET 2007
Thanks Luigi!
==> Bug 329
Olaf
Olaf Spinczyk wrote:
> Hi Luigi,
>
> an error in an "ananymous unit" indicates that ac++ with unable to parse
> the code which it had generated itself. This should never happen. In
> this sense you have found an ac++ bug.
>
> The actual reason for the error message is that the class "Subject" does
> not exist. The advice ...
>
>>> advice realsubjects(): slice class: public Subject {};
>
> ... introduces a base class "Subject" into all classes described by
> "realsubjects()". If this class does not exist, the generated code
> cannot be parsed.
>
> I will write a bug report that recommends to check whether introduced
> classes do really exists.
>
> Best regards,
>
> Olaf
>
>
> Luigi 'Comio' Mantellini wrote:
>> I have deleted the baseclass injection... now the code is ok... in any
>> case I haven't understood the problem...
>>
>> ciao
>>
>> luigi
>>
>> 2007/1/12, Luigi 'Comio' Mantellini <luigi.mantellini at gmail.com>:
>>> Dear all,
>>>
>>> I'm trying to write a AspectC++ version of Proxy Pattern, but I have
>>> the following error:
>>>
>>> 1><anonymous unit>(1): error: invalid declaration near token `:'
>>>
>>> I don't know where I have made the mistake... can you help me to
>>> understand the error?
>>> (I'm using the trial version of AspectC++ plugin for VC).
>>>
>>> Thanks in advance
>>>
>>> luigi
>>>
>>> (the code...)
>>>
>>> [code]
>>> # aabstractproxy.ah
>>> #ifndef __AABSTRACTPROXY_H__
>>> #define __AABSTRACTPROXY_H__
>>>
>>> #pragma once;
>>>
>>> aspect AAbstractProxy {
>>>
>>> protected:
>>> pointcut virtual callers() = "%"; // Chiamanti che devono
>>> attraversare il proxy
>>> pointcut virtual requests() = 0; // Metodi da monitorare
>>> pointcut virtual realsubjects() = 0; // Classi che effettuano
>>>
>>> private:
>>> advice realsubjects(): slice class: public Subject {};
>>>
>>> //
>>> public:
>>> advice requests() /*&& target(callers()) &&
>>> that(realsubjects()) */ :
>>> around() {
>>> if (! isProxyProtected(/*tjp*/) ) {
>>> tjp->proceed();
>>> } else {
>>> handleProxyProtection(/*tjp*/);
>>> }
>>> };
>>>
>>> protected:
>>> virtual bool isProxyProtected(/*JoinPoint *tjp*/) = 0;
>>> virtual void handleProxyProtection(/*JoinPoint *tjp*/) {
>>> return;
>>> };
>>> };
>>>
>>> #endif
>>> [/code]
>>>
>>> [code]
>>> // arequestblocking.h
>>>
>>> #ifndef __AREQUESTBLOCKING_H__
>>> #define __AREQUESTBLOCKING_H__
>>>
>>> #pragma once
>>>
>>> #include <iostream>
>>>
>>> #include "aabstractproxy.ah"
>>>
>>> using namespace std;
>>>
>>> aspect ARequestBlocking: public AAbstractProxy {
>>>
>>> protected:
>>> pointcut virtual realsubjects() = "OutputImplementation";
>>> pointcut virtual requests() = call("% unsafeRequest(...)");
>>> pointcut virtual callers() = "ProxyTestClass";
>>>
>>> bool isProxyProtected(/*JoinPoint *tjp*/) {
>>> cout << "[RequestBlocking] intercepting unsafe
>>> " << endl;
>>> return true;
>>> };
>>> };
>>>
>>> #endif
>>> [/code]
>>>
>>> [code]
>>> #ifndef __TESTPROXY_H__
>>> #define __TESTPROXY_H__
>>>
>>> #pragma once
>>>
>>> #include <iostream>
>>> #include "aabstractproxy.ah"
>>> #include "requestblocking.ah"
>>>
>>> using namespace std;
>>>
>>> class OutputImplementation {
>>>
>>> public:
>>> void safeRequest(char *s) {
>>> cout << "[OutputImplementation.safeRequest()]: " << s
>>> << endl;
>>> }
>>>
>>> void regularRequest(char *s) {
>>> cout << "[OutputImplementation.regularRequest()]: " <<
>>> s << endl;
>>> }
>>>
>>> void unsafeRequest(char *s) {
>>> cout << "[OutputImplementation.unsafeRequest()]: " <<
>>> s << endl;
>>> }
>>> };
>>>
>>>
>>> class ProxyTestMain {
>>>
>>> public: starttest() {
>>>
>>> OutputImplementation *real = new OutputImplementation();
>>>
>>> cout << "\n===> Issuing SAFE request..." << endl;
>>> real->safeRequest("Safe Reqeust");
>>> cout << "\n===> Issuing REGULAR request..." << endl;
>>> real->regularRequest("Normal Request");
>>> cout << "\n===> Issuing UNSAFE request..." << endl;
>>> real->unsafeRequest ("Unsafe Request");
>>> cout << "\n===> Issuing SAFE request..." << endl;
>>> real->safeRequest("Safe Reqeust");
>>> cout << "\n===> Issuing REGULAR request..." << endl;
>>> real->regularRequest("Normal Request");
>>> cout << "\n===> Issuing UNSAFE request..." << endl;
>>> real->unsafeRequest ("Unsafe Request");
>>> }
>>> };
>>>
>>> void testProxy() {
>>> ProxyTestMain *m=new ProxyTestMain();
>>> m->starttest();
>>> cout << "Start Proxt Pattern testing..." << endl;
>>> }
>>>
>>> #endif
>>> [/code]
>>>
>>>
>>>
>>> --
>>> Luigi 'Comio' Mantellini
>>>
>>> The three laws of users:
>>>
>>> 1. A user may not injure a sysadmin, or through inaction,
>>> allow a sysadmin to come to harm.
>>> 2. A user must obey the orders given it by sysadmins except
>>> where such orders would conflict with the First Law.
>>> 3. A user must protect its own existence as long as such
>>> protection does not conflict with the First or Second Law.
>>>
>>
>
> _______________________________________________
> 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