View Single Post
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 02-26-2016 , 20:51   Re: [2016.02.27] Dynamic Objects and Properties - v005
Reply With Quote #22

As we know, methodmaps require data backing the properties which steers people away from using them.

You can create methodmaps that inherit the Dynamic class and write properties that use the dynamic object to back the properties.

dynamic-example.inc

Quote:
In the linked example, I use static offsets in each property of the methodmap to cache member positions in the dynamic object to increase performance.

This then requires all the dynamic members to be in the same positions.

To get around this, you can see I set all the members in the initialiser for MyClass, this means over multiple instances of MyClass, the member offsets will always correct.
The key points to following when making your own dynamic classes are:

1. All members must be set to their default values in the constructer
2. Use static offsets in each property to increase performance

I'm about to make a webpage where you can define your class. It will then spit out the methodmap to make that class using Dynamic.
__________________
Neuro Toxin is offline