1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
// foo.h
#include <vector>
#include <stdio.h>
#define std_default_vector std::vector
template <class T>
class FOO
{
public:
typedef std_default_vector<T> vector;
class MyVec;
class BlaBla {};
};
template <class T>
class std_vector : public FOO<T>::vector { };
template<class T>
class MyStdVector : public std_default_vector<T>
{
};
template <class T>
class FOO<T>::MyVec : public std::vector<T>
{
};
#define std_vector MyStdVector
class GOO;
typedef std_vector<GOO*> GooList;
class GOO {
public:
GOO(void) {};
GOO(const GOO &, int = 0) {};
virtual void m(void);
static void m(GooList& glist);
virtual int m2(void);
};
// foo.cpp
int main(int argc, char **argv)
{
printf ("IntroInAll: tests intros into \"%%\"\n");
printf ("=============================================================\n");
printf ("it is OK if it compiles!\n");
GooList glist;
GOO::m(glist);
printf ("=============================================================\n");
}
void GOO::m(GooList &glist)
{
GooList::const_iterator idx = glist.begin();
for (; idx != glist.end(); idx++)
(*idx)->m();
int sorted = 1;
for (; sorted < (int)glist.size(); sorted++)
{
GOO* tmp = glist[sorted];
int index = sorted - 1;
while (index >= 0)
{
GOO* current = glist[index];
if (tmp->m2() > current->m2())
break;
glist[index+1] = glist[index];
index--;
}
glist[index+1] = tmp;
}
}
void GOO::m(void)
{
}
int GOO::m2(void)
{
return 1;
}
// foo.ah
aspect Trace
{
pointcut all() = "%";
advice all() : void *fAttr;
advice all() : void *getAttr(void)
{
return fAttr;
}
advice all() : void setAttr(void* attr)
{
fAttr = attr;
}
advice construction (all ()) : after ()
{
void *attr = 0;
// compute attr
tjp->target()->setAttr(attr);
}
advice call ("virtual % ...::%(...)") : before ()
{
void *selfAttr = tjp->target()->getAttr();
void *myAttr = (void *)1;
// compare selfAttr & myAttr
}
};
|