コード例 #1
0
 void SyntaxChecker()
 {
     try
     {
         while (Open)
         {
             string EditorText = "";
             lock (EditorTextStack)
             {
                 if (EditorTextStack.Count > 0)
                 {
                     EditorText = EditorTextStack.Pop();
                     EditorTextStack.Clear();
                 }
             }
             string ErrorMessage = "";
             try
             {
                 string IndentError = "";
                 if (CurrentLanguage.Equals("py"))
                 {
                     IndentError = CheckPythonIndentation(EditorText)[0];
                 }
                 ScriptSource        Source        = Engine.CreateScriptSourceFromString(EditorText);
                 ScriptErrorReporter CompileErrors = new ScriptErrorReporter();
                 Source.Compile(CompileErrors);
                 ErrorMessage = CompileErrors.GetErrors();
                 if (IndentError.Length > 0)
                 {
                     ErrorMessage = string.Format("{0}\r\n{1}", IndentError, ErrorMessage);
                     ShowHideIndentationFixMenu(true);
                 }
                 else
                 {
                     ShowHideIndentationFixMenu(false);
                 }
                 if (ErrorMessage.Length == 0)
                 {
                     ErrorMessage = "0";
                 }
             }
             catch (Exception Exp)
             {
                 ErrorMessage = Exp.Message;
             }
             IronUI.ShowPluginCompilerError(ErrorMessage);
             MRE.Reset();
             MRE.WaitOne();
         }
     }
     catch (ThreadAbortException) { }
     catch (Exception Exp)
     {
         IronException.Report("Error performing Syntax checking", Exp);
     }
 }
コード例 #2
0
        static void LoadPlugin(string PluginFile, ScriptEngine Engine)
        {
            try
            {
                ScriptSource        PluginSource;
                CompiledCode        CompiledPlugin;
                ScriptErrorReporter CompileErrors = new ScriptErrorReporter();
                string ErrorMessage = "";

                fileName = PluginFile.Substring(PluginFile.LastIndexOf('\\') + 1);
                if (StartUp)
                {
                    IronUI.ShowLoadMessage("Loading Plugin - " + fileName);
                }
                if (PluginFile.EndsWith(".py", StringComparison.CurrentCultureIgnoreCase))
                {
                    Engine.Runtime.TryGetEngine("py", out Engine);
                    PluginSource = Engine.CreateScriptSourceFromFile(PluginFile);
                    string IndentError = PluginEditor.CheckPythonIndentation(PluginSource.GetCode())[1];
                    CompiledPlugin = PluginSource.Compile(CompileErrors);
                    ErrorMessage   = CompileErrors.GetErrors();
                    if (IndentError.Length > 0)
                    {
                        ErrorMessage = string.Format("{0}\r\n{1}", IndentError, ErrorMessage);
                    }
                    if (ErrorMessage.Length == 0)
                    {
                        PluginSource.ExecuteProgram();
                    }
                }
                else if (PluginFile.EndsWith(".rb", StringComparison.CurrentCultureIgnoreCase))
                {
                    Engine.Runtime.TryGetEngine("rb", out Engine);
                    PluginSource   = Engine.CreateScriptSourceFromFile(PluginFile);
                    CompiledPlugin = PluginSource.Compile(CompileErrors);
                    ErrorMessage   = CompileErrors.GetErrors();
                    if (ErrorMessage.Length == 0)
                    {
                        PluginSource.ExecuteProgram();
                    }
                }
                if (ErrorMessage.Length > 0)
                {
                    IronException.Report("Syntax error in Plugin - " + PluginFile, ErrorMessage);
                }
            }
            catch (Exception Exp)
            {
                IronException.Report("Error loading plugin - " + PluginFile, Exp.Message, Exp.StackTrace);
            }
            finally
            {
                fileName = "";
            }
        }
