bo0liu / as3-commons

Automatically exported from code.google.com/p/as3-commons
0 stars 0 forks source link

Bytecode documentation may need updating #96

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Amazing product! just a few niggles with the documentation on 
http://www.as3commons.org/as3-commons-bytecode/emit.html 
and 
http://www.as3commons.org/as3-commons-bytecode/index.html

Issue 1:
=======

metadataArgument.name = "name";
should be 
metadataArgument.key = "name";

Issue 2:
=======

I get:

TypeError: Error #1009: Cannot access a property or method of a null object 
reference.
at 
org.as3commons.bytecode.emit.impl::MetadataBuilder/defineArgument(MetadataBuilde
r.as:66)

Unless I do this:

metadataBuilder.arguments = [];

Issue 3:
=======

The link AVM2 Instructions 
(http://learn.adobe.com/wiki/display/AVM2/5.+AVM2+instructions) is really 
uninformative 
It would be good to link to 
http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/actionscrip
t/articles/avm2overview.pdf instead

Issue 4:
=======

Documented dependency with logging api missing from page:
http://www.as3commons.org/as3-commons-bytecode/index.html

VerifyError: Error #1014: Class org.as3commons.logging.api::ILogger could not 
be found.
at 
org.as3commons.bytecode.emit.impl::ClassBuilder/build()[C:\projects\as3-commons\
as3-commons-bytecode\src\main\actionscript\org\as3commons\bytecode\emit\impl\Cla
ssBuilder.as:223]
at 
org.as3commons.bytecode.emit.impl::PackageBuilder/build()[C:\projects\as3-common
s\as3-commons-bytecode\src\main\actionscript\org\as3commons\bytecode\emit\impl\P
ackageBuilder.as:160]
at 
org.as3commons.bytecode.emit.impl::AbcBuilder/build()[C:\projects\as3-commons\as
3-commons-bytecode\src\main\actionscript\org\as3commons\bytecode\emit\impl\AbcBu
ilder.as:248]
at 
org.as3commons.bytecode.emit.impl::AbcBuilder/buildAndLoad()[C:\projects\as3-com
mons\as3-commons-bytecode\src\main\actionscript\org\as3commons\bytecode\emit\imp
l\AbcBuilder.as:258]

Issue 5:
=======

I received the error (with no stack trace, assuming there is one)
VerifyError: Error #1043: Invalid code_length=0.

Which goes away when I remove

var ctorBuilder:ICtorBuilder = classBuilder.defineConstructor();

What version of the product are you using? On what operating system?

I am using:
as3commons-bytecode-1.0.swc
as3commons-lang-0.3.4.swc
as3commons-logging-2.6.swc
as3commons-reflect-1.5.swc

In Flash Builder 4.5.1

Compiling with sdk 4.5

On OSX 10.6.8 Snow Leopard

Original issue reported on code.google.com by tom.co...@gmail.com on 30 Sep 2011 at 10:11

GoogleCodeExporter commented 9 years ago

Original comment by martin.h...@gmail.com on 30 Sep 2011 at 10:52

GoogleCodeExporter commented 9 years ago
Hi there,

thank you for your comments! I've changed the mistakes in the documentation 
pages and fixed the null pointer error in the defineArguments method.

One thing that isn't clear to me though is your last issue. Where exactly do 
you use defineConstructor()? It is perfectly logical that the resulting SWF 
will throw a verify error if you don't add a method body to the constructor as 
well. Simply calling defineConstructor() will not be enough.
What is your use case exactly?

thanks for your efforts!

cheers,

Roland

Original comment by ihatelivelyids on 30 Sep 2011 at 2:26

GoogleCodeExporter commented 9 years ago
Hi Roland,

You are absolutely right I completely overlooked the fact that I need to put 
something in the constructor and I have realised that I did not read the 
information about a generic constructor being created by default. Sorry about 
that.

BTW: Part of what I'm doing involves saving classes to a swf file at run time 
without user interaction.
I wondered if it would be worth adding to the "Exporting Generated Classes" 
section with some information about saving without a dialog
e.g.

var swf:File = new File( someDirectory.nativePath + File.separator + 
filename.swf );

var stream:FileStream = new FileStream();
stream.open( swf, FileMode.WRITE );

... make runtime class code ...

var generatedSwfByteArray:ByteArray = abcBuilder.buildAndExport();

stream.writeBytes( generatedSwfByteArray );
 stream.close();

Best regards
Tom

Original comment by tom.co...@gmail.com on 30 Sep 2011 at 3:18