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

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
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
///-----------------------------------------------------------------------------
/// 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-13515, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.6
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7256
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

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
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 ()!
CB-13515, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.6
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9702
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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
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
extern DLLIMPORT wxString UnixFilename(const wxString& filename);
r8394 ... r8466:
Code
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-13515, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.6
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7256
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.
« Last Edit: October 23, 2012, 09:53:50 am by jens »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9702
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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: Squirrel script with error : UnixFilename()
« Reply #7 on: October 23, 2012, 11:09:19 am »
YES it works very well as shown MortenMacFly.
CB-13515, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.6
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.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
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: 9702
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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