Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

How to export wxString::find

(1/2) > >>

oBFusCATed:
Hello, I need to export to squirrel a find function that has a start parameter.

So I tried:


--- Code: ---        typedef size_t (wxString::*WXSTR_FIND)(const wxStringBase& str, size_t nStart) const;

        SqPlus::SQClassDef<wxString>("wxString").
                emptyCtor().
                staticFuncVarArgs(&wxString_OpAdd, "_add", "*").
                staticFuncVarArgs(&wxString_OpCmp, "_cmp", "*").
                staticFuncVarArgs(&wxString_OpToString, "_tostring", "").
                func<WXSTR_FIRST_STR>(&wxString::First, "Find").
                staticFuncVarArgs(&wxString_Matches, "Matches", "*").
                staticFuncVarArgs(&wxString_AddChar, "AddChar", "n").
                staticFuncVarArgs(&wxString_GetChar, "GetChar", "n").
                func(&wxString::IsEmpty, "IsEmpty").
                func(&wxString::Length, "Length").
                func(&wxString::Length, "length").
                func(&wxString::Length, "len").
                func(&wxString::Length, "size").
                func(&wxString::Lower, "Lower").
                func(&wxString::LowerCase, "LowerCase").
                func(&wxString::MakeLower, "MakeLower").
                func(&wxString::Upper, "Upper").
                func(&wxString::UpperCase, "UpperCase").
                func(&wxString::MakeUpper, "MakeUpper").
                func(&wxString::Mid, "Mid").
                func<WXSTR_REMOVE_2>(&wxString::Remove, "Remove").
                func(&wxString::RemoveLast, "RemoveLast").
                staticFuncVarArgs(&wxString_Replace, "Replace", "*").
                func(&wxString::Right, "Right").
                staticFuncVarArgs(&wxString_AfterFirst, "AfterFirst", "*").
                staticFuncVarArgs(&wxString_AfterLast, "AfterLast", "*").
                staticFuncVarArgs(&wxString_BeforeFirst, "BeforeFirst", "*").
                staticFuncVarArgs(&wxString_BeforeLast, "BeforeLast", "*").
                func<WXSTR_FIND>(&wxString::find, "FindIndex");

--- End code ---

See the last row, but I get a compilation error :(
I suppose the problem is that this function is wxStringBase method and take wxStringBase as the first parameter, which is not know to the bindings.
What should I do?
Add a free function?

stahta01:
Did you try this?

I do not really understand this code; but, I have gotten sort of good at patching it using trial and error.

Tim S


--- Code: ---Index: src/sdk/scripting/bindings/sc_wxtypes.cpp
===================================================================
--- src/sdk/scripting/bindings/sc_wxtypes.cpp (revision 5668)
+++ src/sdk/scripting/bindings/sc_wxtypes.cpp (working copy)
@@ -305,6 +305,7 @@
 
         typedef int(wxString::*WXSTR_FIRST_STR)(const wxString&)const;
         typedef wxString&(wxString::*WXSTR_REMOVE_2)(size_t pos, size_t len);
+        typedef size_t (wxString::*WXSTR_FIND)(const wxString& str, size_t nStart)const;
 
         SqPlus::SQClassDef<wxString>("wxString").
                 emptyCtor().
@@ -328,6 +329,7 @@
                 func(&wxString::MakeUpper, "MakeUpper").
                 func(&wxString::Mid, "Mid").
                 func<WXSTR_REMOVE_2>(&wxString::Remove, "Remove").
+                func<WXSTR_FIRST_STR>(&wxString::First, "Find").
                 func(&wxString::RemoveLast, "RemoveLast").
                 staticFuncVarArgs(&wxString_Replace, "Replace", "*").
                 func(&wxString::Right, "Right").

--- End code ---

MortenMacFly:

--- Quote from: oBFusCATed on June 17, 2009, 11:58:27 pm ---Hello, I need to export to squirrel a find function that has a start parameter.

--- End quote ---
Did you read this:
http://wiki.codeblocks.org/index.php?title=Script_bindings
??? This will pretty much explain what you want to do in more detail.

raybert:
FWIW, I created a patch that implements persistent storage of regular editor bookmarks.  I wrote them to the project layout file using a series of <Bookmark> tags.  Patch #2751.

I considered also saving breakpoints but I decided not to (mostly because I didn't have the time to investigate how they work).

~ray

oBFusCATed:
morten: Apparently I've not, thanks ... after looking at the code I've found the way...

raybert: I think you have posted in the wrong thread :)

Navigation

[0] Message Index

[#] Next page

Go to full version