Author Topic: ReplaceMacros second parameter in scripts  (Read 5815 times)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
ReplaceMacros second parameter in scripts
« on: February 06, 2014, 01:57:00 am »
maybe it is to late for me, but can someone lighten me what the second parameter in ReplaceMacros in the wizardscripts is?

ex. wxWidgets project script the boolean false:
Code
buffer.Replace(_T("[NOW]"), ReplaceMacros(_T("$(TODAY)"), false));

in the wiki is only one parameter
http://wiki.codeblocks.org/index.php?title=Scripting_commands
Code
wxString 	ReplaceMacros 	wxString 	Does variable expansion on the input wxString 

and also the binding is made only with one parameter
Code
wxString gReplaceMacros(const wxString& buffer){ return Manager::Get()->GetMacrosManager()->ReplaceMacros(buffer); }
SqPlus::RegisterGlobal(gReplaceMacros, "ReplaceMacros");

i have no idea where this second parameter is going...

greetings

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: ReplaceMacros second parameter in scripts
« Reply #1 on: February 06, 2014, 02:17:49 am »
I am guessing its a mistake.

I found the below in macrosmanager.h
Code
    void ReplaceMacros(wxString& buffer, ProjectBuildTarget* target = nullptr, bool subrequest = false);
    wxString ReplaceMacros(const wxString& buffer, ProjectBuildTarget* target = nullptr);


I am guessing its using the second of those above.

Just a guess.


After looking closer; I think it is the first one of the two above.

Tim S.
« Last Edit: February 06, 2014, 02:33:03 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: ReplaceMacros second parameter in scripts
« Reply #2 on: February 06, 2014, 08:53:40 am »
Does the script works or it fails with errors?
Probably is bug in the script.
(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 LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: ReplaceMacros second parameter in scripts
« Reply #3 on: February 06, 2014, 11:36:12 am »
I never used the second parameter.
But if you put it, it does not generate an error !
If the second parameter was necessary script would generate a runtime error, because all parameters must be specified.

I think it is a mistake that spread by copying ...

CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
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 BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: ReplaceMacros second parameter in scripts
« Reply #4 on: February 06, 2014, 11:44:06 am »
hmm
The scripts work on the actual implementation of squirrel in c::b. But with my new with sqrat binding they crash, because of the wrong parameter count.
I don't understand why this scripts aren't crashing in the actual version, because there is no binding to squirrel for a function with 2 parameters.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: ReplaceMacros second parameter in scripts
« Reply #5 on: February 06, 2014, 12:21:27 pm »
After some more investigation i think this is a script error and sqplus don't give a error if the parameter count is to high. So what should i do? Correct the scripts, or provide a overloaded function with the given feature? (I think i will do the second, it is less work, but can have some side effects :P )

greetings

[Edit:]

After a second overlook i think the bool parameter is only for internal use:
Code
void MacrosManager::ReplaceMacros(wxString& buffer, ProjectBuildTarget* target, bool subrequest)
{
[...]
    while ((index = buffer.Index(toNativePath)) != wxNOT_FOUND)
    {
        int end = MatchBrace(buffer, index + toNativePath.Length() - 1);
        wxString content = buffer.Mid(index + toNativePath.Length(), end - index - toNativePath.Length());
!!!     ReplaceMacros(content, target, true);
        buffer.Replace(buffer.Mid(index, end - index + 1), UnixFilename(content), false);
    }
[...]
    if (!subrequest)
    {
        buffer.Replace(_T("%%"), _T("%"));
        buffer.Replace(_T("$$"), _T("$"));
    }
}

so this functionality should not be ported to the scripts or should it?
« Last Edit: February 06, 2014, 12:35:20 pm by BlueHazzard »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: ReplaceMacros second parameter in scripts
« Reply #6 on: February 07, 2014, 01:13:01 am »
Post a patch to trunk please, so we can fix the script there.
(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!]