コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: mvvc3/main
        public MainPage()
        {
            this.InitializeComponent();

            var setup = new ScriptRuntimeSetup();

            setup.HostType = typeof(DlrHost);
            setup.AddRubySetup();

            var runtime = Ruby.CreateRuntime(setup);

            this.engine = Ruby.GetEngine(runtime);
            this.scope  = engine.CreateScope();
            this.scope.SetVariable("Main", this);

            runtime.LoadAssembly(typeof(object).GetTypeInfo().Assembly);
            runtime.LoadAssembly(typeof(TextSetOptions).GetTypeInfo().Assembly);
            runtime.LoadAssembly(typeof(TextAlignment).GetTypeInfo().Assembly);

            string outputText = @"
box = main.find_name('OutputBox')
p box.text_alignment
box.text_alignment = Windows::UI::Xaml::TextAlignment.Right
p box.text_alignment
";

            InputBox.IsSpellCheckEnabled  = false;
            OutputBox.IsSpellCheckEnabled = false;
            InputBox.Document.SetText(TextSetOptions.None, outputText);
        }
コード例 #2
0
ファイル: Driver.cs プロジェクト: gaybro8777/ironruby
        public TestRuntime(Driver /*!*/ driver, TestCase /*!*/ testCase)
        {
            _driver   = driver;
            _testName = testCase.Name;

            if (_driver.IsDebug)
            {
                Environment.SetEnvironmentVariable("DLR_AssembliesFileName", _testName);
            }

            var           runtimeSetup  = ScriptRuntimeSetup.ReadConfiguration();
            LanguageSetup langaugeSetup = null;

            foreach (var language in runtimeSetup.LanguageSetups)
            {
                if (language.TypeName == typeof(RubyContext).AssemblyQualifiedName)
                {
                    langaugeSetup = language;
                    break;
                }
            }

            // TODO: dynamic modules with symbols are not available in partial trust
            runtimeSetup.DebugMode = !driver.PartialTrust;
            langaugeSetup.Options["InterpretedMode"] = _driver.Interpret;
            langaugeSetup.Options["Verbosity"]       = 2;
            langaugeSetup.Options["Compatibility"]   = testCase.Compatibility;

            _env     = Ruby.CreateRuntime(runtimeSetup);
            _engine  = Ruby.GetEngine(_env);
            _context = Ruby.GetExecutionContext(_engine);
        }
コード例 #3
0
 public ScriptHandler()
 {
     _runtime = Ruby.CreateRuntime();
     _runtime.LoadAssembly(GetType().Assembly);
     _engine = Ruby.GetEngine(_runtime);
     _scope  = _engine.CreateScope();
 }
コード例 #4
0
        public TestRuntime(Driver /*!*/ driver, TestCase /*!*/ testCase)
        {
            _driver   = driver;
            _testName = testCase.Name;

            if (testCase.Options.NoRuntime)
            {
                return;
            }

            if (_driver.SaveToAssemblies)
            {
                Environment.SetEnvironmentVariable("DLR_AssembliesFileName", _testName);
            }

            var runtimeSetup  = ScriptRuntimeSetup.ReadConfiguration();
            var languageSetup = runtimeSetup.AddRubySetup();

            runtimeSetup.DebugMode      = _driver.IsDebug;
            runtimeSetup.PrivateBinding = testCase.Options.PrivateBinding;
            runtimeSetup.HostType       = typeof(TestHost);
            runtimeSetup.HostArguments  = new object[] { testCase.Options };
            languageSetup.Options["NoAdaptiveCompilation"] = _driver.NoAdaptiveCompilation;
            languageSetup.Options["CompilationThreshold"]  = _driver.CompilationThreshold;
            languageSetup.Options["Verbosity"]             = 2;

            _runtime = Ruby.CreateRuntime(runtimeSetup);
            _engine  = Ruby.GetEngine(_runtime);
            _context = (RubyContext)HostingHelpers.GetLanguageContext(_engine);
        }
コード例 #5
0
 private void Initialize()
 {
     Engine       = Ruby.GetEngine(Runtime);
     Context      = Ruby.GetExecutionContext(Engine);
     CurrentScope = Engine.CreateScope();
     Operations   = Engine.CreateOperations();
     LoadAssemblies(typeof(object), typeof(Uri), typeof(Func <object>), typeof(StandardKernel), typeof(IRubyEngine));
     RequireRubyFile("Ninject.Dynamic.initializer.rb", ReaderType.Assembly);
 }
コード例 #6
0
        public RubyEngine()
        {
            var setup = CreateRuntimeSetup();

            setup.Options["InterpretedMode"] = true;
            var runtime = new ScriptRuntime(setup);

            _engine = Ruby.GetEngine(runtime);
        }
コード例 #7
0
ファイル: RubyEngine.cs プロジェクト: plus3x/ironrubymvc
 private void Initialize()
 {
     Engine       = Ruby.GetEngine(Runtime);
     Context      = Ruby.GetExecutionContext(Engine);
     CurrentScope = Engine.CreateScope();
     Operations   = Engine.CreateOperations();
     LoadAssemblies(typeof(object), typeof(Uri), typeof(HttpResponseBase), typeof(MembershipCreateStatus), typeof(RouteTable), typeof(Controller), typeof(RubyController));
     AddLoadPaths();
     DefineReadOnlyGlobalVariable(Constants.ScriptRuntimeVariable, Engine);
     RequireControllerFile();
 }
