Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

Plugin scripts - accessing local context data

<< < (3/4) > >>

beldaz:
Perhaps answering my own question, following the related wiki advice on overloaded functions, this seems to compile:


--- Code: ---typedef wxString(cbStyledTextCtrl::*cbStyledTextCtrlFunc)();

SqPlus::SQClassDef<cbStyledTextCtrl>("cbStyledTextCtrl")
    .func(&cbStyledTextCtrl::IsCharacter, "IsCharacter")
    .func(&cbStyledTextCtrl::IsString, "IsString")
    .func(&cbStyledTextCtrl::IsPreprocessor, "IsPreprocessor")
    .func(&cbStyledTextCtrl::IsComment, "IsComment")
    .func<cbStyledTextCtrlFunc>(&cbStyledTextCtrl::GetSelectedText, "GetSelectedText");

--- End code ---

Now to see whether this actually works in a script...

oBFusCATed:
You have to bind cbEditor::GetControl probably and then use it to get the cbStyledTextCtrl.

beldaz:

--- Quote from: oBFusCATed on December 13, 2011, 10:32:45 am ---You have to bind cbEditor::GetControl probably and then use it to get the cbStyledTextCtrl.

--- End quote ---
Already had that elsewhere, should have mentioned, sorry. The problem I was facing was a compilation one - SqPlus didn't like my adding bindings to members inherited from a base class (wxScintilla) for which there was no binding. And adding a binding for wxScintilla was not going to be easy. Explicitly defining the template parameters for the binding seems to fix this.

I've submitted patch (number 3242).

This patch provides bindings to all the cbStyledTextCtrl methods used in your cbDebuggerPlugin::GetEditorWordAtCaret method, and in a rather similar method CodeRefactoring::GetSymbolUnderCursor() in the code completion plugin. The one omission is cbStyledTextCtrl::PositionFromPoint, which takes a wxPoint value as a parameter. A binding for this breaks the build as the line "DECLARE_INSTANCE_TYPE(wxPoint)" in sc_base_type.h generates Match and Get functions only for passing by reference or pointer. I am open to suggestions as to how best to resolve this issue.

oBFusCATed:

--- Quote from: beldaz on December 13, 2011, 12:09:03 pm ---This patch provides bindings to all the cbStyledTextCtrl methods used in your cbDebuggerPlugin::GetEditorWordAtCaret method, and in a rather similar method CodeRefactoring::GetSymbolUnderCursor() in the code completion plugin. The one omission is cbStyledTextCtrl::PositionFromPoint, which takes a wxPoint value as a parameter. A binding for this breaks the build as the line "DECLARE_INSTANCE_TYPE(wxPoint)" in sc_base_type.h generates Match and Get functions only for passing by reference or pointer. I am open to suggestions as to how best to resolve this issue.

--- End quote ---
You can bind a normal function with explicit this parameter, which uses reference instead of pointer parameters.

Something like:

--- Code: ---void my_method(MyClass *this, const Test &t) { this->my_method(&t); }

--- End code ---

beldaz:

--- Quote from: oBFusCATed on December 13, 2011, 12:33:45 pm ---You can bind a normal function with explicit this parameter, which uses reference instead of pointer parameters.

Something like:

--- Code: ---void my_method(MyClass *this, const Test &t) { this->my_method(&t); }

--- End code ---

--- End quote ---
Thanks for that. It wasn't quite what I needed, but close enough to put me on the right track (overloaded method with pass-by-reference shim.

Patch updated.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version