genius257 Posted May 20 Share Posted May 20 I've made a transpiler for converting AutoIt-like class syntax into AutoIt code. GIthub: https://github.com/genius257/au3class/ Example for the syntax: #include-once Class Example $property = Null Func __construct($ts = 'now') $this.property = 0 EndFunc Func __destruct() ; Destructor code here. EndFunc Func method() Return "something" EndFunc Get Func dynamic() Return $this.dynamic & $this.property EndFunc Set Func dynamic($value) $this.property += 1 $this.dynamic = $value EndFunc EndClass $oExample = Example() $oExample.dynamic = 12 MsgBox(0, "", $oExample.dynamic) MsgBox(0, "", $oExample.method()) $oExample = Null class properties are defined as variables within the Class structure class methods are defined as function declarations within the Class structure property getters and setters need to have Get or Set in front of their function declaration Getter and setter can access their own underlying property, without triggering the getter or setter for said variable. Version 2 produces more code than version 1, but does not need any other scripts included to work. Version 2 is also faster than version 1, since version 2 creates specific code for looking up class members, instead of relying on AutoItObject_Internal with it's dynamic properties lookup. See the example folder on Github for building and using this: https://github.com/genius257/au3class/tree/master/Example Danyfirex, funkey and Gianni 3 My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser Link to comment Share on other sites More sharing options...
Gianni Posted May 20 Share Posted May 20 Hi @genius257 Just a small oversight: I tried to "build" example.au3 from example.au3p using build.au3 the output file produced contains this little "flaw": If $pObj=0 Then Return $__AOI_E_POINTER "C:\Temp\au3class-master\Example\Example.au3"(30,40) : warning: $__AOI_E_POINTER: possibly used before declaration. If $pObj=0 Then Return $__AOI_E_POINTER ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Temp\au3class-master\Example\Example.au3"(30,40) : error: $__AOI_E_POINTER: undeclared global variable. If $pObj=0 Then Return $__AOI_E_POINTER ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ apart from this the created "object" works correctly. Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
genius257 Posted May 20 Author Share Posted May 20 Hi @Gianni You are right, that is indeed an oversight, thanks for telling me The issue has been fixed on the master branch now, but I'll wait a day or two before creating a new release, to verify no more small mistakes appear Gianni and argumentum 1 1 My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now