Made anything interesting with Reflection?
BlitzMax Forums/BlitzMax Programming/Made anything interesting with Reflection?
| ||
Ive tried to find a clever use for this Reflection thing. so far ive cloned types, made a generic serializer and even simulated interfaces. What have you been using Reflection for, if at all? |
| ||
I've used it for my Unit Testing module. Previously, creating a test involved function pointers and manually adding tests to a suite. With reflection, it takes all the effort out of writing them, so you can concentrate on the testing instead. For example, by extending from a TTest type, that type is automagically included for testing. Methods can be called anything you like, you just tag them with {test} ... Method testAdd() { test } End Method Reflection does the rest :-) |
| ||
I have interface implementation. Type Test { implementes=Test1,Test2 } End Type and a given function call in the new method. That will test at creation if the type really implements all the functionality of those 2. There is as well a method that checks if a given object implements a given type and if a given class implements a given type for real usage this would need to be compiler level stuff sadly, using BMK is no option as the bmk isn't designed for this kind of extension due to its code processing. |
| ||
A clone function that can clone any Type. |
| ||
I have something along the same lines with interfaces, and i think it turned out pretty good. dont know how fast it is though, with TMethod.Invoke() and the extra method call. But with a few macros to ease the creation of interface types its at least usable ;) ' this generates the type below 'Interface(ITable) ' IMethod( Lookup, :String, name:String) 'EndInterface() Type ITable Extends TInterface Field intf_Lookup:TMethod Method Lookup:String(name:string) Return intf_Read.Invoke( _intf_This, [name]) EndMethod EndType Type TTable {implements="ITable"} Method Lookup:String( name:string) Print "TTable.Lookup()" EndMethod EndType Local obj:TTable= New TTable Local intf:ITable = ITable( QueryInterface( obj, "ITable")) If intf Then intf.Lookup("") As you can guess, QueryInterface() does all the job of filling in the interface object with the proper TMethod objects, so its really just a proxy... i want me some real shiny interfaces! |
| ||
Reflection is proving very useful for a framework I am working on. More details some day - it's just a part of a large project I've started recently. Basically I'm using it to make it a lot easier to write regular applications (or even games if I extend the framework) with BlitzMax. |
| ||
Hi, I'm just finishing up a lua->bmx binding thing that uses reflection to allow lua code to invoke/access any bmx methods/fields - way cool! |
| ||
Will there ever be a reflection tutorial written in the same n00b-style as B+'s first Hello World examples? |
| ||
What the hell. Since when has the reflection stuff actualy been in a public release ? That one slipped past my radar. cool! |
| ||
CS_TBL - have you had a look at the help for reflection? It's under "modules\BASIC". |
| ||
Used reflection to serialize classes to xml and reverse. Works like a charme. |
| ||
Persistence Framework. |
| ||
Is there any documentation on how this actually works? |
| ||
Like what Beaker said. |