Browse Source

plString-ify plPythonSDLModifier

Adam Johnson 11 years ago
parent
commit
2cc162eecb
  1. 32
      Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp
  2. 18
      Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.h
  3. 20
      Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifierGlue.cpp

32
Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp

@ -699,48 +699,48 @@ PyObject* pySDLModifier::GetAgeSDL()
}
void pySDLModifier::SetDefault(pySDLModifier& self, std::string key, PyObject* value)
void pySDLModifier::SetDefault(pySDLModifier& self, const plString& key, PyObject* value)
{
self.fRecord->SetDefault(key.c_str(), value);
self.fRecord->SetDefault(key, value);
}
void pySDLModifier::SendToClients(pySDLModifier& self, std::string key)
void pySDLModifier::SendToClients(pySDLModifier& self, const plString& key)
{
self.fRecord->SendToClients(key.c_str());
self.fRecord->SendToClients(key);
}
void pySDLModifier::SetNotify(pySDLModifier& self, pyKey& selfkey, std::string key, float tolerance)
void pySDLModifier::SetNotify(pySDLModifier& self, pyKey& selfkey, const plString& key, float tolerance)
{
self.fRecord->SetNotify(selfkey, key.c_str(), tolerance);
self.fRecord->SetNotify(selfkey, key, tolerance);
}
PyObject* pySDLModifier::GetItem(pySDLModifier& self, std::string key)
PyObject* pySDLModifier::GetItem(pySDLModifier& self, const plString& key)
{
return self.fRecord->GetItem(key.c_str());
return self.fRecord->GetItem(key);
}
void pySDLModifier::SetItem(pySDLModifier& self, std::string key, PyObject* value)
void pySDLModifier::SetItem(pySDLModifier& self, const plString& key, PyObject* value)
{
self.fRecord->SetItem(key.c_str(), value);
self.fRecord->SetItem(key, value);
}
void pySDLModifier::SetItemIdx(pySDLModifier& self, std::string key, int idx, PyObject* value)
void pySDLModifier::SetItemIdx(pySDLModifier& self, const plString& key, int idx, PyObject* value)
{
self.fRecord->SetItemIdx(key.c_str(), idx, value);
self.fRecord->SetItemIdx(key, idx, value);
}
void pySDLModifier::SetItemIdxImmediate(pySDLModifier& self, std::string key, int idx, PyObject* value)
void pySDLModifier::SetItemIdxImmediate(pySDLModifier& self, const plString& key, int idx, PyObject* value)
{
self.fRecord->SetItemIdx(key.c_str(), idx, value, true);
self.fRecord->SetItemIdx(key, idx, value, true);
}
void pySDLModifier::SetFlags(pySDLModifier& self, const char* name, bool sendImmediate, bool skipOwnershipCheck)
void pySDLModifier::SetFlags(pySDLModifier& self, const plString& name, bool sendImmediate, bool skipOwnershipCheck)
{
self.fRecord->SetFlags(name,sendImmediate,skipOwnershipCheck);
}
void pySDLModifier::SetTagString(pySDLModifier& self, const char* name, const char* tag)
void pySDLModifier::SetTagString(pySDLModifier& self, const plString& name, const plString& tag)
{
self.fRecord->SetTagString(name,tag);
}

18
Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.h

@ -142,16 +142,16 @@ public:
// global function to get the GrandMaster Age SDL object
static PyObject* GetAgeSDL();
static void SetDefault(pySDLModifier& self, std::string key, PyObject* value);
static void SendToClients(pySDLModifier& self, std::string key);
static void SetNotify(pySDLModifier& self, pyKey& selfkey, std::string key, float tolerance);
static void SetDefault(pySDLModifier& self, const plString& key, PyObject* value);
static void SendToClients(pySDLModifier& self, const plString& key);
static void SetNotify(pySDLModifier& self, pyKey& selfkey, const plString& key, float tolerance);
static PyObject* GetItem(pySDLModifier& self, std::string key);
static void SetItem(pySDLModifier& self, std::string key, PyObject* value);
static void SetItemIdx(pySDLModifier& self, std::string key, int idx, PyObject* value);
static void SetItemIdxImmediate(pySDLModifier& self, std::string key, int idx, PyObject* value);
static void SetFlags(pySDLModifier& self, const char* name, bool sendImmediate, bool skipOwnershipCheck);
static void SetTagString(pySDLModifier& self, const char* name, const char* tag);
static PyObject* GetItem(pySDLModifier& self, const plString& key);
static void SetItem(pySDLModifier& self, const plString& key, PyObject* value);
static void SetItemIdx(pySDLModifier& self, const plString& key, int idx, PyObject* value);
static void SetItemIdxImmediate(pySDLModifier& self, const plString& key, int idx, PyObject* value);
static void SetFlags(pySDLModifier& self, const plString& name, bool sendImmediate, bool skipOwnershipCheck);
static void SetTagString(pySDLModifier& self, const plString& name, const plString& tag);
};

