aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs99
1 files changed, 97 insertions, 2 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 44c9ada..a90362e 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using System.Collections.Generic;
30using Nini.Config; 31using Nini.Config;
31using log4net; 32using log4net;
32using OpenSim.Framework; 33using OpenSim.Framework;
@@ -35,7 +36,7 @@ using OpenSim.Region.Framework.Scenes;
35using Mono.Addins; 36using Mono.Addins;
36using OpenMetaverse; 37using OpenMetaverse;
37 38
38namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms 39namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
39{ 40{
40 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] 41 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")]
41 class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms 42 class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms
@@ -43,10 +44,30 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
43 private static readonly ILog m_log = 44 private static readonly ILog m_log =
44 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 46
46 private IScriptModule m_scriptModule = null; 47#region ScriptInvocation
48 protected class ScriptInvocationData
49 {
50 public ScriptInvocation ScriptInvocationFn { get; private set; }
51 public string FunctionName { get; private set; }
52 public Type[] TypeSignature { get; private set; }
53 public Type ReturnType { get; private set; }
54
55 public ScriptInvocationData(string fname, ScriptInvocation fn, Type[] callsig, Type returnsig)
56 {
57 FunctionName = fname;
58 ScriptInvocationFn = fn;
59 TypeSignature = callsig;
60 ReturnType = returnsig;
61 }
62 }
47 63
64 private Dictionary<string,ScriptInvocationData> m_scriptInvocation = new Dictionary<string,ScriptInvocationData>();
65#endregion
66
67 private IScriptModule m_scriptModule = null;
48 public event ScriptCommand OnScriptCommand; 68 public event ScriptCommand OnScriptCommand;
49 69
70#region RegionModuleInterface
50 public void Initialise(IConfigSource config) 71 public void Initialise(IConfigSource config)
51 { 72 {
52 } 73 }
@@ -81,6 +102,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
81 public void Close() 102 public void Close()
82 { 103 {
83 } 104 }
105#endregion
106
107#region ScriptModuleComms
84 108
85 public void RaiseEvent(UUID script, string id, string module, string command, string k) 109 public void RaiseEvent(UUID script, string id, string module, string command, string k)
86 { 110 {
@@ -101,5 +125,76 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
101 125
102 m_scriptModule.PostScriptEvent(script, "link_message", args); 126 m_scriptModule.PostScriptEvent(script, "link_message", args);
103 } 127 }
128
129 public void RegisterScriptInvocation(string fname, ScriptInvocation fcall, Type[] csig, Type rsig)
130 {
131 lock (m_scriptInvocation)
132 {
133 m_scriptInvocation[fname] = new ScriptInvocationData(fname,fcall,csig,rsig);
134 }
135 }
136
137 public string LookupModInvocation(string fname)
138 {
139 lock (m_scriptInvocation)
140 {
141 ScriptInvocationData sid;
142 if (m_scriptInvocation.TryGetValue(fname,out sid))
143 {
144 if (sid.ReturnType == typeof(string))
145 return "modInvokeS";
146 else if (sid.ReturnType == typeof(int))
147 return "modInvokeI";
148 else if (sid.ReturnType == typeof(float))
149 return "modInvokeF";
150 }
151 }
152
153 return null;
154 }
155
156 public ScriptInvocation LookupScriptInvocation(string fname)
157 {
158 lock (m_scriptInvocation)
159 {
160 ScriptInvocationData sid;
161 if (m_scriptInvocation.TryGetValue(fname,out sid))
162 return sid.ScriptInvocationFn;
163 }
164
165 return null;
166 }
167
168 public Type[] LookupTypeSignature(string fname)
169 {
170 lock (m_scriptInvocation)
171 {
172 ScriptInvocationData sid;
173 if (m_scriptInvocation.TryGetValue(fname,out sid))
174 return sid.TypeSignature;
175 }
176
177 return null;
178 }
179
180 public Type LookupReturnType(string fname)
181 {
182 lock (m_scriptInvocation)
183 {
184 ScriptInvocationData sid;
185 if (m_scriptInvocation.TryGetValue(fname,out sid))
186 return sid.ReturnType;
187 }
188
189 return null;
190 }
191
192 public object InvokeOperation(UUID scriptid, string fname, params object[] parms)
193 {
194 ScriptInvocation fn = LookupScriptInvocation(fname);
195 return fn(scriptid,parms);
196 }
197#endregion
198
104 } 199 }
105} 200}