News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

How to export wxString::find

Started by oBFusCATed, June 17, 2009, 11:58:27 PM

Previous topic - Next topic

oBFusCATed

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

So I tried:


        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!]

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


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++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

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.
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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

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 :)
(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!]

raybert

#5
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.next.codeblocks.org/index.php/topic,10704.msg73335.html#msg73335

~ray

MortenMacFly

Quote from: raybert on June 24, 2009, 11:36:13 PM
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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]