コード例 #8
0
        public static void Initialize()
        {
            self_path = System.IO.Directory.GetCurrentDirectory();
            ScriptRuntime _runTime = Ruby.CreateRuntime();

            _engine = Ruby.GetEngine(_runTime);
            _scope  = _engine.CreateScope();
            _engine.Execute(@"load_assembly 'IronRuby.Libraries'; load_assembly 'DataStructure'", _scope);
            _engine.ExecuteFile(@"rb\mapx.rb");
            _scope.SetVariable("a", "");
            _engine.Execute(@"$path = a", _scope);
        }
コード例 #9
0
ファイル: RubyContext.cs プロジェクト: Spharah/Warewolf-ESB
        public ScriptEngine CreateRubyEngine()
        {
            var runtimeSetup = ScriptRuntimeSetup.ReadConfiguration();
            var languageSetup = runtimeSetup.AddRubySetup();

            runtimeSetup.PrivateBinding = true;
            runtimeSetup.HostType = typeof(TmpHost);
            runtimeSetup.HostArguments = new object[] { new OptionsAttribute() };

            languageSetup.Options["Verbosity"] = 2;

            var runtime = Ruby.CreateRuntime(runtimeSetup);
            return Ruby.GetEngine(runtime);
        }
コード例 #10
0
        public Action Cleanup;  // A function delegate that will be called when the script is completed to allow any cleanup actions to take place.

        public DialPlanExecutingScript(SIPMonitorLogDelegate logDelegate)
        {
            ScriptNumber = ++ScriptCounter % Int32.MaxValue;
            Id           = Guid.NewGuid();

            var setup         = ScriptRuntimeSetup.ReadConfiguration();
            var scriptRuntime = Ruby.CreateRuntime(setup);

            DialPlanScriptEngine = Ruby.GetEngine(scriptRuntime);

            //DialPlanScriptEngine = Ruby.CreateEngine();

            DialPlanScriptScope = DialPlanScriptEngine.CreateScope();

            LogDelegate = logDelegate;
        }
コード例 #11
0
        public MainPage()
        {
            this.InitializeComponent();

            var setup = new ScriptRuntimeSetup();

            setup.HostType = typeof(DlrHost);
            setup.AddRubySetup();

            var runtime = Ruby.CreateRuntime(setup);

            this.engine = Ruby.GetEngine(runtime);
            this.scope  = engine.CreateScope();
            this.scope.SetVariable("Main", this);

            runtime.LoadAssembly(typeof(object).GetTypeInfo().Assembly);
            runtime.LoadAssembly(typeof(TextSetOptions).GetTypeInfo().Assembly);
            runtime.LoadAssembly(typeof(TextAlignment).GetTypeInfo().Assembly);

            string outputText = @"
box = main.find_name('OutputBox')
p box.text_alignment
box.text_alignment = Windows::UI::Xaml::TextAlignment.Right
p box.text_alignment
";

            InputBox.IsSpellCheckEnabled  = false;
            OutputBox.IsSpellCheckEnabled = false;
            InputBox.Document.SetText(TextSetOptions.None, outputText);

            // http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx

            IInspectable insp = (IInspectable)InputBox.Document;
            string       winTypeName;

            insp.GetRuntimeClassName(out winTypeName);
            Guid[] iids;
            int    iidCount;

            insp.GetIids(out iidCount, out iids);

            // winTypeName = "Windows.Foundation.Collections.IIterator`1<Windows.Foundation.Collections.IMapView`2<Windows.Foundation.Collections.IVector`1<String>, String>>";

            var  parts = ParseWindowsTypeName(winTypeName);
            Type type  = MakeWindowsType(parts);
            var  guid  = type.GetTypeInfo().GUID;
        }
コード例 #12
0
ファイル: Driver.cs プロジェクト: ife/IronLanguages
        public ScriptEngine CreateRubyEngine(bool privateBinding = false, OptionsAttribute options = null)
        {
            var runtimeSetup  = ScriptRuntimeSetup.ReadConfiguration();
            var languageSetup = runtimeSetup.AddRubySetup();

            runtimeSetup.DebugMode      = IsDebug;
            runtimeSetup.PrivateBinding = privateBinding;
            runtimeSetup.HostType       = typeof(TestHost);
            runtimeSetup.HostArguments  = new object[] { options ?? new OptionsAttribute() };

            languageSetup.Options["ApplicationBase"]       = BaseDirectory;
            languageSetup.Options["NoAdaptiveCompilation"] = NoAdaptiveCompilation;
            languageSetup.Options["CompilationThreshold"]  = CompilationThreshold;
            languageSetup.Options["Verbosity"]             = 2;

            var runtime = Ruby.CreateRuntime(runtimeSetup);

            return(Ruby.GetEngine(runtime));
        }
コード例 #13
0
ファイル: RubyHasher.cs プロジェクト: tanqingliang/httpardon
 static RubyHasher()
 {
     runtime = Ruby.CreateRuntime();
     engine  = Ruby.GetEngine(runtime);
 }