<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
Hi!<br>
<br>
I'll comment the three problems below ...<br>
<br>
On 04/26/2011 03:18 PM, sh jalilian wrote:
<blockquote cite="mid:403671.21411.qm@web114705.mail.gq1.yahoo.com"
type="cite">
<style type="text/css"><!-- DIV {margin:0px;} --></style>
<div
style="font-family: 'times new roman','new york',times,serif; font-size: 12pt;">
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;">hi
dear</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;">Recently
I have reported a problem about args() and I test your solution but yet
there is some problems I want to report here:</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;">------------------
main code -------------------------------</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;">void
f1(int i, char *str) {}</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;">void
main()</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;">{</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;">f1(1,
"test");</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;">}</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;">------------------
aspect code -------------------------------</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;">aspect
A1{</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;"><span
class="Apple-tab-span" style="white-space: pre;"> </span>advice
call("% f%(...)") : after() {</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;"><span
class="Apple-tab-span" style="white-space: pre;"> </span> cout
<< "int value= " << *(int *)tjp->arg(0) << "char *
string= " << (char *)tjp->arg(1) << endl;</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;"><span
class="Apple-tab-span" style="white-space: pre;"></span><span
class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;">};</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;"> problem
1) -----------------</div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;">arg(0)
output is OK for int type but arg(1) does not work for "char *" and </div>
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;">-------------------------------------------------------------------</div>
</div>
</blockquote>
<br>
tjp->arg(1) points to a char* object. Therefore, it has to be casted
to (char**). Then the pointer has to be dereferenced:<br>
<br>
cout ... << *(char**)tjp->arg(1) ...<br>
<br>
Alternatively, you could use the type-safe variant:<br>
<br>
cout ... << *tjp->arg<1>() ...<br>
<br>
<blockquote cite="mid:403671.21411.qm@web114705.mail.gq1.yahoo.com"
type="cite">
<div
style="font-family: 'times new roman','new york',times,serif; font-size: 12pt;">
<div
style="color: black; font-family: 'times new roman','new york',times,serif; font-size: 12pt;">problem
2) ----------------------------------------------</div>
<div><font class="Apple-style-span" size="3"
face="'times new roman', 'new york', times, serif">function args() can
return arguments (you should specify all arguments in args() ) but
args() has problem when you want to use by "within" </font><font
class="Apple-style-span"
face="'times new roman', 'new york', times, serif">statement: </font></div>
<div><font class="Apple-style-span"
face="'times new roman', 'new york', times, serif">aspect A2{</font></div>
<div><font class="Apple-style-span"
face="'times new roman', 'new york', times, serif"><span
class="Apple-tab-span" style="white-space: pre;"> </span>pointcut PC1
= call("% f%(int i, char *s)") && !within("A2") &&
args(i, s);</font></div>
<div><font class="Apple-style-span"
face="'times new roman', 'new york', times, serif"><span
class="Apple-tab-span" style="white-space: pre;"> </span>advice
PC1(i, s) : after(</font><span class="Apple-style-span"
style="font-family: 'times new roman','new york',times,serif;">int i,
char *s) {</span></div>
<div><span class="Apple-style-span"
style="font-family: 'times new roman','new york',times,serif;"><span
class="Apple-tab-span" style="white-space: pre;"> </span>cout
<< "func call" << endl;</span></div>
<div><span class="Apple-style-span"
style="font-family: 'times new roman','new york',times,serif;"><span
class="Apple-tab-span" style="white-space: pre;"> </span>f1(5,
"test2");</span></div>
<div><span class="Apple-style-span"
style="font-family: 'times new roman','new york',times,serif;"><span
class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div>
<div><font class="Apple-style-span"
face="'times
new roman', 'new york', times, serif">}</font></div>
</div>
</blockquote>
<br>
Your aspect is syntactically wrong. Here is the corrected version:<br>
<br>
aspect A2{<br>
pointcut PC1(int i, char *s) = call("% f%(int, char *)") &&
!within("A2") && args(i, s);<br>
advice PC1(i, s) : after(int i, char *s) {<br>
cout << "func call" << endl;<br>
f1(5, "test2");<br>
}<br>
};<br>
<br>
I tried it and it works as expected.<br>
<br>
<blockquote cite="mid:403671.21411.qm@web114705.mail.gq1.yahoo.com"
type="cite">
<div
style="font-family: 'times new roman','new york',times,serif; font-size: 12pt;">
<div><font class="Apple-style-span"
face="'times new roman', 'new york', times, serif">----------------------------------------------------------------------------</font></div>
<div><font class="Apple-style-span"
face="'times new roman', 'new york', times, serif">problem 3) a
general bug in Aspectc is that it is not capture joinpoints such as
"unsigned char" objects.</font></div>
</div>
</blockquote>
<br>
What does that mean? Could you give me a concrete example? "unsigned
char objects" are no joinpoints in the AspectC++ joinpoint model.<br>
<br>
Best regards,<br>
<br>
Olaf<br>
<br>
</body>
</html>