langpython.c

Go to the documentation of this file.
00001 
00002 /*  $Id: langpython.c 1206 2006-04-05 23:21:19Z karstenw $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #include "frontier.h"
00029 #include "standard.h"
00030 
00031 #define xxxFRONTIER_PYTHON 1
00032 
00033 #ifdef FRONTIER_PYTHON
00034 
00035 #include "C:\\Python16\\include\\Python.h"
00036 
00037 #endif
00038 
00039 #ifdef MACVERSION
00040 #include <iac.h>
00041 #endif
00042 
00043 #include "error.h"
00044 #include "file.h"
00045 #include "memory.h"
00046 #include "ops.h"
00047 #include "resources.h"
00048 #include "strings.h"
00049 #include "lang.h"
00050 #include "langipc.h"
00051 #include "langinternal.h"
00052 #include "langexternal.h"
00053 #include "langsystem7.h"
00054 #include "langhtml.h"
00055 #include "langwinipc.h"
00056 #include "process.h"
00057 #include "tableinternal.h"
00058 #include "tablestructure.h"
00059 #include "tableverbs.h"
00060 #include "op.h"
00061 #include "opinternal.h"
00062 #include "oplist.h"
00063 #include "opverbs.h"
00064 #include "kernelverbs.h"
00065 #include "kernelverbdefs.h"
00066 #include "shell.rsrc.h"
00067 #include "timedate.h"
00068 #include "WinSockNetEvents.h"
00069 #ifdef flcomponent
00070 #include "osacomponent.h"
00071 #endif
00072 #include "langpython.h"
00073 
00074 #ifdef FRONTIER_PYTHON
00075 
00076 static boolean flpythoninitialized = false;
00077 
00078 static void initpython (void) {
00079 
00080     if (!flpythoninitialized) {
00081 
00082         flpythoninitialized = true;
00083 
00084         Py_Initialize ();
00085         }
00086 
00087     return;
00088     }/*initpython*/
00089 
00090 
00091 boolean langrunpythonscript (hdltreenode hp1, tyvaluerecord *v) {
00092 
00093     Handle h;
00094     boolean fl = false;
00095     char nilchar = '\0';
00096 
00097     flnextparamislast = true;
00098 
00099     if (!getexempttextvalue (hp1, 1, &h))
00100         return (false);
00101 
00102     if (!enlargehandle (h, 1, &nilchar)) {
00103 
00104         disposehandle (h);
00105 
00106         return (false);
00107         }
00108 
00109     initpython ();
00110 
00111     lockhandle (h);
00112 
00113     //PyObject* PyRun_String (char *str, int start, PyObject *globals, PyObject *locals);
00114 
00115     if (PyRun_SimpleString (*h) == 0)
00116         fl = setbooleanvalue (true, v);
00117     
00118     unlockhandle (h);
00119 
00120     disposehandle (h);
00121 
00122     return (fl);
00123     }/*langrunpythonscript*/
00124 
00125 #else
00126 
00127 boolean langrunpythonscript (hdltreenode hp1, tyvaluerecord *v) {
00128 #pragma unused(hp1, v)
00129 
00130     langerror (unimplementedverberror);
00131 
00132     return (false);
00133     }
00134 
00135 #endif

Generated on Wed May 31 18:19:52 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6