Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://haxe.googlecode.com/svn/trunk@3242 f16182fa-f095-11de-8f43-4547254af6c6
- Loading branch information
ncannasse
committed
Jul 23, 2010
1 parent
17227d6
commit cae4e7e
Showing
13 changed files
with
211 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2005-2009, The haXe Project Contributors | ||
* All rights reserved. | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* - Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR | ||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
* DAMAGE. | ||
*/ | ||
package haxe.rtti; | ||
|
||
class Meta { | ||
|
||
public static function getType( t : Dynamic ) : Dynamic<Array<Dynamic>> { | ||
var meta : Dynamic = untyped t.__meta__; | ||
return (meta == null) ? meta : meta.obj; | ||
} | ||
|
||
public static function getStatics( t : Dynamic ) : Dynamic<Dynamic<Array<Dynamic>>> { | ||
var meta : Dynamic = untyped t.__meta__; | ||
return (meta == null) ? meta : meta.statics; | ||
} | ||
|
||
public static function getFields( t : Dynamic ) : Dynamic<Dynamic<Array<Dynamic>>> { | ||
var meta : Dynamic = untyped t.__meta__; | ||
return (meta == null) ? meta : meta.fields; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package unit; | ||
|
||
@enumMeta private enum E { | ||
@a A; | ||
@b(0) B; | ||
} | ||
|
||
@classMeta("x") class TestMeta extends Test { | ||
|
||
@empty() @_int(-45) @complex([{ x : 0, y : "hello", z : -1.48, b : true, k : null }]) static var foo : Int; | ||
|
||
@new public function new() { | ||
super(); | ||
} | ||
|
||
function fields( o : Dynamic ) { | ||
if( o == null ) return null; | ||
var fl = Reflect.fields(o); | ||
fl.sort(Reflect.compare); | ||
return fl.join("#"); | ||
} | ||
|
||
public function testMeta() { | ||
var m = haxe.rtti.Meta.getType(E); | ||
eq( fields(m), "enumMeta" ); | ||
eq( m.enumMeta, null ); | ||
|
||
var m = haxe.rtti.Meta.getType(TestMeta); | ||
eq( fields(m), "classMeta" ); | ||
eq( Std.string(m.classMeta), "[x]" ); | ||
|
||
var m = haxe.rtti.Meta.getFields(E); | ||
eq( fields(m), "A#B" ); | ||
eq( fields(m.A), "a" ); | ||
eq( m.A.a, null ); | ||
eq( fields(m.B), "b" ); | ||
eq( Std.string(m.B.b), "[0]" ); | ||
|
||
var m = haxe.rtti.Meta.getFields(TestMeta); | ||
eq( fields(m), "_" ); | ||
eq( fields(m._), "new" ); | ||
|
||
var m = haxe.rtti.Meta.getStatics(E); | ||
eq( m, null ); | ||
|
||
var m = haxe.rtti.Meta.getStatics(TestMeta); | ||
eq( fields(m), "foo" ); | ||
eq( fields(m.foo), "_int#complex#empty" ); | ||
eq( m.foo.empty, null ); | ||
eq( Std.string(m.foo._int), "[-45]" ); | ||
var c : Dynamic = m.foo.complex[0][0]; | ||
eq( fields(c), "b#k#x#y#z" ); | ||
eq( c.x, 0 ); | ||
eq( c.y, "hello" ); | ||
eq( c.z, -1.48 ); | ||
eq( c.b, true ); | ||
eq( c.k, null ); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,7 @@ unit.Test | |
|
||
-cpp cpp | ||
|
||
-debug | ||
-main unit.Test | ||
|
||
-cp .. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters