mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
Fix typeof incorrectly returning null for arrays and dictionaries
fixes #8002
This commit is contained in:
parent
b5c7e2de4e
commit
04ca634a16
@ -21,9 +21,7 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_BUILTIN_TYPE(int);
|
REGISTER_BUILTIN_TYPE(Number);
|
||||||
REGISTER_BUILTIN_TYPE(double);
|
|
||||||
REGISTER_BUILTIN_TYPE(bool);
|
|
||||||
|
|
||||||
PrimitiveType::PrimitiveType(const String& name)
|
PrimitiveType::PrimitiveType(const String& name)
|
||||||
: m_Name(name)
|
: m_Name(name)
|
||||||
|
@ -48,16 +48,24 @@ private:
|
|||||||
|
|
||||||
#define REGISTER_BUILTIN_TYPE(type) \
|
#define REGISTER_BUILTIN_TYPE(type) \
|
||||||
namespace { namespace UNIQUE_NAME(prt) { namespace prt ## type { \
|
namespace { namespace UNIQUE_NAME(prt) { namespace prt ## type { \
|
||||||
void RegisterPrimitiveType(void) \
|
void RegisterBuiltinType(void) \
|
||||||
{ \
|
{ \
|
||||||
icinga::Type::Ptr t = new PrimitiveType(#type); \
|
icinga::Type::Ptr t = new PrimitiveType(#type); \
|
||||||
icinga::Type::Register(t); \
|
icinga::Type::Register(t); \
|
||||||
} \
|
} \
|
||||||
INITIALIZE_ONCE(RegisterPrimitiveType); \
|
INITIALIZE_ONCE(RegisterBuiltinType); \
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
#define REGISTER_PRIMITIVE_TYPE(type) \
|
#define REGISTER_PRIMITIVE_TYPE(type) \
|
||||||
REGISTER_BUILTIN_TYPE(type); \
|
namespace { namespace UNIQUE_NAME(prt) { namespace prt ## type { \
|
||||||
|
void RegisterPrimitiveType(void) \
|
||||||
|
{ \
|
||||||
|
icinga::Type::Ptr t = new PrimitiveType(#type); \
|
||||||
|
icinga::Type::Register(t); \
|
||||||
|
type::TypeInstance = t; \
|
||||||
|
} \
|
||||||
|
INITIALIZE_ONCE(RegisterPrimitiveType); \
|
||||||
|
} } } \
|
||||||
DEFINE_TYPE_INSTANCE(type)
|
DEFINE_TYPE_INSTANCE(type)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,12 @@
|
|||||||
|
|
||||||
#include "base/scriptfunction.hpp"
|
#include "base/scriptfunction.hpp"
|
||||||
#include "base/scriptvariable.hpp"
|
#include "base/scriptvariable.hpp"
|
||||||
|
#include "base/primitivetype.hpp"
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
|
REGISTER_PRIMITIVE_TYPE(ScriptFunction);
|
||||||
|
|
||||||
ScriptFunction::ScriptFunction(const Callback& function)
|
ScriptFunction::ScriptFunction(const Callback& function)
|
||||||
: m_Callback(function)
|
: m_Callback(function)
|
||||||
{ }
|
{ }
|
||||||
|
@ -37,7 +37,7 @@ namespace icinga
|
|||||||
class I2_BASE_API ScriptFunction : public Object
|
class I2_BASE_API ScriptFunction : public Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(ScriptFunction);
|
DECLARE_OBJECT(ScriptFunction);
|
||||||
|
|
||||||
typedef boost::function<Value (const std::vector<Value>& arguments)> Callback;
|
typedef boost::function<Value (const std::vector<Value>& arguments)> Callback;
|
||||||
|
|
||||||
|
@ -299,11 +299,14 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
|
|||||||
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
|
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
|
||||||
std::string ftype = it->Type;
|
std::string ftype = it->Type;
|
||||||
|
|
||||||
|
if (ftype == "bool" || ftype == "int" || ftype == "double")
|
||||||
|
ftype = "Number";
|
||||||
|
|
||||||
if (ftype.find("::Ptr") != std::string::npos)
|
if (ftype.find("::Ptr") != std::string::npos)
|
||||||
ftype = ftype.substr(0, ftype.size() - strlen("::Ptr"));
|
ftype = ftype.substr(0, ftype.size() - strlen("::Ptr"));
|
||||||
|
|
||||||
if (it->Attributes & FAEnum)
|
if (it->Attributes & FAEnum)
|
||||||
ftype = "int";
|
ftype = "Number";
|
||||||
|
|
||||||
std::cout << "\t\t\t" << "case " << num << ":" << std::endl
|
std::cout << "\t\t\t" << "case " << num << ":" << std::endl
|
||||||
<< "\t\t\t\t" << "return Field(" << num << ", \"" << ftype << "\", \"" << it->Name << "\", " << it->Attributes << ");" << std::endl;
|
<< "\t\t\t\t" << "return Field(" << num << ", \"" << ftype << "\", \"" << it->Name << "\", " << it->Attributes << ");" << std::endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user