aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
diff options
context:
space:
mode:
authorMelanie2012-03-26 00:30:52 +0100
committerMelanie2012-03-26 00:30:52 +0100
commit4b76c52c41ffcdaf4254a290885cf26e4d447397 (patch)
tree684c29c6ecb169da73d8a9d8d3d0936a75dec5b6 /OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
parentMerge branch 'master' into careminster (diff)
downloadopensim-SC-4b76c52c41ffcdaf4254a290885cf26e4d447397.zip
opensim-SC-4b76c52c41ffcdaf4254a290885cf26e4d447397.tar.gz
opensim-SC-4b76c52c41ffcdaf4254a290885cf26e4d447397.tar.bz2
opensim-SC-4b76c52c41ffcdaf4254a290885cf26e4d447397.tar.xz
Correct the design error I introduced into ScriptComms. Untested but about to
be.
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs36
1 files changed, 22 insertions, 14 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 8e8a0b6..e37e42e 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -47,15 +47,15 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
47#region ScriptInvocation 47#region ScriptInvocation
48 protected class ScriptInvocationData 48 protected class ScriptInvocationData
49 { 49 {
50 public ScriptInvocation ScriptInvocationFn { get; private set; } 50 public Delegate ScriptInvocationDelegate { get; private set; }
51 public string FunctionName { get; private set; } 51 public string FunctionName { get; private set; }
52 public Type[] TypeSignature { get; private set; } 52 public Type[] TypeSignature { get; private set; }
53 public Type ReturnType { get; private set; } 53 public Type ReturnType { get; private set; }
54 54
55 public ScriptInvocationData(string fname, ScriptInvocation fn, Type[] callsig, Type returnsig) 55 public ScriptInvocationData(string fname, Delegate fn, Type[] callsig, Type returnsig)
56 { 56 {
57 FunctionName = fname; 57 FunctionName = fname;
58 ScriptInvocationFn = fn; 58 ScriptInvocationDelegate = fn;
59 TypeSignature = callsig; 59 TypeSignature = callsig;
60 ReturnType = returnsig; 60 ReturnType = returnsig;
61 } 61 }
@@ -126,26 +126,30 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
126 m_scriptModule.PostScriptEvent(script, "link_message", args); 126 m_scriptModule.PostScriptEvent(script, "link_message", args);
127 } 127 }
128 128
129 public void RegisterScriptInvocation(ScriptInvocation fcall) 129 public void RegisterScriptInvocation(Delegate fcall)
130 { 130 {
131 lock (m_scriptInvocation) 131 lock (m_scriptInvocation)
132 { 132 {
133 ParameterInfo[] parameters = fcall.Method.GetParameters (); 133 ParameterInfo[] parameters = fcall.Method.GetParameters ();
134 Type[] parmTypes = new Type[parameters.Length]; 134 if (parameters.Length == 0) // Must have one UUID param
135 for (int i = 0 ; i < parameters.Length ; i++) 135 return;
136 parmTypes[i] = parameters[i].ParameterType; 136
137 // Hide the first parameter
138 Type[] parmTypes = new Type[parameters.Length - 1];
139 for (int i = 1 ; i < parameters.Length ; i++)
140 parmTypes[i - 1] = parameters[i].ParameterType;
137 m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType); 141 m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType);
138 } 142 }
139 } 143 }
140 144
141 public ScriptInvocation[] GetScriptInvocationList() 145 public Delegate[] GetScriptInvocationList()
142 { 146 {
143 List<ScriptInvocation> ret = new List<ScriptInvocation>(); 147 List<Delegate> ret = new List<Delegate>();
144 148
145 lock (m_scriptInvocation) 149 lock (m_scriptInvocation)
146 { 150 {
147 foreach (ScriptInvocationData d in m_scriptInvocation.Values) 151 foreach (ScriptInvocationData d in m_scriptInvocation.Values)
148 ret.Add(d.ScriptInvocationFn); 152 ret.Add(d.ScriptInvocationDelegate);
149 } 153 }
150 return ret.ToArray(); 154 return ret.ToArray();
151 } 155 }
@@ -177,13 +181,13 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
177 return null; 181 return null;
178 } 182 }
179 183
180 public ScriptInvocation LookupScriptInvocation(string fname) 184 public Delegate LookupScriptInvocation(string fname)
181 { 185 {
182 lock (m_scriptInvocation) 186 lock (m_scriptInvocation)
183 { 187 {
184 ScriptInvocationData sid; 188 ScriptInvocationData sid;
185 if (m_scriptInvocation.TryGetValue(fname,out sid)) 189 if (m_scriptInvocation.TryGetValue(fname,out sid))
186 return sid.ScriptInvocationFn; 190 return sid.ScriptInvocationDelegate;
187 } 191 }
188 192
189 return null; 193 return null;
@@ -215,8 +219,12 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
215 219
216 public object InvokeOperation(UUID scriptid, string fname, params object[] parms) 220 public object InvokeOperation(UUID scriptid, string fname, params object[] parms)
217 { 221 {
218 ScriptInvocation fn = LookupScriptInvocation(fname); 222 List<object> olist = new List<object>();
219 return fn(scriptid,parms); 223 olist.Add(scriptid);
224 foreach (object o in parms)
225 olist.Add(o);
226 Delegate fn = LookupScriptInvocation(fname);
227 return fn.DynamicInvoke(olist.ToArray());
220 } 228 }
221#endregion 229#endregion
222 230