コード例 #3
0
ファイル: PluginEditor.cs プロジェクト: melagiri/IronWASP
 void SyntaxChecker()
 {
     try
     {
         while (Open)
         {
             string EditorText = "";
             lock (EditorTextStack)
             {
                 if (EditorTextStack.Count > 0)
                 {
                     EditorText = EditorTextStack.Pop();
                     EditorTextStack.Clear();
                 }
                 else
                 {
                     continue;
                 }
             }
             string ErrorMessage = "";
             try
             {
                 ScriptSource        Source        = Engine.CreateScriptSourceFromString(EditorText);
                 ScriptErrorReporter CompileErrors = new ScriptErrorReporter();
                 Source.Compile(CompileErrors);
                 ErrorMessage = CompileErrors.GetErrors();
                 if (ErrorMessage.Length == 0)
                 {
                     ErrorMessage = "0";
                 }
             }
             catch (Exception Exp)
             {
                 ErrorMessage = Exp.Message;
             }
             IronUI.ShowPluginCompilerError(ErrorMessage);
             MRE.Reset();
             MRE.WaitOne();
         }
     }
     catch (ThreadAbortException) { }
     catch (Exception Exp)
     {
         IronException.Report("Error performing Syntax checking", Exp);
     }
 }
コード例 #4
0
ファイル: PluginEditor.cs プロジェクト: 0ks3ii/IronWASP
        void SyntaxChecker()
        {
            try
            {
                while (Open)
                {
                    string EditorText = "";
                    lock (EditorTextStack)
                    {
                        if (EditorTextStack.Count > 0)
                        {

                            EditorText = EditorTextStack.Pop();
                            EditorTextStack.Clear();
                        }
                    }
                    string ErrorMessage = "";
                    try
                    {
                        string IndentError = "";
                        if (CurrentLanguage.Equals("py"))
                        {
                            IndentError = CheckPythonIndentation(EditorText)[0];
                        }
                        ScriptSource Source = Engine.CreateScriptSourceFromString(EditorText);
                        ScriptErrorReporter CompileErrors = new ScriptErrorReporter();
                        Source.Compile(CompileErrors);
                        ErrorMessage = CompileErrors.GetErrors();
                        if (IndentError.Length > 0)
                        {
                            ErrorMessage = string.Format("{0}\r\n{1}", IndentError, ErrorMessage);
                            ShowHideIndentationFixMenu(true);
                        }
                        else
                        {
                            ShowHideIndentationFixMenu(false);
                        }
                        if (ErrorMessage.Length == 0) { ErrorMessage = "0"; }
                    }
                    catch (Exception Exp)
                    {
                        ErrorMessage = Exp.Message;
                    }
                    IronUI.ShowPluginCompilerError(ErrorMessage);
                    MRE.Reset();
                    MRE.WaitOne();
                }
            }
            catch (ThreadAbortException) { }
            catch (Exception Exp)
            {
                IronException.Report("Error performing Syntax checking", Exp);
            }
        }
コード例 #5
0
ファイル: Module.cs プロジェクト: 0ks3ii/IronWASP
        internal static Module LoadModule(Module M)
        {
            try
            {
                string FullName = string.Format("{0}\\modules\\{1}\\{2}", Config.RootDir, M.Name, M.FileName);
                if (M.FileName.EndsWith(".dll"))
                {
                    Assembly MA = System.Reflection.Assembly.LoadFile(FullName);
                    Module NewModule = (Module) Activator.CreateInstance(MA.GetTypes()[0]);
                    Module.Add(NewModule.GetInstance());
                }
                else
                {
                    Engine = PluginEngine.GetScriptEngine();

                    if (M.FileName.EndsWith(".py"))
                        Engine.Runtime.TryGetEngine("py", out Engine);
                    else
                        Engine.Runtime.TryGetEngine("rb", out Engine);
                    List<string> ModulePaths = new List<string>();
                    foreach (Module ModuleFromXml in ModuleListFromXml)
                    {
                        ModulePaths.Add(string.Format("{0}\\modules\\{1}\\", Config.RootDir, ModuleFromXml.Name));
                    }
                    Engine.SetSearchPaths(ModulePaths);
                    if (M.FileName.Length == 0)
                        throw new Exception("Module is missing script files");
                    ScriptSource ModuleSource = Engine.CreateScriptSourceFromFile(FullName);
                    ScriptErrorReporter CompileErrors = new ScriptErrorReporter();
                    string ErrorMessage = "";
                    CompiledCode CompiledModule = ModuleSource.Compile(CompileErrors);
                    ErrorMessage = CompileErrors.GetErrors();
                    if (M.FileName.EndsWith(".py"))
                    {
                        string IndentError = PluginEditor.CheckPythonIndentation(ModuleSource.GetCode())[1];
                        if (IndentError.Length > 0)
                        {
                            ErrorMessage = string.Format("{0}\r\n{1}", IndentError, ErrorMessage);
                        }
                    }
                    if (ErrorMessage.Length == 0)
                    {
                        ModuleSource.ExecuteProgram();
                    }
                    else
                    {
                        throw new Exception(string.Format("Syntax error in module file:{0}\r\n{1}", M.FileName, ErrorMessage));
                    }
                }
            }
            catch(Exception Exp)
            {
                 ModuleStartPromptForm PF = GetPromptWindow(M);
                 if (PF != null) PF.ShowError("Error Loading Module.");
                 IronException.Report(string.Format("Error Loading Module - {0}", M.Name), Exp);
                 return null;
            }
            IronUI.BuildPluginTree();
            ModuleStartPromptForm UsedPF = RemovePromptWindowFromList(M);
            if (UsedPF != null)
            {
                try
                {
                    if (!UsedPF.IsClosed)
                        UsedPF.CloseForm();
                }
                catch { }
            }
            return Get(M.Name);
        }
