icinga2/lib/base/function.cpp

39 lines
1,004 B
C++
Raw Normal View History

Replace all existing copyright headers with `SPDX` headers I've used the following command to replace the original copyright header lines in a C-style comment block: ``` $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{/\*[^*]*\(\s*c\s*\)\s*(\d{4})\s*Icinga\s+GmbH[^*]*\*/}{// SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n// SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + ``` For files that use shell-style comments (#) like CMakeLists.txt, I've used this command: ``` $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{#.*\(\s*c\s*\)\s(\d{4})\sIcinga\s+GmbH.*}{# SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n# SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + ``` And for SQL files: ``` $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{--.*\(c\)\s(\d{4})\sIcinga\sGmbH.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{-- Copyright \(c\)\s(\d{4})\sIcinga\s+Development\sTeam.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + ```
2026-01-27 09:06:40 -05:00
// SPDX-FileCopyrightText: 2012 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-2.0-or-later
2012-10-16 04:41:54 -04:00
#include "base/function.hpp"
2018-01-18 07:50:38 -05:00
#include "base/function-ti.cpp"
#include "base/array.hpp"
#include "base/scriptframe.hpp"
2012-07-14 09:59:59 -04:00
using namespace icinga;
REGISTER_TYPE_WITH_PROTOTYPE(Function, Function::GetPrototype());
Function::Function(const String& name, Callback function, const std::vector<String>& args,
bool side_effect_free, bool deprecated)
: m_Callback(std::move(function))
{
SetName(name, true);
SetSideEffectFree(side_effect_free, true);
SetDeprecated(deprecated, true);
SetArguments(Array::FromVector(args), true);
}
2012-07-14 09:59:59 -04:00
Value Function::Invoke(const std::vector<Value>& arguments)
2012-07-14 09:59:59 -04:00
{
ScriptFrame frame(false);
return m_Callback(arguments);
}
Value Function::InvokeThis(const Value& otherThis, const std::vector<Value>& arguments)
{
2018-01-03 04:19:24 -05:00
ScriptFrame frame(false, otherThis);
2013-03-25 13:36:15 -04:00
return m_Callback(arguments);
2012-07-14 09:59:59 -04:00
}
2013-03-16 16:18:53 -04:00
Object::Ptr Function::Clone() const
{
return const_cast<Function *>(this);
}