]> granicus.if.org Git - icinga2/commitdiff
Remove support for type hints.
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 15 Feb 2013 17:27:21 +0000 (18:27 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 15 Feb 2013 17:35:40 +0000 (18:35 +0100)
lib/base/scriptfunction.cpp
lib/base/scriptfunction.h
lib/python/pythonlanguage.cpp
lib/python/pythonlanguage.h

index 84a1f2a46b705d11420e3e3764564e82fbeb2149..3a8f5fafa4aa042a77475b3c4c4dffc595e61cc5 100644 (file)
@@ -25,7 +25,7 @@ boost::signal<void (const String&, const ScriptFunction::Ptr&)> ScriptFunction::
 boost::signal<void (const String&)> ScriptFunction::OnUnregistered;
 
 ScriptFunction::ScriptFunction(const Callback& function)
-       : m_Callback(function), m_ArgumentCount(-1)
+       : m_Callback(function)
 { }
 
 void ScriptFunction::Register(const String& name, const ScriptFunction::Ptr& function)
@@ -62,43 +62,3 @@ map<String, ScriptFunction::Ptr>& ScriptFunction::GetFunctions(void)
        static map<String, ScriptFunction::Ptr> functions;
        return functions;
 }
-
-void ScriptFunction::SetArgumentCount(int count)
-{
-       if (m_ArgumentCount >= 0)
-               m_ArgumentHints.resize(count);
-
-       m_ArgumentCount = count;
-}
-
-int ScriptFunction::GetArgumentCount(void) const
-{
-       return m_ArgumentCount;
-}
-
-void ScriptFunction::SetArgumentHint(int index, const ScriptArgumentHint& hint)
-{
-       assert(index >= 0 && index < m_ArgumentCount);
-
-       m_ArgumentHints[index] = hint;
-}
-
-ScriptArgumentHint ScriptFunction::GetArgumentHint(int index) const
-{
-       if (m_ArgumentCount == -1 || index >= m_ArgumentCount)
-               return ScriptArgumentHint();
-
-       assert(index >= 0 && index < m_ArgumentHints.size());
-
-       return m_ArgumentHints[index];
-}
-
-void ScriptFunction::SetReturnHint(const ScriptArgumentHint& hint)
-{
-       m_ReturnHint = hint;
-}
-
-ScriptArgumentHint ScriptFunction::GetReturnHint(void) const
-{
-       return m_ReturnHint;
-}
index c10da40c8c0309bd82c103084741c67c7f97ad19..4597acde6bfff443c2a06ac71d9bc5e0bf569e6e 100644 (file)
@@ -25,20 +25,6 @@ namespace icinga
 
 class ScriptTask;
 
-/**
- * A type hint.
- */
-struct ScriptArgumentHint
-{
-       bool RestrictType;
-       ValueType Type;
-       String Class;
-
-       ScriptArgumentHint(void)
-               : RestrictType(false), Type(ValueEmpty), Class()
-       { }
-};
-
 /**
  * A script function that can be used to execute a script task.
  *
@@ -60,15 +46,6 @@ public:
 
        void Invoke(const shared_ptr<ScriptTask>& task, const vector<Value>& arguments);
 
-       void SetArgumentCount(int count);
-       int GetArgumentCount(void) const;
-
-       void SetArgumentHint(int index, const ScriptArgumentHint& hint);
-       ScriptArgumentHint GetArgumentHint(int index) const;
-
-       void SetReturnHint(const ScriptArgumentHint& hint);
-       ScriptArgumentHint GetReturnHint(void) const;
-
        static map<String, ScriptFunction::Ptr>& GetFunctions(void);
 
        static boost::signal<void (const String&, const ScriptFunction::Ptr&)> OnRegistered;
@@ -76,9 +53,6 @@ public:
 
 private:
        Callback m_Callback;
-       int m_ArgumentCount;
-       vector<ScriptArgumentHint> m_ArgumentHints;
-       ScriptArgumentHint m_ReturnHint;
 };
 
 /**
index 044e33d8c3b5720d1a8bc184fb96c7c701cba57f..36b93385b817c9f0f84f5011f37fe02fce1e0a44 100644 (file)
@@ -69,7 +69,7 @@ PyThreadState *PythonLanguage::GetMainThreadState(void) const
        return m_MainThreadState;
 }
 
-PyObject *PythonLanguage::MarshalToPython(const Value& value, const ScriptArgumentHint& hint)
+PyObject *PythonLanguage::MarshalToPython(const Value& value)
 {
        String svalue;
 
@@ -158,10 +158,10 @@ PyObject *PythonLanguage::CallNativeFunction(PyObject *self, PyObject *args)
                        for (Py_ssize_t i = 0; i < PyTuple_Size(args); i++) {
                                PyObject *arg = PyTuple_GetItem(args, i);
 
-                               arguments.push_back(MarshalFromPython(arg, function->GetArgumentHint(i)));
+                               arguments.push_back(MarshalFromPython(arg));
                        }
                } else {
-                       arguments.push_back(MarshalFromPython(args, function->GetArgumentHint(0)));
+                       arguments.push_back(MarshalFromPython(args));
                }
        }
 
@@ -172,7 +172,7 @@ PyObject *PythonLanguage::CallNativeFunction(PyObject *self, PyObject *args)
        try {
                Value result = task->GetResult();
 
-               return MarshalToPython(result, function->GetReturnHint());
+               return MarshalToPython(result);
        } catch (const std::exception& ex) {
                String message = diagnostic_information(ex);
                PyErr_SetString(PyExc_RuntimeError, message.CStr());
index 1fed98c4454888e846d027f8f8fda5d6aa892df2..f27a994368b2f38098a5ea9eeb805612abefa0f6 100644 (file)
@@ -50,8 +50,8 @@ private:
 
        static PyObject *CallNativeFunction(PyObject *self, PyObject *args);
 
-       static PyObject *MarshalToPython(const Value& value, const ScriptArgumentHint& hint);
-       static Value MarshalFromPython(PyObject *value, const ScriptArgumentHint& hint);
+       static PyObject *MarshalToPython(const Value& value);
+       static Value MarshalFromPython(PyObject *value);
 };
 
 }