コード例 #6
0
ファイル: Module.cs プロジェクト: war-and-code/IronWASP
        internal static Module LoadModule(Module M)
        {
            try
            {
                string FullName = string.Format("{0}\\modules\\{1}\\{2}", Config.RootDir, M.Name, M.FileName);
                if (M.FileName.EndsWith(".dll"))
                {
                    Assembly MA        = System.Reflection.Assembly.LoadFile(FullName);
                    Module   NewModule = (Module)Activator.CreateInstance(MA.GetTypes()[0]);
                    Module.Add(NewModule.GetInstance());
                }
                else
                {
                    Engine = PluginEngine.GetScriptEngine();

                    if (M.FileName.EndsWith(".py"))
                    {
                        Engine.Runtime.TryGetEngine("py", out Engine);
                    }
                    else
                    {
                        Engine.Runtime.TryGetEngine("rb", out Engine);
                    }
                    List <string> ModulePaths = new List <string>();
                    foreach (Module ModuleFromXml in ModuleListFromXml)
                    {
                        ModulePaths.Add(string.Format("{0}\\modules\\{1}\\", Config.RootDir, ModuleFromXml.Name));
                    }
                    Engine.SetSearchPaths(ModulePaths);
                    if (M.FileName.Length == 0)
                    {
                        throw new Exception("Module is missing script files");
                    }
                    ScriptSource        ModuleSource  = Engine.CreateScriptSourceFromFile(FullName);
                    ScriptErrorReporter CompileErrors = new ScriptErrorReporter();
                    string       ErrorMessage         = "";
                    CompiledCode CompiledModule       = ModuleSource.Compile(CompileErrors);
                    ErrorMessage = CompileErrors.GetErrors();
                    if (M.FileName.EndsWith(".py"))
                    {
                        string IndentError = PluginEditor.CheckPythonIndentation(ModuleSource.GetCode())[1];
                        if (IndentError.Length > 0)
                        {
                            ErrorMessage = string.Format("{0}\r\n{1}", IndentError, ErrorMessage);
                        }
                    }
                    if (ErrorMessage.Length == 0)
                    {
                        ModuleSource.ExecuteProgram();
                    }
                    else
                    {
                        throw new Exception(string.Format("Syntax error in module file:{0}\r\n{1}", M.FileName, ErrorMessage));
                    }
                }
            }
            catch (Exception Exp)
            {
                ModuleStartPromptForm PF = GetPromptWindow(M);
                if (PF != null)
                {
                    PF.ShowError("Error Loading Module.");
                }
                IronException.Report(string.Format("Error Loading Module - {0}", M.Name), Exp);
                return(null);
            }
            IronUI.BuildPluginTree();
            ModuleStartPromptForm UsedPF = RemovePromptWindowFromList(M);

            if (UsedPF != null)
            {
                try
                {
                    if (!UsedPF.IsClosed)
                    {
                        UsedPF.CloseForm();
                    }
                }
                catch { }
            }
            return(Get(M.Name));
        }
