diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | 79 |
1 files changed, 72 insertions, 7 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 8f34833..1458c95 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -30,6 +30,8 @@ using System.Reflection; | |||
30 | using System.Collections; | 30 | using System.Collections; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
33 | using System.Threading; | ||
34 | using log4net; | ||
33 | using OpenMetaverse; | 35 | using OpenMetaverse; |
34 | using Nini.Config; | 36 | using Nini.Config; |
35 | using OpenSim; | 37 | using OpenSim; |
@@ -55,15 +57,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
55 | [Serializable] | 57 | [Serializable] |
56 | public class MOD_Api : MarshalByRefObject, IMOD_Api, IScriptApi | 58 | public class MOD_Api : MarshalByRefObject, IMOD_Api, IScriptApi |
57 | { | 59 | { |
60 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
61 | |||
58 | internal IScriptEngine m_ScriptEngine; | 62 | internal IScriptEngine m_ScriptEngine; |
59 | internal SceneObjectPart m_host; | 63 | internal SceneObjectPart m_host; |
60 | internal TaskInventoryItem m_item; | 64 | internal TaskInventoryItem m_item; |
61 | internal bool m_MODFunctionsEnabled = false; | 65 | internal bool m_MODFunctionsEnabled = false; |
62 | internal IScriptModuleComms m_comms = null; | 66 | internal IScriptModuleComms m_comms = null; |
63 | 67 | ||
64 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) | 68 | public void Initialize( |
69 | IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item) | ||
65 | { | 70 | { |
66 | m_ScriptEngine = ScriptEngine; | 71 | m_ScriptEngine = scriptEngine; |
67 | m_host = host; | 72 | m_host = host; |
68 | m_item = item; | 73 | m_item = item; |
69 | 74 | ||
@@ -107,8 +112,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
107 | if (message.Length > 1023) | 112 | if (message.Length > 1023) |
108 | message = message.Substring(0, 1023); | 113 | message = message.Substring(0, 1023); |
109 | 114 | ||
110 | World.SimChat(Utils.StringToBytes(message), | 115 | World.SimChat( |
111 | ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); | 116 | Utils.StringToBytes(message), |
117 | ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, | ||
118 | m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, false); | ||
112 | 119 | ||
113 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 120 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
114 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); | 121 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); |
@@ -122,6 +129,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
122 | /// <returns>string result of the invocation</returns> | 129 | /// <returns>string result of the invocation</returns> |
123 | public void modInvokeN(string fname, params object[] parms) | 130 | public void modInvokeN(string fname, params object[] parms) |
124 | { | 131 | { |
132 | // m_log.DebugFormat( | ||
133 | // "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", | ||
134 | // fname, | ||
135 | // string.Join(",", Array.ConvertAll<object, string>(parms, o => o.ToString())), | ||
136 | // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); | ||
137 | |||
125 | Type returntype = m_comms.LookupReturnType(fname); | 138 | Type returntype = m_comms.LookupReturnType(fname); |
126 | if (returntype != typeof(string)) | 139 | if (returntype != typeof(string)) |
127 | MODError(String.Format("return type mismatch for {0}",fname)); | 140 | MODError(String.Format("return type mismatch for {0}",fname)); |
@@ -131,6 +144,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
131 | 144 | ||
132 | public LSL_String modInvokeS(string fname, params object[] parms) | 145 | public LSL_String modInvokeS(string fname, params object[] parms) |
133 | { | 146 | { |
147 | // m_log.DebugFormat( | ||
148 | // "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", | ||
149 | // fname, | ||
150 | // string.Join(",", Array.ConvertAll<object, string>(parms, o => o.ToString())), | ||
151 | // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); | ||
152 | |||
134 | Type returntype = m_comms.LookupReturnType(fname); | 153 | Type returntype = m_comms.LookupReturnType(fname); |
135 | if (returntype != typeof(string)) | 154 | if (returntype != typeof(string)) |
136 | MODError(String.Format("return type mismatch for {0}",fname)); | 155 | MODError(String.Format("return type mismatch for {0}",fname)); |
@@ -141,6 +160,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
141 | 160 | ||
142 | public LSL_Integer modInvokeI(string fname, params object[] parms) | 161 | public LSL_Integer modInvokeI(string fname, params object[] parms) |
143 | { | 162 | { |
163 | // m_log.DebugFormat( | ||
164 | // "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", | ||
165 | // fname, | ||
166 | // string.Join(",", Array.ConvertAll<object, string>(parms, o => o.ToString())), | ||
167 | // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); | ||
168 | |||
144 | Type returntype = m_comms.LookupReturnType(fname); | 169 | Type returntype = m_comms.LookupReturnType(fname); |
145 | if (returntype != typeof(int)) | 170 | if (returntype != typeof(int)) |
146 | MODError(String.Format("return type mismatch for {0}",fname)); | 171 | MODError(String.Format("return type mismatch for {0}",fname)); |
@@ -151,6 +176,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
151 | 176 | ||
152 | public LSL_Float modInvokeF(string fname, params object[] parms) | 177 | public LSL_Float modInvokeF(string fname, params object[] parms) |
153 | { | 178 | { |
179 | // m_log.DebugFormat( | ||
180 | // "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", | ||
181 | // fname, | ||
182 | // string.Join(",", Array.ConvertAll<object, string>(parms, o => o.ToString())), | ||
183 | // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); | ||
184 | |||
154 | Type returntype = m_comms.LookupReturnType(fname); | 185 | Type returntype = m_comms.LookupReturnType(fname); |
155 | if (returntype != typeof(float)) | 186 | if (returntype != typeof(float)) |
156 | MODError(String.Format("return type mismatch for {0}",fname)); | 187 | MODError(String.Format("return type mismatch for {0}",fname)); |
@@ -161,6 +192,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
161 | 192 | ||
162 | public LSL_Key modInvokeK(string fname, params object[] parms) | 193 | public LSL_Key modInvokeK(string fname, params object[] parms) |
163 | { | 194 | { |
195 | // m_log.DebugFormat( | ||
196 | // "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", | ||
197 | // fname, | ||
198 | // string.Join(",", Array.ConvertAll<object, string>(parms, o => o.ToString())), | ||
199 | // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); | ||
200 | |||
164 | Type returntype = m_comms.LookupReturnType(fname); | 201 | Type returntype = m_comms.LookupReturnType(fname); |
165 | if (returntype != typeof(UUID)) | 202 | if (returntype != typeof(UUID)) |
166 | MODError(String.Format("return type mismatch for {0}",fname)); | 203 | MODError(String.Format("return type mismatch for {0}",fname)); |
@@ -171,6 +208,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
171 | 208 | ||
172 | public LSL_Vector modInvokeV(string fname, params object[] parms) | 209 | public LSL_Vector modInvokeV(string fname, params object[] parms) |
173 | { | 210 | { |
211 | // m_log.DebugFormat( | ||
212 | // "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", | ||
213 | // fname, | ||
214 | // string.Join(",", Array.ConvertAll<object, string>(parms, o => o.ToString())), | ||
215 | // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); | ||
216 | |||
174 | Type returntype = m_comms.LookupReturnType(fname); | 217 | Type returntype = m_comms.LookupReturnType(fname); |
175 | if (returntype != typeof(OpenMetaverse.Vector3)) | 218 | if (returntype != typeof(OpenMetaverse.Vector3)) |
176 | MODError(String.Format("return type mismatch for {0}",fname)); | 219 | MODError(String.Format("return type mismatch for {0}",fname)); |
@@ -181,6 +224,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
181 | 224 | ||
182 | public LSL_Rotation modInvokeR(string fname, params object[] parms) | 225 | public LSL_Rotation modInvokeR(string fname, params object[] parms) |
183 | { | 226 | { |
227 | // m_log.DebugFormat( | ||
228 | // "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", | ||
229 | // fname, | ||
230 | // string.Join(",", Array.ConvertAll<object, string>(parms, o => o.ToString())), | ||
231 | // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); | ||
232 | |||
184 | Type returntype = m_comms.LookupReturnType(fname); | 233 | Type returntype = m_comms.LookupReturnType(fname); |
185 | if (returntype != typeof(OpenMetaverse.Quaternion)) | 234 | if (returntype != typeof(OpenMetaverse.Quaternion)) |
186 | MODError(String.Format("return type mismatch for {0}",fname)); | 235 | MODError(String.Format("return type mismatch for {0}",fname)); |
@@ -191,6 +240,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
191 | 240 | ||
192 | public LSL_List modInvokeL(string fname, params object[] parms) | 241 | public LSL_List modInvokeL(string fname, params object[] parms) |
193 | { | 242 | { |
243 | // m_log.DebugFormat( | ||
244 | // "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", | ||
245 | // fname, | ||
246 | // string.Join(",", Array.ConvertAll<object, string>(parms, o => o.ToString())), | ||
247 | // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); | ||
248 | |||
194 | Type returntype = m_comms.LookupReturnType(fname); | 249 | Type returntype = m_comms.LookupReturnType(fname); |
195 | if (returntype != typeof(object[])) | 250 | if (returntype != typeof(object[])) |
196 | MODError(String.Format("return type mismatch for {0}",fname)); | 251 | MODError(String.Format("return type mismatch for {0}",fname)); |
@@ -211,6 +266,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
211 | { | 266 | { |
212 | llist[i] = new LSL_Float((float)result[i]); | 267 | llist[i] = new LSL_Float((float)result[i]); |
213 | } | 268 | } |
269 | else if (result[i] is double) | ||
270 | { | ||
271 | llist[i] = new LSL_Float((double)result[i]); | ||
272 | } | ||
214 | else if (result[i] is UUID) | 273 | else if (result[i] is UUID) |
215 | { | 274 | { |
216 | llist[i] = new LSL_Key(result[i].ToString()); | 275 | llist[i] = new LSL_Key(result[i].ToString()); |
@@ -248,13 +307,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
248 | return ""; | 307 | return ""; |
249 | } | 308 | } |
250 | 309 | ||
310 | // m_log.DebugFormat( | ||
311 | // "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", | ||
312 | // fname, | ||
313 | // string.Join(",", Array.ConvertAll<object, string>(parms, o => o.ToString())), | ||
314 | // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); | ||
315 | |||
251 | Type[] signature = m_comms.LookupTypeSignature(fname); | 316 | Type[] signature = m_comms.LookupTypeSignature(fname); |
252 | if (signature.Length != parms.Length) | 317 | if (signature.Length != parms.Length) |
253 | MODError(String.Format("wrong number of parameters to function {0}",fname)); | 318 | MODError(String.Format("wrong number of parameters to function {0}",fname)); |
254 | 319 | ||
255 | object[] convertedParms = new object[parms.Length]; | 320 | object[] convertedParms = new object[parms.Length]; |
256 | for (int i = 0; i < parms.Length; i++) | 321 | for (int i = 0; i < parms.Length; i++) |
257 | convertedParms[i] = ConvertFromLSL(parms[i],signature[i], fname); | 322 | convertedParms[i] = ConvertFromLSL(parms[i], signature[i], fname); |
258 | 323 | ||
259 | // now call the function, the contract with the function is that it will always return | 324 | // now call the function, the contract with the function is that it will always return |
260 | // non-null but don't trust it completely | 325 | // non-null but don't trust it completely |
@@ -351,7 +416,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
351 | { | 416 | { |
352 | if (type == typeof(object[])) | 417 | if (type == typeof(object[])) |
353 | { | 418 | { |
354 | object[] plist = (lslparm as LSL_List).Data; | 419 | object[] plist = ((LSL_List)lslparm).Data; |
355 | object[] result = new object[plist.Length]; | 420 | object[] result = new object[plist.Length]; |
356 | for (int i = 0; i < plist.Length; i++) | 421 | for (int i = 0; i < plist.Length; i++) |
357 | { | 422 | { |
@@ -379,7 +444,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
379 | } | 444 | } |
380 | } | 445 | } |
381 | 446 | ||
382 | MODError(String.Format("{1}: parameter type mismatch; expecting {0}",type.Name, fname)); | 447 | MODError(String.Format("{0}: parameter type mismatch; expecting {1}, type(parm)={2}", fname, type.Name, lslparm.GetType())); |
383 | return null; | 448 | return null; |
384 | } | 449 | } |
385 | 450 | ||