Base::InterpreterSingleton Class Reference

The Interpreter class This class manage the python interpreter and hold a lot helper functions for handling python stuff. More...

#include <Interpreter.h>

List of all members.

Public Member Functions

 InterpreterSingleton ()
 ~InterpreterSingleton ()
Cleanup



int cleanup (void(*func)(void))
 Register a cleanup function to be called by finalize().
void finalize ()
 This calls the registered cleanup functions.
void systemExit ()
 This shuts down the application.
external wrapper libs

here we can access external dynamically loaded wrapper libs done e.g.

by SWIG or SIP



void cleanupSWIG (const char *TypeName)
bool convertSWIGPointerObj (const char *Module, const char *TypeName, PyObject *obj, void **ptr, int flags)
PyObjectcreateSWIGPointerObj (const char *Modole, const char *TypeName, void *Pointer, int own)
 generate a SWIG object
methods for debugging facility



void dbgObserveFile (const char *sFileName="")
 sets the file name which should be debugged
void dbgSetBreakPoint (unsigned int uiLineNumber)
 sets a break point to a special line number in the current file
void dbgStep (void)
 One step further.
void dbgUnsetBreakPoint (unsigned int uiLineNumber)
 unsets a break point to a special line number in the current file
execution methods



void runFile (const char *pxFileName)
 Run file (script) on the python interpreter.
void runInteractiveString (const char *psCmd)
 Run a statement on the python interpreter and gives back a string with the representation of the result.
void runMethod (PyObject *pobject, const char *method, const char *resfmt=0, void *cresult=0, const char *argfmt="()",...)
 runs a python method with arbitrary params
PyObjectrunMethodObject (PyObject *pobject, const char *method)
 runs a python object method which returns a arbitrary object
void runMethodVoid (PyObject *pobject, const char *method)
 runs a python object method with no return value and no arguments
std::string runString (const char *psCmd)
 Run a statement on the python interpreter and gives back a string with the representation of the result.
void runStringArg (const char *psCom,...)
 Run a statement with arguments on the python interpreter.

Static Public Member Functions

static helper functions



static const std::string strToPython (const std::string &Str)
static const std::string strToPython (const char *Str)
 replaces all char with escapes for usage in python console

Static Protected Attributes

static InterpreterSingleton_pcSingelton = 0

Module handling



void addPythonPath (const char *Path)
 Add an addtional pyhton path.
bool loadModule (const char *psModName)
static void addType (PyTypeObject *Type, PyObject *Module, const char *Name)

startup and singletons



const char * init (int argc, char *argv[])
 init the interpreter and returns the module search path
int runCommandLine (const char *prompt)
static void Destruct (void)
static InterpreterSingletonInstance (void)

Detailed Description

The Interpreter class This class manage the python interpreter and hold a lot helper functions for handling python stuff.

Definition at line 136 of file Interpreter.h.


Constructor & Destructor Documentation

InterpreterSingleton::InterpreterSingleton (  ) 

Definition at line 93 of file Interpreter.cpp.

Referenced by Instance().

InterpreterSingleton::~InterpreterSingleton (  ) 

Definition at line 98 of file Interpreter.cpp.


Member Function Documentation

void InterpreterSingleton::addPythonPath ( const char *  Path  ) 

Add an addtional pyhton path.

Definition at line 264 of file Interpreter.cpp.

void InterpreterSingleton::addType ( PyTypeObject *  Type,
PyObject Module,
const char *  Name 
) [static]

Definition at line 254 of file Interpreter.cpp.

References PyType_Object::o.

int InterpreterSingleton::cleanup ( void(*)(void)  func  ) 

Register a cleanup function to be called by finalize().

The cleanup function will be called with no arguments and should return no value. At most 32 cleanup functions can be registered.When the registration is successful 0 is returned; on failure -1 is returned. The cleanup function registered last is called first. Each cleanup function will be called at most once. Since Python's internal finallization will have completed before the cleanup function, no Python APIs should be called by func.

Definition at line 287 of file Interpreter.cpp.

void InterpreterSingleton::cleanupSWIG ( const char *  TypeName  ) 

Definition at line 608 of file Interpreter.cpp.

References Swig_python::cleanupSWIG_T().

bool InterpreterSingleton::convertSWIGPointerObj ( const char *  Module,
const char *  TypeName,
PyObject obj,
void **  ptr,
int  flags 
)
PyObject * InterpreterSingleton::createSWIGPointerObj ( const char *  Modole,
const char *  TypeName,
void *  Pointer,
int  own 
)

generate a SWIG object

Definition at line 515 of file Interpreter.cpp.

