Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

testmain.cpp

Go to the documentation of this file.
00001 #include "PyObjectPlus.h"
00002 #include "EmbeddedClass.h"
00003 
00004 extern "C" void initEmbeddedClass(void);
00005 
00006 void main(int argc, char **argv)

00007 {
00008         int sizeemb = sizeof(EmbeddedClass);
00009         int sizepy = sizeof(PyObjectPlus);
00010         /* Pass argv[0] to the Python interpreter */
00011         Py_SetProgramName(argv[0]);
00012 
00013         /* Initialize the Python interpreter.  Required. */
00014         Py_Initialize();
00015 
00016         /* add the static C++ Embedded Class extension */
00017         initEmbeddedClass();
00018         
00019         /* Define sys.argv.  It is up to the application if you

00020            want this; you can also let it undefined (since the Python 

00021            code is generally not a main program it has no business

00022            touching sys.argv...) */
00023         PySys_SetArgv(argc, argv);
00024 
00025         /* Do some application specific code */
00026         printf("Hello, brave new world\n\n");
00027 
00028         /* Execute some Python statements (in module __main__) */
00029 //      PyRun_SimpleString("import sys\n");
00030         
00031         PyRun_SimpleString("import EmbeddedClass\n");
00032         /* Create a C++ Embedded Class from within Python */
00033         PyRun_SimpleString("N1 = EmbeddedClass.new(\"objname\")\n");
00034         PyRun_SimpleString("N1.PrintHello()\n");
00035         PyRun_SimpleString("N1.bagger.python = 10\n");
00036 
00037         
00038         /* Clean up the interpreter */
00039         Py_Finalize();
00040 
00041         /* Some more application specific code */
00042         printf("\nGoodbye, cruel world\n");
00043 }

Generated at Thu Feb 1 13:03:13 2001 for Ketsji Game Engine by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000