From 3358d70c5b174b2b9ac1216e9e43497279982805 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 20 Apr 2008 04:19:44 +0000 Subject: * Updates LSL2CS converter * All objects are not touchable by default now * When a script listens for one of the touch events in the state, an object becomes touchable. * All LSL scripts report which events they consume now ** This uses semi-complicated Regex to discover the events, stick them in a dictionary, and then write a method call into each script state's state_entry() event. ** Tedd may figure out a better way to do this in the future. For now, this works for LSL. --- .../DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | 200 ++++++++++++++++++++- 1 file changed, 199 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler') diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index 9f753df..8d85b69 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs @@ -32,6 +32,7 @@ using System; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL { + public class LSL2CSConverter { @@ -41,6 +42,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL //private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled); private Dictionary dataTypes = new Dictionary(); private Dictionary quotes = new Dictionary(); + private Dictionary state_events = new Dictionary(); public LSL2CSConverter() { @@ -294,8 +296,63 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL } + // Finds out which events are in the script and writes a method call with the events in each state_entry event + + // Note the (?:)? block optional, and not returning a group. Less greedy then .* + + string[] eventmatches = new string[0]; + //Regex stateevents = new Regex(@"(public void )([^_]+)(_event_)([^\(]+)[\(\)]+\s+[^\{]\{"); + eventmatches = Regex.Split(Script, @"public void\s([^_]+)_event_([^\(]+)\((?:[a-zA-Z0-9\s_,\.\-]+)?\)+\s+[^\{]\{", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase); + for (int pos = 0; pos