back2dos / tinkerbell

MIT License
83 stars 8 forks source link

will @:forward support typedef/interface Metadata? #49

Closed sonygod closed 11 years ago

sonygod commented 11 years ago

will @:forward support typedef/interface Metadata?

as far as I know ,only class support @Metadata,interface or typedef not support will tinkerbell support this feature? btw, is that tinkerbell not support HAXE 3 rc now? thanks .

back2dos commented 11 years ago

I am not sure what you mean. Can you show me a code example of what you'd like to work?

As for RC3 support, did you try the current head?

sonygod commented 11 years ago

Running process: C:\Program Files\FlashDevelop\Tools\fdbuild\fdbuild.exe "D:\GitHub\tinkerbell\tests\avm2test\avm2test.hxproj" -ipc ec4c4bb5-06a2-4139-8ed8-6eece193bd91 -version "3.0.0" -compiler "C:\Motion-Twin\haxe" -library "C:\Program Files\FlashDevelop\Library" Building avm2test haxe --connect 6000 -cp src -cp ../src -cp ../../src -swf D:/GitHub/tinkerbell/tests/avm2test/bin/avm2test.swf -swf-header 800:600:60:FFFFFF -swf-version 10.3 -D tink_reactive -main Main -debug --no-inline -D fdb

../../src/tink/reflect/Property.hx:87: characters 48-49 : Missing ; ../src/lang/ClsTest.hx:243: characters 24-25 : Unexpected , Build halted with errors (haxe.exe).

I use the current head mast branch clone in windows use github client ,but no luck to compile the example test code.and my haxe version is 3.0 RC,not svn nightly build version.

and some example code for @:forward to auto create metadata like this.

interface ITask { @index(1) function getTaskAccepted():Vector; }

or

typedef FwdTarget = { @index(3) function add(a:Int, b:Int):Int; @index(4) function subtract(a:Int, b:Int):Int;

} //--------------code piece

class Forwarder implements Cls { var fields:Hash = new Hash(); @:forward(!multiply) var target:FwdTarget; @:forward function fwd2(x:ITask,x:FwdTarget ) { get: fields.get($name), set: fields.set($name, param), call: $name + '_' + $args.length } public function new(target) { this.target = target; } }

and final Forwarder class may be look like

class Forwarder{ @index(1) //key the Meta data here function getTaskAccepted():Vector{ ......... } @index(3) function add(a:Int, b:Int):Int{ ....... } @index(4) function subtract(a:Int, b:Int):Int{..... }

}