[icinga-checkins] icinga.org: icinga2/master: Remove support for type hints.

git at icinga.org git at icinga.org
Sat Feb 16 07:49:46 CET 2013


Module: icinga2
Branch: master
Commit: d0481ea578aeb2e0b30185c2e56d807bb61ed901
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=d0481ea578aeb2e0b30185c2e56d807bb61ed901

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Fri Feb 15 18:27:21 2013 +0100

Remove support for type hints.

---

 lib/base/scriptfunction.cpp   |   42 +----------------------------------------
 lib/base/scriptfunction.h     |   26 -------------------------
 lib/python/pythonlanguage.cpp |    8 +++---
 lib/python/pythonlanguage.h   |    4 +-
 4 files changed, 7 insertions(+), 73 deletions(-)

diff --git a/lib/base/scriptfunction.cpp b/lib/base/scriptfunction.cpp
index 84a1f2a..3a8f5fa 100644
--- a/lib/base/scriptfunction.cpp
+++ b/lib/base/scriptfunction.cpp
@@ -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;
-}
diff --git a/lib/base/scriptfunction.h b/lib/base/scriptfunction.h
index c10da40..4597acd 100644
--- a/lib/base/scriptfunction.h
+++ b/lib/base/scriptfunction.h
@@ -26,20 +26,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.
  *
  * @ingroup base
@@ -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;
 };
 
 /**
diff --git a/lib/python/pythonlanguage.cpp b/lib/python/pythonlanguage.cpp
index 044e33d..36b9338 100644
--- a/lib/python/pythonlanguage.cpp
+++ b/lib/python/pythonlanguage.cpp
@@ -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());
diff --git a/lib/python/pythonlanguage.h b/lib/python/pythonlanguage.h
index 1fed98c..f27a994 100644
--- a/lib/python/pythonlanguage.h
+++ b/lib/python/pythonlanguage.h
@@ -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);
 };
 
 }





More information about the icinga-checkins mailing list