How can i create a class completely dynamic?
Background: i want to create autohotkey classes from c structs.
I've tried to create the class members in the new function, but it only works for the first instance.
In the following example cAna is created without calling the New() function again - so i look for a way to create also the class dynamically.
Any help is appreciated!
meta := "TimeUnit IntervalUnit;word MeasureInterval;byte DhtPin;byte TempHyst;byte HumiHyst;int TempVal;word HumiVal" cDht := new CHead() meta := "byte AnaPin : 3;TimeUnit IntervalUnit;word MeasureInterval;byte Hyst;byte Calibration;word Value;byte PVal;" cAna := new CHead() ;does not work - has the fields from cDht class CHead extends CStruct_Base { __New() { global buf this.AddStructVar("data", "uint", "union_start") this.AddStructVar("head", "CHeadBits") this.AddStructVar("body", "CBody", "union_end") this.SetStructCapacity() this.AddrFrom(&buf) } } class CHeadBits extends CStruct_Base { __New() { metahead := "byte hType : 5;byte Id : 5;byte Enabled : 1;byte HasFollower : 1;byte HasTimer : 1;byte IsFollower : 1;byte HystOverride : 1;byte Startup : 1;byte TimerPtr : 4;byte State : 4" Loop, Parse, metahead, `;, { StringSplit, aH, A_LoopField,%A_Space% if (aH0 > 3) this.AddStructVar(aH2 , aH1, "bit:" . aH4 ) Else { if (aH1 = "TimeUnit") this.AddStructVar(aH2 , "byte", "bit:3" ) else this.AddStructVar(aH2 , aH1 ) } } this.SetStructCapacity() } } class CBody extends CStruct_Base { __New() { global meta Loop, Parse, meta, `;, { StringSplit, aH, A_LoopField,%A_Space% if (aH0 > 3) this.AddStructVar(aH2 , aH1, "bit:" . aH4 ) Else { if (aH1 = "TimeUnit") this.AddStructVar(aH2 , "byte", "bit:3" ) else this.AddStructVar(aH2 , aH1 ) } } this.SetStructCapacity() } }