News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Squirrel script with error : UnixFilename()

Started by LETARTARE, October 21, 2012, 02:43:45 PM

Previous topic - Next topic

LETARTARE

hello,
with r8466:
the execution of this script causes an error on the "UnixFilename ()":

///-----------------------------------------------------------------------------
/// test_UnixFilename.script : LETARTARE 15-10-2012
///-----------------------------------------------------------------------------

function SetBuildOptions (base) {
}
///-----------------------------------------------------------------------------
function main() {
/// path file configuration
local Nameconf = _T("default.conf");
/// locate 'default.conf'
local pathconf = ::LocateDataFile(Nameconf, ::sdAllKnown);
/// results
::print (pathconf)
/// ===> Squirrel error from revision r8394  <===
::print (UnixFilename(pathconf))
}
///-----------------------------------------------------------------------------
///  Vista business Pack2 , Mingw32 with TDM-GCC 4.5.2,  wxWidgets unicode 2.8.12
///  C::B ...r8393, r8394...r8466
///-----------------------------------------------------------------------------

///-----------------------------------------------------------------------------
///  with <= r8393  : it's good

/// C:\Users\aaa\AppData\Roaming\CodeBlocks\default.conf
/// C:\Users\aaa\AppData\Roaming\CodeBlocks\default.conf
///-----------------------------------------------------------------------------
///  with >= r8394  : Squirrel error

///  Message :
///  AN ERROR HAS OCCURED [Incorrect function argument]
///  CALLSTACK
///  *FUNCTION [main()] test_UnixFilename.script line [17]
///  *FUNCTION [main()] ScriptConsole line [1]
///-----------------------------------------------------------------------------

looking, I found that the error occurs since r8394.

I think MortenMacFly realized the r8394.

Can you help me?
cordially
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

Jenna

Quote from: LETARTARE on October 21, 2012, 02:43:45 PM
looking, I found that the error occurs since r8394.

Are you sure it occurs with r8394 ?
I don't see anything related to scripting in this revision.

LETARTARE

yes
I tried with r8393 and I have no error.
In changing MortenMacFly, I did not find any relationship with UnixFilename ()!
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

MortenMacFly

...try to replace:
::print (UnixFilename(pathconf))

...with:
::print (UnixFilename(pathconf,wxPATH_NATIVE))

Does it work now?
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]

LETARTARE

hello,
thank you.
I tried with r8394, r8466 and I have no error.

-> Include\global.h is written:
r8393 :
extern DLLIMPORT wxString UnixFilename(const wxString& filename);
r8394 ... r8466:

extern DLLIMPORT wxString UnixFilename(const wxString& filename, wxPathFormat format = wxPATH_NATIVE);


of course must specify the defaults in Squirrel !!

But why the change from r8394 ?

Thank you again.
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

Jenna

#5
8394 has no such change

I did not look into later revisions.
No time at vthe moment,sorry.

MortenMacFly

Quote from: LETARTARE on October 23, 2012, 09:29:23 AM
But why the change from r8394 ?
Inspect the SVN log for a description.

BTW: Is it working with the proposed change or not?
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]

LETARTARE

YES it works very well as shown MortenMacFly.
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

Alpha

Maybe overload instead of default arguments then?  ... except this does not compile because squirrel cannot figure out what to bind.

Index: src/include/globals.h
===================================================================
--- src/include/globals.h (revision 8478)
+++ src/include/globals.h (working copy)
@@ -186,7 +186,8 @@
extern DLLIMPORT wxString MakeUniqueString(const wxString& text,  const wxString& separator = DEFAULT_ARRAY_SEP, bool caseSens = true);
extern DLLIMPORT void AppendArray(const wxArrayString& from, wxArrayString& to);

-extern DLLIMPORT wxString UnixFilename(const wxString& filename, wxPathFormat format = wxPATH_NATIVE);
+extern DLLIMPORT wxString UnixFilename(const wxString& filename/*, wxPathFormat format = wxPATH_NATIVE*/);
+extern DLLIMPORT wxString UnixFilename(const wxString& filename, wxPathFormat format/* = wxPATH_NATIVE*/);
extern DLLIMPORT void QuoteStringIfNeeded(wxString& str);

/// Escapes spaces and tabs (NOT quoting the string)
Index: src/sdk/globals.cpp
===================================================================
--- src/sdk/globals.cpp (revision 8478)
+++ src/sdk/globals.cpp (working copy)
@@ -211,6 +211,11 @@
         to.Add(from[i]);
}

+wxString UnixFilename(const wxString& filename)
+{
+    return UnixFilename(filename, wxPATH_NATIVE);
+}
+
wxString UnixFilename(const wxString& filename, wxPathFormat format)
{
     wxString result = filename;

MortenMacFly

Quote from: Alpha on October 23, 2012, 11:06:04 PM
Maybe overload instead of default arguments then?
I don't think this is needed. Squirrel does not handle default parameters by design, so as a general rule you always have to provide all parameters for all interfaces. This applies to all squirrel bindings. As we cannot change every method with a default parameter to an overloaded one, developers just have to follow this simple rule:
If there is a default parameter, specify it. Period.

It has been like that since the beginning btw, just as we changed the interface of that methods now you'll need to provide an additional parameter when using it. But this won't hurt.
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]