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)
#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)
}
#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)
{ }
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;
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;