clockwerk-opensim-stable – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27  
28 using System;
29 using System.Reflection;
30 using System.Collections.Generic;
31 using OpenMetaverse;
32  
33 namespace OpenSim.Region.Framework.Interfaces
34 {
35 public delegate void ScriptCommand(UUID script, string id, string module, string command, string k);
36  
37 /// <summary>
38 /// Interface for communication between OpenSim modules and in-world scripts
39 /// </summary>
40 ///
41 /// See OpenSim.Region.ScriptEngine.Shared.Api.MOD_Api.modSendCommand() for information on receiving messages
42 /// from scripts in OpenSim modules.
43 public interface IScriptModuleComms
44 {
45 /// <summary>
46 /// Modules can subscribe to this event to receive command invocations from in-world scripts
47 /// </summary>
48 event ScriptCommand OnScriptCommand;
49  
50 /// <summary>
51 /// Register an instance method as a script call by method name
52 /// </summary>
53 /// <param name="target"></param>
54 /// <param name="method"></param>
55 void RegisterScriptInvocation(object target, string method);
56  
57 /// <summary>
58 /// Register a static or instance method as a script call by method info
59 /// </summary>
60 /// <param name="target">If target is a Type object, will assume method is static.</param>
61 /// <param name="method"></param>
62 void RegisterScriptInvocation(object target, MethodInfo method);
63  
64 /// <summary>
65 /// Register one or more instance methods as script calls by method name
66 /// </summary>
67 /// <param name="target"></param>
68 /// <param name="methods"></param>
69 void RegisterScriptInvocation(object target, string[] methods);
70  
71 /// <summary>
72 /// Register one or more static methods as script calls by method name
73 /// </summary>
74 /// <param name="target"></param>
75 /// <param name="methods"></param>
76 void RegisterScriptInvocation(Type target, string[] methods);
77  
78 /// <summary>
79 /// Automatically register script invocations by checking for methods
80 /// with <see cref="ScriptInvocationAttribute"/>. Should only check
81 /// public methods.
82 /// </summary>
83 /// <param name="target"></param>
84 void RegisterScriptInvocations(IRegionModuleBase target);
85  
86 /// <summary>
87 /// Returns an array of all registered script calls
88 /// </summary>
89 /// <returns></returns>
90 Delegate[] GetScriptInvocationList();
91  
92 Delegate LookupScriptInvocation(string fname);
93 string LookupModInvocation(string fname);
94 Type[] LookupTypeSignature(string fname);
95 Type LookupReturnType(string fname);
96  
97 object InvokeOperation(UUID hostId, UUID scriptId, string fname, params object[] parms);
98  
99 /// <summary>
100 /// Send a link_message event to an in-world script
101 /// </summary>
102 /// <param name="scriptId"></param>
103 /// <param name="code"></param>
104 /// <param name="text"></param>
105 /// <param name="key"></param>
106 void DispatchReply(UUID scriptId, int code, string text, string key);
107  
108 /// <summary>
109 /// Operation to for a region module to register a constant to be used
110 /// by the script engine
111 /// </summary>
112 /// <param name="cname">
113 /// The name of the constant. LSL convention is for constant names to
114 /// be uppercase.
115 /// </param>
116 /// <param name="value">
117 /// The value of the constant. Should be of a type that can be
118 /// converted to one of <see cref="OpenSim.Region.ScriptEngine.Shared.LSL_Types"/>
119 /// </param>
120 void RegisterConstant(string cname, object value);
121  
122 /// <summary>
123 /// Automatically register all constants on a region module by
124 /// checking for fields with <see cref="ScriptConstantAttribute"/>.
125 /// </summary>
126 /// <param name="target"></param>
127 void RegisterConstants(IRegionModuleBase target);
128  
129 /// <summary>
130 /// Operation to check for a registered constant
131 /// </summary>
132 /// <param name="cname">Name of constant</param>
133 /// <returns>Value of constant or null if none found.</returns>
134 object LookupModConstant(string cname);
135 Dictionary<string, object> GetConstants();
136  
137 // For use ONLY by the script API
138 void RaiseEvent(UUID script, string id, string module, string command, string key);
139 }
140  
141 [AttributeUsage(AttributeTargets.Method)]
142 public class ScriptInvocationAttribute : Attribute
143 { }
144  
145 [AttributeUsage(AttributeTargets.Field)]
146 public class ScriptConstantAttribute : Attribute
147 { }
148 }