Author Topic: Squirrel script with error : UnixFilename()  (Read 6278 times)

Offline LETARTARE

  • Regular
  • ***
  • Posts: 390
  • L'ami de l'homme.The friend of man.
Squirrel script with error : UnixFilename()
« on: October 21, 2012, 02:43:45 pm »
hello,
with r8466:
the execution of this script causes an error on the "UnixFilename ()":
Code: [Select]
///-----------------------------------------------------------------------------
/// 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
C::B  : svn11831, wx2.8, 3.1.1, plugins : QtPregen-2.6.2-sdk143
1-Vista Business Pack 2 32bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.4.1,
=> !! The messages are translated by Deepl !!

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Squirrel script with error : UnixFilename()
« Reply #1 on: October 21, 2012, 03:01:29 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.

Offline LETARTARE

  • Regular
  • ***
  • Posts: 390
  • L'ami de l'homme.The friend of man.
Re: Squirrel script with error : UnixFilename()
« Reply #2 on: October 21, 2012, 03:05:20 pm »
yes
I tried with r8393 and I have no error.
In changing MortenMacFly, I did not find any relationship with UnixFilename ()!
C::B  : svn11831, wx2.8, 3.1.1, plugins : QtPregen-2.6.2-sdk143
1-Vista Business Pack 2 32bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.4.1,
=> !! The messages are translated by Deepl !!

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: Squirrel script with error : UnixFilename()
« Reply #3 on: October 23, 2012, 08:23:23 am »
...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: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline LETARTARE

  • Regular
  • ***
  • Posts: 390
  • L'ami de l'homme.The friend of man.
Re: Squirrel script with error : UnixFilename()
« Reply #4 on: October 23, 2012, 09:29:23 am »
hello,
thank you.
I tried with r8394, r8466 and I have no error.

-> Include\global.h is written:
r8393 :
Code: [Select]
extern DLLIMPORT wxString UnixFilename(const wxString& filename);r8394 ... r8466:
Code: [Select]
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.
C::B  : svn11831, wx2.8, 3.1.1, plugins : QtPregen-2.6.2-sdk143
1-Vista Business Pack 2 32bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.4.1,
=> !! The messages are translated by Deepl !!

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Squirrel script with error : UnixFilename()
« Reply #5 on: October 23, 2012, 09:43:58 am »
8394 has no such change

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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: Squirrel script with error : UnixFilename()
« Reply #6 on: October 23, 2012, 09:47:33 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: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline LETARTARE

  • Regular
  • ***
  • Posts: 390
  • L'ami de l'homme.The friend of man.
Re: Squirrel script with error : UnixFilename()
« Reply #7 on: October 23, 2012, 11:09:19 am »
YES it works very well as shown MortenMacFly.
C::B  : svn11831, wx2.8, 3.1.1, plugins : QtPregen-2.6.2-sdk143
1-Vista Business Pack 2 32bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.4.1,
=> !! The messages are translated by Deepl !!

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Squirrel script with error : UnixFilename()
« Reply #8 on: October 23, 2012, 11:06:04 pm »
Maybe overload instead of default arguments then?  ... except this does not compile because squirrel cannot figure out what to bind.
Code: [Select]
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;

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: Squirrel script with error : UnixFilename()
« Reply #9 on: October 24, 2012, 09:08:21 am »
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: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