Author Topic: How to export wxString::find  (Read 8251 times)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
How to export wxString::find
« on: June 17, 2009, 11:58:27 pm »
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");

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?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: How to export wxString::find
« Reply #1 on: June 19, 2009, 11:55:48 pm »
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").
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: How to export wxString::find
« Reply #2 on: June 22, 2009, 07:13:21 am »
Hello, I need to export to squirrel a find function that has a start parameter.
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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline raybert

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: How to export wxString::find
« Reply #3 on: June 22, 2009, 06:24:48 pm »
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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: How to export wxString::find
« Reply #4 on: June 22, 2009, 10:04:31 pm »
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 :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline raybert

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: How to export wxString::find
« Reply #5 on: June 24, 2009, 11:36:13 pm »
oh!  THAT'S what happened to that post!?  I was wondering why it wasn't where I expected it to be.  Now how the heck did I do that......  ?

Is there any way to move a post to another topic (other than manually re-posting it)?  It should have been here: http://forums.codeblocks.org/index.php/topic,10704.msg73335.html#msg73335

~ray
« Last Edit: June 24, 2009, 11:40:02 pm by raybert »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: How to export wxString::find
« Reply #6 on: June 25, 2009, 07:59:52 am »
Is there any way to move a post to another topic (other than manually re-posting it)?
Post it there again and give me a note. Then I'll remove the posts in this thread.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