diff options
Diffstat (limited to '')
4 files changed, 117 insertions, 21 deletions
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs b/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs index e4ca635..a7fa502 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs | |||
@@ -34,7 +34,36 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
34 | { | 34 | { |
35 | public interface ICompiler | 35 | public interface ICompiler |
36 | { | 36 | { |
37 | void PerformScriptCompile(string source, string asset, UUID ownerID, out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap); | 37 | /// <summary> |
38 | /// Performs the script compile. | ||
39 | /// </summary> | ||
40 | /// <param name="Script"></param> | ||
41 | /// <param name="asset"></param> | ||
42 | /// <param name="ownerUUID"></param> | ||
43 | /// <param name="alwaysRecompile"> | ||
44 | /// If set to true then always recompile the script, even if we have a DLL already cached. | ||
45 | /// </param> | ||
46 | /// <param name="assembly"></param> | ||
47 | /// <param name="linemap"></param> | ||
48 | void PerformScriptCompile( | ||
49 | string source, string asset, UUID ownerID, | ||
50 | out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap); | ||
51 | |||
52 | /// <summary> | ||
53 | /// Performs the script compile. | ||
54 | /// </summary> | ||
55 | /// <param name="Script"></param> | ||
56 | /// <param name="asset"></param> | ||
57 | /// <param name="ownerUUID"></param> | ||
58 | /// <param name="alwaysRecompile"> | ||
59 | /// If set to true then always recompile the script, even if we have a DLL already cached. | ||
60 | /// </param> | ||
61 | /// <param name="assembly"></param> | ||
62 | /// <param name="linemap"></param> | ||
63 | void PerformScriptCompile( | ||
64 | string source, string asset, UUID ownerID, bool alwaysRecompile, | ||
65 | out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap); | ||
66 | |||
38 | string[] GetWarnings(); | 67 | string[] GetWarnings(); |
39 | } | 68 | } |
40 | } | 69 | } |
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs index 2027ca6..b9970bf 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs | |||
@@ -26,9 +26,11 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Threading; | ||
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
30 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
31 | using OpenSim.Region.Framework.Scenes; | 32 | using OpenSim.Region.Framework.Scenes; |
33 | using OpenSim.Region.ScriptEngine.Shared; | ||
32 | 34 | ||
33 | namespace OpenSim.Region.ScriptEngine.Interfaces | 35 | namespace OpenSim.Region.ScriptEngine.Interfaces |
34 | { | 36 | { |
@@ -38,11 +40,12 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
38 | /// Initialize the API | 40 | /// Initialize the API |
39 | /// </summary> | 41 | /// </summary> |
40 | /// <remarks> | 42 | /// <remarks> |
41 | /// Each API has an identifier, which is used to load the | 43 | /// Each API has an identifier, which is used to load the proper runtime assembly at load time. |
42 | /// proper runtime assembly at load time. | 44 | /// <param name='scriptEngine'>/param> |
43 | /// <param name='engine'>/param> | 45 | /// <param name='host'>/param> |
44 | /// <param name='part'></param> | 46 | /// <param name='item'>/param> |
45 | /// <param name='item'></param> | 47 | /// <param name='coopSleepHandle'>/param> |
46 | void Initialize(IScriptEngine engine, SceneObjectPart part, TaskInventoryItem item); | 48 | void Initialize( |
49 | IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item); | ||
47 | } | 50 | } |
48 | } \ No newline at end of file | 51 | } |
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs index 17c2708..6355669 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs | |||
@@ -25,16 +25,17 @@ | |||
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 log4net; | ||
29 | using System; | 28 | using System; |
30 | using OpenSim.Region.ScriptEngine.Shared; | 29 | using System.Reflection; |
30 | using OpenSim.Framework; | ||
31 | using OpenSim.Region.Framework.Scenes; | 31 | using OpenSim.Region.Framework.Scenes; |
32 | using OpenSim.Region.Framework.Interfaces; | 32 | using OpenSim.Region.Framework.Interfaces; |
33 | using OpenMetaverse; | ||
34 | using Nini.Config; | ||
35 | using OpenSim.Region.ScriptEngine.Interfaces; | 33 | using OpenSim.Region.ScriptEngine.Interfaces; |
34 | using OpenSim.Region.ScriptEngine.Shared; | ||
36 | using Amib.Threading; | 35 | using Amib.Threading; |
37 | using OpenSim.Framework; | 36 | using log4net; |
37 | using Nini.Config; | ||
38 | using OpenMetaverse; | ||
38 | 39 | ||
39 | namespace OpenSim.Region.ScriptEngine.Interfaces | 40 | namespace OpenSim.Region.ScriptEngine.Interfaces |
40 | { | 41 | { |
@@ -76,6 +77,40 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
76 | IConfigSource ConfigSource { get; } | 77 | IConfigSource ConfigSource { get; } |
77 | string ScriptEngineName { get; } | 78 | string ScriptEngineName { get; } |
78 | string ScriptEnginePath { get; } | 79 | string ScriptEnginePath { get; } |
80 | |||
81 | /// <summary> | ||
82 | /// Return the name of the class that will be used for all running scripts. | ||
83 | /// </summary> | ||
84 | /// <remarks> | ||
85 | /// Each class goes in its own assembly so we don't need to otherwise distinguish the class name. | ||
86 | /// </remarks> | ||
87 | string ScriptClassName { get; } | ||
88 | |||
89 | /// <summary> | ||
90 | /// Return the name of the base class that will be used for all running scripts. | ||
91 | /// </summary> | ||
92 | string ScriptBaseClassName { get; } | ||
93 | |||
94 | /// <summary> | ||
95 | /// Assemblies that need to be referenced when compiling scripts. | ||
96 | /// </summary> | ||
97 | /// <remarks> | ||
98 | /// These are currently additional to those always referenced by the compiler, BUT THIS MAY CHANGE IN THE | ||
99 | /// FUTURE. | ||
100 | /// This can be null if there are no additional assemblies. | ||
101 | /// </remarks> | ||
102 | string[] ScriptReferencedAssemblies { get; } | ||
103 | |||
104 | /// <summary> | ||
105 | /// Parameters for the generated script's constructor. | ||
106 | /// </summary> | ||
107 | /// <remarks> | ||
108 | /// Can be null if there are no parameters | ||
109 | /// </remarks> | ||
110 | ParameterInfo[] ScriptBaseClassParameters { get; } | ||
111 | |||
79 | IScriptApi GetApi(UUID itemID, string name); | 112 | IScriptApi GetApi(UUID itemID, string name); |
113 | |||
114 | void SleepScript(UUID itemID, int delay); | ||
80 | } | 115 | } |
81 | } | 116 | } |
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index 2f5b526..e4297c4 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs | |||
@@ -28,9 +28,12 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Threading; | ||
32 | using System.Diagnostics; | ||
31 | using OpenMetaverse; | 33 | using OpenMetaverse; |
32 | using log4net; | 34 | using log4net; |
33 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Scenes; | ||
34 | using OpenSim.Region.ScriptEngine.Shared; | 37 | using OpenSim.Region.ScriptEngine.Shared; |
35 | using OpenSim.Region.ScriptEngine.Interfaces; | 38 | using OpenSim.Region.ScriptEngine.Interfaces; |
36 | 39 | ||
@@ -49,8 +52,13 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
49 | public interface IScriptWorkItem | 52 | public interface IScriptWorkItem |
50 | { | 53 | { |
51 | bool Cancel(); | 54 | bool Cancel(); |
52 | void Abort(); | 55 | bool Abort(); |
53 | bool Wait(TimeSpan t); | 56 | |
57 | /// <summary> | ||
58 | /// Wait for the work item to complete. | ||
59 | /// </summary> | ||
60 | /// <param name='t'>The number of milliseconds to wait. Must be >= -1 (Timeout.Infinite).</param> | ||
61 | bool Wait(int t); | ||
54 | } | 62 | } |
55 | 63 | ||
56 | /// <summary> | 64 | /// <summary> |
@@ -86,24 +94,35 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
86 | bool ShuttingDown { get; set; } | 94 | bool ShuttingDown { get; set; } |
87 | 95 | ||
88 | /// <summary> | 96 | /// <summary> |
97 | /// When stopping the script: should it remain stopped permanently (i.e., save !Running in its state)? | ||
98 | /// </summary> | ||
99 | bool StayStopped { get; set; } | ||
100 | |||
101 | /// <summary> | ||
89 | /// Script state | 102 | /// Script state |
90 | /// </summary> | 103 | /// </summary> |
91 | string State { get; set; } | 104 | string State { get; set; } |
92 | 105 | ||
93 | /// <summary> | 106 | /// <summary> |
107 | /// If true then the engine is responsible for persisted state. If false then some other component may | ||
108 | /// persist state (e.g. attachments persisting in assets). | ||
109 | /// </summary> | ||
110 | bool StatePersistedHere { get; } | ||
111 | |||
112 | /// <summary> | ||
94 | /// Time the script was last started | 113 | /// Time the script was last started |
95 | /// </summary> | 114 | /// </summary> |
96 | DateTime TimeStarted { get; } | 115 | DateTime TimeStarted { get; } |
97 | 116 | ||
98 | /// <summary> | 117 | /// <summary> |
99 | /// Tick the last measurement period was started. | 118 | /// Collects information about how long the script was executed. |
100 | /// </summary> | 119 | /// </summary> |
101 | long MeasurementPeriodTickStart { get; } | 120 | MetricsCollectorTime ExecutionTime { get; } |
102 | 121 | ||
103 | /// <summary> | 122 | /// <summary> |
104 | /// Ticks spent executing in the last measurement period. | 123 | /// Scene part in which this script instance is contained. |
105 | /// </summary> | 124 | /// </summary> |
106 | long MeasurementPeriodExecutionTime { get; } | 125 | SceneObjectPart Part { get; } |
107 | 126 | ||
108 | IScriptEngine Engine { get; } | 127 | IScriptEngine Engine { get; } |
109 | UUID AppDomain { get; set; } | 128 | UUID AppDomain { get; set; } |
@@ -124,6 +143,12 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
124 | 143 | ||
125 | uint LocalID { get; } | 144 | uint LocalID { get; } |
126 | UUID AssetID { get; } | 145 | UUID AssetID { get; } |
146 | |||
147 | /// <summary> | ||
148 | /// Inventory item containing the script used. | ||
149 | /// </summary> | ||
150 | TaskInventoryItem ScriptTask { get; } | ||
151 | |||
127 | Queue EventQueue { get; } | 152 | Queue EventQueue { get; } |
128 | 153 | ||
129 | /// <summary> | 154 | /// <summary> |
@@ -139,6 +164,9 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
139 | void ClearQueue(); | 164 | void ClearQueue(); |
140 | int StartParam { get; set; } | 165 | int StartParam { get; set; } |
141 | 166 | ||
167 | WaitHandle CoopWaitHandle { get; } | ||
168 | Stopwatch ExecutionTimer { get; } | ||
169 | |||
142 | void RemoveState(); | 170 | void RemoveState(); |
143 | 171 | ||
144 | void Init(); | 172 | void Init(); |
@@ -154,8 +182,9 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
154 | /// <param name="timeout"></param> | 182 | /// <param name="timeout"></param> |
155 | /// How many milliseconds we will wait for an existing script event to finish before | 183 | /// How many milliseconds we will wait for an existing script event to finish before |
156 | /// forcibly aborting that event. | 184 | /// forcibly aborting that event. |
185 | /// <param name="clearEventQueue">If true then the event queue is also cleared</param> | ||
157 | /// <returns>true if the script was successfully stopped, false otherwise</returns> | 186 | /// <returns>true if the script was successfully stopped, false otherwise</returns> |
158 | bool Stop(int timeout); | 187 | bool Stop(int timeout, bool clearEventQueue = false); |
159 | 188 | ||
160 | void SetState(string state); | 189 | void SetState(string state); |
161 | 190 | ||
@@ -204,7 +233,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
204 | void SetVars(Dictionary<string, object> vars); | 233 | void SetVars(Dictionary<string, object> vars); |
205 | DetectParams GetDetectParams(int idx); | 234 | DetectParams GetDetectParams(int idx); |
206 | UUID GetDetectID(int idx); | 235 | UUID GetDetectID(int idx); |
207 | void SaveState(string assembly); | 236 | void SaveState(); |
208 | void DestroyScriptInstance(); | 237 | void DestroyScriptInstance(); |
209 | 238 | ||
210 | IScriptApi GetApi(string name); | 239 | IScriptApi GetApi(string name); |