You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(6) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(3) |
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
(11) |
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
(1) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <HG...@gm...> - 2010-12-07 12:16:59
|
Hello Iwan! First: thanks for the link to the AspectX.xsd file. I want to use xweaver to add tracing to a C project. And I try to understand XWeaver but I'm not really familiar with XSL and XPath. I have a more complex problem: I need a new pointcut: something like after_function_declarations I modified the TraceAspectStd.ax example: <pointcut name="allFunctions" type="src:function"> <description>Points to the all methods.</description> </pointcut> <advice type="begin" name="enterFunction"> <description>Weave the log message at the beginning of every function.</description> <pointcutRef ref="allFunctions" type="src:function"/> <codeModifier type="codeFragment"> <text>logTrace("${filename}", "${functionName} - Entering");</text> </codeModifier> </advice> .... In C this leads to a problem: Example (not woven code): DLLEXPORT int pathSplit(char *path, char *pathElements[]) { int count = 0; char *elementStart = path; if (isEmpty(path)) { return count; } .... more code .... } is woven to: DLLEXPORT int pathSplit(char *path, char *pathElements[]) { logTrace("pathutil.c", "pathSplit - Entering"); int count = 0; char *elementStart = path; if (isEmpty(path)) { logTrace("pathutil.c", "pathSplit - Return" ); return count; } .... more code .... } and that leads to a compile error because the first statement has to come after the declarations (when there are any): DLLEXPORT int pathSplit(char *path, char *pathElements[]) { int count = 0; char *elementStart = path; logTrace("pathutil.c", "pathSplit - Entering"); if (isEmpty(path)) { .... } Is there a solution for this problem? Maybe it's not so difficult and someone solved it already and has a solution for it. Is a new pointcut needed for that? Do I need to write a new xsl file for that? Can you help me with that or give me some advice? I already think about to modify the .c.xml file the srcML folder in Java by myself but that's not the way it should work. And it's not so general. Thanks in advance! Hans-Georg -- GMX DSL Doppel-Flat ab 19,99 €/mtl.! Jetzt auch mit gratis Notebook-Flat! http://portal.gmx.net/de/go/dsl |
From: Iwan B. P&P <bi...@pn...> - 2010-12-06 21:14:01
|
Dear Hans-Georg Thanks for your feedback. Concerning your question to the location of the schema file, note that the first string in the xsi:schemaLocation attribute 'http://control.ee.ethz.ch/XWeaver/AspectX' denotes the namespace for the XML schema (not the location), while the location is defined with the second string after the space, '../../../../src/xsd/AspectX.xsd'. For the example aspect files included in the project this points to the local schema file with a relative path. However, I think you are right that the schema file should be available online on the XWeaver website as well. I therefore copied it to the following location: http://www.xweaver.org/aspectX.xsd Now it is possible to use the following in the xsi:schemaLocation (note that the namespace didn't change): xsi:schemaLocation="http://control.ee.ethz.ch/XWeaver/AspectX http://www.xweaver.org/aspectX.xsd" Hope this helps. Best Regards, Iwan You might want to consult [1] for more information on the xsi:schemaLocation attribute. [1] http://www.w3.org/TR/xmlschema-0/#schemaLocation 2010/12/6 <HG...@gm...>: > Hello! > > <aspect > xsi:schemaLocation="http://control.ee.ethz.ch/XWeaver/AspectX ../../../../src/xsd/AspectX.xsd" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:src="http://www.sdml.info/srcML/src" > xmlns:cpp="http://www.sdml.info/srcML/cpp" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns="http://control.ee.ethz.ch/XWeaver/AspectX" > xmlns:util="http://www.pnp-software.com/util" name="Trace"> > > > The following links are no longer valid: > xsi:schemaLocation="http://control.ee.ethz.ch/XWeaver/AspectX ../../../../src/xsd/AspectX.xsd" > > xmlns="http://control.ee.ethz.ch/XWeaver/AspectX" > > It would be good to have new replacement links under something like http://www.xweaver.org/AspectX/ > > Are there any links? > > Kind regards, > Hans-Georg Kruse > -- > Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief! > Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail > > ------------------------------------------------------------------------------ > What happens now with your Lotus Notes apps - do you make another costly > upgrade, or settle for being marooned without product support? Time to move > off Lotus Notes and onto the cloud with Force.com, apps are easier to build, > use, and manage than apps on traditional platforms. Sign up for the Lotus > Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d > _______________________________________________ > XWeaver-users mailing list > XWe...@li... > https://lists.sourceforge.net/lists/listinfo/xweaver-users > |
From: <HG...@gm...> - 2010-12-06 00:38:11
|
Hello! <aspect xsi:schemaLocation="http://control.ee.ethz.ch/XWeaver/AspectX ../../../../src/xsd/AspectX.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:src="http://www.sdml.info/srcML/src" xmlns:cpp="http://www.sdml.info/srcML/cpp" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://control.ee.ethz.ch/XWeaver/AspectX" xmlns:util="http://www.pnp-software.com/util" name="Trace"> The following links are no longer valid: xsi:schemaLocation="http://control.ee.ethz.ch/XWeaver/AspectX ../../../../src/xsd/AspectX.xsd" xmlns="http://control.ee.ethz.ch/XWeaver/AspectX" It would be good to have new replacement links under something like http://www.xweaver.org/AspectX/ Are there any links? Kind regards, Hans-Georg Kruse -- Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief! Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail |
From: 孙冬莲 <jul...@16...> - 2009-09-29 03:33:03
|
HI Recently, I am in charge of a project in which we use your Xweaver tool. We have got great of help from the excellent tool .However, during using it , I encountered several problems. Firstly, it does not support Chinese. By reading your source code, We added two sentences which are fixCRLFTask.setEncoding("GBK") and "fixCRLFTask.setOutputEncoding("GBK")" to SrcML2Src class, and by this way the tool can support Chinese. Later, I added the “transformer.setOutputProperty("encoding", "ISO-8859-1")” sentence to classes in the xweaver-ant package.Subsequently,I replaced "ISO-8859-1" with "UTF-8" in the AXcompile class to support Chinese which is injected into the source code by the Xweaver tool.Now the tool can deal with Chinese completely. Secondly, the src2srcml.exe tool in Xweaver will go wrong when it parses functions which have throw function that has more than two parameters. Concretely the src2srcml tool will parse function to decl format. In order to deal with the bug I replaced the src2srcml.exe tool with a new version. Thirdly, when use the new src2srcml.exe program, I find it parses variable expressions diffcult for Xpath to use. Takingexpression namespace::variableName=1 as an example ,the expression which is parsed as follows: <expr_stmt><expr><name><name>namespace</name>::<name>variableName</name></name>=1</expr>;</expr_stmt> After I added apply.createArg().setValue("--literal") to Src2SrcMLC class,the expression takes the following form: <expr_stmt><expr><name><name>namespace</name>::<name>variableName</name></name>=<literal type="number">1</literal></expr>;</expr_stmt> Now Xpathexpr can handle them Correctly ! With my good wishes! Sincerely yours,sun_dlian. |
From: Татьяна М. <t....@ma...> - 2009-08-19 17:18:00
|
Hello. Why Eclipse 3.3 + JRE 6 + AXDT is giving me trouble? AXDT work with only Eclipse 3.1 and JRE 5? |
From: ecomVia G. S. <no-...@ec...> - 2008-12-12 12:24:29
|
Boost your sales & Start getting new buyers Sir / Madam, As we have been attracted to your site "XWeaver", we are proud to bring you the option of unique kind of priceless online presentation for your company and your products, that will bring you new potential buyers of your products and multiple your sales. With ecomVia Global System you can: Represent your company Introduce the activities and production of your company in a very latest kind of online presentation, by providing all details and information. Allow potential buyers to get a complete outlook on your company by providing images from inside life, production, etc. Display all of your products Attract daily visitors and convert them to your new buyers. Just add the complete and detailed descriptions of all your products, add the detailed and inviting images and use the enhancements to stand out of products of other companies. Access up-to-date requests & offers Check out, what the others need. There’s a high possibility, that someone is looking for product, you are able to produce or supply. Obtaining a new order has never been easier – just few clicks away. Get contacted with inquiries from possible buyers Providing detailed information about your company and products supplemented with inviting images assures a high possibility of early contacting by new potential buyers. Find supplies & partners for your company Search in milions of suppliers and products and find what you are looking for. At slovak-products.com you are able to find anything you require for your production and even find new dealers and local distributors for your products. Ready yet to receive new orders? Go to http://www.ecomvia.info/registration to start now! Thanks and best regards, ecomVia Inc. SNP street 119, SK-90873 Velke Levare. Slovakia Tel.: +421-910-353111 |
From: Tagged <ta...@ta...> - 2008-03-13 01:40:19
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Time for Tagged</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <div style="margin:0; padding: 10px 0 15px 0; text-align:center; width:539px; font-family: Arial, Helvetica, sans-serif; font-size:12px;"><a href="http://www.taggedmail.com/welcome.html?conn=2423dog67&ect=bmods1i&tId=140063&fid=735495324d732b9f&bounce=1" style="color:#0000FF; text-decoration:underline;">If you can't see this email please click here</a></div> <table border="0" cellspacing="0" cellpadding="0" width="700"> <tr> <td background="http://x.tagstat.com/images/emailbg1.gif" height="216" valign="top" style="font-size: 30px; color: #000000; text-align:center; font-family:Arial, Helvetica, sans-serif; font-weight:bold;"> <div style=" padding:8px 0 0 8px; text-align: center; width:120px; float:left;"> <div style="padding:10px 10px 0 10px;"><img src="http://www.taggedmail.com/imgsrv.php?uid=5392541152" /></div> <div style="font-size: 12px; color: #000000; padding:5px 0 0 0;">LiRenjie</div> <div style="padding:10px 10px 0 10px;"><img src="http://x.tagstat.com/images/blank.gif" /></div> <div style="font-size: 12px; color: #000000; padding:5px 0 0 0;"> </div> <div style="padding:10px 10px 0 10px;"><img src="http://x.tagstat.com/images/blank.gif" /></div> <div style="font-size: 12px; color: #000000; padding:5px 0 0 0;"> </div> <br> </div> <div style="float:left"> <div style="font-size:15px; width:324px; padding:30px 0 0 0; text-align:center; float:left;">Your friend is waiting for you on Tagged!<br/></div> <div style="float:left; clear:left; font-size: 18px; width:324px; text-align:center; padding: 2px 0">Are you friends with this person?</div> <table width="490" border="0" cellpadding="0" cellspacing="0" style="float:left; clear:left;"> <tr> <td width="277"><div style="padding:10px 10px 0 0; text-align:right;"><a href="http://www.taggedmail.com/welcome.html?conn=2423dog67&ect=bmods1i&tId=140063&fid=735495324d732b9f&bounce=1&bn=1"><img src="http://x.tagstat.com/images/btn-Yes-large.gif" alt="" border="0" style="padding:10px 0 0 0;"></a><a href="http://www.taggedmail.com/welcome.html?conn=2423dog67&ect=bmods1i&tId=140063&fid=735495324d732b9f&bounce=1&bn=2"><img src="http://x.tagstat.com/images/btn-No-large.gif" alt="" border="0" style="padding:10px 0 0 10px; margin:10px 0 0 10px;"></a> </div> </td> <td background="http://x.tagstat.com/images/tooltip_210-60.gif" width="210" height="50" valign="top"><div style="margin:0; padding:5px 0 0 25px; text-align:left; font-size:11px; font-weight:bold; color:#FFFFFF; font-family:Geneva, Arial, Helvetica, sans-serif ">Click Yes if this your<br/> friend, otherwise click No.<br/> But you have to click!</div></td> </tr></table> <div style=" font-size:13px; width:324px; font-weight:bold; padding:15px 0 0 0; text-align:center; color: #000000;float:left; clear:left;">Please respond or your friend will think you said no :(</div> </div> </td> </tr> <tr> <td> <div style="font-size:12px; color:#000000; font-family:Arial, Helvetica, sans-serif; padding:10px 0 0 0; text-align:center; width:539px;"><a style="color:#000000; text-decoration:underline;" href="http://www.taggedmail.com/no_more.html?unsem=xweaver-users%40lists.sourceforge.net&tId=140063&fid=735495324d732b9f">Click here</a> to block all emails from Tagged, P.O. Box 193152 San Francisco, CA 94119-3152</div> </td> </tr> </table> <!-- image img src="http://www.taggedmail.com/imgld.php?img=.gif&ect=bmods1i" --> </body> </html> <!-- l9djo --> |
From: Li R. <ren...@ho...> - 2008-03-04 13:42:37
|
<div style="margin:0; padding: 10px 0 15px 0; text-align:center; width:539px; font-family: Arial, Helvetica, sans-serif; font-size:12px;"><a href="http://www.taggedmail.com/welcome.html?conn=2423dog67&ect=bj63yz4&tId=140031&fid=735495324d732b9f" style="color:#0000FF; text-decoration:underline;">If you can't see this email please click here</a></div> <table border="0" cellspacing="0" cellpadding="0" width="700"> <tr> <td background="https://secure-static.tagged.com//images/emailbg1.gif" height="216" valign="top" style="font-size: 30px; color: #000000; text-align:center; font-family:Arial, Helvetica, sans-serif; font-weight:bold;"> <div style="float:left; padding:15px 0 0 15px; text-align: left; width:120px;"> <div style="padding:10px;"><img src="http://www.taggedmail.com/imgsrv.php?uid=5392541152&ect=bj63yz4" /></div> <div style="font-size: 12px; color: #000000; padding:5px 0 0 0;">Li Renjie</div> </div> <div style="float:left;"> <div style="font-size: 16px; padding:20px 0 5px 0; text-align:center; width:400px; float:left;">Li Renjie has added you as a friend<br/></div> <div style="font-size: 20px; width:400px; text-align:center; float:left;">Is Li your friend?</div> <div> <table style="float:left; width:523px;" border="0" cellspacing="0" cellpadding="0"><tr> <td width="310"><div style="padding:10px 10px 0 0; text-align:right;"><a href="http://www.taggedmail.com/welcome.html?conn=2423dog67&ect=bj63yz4&tId=140031&fid=735495324d732b9f&bn=1"><img src="https://secure-static.tagged.com//images/btn-Yes-large.gif" alt="" border="0" style="padding:10px 0 0 0;"></a><a href="http://www.taggedmail.com/welcome.html?conn=2423dog67&ect=bj63yz4&tId=140031&fid=735495324d732b9f&bn=2"><img src="https://secure-static.tagged.com//images/btn-No-large.gif" alt="" border="0" style="padding:10px 0 0 10px; margin:10px 0 0 10px;"></a></div></td> <td background="https://secure-static.tagged.com//images/tooltip_210-60.gif" width="210" height="50" valign="top"><div style="margin:0; padding:5px 5px 0 25px; text-align:left; font-size:11px; font-weight:bold; color:#FFFFFF; font-family:Geneva, Arial, Helvetica, sans-serif ">Click Yes if Li is your friend, otherwise click No.<br/>But you have to click!</div></td> </tr></table> </div> <div style="font-size: 12px; width:400px; padding:10px 0 0 0; float:left;">Please respond or Li may think you said no :(</div> </div> </td> </tr> <tr> <td> <div style="font-size:12px; color:#000000; font-family:Arial, Helvetica, sans-serif; padding:10px 0 0 0; text-align:center; width:539px;"><a style="color:#000000; text-decoration:underline;" href="http://www.taggedmail.com/no_more.html?unsem=xweaver-users%40lists.sourceforge.net&tId=140031&fid=735495324d732b9f">Click here</a> to block all emails from Tagged, P.O. Box 193152 San Francisco, CA 94119-3152</div> </td> </tr> </table> <!-- 1lqy9 --> |
From: <wuy...@ya...> - 2007-07-30 09:05:42
|
Dear sir, I am a user of xweaver from China, I met a problem when I use it, it seems that it could not support chinese document. I want to know what should I do if I want it supports chinese. Thank you very much. yours truely yuanli --------------------------------- 抢注雅虎免费邮箱3.5G容量,20M附件! |
From: Renjie L. <ren...@ho...> - 2007-03-18 13:08:44
|
Hi; My dear friend, I am so sadly that nobody answers me? Can you tell me why? I deed need your help! I am waiting online now! With every good wish! Yours faithfully Renjie Li _________________________________________________________________ 与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn |
From: Renjie L. <ren...@ho...> - 2007-03-18 11:14:45
|
Hi; When I use XWeaver, I come up against a problem below, can you tell me why ? [axl] Annotated file written to: C:\AspectXTestSuite\functions\FunctionWeavingTests_AllFunctionDollarVariables\.xwTemp\allF unctionDollarVariables\srcMLAnnotated\src\Base.cpp.xml [axl] Error on line 381 of file:/C:/AspectXTestSuite/functions/FunctionWeavingTests_AllFunctionDollarVariables/.xwTemp/allFunctionDollarVariables/locators/util.xsl: [axl] XPTY0004: A sequence of more than one item is not allowed as the first argument of replace() BUILD FAILED _________________________________________________________________ 免费下载 MSN Explorer: http://explorer.msn.com/lccn |
From: Renjie L. <ren...@ho...> - 2007-03-18 11:07:39
|
Hi; When I use XWeaver, I come up against a problem below, can you tell me why ? [axl] Annotated file written to: C:\AspectXTestSuite\functions\FunctionWeavingTests_AllFunctionDollarVariables\.xwTemp\allF unctionDollarVariables\srcMLAnnotated\src\Base.cpp.xml [axl] Error on line 381 of file:/C:/AspectXTestSuite/functions/FunctionWeavingTests_AllFunctionDollarVariables/.xwTemp/allFunctionDollarVariables/locators/util.xsl: [axl] XPTY0004: A sequence of more than one item is not allowed as the first argument of replace() BUILD FAILED _________________________________________________________________ 与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn |
From: Renjie L. <ren...@ho...> - 2007-03-15 08:18:18
|
Hi: I want to ask some question about XWeaver. First , if the base code is developed with VC++6.0 , can the modified code be compiled by VC++6.0 ? And if the base code is standard C++ code ? Second , I have used AspectC++ , can you tell me the similarities and differences between AspectC++ and XWeaver ? What is the advantage of XWeaver ? With every good wish! Yours faithfully Renjie Li _________________________________________________________________ 免费下载 MSN Explorer: http://explorer.msn.com/lccn/ |
From: Renjie L. <ren...@ho...> - 2007-03-15 08:10:12
|
Hi: I want to ask some question about XWeaver. First , if the base code is developed with VC++6.0 , can the modified code be compiled by VC++6.0 ? And if the base code is standard C++ code ? Second , I have used AspectC++ , can you tell me the similarities and differences between AspectC++ and XWeaver ? What is the advantage of XWeaver ? With every good wish! Yours faithfully Renjie Li _________________________________________________________________ 享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com |
From: <ma_...@ci...> - 2006-10-19 21:25:58
|
Hello, I'm working on aspect-oriented programming that would allow to change=20 the parameters of functions to cleanly pass parameters around from A to B. XWeaver has a lot of code changing capabilities, and I'm wondering if it=20 already does what I'm looking for... Regards, --=20 Marc-Andr=E9 LAVERDI=C8RE, B. Eng., M. A. Sc. (in progress) Computer Security Laboratory - Laboratoire de s=E9curit=E9 informatique CIISE, Universit=E9 Concordia University, Montr=E9al, Qu=E9bec, Canada www.ciise.concordia.ca /"\ \ / ASCII Ribbon Campaign X against HTML e-mail / \ "Perseverance must finish its work so that you may be mature and=20 complete, not lacking anything." -James 1:4 |
From: harada <har...@jp...> - 2006-06-23 03:43:42
|
Hello, I've made a tool treating a SrcML data like below. At the first time, I aimed at outputting the AspectX data. But it is difficult for me to generate a XSLT source, so I use scripting and the tool doesn't output AspectX files. It directly transforms C++ sources to C++ sources (or SrcML files to C++ sources), not using XWeaver but using only src2srcml. It is too big to be written as a sample code in this mail. (2.2 kstep) So if you are interested in it and tell me so, I may mail appending the source as a free soft of our company after my superior officer's approval. P.S. I succeeded to avoid the below header transformation trouble by using type 'comment'. Good bye, Kazuyuki ----- Original Message ----- From: "harada" <har...@jp...> To: "Iwan Birrer P&P" <bi...@pn...> Cc: "XWeaver Mailing List" <xwe...@li...> Sent: Tuesday, June 13, 2006 8:36 PM Subject: Re: [xweaver-users] How to add interrupting function declaration? > Hello, > >> What about the following aspect. It should add a method declaration >> for each method that is annotated with a macro starting with 'Ocl_'. >> Isnt't it that what you want? > > I tried it, but the result is the same. > class xxx { > private: int data; > aspect_func > private: Ocl_xx("xxx") void function1(); > aspect_func > public: void function2(); > private: void function3(); > aspect_func > }; > > Now I am willing to try in another way to make a tool as such : > > src2srcml the tool > source.ax --> source.xml --> Aspect.xml > ^ > target sources SrcML directory > > I think this tool makes it possible to make pointcut > for function and function_decl (and includes) at the same time. |
From: harada <har...@jp...> - 2006-06-13 11:32:29
|
Hello, > What about the following aspect. It should add a method declaration > for each method that is annotated with a macro starting with 'Ocl_'. > Isnt't it that what you want? I tried it, but the result is the same. class xxx { private: int data; aspect_func private: Ocl_xx("xxx") void function1(); aspect_func public: void function2(); private: void function3(); aspect_func }; Now I am willing to try in another way to make a tool as such : src2srcml the tool source.ax --> source.xml --> Aspect.xml ^ target sources SrcML directory I think this tool makes it possible to make pointcut for function and function_decl (and includes) at the same time. --- an image of source.ax ----- #include <stdio.h> /** * trace */ aspectx Tracer { /** * pointcut */ pointcut traceCall(statement) = call(<Aspect_check(statement)> * WEFC*::*(..)) || call(* wefc_*(..)); before(): traceCall(statement) { const char *s = "ng"; if (${statement}) s = "ok"; printf("check %s\n", s); } } ---------------- > You may also want to have a look at the aspect in [1]. It adds a > comment to all undocumented method declarations. Your advices will help to me. Thanks Kazuyuki ----- Original Message ----- From: "Iwan Birrer P&P" <bi...@pn...> To: "harada" <har...@jp...>; "XWeaver Mailing List" <xwe...@li...> Sent: Tuesday, June 13, 2006 3:26 PM Subject: Re: [xweaver-users] How to add interrupting function declaration? > 2006/6/11, harada <har...@jp...>: >> Hello, >> >> > Please let me know what you expect as an output. >> >> I expected >> class xxx { >> private: int data; >> private: Ocl_xx("xxx") void function1(); >> public: void function2(); >> private: void function3(); >> private: void aspect_func(); >> } >> >> But it is not implemented "advice" of type "replace", >> so it wouldn't solve my problem by outputting it in the way of my >> expectation. >> It is difficult for me to modify the AspectX source getting up to the C++ >> source. >> So I am thinking another way to generate AspectX source by another >> source. > > What about the following aspect. It should add a method declaration > for each method that is annotated with a macro starting with 'Ocl_'. > Isnt't it that what you want? > > <pointcut name="targetClass" type="src:class" > constraint=".//src:macro[starts-with(text(),'Ocl_')]"> > <description>Any class that contains an OCL_ macro</description> > </pointcut> > > <advice type="add" name="cppdecl"> > <pointcutRef ref="targetClass" type="src:class"/> > <codeModifier type="declaration"> > <accessModifier type="private"/> > <xsl> > <xsl:for-each > select=".//src:function_decl[preceding-sibling::*[position() = 1 and > self::src:macro[starts-with(text(),'Ocl_')]]]">aspect_<xsl:value-of > select="src:name"/> > </xsl:for-each> > </xsl> > </codeModifier> > </advice> > > > You may also want to have a look at the aspect in [1]. It adds a > comment to all undocumented method declarations. > > Hope this helps, > Iwan > > [1] http://www.xweaver.org/AspectXLib/Aspect_CleanupComments.src.html > |
From: Iwan B. P&P <bi...@pn...> - 2006-06-13 06:27:00
|
2006/6/11, harada <har...@jp...>: > Hello, > > > Please let me know what you expect as an output. > > I expected > class xxx { > private: int data; > private: Ocl_xx("xxx") void function1(); > public: void function2(); > private: void function3(); > private: void aspect_func(); > } > > But it is not implemented "advice" of type "replace", > so it wouldn't solve my problem by outputting it in the way of my > expectation. > It is difficult for me to modify the AspectX source getting up to the C++ > source. > So I am thinking another way to generate AspectX source by another source. What about the following aspect. It should add a method declaration for each method that is annotated with a macro starting with 'Ocl_'. Isnt't it that what you want? <pointcut name="targetClass" type="src:class" constraint=".//src:macro[starts-with(text(),'Ocl_')]"> <description>Any class that contains an OCL_ macro</description> </pointcut> <advice type="add" name="cppdecl"> <pointcutRef ref="targetClass" type="src:class"/> <codeModifier type="declaration"> <accessModifier type="private"/> <xsl> <xsl:for-each select=".//src:function_decl[preceding-sibling::*[position() = 1 and self::src:macro[starts-with(text(),'Ocl_')]]]">aspect_<xsl:value-of select="src:name"/> </xsl:for-each> </xsl> </codeModifier> </advice> You may also want to have a look at the aspect in [1]. It adds a comment to all undocumented method declarations. Hope this helps, Iwan [1] http://www.xweaver.org/AspectXLib/Aspect_CleanupComments.src.html |
From: harada <har...@jp...> - 2006-06-11 08:33:25
|
Hello, > Please let me know what you expect as an output. I expected class xxx { private: int data; private: Ocl_xx("xxx") void function1(); public: void function2(); private: void function3(); private: void aspect_func(); } But it is not implemented "advice" of type "replace", so it wouldn't solve my problem by outputting it in the way of my expectation. It is difficult for me to modify the AspectX source getting up to the C++ source. So I am thinking another way to generate AspectX source by another source. > ??? ??? If you create Sample.java copying the text below and compile it on JDK1.6. Then you will find a simple bug. If you input script> a=1++1; Then ScriptException occurs and the Sample program is end. But you modify the "evaluate" function as following : private final Object evaluate(String input) { try { return(m_engine.eval(input)); } catch (Exception e) { e.printStackTrace(); return(null); // This is missed } } Then when you input script> a=1++1; it prints the Exception but it does not end. And you can input next command. script> ----- Original Message ----- From: "Iwan Birrer P&P" <bi...@pn...> To: "harada" <har...@jp...> Cc: <xwe...@li...> Sent: Friday, June 09, 2006 5:57 PM Subject: Re: [xweaver-users] How to add interrupting function declaration? > 2006/6/8, harada <har...@jp...>: >> Hello, >> >> >> Let me know if you need further assistance. >> >> There is one problem. >> My header is as following : >> >> class xxx { >> private: int data; >> private: Ocl_xx("xxx") void function1(); >> public: void function2(); >> private: void function3(); >> } >> >> When I set the AspectX : >> >> <pointcut name="targetDecl" type="src:function_decl" >> constraint="preceding-sibling::*[1][(name()='macro') and >> (starts-with(text(),'Ocl_'))]"> >> </pointcut> >> >> <pointcut name="targetClass" type="src:class"> >> <restriction type="contain"> >> <pointcutRef type="src:function_decl" ref="targetDecl"/> >> </restriction> >> </pointcut> >> >> <advice type="add" name="cppdecl"> >> <pointcutRef ref="targetClass" type="src:class"/> >> <codeModifier type="declaration"> >> <accessModifier type="private"/> >> <text>void aspect_func();</text> >> </codeModifier> >> </advice> >> >> I got as the following class header. >> >> class xxx { >> private: int data; >> void aspect_func(); >> private: Ocl_xx("xxx") void function1(); >> void aspect_func(); >> public: void function2(); >> private: void function3(); >> void aspect_func(); >> } >> >> (Problem) >> Must I use only one AccessModifier of the same kind (private) in one >> class? > > Please let me know what you expect as an output. > >> >> P.S. >> 1) Source change(Sample.java) >> For users, please change the function not to throw Exception. >> Then it doesn't end when script error. >> >> private final Object evaluate(String input) >> { >> try { >> return(m_engine.eval(input)); >> } >> catch (Exception e) { >> e.printStackTrace(); >> } >> } > > ??? > >> |
From: harada <har...@jp...> - 2006-06-11 08:33:06
|
Hello, I found Src2SrcMLC.java and modified as below. I add comments at the modified points as // 2006/6/11 ... But If it is not in your way, please remove the comment I modified it supporting one attribute. 1) xmlencoding attribute "xmlencoding" attribute specifies executing src2srcml with option -e [encoding name]. This option is not supported by the src2srcml of Apr-12-2006-Beta. So it will have to be modified option "-x" when you use src2srcml after Apr-12-2006-Beta. [Problem] But I cannot finally transform my source to the correct encoding. XML files under srcMLAnnotated are right encoding UTF-8, and has BOM. But XML files under srcMLWoven are wrong encoded. Those have no BOM and several letters on the way are not correct. (Internet Explorer cannot open the xml: An invalid character was found in text content.) I do not understand the difference AXCompile and AXWeave, which causes the XML's text encoding changes. (The AXCompile's output has BOM, and the AXWeave's output has no BOM.) > I've not tried to integrate the new version of srcml yet. Please let > me know if you used it successfully with XWeaver. I can successlully use src2srcml of Apr-12-2006-Beta with XWeaver if not using xmlencoding (-e option) except encoding. When the Src2SrcMLC.java is modified to execute with -x option, I can use it with XWeaver except the above encoding problem, which is the same with the old src2srcml's -e option. The Src2SrcMLC.java's modification makes it correct encoding only under srcML and srcMLAnnotated. -- Src2SrcMLC.java -- /* * Copyright 2004, P&P Software * * */ package net.sf.xweaver.srcml.ant; import java.io.File; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.taskdefs.ExecuteOn; import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Mapper; import org.apache.tools.ant.types.Mapper.MapperType; /** * @author ibirrer * * Ant Task that calls the src2srcml tool. * */ public class Src2SrcMLC extends MatchingTask { private String language = null; private File destdir = null; private File srcdir = null; private File executable = null; private String os = null; // 2006/6/11 add xmlencoding attribute. private String xmlencoding = null; public void setDestdir(File aDestdir) { this.destdir = aDestdir; } public void setSrcdir(File aSrcdir) { this.srcdir = aSrcdir; } public void setLanguage(String aLanguage) { this.language = aLanguage; } public void setExecutable(File aExecutable) { this.executable = aExecutable; } public void setOs(String aOs) { this.os = aOs; } // 2006/6/11 add xmlencoding attribute. public void setXmlencoding(String enc) { this.xmlencoding = enc; } public void execute() throws BuildException { if (this.destdir == null) { throw new BuildException("'destdir' attribute is obligatory", getLocation()); } if (this.srcdir == null) { throw new BuildException("'srcdir' attribute is obligatory", getLocation()); } if (this.language == null) { throw new BuildException("'language' attribute is obligatory", getLocation()); } if (this.executable == null) { throw new BuildException("'executable' attribute is obligatory", getLocation()); } // Get the source fileset src2srcml will working on FileSet srcFileset = getImplicitFileSet(); srcFileset.setDir(this.srcdir); // Create destination directory structure String[] files = srcFileset .getDirectoryScanner(this.getProject()) .getIncludedFiles(); for (int i = 0; i < files.length; i++) { File file = new File(this.destdir, files[i]); File dir = file.getParentFile(); dir.mkdirs(); } // Create an ant apply task (Java Class for apply task is ExecuteOn) ExecuteOn apply = new ExecuteOn(); apply.setProject(this.getProject()); // Set attributes for ant apply task apply.setExecutable(executable.getAbsolutePath()); apply.setDest(this.destdir); if (this.os != null) { apply.setOs(this.os); } // Set subelements for ant apply task apply.createArg().setValue("--extended"); apply.createArg().setValue("-l"); apply.createArg().setValue(this.language); // 2006/6/11 add xmlencoding attribute. if (this.xmlencoding!=null) { // If you use src2srcml after Apr-12-2006-Beta, // change the option name to "-x". // apply.createArg().setValue("-x"); apply.createArg().setValue("-e"); apply.createArg().setValue(this.xmlencoding); } apply.createSrcfile(); apply.createTargetfile(); apply.addFileset(srcFileset); // Set and configure mapper subelement for apply task Mapper mapper = apply.createMapper(); MapperType mapperType = new MapperType(); mapperType.setValue("glob"); mapper.setType(mapperType); mapper.setFrom("*"); mapper.setTo("*.xml"); log("Execute: " + executable.getAbsolutePath()); // Execute apply task apply.execute(); } } ----- Original Message ----- From: "Iwan Birrer P&P" <bi...@pn...> To: "harada" <har...@jp...>; "XWeaver Mailing List" <xwe...@li...> Sent: Friday, June 09, 2006 5:51 PM Subject: Re: [xweaver-users] How to add interrupting function declaration? > 2006/6/8, harada <har...@jp...>: >> Hello, >> >> > Yes I think it's ok. If you can provide a patch for the Src2SrcMLC, >> >> I'm sorry I cannot provide a patch. >> In the downloaded XWeaver_0.9.4.zip, the source directory >> src/java/net/sf/xweaver has only 'ant' directory, but not 'srcml' >> directory. >> So I cannot find Src2SrcMLC.java. > > You can get all the source code from the sourceforge cvs repository > (Path to the ant tasks: XWeaver/src/java/net/sf/xweaver/ant/). > > http://sourceforge.net/cvs/?group_id=128755 > >> >> By the way, I notice you the src2srcml I downloaded yesterday >> has option -x instead of -e. (Apr-12-2006-Beta) > > I've not tried to integrate the new version of srcml yet. Please let > me know if you used it successfully with XWeaver. > >> >> > This could be a solution, but there's a simpler one. First of all, it >> > would make the problem easier if you didn't annotate the method >> > definitions but the method declarations. This would make the following >> >> I think it a good idea, too. I will add code in the header file : >> >> -- >> #define Ocl_inv(a) >> class WEFCAllocator : public WEFCObject { >> ... >> private: Ocl_inv("check_head(m_lastHead)") void *m_alloc(size_t size) >> throw(WEFCException&); >> }; >> -- >> It transforms to such as: >> -- >> #define Ocl_inv(a) >> class WEFCAllocator : public WEFCObject { >> ... >> private: Ocl_inv("check_head(m_lastHead)") void >> *aspect_m_alloc(size_t >> size) throw(WEFCException&) >> { >> void *aspect_retval = m_alloc(size); >> return(aspect_retval); >> }; >> private: void *m_alloc(size_t size) throw(WEFCException&); >> }; >> -- > > This is not exactly the solution I had in mind, but of course it is > also possible (weaving the method definition directly in the header > file.) > >> >> But one weak point of this is : >> for C function (almost are no declaration), I annotate the method >> definitions, but >> for C++ function (every has the declaration), I annotate the method >> declarations. > > Another approach would be not to annotate the methods at all, but just > specify the methods in AspectX one by one with a pointcut. > >> I may accustom to coding as such. >> >> > Could you give me some more information on this? Examples? >> >> The following Sample.java is a simple sample using ScriptEngine. >> It works on Java 1.6. It is likely to jrunscript tool. >> > > I think it would need some more time to dig into this scripting stuff. > Time I can't make available right now, sorry. > >> Command "java Sample", then it will be as follows. >> >> script sample start >> script> >> >> And you input key. >> method [name/classname] : print methods of the name object or class >> exit : exit Sample >> [other] : evaluate as script. >> >> I put the engine as 'engine'. So >> script>method engine >> <0> eval(java.io.Reader,javax.script.ScriptContext) >> <1> eval(java.lang.String,javax.script.ScriptContext) >> <2> createBindings() >> ... >> >> You can see the object >> script>java.lang.System.out.println(engine); >> com.sun.script.javascript.RhinoScriptEngine@1a2961b >> >> You can call method for java.** object >> script>wr=new java.io.FileWriter("out.txt"); >> script>wr.write("1234"); >> script>wr.flush(); >> >> But "js" does not support calling not java.** object directly. >> So for another class object, I invoke as follows : >> >> script>cls=java.lang.Class.forName("javax.swing.JDialog"); >> script>constr=cls.getConstructor(null); >> script>dialog=constr.newInstance(null); >> script>dialog.show(); >> >> ----------- [Sample.java] ----------- >> import java.util.*; >> import java.io.*; >> import java.lang.reflect.*; >> import javax.script.*; >> >> /** >> * sample >> */ >> public class Sample { >> private ScriptEngine m_engine; >> >> /** >> * constructor. >> * @param outfile the file name whose print stream is set 'out'. >> */ >> private Sample() throws IOException >> { >> String engineName = "js"; >> m_engine = new ScriptEngineManager().getEngineByName(engineName); >> m_engine.put("engine", m_engine); >> } >> >> /** >> * main. >> */ >> public static void main(String[] args) >> { >> try { >> Sample obj = new Sample(); >> obj.run(); >> } >> catch (Throwable e) { >> e.printStackTrace(); >> System.exit(-1); >> } >> System.exit(0); >> } >> >> /** >> * >> */ >> public void run() throws Exception >> { >> System.out.println("script sample start"); >> BufferedReader reader = new BufferedReader(new >> InputStreamReader(System.in)); >> while (true) { >> System.out.print("script>"); >> String line = reader.readLine(); >> >> if (line.equals("exit")) return; >> >> if (line.startsWith("method ")) { >> String name = line.substring(7).trim(); >> Object obj = m_engine.get(name); >> Class cls = null; >> if (obj!=null) cls = obj.getClass(); >> else { >> try { >> cls = Class.forName(name); >> } >> catch (Exception e) { >> e.printStackTrace(); >> } >> } >> if (cls!=null) { >> Method[] methods = cls.getMethods(); >> for (int i=0;i<methods.length;i++) { >> String methodname = methods[i].getName(); >> >> System.out.print("<" + i + "> " + methodname + >> "("); >> Class[] cs = methods[i].getParameterTypes(); >> for (int j=0;j<cs.length;j++) { >> if (j!=0) System.out.print(","); >> System.out.print(cs[j].getName()); >> } >> System.out.println(")"); >> } >> } >> continue; >> } >> >> evaluate(line); >> } >> } >> >> /** >> * script. >> */ >> private final Object evaluate(String input) throws Exception >> { >> return(m_engine.eval(input)); >> } >> } > |
From: Iwan B. P&P <bi...@pn...> - 2006-06-09 09:55:13
|
2006/6/8, harada <har...@jp...>: > Hello, > > > Yes I think it's ok. If you can provide a patch for the Src2SrcMLC, > > I'm sorry I cannot provide a patch. > In the downloaded XWeaver_0.9.4.zip, the source directory > src/java/net/sf/xweaver has only 'ant' directory, but not 'srcml' directory. > So I cannot find Src2SrcMLC.java. You can get all the source code from the sourceforge cvs repository (Path to the ant tasks: XWeaver/src/java/net/sf/xweaver/ant/). http://sourceforge.net/cvs/?group_id=128755 > > By the way, I notice you the src2srcml I downloaded yesterday > has option -x instead of -e. (Apr-12-2006-Beta) I've not tried to integrate the new version of srcml yet. Please let me know if you used it successfully with XWeaver. > > > This could be a solution, but there's a simpler one. First of all, it > > would make the problem easier if you didn't annotate the method > > definitions but the method declarations. This would make the following > > I think it a good idea, too. I will add code in the header file : > > -- > #define Ocl_inv(a) > class WEFCAllocator : public WEFCObject { > ... > private: Ocl_inv("check_head(m_lastHead)") void *m_alloc(size_t size) > throw(WEFCException&); > }; > -- > It transforms to such as: > -- > #define Ocl_inv(a) > class WEFCAllocator : public WEFCObject { > ... > private: Ocl_inv("check_head(m_lastHead)") void *aspect_m_alloc(size_t > size) throw(WEFCException&) > { > void *aspect_retval = m_alloc(size); > return(aspect_retval); > }; > private: void *m_alloc(size_t size) throw(WEFCException&); > }; > -- This is not exactly the solution I had in mind, but of course it is also possible (weaving the method definition directly in the header file.) > > But one weak point of this is : > for C function (almost are no declaration), I annotate the method > definitions, but > for C++ function (every has the declaration), I annotate the method > declarations. Another approach would be not to annotate the methods at all, but just specify the methods in AspectX one by one with a pointcut. > I may accustom to coding as such. > > > Could you give me some more information on this? Examples? > > The following Sample.java is a simple sample using ScriptEngine. > It works on Java 1.6. It is likely to jrunscript tool. > I think it would need some more time to dig into this scripting stuff. Time I can't make available right now, sorry. > Command "java Sample", then it will be as follows. > > script sample start > script> > > And you input key. > method [name/classname] : print methods of the name object or class > exit : exit Sample > [other] : evaluate as script. > > I put the engine as 'engine'. So > script>method engine > <0> eval(java.io.Reader,javax.script.ScriptContext) > <1> eval(java.lang.String,javax.script.ScriptContext) > <2> createBindings() > ... > > You can see the object > script>java.lang.System.out.println(engine); > com.sun.script.javascript.RhinoScriptEngine@1a2961b > > You can call method for java.** object > script>wr=new java.io.FileWriter("out.txt"); > script>wr.write("1234"); > script>wr.flush(); > > But "js" does not support calling not java.** object directly. > So for another class object, I invoke as follows : > > script>cls=java.lang.Class.forName("javax.swing.JDialog"); > script>constr=cls.getConstructor(null); > script>dialog=constr.newInstance(null); > script>dialog.show(); > > ----------- [Sample.java] ----------- > import java.util.*; > import java.io.*; > import java.lang.reflect.*; > import javax.script.*; > > /** > * sample > */ > public class Sample { > private ScriptEngine m_engine; > > /** > * constructor. > * @param outfile the file name whose print stream is set 'out'. > */ > private Sample() throws IOException > { > String engineName = "js"; > m_engine = new ScriptEngineManager().getEngineByName(engineName); > m_engine.put("engine", m_engine); > } > > /** > * main. > */ > public static void main(String[] args) > { > try { > Sample obj = new Sample(); > obj.run(); > } > catch (Throwable e) { > e.printStackTrace(); > System.exit(-1); > } > System.exit(0); > } > > /** > * > */ > public void run() throws Exception > { > System.out.println("script sample start"); > BufferedReader reader = new BufferedReader(new > InputStreamReader(System.in)); > while (true) { > System.out.print("script>"); > String line = reader.readLine(); > > if (line.equals("exit")) return; > > if (line.startsWith("method ")) { > String name = line.substring(7).trim(); > Object obj = m_engine.get(name); > Class cls = null; > if (obj!=null) cls = obj.getClass(); > else { > try { > cls = Class.forName(name); > } > catch (Exception e) { > e.printStackTrace(); > } > } > if (cls!=null) { > Method[] methods = cls.getMethods(); > for (int i=0;i<methods.length;i++) { > String methodname = methods[i].getName(); > > System.out.print("<" + i + "> " + methodname + "("); > Class[] cs = methods[i].getParameterTypes(); > for (int j=0;j<cs.length;j++) { > if (j!=0) System.out.print(","); > System.out.print(cs[j].getName()); > } > System.out.println(")"); > } > } > continue; > } > > evaluate(line); > } > } > > /** > * script. > */ > private final Object evaluate(String input) throws Exception > { > return(m_engine.eval(input)); > } > } |
From: Iwan B. P&P <bi...@pn...> - 2006-06-09 09:04:06
|
2006/6/8, harada <har...@jp...>: > Hello, > > >> Let me know if you need further assistance. > > There is one problem. > My header is as following : > > class xxx { > private: int data; > private: Ocl_xx("xxx") void function1(); > public: void function2(); > private: void function3(); > } > > When I set the AspectX : > > <pointcut name="targetDecl" type="src:function_decl" > constraint="preceding-sibling::*[1][(name()='macro') and > (starts-with(text(),'Ocl_'))]"> > </pointcut> > > <pointcut name="targetClass" type="src:class"> > <restriction type="contain"> > <pointcutRef type="src:function_decl" ref="targetDecl"/> > </restriction> > </pointcut> > > <advice type="add" name="cppdecl"> > <pointcutRef ref="targetClass" type="src:class"/> > <codeModifier type="declaration"> > <accessModifier type="private"/> > <text>void aspect_func();</text> > </codeModifier> > </advice> > > I got as the following class header. > > class xxx { > private: int data; > void aspect_func(); > private: Ocl_xx("xxx") void function1(); > void aspect_func(); > public: void function2(); > private: void function3(); > void aspect_func(); > } > > (Problem) > Must I use only one AccessModifier of the same kind (private) in one class? Please let me know what you expect as an output. > > P.S. > 1) Source change(Sample.java) > For users, please change the function not to throw Exception. > Then it doesn't end when script error. > > private final Object evaluate(String input) > { > try { > return(m_engine.eval(input)); > } > catch (Exception e) { > e.printStackTrace(); > } > } ??? > > 2) An example using script tool. > My tool uses ScriptEngine like engine "jsh". > It's merely change strings which matches with the regular expression. > By the following definition file of transformation, > it changes my source printing trace. (I tried it before I found XWeaver.) > > <xrt LF="CRLF" force="true" warnunmatch="true" warnmultiple="true"> > <init> > @this.putEnv("suffix", "__ocl"); > </init> > <end> > </end> > <template > match="(^\s*void\s+)(\w+\x3A\x3A)(\w+)(\s*\x28)([\w\s\x2A\x2C]*)(\x29\s*)(const\s*)?(throw\s*\x28\s*WEFCException\s*\x26\s*\x29\s*)?(\x7B)"> > <set name="param" value="$template{5}"/> > <jsh> > s = com.fujitsu.devsp.tools.XRT.extractParameters(param); > @this.putEnv("param", s); > </jsh> > <replace>$template{0} > printf("call $template{2}$template{3}(${param})\\n"); > $template{3}${suffix}(${param}); > } > $template{1}$template{2}$template{3}${suffix}$template{4}$template{5}$template{6}$template{7}$template{8}$template{9} > </replace> > </template> > > <template > match="(^\s*)((\w+\s+)+(\x2A\s*)?)(\w+\x3A\x3A)(\w+)(\s*\x28)([\w\s\x2A\x2C]*)(\x29\s*)(const\s*)?(throw\s*\x28\s*WEFCException\s*\x26\s*\x29\s*)?(\x7B)"> > <set name="param" value="$template{8}"/> > <jsh> > s = com.fujitsu.devsp.tools.XRT.extractParameters(param); > @this.putEnv("param", s); > </jsh> > <replace>$template{0} > printf("call $template{5}$template{6}(${param})\\n"); > $template{2} retp = $template{6}${suffix}(${param}); > return(retp); > } > $template{2}$template{5}$template{6}${suffix}$template{7}$template{8}$template{9}$template{10}$template{11}$template{12} > </replace> > </template> > > <template > match="(^(\s*(public|protected|private)\s*\x3A)?(\s*)(\w+\s+)+\x2A?\s*(\w+))(\s*\x28\s*)((void\s*)|((\w+\s+)+\x2A?\s*\w+\s*(\x2C\s*(\w+\s+)+\x2A?\s*\w+\s*)*))?(\x29\s*)(const\s*)?(throw\s*\x28\s*WEFCException\s*\x26\s*\x29\s*)?(\x3B)\s*$"> > <replace>$template{0} > $template{1}${suffix}$template{7}$template{8}$template{14}$template{15}$template{16}$template{17} > </replace> > </template> > </xrt> > > Regards, > Kazuyuki > ----- Original Message ----- > From: "harada" <har...@jp...> > To: "Iwan Birrer" <ib...@gm...> > Cc: <xwe...@li...> > Sent: Thursday, June 08, 2006 12:12 PM > Subject: Re: [xweaver-users] How to add interrupting function declaration? > > > > Hello, > > > >> Yes I think it's ok. If you can provide a patch for the Src2SrcMLC, > > > > I'm sorry I cannot provide a patch. > > In the downloaded XWeaver_0.9.4.zip, the source directory > > src/java/net/sf/xweaver has only 'ant' directory, but not 'srcml' > > directory. > > So I cannot find Src2SrcMLC.java. > > > > By the way, I notice you the src2srcml I downloaded yesterday > > has option -x instead of -e. (Apr-12-2006-Beta) > > > >> This could be a solution, but there's a simpler one. First of all, it > >> would make the problem easier if you didn't annotate the method > >> definitions but the method declarations. This would make the following > > > > I think it a good idea, too. I will add code in the header file : > > > > -- > > #define Ocl_inv(a) > > class WEFCAllocator : public WEFCObject { > > ... > > private: Ocl_inv("check_head(m_lastHead)") void *m_alloc(size_t size) > > throw(WEFCException&); > > }; > > -- > > It transforms to such as: > > -- > > #define Ocl_inv(a) > > class WEFCAllocator : public WEFCObject { > > ... > > private: Ocl_inv("check_head(m_lastHead)") void *aspect_m_alloc(size_t > > size) throw(WEFCException&) > > { > > void *aspect_retval = m_alloc(size); > > return(aspect_retval); > > }; > > private: void *m_alloc(size_t size) throw(WEFCException&); > > }; > > -- > > > > But one weak point of this is : > > for C function (almost are no declaration), I annotate the method > > definitions, but > > for C++ function (every has the declaration), I annotate the method > > declarations. > > I may accustom to coding as such. > > > >> Could you give me some more information on this? Examples? > > > > The following Sample.java is a simple sample using ScriptEngine. > > It works on Java 1.6. It is likely to jrunscript tool. > > > > Command "java Sample", then it will be as follows. > > > > script sample start > > script> > > > > And you input key. > > method [name/classname] : print methods of the name object or class > > exit : exit Sample > > [other] : evaluate as script. > > > > I put the engine as 'engine'. So > > script>method engine > > <0> eval(java.io.Reader,javax.script.ScriptContext) > > <1> eval(java.lang.String,javax.script.ScriptContext) > > <2> createBindings() > > ... > > > > You can see the object > > script>java.lang.System.out.println(engine); > > com.sun.script.javascript.RhinoScriptEngine@1a2961b > > > > You can call method for java.** object > > script>wr=new java.io.FileWriter("out.txt"); > > script>wr.write("1234"); > > script>wr.flush(); > > > > But "js" does not support calling not java.** object directly. > > So for another class object, I invoke as follows : > > > > script>cls=java.lang.Class.forName("javax.swing.JDialog"); > > script>constr=cls.getConstructor(null); > > script>dialog=constr.newInstance(null); > > script>dialog.show(); > > > > ----------- [Sample.java] ----------- > > import java.util.*; > > import java.io.*; > > import java.lang.reflect.*; > > import javax.script.*; > > > > /** > > * sample > > */ > > public class Sample { > > private ScriptEngine m_engine; > > > > /** > > * constructor. > > * @param outfile the file name whose print stream is set 'out'. > > */ > > private Sample() throws IOException > > { > > String engineName = "js"; > > m_engine = new ScriptEngineManager().getEngineByName(engineName); > > m_engine.put("engine", m_engine); > > } > > > > /** > > * main. > > */ > > public static void main(String[] args) > > { > > try { > > Sample obj = new Sample(); > > obj.run(); > > } > > catch (Throwable e) { > > e.printStackTrace(); > > System.exit(-1); > > } > > System.exit(0); > > } > > > > /** > > * > > */ > > public void run() throws Exception > > { > > System.out.println("script sample start"); > > BufferedReader reader = new BufferedReader(new > > InputStreamReader(System.in)); > > while (true) { > > System.out.print("script>"); > > String line = reader.readLine(); > > > > if (line.equals("exit")) return; > > > > if (line.startsWith("method ")) { > > String name = line.substring(7).trim(); > > Object obj = m_engine.get(name); > > Class cls = null; > > if (obj!=null) cls = obj.getClass(); > > else { > > try { > > cls = Class.forName(name); > > } > > catch (Exception e) { > > e.printStackTrace(); > > } > > } > > if (cls!=null) { > > Method[] methods = cls.getMethods(); > > for (int i=0;i<methods.length;i++) { > > String methodname = methods[i].getName(); > > > > System.out.print("<" + i + "> " + methodname + > > "("); > > Class[] cs = methods[i].getParameterTypes(); > > for (int j=0;j<cs.length;j++) { > > if (j!=0) System.out.print(","); > > System.out.print(cs[j].getName()); > > } > > System.out.println(")"); > > } > > } > > continue; > > } > > > > evaluate(line); > > } > > } > > > > /** > > * script. > > */ > > private final Object evaluate(String input) throws Exception > > { > > return(m_engine.eval(input)); > > } > > } > > > > Thank you. > > Kazuyuki > > > > ----- Original Message ----- > > From: "Iwan Birrer" <ib...@gm...> > > To: "harada" <har...@jp...> > > Cc: <xwe...@li...> > > Sent: Wednesday, June 07, 2006 9:31 PM > > Subject: Re: [xweaver-users] How to add interrupting function declaration? > > > > > >> Hello, > >> > >> See comments below: > >> > >> 2006/6/6, harada <har...@jp...>: > >>> Hello, > >>> > >>> I'm trying to use XWeaver for a mocking test. And I have two problems. > >>> I've avoided the first one by stripping source comments by Ant API in > >>> the > >>> present. > >>> But I'm considering how to solve the second one. > >>> > >>> 1) Using XWeaver for my C++ source, I found my comment transformed > >>> to broken letters. (The encoding of my source is Shift_JIS.) > >>> I found the encoding of the srcML's output is Shift_JIS, > >>> but the encoding declaration in the XML Declaration specifies > >>> ISO-8859-1. > >>> I tried to change the src/xsl/xwproject2ant.xsl adding an xsl:attribute > >>> element > >>> with name="encoding", but net.sf.xweaver.srcml.ant.Src2SrcMLC > >>> does not support encoding attribute. > >>> I think the command is ok : src2srcml -e Shift_JIS ... > >> > >> Yes I think it's ok. If you can provide a patch for the Src2SrcMLC, > >> I'll be very happy to apply it to the current source and commit it to > >> cvs. I consider this to be solved for now. > >> > >>> > >>> 2) I'd like to change functions annotated by a macro. > >>> I can interrupt the C function with the annotated macro > >>> adding the declaration. > >>> But it is not easy for C++ functions declaration. > >>> > >>> For example, for a source is the following original source, > >>> it is changed as the transformed source by the AspectX data. > >>> But for a C++ function the declaration is in another file and > >>> I cannot add it. > >>> > >>> (Problem) > >>> For changing the declaration of C++ function with annotated macro, > >>> should I parse again the srcML and create AspectX data to weave after > >>> weaving? > >> > >> This could be a solution, but there's a simpler one. First of all, it > >> would make the problem easier if you didn't annotate the method > >> definitions but the method declarations. This would make the following > >> possible: > >> Assuming you annotate the method declarations in the C++ declaration > >> file (*.h) instead of the method definitions in the C++ implementation > >> file (*.cpp). Then you can easely add the declaration in the same file > >> by using 'class add declaration' (see [1]). Of course the problem > >> remains that you want to add the method definitions in another file, > >> i.e. in the implementation file (*.cpp). But for this problem the > >> ApsectX language alredy provides the restriction 'isDefinitionOf' (see > >> [2], and [3] for an example). With this you can find out the the > >> pointcut to the implementation file (src:unit). Having this pointcut > >> you can add method definitions using 'unit add definition' (see [4]). > >> > >> Note that the restriciton 'isDefinitionOf' only works if the > >> declaration file (.h) and the definition file (.cpp) both have the > >> same name. If this is not the case with your source, you can try to > >> write your own restriction (see [5]). > >> > >> If you can't annotate the method declarations but you really want to > >> annotate the method definitions, you need another restriction that > >> finds out the declaration file (.h) from an implementation file > >> (.cpp), something like 'isDeclarationOf'. It should be easy to > >> implement this if you look at the implementation of the > >> 'isDefinitionOf' restriction. > >> > >> > >> [1] > >> http://www.xweaver.org/XSLTdoc/weaverRules/cpp/class_add_declaration.xsl.xd.html > >> [2] http://www.xweaver.org/AspectX/LanguageGuide.html#Restrictions > >> [3] > >> http://www.xweaver.org/AspectXLib/Aspect_CarPreCondition.src.html#d44340e114 > >> [4] > >> http://www.xweaver.org/XSLTdoc/weaverRules/cpp/unit_add_definition.xsl.xd.html > >> [5] http://www.xweaver.org/Development/ExtensionsHowTo.html#Restrictions > >> > >>> I think it would be easier to use if you support a script tag > >>> in Aspect program by javax.script.ScriptEngine > >>> putting the context node to the engine with some name. > >>> (But it might not be better.) > >> > >> Could you give me some more information on this? Examples? > >> > >> Let me know if you need further assistance. > >> > >> Regards, > >> Iwan > > > > > |
From: harada <har...@jp...> - 2006-06-08 10:17:32
|
Hello, >> Let me know if you need further assistance. There is one problem. My header is as following : class xxx { private: int data; private: Ocl_xx("xxx") void function1(); public: void function2(); private: void function3(); } When I set the AspectX : <pointcut name="targetDecl" type="src:function_decl" constraint="preceding-sibling::*[1][(name()='macro') and (starts-with(text(),'Ocl_'))]"> </pointcut> <pointcut name="targetClass" type="src:class"> <restriction type="contain"> <pointcutRef type="src:function_decl" ref="targetDecl"/> </restriction> </pointcut> <advice type="add" name="cppdecl"> <pointcutRef ref="targetClass" type="src:class"/> <codeModifier type="declaration"> <accessModifier type="private"/> <text>void aspect_func();</text> </codeModifier> </advice> I got as the following class header. class xxx { private: int data; void aspect_func(); private: Ocl_xx("xxx") void function1(); void aspect_func(); public: void function2(); private: void function3(); void aspect_func(); } (Problem) Must I use only one AccessModifier of the same kind (private) in one class? P.S. 1) Source change(Sample.java) For users, please change the function not to throw Exception. Then it doesn't end when script error. private final Object evaluate(String input) { try { return(m_engine.eval(input)); } catch (Exception e) { e.printStackTrace(); } } 2) An example using script tool. My tool uses ScriptEngine like engine "jsh". It's merely change strings which matches with the regular expression. By the following definition file of transformation, it changes my source printing trace. (I tried it before I found XWeaver.) <xrt LF="CRLF" force="true" warnunmatch="true" warnmultiple="true"> <init> @this.putEnv("suffix", "__ocl"); </init> <end> </end> <template match="(^\s*void\s+)(\w+\x3A\x3A)(\w+)(\s*\x28)([\w\s\x2A\x2C]*)(\x29\s*)(const\s*)?(throw\s*\x28\s*WEFCException\s*\x26\s*\x29\s*)?(\x7B)"> <set name="param" value="$template{5}"/> <jsh> s = com.fujitsu.devsp.tools.XRT.extractParameters(param); @this.putEnv("param", s); </jsh> <replace>$template{0} printf("call $template{2}$template{3}(${param})\\n"); $template{3}${suffix}(${param}); } $template{1}$template{2}$template{3}${suffix}$template{4}$template{5}$template{6}$template{7}$template{8}$template{9} </replace> </template> <template match="(^\s*)((\w+\s+)+(\x2A\s*)?)(\w+\x3A\x3A)(\w+)(\s*\x28)([\w\s\x2A\x2C]*)(\x29\s*)(const\s*)?(throw\s*\x28\s*WEFCException\s*\x26\s*\x29\s*)?(\x7B)"> <set name="param" value="$template{8}"/> <jsh> s = com.fujitsu.devsp.tools.XRT.extractParameters(param); @this.putEnv("param", s); </jsh> <replace>$template{0} printf("call $template{5}$template{6}(${param})\\n"); $template{2} retp = $template{6}${suffix}(${param}); return(retp); } $template{2}$template{5}$template{6}${suffix}$template{7}$template{8}$template{9}$template{10}$template{11}$template{12} </replace> </template> <template match="(^(\s*(public|protected|private)\s*\x3A)?(\s*)(\w+\s+)+\x2A?\s*(\w+))(\s*\x28\s*)((void\s*)|((\w+\s+)+\x2A?\s*\w+\s*(\x2C\s*(\w+\s+)+\x2A?\s*\w+\s*)*))?(\x29\s*)(const\s*)?(throw\s*\x28\s*WEFCException\s*\x26\s*\x29\s*)?(\x3B)\s*$"> <replace>$template{0} $template{1}${suffix}$template{7}$template{8}$template{14}$template{15}$template{16}$template{17} </replace> </template> </xrt> Regards, Kazuyuki ----- Original Message ----- From: "harada" <har...@jp...> To: "Iwan Birrer" <ib...@gm...> Cc: <xwe...@li...> Sent: Thursday, June 08, 2006 12:12 PM Subject: Re: [xweaver-users] How to add interrupting function declaration? > Hello, > >> Yes I think it's ok. If you can provide a patch for the Src2SrcMLC, > > I'm sorry I cannot provide a patch. > In the downloaded XWeaver_0.9.4.zip, the source directory > src/java/net/sf/xweaver has only 'ant' directory, but not 'srcml' > directory. > So I cannot find Src2SrcMLC.java. > > By the way, I notice you the src2srcml I downloaded yesterday > has option -x instead of -e. (Apr-12-2006-Beta) > >> This could be a solution, but there's a simpler one. First of all, it >> would make the problem easier if you didn't annotate the method >> definitions but the method declarations. This would make the following > > I think it a good idea, too. I will add code in the header file : > > -- > #define Ocl_inv(a) > class WEFCAllocator : public WEFCObject { > ... > private: Ocl_inv("check_head(m_lastHead)") void *m_alloc(size_t size) > throw(WEFCException&); > }; > -- > It transforms to such as: > -- > #define Ocl_inv(a) > class WEFCAllocator : public WEFCObject { > ... > private: Ocl_inv("check_head(m_lastHead)") void *aspect_m_alloc(size_t > size) throw(WEFCException&) > { > void *aspect_retval = m_alloc(size); > return(aspect_retval); > }; > private: void *m_alloc(size_t size) throw(WEFCException&); > }; > -- > > But one weak point of this is : > for C function (almost are no declaration), I annotate the method > definitions, but > for C++ function (every has the declaration), I annotate the method > declarations. > I may accustom to coding as such. > >> Could you give me some more information on this? Examples? > > The following Sample.java is a simple sample using ScriptEngine. > It works on Java 1.6. It is likely to jrunscript tool. > > Command "java Sample", then it will be as follows. > > script sample start > script> > > And you input key. > method [name/classname] : print methods of the name object or class > exit : exit Sample > [other] : evaluate as script. > > I put the engine as 'engine'. So > script>method engine > <0> eval(java.io.Reader,javax.script.ScriptContext) > <1> eval(java.lang.String,javax.script.ScriptContext) > <2> createBindings() > ... > > You can see the object > script>java.lang.System.out.println(engine); > com.sun.script.javascript.RhinoScriptEngine@1a2961b > > You can call method for java.** object > script>wr=new java.io.FileWriter("out.txt"); > script>wr.write("1234"); > script>wr.flush(); > > But "js" does not support calling not java.** object directly. > So for another class object, I invoke as follows : > > script>cls=java.lang.Class.forName("javax.swing.JDialog"); > script>constr=cls.getConstructor(null); > script>dialog=constr.newInstance(null); > script>dialog.show(); > > ----------- [Sample.java] ----------- > import java.util.*; > import java.io.*; > import java.lang.reflect.*; > import javax.script.*; > > /** > * sample > */ > public class Sample { > private ScriptEngine m_engine; > > /** > * constructor. > * @param outfile the file name whose print stream is set 'out'. > */ > private Sample() throws IOException > { > String engineName = "js"; > m_engine = new ScriptEngineManager().getEngineByName(engineName); > m_engine.put("engine", m_engine); > } > > /** > * main. > */ > public static void main(String[] args) > { > try { > Sample obj = new Sample(); > obj.run(); > } > catch (Throwable e) { > e.printStackTrace(); > System.exit(-1); > } > System.exit(0); > } > > /** > * > */ > public void run() throws Exception > { > System.out.println("script sample start"); > BufferedReader reader = new BufferedReader(new > InputStreamReader(System.in)); > while (true) { > System.out.print("script>"); > String line = reader.readLine(); > > if (line.equals("exit")) return; > > if (line.startsWith("method ")) { > String name = line.substring(7).trim(); > Object obj = m_engine.get(name); > Class cls = null; > if (obj!=null) cls = obj.getClass(); > else { > try { > cls = Class.forName(name); > } > catch (Exception e) { > e.printStackTrace(); > } > } > if (cls!=null) { > Method[] methods = cls.getMethods(); > for (int i=0;i<methods.length;i++) { > String methodname = methods[i].getName(); > > System.out.print("<" + i + "> " + methodname + > "("); > Class[] cs = methods[i].getParameterTypes(); > for (int j=0;j<cs.length;j++) { > if (j!=0) System.out.print(","); > System.out.print(cs[j].getName()); > } > System.out.println(")"); > } > } > continue; > } > > evaluate(line); > } > } > > /** > * script. > */ > private final Object evaluate(String input) throws Exception > { > return(m_engine.eval(input)); > } > } > > Thank you. > Kazuyuki > > ----- Original Message ----- > From: "Iwan Birrer" <ib...@gm...> > To: "harada" <har...@jp...> > Cc: <xwe...@li...> > Sent: Wednesday, June 07, 2006 9:31 PM > Subject: Re: [xweaver-users] How to add interrupting function declaration? > > >> Hello, >> >> See comments below: >> >> 2006/6/6, harada <har...@jp...>: >>> Hello, >>> >>> I'm trying to use XWeaver for a mocking test. And I have two problems. >>> I've avoided the first one by stripping source comments by Ant API in >>> the >>> present. >>> But I'm considering how to solve the second one. >>> >>> 1) Using XWeaver for my C++ source, I found my comment transformed >>> to broken letters. (The encoding of my source is Shift_JIS.) >>> I found the encoding of the srcML's output is Shift_JIS, >>> but the encoding declaration in the XML Declaration specifies >>> ISO-8859-1. >>> I tried to change the src/xsl/xwproject2ant.xsl adding an xsl:attribute >>> element >>> with name="encoding", but net.sf.xweaver.srcml.ant.Src2SrcMLC >>> does not support encoding attribute. >>> I think the command is ok : src2srcml -e Shift_JIS ... >> >> Yes I think it's ok. If you can provide a patch for the Src2SrcMLC, >> I'll be very happy to apply it to the current source and commit it to >> cvs. I consider this to be solved for now. >> >>> >>> 2) I'd like to change functions annotated by a macro. >>> I can interrupt the C function with the annotated macro >>> adding the declaration. >>> But it is not easy for C++ functions declaration. >>> >>> For example, for a source is the following original source, >>> it is changed as the transformed source by the AspectX data. >>> But for a C++ function the declaration is in another file and >>> I cannot add it. >>> >>> (Problem) >>> For changing the declaration of C++ function with annotated macro, >>> should I parse again the srcML and create AspectX data to weave after >>> weaving? >> >> This could be a solution, but there's a simpler one. First of all, it >> would make the problem easier if you didn't annotate the method >> definitions but the method declarations. This would make the following >> possible: >> Assuming you annotate the method declarations in the C++ declaration >> file (*.h) instead of the method definitions in the C++ implementation >> file (*.cpp). Then you can easely add the declaration in the same file >> by using 'class add declaration' (see [1]). Of course the problem >> remains that you want to add the method definitions in another file, >> i.e. in the implementation file (*.cpp). But for this problem the >> ApsectX language alredy provides the restriction 'isDefinitionOf' (see >> [2], and [3] for an example). With this you can find out the the >> pointcut to the implementation file (src:unit). Having this pointcut >> you can add method definitions using 'unit add definition' (see [4]). >> >> Note that the restriciton 'isDefinitionOf' only works if the >> declaration file (.h) and the definition file (.cpp) both have the >> same name. If this is not the case with your source, you can try to >> write your own restriction (see [5]). >> >> If you can't annotate the method declarations but you really want to >> annotate the method definitions, you need another restriction that >> finds out the declaration file (.h) from an implementation file >> (.cpp), something like 'isDeclarationOf'. It should be easy to >> implement this if you look at the implementation of the >> 'isDefinitionOf' restriction. >> >> >> [1] >> http://www.xweaver.org/XSLTdoc/weaverRules/cpp/class_add_declaration.xsl.xd.html >> [2] http://www.xweaver.org/AspectX/LanguageGuide.html#Restrictions >> [3] >> http://www.xweaver.org/AspectXLib/Aspect_CarPreCondition.src.html#d44340e114 >> [4] >> http://www.xweaver.org/XSLTdoc/weaverRules/cpp/unit_add_definition.xsl.xd.html >> [5] http://www.xweaver.org/Development/ExtensionsHowTo.html#Restrictions >> >>> I think it would be easier to use if you support a script tag >>> in Aspect program by javax.script.ScriptEngine >>> putting the context node to the engine with some name. >>> (But it might not be better.) >> >> Could you give me some more information on this? Examples? >> >> Let me know if you need further assistance. >> >> Regards, >> Iwan > |
From: harada <har...@jp...> - 2006-06-08 03:08:02
|
Hello, > Yes I think it's ok. If you can provide a patch for the Src2SrcMLC, I'm sorry I cannot provide a patch. In the downloaded XWeaver_0.9.4.zip, the source directory src/java/net/sf/xweaver has only 'ant' directory, but not 'srcml' directory. So I cannot find Src2SrcMLC.java. By the way, I notice you the src2srcml I downloaded yesterday has option -x instead of -e. (Apr-12-2006-Beta) > This could be a solution, but there's a simpler one. First of all, it > would make the problem easier if you didn't annotate the method > definitions but the method declarations. This would make the following I think it a good idea, too. I will add code in the header file : -- #define Ocl_inv(a) class WEFCAllocator : public WEFCObject { ... private: Ocl_inv("check_head(m_lastHead)") void *m_alloc(size_t size) throw(WEFCException&); }; -- It transforms to such as: -- #define Ocl_inv(a) class WEFCAllocator : public WEFCObject { ... private: Ocl_inv("check_head(m_lastHead)") void *aspect_m_alloc(size_t size) throw(WEFCException&) { void *aspect_retval = m_alloc(size); return(aspect_retval); }; private: void *m_alloc(size_t size) throw(WEFCException&); }; -- But one weak point of this is : for C function (almost are no declaration), I annotate the method definitions, but for C++ function (every has the declaration), I annotate the method declarations. I may accustom to coding as such. > Could you give me some more information on this? Examples? The following Sample.java is a simple sample using ScriptEngine. It works on Java 1.6. It is likely to jrunscript tool. Command "java Sample", then it will be as follows. script sample start script> And you input key. method [name/classname] : print methods of the name object or class exit : exit Sample [other] : evaluate as script. I put the engine as 'engine'. So script>method engine <0> eval(java.io.Reader,javax.script.ScriptContext) <1> eval(java.lang.String,javax.script.ScriptContext) <2> createBindings() ... You can see the object script>java.lang.System.out.println(engine); com.sun.script.javascript.RhinoScriptEngine@1a2961b You can call method for java.** object script>wr=new java.io.FileWriter("out.txt"); script>wr.write("1234"); script>wr.flush(); But "js" does not support calling not java.** object directly. So for another class object, I invoke as follows : script>cls=java.lang.Class.forName("javax.swing.JDialog"); script>constr=cls.getConstructor(null); script>dialog=constr.newInstance(null); script>dialog.show(); ----------- [Sample.java] ----------- import java.util.*; import java.io.*; import java.lang.reflect.*; import javax.script.*; /** * sample */ public class Sample { private ScriptEngine m_engine; /** * constructor. * @param outfile the file name whose print stream is set 'out'. */ private Sample() throws IOException { String engineName = "js"; m_engine = new ScriptEngineManager().getEngineByName(engineName); m_engine.put("engine", m_engine); } /** * main. */ public static void main(String[] args) { try { Sample obj = new Sample(); obj.run(); } catch (Throwable e) { e.printStackTrace(); System.exit(-1); } System.exit(0); } /** * */ public void run() throws Exception { System.out.println("script sample start"); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); while (true) { System.out.print("script>"); String line = reader.readLine(); if (line.equals("exit")) return; if (line.startsWith("method ")) { String name = line.substring(7).trim(); Object obj = m_engine.get(name); Class cls = null; if (obj!=null) cls = obj.getClass(); else { try { cls = Class.forName(name); } catch (Exception e) { e.printStackTrace(); } } if (cls!=null) { Method[] methods = cls.getMethods(); for (int i=0;i<methods.length;i++) { String methodname = methods[i].getName(); System.out.print("<" + i + "> " + methodname + "("); Class[] cs = methods[i].getParameterTypes(); for (int j=0;j<cs.length;j++) { if (j!=0) System.out.print(","); System.out.print(cs[j].getName()); } System.out.println(")"); } } continue; } evaluate(line); } } /** * script. */ private final Object evaluate(String input) throws Exception { return(m_engine.eval(input)); } } Thank you. Kazuyuki ----- Original Message ----- From: "Iwan Birrer" <ib...@gm...> To: "harada" <har...@jp...> Cc: <xwe...@li...> Sent: Wednesday, June 07, 2006 9:31 PM Subject: Re: [xweaver-users] How to add interrupting function declaration? > Hello, > > See comments below: > > 2006/6/6, harada <har...@jp...>: >> Hello, >> >> I'm trying to use XWeaver for a mocking test. And I have two problems. >> I've avoided the first one by stripping source comments by Ant API in the >> present. >> But I'm considering how to solve the second one. >> >> 1) Using XWeaver for my C++ source, I found my comment transformed >> to broken letters. (The encoding of my source is Shift_JIS.) >> I found the encoding of the srcML's output is Shift_JIS, >> but the encoding declaration in the XML Declaration specifies >> ISO-8859-1. >> I tried to change the src/xsl/xwproject2ant.xsl adding an xsl:attribute >> element >> with name="encoding", but net.sf.xweaver.srcml.ant.Src2SrcMLC >> does not support encoding attribute. >> I think the command is ok : src2srcml -e Shift_JIS ... > > Yes I think it's ok. If you can provide a patch for the Src2SrcMLC, > I'll be very happy to apply it to the current source and commit it to > cvs. I consider this to be solved for now. > >> >> 2) I'd like to change functions annotated by a macro. >> I can interrupt the C function with the annotated macro >> adding the declaration. >> But it is not easy for C++ functions declaration. >> >> For example, for a source is the following original source, >> it is changed as the transformed source by the AspectX data. >> But for a C++ function the declaration is in another file and >> I cannot add it. >> >> (Problem) >> For changing the declaration of C++ function with annotated macro, >> should I parse again the srcML and create AspectX data to weave after >> weaving? > > This could be a solution, but there's a simpler one. First of all, it > would make the problem easier if you didn't annotate the method > definitions but the method declarations. This would make the following > possible: > Assuming you annotate the method declarations in the C++ declaration > file (*.h) instead of the method definitions in the C++ implementation > file (*.cpp). Then you can easely add the declaration in the same file > by using 'class add declaration' (see [1]). Of course the problem > remains that you want to add the method definitions in another file, > i.e. in the implementation file (*.cpp). But for this problem the > ApsectX language alredy provides the restriction 'isDefinitionOf' (see > [2], and [3] for an example). With this you can find out the the > pointcut to the implementation file (src:unit). Having this pointcut > you can add method definitions using 'unit add definition' (see [4]). > > Note that the restriciton 'isDefinitionOf' only works if the > declaration file (.h) and the definition file (.cpp) both have the > same name. If this is not the case with your source, you can try to > write your own restriction (see [5]). > > If you can't annotate the method declarations but you really want to > annotate the method definitions, you need another restriction that > finds out the declaration file (.h) from an implementation file > (.cpp), something like 'isDeclarationOf'. It should be easy to > implement this if you look at the implementation of the > 'isDefinitionOf' restriction. > > > [1] > http://www.xweaver.org/XSLTdoc/weaverRules/cpp/class_add_declaration.xsl.xd.html > [2] http://www.xweaver.org/AspectX/LanguageGuide.html#Restrictions > [3] > http://www.xweaver.org/AspectXLib/Aspect_CarPreCondition.src.html#d44340e114 > [4] > http://www.xweaver.org/XSLTdoc/weaverRules/cpp/unit_add_definition.xsl.xd.html > [5] http://www.xweaver.org/Development/ExtensionsHowTo.html#Restrictions > >> I think it would be easier to use if you support a script tag >> in Aspect program by javax.script.ScriptEngine >> putting the context node to the engine with some name. >> (But it might not be better.) > > Could you give me some more information on this? Examples? > > Let me know if you need further assistance. > > Regards, > Iwan |
From: Iwan B. <ib...@gm...> - 2006-06-07 20:06:27
|
Hello, See comments below: 2006/6/6, harada <har...@jp...>: > Hello, > > I'm trying to use XWeaver for a mocking test. And I have two problems. > I've avoided the first one by stripping source comments by Ant API in the > present. > But I'm considering how to solve the second one. > > 1) Using XWeaver for my C++ source, I found my comment transformed > to broken letters. (The encoding of my source is Shift_JIS.) > I found the encoding of the srcML's output is Shift_JIS, > but the encoding declaration in the XML Declaration specifies ISO-8859-1. > I tried to change the src/xsl/xwproject2ant.xsl adding an xsl:attribute > element > with name="encoding", but net.sf.xweaver.srcml.ant.Src2SrcMLC > does not support encoding attribute. > I think the command is ok : src2srcml -e Shift_JIS ... Yes I think it's ok. If you can provide a patch for the Src2SrcMLC, I'll be very happy to apply it to the current source and commit it to cvs. I consider this to be solved for now. > > 2) I'd like to change functions annotated by a macro. > I can interrupt the C function with the annotated macro > adding the declaration. > But it is not easy for C++ functions declaration. > > For example, for a source is the following original source, > it is changed as the transformed source by the AspectX data. > But for a C++ function the declaration is in another file and > I cannot add it. > > (Problem) > For changing the declaration of C++ function with annotated macro, > should I parse again the srcML and create AspectX data to weave after > weaving? This could be a solution, but there's a simpler one. First of all, it would make the problem easier if you didn't annotate the method definitions but the method declarations. This would make the following possible: Assuming you annotate the method declarations in the C++ declaration file (*.h) instead of the method definitions in the C++ implementation file (*.cpp). Then you can easely add the declaration in the same file by using 'class add declaration' (see [1]). Of course the problem remains that you want to add the method definitions in another file, i.e. in the implementation file (*.cpp). But for this problem the ApsectX language alredy provides the restriction 'isDefinitionOf' (see [2], and [3] for an example). With this you can find out the the pointcut to the implementation file (src:unit). Having this pointcut you can add method definitions using 'unit add definition' (see [4]). Note that the restriciton 'isDefinitionOf' only works if the declaration file (.h) and the definition file (.cpp) both have the same name. If this is not the case with your source, you can try to write your own restriction (see [5]). If you can't annotate the method declarations but you really want to annotate the method definitions, you need another restriction that finds out the declaration file (.h) from an implementation file (.cpp), something like 'isDeclarationOf'. It should be easy to implement this if you look at the implementation of the 'isDefinitionOf' restriction. [1] http://www.xweaver.org/XSLTdoc/weaverRules/cpp/class_add_declaration.xsl.xd.html [2] http://www.xweaver.org/AspectX/LanguageGuide.html#Restrictions [3] http://www.xweaver.org/AspectXLib/Aspect_CarPreCondition.src.html#d44340e114 [4] http://www.xweaver.org/XSLTdoc/weaverRules/cpp/unit_add_definition.xsl.xd.html [5] http://www.xweaver.org/Development/ExtensionsHowTo.html#Restrictions > I think it would be easier to use if you support a script tag > in Aspect program by javax.script.ScriptEngine > putting the context node to the engine with some name. > (But it might not be better.) Could you give me some more information on this? Examples? Let me know if you need further assistance. Regards, Iwan |