<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" version="2.0">

<channel>
	<title>Loom Blog</title>
	
	<link>http://loom.ninjitsoft.com</link>
	<description>Loom is an Aspect-Oriented Programming (AOP) and Bytecode Weaving Library for ActionScript 3 (AS3)</description>
	<pubDate>Mon, 11 Jan 2010 23:21:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/LoomBlog" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="loomblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Loom is Dead</title>
		<link>http://loom.ninjitsoft.com/?p=79</link>
		<comments>http://loom.ninjitsoft.com/?p=79#comments</comments>
		<pubDate>Mon, 11 Jan 2010 23:21:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://loom.ninjitsoft.com/?p=79</guid>
		<description><![CDATA[Unfortunately, I ran out of motivation for Loom. I solicited some people to take over the project on the mailing lists, but without any takers, I think it&#8217;s time we called it.
There&#8217;s been some very nice work done in the AS3 bytecode generation space by Richard Szalay (FLemit and FLoxy), and mocking implementations (my original [...]]]></description>
			<content:encoded><![CDATA[<p>Unfortunately, I ran out of motivation for Loom. I solicited some people to take over the project on the mailing lists, but without any takers, I think it&#8217;s time we called it.</p>
<p>There&#8217;s been some very nice work done in the AS3 bytecode generation space by Richard Szalay (<a href="http://code.google.com/p/flemit/">FLemit</a> and <a href="http://code.google.com/p/floxy/">FLoxy</a>), and mocking implementations (my original motivation for Loom) by both Richard (<a href="asmock.sourceforge.net/">ASMock</a>) and Drew Bourne (<a href="http://code.google.com/p/mock-as3/">mock-as3</a> and <a href="http://github.com/drewbourne/mockolate">mockolate</a>). I encourage you to check out and support their work.</p>
<p>I&#8217;m leaving the source for Loom <a href="http://code.google.com/p/loom-as3/source/checkout">out on the web</a>, of course. I know at least one person on the Tamarin lists has been using it as a reference for a project they are working on. I learned a lot from the process of writing Loom, and I hope that others find it useful too. If you are interested in taking over the project or learning more about the implementation, please contact me using the contact link on this site.</p>
<p>Thanks to everybody on the Loom forums and across the world for motivation, encouragement, and support. Long live Flex and AS3!</p>
]]></content:encoded>
			<wfw:commentRss>http://loom.ninjitsoft.com/?feed=rss2&amp;p=79</wfw:commentRss>
		</item>
		<item>
		<title>Loom Source Posted</title>
		<link>http://loom.ninjitsoft.com/?p=76</link>
		<comments>http://loom.ninjitsoft.com/?p=76#comments</comments>
		<pubDate>Fri, 04 Sep 2009 01:35:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://loom.ninjitsoft.com/?p=76</guid>
		<description><![CDATA[Loom is still a work in progress, but it was time to get the source out there so the project can get some momentum from contributors. You can now find it on the Google Code site for the Loom project.
]]></description>
			<content:encoded><![CDATA[<p>Loom is still a work in progress, but it was time to get the source out there so the project can get some momentum from contributors. You can now find it on the <a href="http://code.google.com/p/loom-as3/source/checkout">Google Code site for the Loom project</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://loom.ninjitsoft.com/?feed=rss2&amp;p=76</wfw:commentRss>
		</item>
		<item>
		<title>Looking for Loom Contributors</title>
		<link>http://loom.ninjitsoft.com/?p=73</link>
		<comments>http://loom.ninjitsoft.com/?p=73#comments</comments>
		<pubDate>Wed, 29 Jul 2009 02:56:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://loom.ninjitsoft.com/?p=73</guid>
		<description><![CDATA[Check out the details on the Loom discussion group (which is no longer private so come on in!)  
]]></description>
			<content:encoded><![CDATA[<p>Check out the details on the <a href="http://groups.google.com/group/loom-as3/browse_thread/thread/230bdfec65bea84f">Loom discussion group</a> (which is no longer private so come on in!) <img src='http://loom.ninjitsoft.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://loom.ninjitsoft.com/?feed=rss2&amp;p=73</wfw:commentRss>
		</item>
		<item>
		<title>greaterequals Opcode in Tamarin/AVM2 Spec</title>
		<link>http://loom.ninjitsoft.com/?p=68</link>
		<comments>http://loom.ninjitsoft.com/?p=68#comments</comments>
		<pubDate>Sat, 23 May 2009 16:19:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://loom.ninjitsoft.com/?p=68</guid>
		<description><![CDATA[While working on Loom today, I ran across the opcode 0xaf, which matches two opcodes in the AVM2 spec: greaterthan and greaterequals. Checking the AVM2 spec errata on the Tamarin project page produced the following:
&#8220;On page 66, instruction name is greaterequals but format, forms, and description are those of greaterthan&#8217;.&#8221;
Awesome. Thanks guys, that really helps [...]]]></description>
			<content:encoded><![CDATA[<p>While working on Loom today, I ran across the opcode <code>0xaf</code>, which matches two opcodes in the AVM2 spec: <code>greaterthan</code> and <code>greaterequals</code>. Checking the <a href="https://wiki.mozilla.org/Tamarin::AVM2_Overview_Errata">AVM2 spec errata</a> on the Tamarin project page produced the following:</p>
<p><i>&#8220;On page 66, instruction name is greaterequals but format, forms, and description are those of greaterthan&#8217;.&#8221;</i></p>
<p>Awesome. Thanks guys, that really helps me to know what the PROPER OPCODE VALUE IS SUPPOSED TO BE. It&#8217;s obviously in the source code for the Tamarin C++ project, but it would have been nice if somebody had put this on the errata.</p>
<p>So, to clarify the matter once and for all:<br />
<code>greaterequals:</code> <code>0xb0</code><br />
<code>greaterthan:</code> <code>0xaf</code></p>
]]></content:encoded>
			<wfw:commentRss>http://loom.ninjitsoft.com/?feed=rss2&amp;p=68</wfw:commentRss>
		</item>
		<item>
		<title>Loom Private Alpha 4 Released</title>
		<link>http://loom.ninjitsoft.com/?p=66</link>
		<comments>http://loom.ninjitsoft.com/?p=66#comments</comments>
		<pubDate>Wed, 22 Apr 2009 05:25:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://loom.ninjitsoft.com/?p=66</guid>
		<description><![CDATA[Got the issue with getters/setters fixed, so they are now fully advisable. I think I have also figured out why custom namespaced functions are not advisable, but since I don&#8217;t think custom namespace functions get used terribly regularly by most developers, I am planning on putting this item behind the SWFLoader, which is the bit [...]]]></description>
			<content:encoded><![CDATA[<p>Got the issue with getters/setters fixed, so they are now fully advisable. I think I have also figured out why custom namespaced functions are not advisable, but since I don&#8217;t think custom namespace functions get used terribly regularly by most developers, I am planning on putting this item behind the SWFLoader, which is the bit that will make Loom useful for mainstream Flex development.</p>
<p>Of course, not much will be happening on this front for a few weeks since I am getting married on Saturday, and have family in town most of the week. I&#8217;ll be back on Loom full force when I return from vacation in May.</p>
]]></content:encoded>
			<wfw:commentRss>http://loom.ninjitsoft.com/?feed=rss2&amp;p=66</wfw:commentRss>
		</item>
		<item>
		<title>Loom Private Alpha 3 Released</title>
		<link>http://loom.ninjitsoft.com/?p=64</link>
		<comments>http://loom.ninjitsoft.com/?p=64#comments</comments>
		<pubDate>Fri, 17 Apr 2009 14:40:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://loom.ninjitsoft.com/?p=64</guid>
		<description><![CDATA[Last night I fixed the issues with advising methods with ...rest and optional arguments, and came up with a potentially nifty strategy for dealing with getter/setter advice.
Getters/setters are a little harder to advise since their functions are seen by the AVM as properties, and as a result you can&#8217;t pass their function references around. I [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I fixed the issues with advising methods with <code>...rest</code> and optional arguments, and came up with a potentially nifty strategy for dealing with getter/setter advice.</p>
<p>Getters/setters are a little harder to advise since their functions are seen by the AVM as properties, and as a result you can&#8217;t pass their function references around. I think I have it tackled though, and should have it all working in a few days.</p>
]]></content:encoded>
			<wfw:commentRss>http://loom.ninjitsoft.com/?feed=rss2&amp;p=64</wfw:commentRss>
		</item>
		<item>
		<title>Loom Private Alpha 2 Released</title>
		<link>http://loom.ninjitsoft.com/?p=61</link>
		<comments>http://loom.ninjitsoft.com/?p=61#comments</comments>
		<pubDate>Thu, 16 Apr 2009 18:20:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[Loom]]></category>

		<guid isPermaLink="false">http://loom.ninjitsoft.com/?p=61</guid>
		<description><![CDATA[Last night, I released the second private alpha to the Loom discussion group. Loom can now subclass any base class. There are a few known issues with certain method signatures and another small issue with getters and setters.
I&#8217;ll be remedying these issues this week with a view to a third private alpha by the close [...]]]></description>
			<content:encoded><![CDATA[<p>Last night, I released the second private alpha to the <a href="http://groups.google.com/group/loom-as3">Loom discussion group</a>. Loom can now subclass any base class. There are a few known issues with certain method signatures and another small issue with getters and setters.</p>
<p>I&#8217;ll be remedying these issues this week with a view to a third private alpha by the close of the upcoming weekend, after which I&#8217;ll be back on the SWFLoader in preparation for a public beta. I&#8217;m hoping to get this all out before I get married on 4/25, since after that I&#8217;ll be out of action for a few weeks in Europe on our honeymoon!</p>
]]></content:encoded>
			<wfw:commentRss>http://loom.ninjitsoft.com/?feed=rss2&amp;p=61</wfw:commentRss>
		</item>
		<item>
		<title>VerifyError: Error #1032: Cpool index X is out of range X</title>
		<link>http://loom.ninjitsoft.com/?p=57</link>
		<comments>http://loom.ninjitsoft.com/?p=57#comments</comments>
		<pubDate>Sat, 11 Apr 2009 06:47:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[AVM]]></category>

		<guid isPermaLink="false">http://loom.ninjitsoft.com/?p=57</guid>
		<description><![CDATA[Whenever you are working with an ABC file and loading it in to the AVM, the AVM will validate the ABC on the way in. I ran in to an issue tonight where I was dynamically weaving the opcodes for a method in Loom, and I forgot to add a NamespaceSet to the ConstantPool. If [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever you are working with an ABC file and loading it in to the AVM, the AVM will validate the ABC on the way in. I ran in to an issue tonight where I was dynamically weaving the opcodes for a method in Loom, and I forgot to add a NamespaceSet to the ConstantPool. If you do something like this, you end up with this rather nondescript error.</p>
<p>Now, in fairness, the AVM does tell you that there is a problem with the constant pool and it does tell you which index it can&#8217;t find. If your index was 6 for example (which my one was), it means that one of the parts of your ABC file references the <i>seventh</i> item in a pool that has less than seven items (since the code in the AVM is written in C++ and is 0-based for collection indices). Typically this would not be confusing for a programmer, but the ABC code starts at 1-based positions for all the constant pools, and after thinking that way for a while you can get tricked by error messages that don&#8217;t indicate what the starting loop position is.</p>
<p>Hopefully you won&#8217;t run in to this issue, but if you do, now you&#8217;ll know why.</p>
]]></content:encoded>
			<wfw:commentRss>http://loom.ninjitsoft.com/?feed=rss2&amp;p=57</wfw:commentRss>
		</item>
		<item>
		<title>Private Loom Alpha Released</title>
		<link>http://loom.ninjitsoft.com/?p=54</link>
		<comments>http://loom.ninjitsoft.com/?p=54#comments</comments>
		<pubDate>Sat, 11 Apr 2009 06:44:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[Loom]]></category>

		<guid isPermaLink="false">http://loom.ninjitsoft.com/?p=54</guid>
		<description><![CDATA[I just sent the Loom library out for a private alpha with a limited group of people. If you are interested in joining in, just ping me on the contact form on this blog or hit me up directly from the Loom discussion group.
]]></description>
			<content:encoded><![CDATA[<p>I just sent the Loom library out for a private alpha with a limited group of people. If you are interested in joining in, just ping me on the contact form on this blog or hit me up directly from the <a href="http://groups.google.com/group/loom-as3">Loom discussion group</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://loom.ninjitsoft.com/?feed=rss2&amp;p=54</wfw:commentRss>
		</item>
		<item>
		<title>Loom Lives!</title>
		<link>http://loom.ninjitsoft.com/?p=45</link>
		<comments>http://loom.ninjitsoft.com/?p=45#comments</comments>
		<pubDate>Fri, 10 Apr 2009 16:37:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[Loom]]></category>

		<guid isPermaLink="false">http://loom.ninjitsoft.com/?p=45</guid>
		<description><![CDATA[About fifteen minutes ago, I successfully weaved the final opcodes required to create an AOP dynamic proxy with Loom. I am totally stoked.
It&#8217;s been almost three months of work, admittedly on and off. I think if I strung together all the hours I have put in to the project, it would be about 120-160 hours [...]]]></description>
			<content:encoded><![CDATA[<p>About fifteen minutes ago, I successfully weaved the final opcodes required to create an AOP dynamic proxy with Loom. I am totally stoked.</p>
<p>It&#8217;s been almost three months of work, admittedly on and off. I think if I strung together all the hours I have put in to the project, it would be about 120-160 hours altogether here and there. The first revision of the ABC parser that I worked on in January and February worked great but wasn&#8217;t very usable, so it ended up getting replaced by the new version. The new version of the parser and serializer along with the opcode enumeration are a big improvement, and were so easy to use that I was able to weave a dynamic proxy in just a few hours (most of which was spent tackling the learning curve of AVM &#8220;assembly&#8221; and diagnosing/fixing an opcode bug I found along the way).</p>
<p>So without further ado, here&#8217;s a sneak peak in to the unfinished API for Loom. Below is a copy of a really quick n&#8217; dirty test case that I put together to make sure that Loom was working as expected. The test case does as follows.</p>
<p>1) Loads the ABC bytecode for a class called loom.template:BaseClass.<br />
2) Parses the ABC code and enhances it with several Loom-related items: a <code>Dictionary</code> to hold anonymous advise handling functions, a <code>setHandler()</code> method to accept these functions, and a method call <code>proxyInvocation()</code> that handles dynamic method invocation.<br />
3) Stomps the opcodes for all the instance methods with dynamically weaved opcodes that tell the method to invoke <code>proxyInvocation()</code>.<br />
4) Re-serializes the enhanced class definition to ABC bytecode.<br />
5) Loads the enhanced bytecode in to the Flash Player/AVM</p>
<p>Then we run the tests. The bytecode loading in step #5 is currently asynchronous so I have to do this through an event listener, but the next item for me to write is a Loom SWF loader that will enhance bytecode on the fly, making it appear to the app as if the proxy definitions were added by the compiler.</p>
<p>Without further ado, here&#8217;s the code. I&#8217;ll be releasing Loom as a private alpha this weekend (so touch base via the contact form on this blog if you want to be added to the list of testers), and a public beta will be made available once the SWF loader is finished.</p>
<p><b>BaseClass.as</b></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> loom.template
<span style="color: #000000;">&#123;</span>
  <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> BaseClass
  <span style="color: #000000;">&#123;</span>    
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> BaseClass<span style="color: #000000;">&#40;</span>constructorArg1 <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span>, constructorArg2 <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;BaseClass::constructor()&quot;</span><span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> methodCallOne<span style="color: #000000;">&#40;</span>arg1 <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span>, arg2 <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">int</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;BaseClass::methodCallOne()&quot;</span><span style="color: #000000;">&#41;</span>;
      <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #000000; font-weight:bold;">100</span>;
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> methodCallTwo<span style="color: #000000;">&#40;</span>arg1 <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span>, arg2 <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Number</span>, arg3 <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;BaseClass::methodCallTwo()&quot;</span><span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span> 
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> methodCallThree<span style="color: #000000;">&#40;</span>arg1 <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span>, arg2 <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;BaseClass::methodCallThree()&quot;</span><span style="color: #000000;">&#41;</span>;
      <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #990000;">&quot;stringValue&quot;</span>;
    <span style="color: #000000;">&#125;</span>
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><b>Quick n&#8217; Dirty Test Demonstrating Loom Weaving a Dynamic Subclass</b></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> loom.util
<span style="color: #000000;">&#123;</span>
  <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
  <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">describeType</span>;
  <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">getDefinitionByName</span>;
&nbsp;
  <span style="color: #0033ff; font-weight: bold;">import</span> loom.TestConstants;
  <span style="color: #0033ff; font-weight: bold;">import</span> loom.abc.AbcFile;
  <span style="color: #0033ff; font-weight: bold;">import</span> loom.loom_namespace;
  <span style="color: #0033ff; font-weight: bold;">import</span> loom.swf.AbcClassLoader;
  <span style="color: #0033ff; font-weight: bold;">import</span> loom.template.BaseClass;
  <span style="color: #0033ff; font-weight: bold;">import</span> loom.template.MethodInvocation;
&nbsp;
  <span style="color: #0033ff; font-weight: bold;">import</span> net.digitalprimates.fluint.tests.TestCase;
&nbsp;
  <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> DynamicProxyFactoryTest extends TestCase
  <span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> testCreateProxy<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #6699cc; font-weight: bold;">var</span> fixture <span style="color: #000000; font-weight: bold;">:</span> DynamicProxyFactory = <span style="color: #0033ff; font-weight: bold;">new</span> DynamicProxyFactory<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
      <span style="color: #6699cc; font-weight: bold;">var</span> proxyFile <span style="color: #000000; font-weight: bold;">:</span> AbcFile = <span style="color: #0033ff; font-weight: bold;">new</span> AbcDeserializer<span style="color: #000000;">&#40;</span>TestConstants.getBaseClassTemplate<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.deserialize<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
      <span style="color: #009900;">// We enhance the loaded ABC file to save the work the compiler already did, and just add to/replace it</span>
      fixture.createProxy<span style="color: #000000;">&#40;</span>proxyFile<span style="color: #000000;">&#41;</span>;
&nbsp;
      <span style="color: #6699cc; font-weight: bold;">var</span> classLoader <span style="color: #000000; font-weight: bold;">:</span> AbcClassLoader = <span style="color: #0033ff; font-weight: bold;">new</span> AbcClassLoader<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
      classLoader.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>
        <span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span>,
        <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #000000;">&#40;</span>event <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
        <span style="color: #000000;">&#123;</span>
          <span style="color: #6699cc; font-weight: bold;">var</span> classRef <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight: bold;">*</span> = <span style="color: #004993;">getDefinitionByName</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;loom.template::DynamicSubClass&quot;</span><span style="color: #000000;">&#41;</span>;
          <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">describeType</span><span style="color: #000000;">&#40;</span>classRef<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
          <span style="color: #009900;">// This would blow up if the types are not compatible</span>
          <span style="color: #6699cc; font-weight: bold;">var</span> instance <span style="color: #000000; font-weight: bold;">:</span> BaseClass = <span style="color: #0033ff; font-weight: bold;">new</span> classRef<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">null</span>, <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>;
          assertTrue<span style="color: #000000;">&#40;</span>instance <span style="color: #0033ff; font-weight: bold;">is</span> BaseClass<span style="color: #000000;">&#41;</span>; <span style="color: #009900;">// redundant, yet satisfying :)</span>
&nbsp;
          <span style="color: #009900;">// Run original method invocation</span>
          <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;&gt;&gt;&gt; Original method invocation&quot;</span><span style="color: #000000;">&#41;</span>;
          <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>instance.methodCallOne<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Hello Original Method Invocation!&quot;</span>, <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
          <span style="color: #009900;">// Set up a handler</span>
          instance.loom_namespace<span style="color: #000000; font-weight: bold;">::</span>setHandler<span style="color: #000000;">&#40;</span>
            <span style="color: #990000;">&quot;methodCallOne&quot;</span>,
            <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #000000;">&#40;</span>invocation <span style="color: #000000; font-weight: bold;">:</span> MethodInvocation<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight: bold;">*</span>
            <span style="color: #000000;">&#123;</span>
              <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Before advice for: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> invocation<span style="color: #000000;">&#41;</span>;
&nbsp;
              <span style="color: #0033ff; font-weight: bold;">try</span>
              <span style="color: #000000;">&#123;</span>
                <span style="color: #0033ff; font-weight: bold;">return</span> invocation.proceed<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
              <span style="color: #000000;">&#125;</span>
              <span style="color: #0033ff; font-weight: bold;">catch</span> <span style="color: #000000;">&#40;</span>e <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Error</span><span style="color: #000000;">&#41;</span>
              <span style="color: #000000;">&#123;</span>
                <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Throws advice for: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> e<span style="color: #000000;">&#41;</span>;
              <span style="color: #000000;">&#125;</span>
              finally
              <span style="color: #000000;">&#123;</span>
                <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;After advice for: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> invocation<span style="color: #000000;">&#41;</span>;
              <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
          <span style="color: #000000;">&#41;</span>;
          <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;&gt;&gt;&gt; AOP method invocation&quot;</span><span style="color: #000000;">&#41;</span>;
          <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>instance.methodCallOne<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Hello Dynamic Method Invocation!&quot;</span>, <span style="color: #000000; font-weight:bold;">1234</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
      <span style="color: #000000;">&#41;</span>;
&nbsp;
      <span style="color: #009900;">// Load in the proxied class definition</span>
      classLoader.loadClassDefinitionsFromBytecode<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>
       <span style="color: #0033ff; font-weight: bold;">new</span> AbcSerializer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.serializeAbcFile<span style="color: #000000;">&#40;</span>proxyFile<span style="color: #000000;">&#41;</span>
      <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><b>Output</b></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;loom.template::DynamicSubClass&quot;</span> <span style="color: #000066;">base</span>=<span style="color: #ff0000;">&quot;Class&quot;</span> <span style="color: #000066;">isDynamic</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">isFinal</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">isStatic</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;extendsClass</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Class&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;extendsClass</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Object&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;accessor</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;prototype&quot;</span> <span style="color: #000066;">access</span>=<span style="color: #ff0000;">&quot;readonly&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">declaredBy</span>=<span style="color: #ff0000;">&quot;Class&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;factory</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;loom.template::DynamicSubClass&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;extendsClass</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;loom.template::BaseClass&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;extendsClass</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Object&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> <span style="color: #000066;">optional</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> <span style="color: #000066;">optional</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/constructor<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;methodCallThree&quot;</span> <span style="color: #000066;">declaredBy</span>=<span style="color: #ff0000;">&quot;loom.template::DynamicSubClass&quot;</span> <span style="color: #000066;">returnType</span>=<span style="color: #ff0000;">&quot;String&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> <span style="color: #000066;">optional</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Number&quot;</span> <span style="color: #000066;">optional</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/method<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;variable</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;handlerMappings&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;flash.utils::Dictionary&quot;</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;http://loom.ninjitsoft.com&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;setHandler&quot;</span> <span style="color: #000066;">declaredBy</span>=<span style="color: #ff0000;">&quot;loom.template::DynamicSubClass&quot;</span> <span style="color: #000066;">returnType</span>=<span style="color: #ff0000;">&quot;void&quot;</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;http://loom.ninjitsoft.com&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> <span style="color: #000066;">optional</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Function&quot;</span> <span style="color: #000066;">optional</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/method<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;methodCallOne&quot;</span> <span style="color: #000066;">declaredBy</span>=<span style="color: #ff0000;">&quot;loom.template::DynamicSubClass&quot;</span> <span style="color: #000066;">returnType</span>=<span style="color: #ff0000;">&quot;int&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> <span style="color: #000066;">optional</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Number&quot;</span> <span style="color: #000066;">optional</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/method<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;methodCallTwo&quot;</span> <span style="color: #000066;">declaredBy</span>=<span style="color: #ff0000;">&quot;loom.template::DynamicSubClass&quot;</span> <span style="color: #000066;">returnType</span>=<span style="color: #ff0000;">&quot;void&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> <span style="color: #000066;">optional</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Number&quot;</span> <span style="color: #000066;">optional</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Object&quot;</span> <span style="color: #000066;">optional</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/method<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;proxyInvocation&quot;</span> <span style="color: #000066;">declaredBy</span>=<span style="color: #ff0000;">&quot;loom.template::DynamicSubClass&quot;</span> <span style="color: #000066;">returnType</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;http://loom.ninjitsoft.com&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">index</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;loom.template::MethodInvocation&quot;</span> <span style="color: #000066;">optional</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/method<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/factory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
BaseClass::constructor()
&gt;&gt;&gt; Original method invocation
BaseClass::methodCallOne()
100
&gt;&gt;&gt; AOP method invocation
Before advice for: methodCallOne(Hello Dynamic Method Invocation!, 1234)
BaseClass::methodCallOne()
After advice for: methodCallOne(Hello Dynamic Method Invocation!, 1234)
100</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://loom.ninjitsoft.com/?feed=rss2&amp;p=45</wfw:commentRss>
		</item>
	</channel>
</rss>
