

/*© copyright 1999 UserLand Software, Inc. All Rights Reserved.*/


#define xxxFRONTIER_PYTHON 1

#ifdef FRONTIER_PYTHON

#include "C:\\Python16\\include\\Python.h"

#endif

#ifdef MACVERSION
#include <AppleEvents.h>
#include <iac.h>
#include <standard.h>
#endif

#ifdef WIN95VERSION
#include "standard.h"
#endif

#include <ctype.h>
#include <string.h>
#include "error.h"
#include "file.h"
#include "memory.h"
#include "ops.h"
#include "resources.h"
#include "strings.h"
#include "lang.h"
#include "langipc.h"
#include "langinternal.h"
#include "langexternal.h"
#include "langsystem7.h"
#include "langhtml.h"
#include "langwinipc.h"
#include "process.h"
#include "tableinternal.h"
#include "tablestructure.h"
#include "tableverbs.h"
#include "op.h"
#include "opinternal.h"
#include "oplist.h"
#include "opverbs.h"
#include "kernelverbs.h"
#include "kernelverbdefs.h"
#include "shell.rsrc.h"
#include "timedate.h"
#include "winsocknetevents.h"
#ifdef flcomponent
#include "osacomponent.h"
#endif
#include "langpython.h"

#ifdef FRONTIER_PYTHON

static boolean flpythoninitialized = false;

static void initpython (void) {

	if (!flpythoninitialized) {

		flpythoninitialized = true;

		Py_Initialize ();
		}

	return;
	}/*initpython*/


boolean langrunpythonscript (hdltreenode hp1, tyvaluerecord *v) {

	Handle h;
	boolean fl = false;
	char nilchar = '\0';

	flnextparamislast = true;

	if (!getexempttextvalue (hp1, 1, &h))
		return (false);

	if (!enlargehandle (h, 1, &nilchar)) {

		disposehandle (h);

		return (false);
		}

	initpython ();

	lockhandle (h);

	//PyObject* PyRun_String (char *str, int start, PyObject *globals, PyObject *locals);

	if (PyRun_SimpleString (*h) == 0)
		fl = setbooleanvalue (true, v);
	
	unlockhandle (h);

	disposehandle (h);

	return (fl);
	}/*langrunpythonscript*/

#else

boolean langrunpythonscript (hdltreenode hp1, tyvaluerecord *v) {

	langerror (unimplementedverberror);

	return (false);
	}

#endif
