jaberwacky Posted January 25, 2014 Posted January 25, 2014 (edited) Hi. Decided to put this question here because the description covers "General coding talk. Scripting, programming, C++, etc." So, I'm trying to alter AutoItObject to accept references to functions rather than just strings. For example: $this.AddMethod("MyMethod", "_my_method") to this--> $this.AddMethod("MyMethod", _my_method) And so I found this class: expandcollapse popupclass AutoItElement { public: AutoItElement(void); AutoItElement(wchar_t* name,VARIANT*); ~AutoItElement(void); enum TYPE { NOTHING, METHOD, PROPERTY }; TYPE GetType() const; void SetType(TYPE new_type); enum SCOPE { PUBLIC, READONLY, PRIVATE }; SCOPE GetScope() const; void SetScope(SCOPE new_scope); void SetData(LPCWSTR); void SetData(VARIANT*); VARIANT* GetData(); wchar_t* GetName(); void SetName(wchar_t*); private: wchar_t* name; VARIANT data; TYPE type; SCOPE scope; }; Which looks to me to have an overloaded SetData accepting a pointer to a type VARIANT. This leads me to wonder if all I would need to do is to change these functions: void AutoItObject::AddMethod(wchar_t* method, wchar_t* value, AutoItElement::SCOPE new_scope) { AutoItElement *elem = new AutoItElement; elem->SetType(AutoItElement::METHOD); elem->SetScope(new_scope); elem->SetName(method); elem->SetData(value); this->AddMember(elem); } to this --> void AutoItObject::AddMethod(wchar_t* method, <something>* value, AutoItElement::SCOPE new_scope) {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^ AutoItElement *elem = new AutoItElement; elem->SetType(AutoItElement::METHOD); elem->SetScope(new_scope); elem->SetName(method); elem->SetData(value); this->AddMember(elem); } And this: Func _AutoItObject_AddMethod(ByRef $oObject, $sName, $sAutoItFunc, $fPrivate = False) ; Author: Prog@ndy If Not IsObj($oObject) Then Return SetError(2, 0, 0) Local Const $iFlags = $fPrivate ? $ELSCOPE_PRIVATE : 0 DllCall($ghAutoItObjectDLL, "none", "AddMethod", "idispatch", $oObject, "wstr", $sName, "wstr", $sAutoItFunc, 'dword', $iFlags) If @error Then Return SetError(1, @error, 0) Return True EndFunc ;==>_AutoItObject_AddMethod To this --> Func _AutoItObject_AddMethod(ByRef $oObject, $sName, $sAutoItFunc, $fPrivate = False) ; Author: Prog@ndy If Not IsObj($oObject) Then Return SetError(2, 0, 0) Local Const $iFlags = $fPrivate ? $ELSCOPE_PRIVATE : 0 DllCall($ghAutoItObjectDLL, "none", "AddMethod", "idispatch", $oObject, "wstr", $sName, "ptr", $sAutoItFunc, 'dword', $iFlags) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^ If @error Then Return SetError(1, @error, 0) Return True EndFunc ;==>_AutoItObject_AddMethod Or does the rabbit hole go deeper than I could ever imagine? Edited January 26, 2014 by jaberwacky Helpful Posts and Websites: AutoIt Wiki | Can't find what you're looking for on the Forum? My scripts: Guiscape | Baroque AU3 Code Formatter | MouseHoverCalltips | SciTe Customization GUI | ActiveWindowTrack Toy | Monitor Configuration UDF
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