20
Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifierGlue.cpp

@ -76,7 +76,7 @@ PYTHON_METHOD_DEFINITION(ptSDL, setIndexNow, args)
char* key;
int idx;
PyObject* value = NULL;
if (!PyArg_ParseTuple(args, "siO", &key, &idx, &value))
if (!PyArg_ParseTuple(args, "etiO", "utf8", &key, &idx, &value))
{
PyErr_SetString(PyExc_TypeError, "setIndexNow expects a string, int, and an object");
PYTHON_RETURN_ERROR;
@ -89,7 +89,7 @@ PYTHON_METHOD_DEFINITION(ptSDL, setDefault, args)
{
char* key;
PyObject* value = NULL;
if (!PyArg_ParseTuple(args, "sO", &key, &value))
if (!PyArg_ParseTuple(args, "etO", "utf8", &key, &value))
{
PyErr_SetString(PyExc_TypeError, "setDefault expects a string and a tuple");
PYTHON_RETURN_ERROR;
@ -106,7 +106,7 @@ PYTHON_METHOD_DEFINITION(ptSDL, setDefault, args)
PYTHON_METHOD_DEFINITION(ptSDL, sendToClients, args)
{
char* key;
if (!PyArg_ParseTuple(args, "s", &key))
if (!PyArg_ParseTuple(args, "et", "utf8", &key))
{
PyErr_SetString(PyExc_TypeError, "sendToClients expects a string");
PYTHON_RETURN_ERROR;
@ -120,7 +120,7 @@ PYTHON_METHOD_DEFINITION(ptSDL, setNotify, args)
PyObject* selfKeyObj;
char* key;
float tolerance;
if (!PyArg_ParseTuple(args, "Osf", &selfKeyObj, &key, &tolerance))
if (!PyArg_ParseTuple(args, "Oetf", &selfKeyObj, "utf8", &key, &tolerance))
{
PyErr_SetString(PyExc_TypeError, "setNotify expects a ptKey, string, and float");
PYTHON_RETURN_ERROR;
@ -139,7 +139,7 @@ PYTHON_METHOD_DEFINITION(ptSDL, setFlags, args)
{
char* key;
char sendImmediate, skipOwnershipCheck;
if (!PyArg_ParseTuple(args, "sbb", &key, &sendImmediate, &skipOwnershipCheck))
if (!PyArg_ParseTuple(args, "etbb", "utf8", &key, &sendImmediate, &skipOwnershipCheck))
{
PyErr_SetString(PyExc_TypeError, "setFlags expects a string and two booleans");
PYTHON_RETURN_ERROR;
@ -152,7 +152,7 @@ PYTHON_METHOD_DEFINITION(ptSDL, setTagString, args)
{
char* key;
char* tag;
if (!PyArg_ParseTuple(args, "ss", &key, &tag))
if (!PyArg_ParseTuple(args, "etet", "utf8", &key, "utf8", &tag))
{
PyErr_SetString(PyExc_TypeError, "setTagString expects two strings");
PYTHON_RETURN_ERROR;
@ -179,12 +179,12 @@ PYTHON_END_METHODS_TABLE;
PyObject* ptSDL_subscript(ptSDL* self, PyObject* key)
{
if (!PyString_Check(key))
if (!PyString_CheckEx(key))
{
PyErr_SetString(PyExc_TypeError, "SDL indexes must be strings");
PYTHON_RETURN_ERROR;
}
char *keyStr = PyString_AsString(key);
plString keyStr = PyString_AsStringEx(key);
return pySDLModifier::GetItem(*(self->fThis), keyStr);
}
@ -195,7 +195,7 @@ int ptSDL_ass_subscript(ptSDL* self, PyObject* key, PyObject* value)
PyErr_SetString(PyExc_RuntimeError, "Cannot remove sdl records");
return -1; // error return
}
if (!PyString_Check(key))
if (!PyString_CheckEx(key))
{
PyErr_SetString(PyExc_TypeError, "SDL indexes must be strings");
return -1; // error return
@ -205,7 +205,7 @@ int ptSDL_ass_subscript(ptSDL* self, PyObject* key, PyObject* value)
PyErr_SetString(PyExc_TypeError, "SDL values must be tuples");
return -1; // error return
}
char* keyStr = PyString_AsString(key);
plString keyStr = PyString_AsStringEx(key);
pySDLModifier::SetItem(*(self->fThis), keyStr, value);
return 0; // success return
}

Loading…
Cancel
Save