removed some builtins from the ironpython environment

This commit is contained in:
Valerie Wolfe 2024-03-28 23:30:10 -04:00
parent cba906b9b8
commit 3a80cb18a9

View file

@ -1,3 +1,4 @@
using System.Collections.Generic;
using IronPython.Hosting; using IronPython.Hosting;
using Microsoft.Scripting.Hosting; using Microsoft.Scripting.Hosting;
@ -11,11 +12,14 @@ namespace Dungeoneer {
// set up python engine // set up python engine
Engine = Python.CreateEngine(); Engine = Python.CreateEngine();
Scope = Engine.CreateScope(); Scope = Engine.CreateScope();
dynamic Builtin = Engine.GetBuiltinModule(); dynamic builtin = Engine.GetBuiltinModule();
// set up python environment // set up python environment
Builtin.Remove("open"); builtin.RemoveVariable("compile");
Scope.roll = new Func<int, int>((sides) => { return Dungeoneer.Util.Roll(sides); }); builtin.SetVariable("exec", (Action<string>)Run);
builtin.RemoveVariable("open");
Scope.roll = (Func<int, int>)Dungeoneer.Util.Roll;
} }
public static void Run(string file) { public static void Run(string file) {