コード例 #7
0
ファイル: PluginEngine.cs プロジェクト: 0ks3ii/IronWASP
        static void LoadPlugin(string PluginFile, ScriptEngine Engine)
        {
            try
            {
                ScriptSource PluginSource;
                CompiledCode CompiledPlugin;
                ScriptErrorReporter CompileErrors = new ScriptErrorReporter();
                string ErrorMessage = "";

                fileName = PluginFile.Substring(PluginFile.LastIndexOf('\\') + 1);
                if(StartUp) IronUI.LF.ShowLoadMessage("Loading Plugin - " + fileName);
                if (PluginFile.EndsWith(".py", StringComparison.CurrentCultureIgnoreCase))
                {
                    Engine.Runtime.TryGetEngine("py", out Engine);
                    PluginSource = Engine.CreateScriptSourceFromFile(PluginFile);
                    string IndentError = PluginEditor.CheckPythonIndentation(PluginSource.GetCode())[1];
                    if (IndentError.Length > 0)
                    {
                        string UpdatedCode =  PluginEditor.FixPythonIndentation(PluginSource.GetCode());
                        PluginSource = Engine.CreateScriptSourceFromString(UpdatedCode);
                        //ErrorMessage = string.Format("{0}\r\n{1}", IndentError, ErrorMessage);
                    }
                    CompiledPlugin = PluginSource.Compile(CompileErrors);
                    ErrorMessage = CompileErrors.GetErrors();
                    if (ErrorMessage.Length > 0 && IndentError.Length > 0)
                    {
                        ErrorMessage = string.Format("{0}\r\n{1}", IndentError, ErrorMessage);
                    }
                    if (ErrorMessage.Length == 0)
                    {
                        PluginSource.ExecuteProgram();
                    }
                }
                else if (PluginFile.EndsWith(".rb", StringComparison.CurrentCultureIgnoreCase))
                {
                    Engine.Runtime.TryGetEngine("rb", out Engine);
                    PluginSource = Engine.CreateScriptSourceFromFile(PluginFile);
                    CompiledPlugin = PluginSource.Compile(CompileErrors);
                    ErrorMessage = CompileErrors.GetErrors();
                    if (ErrorMessage.Length == 0)
                    {
                        PluginSource.ExecuteProgram();
                    }
                }
                if (ErrorMessage.Length > 0)
                {
                    IronException.Report("Syntax error in Plugin - " + PluginFile, ErrorMessage);
                }
            }
            catch (Exception Exp)
            {
                IronException.Report("Error loading plugin - " + PluginFile, Exp.Message, Exp.StackTrace);
            }
            finally
            {
                fileName = "";
            }
        }
コード例 #8
0
ファイル: PluginEditor.cs プロジェクト: welias/IronWASP
        void SyntaxChecker()
        {
            try
            {
                while (Open)
                {
                    string EditorText = "";
                    lock (EditorTextStack)
                    {
                        if (EditorTextStack.Count > 0)
                        {

                            EditorText = EditorTextStack.Pop();
                            EditorTextStack.Clear();
                        }
                        else
                        {
                            continue;
                        }
                    }
                    string ErrorMessage = "";
                    try
                    {
                        ScriptSource Source = Engine.CreateScriptSourceFromString(EditorText);
                        ScriptErrorReporter CompileErrors = new ScriptErrorReporter();
                        Source.Compile(CompileErrors);
                        ErrorMessage = CompileErrors.GetErrors();
                        if (ErrorMessage.Length == 0) { ErrorMessage = "0"; }
                    }
                    catch (Exception Exp)
                    {
                        ErrorMessage = Exp.Message;
                    }
                    IronUI.ShowPluginCompilerError(ErrorMessage);
                    MRE.Reset();
                    MRE.WaitOne();
                }
            }
            catch (ThreadAbortException) { }
            catch (Exception Exp)
            {
                IronException.Report("Error performing Syntax checking", Exp);
            }
        }