pythonscript.cpp
64PythonScript::PythonScript(Kross::Api::Interpreter* interpreter, Kross::Api::ScriptContainer* scriptcontainer)
91 throw Kross::Api::Exception::Ptr( new Kross::Api::Exception(TQString("Invalid scripting code for script '%1'").arg( m_scriptcontainer->getName() )) );
94 throw Kross::Api::Exception::Ptr( new Kross::Api::Exception(TQString("Name for the script is invalid!")) );
99 throw Kross::Api::Exception::Ptr( new Kross::Api::Exception(TQString("Failed to initialize local module context for script '%1'").arg( m_scriptcontainer->getName() )) );
102 krossdebug( TQString("PythonScript::initialize() module='%1' refcount='%2'").arg(d->m_module->as_string().c_str()).arg(d->m_module->reference_count()) );
123 PyObject* pyrun = PyRun_StringFlags((char*)s.latin1(), Py_file_input, mainmoduledict.ptr(), moduledict.ptr());
134 krossdebug( TQString("PythonScript::initialize() name=%1 restricted=%2").arg(m_scriptcontainer->getName()).arg(restricted) );
163 Kross::Api::Exception::Ptr exception = toException( TQString("Failed to compile python code: %1").arg(err) );
173 krossdebug( TQString("PythonScript::finalize() module='%1' refcount='%2'").arg(d->m_module->as_string().c_str()).arg(d->m_module->reference_count()) );
208 krosswarning( TQString("Kross::Python::PythonScript::toException() Failed to fetch a traceback: %1").arg(err) );
296 PyObject* pyrun = PyRun_String(s.latin1(), Py_file_input, mainmoduledict.ptr(), moduledict.ptr());
328 krossdebug( TQString("PythonScript::execute() class '%1' added.").arg(vt.first.as_string().c_str()) );
334 krossdebug( TQString("PythonScript::execute() function '%1' added.").arg(vt.first.as_string().c_str()) );
346 if(errobj.ptr() == Py_None) // at least string-exceptions have there errormessage in the type-object
350 Kross::Api::Exception::Ptr exception = toException( TQString("Failed to execute python code: %1").arg(err) );
356 Kross::Api::Exception::Ptr exception = toException( TQString("Failed to execute python code: %1").arg(err) );
368Kross::Api::Object::Ptr PythonScript::callFunction(const TQString& name, Kross::Api::List::Ptr args)
390 throw Kross::Api::Exception::Ptr( new Kross::Api::Exception(TQString("No such function '%1'.").arg(name)) );
396 throw Kross::Api::Exception::Ptr( new Kross::Api::Exception(TQString("Function is not callable.")) );
436 throw Kross::Api::Exception::Ptr( new Kross::Api::Exception(TQString("No such class '%1'.").arg(name)) );
440 throw Kross::Api::Exception::Ptr( new Kross::Api::Exception(TQString("Failed to create instance of class '%1'.").arg(name)) );
445 krossdebug( TQString("PythonScript::classInstance() inst='%1'").arg(classobject.as_string().c_str()) );
Common exception class used for representing exceptions in Kross.
Definition exception.h:39
TDESharedPtr< Exception > Ptr
Shared pointer to implement reference-counting.
Definition exception.h:45
The ScriptContainer class is something like a single standalone scriptfile.
Definition scriptcontainer.h:51
const TQString getName() const
Definition scriptcontainer.cpp:104
TQVariant getOption(const TQString name, TQVariant defaultvalue=TQVariant(), bool recursive=false)
Definition scriptcontainer.cpp:152
TQString getCode() const
Return the scriptcode this ScriptContainer holds.
Definition scriptcontainer.cpp:114
Interpreter *const m_interpreter
The Interpreter used to create this Script instance.
Definition script.h:128
Script(Interpreter *const interpreter, ScriptContainer *const scriptcontainer)
Constructor.
Definition script.cpp:29
ScriptContainer *const m_scriptcontainer
The ScriptContainer associated with this Script.
Definition script.h:130
virtual const TQStringList & getFunctionNames()
Return a list of callable functionnames this script spends.
Definition pythonscript.cpp:257
PythonScript(Kross::Api::Interpreter *interpreter, Kross::Api::ScriptContainer *scriptcontainer)
Constructor.
Definition pythonscript.cpp:64
virtual Kross::Api::Object::Ptr callFunction(const TQString &name, Kross::Api::List::Ptr args)
Call a function.
Definition pythonscript.cpp:368
virtual Kross::Api::Object::Ptr classInstance(const TQString &name)
Create and return a new class instance.
Definition pythonscript.cpp:421
virtual const TQStringList & getClassNames()
Return a list of class types this script supports.
Definition pythonscript.cpp:414
TDEAction * next(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
The Kross scripting bridge to embed scripting functionality into an application.
Definition callable.h:33
