Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
tutorial [2009/09/07 21:10] aspectscript |
tutorial [2009/10/26 17:55] (current) aspectscript |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Tutorial ====== | ====== Tutorial ====== | ||
| - | Here, you can find a small tutorial of AspectScript. For more information, | + | ===== Getting Started ===== |
| - | ===== Getting Start ===== | + | In order to be able to dynamically weave aspects without modifying a particular JavaScript engine, AspectScript first performs a code transformation phase in which some expressions are rewritten. This instrumentation can be performed in two ways. The first is easier, but less efficient (useful for development). The second is a little bit more complicated, |
| + | |||
| + | === The easy way --- on-line transformation | ||
| + | |||
| + | This option is ideal when you are learning AspectScript or you are developing code, because the code is transformed each time your Javascript script is loaded. For on-line tranformation, | ||
| - | The code transformation can use in two ways. The first is easier, but it is lesser efficient. The second is a little bit more complicated but it is more efficient. | ||
| - | === The easy way === | ||
| - | This way is ideal when you are learning AspectScript or you are editing and testing the JavaScript code. To use AspectScript, | ||
| - | you must change that by: | ||
| <code html> | <code html> | ||
| <script language=" | <script language=" | ||
| </ | </ | ||
| - | The **jst.php** is the PHP file available in AspectScript | + | |
| - | === The efficient way === | + | Where the **jst.php** is the PHP file available in the standard distribution of AspectScript. |
| - | The inefficient | + | |
| + | For instance, [[http:// | ||
| + | |||
| + | === The efficient way - off-line transformation | ||
| + | |||
| + | On-line transformation is a little bit inefficient because the scripts are transformed each time they are requested (on every page load). As an altenative, Javascript scripts | ||
| <code Bash> | <code Bash> | ||
| - | cat script.js | js -f ' | + | cat script.js | js -f ' |
| </ | </ | ||
| - | In the web page you include the new script | + | |
| + | And then, in the web page you include the transformed | ||
| <code html> | <code html> | ||
| - | <script language=" | + | <script language=" |
| </ | </ | ||
| - | ==== Define and Deploy Aspects ==== | + | The **launcher.js** script and the **js** executable are included in the standard AspectScript distribution. |
| - | The aspects of AspectScript are pointcut-advices pairs. The pointcuts | + | |
| - | < | + | ===== Define and Deploy Aspects |
| - | AspectScript.after(AspectScript.Pointcuts.exec(foo), function(jp) { | + | |
| - | alert(" | + | The aspects of AspectScript are just a pointcut-advice pair. Pointcuts |
| - | }); | + | |
| + | < | ||
| + | var pointcut = AspectScript.Pointcuts.exec(foo); | ||
| + | var advice | ||
| + | | ||
| + | }; | ||
| + | AspectScript.after(pointcut, | ||
| </ | </ | ||
| - | ==== For more information | + | ===== For More Information ===== |
| - | You want to learn more about AspectScript, | + | |
| + | This page is still under construction. | ||