From 3df8893c507ab6ab9e69d840cd5470ea96ae42ad Mon Sep 17 00:00:00 2001 From: Kevin Gadd <kevin.gadd@gmail.com> Date: Wed, 11 Apr 2012 16:44:34 -0700 Subject: [PATCH] Update the proxies. Flag regexes as ECMAScript compatible so JSIL won't choke on them. --- Examples/Sully/Proxies/File.cs | 22 +++++++++++++++++++ .../Sully/Proxies/{FastJSON.cs => JSON.cs} | 12 +++++----- Examples/Sully/Proxies/Proxies.csproj | 10 ++------- Sully.sln | 5 ----- XNAVERGE/Utility.cs | 4 ++-- XNAVERGE/sprite/Movestring.cs | 3 ++- XNAVERGE/sprite/Sprite_Loader.cs | 1 + 7 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 Examples/Sully/Proxies/File.cs rename Examples/Sully/Proxies/{FastJSON.cs => JSON.cs} (50%) diff --git a/Examples/Sully/Proxies/File.cs b/Examples/Sully/Proxies/File.cs new file mode 100644 index 0000000..5ad3734 --- /dev/null +++ b/Examples/Sully/Proxies/File.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using JSIL.Meta; +using JSIL.Proxy; + +namespace Sully.Proxies { + [JSProxy( + "XNAVERGE.Utility", + memberPolicy: JSProxyMemberPolicy.ReplaceDeclared, + attributePolicy: JSProxyAttributePolicy.ReplaceDeclared, + inheritable: true + )] + public static class UtilityProxy { + [JSReplacement("System.IO.File.ReadAllText($filepath)")] + [JSIsPure] + public static String read_file_text (String filepath) { + throw new NotImplementedException(); + } + } +} diff --git a/Examples/Sully/Proxies/FastJSON.cs b/Examples/Sully/Proxies/JSON.cs similarity index 50% rename from Examples/Sully/Proxies/FastJSON.cs rename to Examples/Sully/Proxies/JSON.cs index 7ec06e5..c8d3d3c 100644 --- a/Examples/Sully/Proxies/FastJSON.cs +++ b/Examples/Sully/Proxies/JSON.cs @@ -4,18 +4,18 @@ using System.Text; using JSIL.Meta; using JSIL.Proxy; -using fastJSON; namespace Sully.Proxies { [JSProxy( - typeof(fastJSON.JSON), + "Newtonsoft.Json.JsonConvert", memberPolicy: JSProxyMemberPolicy.ReplaceDeclared, - attributePolicy: JSProxyAttributePolicy.ReplaceDeclared + attributePolicy: JSProxyAttributePolicy.ReplaceDeclared, + inheritable: true )] - public class FastJSONProxy { - [JSReplacement("JSIL.JSON.Parse($json)")] + public static class NewtonsoftJSONProxy { + [JSReplacement("JSIL.JSON.Parse($value)")] [JSIsPure] - public object Parse (string json) { + public static T DeserializeObject<T> (string value, params AnyType[] converters) { throw new InvalidOperationException(); } } diff --git a/Examples/Sully/Proxies/Proxies.csproj b/Examples/Sully/Proxies/Proxies.csproj index 8e73f91..fdf7a67 100644 --- a/Examples/Sully/Proxies/Proxies.csproj +++ b/Examples/Sully/Proxies/Proxies.csproj @@ -40,16 +40,10 @@ <Reference Include="System.Core" /> </ItemGroup> <ItemGroup> - <Compile Include="FastJSON.cs" /> + <Compile Include="File.cs" /> + <Compile Include="JSON.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\..\..\Upstream\fastJSON\fastJSON\fastJSON.csproj"> - <Project>{207E91B1-C9F8-4913-88E1-3549EF5F3273}</Project> - <Name>fastJSON</Name> - <Private>False</Private> - </ProjectReference> - </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. diff --git a/Sully.sln b/Sully.sln index c486b90..9bba41e 100644 --- a/Sully.sln +++ b/Sully.sln @@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sully", "Examples\Sully\Sul EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SullyContent", "Examples\Sully\SullyContent\SullyContent.contentproj", "{BE4DABF9-B23E-45E7-8DF9-2D6E882AEC5A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fastJSON", "Upstream\fastJSON\fastJSON\fastJSON.csproj", "{207E91B1-C9F8-4913-88E1-3549EF5F3273}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Proxies", "Examples\Sully\Proxies\Proxies.csproj", "{12DBCC9A-50FE-43B1-BAD1-8029D4AD60CA}" EndProject Global @@ -38,9 +36,6 @@ Global {354DAF82-D6AF-4310-870C-4D5EF870344F}.Release|x86.Build.0 = Release|x86 {BE4DABF9-B23E-45E7-8DF9-2D6E882AEC5A}.Debug|x86.ActiveCfg = Debug|x86 {BE4DABF9-B23E-45E7-8DF9-2D6E882AEC5A}.Release|x86.ActiveCfg = Release|x86 - {207E91B1-C9F8-4913-88E1-3549EF5F3273}.Debug|x86.ActiveCfg = Debug|Any CPU - {207E91B1-C9F8-4913-88E1-3549EF5F3273}.Debug|x86.Build.0 = Debug|Any CPU - {207E91B1-C9F8-4913-88E1-3549EF5F3273}.Release|x86.ActiveCfg = Release|Any CPU {12DBCC9A-50FE-43B1-BAD1-8029D4AD60CA}.Debug|x86.ActiveCfg = Debug|Any CPU {12DBCC9A-50FE-43B1-BAD1-8029D4AD60CA}.Debug|x86.Build.0 = Debug|Any CPU {12DBCC9A-50FE-43B1-BAD1-8029D4AD60CA}.Release|x86.ActiveCfg = Release|Any CPU diff --git a/XNAVERGE/Utility.cs b/XNAVERGE/Utility.cs index 301761d..14987ef 100644 --- a/XNAVERGE/Utility.cs +++ b/XNAVERGE/Utility.cs @@ -3,7 +3,7 @@ using System.Linq; using System.Text; using System.IO; - +using System.Text.RegularExpressions; using Microsoft.Xna.Framework; using Newtonsoft.Json; @@ -139,7 +139,7 @@ public static String read_known_length_string(StreamReader reader, int len) { private const String WHITESPACE = @"\s"; public static String strip_whitespace(String str) { - return System.Text.RegularExpressions.Regex.Replace(str, WHITESPACE, ""); + return Regex.Replace(str, WHITESPACE, "", RegexOptions.ECMAScript); } // Returns a Direction based on the signs of the x and y values given. ++ is DownRight, -0 is Left, etc. diff --git a/XNAVERGE/sprite/Movestring.cs b/XNAVERGE/sprite/Movestring.cs index 5763604..fc44392 100644 --- a/XNAVERGE/sprite/Movestring.cs +++ b/XNAVERGE/sprite/Movestring.cs @@ -23,7 +23,8 @@ public class Movestring { public static Regex regex = new Regex( @"([ulrdxyptzwfb])\s*(\d*)", - RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant); + RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ECMAScript + ); public MovestringCommand[] commands; diff --git a/XNAVERGE/sprite/Sprite_Loader.cs b/XNAVERGE/sprite/Sprite_Loader.cs index ddcedf6..6c0198c 100644 --- a/XNAVERGE/sprite/Sprite_Loader.cs +++ b/XNAVERGE/sprite/Sprite_Loader.cs @@ -46,6 +46,7 @@ public static SpriteBasis _load_basis_by_asset_name(string asset_name) { cur = (i == 0 ? CHR_LOCATION : "") + (j == 0 ? asset_name : naked_name); if (File.Exists(@"content\" + cur + ".xnb")) { spr = VERGEGame.game.MapContent.Load<SpriteBasis>(cur); + spr.name = cur; i = 999; j = 999; }