diff options
-rw-r--r-- | OpenSim/Framework/Data.MSSQLMapper/MSSQLDatabaseMapper.cs | 102 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Interfaces/ICommand.cs | 32 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Interfaces/ICommandableModule.cs | 32 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Interfaces/ICommander.cs | 28 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/CommanderTestModule.cs | 184 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs | 542 | ||||
-rw-r--r--[-rwxr-xr-x] | bin/libode-debug.so | bin | 2992241 -> 2992241 bytes | |||
-rw-r--r--[-rwxr-xr-x] | bin/ode-debug.dll | bin | 630784 -> 630784 bytes |
8 files changed, 460 insertions, 460 deletions
diff --git a/OpenSim/Framework/Data.MSSQLMapper/MSSQLDatabaseMapper.cs b/OpenSim/Framework/Data.MSSQLMapper/MSSQLDatabaseMapper.cs index 725322d..c56b5a6 100644 --- a/OpenSim/Framework/Data.MSSQLMapper/MSSQLDatabaseMapper.cs +++ b/OpenSim/Framework/Data.MSSQLMapper/MSSQLDatabaseMapper.cs | |||
@@ -1,52 +1,52 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Data.Common; | 28 | using System.Data.Common; |
29 | using System.Data.SqlClient; | 29 | using System.Data.SqlClient; |
30 | using OpenSim.Framework.Data; | 30 | using OpenSim.Framework.Data; |
31 | 31 | ||
32 | namespace OpenSim.Framework.Data.MSSQLMapper | 32 | namespace OpenSim.Framework.Data.MSSQLMapper |
33 | { | 33 | { |
34 | public class MSSQLDatabaseMapper : OpenSimDatabaseConnector | 34 | public class MSSQLDatabaseMapper : OpenSimDatabaseConnector |
35 | { | 35 | { |
36 | public MSSQLDatabaseMapper(string connectionString) | 36 | public MSSQLDatabaseMapper(string connectionString) |
37 | : base(connectionString) | 37 | : base(connectionString) |
38 | { | 38 | { |
39 | } | 39 | } |
40 | 40 | ||
41 | public override DbConnection GetNewConnection() | 41 | public override DbConnection GetNewConnection() |
42 | { | 42 | { |
43 | SqlConnection connection = new SqlConnection(m_connectionString); | 43 | SqlConnection connection = new SqlConnection(m_connectionString); |
44 | return connection; | 44 | return connection; |
45 | } | 45 | } |
46 | 46 | ||
47 | public override string CreateParamName(string fieldName) | 47 | public override string CreateParamName(string fieldName) |
48 | { | 48 | { |
49 | return "@" + fieldName; | 49 | return "@" + fieldName; |
50 | } | 50 | } |
51 | } | 51 | } |
52 | } \ No newline at end of file | 52 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Interfaces/ICommand.cs b/OpenSim/Region/Environment/Interfaces/ICommand.cs index bccd8d3..396136b 100644 --- a/OpenSim/Region/Environment/Interfaces/ICommand.cs +++ b/OpenSim/Region/Environment/Interfaces/ICommand.cs | |||
@@ -1,16 +1,16 @@ | |||
1 | using System; | 1 | using System; |
2 | 2 | ||
3 | using OpenSim.Region.Environment.Modules.ModuleFramework; | 3 | using OpenSim.Region.Environment.Modules.ModuleFramework; |
4 | 4 | ||
5 | namespace OpenSim.Region.Environment.Interfaces | 5 | namespace OpenSim.Region.Environment.Interfaces |
6 | { | 6 | { |
7 | public interface ICommand | 7 | public interface ICommand |
8 | { | 8 | { |
9 | void AddArgument(string name, string helptext, string type); | 9 | void AddArgument(string name, string helptext, string type); |
10 | System.Collections.Generic.Dictionary<string, string> Arguments { get; } | 10 | System.Collections.Generic.Dictionary<string, string> Arguments { get; } |
11 | string Help { get; } | 11 | string Help { get; } |
12 | string Name { get; } | 12 | string Name { get; } |
13 | void Run(object[] args); | 13 | void Run(object[] args); |
14 | void ShowConsoleHelp(); | 14 | void ShowConsoleHelp(); |
15 | } | 15 | } |
16 | } | 16 | } |
diff --git a/OpenSim/Region/Environment/Interfaces/ICommandableModule.cs b/OpenSim/Region/Environment/Interfaces/ICommandableModule.cs index 31ef49b..e1f7ed6 100644 --- a/OpenSim/Region/Environment/Interfaces/ICommandableModule.cs +++ b/OpenSim/Region/Environment/Interfaces/ICommandableModule.cs | |||
@@ -1,16 +1,16 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | using OpenSim.Region.Environment.Modules.ModuleFramework; | 5 | using OpenSim.Region.Environment.Modules.ModuleFramework; |
6 | 6 | ||
7 | namespace OpenSim.Region.Environment.Interfaces | 7 | namespace OpenSim.Region.Environment.Interfaces |
8 | { | 8 | { |
9 | public interface ICommandableModule | 9 | public interface ICommandableModule |
10 | { | 10 | { |
11 | ICommander CommandInterface | 11 | ICommander CommandInterface |
12 | { | 12 | { |
13 | get; | 13 | get; |
14 | } | 14 | } |
15 | } | 15 | } |
16 | } | 16 | } |
diff --git a/OpenSim/Region/Environment/Interfaces/ICommander.cs b/OpenSim/Region/Environment/Interfaces/ICommander.cs index 93a9956..316a813 100644 --- a/OpenSim/Region/Environment/Interfaces/ICommander.cs +++ b/OpenSim/Region/Environment/Interfaces/ICommander.cs | |||
@@ -1,14 +1,14 @@ | |||
1 | using System; | 1 | using System; |
2 | 2 | ||
3 | using OpenSim.Region.Environment.Modules.ModuleFramework; | 3 | using OpenSim.Region.Environment.Modules.ModuleFramework; |
4 | 4 | ||
5 | namespace OpenSim.Region.Environment.Interfaces | 5 | namespace OpenSim.Region.Environment.Interfaces |
6 | { | 6 | { |
7 | public interface ICommander | 7 | public interface ICommander |
8 | { | 8 | { |
9 | void ProcessConsoleCommand(string function, string[] args); | 9 | void ProcessConsoleCommand(string function, string[] args); |
10 | void RegisterCommand(string commandName, ICommand command); | 10 | void RegisterCommand(string commandName, ICommand command); |
11 | void Run(string function, object[] args); | 11 | void Run(string function, object[] args); |
12 | string GenerateRuntimeAPI(); | 12 | string GenerateRuntimeAPI(); |
13 | } | 13 | } |
14 | } | 14 | } |
diff --git a/OpenSim/Region/Environment/Modules/CommanderTestModule.cs b/OpenSim/Region/Environment/Modules/CommanderTestModule.cs index 555944c..0133f27 100644 --- a/OpenSim/Region/Environment/Modules/CommanderTestModule.cs +++ b/OpenSim/Region/Environment/Modules/CommanderTestModule.cs | |||
@@ -1,92 +1,92 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using libsecondlife; | 30 | using libsecondlife; |
31 | using Nini.Config; | 31 | using Nini.Config; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Region.Environment.Interfaces; | 33 | using OpenSim.Region.Environment.Interfaces; |
34 | using OpenSim.Region.Environment.Scenes; | 34 | using OpenSim.Region.Environment.Scenes; |
35 | using OpenSim.Region.Environment.Modules.ModuleFramework; | 35 | using OpenSim.Region.Environment.Modules.ModuleFramework; |
36 | 36 | ||
37 | namespace OpenSim.Region.Environment.Modules | 37 | namespace OpenSim.Region.Environment.Modules |
38 | { | 38 | { |
39 | public class CommanderTestModule : IRegionModule, ICommandableModule | 39 | public class CommanderTestModule : IRegionModule, ICommandableModule |
40 | { | 40 | { |
41 | Commander m_commander = new Commander("CommanderTest"); | 41 | Commander m_commander = new Commander("CommanderTest"); |
42 | Scene m_scene; | 42 | Scene m_scene; |
43 | 43 | ||
44 | #region IRegionModule Members | 44 | #region IRegionModule Members |
45 | 45 | ||
46 | public void Initialise(Scene scene, IConfigSource source) | 46 | public void Initialise(Scene scene, IConfigSource source) |
47 | { | 47 | { |
48 | m_scene = scene; | 48 | m_scene = scene; |
49 | } | 49 | } |
50 | 50 | ||
51 | private void InterfaceHelloWorld(Object[] args) | 51 | private void InterfaceHelloWorld(Object[] args) |
52 | { | 52 | { |
53 | Console.WriteLine("Hello World"); | 53 | Console.WriteLine("Hello World"); |
54 | } | 54 | } |
55 | 55 | ||
56 | public void PostInitialise() | 56 | public void PostInitialise() |
57 | { | 57 | { |
58 | Command testCommand = new Command("hello", InterfaceHelloWorld, "Says a simple debugging test string"); | 58 | Command testCommand = new Command("hello", InterfaceHelloWorld, "Says a simple debugging test string"); |
59 | testCommand.AddArgument("world", "Write world here", "string"); | 59 | testCommand.AddArgument("world", "Write world here", "string"); |
60 | 60 | ||
61 | m_commander.RegisterCommand("hello", testCommand); | 61 | m_commander.RegisterCommand("hello", testCommand); |
62 | 62 | ||
63 | // Register me | 63 | // Register me |
64 | m_scene.RegisterModuleCommander("commandertest", m_commander); | 64 | m_scene.RegisterModuleCommander("commandertest", m_commander); |
65 | } | 65 | } |
66 | 66 | ||
67 | public void Close() | 67 | public void Close() |
68 | { | 68 | { |
69 | } | 69 | } |
70 | 70 | ||
71 | public string Name | 71 | public string Name |
72 | { | 72 | { |
73 | get { return "CommanderTestModule"; } | 73 | get { return "CommanderTestModule"; } |
74 | } | 74 | } |
75 | 75 | ||
76 | public bool IsSharedModule | 76 | public bool IsSharedModule |
77 | { | 77 | { |
78 | get { return false; } | 78 | get { return false; } |
79 | } | 79 | } |
80 | 80 | ||
81 | #endregion | 81 | #endregion |
82 | 82 | ||
83 | #region ICommandableModule Members | 83 | #region ICommandableModule Members |
84 | 84 | ||
85 | public ICommander CommandInterface | 85 | public ICommander CommandInterface |
86 | { | 86 | { |
87 | get { throw new NotImplementedException(); } | 87 | get { throw new NotImplementedException(); } |
88 | } | 88 | } |
89 | 89 | ||
90 | #endregion | 90 | #endregion |
91 | } | 91 | } |
92 | } | 92 | } |
diff --git a/OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs b/OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs index a17348e..946a876 100644 --- a/OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs +++ b/OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs | |||
@@ -1,271 +1,271 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | using OpenSim.Region.Environment.Interfaces; | 5 | using OpenSim.Region.Environment.Interfaces; |
6 | 6 | ||
7 | namespace OpenSim.Region.Environment.Modules.ModuleFramework | 7 | namespace OpenSim.Region.Environment.Modules.ModuleFramework |
8 | { | 8 | { |
9 | /// <summary> | 9 | /// <summary> |
10 | /// A single function call encapsulated in a class which enforces arguments when passing around as Object[]'s. | 10 | /// A single function call encapsulated in a class which enforces arguments when passing around as Object[]'s. |
11 | /// Used for console commands and script API generation | 11 | /// Used for console commands and script API generation |
12 | /// </summary> | 12 | /// </summary> |
13 | public class Command : ICommand | 13 | public class Command : ICommand |
14 | { | 14 | { |
15 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 15 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
16 | 16 | ||
17 | private Action<Object[]> m_command; | 17 | private Action<Object[]> m_command; |
18 | private string m_name; | 18 | private string m_name; |
19 | private string m_help; | 19 | private string m_help; |
20 | private List<CommandArgument> m_args = new List<CommandArgument>(); | 20 | private List<CommandArgument> m_args = new List<CommandArgument>(); |
21 | 21 | ||
22 | public Command(string name, Action<Object[]> command, string help) | 22 | public Command(string name, Action<Object[]> command, string help) |
23 | { | 23 | { |
24 | m_name = name; | 24 | m_name = name; |
25 | m_command = command; | 25 | m_command = command; |
26 | m_help = help; | 26 | m_help = help; |
27 | } | 27 | } |
28 | 28 | ||
29 | public void AddArgument(string name, string helptext, string type) | 29 | public void AddArgument(string name, string helptext, string type) |
30 | { | 30 | { |
31 | m_args.Add(new CommandArgument(name, helptext, type)); | 31 | m_args.Add(new CommandArgument(name, helptext, type)); |
32 | } | 32 | } |
33 | 33 | ||
34 | public string Name | 34 | public string Name |
35 | { | 35 | { |
36 | get { return m_name; } | 36 | get { return m_name; } |
37 | } | 37 | } |
38 | 38 | ||
39 | public string Help | 39 | public string Help |
40 | { | 40 | { |
41 | get { return m_help; } | 41 | get { return m_help; } |
42 | } | 42 | } |
43 | 43 | ||
44 | public Dictionary<string, string> Arguments | 44 | public Dictionary<string, string> Arguments |
45 | { | 45 | { |
46 | get | 46 | get |
47 | { | 47 | { |
48 | Dictionary<string, string> tmp = new Dictionary<string, string>(); | 48 | Dictionary<string, string> tmp = new Dictionary<string, string>(); |
49 | foreach (CommandArgument arg in m_args) | 49 | foreach (CommandArgument arg in m_args) |
50 | { | 50 | { |
51 | tmp.Add(arg.Name, arg.ArgumentType); | 51 | tmp.Add(arg.Name, arg.ArgumentType); |
52 | } | 52 | } |
53 | return tmp; | 53 | return tmp; |
54 | } | 54 | } |
55 | } | 55 | } |
56 | 56 | ||
57 | public void ShowConsoleHelp() | 57 | public void ShowConsoleHelp() |
58 | { | 58 | { |
59 | m_log.Info("== " + Name + " =="); | 59 | m_log.Info("== " + Name + " =="); |
60 | m_log.Info(m_help); | 60 | m_log.Info(m_help); |
61 | m_log.Info("= Parameters ="); | 61 | m_log.Info("= Parameters ="); |
62 | foreach (CommandArgument arg in m_args) | 62 | foreach (CommandArgument arg in m_args) |
63 | { | 63 | { |
64 | m_log.Info("* " + arg.Name + " (" + arg.ArgumentType + ")"); | 64 | m_log.Info("* " + arg.Name + " (" + arg.ArgumentType + ")"); |
65 | m_log.Info("\t" + arg.HelpText); | 65 | m_log.Info("\t" + arg.HelpText); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | public void Run(Object[] args) | 69 | public void Run(Object[] args) |
70 | { | 70 | { |
71 | Object[] cleanArgs = new Object[m_args.Count]; | 71 | Object[] cleanArgs = new Object[m_args.Count]; |
72 | 72 | ||
73 | if (args.Length < cleanArgs.Length) | 73 | if (args.Length < cleanArgs.Length) |
74 | { | 74 | { |
75 | m_log.Error("Missing " + (cleanArgs.Length - args.Length) + " argument(s)"); | 75 | m_log.Error("Missing " + (cleanArgs.Length - args.Length) + " argument(s)"); |
76 | ShowConsoleHelp(); | 76 | ShowConsoleHelp(); |
77 | return; | 77 | return; |
78 | } | 78 | } |
79 | if (args.Length > cleanArgs.Length) | 79 | if (args.Length > cleanArgs.Length) |
80 | { | 80 | { |
81 | m_log.Error("Too many arguments for this command. Type '<module> <command> help' for help."); | 81 | m_log.Error("Too many arguments for this command. Type '<module> <command> help' for help."); |
82 | return; | 82 | return; |
83 | } | 83 | } |
84 | 84 | ||
85 | int i = 0; | 85 | int i = 0; |
86 | foreach (Object arg in args) | 86 | foreach (Object arg in args) |
87 | { | 87 | { |
88 | if (string.IsNullOrEmpty(arg.ToString())) | 88 | if (string.IsNullOrEmpty(arg.ToString())) |
89 | { | 89 | { |
90 | m_log.Error("Empty arguments are not allowed"); | 90 | m_log.Error("Empty arguments are not allowed"); |
91 | return; | 91 | return; |
92 | } | 92 | } |
93 | try | 93 | try |
94 | { | 94 | { |
95 | switch (m_args[i].ArgumentType) | 95 | switch (m_args[i].ArgumentType) |
96 | { | 96 | { |
97 | case "String": | 97 | case "String": |
98 | m_args[i].ArgumentValue = arg.ToString(); | 98 | m_args[i].ArgumentValue = arg.ToString(); |
99 | break; | 99 | break; |
100 | case "Integer": | 100 | case "Integer": |
101 | m_args[i].ArgumentValue = Int32.Parse(arg.ToString()); | 101 | m_args[i].ArgumentValue = Int32.Parse(arg.ToString()); |
102 | break; | 102 | break; |
103 | case "Double": | 103 | case "Double": |
104 | m_args[i].ArgumentValue = Double.Parse(arg.ToString()); | 104 | m_args[i].ArgumentValue = Double.Parse(arg.ToString()); |
105 | break; | 105 | break; |
106 | case "Boolean": | 106 | case "Boolean": |
107 | m_args[i].ArgumentValue = Boolean.Parse(arg.ToString()); | 107 | m_args[i].ArgumentValue = Boolean.Parse(arg.ToString()); |
108 | break; | 108 | break; |
109 | default: | 109 | default: |
110 | m_log.Error("Unknown desired type for argument " + m_args[i].Name + " on command " + m_name); | 110 | m_log.Error("Unknown desired type for argument " + m_args[i].Name + " on command " + m_name); |
111 | break; | 111 | break; |
112 | } | 112 | } |
113 | } | 113 | } |
114 | catch (FormatException) | 114 | catch (FormatException) |
115 | { | 115 | { |
116 | m_log.Error("Argument number " + (i + 1) + | 116 | m_log.Error("Argument number " + (i + 1) + |
117 | " (" + m_args[i].Name + ") must be a valid " + | 117 | " (" + m_args[i].Name + ") must be a valid " + |
118 | m_args[i].ArgumentType.ToLower() + "."); | 118 | m_args[i].ArgumentType.ToLower() + "."); |
119 | } | 119 | } |
120 | cleanArgs[i] = m_args[i].ArgumentValue; | 120 | cleanArgs[i] = m_args[i].ArgumentValue; |
121 | 121 | ||
122 | i++; | 122 | i++; |
123 | } | 123 | } |
124 | 124 | ||
125 | m_command.Invoke(cleanArgs); | 125 | m_command.Invoke(cleanArgs); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | /// <summary> | 129 | /// <summary> |
130 | /// A single command argument, contains name, type and at runtime, value. | 130 | /// A single command argument, contains name, type and at runtime, value. |
131 | /// </summary> | 131 | /// </summary> |
132 | public class CommandArgument | 132 | public class CommandArgument |
133 | { | 133 | { |
134 | private string m_name; | 134 | private string m_name; |
135 | private string m_help; | 135 | private string m_help; |
136 | private string m_type; | 136 | private string m_type; |
137 | private Object m_val; | 137 | private Object m_val; |
138 | 138 | ||
139 | public CommandArgument(string name, string help, string type) | 139 | public CommandArgument(string name, string help, string type) |
140 | { | 140 | { |
141 | m_name = name; | 141 | m_name = name; |
142 | m_help = help; | 142 | m_help = help; |
143 | m_type = type; | 143 | m_type = type; |
144 | } | 144 | } |
145 | 145 | ||
146 | public string Name | 146 | public string Name |
147 | { | 147 | { |
148 | get { return m_name; } | 148 | get { return m_name; } |
149 | } | 149 | } |
150 | 150 | ||
151 | public string HelpText | 151 | public string HelpText |
152 | { | 152 | { |
153 | get { return m_help; } | 153 | get { return m_help; } |
154 | } | 154 | } |
155 | 155 | ||
156 | public string ArgumentType | 156 | public string ArgumentType |
157 | { | 157 | { |
158 | get { return m_type; } | 158 | get { return m_type; } |
159 | } | 159 | } |
160 | 160 | ||
161 | public Object ArgumentValue | 161 | public Object ArgumentValue |
162 | { | 162 | { |
163 | get { return m_val; } | 163 | get { return m_val; } |
164 | set { m_val = value; } | 164 | set { m_val = value; } |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | /// <summary> | 168 | /// <summary> |
169 | /// A class to enable modules to register console and script commands, which enforces typing and valid input. | 169 | /// A class to enable modules to register console and script commands, which enforces typing and valid input. |
170 | /// </summary> | 170 | /// </summary> |
171 | public class Commander : ICommander | 171 | public class Commander : ICommander |
172 | { | 172 | { |
173 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 173 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
174 | private Dictionary<string, ICommand> m_commands = new Dictionary<string, ICommand>(); | 174 | private Dictionary<string, ICommand> m_commands = new Dictionary<string, ICommand>(); |
175 | private string m_name; | 175 | private string m_name; |
176 | 176 | ||
177 | public Commander(string name) | 177 | public Commander(string name) |
178 | { | 178 | { |
179 | m_name = name; | 179 | m_name = name; |
180 | } | 180 | } |
181 | 181 | ||
182 | public void RegisterCommand(string commandName, ICommand command) | 182 | public void RegisterCommand(string commandName, ICommand command) |
183 | { | 183 | { |
184 | m_commands[commandName] = command; | 184 | m_commands[commandName] = command; |
185 | } | 185 | } |
186 | 186 | ||
187 | void ShowConsoleHelp() | 187 | void ShowConsoleHelp() |
188 | { | 188 | { |
189 | m_log.Info("===" + m_name + "==="); | 189 | m_log.Info("===" + m_name + "==="); |
190 | foreach (ICommand com in m_commands.Values) | 190 | foreach (ICommand com in m_commands.Values) |
191 | { | 191 | { |
192 | m_log.Info("* " + com.Name + " - " + com.Help); | 192 | m_log.Info("* " + com.Name + " - " + com.Help); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | string EscapeRuntimeAPICommand(string command) | 196 | string EscapeRuntimeAPICommand(string command) |
197 | { | 197 | { |
198 | command = command.Replace('-', '_'); | 198 | command = command.Replace('-', '_'); |
199 | StringBuilder tmp = new StringBuilder(command); | 199 | StringBuilder tmp = new StringBuilder(command); |
200 | tmp[0] = tmp[0].ToString().ToUpper().ToCharArray()[0]; | 200 | tmp[0] = tmp[0].ToString().ToUpper().ToCharArray()[0]; |
201 | 201 | ||
202 | return tmp.ToString(); | 202 | return tmp.ToString(); |
203 | } | 203 | } |
204 | 204 | ||
205 | /// <summary> | 205 | /// <summary> |
206 | /// Generates a runtime C# class which can be compiled and inserted via reflection to enable modules to register new script commands | 206 | /// Generates a runtime C# class which can be compiled and inserted via reflection to enable modules to register new script commands |
207 | /// </summary> | 207 | /// </summary> |
208 | /// <returns>Returns C# source code to create a binding</returns> | 208 | /// <returns>Returns C# source code to create a binding</returns> |
209 | public string GenerateRuntimeAPI() | 209 | public string GenerateRuntimeAPI() |
210 | { | 210 | { |
211 | string classSrc = "\n\tpublic class " + m_name + " {\n"; | 211 | string classSrc = "\n\tpublic class " + m_name + " {\n"; |
212 | foreach (ICommand com in m_commands.Values) | 212 | foreach (ICommand com in m_commands.Values) |
213 | { | 213 | { |
214 | classSrc += "\tpublic void " + EscapeRuntimeAPICommand(com.Name) + "( "; | 214 | classSrc += "\tpublic void " + EscapeRuntimeAPICommand(com.Name) + "( "; |
215 | foreach (KeyValuePair<string, string> arg in com.Arguments) | 215 | foreach (KeyValuePair<string, string> arg in com.Arguments) |
216 | { | 216 | { |
217 | classSrc += arg.Value + " " + Framework.Util.Md5Hash(arg.Key) + ","; | 217 | classSrc += arg.Value + " " + Framework.Util.Md5Hash(arg.Key) + ","; |
218 | } | 218 | } |
219 | classSrc = classSrc.Remove(classSrc.Length - 1); // Delete the last comma | 219 | classSrc = classSrc.Remove(classSrc.Length - 1); // Delete the last comma |
220 | classSrc += " )\n\t{\n"; | 220 | classSrc += " )\n\t{\n"; |
221 | classSrc += "\t\tObject[] args = new Object[" + com.Arguments.Count.ToString() + "];\n"; | 221 | classSrc += "\t\tObject[] args = new Object[" + com.Arguments.Count.ToString() + "];\n"; |
222 | int i = 0; | 222 | int i = 0; |
223 | foreach (KeyValuePair<string, string> arg in com.Arguments) | 223 | foreach (KeyValuePair<string, string> arg in com.Arguments) |
224 | { | 224 | { |
225 | classSrc += "\t\targs[" + i.ToString() + "] = " + Framework.Util.Md5Hash(arg.Key) + " " + ";\n"; | 225 | classSrc += "\t\targs[" + i.ToString() + "] = " + Framework.Util.Md5Hash(arg.Key) + " " + ";\n"; |
226 | i++; | 226 | i++; |
227 | } | 227 | } |
228 | classSrc += "\t\tGetCommander(\"" + m_name + "\").Run(\"" + com.Name + "\", args);\n"; | 228 | classSrc += "\t\tGetCommander(\"" + m_name + "\").Run(\"" + com.Name + "\", args);\n"; |
229 | classSrc += "\t}\n"; | 229 | classSrc += "\t}\n"; |
230 | } | 230 | } |
231 | classSrc += "}\n"; | 231 | classSrc += "}\n"; |
232 | 232 | ||
233 | return classSrc; | 233 | return classSrc; |
234 | } | 234 | } |
235 | 235 | ||
236 | /// <summary> | 236 | /// <summary> |
237 | /// Runs a specified function with attached arguments | 237 | /// Runs a specified function with attached arguments |
238 | /// *** <b>DO NOT CALL DIRECTLY.</b> *** | 238 | /// *** <b>DO NOT CALL DIRECTLY.</b> *** |
239 | /// Call ProcessConsoleCommand instead if handling human input. | 239 | /// Call ProcessConsoleCommand instead if handling human input. |
240 | /// </summary> | 240 | /// </summary> |
241 | /// <param name="function">The function name to call</param> | 241 | /// <param name="function">The function name to call</param> |
242 | /// <param name="args">The function parameters</param> | 242 | /// <param name="args">The function parameters</param> |
243 | public void Run(string function, object[] args) | 243 | public void Run(string function, object[] args) |
244 | { | 244 | { |
245 | m_commands[function].Run(args); | 245 | m_commands[function].Run(args); |
246 | } | 246 | } |
247 | 247 | ||
248 | public void ProcessConsoleCommand(string function, string[] args) | 248 | public void ProcessConsoleCommand(string function, string[] args) |
249 | { | 249 | { |
250 | if (m_commands.ContainsKey(function)) | 250 | if (m_commands.ContainsKey(function)) |
251 | { | 251 | { |
252 | if (args[0] == "help") | 252 | if (args[0] == "help") |
253 | { | 253 | { |
254 | m_commands[function].ShowConsoleHelp(); | 254 | m_commands[function].ShowConsoleHelp(); |
255 | } | 255 | } |
256 | else | 256 | else |
257 | { | 257 | { |
258 | m_commands[function].Run(args); | 258 | m_commands[function].Run(args); |
259 | } | 259 | } |
260 | } | 260 | } |
261 | else | 261 | else |
262 | { | 262 | { |
263 | if (function != "help") | 263 | if (function != "help") |
264 | m_log.Error("Invalid command - No such command exists"); | 264 | m_log.Error("Invalid command - No such command exists"); |
265 | if (function == "api") | 265 | if (function == "api") |
266 | m_log.Info(GenerateRuntimeAPI()); | 266 | m_log.Info(GenerateRuntimeAPI()); |
267 | ShowConsoleHelp(); | 267 | ShowConsoleHelp(); |
268 | } | 268 | } |
269 | } | 269 | } |
270 | } | 270 | } |
271 | } | 271 | } |
diff --git a/bin/libode-debug.so b/bin/libode-debug.so index 8532ee8..8532ee8 100755..100644 --- a/bin/libode-debug.so +++ b/bin/libode-debug.so | |||
Binary files differ | |||
diff --git a/bin/ode-debug.dll b/bin/ode-debug.dll index 590dfa5..590dfa5 100755..100644 --- a/bin/ode-debug.dll +++ b/bin/ode-debug.dll | |||
Binary files differ | |||