Reflection: an array's methods and length field

BlitzMax Forums/BlitzMax Programming/Reflection: an array's methods and length field

Warpy(Posted 2009) [#1]
So I'm still playing with reflection, and I've foudn out that you can't access an array's methods (Sort and Dimensions according to the docs) or its "length" field.

I know you can get the dimensions and length directly through the methods in TTypeId, but I'd like to be able to get the relevant TMethods and TField as well, for simplicity's sake.

Have a look at this:
Function test(o:Object)
	Print ""
	t:TTypeId=TTypeId.ForObject(o)
	Print "ttypeid: "+t.name()
	Print "fields:"
	For f:TField=EachIn t.enumfields()
		Print "  "+f.name()
	Next
	Print "methods:"
	For m:TMethod=EachIn t.enummethods()
		Print "  "+m.name()
	Next
End Function

test(["hi"])
test "hi"

'try with TLists just to make sure it's not because String is a builtin type
test(New TList[1])
test New TList



slenkar(Posted 2009) [#2]
Brucey wrote a serialization module which copies arrays to a xml file, I think he hacked commands into blitz that allow you to get length and number of dimensions.


Warpy(Posted 2009) [#3]
Yes, I know about those, but they don't show up in EnumFields or EnumMethods, they're Methods of TTypeId.