Fix typeof incorrectly returning null for arrays and dictionaries

fixes #8002
This commit is contained in:
Gunnar Beutner 2014-12-08 08:36:03 +01:00
parent b5c7e2de4e
commit 04ca634a16
5 changed files with 21 additions and 9 deletions

View File

@ -21,9 +21,7 @@
using namespace icinga;
REGISTER_BUILTIN_TYPE(int);
REGISTER_BUILTIN_TYPE(double);
REGISTER_BUILTIN_TYPE(bool);
REGISTER_BUILTIN_TYPE(Number);
PrimitiveType::PrimitiveType(const String& name)
: m_Name(name)

View File

@ -48,16 +48,24 @@ private:
#define REGISTER_BUILTIN_TYPE(type) \
namespace { namespace UNIQUE_NAME(prt) { namespace prt ## type { \
void RegisterPrimitiveType(void) \
void RegisterBuiltinType(void) \
{ \
icinga::Type::Ptr t = new PrimitiveType(#type); \
icinga::Type::Register(t); \
} \
INITIALIZE_ONCE(RegisterPrimitiveType); \
INITIALIZE_ONCE(RegisterBuiltinType); \
} } }
#define REGISTER_PRIMITIVE_TYPE(type) \
REGISTER_BUILTIN_TYPE(type); \
#define REGISTER_PRIMITIVE_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)
}

View File

@ -19,9 +19,12 @@
#include "base/scriptfunction.hpp"
#include "base/scriptvariable.hpp"
#include "base/primitivetype.hpp"
using namespace icinga;
REGISTER_PRIMITIVE_TYPE(ScriptFunction);
ScriptFunction::ScriptFunction(const Callback& function)
: m_Callback(function)
{ }

View File

@ -37,7 +37,7 @@ namespace icinga
class I2_BASE_API ScriptFunction : public Object
{
public:
DECLARE_PTR_TYPEDEFS(ScriptFunction);
DECLARE_OBJECT(ScriptFunction);
typedef boost::function<Value (const std::vector<Value>& arguments)> Callback;

View File

@ -299,11 +299,14 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
std::string ftype = it->Type;
if (ftype == "bool" || ftype == "int" || ftype == "double")
ftype = "Number";
if (ftype.find("::Ptr") != std::string::npos)
ftype = ftype.substr(0, ftype.size() - strlen("::Ptr"));
if (it->Attributes & FAEnum)
ftype = "int";
ftype = "Number";
std::cout << "\t\t\t" << "case " << num << ":" << std::endl
<< "\t\t\t\t" << "return Field(" << num << ", \"" << ftype << "\", \"" << it->Name << "\", " << it->Attributes << ");" << std::endl;