Update of /cvsroot/wpdev/wolfpack/python
In directory sc8-pr-cvs1:/tmp/cvs-serv2528/python
Modified Files:
char.cpp global.cpp item.cpp multi.cpp utilities.h
Log Message:
Changed Python Interface
Changed behaviour of setGlobalHook and setCommandHook
Index: char.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/char.cpp,v
retrieving revision 1.105
retrieving revision 1.106
diff -C2 -d -r1.105 -r1.106
*** char.cpp 15 Sep 2003 12:49:05 -0000 1.105
--- char.cpp 23 Sep 2003 12:40:19 -0000 1.106
***************
*** 1789,1793 ****
continue;
! cPythonScript *script = ScriptManager->find( PyString_AsString( PyList_GetItem( value, i ) ) );
if( script )
self->pChar->addEvent( script );
--- 1789,1793 ----
continue;
! cPythonScript *script = ScriptManager::instance()->find( PyString_AsString( PyList_GetItem( value, i ) ) );
if( script )
self->pChar->addEvent( script );
Index: global.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/global.cpp,v
retrieving revision 1.93
retrieving revision 1.94
diff -C2 -d -r1.93 -r1.94
*** global.cpp 19 Sep 2003 20:41:08 -0000 1.93
--- global.cpp 23 Sep 2003 12:40:19 -0000 1.94
***************
*** 72,75 ****
--- 72,85 ----
#include <qmutex.h>
+ PyObject *PyGetObjectObject( cUObject *object )
+ {
+ if( dynamic_cast< P_ITEM >( object ) )
+ return PyGetItemObject( (P_ITEM)object );
+ else if( dynamic_cast< P_CHAR >( object ) )
+ return PyGetCharObject( (P_CHAR)object );
+
+ return 0;
+ }
+
static QStringList getFlagNames( const tile_st &tile )
{
***************
*** 738,752 ****
static PyObject *wpRegisterGlobal( PyObject* self, PyObject* args )
{
! if( !checkArgInt( 0 ) || !checkArgInt( 1 ) || !checkArgStr( 2 ) )
! {
! PyErr_BadArgument();
! return 0;
! }
! UINT32 object = getArgInt( 0 );
! UINT32 event = getArgInt( 1 );
! QString scriptName = getArgStr( 2 );
! cPythonScript *script = ScriptManager->find( scriptName );
if( script == 0 )
--- 748,758 ----
static PyObject *wpRegisterGlobal( PyObject* self, PyObject* args )
{
! unsigned int event;
! const char *scriptName;
! if( !PyArg_ParseTuple( args, "is:wolfpack.registerglobal", &event, &scriptName ) )
! return 0;
! cPythonScript *script = ScriptManager::instance()->find( scriptName );
if( script == 0 )
***************
*** 756,760 ****
}
! ScriptManager->addGlobalHook( object, event, script );
return PyTrue;
}
--- 762,772 ----
}
! if( event >= EVENT_COUNT )
! {
! PyErr_SetString( PyExc_RuntimeError, "Unknown script." );
! return 0;
! }
!
! ScriptManager::instance()->setGlobalHook( (ePythonEvent)event, script );
return PyTrue;
}
***************
*** 765,786 ****
static PyObject *wpRegisterCommand( PyObject* self, PyObject* args )
{
! if( !checkArgStr( 0 ) || !checkArgStr( 1 ) )
! {
! PyErr_BadArgument();
! return 0;
! }
!
! QString command = getArgStr( 0 );
! QString scriptName = getArgStr( 1 );
! cPythonScript *script = ScriptManager->find( scriptName );
! if( script == 0 )
{
! PyErr_SetString( PyExc_RuntimeError, "Unknown script." );
return 0;
}
! ScriptManager->addCommandHook( command, script );
return PyTrue;
}
--- 777,794 ----
static PyObject *wpRegisterCommand( PyObject* self, PyObject* args )
{
! const char *command;
! PyObject *function;
! if( !PyArg_ParseTuple( args, "sO:wolfpack.registercommand", &command, &function ) )
! return 0;
! if( !PyCallable_Check( function ) )
{
! PyErr_SetString( PyExc_TypeError, "wolfpack.registercommand( command, function ): function has to be a callable object" );
return 0;
}
! Py_INCREF( function );
! ScriptManager::instance()->setCommandHook( command, function );
return PyTrue;
}
***************
*** 1144,1261 ****
};
-
- /*!
- Adds a speech keyword to a wolfpack script object.
- */
- static PyObject *wpSpeechAddKeyword( PyObject* self, PyObject* args )
- {
- Q_UNUSED(self);
- if( !checkArgStr( 0 ) || !checkArgInt( 1 ) )
- {
- PyErr_BadArgument();
- return 0;
- }
-
- cPythonScript *script = ScriptManager->find( getArgStr( 0 ) );
-
- if( !script )
- {
- PyErr_Warn( PyExc_Warning, "Use of unknown script-id." );
- return PyFalse;
- }
-
- script->addKeyword( getArgInt( 1 ) );
-
- return PyTrue;
- }
-
- /*!
- Adds a speech trigger-word to a wolfpack script object.
- */
- static PyObject *wpSpeechAddWord( PyObject* self, PyObject* args )
- {
- Q_UNUSED(self);
- if( !checkArgStr( 0 ) || !checkArgStr( 1 ) )
- {
- PyErr_BadArgument();
- return 0;
- }
-
- cPythonScript *script = ScriptManager->find( getArgStr( 0 ) );
-
- if( !script )
- {
- PyErr_Warn( PyExc_Warning, "Use of unknown script-id." );
- return PyFalse;
- }
-
- script->addWord( getArgStr( 1 ) );
-
- return PyTrue;
- }
-
- /*!
- Adds a speech regular expression to a wolfpack script object.
- */
- static PyObject *wpSpeechAddRegexp( PyObject* self, PyObject* args )
- {
- Q_UNUSED(self);
- if( !checkArgStr( 0 ) || !checkArgStr( 1 ) )
- {
- PyErr_BadArgument();
- return 0;
- }
-
- cPythonScript *script = ScriptManager->find( getArgStr( 0 ) );
-
- if( !script )
- {
- PyErr_Warn( PyExc_Warning, "Use of unknown script-id." );
- return PyFalse;
- }
-
- script->addRegexp( QRegExp( getArgStr( 1 ) ) );
-
- return PyTrue;
- }
-
- /*!
- Specifies if a speech script should fetch all speech events and not just one case.
- */
- static PyObject *wpSpeechSetCatchAll( PyObject* self, PyObject* args )
- {
- Q_UNUSED(self);
- if( !checkArgStr( 0 ) || !checkArgInt( 1 ) )
- {
- PyErr_BadArgument();
- return 0;
- }
-
- cPythonScript *script = ScriptManager->find( getArgStr( 0 ) );
-
- if( !script )
- {
- PyErr_Warn( PyExc_Warning, "Use of unknown script-id." );
- return PyFalse;
- }
-
- script->setCatchAllSpeech( getArgInt( 1 ) != 0 );
-
- return PyTrue;
- }
-
- /*!
- wolfpack.speech
- speech related functions
- */
- static PyMethodDef wpSpeech[] =
- {
- { "addKeyword", wpSpeechAddKeyword, METH_VARARGS, "Adds a keyword to a specific speech script." },
- { "addWord", wpSpeechAddWord, METH_VARARGS, "Adds a triggerword to a specific speech script." },
- { "addRegexp", wpSpeechAddRegexp, METH_VARARGS, "Adds a regular expression to a specific speech script." },
- { "setCatchAll", wpSpeechSetCatchAll, METH_VARARGS, "Specifies if a speech script should fetch all speech events and not just one case." },
- { NULL, NULL, 0, NULL } // Terminator
- };
-
/*!
Finds an Account object.
--- 1152,1155 ----
***************
*** 1569,1575 ****
PyObject *mConsole = Py_InitModule( "_wolfpack.console", wpConsole );
PyObject_SetAttrString( wpNamespace, "console", mConsole );
-
- PyObject *mSpeech = Py_InitModule( "_wolfpack.speech", wpSpeech );
- PyObject_SetAttrString( wpNamespace, "speech", mSpeech );
PyObject *mAccounts = Py_InitModule( "_wolfpack.accounts", wpAccounts );
--- 1463,1466 ----
Index: item.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/item.cpp,v
retrieving revision 1.74
retrieving revision 1.75
diff -C2 -d -r1.74 -r1.75
*** item.cpp 11 Sep 2003 16:19:51 -0000 1.74
--- item.cpp 23 Sep 2003 12:40:19 -0000 1.75
***************
*** 752,756 ****
continue;
! cPythonScript *script = ScriptManager->find( PyString_AsString( PyList_GetItem( value, i ) ) );
if( script )
self->pItem->addEvent( script );
--- 752,756 ----
continue;
! cPythonScript *script = ScriptManager::instance()->find( PyString_AsString( PyList_GetItem( value, i ) ) );
if( script )
self->pItem->addEvent( script );
Index: multi.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/multi.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** multi.cpp 11 Sep 2003 16:19:51 -0000 1.18
--- multi.cpp 23 Sep 2003 12:40:20 -0000 1.19
***************
*** 646,650 ****
continue;
! cPythonScript *script = ScriptManager->find( PyString_AsString( PyList_GetItem( value, i ) ) );
if( script )
self->pMulti->addEvent( script );
--- 646,650 ----
continue;
! cPythonScript *script = ScriptManager::instance()->find( PyString_AsString( PyList_GetItem( value, i ) ) );
if( script )
self->pMulti->addEvent( script );
Index: utilities.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/utilities.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** utilities.h 20 Sep 2003 01:05:10 -0000 1.22
--- utilities.h 23 Sep 2003 12:40:20 -0000 1.23
***************
*** 86,89 ****
--- 86,91 ----
P_ITEM getWpItem( PyObject* );
+ PyObject *PyGetObjectObject( cUObject* );
+
bool checkWpChar( PyObject *object );
PyObject* PyGetCharObject( P_CHAR );
|