References Swig_python::createSWIGPointerObj_T(), getSWIGVersionFromModule(), and result.

void InterpreterSingleton::dbgObserveFile ( const char *  sFileName = ""  ) 

sets the file name which should be debugged

Definition at line 408 of file Interpreter.cpp.

void InterpreterSingleton::dbgSetBreakPoint ( unsigned int  uiLineNumber  ) 

sets a break point to a special line number in the current file

Definition at line 416 of file Interpreter.cpp.

void InterpreterSingleton::dbgStep ( void   ) 

One step further.

Definition at line 426 of file Interpreter.cpp.

void InterpreterSingleton::dbgUnsetBreakPoint ( unsigned int  uiLineNumber  ) 

unsets a break point to a special line number in the current file

Definition at line 421 of file Interpreter.cpp.

void InterpreterSingleton::Destruct ( void   )  [static]

Definition at line 330 of file Interpreter.cpp.

References _pcSingelton.

void InterpreterSingleton::finalize (  ) 

This calls the registered cleanup functions.

See also:
cleanup() for more details.

Definition at line 292 of file Interpreter.cpp.

Referenced by App::Application::destruct().

const char * InterpreterSingleton::init ( int  argc,
char *  argv[] 
)

init the interpreter and returns the module search path

Definition at line 274 of file Interpreter.cpp.

InterpreterSingleton & InterpreterSingleton::Instance ( void   )  [static]

Definition at line 322 of file Interpreter.cpp.

References _pcSingelton, and InterpreterSingleton().

Referenced by Base::Interpreter().

bool InterpreterSingleton::loadModule ( const char *  psModName  ) 
int InterpreterSingleton::runCommandLine ( const char *  prompt  ) 

Definition at line 338 of file Interpreter.cpp.

References PP_Run_Command_Line().

Referenced by App::Application::runApplication().

void InterpreterSingleton::runFile ( const char *  pxFileName  ) 

Run file (script) on the python interpreter.

Definition at line 213 of file Interpreter.cpp.

References Base::FileInfo::toStdWString().

Referenced by App::Application::processCmdLineFiles().

void InterpreterSingleton::runInteractiveString ( const char *  psCmd  ) 

Run a statement on the python interpreter and gives back a string with the representation of the result.

Definition at line 178 of file Interpreter.cpp.

References PP_Load_Module(), and Base::Exception::setMessage().

void InterpreterSingleton::runMethod ( PyObject pobject,
const char *  method,
const char *  resfmt = 0,
void *  cresult = 0,
const char *  argfmt = "()",
  ... 
)

runs a python method with arbitrary params

Definition at line 377 of file Interpreter.cpp.

References PP_Convert_Result().

PyObject * InterpreterSingleton::runMethodObject ( PyObject pobject,
const char *  method 
)

runs a python object method which returns a arbitrary object

Definition at line 361 of file Interpreter.cpp.

References PP_Run_Method().

void InterpreterSingleton::runMethodVoid ( PyObject pobject,
const char *  method 
)

runs a python object method with no return value and no arguments

Runs a member method of an object with no parameter and no return value void (void).

There are other methods to run with returns

Definition at line 348 of file Interpreter.cpp.

References PP_Run_Method().

std::string InterpreterSingleton::runString ( const char *  psCmd  ) 

Run a statement on the python interpreter and gives back a string with the representation of the result.

Definition at line 104 of file Interpreter.cpp.

References PP_Load_Module().

Referenced by App::Application::runApplication(), and runStringArg().

void InterpreterSingleton::runStringArg ( const char *  psCom,
  ... 
)

Run a statement with arguments on the python interpreter.

Definition at line 302 of file Interpreter.cpp.

References format2, format2_len, and runString().

Referenced by App::Application::processCmdLineFiles().

static const std::string Base::InterpreterSingleton::strToPython ( const std::string &  Str  )  [inline, static]

Definition at line 230 of file Interpreter.h.

References strToPython().

Referenced by strToPython().

const std::string InterpreterSingleton::strToPython ( const char *  Str  )  [static]

replaces all char with escapes for usage in python console

Definition at line 431 of file Interpreter.cpp.

References result.

void InterpreterSingleton::systemExit ( void   ) 

This shuts down the application.

Definition at line 135 of file Interpreter.cpp.

References Py::int, and Py::value().


Member Data Documentation

Definition at line 235 of file Interpreter.h.

Referenced by Destruct(), and Instance().


The documentation for this class was generated from the following files:

Generated on Wed Nov 23 19:01:47 2011 for FreeCAD by  doxygen 1.6.1