News:

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

Main Menu

ReplaceMacros second parameter in scripts

Started by BlueHazzard, February 06, 2014, 01:57:00 AM

Previous topic - Next topic

BlueHazzard

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:
buffer.Replace(_T("[NOW]"), ReplaceMacros(_T("$(TODAY)"), false));

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

and also the binding is made only with one parameter
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

stahta01

#1
I am guessing its a mistake.

I found the below in macrosmanager.h

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

oBFusCATed

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

LETARTARE

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-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'

BlueHazzard

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.

BlueHazzard

#5
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:

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?

oBFusCATed

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