From 4d9e526bcb0d691dd3622551068deb0ca4b9e54c Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 9 Sep 2012 11:10:50 -0700 Subject: [PATCH 001/251] Update mscorlib assembly name to match eventual module name --- src/Core/CoreLib/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/CoreLib/Properties/AssemblyInfo.cs b/src/Core/CoreLib/Properties/AssemblyInfo.cs index 6078594a1..ddf931d18 100644 --- a/src/Core/CoreLib/Properties/AssemblyInfo.cs +++ b/src/Core/CoreLib/Properties/AssemblyInfo.cs @@ -9,4 +9,4 @@ [assembly: AssemblyTitle("mscorlib")] [assembly: AssemblyDescription("Script# Core Assembly")] -[assembly: ScriptAssembly("core")] +[assembly: ScriptAssembly("ss")] From 4ee36a2cec8b2af6ee09e46fb39dead8a8de9c07 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 9 Sep 2012 11:11:11 -0700 Subject: [PATCH 002/251] Initial commit for runtime scripts project --- .gitignore | 1 - src/Core/Scripts/Runtime.js | 49 ++++ src/Core/Scripts/Runtime/Console.js | 18 ++ src/Core/Scripts/Runtime/TypeSystem.js | 65 ++++++ src/Core/Scripts/Scripts.csproj | 30 +++ src/ScriptSharp.sln | 299 +++++++++++++------------ 6 files changed, 319 insertions(+), 143 deletions(-) create mode 100644 src/Core/Scripts/Runtime.js create mode 100644 src/Core/Scripts/Runtime/Console.js create mode 100644 src/Core/Scripts/Runtime/TypeSystem.js create mode 100644 src/Core/Scripts/Scripts.csproj diff --git a/.gitignore b/.gitignore index 5489f4321..76acd2c3a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,5 @@ obj/ *.user *.cache *.trx -Scripts/ packages/ TestResults/ diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js new file mode 100644 index 000000000..c5c4cc7de --- /dev/null +++ b/src/Core/Scripts/Runtime.js @@ -0,0 +1,49 @@ +//! Script# Core Runtime +//! More information at http://scriptsharp.com +//! + +define('ss', [], function() { +"use strict"; + +// TODO: Inline and remove +function isUndefined(o) { + return (o === undefined); +} + +// TODO: Inline and remove +function isNull(o) { + return (o === null); +} + +// TODO: Use !isValue +function isNullOrUndefined(o) { + return (o === null) || (o === undefined); +} + +function isValue(o) { + return (o !== null) && (o !== undefined); +} + +function extend(o, items) { + for (var n in items) { + o[n] = items[n]; + } + return o; +} + +#include "Runtime\Console.js" +#include "Runtime\TypeSystem.js" + +var ss = module('ss'); +return extend(ss, { + version: '0.7.6.0', + + isUndefined: isUndefined, + isNull: isNull, + isNullOrUndefined: isNullOrUndefined, + isValue: isValue, + + module: module +}); + +}); diff --git a/src/Core/Scripts/Runtime/Console.js b/src/Core/Scripts/Runtime/Console.js new file mode 100644 index 000000000..baec9e210 --- /dev/null +++ b/src/Core/Scripts/Runtime/Console.js @@ -0,0 +1,18 @@ +// Console + +if (!global.console) { + global.console = { + log: function() { + }, + assert: function() { + } + } +} + +console.fail = function(message) { + console.assert(false, message); + if (global.navigator && (global.navigator.userAgent.indexOf('MSIE') > 0)) { + eval('debugger;'); + } +} + diff --git a/src/Core/Scripts/Runtime/TypeSystem.js b/src/Core/Scripts/Runtime/TypeSystem.js new file mode 100644 index 000000000..28f62ae4c --- /dev/null +++ b/src/Core/Scripts/Runtime/TypeSystem.js @@ -0,0 +1,65 @@ +// Type System + +var _modules = {}; + +var _classMarker = 'class'; +var _interfaceMarker = 'interface'; + +function createType(typeName, typeInfo, typeRegistry) { + // The typeInfo is either an array of information representing + // classes and interfaces, or an object representing enums and resources + // or a function, representing a record factory. + + if (Array.isArray(typeInfo)) { + var type = typeInfo[0]; + + // A class is minimally the class type and an object representing + // its prototype members, and optionally the base type, and references + // to interfaces implemented by the class. + if (typeInfo.length >= 2) { + var baseType = typeInfo[2]; + if (baseType) { + // Chain the prototype of the base type (using an anonymous type + // in case the base class is not creatable, or has side-effects). + var anonymous = function() {}; + anonymous.prototype = baseType.prototype; + type.prototype = new anonymous(); + type.prototype.constructor = type; + } + + // Add the type's prototype members if there are any + typeInfo[1] && extend(type.prototype, typeInfo[1]); + + type.$base = baseType || Object; + type.$interfaces = typeInfo.slice(3); + type.$type = _classMarker; + } + else { + type.$type = _interfaceMarker; + } + + return typeRegistry[typeName] = type; + } + + return typeInfo; +} + +function module(name, implementation, exports) { + var registry = _modules[name] = {}; + + if (implementation) { + for (var typeName in implementation) { + createType(typeName, implementation[typeName], registry); + } + } + + var api = {}; + if (exports) { + for (var typeName in exports) { + api[typeName] = createType(typeName, exports[typeName], registry); + } + } + + return api; +} + diff --git a/src/Core/Scripts/Scripts.csproj b/src/Core/Scripts/Scripts.csproj new file mode 100644 index 000000000..85b3bad1b --- /dev/null +++ b/src/Core/Scripts/Scripts.csproj @@ -0,0 +1,30 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {8780581F-7C26-4B64-9236-BA1C458DF36E} + ..\..\..\tools\bin + + + ..\..\..\bin\Debug\ + + + ..\..\..\bin\Release\ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ScriptSharp.sln b/src/ScriptSharp.sln index 93cf128d8..ed90c47b3 100644 --- a/src/ScriptSharp.sln +++ b/src/ScriptSharp.sln @@ -57,6 +57,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Other", "Other", "{BB2DB888 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compiler", "Core\Compiler\Compiler.csproj", "{9F14036F-673F-418E-B817-7E2289D7F3F6}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scripts", "Core\Scripts\Scripts.csproj", "{8780581F-7C26-4B64-9236-BA1C458DF36E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|.NET = Debug|.NET @@ -69,42 +71,18 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Debug|.NET.ActiveCfg = Debug|Any CPU - {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Debug|x86.ActiveCfg = Debug|Any CPU - {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Release|.NET.ActiveCfg = Release|Any CPU - {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Release|Any CPU.Build.0 = Release|Any CPU - {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Release|x86.ActiveCfg = Release|Any CPU - {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Debug|.NET.ActiveCfg = Debug|Any CPU - {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Debug|x86.ActiveCfg = Debug|Any CPU - {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Release|.NET.ActiveCfg = Release|Any CPU - {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Release|Any CPU.Build.0 = Release|Any CPU - {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Release|x86.ActiveCfg = Release|Any CPU - {31456150-1093-407F-9231-58D0F663945D}.Debug|.NET.ActiveCfg = Debug|Any CPU - {31456150-1093-407F-9231-58D0F663945D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {31456150-1093-407F-9231-58D0F663945D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {31456150-1093-407F-9231-58D0F663945D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {31456150-1093-407F-9231-58D0F663945D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {31456150-1093-407F-9231-58D0F663945D}.Debug|x86.ActiveCfg = Debug|Any CPU - {31456150-1093-407F-9231-58D0F663945D}.Release|.NET.ActiveCfg = Release|Any CPU - {31456150-1093-407F-9231-58D0F663945D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {31456150-1093-407F-9231-58D0F663945D}.Release|Any CPU.Build.0 = Release|Any CPU - {31456150-1093-407F-9231-58D0F663945D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {31456150-1093-407F-9231-58D0F663945D}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {31456150-1093-407F-9231-58D0F663945D}.Release|x86.ActiveCfg = Release|Any CPU + {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Debug|.NET.ActiveCfg = Debug|Any CPU + {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Debug|x86.ActiveCfg = Debug|Any CPU + {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Release|.NET.ActiveCfg = Release|Any CPU + {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Release|Any CPU.Build.0 = Release|Any CPU + {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Release|x86.ActiveCfg = Release|Any CPU {3681A9A8-FC40-4125-B842-7775713C8DCE}.Debug|.NET.ActiveCfg = Debug|Any CPU {3681A9A8-FC40-4125-B842-7775713C8DCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3681A9A8-FC40-4125-B842-7775713C8DCE}.Debug|Any CPU.Build.0 = Debug|Any CPU @@ -117,6 +95,54 @@ Global {3681A9A8-FC40-4125-B842-7775713C8DCE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {3681A9A8-FC40-4125-B842-7775713C8DCE}.Release|Mixed Platforms.Build.0 = Release|Any CPU {3681A9A8-FC40-4125-B842-7775713C8DCE}.Release|x86.ActiveCfg = Release|Any CPU + {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Debug|.NET.ActiveCfg = Debug|Any CPU + {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Debug|x86.ActiveCfg = Debug|Any CPU + {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Release|.NET.ActiveCfg = Release|Any CPU + {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Release|Any CPU.Build.0 = Release|Any CPU + {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43}.Release|x86.ActiveCfg = Release|Any CPU + {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Debug|.NET.ActiveCfg = Debug|Any CPU + {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Debug|x86.ActiveCfg = Debug|Any CPU + {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Release|.NET.ActiveCfg = Release|Any CPU + {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Release|Any CPU.Build.0 = Release|Any CPU + {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Release|x86.ActiveCfg = Release|Any CPU + {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Debug|.NET.ActiveCfg = Debug|Any CPU + {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Debug|x86.ActiveCfg = Debug|Any CPU + {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Release|.NET.ActiveCfg = Release|Any CPU + {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Release|Any CPU.Build.0 = Release|Any CPU + {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Release|x86.ActiveCfg = Release|Any CPU + {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Debug|.NET.ActiveCfg = Debug|Any CPU + {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Debug|x86.ActiveCfg = Debug|Any CPU + {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Release|.NET.ActiveCfg = Release|Any CPU + {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Release|Any CPU.Build.0 = Release|Any CPU + {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Release|x86.ActiveCfg = Release|Any CPU {36D4B098-A21C-4725-ACD3-400922885F38}.Debug|.NET.ActiveCfg = Debug|Any CPU {36D4B098-A21C-4725-ACD3-400922885F38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {36D4B098-A21C-4725-ACD3-400922885F38}.Debug|Any CPU.Build.0 = Debug|Any CPU @@ -129,6 +155,54 @@ Global {36D4B098-A21C-4725-ACD3-400922885F38}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {36D4B098-A21C-4725-ACD3-400922885F38}.Release|Mixed Platforms.Build.0 = Release|Any CPU {36D4B098-A21C-4725-ACD3-400922885F38}.Release|x86.ActiveCfg = Release|Any CPU + {31456150-1093-407F-9231-58D0F663945D}.Debug|.NET.ActiveCfg = Debug|Any CPU + {31456150-1093-407F-9231-58D0F663945D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {31456150-1093-407F-9231-58D0F663945D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {31456150-1093-407F-9231-58D0F663945D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {31456150-1093-407F-9231-58D0F663945D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {31456150-1093-407F-9231-58D0F663945D}.Debug|x86.ActiveCfg = Debug|Any CPU + {31456150-1093-407F-9231-58D0F663945D}.Release|.NET.ActiveCfg = Release|Any CPU + {31456150-1093-407F-9231-58D0F663945D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {31456150-1093-407F-9231-58D0F663945D}.Release|Any CPU.Build.0 = Release|Any CPU + {31456150-1093-407F-9231-58D0F663945D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {31456150-1093-407F-9231-58D0F663945D}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {31456150-1093-407F-9231-58D0F663945D}.Release|x86.ActiveCfg = Release|Any CPU + {B87E403B-354D-47A1-9876-14C618A80A41}.Debug|.NET.ActiveCfg = Debug|Any CPU + {B87E403B-354D-47A1-9876-14C618A80A41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B87E403B-354D-47A1-9876-14C618A80A41}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B87E403B-354D-47A1-9876-14C618A80A41}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {B87E403B-354D-47A1-9876-14C618A80A41}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {B87E403B-354D-47A1-9876-14C618A80A41}.Debug|x86.ActiveCfg = Debug|Any CPU + {B87E403B-354D-47A1-9876-14C618A80A41}.Release|.NET.ActiveCfg = Release|Any CPU + {B87E403B-354D-47A1-9876-14C618A80A41}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B87E403B-354D-47A1-9876-14C618A80A41}.Release|Any CPU.Build.0 = Release|Any CPU + {B87E403B-354D-47A1-9876-14C618A80A41}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {B87E403B-354D-47A1-9876-14C618A80A41}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {B87E403B-354D-47A1-9876-14C618A80A41}.Release|x86.ActiveCfg = Release|Any CPU + {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Debug|.NET.ActiveCfg = Debug|Any CPU + {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Debug|x86.ActiveCfg = Debug|Any CPU + {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Release|.NET.ActiveCfg = Release|Any CPU + {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Release|Any CPU.Build.0 = Release|Any CPU + {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {1772A38C-7204-42DC-B81D-6C74D17A4F66}.Release|x86.ActiveCfg = Release|Any CPU + {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Debug|.NET.ActiveCfg = Debug|Any CPU + {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Debug|x86.ActiveCfg = Debug|Any CPU + {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Release|.NET.ActiveCfg = Release|Any CPU + {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Release|Any CPU.Build.0 = Release|Any CPU + {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Release|x86.ActiveCfg = Release|Any CPU {4123C976-739E-42A2-87FB-E04D163BC99C}.Debug|.NET.ActiveCfg = Debug|x86 {4123C976-739E-42A2-87FB-E04D163BC99C}.Debug|Any CPU.ActiveCfg = Debug|x86 {4123C976-739E-42A2-87FB-E04D163BC99C}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 @@ -141,54 +215,6 @@ Global {4123C976-739E-42A2-87FB-E04D163BC99C}.Release|Mixed Platforms.Build.0 = Debug|x86 {4123C976-739E-42A2-87FB-E04D163BC99C}.Release|x86.ActiveCfg = Debug|x86 {4123C976-739E-42A2-87FB-E04D163BC99C}.Release|x86.Build.0 = Debug|x86 - {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Debug|.NET.ActiveCfg = Debug|Any CPU - {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Debug|x86.ActiveCfg = Debug|Any CPU - {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Release|.NET.ActiveCfg = Release|Any CPU - {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Release|Any CPU.Build.0 = Release|Any CPU - {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {4A9F7CE0-5A45-4B28-AD01-05528709B6E4}.Release|x86.ActiveCfg = Release|Any CPU - {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|.NET.ActiveCfg = Debug|Any CPU - {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|x86.ActiveCfg = Debug|Any CPU - {824C1FEC-2455-4183-AFC6-891EDB88213A}.Release|.NET.ActiveCfg = Release|Any CPU - {824C1FEC-2455-4183-AFC6-891EDB88213A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {824C1FEC-2455-4183-AFC6-891EDB88213A}.Release|Any CPU.Build.0 = Release|Any CPU - {824C1FEC-2455-4183-AFC6-891EDB88213A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {824C1FEC-2455-4183-AFC6-891EDB88213A}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {824C1FEC-2455-4183-AFC6-891EDB88213A}.Release|x86.ActiveCfg = Release|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|.NET.ActiveCfg = Debug|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|x86.ActiveCfg = Debug|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|.NET.ActiveCfg = Release|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|Any CPU.Build.0 = Release|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|x86.ActiveCfg = Release|Any CPU - {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Debug|.NET.ActiveCfg = Debug|Any CPU - {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Debug|x86.ActiveCfg = Debug|Any CPU - {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Release|.NET.ActiveCfg = Release|Any CPU - {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Release|Any CPU.Build.0 = Release|Any CPU - {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {9600C55B-E14E-45EA-92C6-F453B19F5D7F}.Release|x86.ActiveCfg = Release|Any CPU {967A6FD7-E14B-4DB0-81D9-86E0DC12291A}.Debug|.NET.ActiveCfg = Debug|Any CPU {967A6FD7-E14B-4DB0-81D9-86E0DC12291A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {967A6FD7-E14B-4DB0-81D9-86E0DC12291A}.Debug|Any CPU.Build.0 = Debug|Any CPU @@ -201,6 +227,30 @@ Global {967A6FD7-E14B-4DB0-81D9-86E0DC12291A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {967A6FD7-E14B-4DB0-81D9-86E0DC12291A}.Release|Mixed Platforms.Build.0 = Release|Any CPU {967A6FD7-E14B-4DB0-81D9-86E0DC12291A}.Release|x86.ActiveCfg = Release|Any CPU + {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|.NET.ActiveCfg = Debug|Any CPU + {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|x86.ActiveCfg = Debug|Any CPU + {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|.NET.ActiveCfg = Release|Any CPU + {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|Any CPU.Build.0 = Release|Any CPU + {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|x86.ActiveCfg = Release|Any CPU + {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|.NET.ActiveCfg = Debug|Any CPU + {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|x86.ActiveCfg = Debug|Any CPU + {824C1FEC-2455-4183-AFC6-891EDB88213A}.Release|.NET.ActiveCfg = Release|Any CPU + {824C1FEC-2455-4183-AFC6-891EDB88213A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {824C1FEC-2455-4183-AFC6-891EDB88213A}.Release|Any CPU.Build.0 = Release|Any CPU + {824C1FEC-2455-4183-AFC6-891EDB88213A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {824C1FEC-2455-4183-AFC6-891EDB88213A}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {824C1FEC-2455-4183-AFC6-891EDB88213A}.Release|x86.ActiveCfg = Release|Any CPU {9F14036F-673F-418E-B817-7E2289D7F3F6}.Debug|.NET.ActiveCfg = Debug|Any CPU {9F14036F-673F-418E-B817-7E2289D7F3F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9F14036F-673F-418E-B817-7E2289D7F3F6}.Debug|Any CPU.Build.0 = Debug|Any CPU @@ -213,74 +263,39 @@ Global {9F14036F-673F-418E-B817-7E2289D7F3F6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {9F14036F-673F-418E-B817-7E2289D7F3F6}.Release|Mixed Platforms.Build.0 = Release|Any CPU {9F14036F-673F-418E-B817-7E2289D7F3F6}.Release|x86.ActiveCfg = Release|Any CPU - {B87E403B-354D-47A1-9876-14C618A80A41}.Debug|.NET.ActiveCfg = Debug|Any CPU - {B87E403B-354D-47A1-9876-14C618A80A41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B87E403B-354D-47A1-9876-14C618A80A41}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B87E403B-354D-47A1-9876-14C618A80A41}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {B87E403B-354D-47A1-9876-14C618A80A41}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {B87E403B-354D-47A1-9876-14C618A80A41}.Debug|x86.ActiveCfg = Debug|Any CPU - {B87E403B-354D-47A1-9876-14C618A80A41}.Release|.NET.ActiveCfg = Release|Any CPU - {B87E403B-354D-47A1-9876-14C618A80A41}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B87E403B-354D-47A1-9876-14C618A80A41}.Release|Any CPU.Build.0 = Release|Any CPU - {B87E403B-354D-47A1-9876-14C618A80A41}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {B87E403B-354D-47A1-9876-14C618A80A41}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {B87E403B-354D-47A1-9876-14C618A80A41}.Release|x86.ActiveCfg = Release|Any CPU - {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Debug|.NET.ActiveCfg = Debug|Any CPU - {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Debug|x86.ActiveCfg = Debug|Any CPU - {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Release|.NET.ActiveCfg = Release|Any CPU - {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Release|Any CPU.Build.0 = Release|Any CPU - {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A}.Release|x86.ActiveCfg = Release|Any CPU - {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Debug|.NET.ActiveCfg = Debug|Any CPU - {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Debug|x86.ActiveCfg = Debug|Any CPU - {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Release|.NET.ActiveCfg = Release|Any CPU - {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Release|Any CPU.Build.0 = Release|Any CPU - {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {BE1E0A21-F6C0-4698-B405-66FC2BB289F4}.Release|x86.ActiveCfg = Release|Any CPU - {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Debug|.NET.ActiveCfg = Debug|Any CPU - {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Debug|x86.ActiveCfg = Debug|Any CPU - {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Release|.NET.ActiveCfg = Release|Any CPU - {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Release|Any CPU.Build.0 = Release|Any CPU - {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {DCA0235F-88C1-43A0-A8DB-FF765D344E06}.Release|x86.ActiveCfg = Release|Any CPU + {8780581F-7C26-4B64-9236-BA1C458DF36E}.Debug|.NET.ActiveCfg = Debug|Any CPU + {8780581F-7C26-4B64-9236-BA1C458DF36E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8780581F-7C26-4B64-9236-BA1C458DF36E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8780581F-7C26-4B64-9236-BA1C458DF36E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {8780581F-7C26-4B64-9236-BA1C458DF36E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {8780581F-7C26-4B64-9236-BA1C458DF36E}.Debug|x86.ActiveCfg = Debug|Any CPU + {8780581F-7C26-4B64-9236-BA1C458DF36E}.Release|.NET.ActiveCfg = Release|Any CPU + {8780581F-7C26-4B64-9236-BA1C458DF36E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8780581F-7C26-4B64-9236-BA1C458DF36E}.Release|Any CPU.Build.0 = Release|Any CPU + {8780581F-7C26-4B64-9236-BA1C458DF36E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {8780581F-7C26-4B64-9236-BA1C458DF36E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {8780581F-7C26-4B64-9236-BA1C458DF36E}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {1772A38C-7204-42DC-B81D-6C74D17A4F66} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} - {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} - {31456150-1093-407F-9231-58D0F663945D} = {37239BB8-2FA4-4831-A7EA-AF89D74EA10E} {3681A9A8-FC40-4125-B842-7775713C8DCE} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} - {36D4B098-A21C-4725-ACD3-400922885F38} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} - {4123C976-739E-42A2-87FB-E04D163BC99C} = {BB2DB888-0F52-4CB5-9625-9D99A33DCE4F} {4A9F7CE0-5A45-4B28-AD01-05528709B6E4} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} - {824C1FEC-2455-4183-AFC6-891EDB88213A} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} - {8780581F-7C26-4B64-9235-BA1C458DF36E} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} + {2E5D9DFC-97BD-4652-B09A-B88E6ECDEF43} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} + {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} {9600C55B-E14E-45EA-92C6-F453B19F5D7F} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} + {DCA0235F-88C1-43A0-A8DB-FF765D344E06} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} {967A6FD7-E14B-4DB0-81D9-86E0DC12291A} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} + {824C1FEC-2455-4183-AFC6-891EDB88213A} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} + {1772A38C-7204-42DC-B81D-6C74D17A4F66} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} + {BE1E0A21-F6C0-4698-B405-66FC2BB289F4} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} + {36D4B098-A21C-4725-ACD3-400922885F38} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} + {8780581F-7C26-4B64-9235-BA1C458DF36E} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} {9F14036F-673F-418E-B817-7E2289D7F3F6} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} + {8780581F-7C26-4B64-9236-BA1C458DF36E} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} + {31456150-1093-407F-9231-58D0F663945D} = {37239BB8-2FA4-4831-A7EA-AF89D74EA10E} {B87E403B-354D-47A1-9876-14C618A80A41} = {37239BB8-2FA4-4831-A7EA-AF89D74EA10E} - {BA1CDDAF-7E54-4DC0-A4D3-AEF05B975A4A} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} - {BE1E0A21-F6C0-4698-B405-66FC2BB289F4} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} - {DCA0235F-88C1-43A0-A8DB-FF765D344E06} = {5D0FD0F6-498E-4126-A297-97B7763DD0AB} + {4123C976-739E-42A2-87FB-E04D163BC99C} = {BB2DB888-0F52-4CB5-9625-9D99A33DCE4F} EndGlobalSection EndGlobal From 5cd061d8233586a8f4b072aa8e380dce9c1a4e82 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 9 Sep 2012 11:49:28 -0700 Subject: [PATCH 003/251] Stop minimizing type names --- src/Core/Compiler/Compiler/MetadataBuilder.cs | 12 -- .../ScriptModel/Symbols/SymbolInternalizer.cs | 32 ++-- .../ScriptModel/Symbols/SymbolObfuscator.cs | 56 +------ .../Compiler/ScriptModel/Symbols/SymbolSet.cs | 10 -- src/Core/CoreLib/ScriptMetadata.cs | 24 --- .../TestCases/Basic/DocComments/Baseline.txt | 12 +- tests/TestCases/Basic/Metadata/Baseline.txt | 34 ++--- .../TestCases/Basic/Minimization/Baseline.txt | 137 ++++++++---------- tests/TestCases/Basic/Resources/Baseline.txt | 6 +- tests/TestCases/Basic/Template/Baseline.txt | 2 +- .../Expression/EnumToString/MinBaseline.txt | 16 +- tests/TestCases/Type/Partials/Baseline.txt | 26 ++-- 12 files changed, 123 insertions(+), 244 deletions(-) diff --git a/src/Core/Compiler/Compiler/MetadataBuilder.cs b/src/Core/Compiler/Compiler/MetadataBuilder.cs index 17f9447f4..26d1c7abd 100644 --- a/src/Core/Compiler/Compiler/MetadataBuilder.cs +++ b/src/Core/Compiler/Compiler/MetadataBuilder.cs @@ -297,18 +297,6 @@ public ICollection BuildMetadata(ParseNodeList compilationUnits, Sym } symbols.ScriptName = scriptName; - string scriptPrefix = GetAssemblyScriptPrefix(compilationUnits); - if (String.IsNullOrEmpty(scriptPrefix) == false) { - if (Utility.IsValidIdentifier(scriptPrefix) == false) { - string errorMessage = "The ScriptQualifier attribute referenced an invalid prefix '{0}'. Script prefix must be valid identifiers."; - _errorHandler.ReportError(String.Format(errorMessage, scriptPrefix), String.Empty); - } - } - else { - scriptPrefix = scriptName.Replace(".", String.Empty); - } - symbols.ScriptPrefix = scriptPrefix; - string assemblyScriptNamespace = GetAssemblyScriptNamespace(compilationUnits); List types = new List(); diff --git a/src/Core/Compiler/ScriptModel/Symbols/SymbolInternalizer.cs b/src/Core/Compiler/ScriptModel/Symbols/SymbolInternalizer.cs index 8a6145ffb..138f1f386 100644 --- a/src/Core/Compiler/ScriptModel/Symbols/SymbolInternalizer.cs +++ b/src/Core/Compiler/ScriptModel/Symbols/SymbolInternalizer.cs @@ -51,35 +51,23 @@ private string TransformMember(MemberSymbol memberSymbol) { } } - private string TransformType(TypeSymbol typeSymbol, out bool transformChildren) { - transformChildren = (typeSymbol.Type != SymbolType.Interface) && - (typeSymbol.Type != SymbolType.Delegate); - - if ((typeSymbol.Type == SymbolType.Enumeration) && - ((EnumerationSymbol)typeSymbol).UseNamedValues) { - // If the enum uses named values, then don't transform, as its - // unlikely the code wants to use some random generated name as the - // named value. - transformChildren = false; - } - - if ((typeSymbol.IsPublic == false) && typeSymbol.IsTransformAllowed) { - return GenerateName(typeSymbol.Name); - } - - return null; - } - #region Implementation of ISymbolTransformer string ISymbolTransformer.TransformSymbol(Symbol symbol, out bool transformChildren) { transformChildren = false; if (symbol is TypeSymbol) { - if ((symbol.Type == SymbolType.Class) && ((ClassSymbol)symbol).IsTestType) { - return null; + transformChildren = (symbol.Type != SymbolType.Interface) && + (symbol.Type != SymbolType.Delegate); + + if ((symbol.Type == SymbolType.Enumeration) && + ((EnumerationSymbol)symbol).UseNamedValues) { + // If the enum uses named values, then don't transform, as its + // unlikely the code wants to use some random generated name as the + // named value. + transformChildren = false; } - return TransformType((TypeSymbol)symbol, out transformChildren); + return null; } else if (symbol is MemberSymbol) { return TransformMember((MemberSymbol)symbol); diff --git a/src/Core/Compiler/ScriptModel/Symbols/SymbolObfuscator.cs b/src/Core/Compiler/ScriptModel/Symbols/SymbolObfuscator.cs index e50a4c828..f85de90ce 100644 --- a/src/Core/Compiler/ScriptModel/Symbols/SymbolObfuscator.cs +++ b/src/Core/Compiler/ScriptModel/Symbols/SymbolObfuscator.cs @@ -10,8 +10,6 @@ namespace ScriptSharp.ScriptModel { internal sealed class SymbolObfuscator : ISymbolTransformer { - private int _count; - private static string GenerateName(int index, int offset) { if (offset == 0) { return String.Format("${0:X}", index); @@ -19,28 +17,6 @@ private static string GenerateName(int index, int offset) { return String.Format("${0:X}_{1:X}", offset, index); } - private string TransformLocal(LocalSymbol localSymbol) { - int depth = 0; - - AnonymousMethodSymbol parentMethod = localSymbol.Parent as AnonymousMethodSymbol; - if (parentMethod != null) { - // If an anonymous method contains a local variable with the - // same name as a variable in the containing method, they will - // conflict at runtime, i.e. the value in the inner method - // will override the value of the outer method when it is run. - // Note that right now we aren't seeing if there is actually a conflict. - // We're always qualifying the inner variable with a depth prefix. - // REVIEW: Should we try to optimize when we qualify? - - depth = parentMethod.Depth; - } - - string transformedName = GenerateName(_count, depth); - _count++; - - return transformedName; - } - private string TransformMember(MemberSymbol memberSymbol) { if ((memberSymbol.InterfaceMember != null) || (memberSymbol.Name.Length < 3) || @@ -110,44 +86,18 @@ private string TransformMember(MemberSymbol memberSymbol) { return null; } - private string TransformType(TypeSymbol typeSymbol, out bool transformChildren) { - string transformedName = null; - transformChildren = (typeSymbol.Type != SymbolType.Interface) && - (typeSymbol.Type != SymbolType.Delegate); - - if ((typeSymbol.IsPublic == false) && typeSymbol.IsTransformAllowed) { - string prefix = typeSymbol.SymbolSet.ScriptPrefix; - - string name = String.Format("{0}${1:X}", prefix, _count); - if ((typeSymbol.Name.Length + 1) < name.Length) { - transformedName = "_" + typeSymbol.Name; - } - else { - transformedName = name; - _count++; - } - } - - return transformedName; - } - #region Implementation of ISymbolTransformer string ISymbolTransformer.TransformSymbol(Symbol symbol, out bool transformChildren) { transformChildren = false; if (symbol is TypeSymbol) { - if ((symbol.Type == SymbolType.Class) && ((ClassSymbol)symbol).IsTestType) { - return null; - } - - return TransformType((TypeSymbol)symbol, out transformChildren); + transformChildren = (symbol.Type != SymbolType.Interface) && + (symbol.Type != SymbolType.Delegate); + return null; } else if (symbol is MemberSymbol) { return TransformMember((MemberSymbol)symbol); } - else if (symbol is LocalSymbol) { - return TransformLocal((LocalSymbol)symbol); - } return null; } diff --git a/src/Core/Compiler/ScriptModel/Symbols/SymbolSet.cs b/src/Core/Compiler/ScriptModel/Symbols/SymbolSet.cs index 469b0c028..0b1abb8a9 100644 --- a/src/Core/Compiler/ScriptModel/Symbols/SymbolSet.cs +++ b/src/Core/Compiler/ScriptModel/Symbols/SymbolSet.cs @@ -26,7 +26,6 @@ internal sealed class SymbolSet : ISymbolTable { private MemberSymbol _entryPoint; private string _scriptName; - private string _scriptPrefix; private Dictionary> _resources; @@ -81,15 +80,6 @@ public string ScriptName { } } - public string ScriptPrefix { - get { - return _scriptPrefix; - } - set { - _scriptPrefix = value; - } - } - public NamespaceSymbol SystemNamespace { get { return _systemNamespace; diff --git a/src/Core/CoreLib/ScriptMetadata.cs b/src/Core/CoreLib/ScriptMetadata.cs index 1d4d51295..a082080e9 100644 --- a/src/Core/CoreLib/ScriptMetadata.cs +++ b/src/Core/CoreLib/ScriptMetadata.cs @@ -56,30 +56,6 @@ public string Name { } } - /// - /// Provides a prefix to use when generating types internal to this assembly so that - /// they can be unique within a given a script namespace. - /// The specified prefix overrides the script name provided in the ScriptAssembly - /// attribute. - /// - [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] - [NonScriptable] - [Imported] - public sealed class ScriptQualifierAttribute : Attribute { - - private string _prefix; - - public ScriptQualifierAttribute(string prefix) { - _prefix = prefix; - } - - public string Prefix { - get { - return _prefix; - } - } - } - /// /// This attribute indicates that the namespace of type within a system assembly /// should be ignored at script generation time. It is useful for creating namespaces diff --git a/tests/TestCases/Basic/DocComments/Baseline.txt b/tests/TestCases/Basic/DocComments/Baseline.txt index 76c48625e..9bec2a60a 100644 --- a/tests/TestCases/Basic/DocComments/Baseline.txt +++ b/tests/TestCases/Basic/DocComments/Baseline.txt @@ -260,9 +260,9 @@ test.DerivedClass.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test._internalClass +// test.InternalClass -test._internalClass = function test__internalClass() { +test.InternalClass = function test_InternalClass() { /// /// An internal class. /// @@ -270,9 +270,9 @@ test._internalClass = function test__internalClass() { //////////////////////////////////////////////////////////////////////////////// -// test._internalClassWithNoComments +// test.InternalClassWithNoComments -test._internalClassWithNoComments = function test__internalClassWithNoComments() { +test.InternalClassWithNoComments = function test_InternalClassWithNoComments() { } @@ -288,7 +288,7 @@ window.run = function test_GlobalMethodsClass$run() { test.BaseClass.registerClass('test.BaseClass'); test.DerivedClass.registerClass('test.DerivedClass', test.BaseClass); -test._internalClass.registerClass('test._internalClass'); -test._internalClassWithNoComments.registerClass('test._internalClassWithNoComments'); +test.InternalClass.registerClass('test.InternalClass'); +test.InternalClassWithNoComments.registerClass('test.InternalClassWithNoComments'); test.BaseClass.constantField = 3; test.BaseClass.staticField = null; diff --git a/tests/TestCases/Basic/Metadata/Baseline.txt b/tests/TestCases/Basic/Metadata/Baseline.txt index d880a5d98..7c45a622a 100644 --- a/tests/TestCases/Basic/Metadata/Baseline.txt +++ b/tests/TestCases/Basic/Metadata/Baseline.txt @@ -4083,13 +4083,13 @@ test.Mode.registerEnum('test.Mode', false); //////////////////////////////////////////////////////////////////////////////// -// test._iFoo +// test.IFoo -test._iFoo = function() { }; -test._iFoo.prototype = { +test.IFoo = function() { }; +test.IFoo.prototype = { } -test._iFoo.registerInterface('test._iFoo'); +test.IFoo.registerInterface('test.IFoo'); //////////////////////////////////////////////////////////////////////////////// @@ -4103,9 +4103,9 @@ test.IApp.registerInterface('test.IApp'); //////////////////////////////////////////////////////////////////////////////// -// test._point +// test.Point -test.$create__point = function test__point(x, y) { +test.$create_Point = function test_Point(x, y) { var $o = { }; $o.x = x; $o.y = y; @@ -4143,37 +4143,37 @@ test.App.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test._appHelper +// test.AppHelper -test._appHelper = function test__appHelper() { +test.AppHelper = function test_AppHelper() { } -test._appHelper.prototype = { +test.AppHelper.prototype = { - get_prop1: function test__appHelper$get_prop1() { + get_prop1: function test_AppHelper$get_prop1() { return 0; }, - get_prop2: function test__appHelper$get_prop2() { + get_prop2: function test_AppHelper$get_prop2() { return 0; }, - set_prop2: function test__appHelper$set_prop2(value) { + set_prop2: function test_AppHelper$set_prop2(value) { return value; }, - _showHelp: function test__appHelper$_showHelp() { + _showHelp: function test_AppHelper$_showHelp() { }, - get_item: function test__appHelper$get_item(name) { + get_item: function test_AppHelper$get_item(name) { return 0; } } //////////////////////////////////////////////////////////////////////////////// -// test._util +// test.Util -window._showHelp = function test__util$_showHelp() { +window._showHelp = function test_Util$_showHelp() { } test.App.registerClass('test.App', null, test.IApp); -test._appHelper.registerClass('test._appHelper'); +test.AppHelper.registerClass('test.AppHelper'); diff --git a/tests/TestCases/Basic/Minimization/Baseline.txt b/tests/TestCases/Basic/Minimization/Baseline.txt index 01dc79325..455f92d03 100644 --- a/tests/TestCases/Basic/Minimization/Baseline.txt +++ b/tests/TestCases/Basic/Minimization/Baseline.txt @@ -5,16 +5,7 @@ Minimization Map Member '_intVal2' renamed to '$1_1' Member '_intVal3' renamed to '$1_2' Member '_strVal' renamed to '$1_3' -Type 'BasicTests.ABC' renamed to '_ABC' Member 'Alpha' renamed to '$0' -Type 'BasicTests.AppHelper' renamed to 'test$3' -Type 'BasicTests.Bar' renamed to '_Bar' -Type 'BasicTests.Bar2' renamed to '_Bar2' -Type 'BasicTests.BarCustom2' renamed to 'test$6' -Type 'BasicTests.BarEx' renamed to 'test$5' -Type 'BasicTests.BaseBaseClass' renamed to 'test$1' -Type 'BasicTests.BaseClass' renamed to 'test$4' -Type 'BasicTests.DerivedClass' renamed to 'test$7' Member 'Dispose' renamed to '$1' Member 'DoStuff' renamed to '$0' Member 'DoStuff' renamed to '$0' @@ -25,11 +16,7 @@ Type 'BasicTests.DerivedClass' renamed to 'test$7' Member 'DoStuffInternal' renamed to '$3' Member 'ExecuteHandler' renamed to '$1' Member 'Foo' renamed to '$2' -Type 'BasicTests.IApp' renamed to '_IApp' Member 'Initialize' renamed to '$0' -Type 'BasicTests.MaskTextBox' renamed to 'test$8' -Type 'BasicTests.MyData' renamed to 'test$2' -Type 'BasicTests.MyMode' renamed to 'test$0' Member 'Numeric' renamed to '$1' Member 'OnClicked' renamed to '$3_1' Member 'OnValueChanged' renamed to '$1_6' @@ -59,11 +46,11 @@ test.AppFlags.prototype = { test.AppFlags.registerEnum('test.AppFlags', false); -test._IApp = function() { }; -test._IApp.registerInterface('test._IApp'); +test.IApp = function() { }; +test.IApp.registerInterface('test.IApp'); -test.$create_test$2 = function(a, b) { +test.$create_MyData = function(a, b) { var $o = { }; $o.$0 = a; $o.$1 = b; @@ -76,8 +63,8 @@ window.run = function() { test.App = function() { - var $0 = new test.test$3(); - $0.$0(); + var helper = new test.AppHelper(); + helper.$0(); } test.App.prototype = { @@ -92,18 +79,18 @@ test.App.prototype = { } -test.test$3 = function() { +test.AppHelper = function() { } -test.test$3.prototype = { +test.AppHelper.prototype = { $0: function() { } } -test._Bar = function() { +test.Bar = function() { } -test._Bar.prototype = { +test.Bar.prototype = { $0: function() { }, @@ -117,25 +104,25 @@ test._Bar.prototype = { } -test._Bar2 = function() { - test._Bar2.initializeBase(this); +test.Bar2 = function() { + test.Bar2.initializeBase(this); } -test.test$5 = function() { - test.test$5.initializeBase(this); +test.BarEx = function() { + test.BarEx.initializeBase(this); } -test.test$5.prototype = { +test.BarEx.prototype = { $2: function() { - var $0 = 1; + var mode = 1; }, $0: function() { this.$2(); - test.test$5.callBaseMethod(this, '$0'); - var $0 = test.$create_test$2('a', 'b'); - $0.$0 = $0.$1; + test.BarEx.callBaseMethod(this, '$0'); + var d = test.$create_MyData('a', 'b'); + d.$0 = d.$1; }, $3: function($p0) { @@ -143,17 +130,17 @@ test.test$5.prototype = { }, $4: function($p0) { - var $0 = $p0 + 1; - var $1 = $p0.toString(); - var $2 = 0; + var numericValue = $p0 + 1; + var stringValue = $p0.toString(); + var value = 0; this.$1(ss.Delegate.create(this, function($p1_0, $p1_1) { this.$1(function($p2_0, $p2_1) { - var $2_0 = 11; + var value = 11; return $p2_0; }); - var $1_0 = 10; - var $1_1 = 11; - return $0 + $p1_0 + $1 + $p1_1 + $1_0; + var value = 10; + var value2 = 11; + return numericValue + $p1_0 + stringValue + $p1_1 + value; })); }, @@ -161,33 +148,33 @@ test.test$5.prototype = { return 0; }, set_$5: function($p0) { - var $0 = $p0; + var x = $p0; return $p0; }, get_$6: function() { this.$1(ss.Delegate.create(this, function($p1_0, $p1_1) { this.$1(function($p2_0, $p2_1) { - var $2_0 = 11; + var value = 11; return $p2_0; }); - var $1_0 = 10; - var $1_1 = 11; - return $p1_0 + $p1_1 + $1_0; + var value = 10; + var value2 = 11; + return $p1_0 + $p1_1 + value; })); return 0; }, set_$6: function($p0) { - var $0 = $p0 + 1; - var $1 = $p0.toString(); + var numericValue = $p0 + 1; + var stringValue = $p0.toString(); this.$1(ss.Delegate.create(this, function($p1_0, $p1_1) { this.$1(function($p2_0, $p2_1) { - var $2_0 = 11; + var value1 = 11; return $p2_0; }); - var $1_0 = 10; - var $1_1 = 11; - return $0 + $p1_0 + $1 + $p1_1 + $p0 + $1_1; + var value2 = 10; + var value3 = 11; + return numericValue + $p1_0 + stringValue + $p1_1 + $p0 + value3; })); return $p0; } @@ -199,10 +186,10 @@ test.BarCustom = function() { } -test.test$6 = function() { - test.test$6.initializeBase(this); +test.BarCustom2 = function() { + test.BarCustom2.initializeBase(this); } -test.test$6.prototype = { +test.BarCustom2.prototype = { $2: function() { return 0; @@ -254,10 +241,10 @@ test.FooBehavior.prototype = { } -test.test$8 = function(e) { - test.test$8.initializeBase(this, [ e ]); +test.MaskTextBox = function(e) { + test.MaskTextBox.initializeBase(this, [ e ]); } -test.test$8.prototype = { +test.MaskTextBox.prototype = { $3_0: function() { }, @@ -267,50 +254,50 @@ test.test$8.prototype = { } -test.test$7 = function() { - test.test$7.initializeBase(this); +test.DerivedClass = function() { + test.DerivedClass.initializeBase(this); } -test.test$7.prototype = { +test.DerivedClass.prototype = { $2: function() { } } -test.test$4 = function() { - test.test$4.initializeBase(this); +test.BaseClass = function() { + test.BaseClass.initializeBase(this); } -test.test$4.prototype = { +test.BaseClass.prototype = { $1: function() { } } -test.test$1 = function() { +test.BaseBaseClass = function() { } -test.test$1.prototype = { +test.BaseBaseClass.prototype = { $0: function() { } } -test._ABC = function() { +test.ABC = function() { } test.App.registerClass('test.App'); -test.test$3.registerClass('test.test$3'); -test._Bar.registerClass('test._Bar'); -test._Bar2.registerClass('test._Bar2', test._Bar); -test.test$5.registerClass('test.test$5', test._Bar2); -test.BarCustom.registerClass('test.BarCustom', test._Bar); -test.test$6.registerClass('test.test$6', test.BarCustom); +test.AppHelper.registerClass('test.AppHelper'); +test.Bar.registerClass('test.Bar'); +test.Bar2.registerClass('test.Bar2', test.Bar); +test.BarEx.registerClass('test.BarEx', test.Bar2); +test.BarCustom.registerClass('test.BarCustom', test.Bar); +test.BarCustom2.registerClass('test.BarCustom2', test.BarCustom); test.FooBehavior.registerClass('test.FooBehavior', ScriptFX.Behavior); -test.test$8.registerClass('test.test$8', ScriptFX.TextBox); -test.test$1.registerClass('test.test$1'); -test.test$4.registerClass('test.test$4', test.test$1); -test.test$7.registerClass('test.test$7', test.test$4); -test._ABC.registerClass('test._ABC'); +test.MaskTextBox.registerClass('test.MaskTextBox', ScriptFX.TextBox); +test.BaseBaseClass.registerClass('test.BaseBaseClass'); +test.BaseClass.registerClass('test.BaseClass', test.BaseBaseClass); +test.DerivedClass.registerClass('test.DerivedClass', test.BaseClass); +test.ABC.registerClass('test.ABC'); test.FooBehavior.$1_3 = null; diff --git a/tests/TestCases/Basic/Resources/Baseline.txt b/tests/TestCases/Basic/Resources/Baseline.txt index 02edf7458..46a8f360a 100644 --- a/tests/TestCases/Basic/Resources/Baseline.txt +++ b/tests/TestCases/Basic/Resources/Baseline.txt @@ -4,14 +4,14 @@ Type.registerNamespace('test'); // test.App test.App = function test_App() { - var s1 = test._strings1.string1; + var s1 = test.Strings1.string1; } //////////////////////////////////////////////////////////////////////////////// -// test._strings1 +// test.Strings1 -test._strings1 = { +test.Strings1 = { string1: 'neutral: aaa', string2: 'fr: bbb', string3: 'fr-FR: ccc' diff --git a/tests/TestCases/Basic/Template/Baseline.txt b/tests/TestCases/Basic/Template/Baseline.txt index c844360cb..583156e4a 100644 --- a/tests/TestCases/Basic/Template/Baseline.txt +++ b/tests/TestCases/Basic/Template/Baseline.txt @@ -16,7 +16,7 @@ test.App.registerClass('test.App'); alert('debug'); -ss.checkScripts('test', 'core'); +ss.checkScripts('test', 'ss'); //! Copyright (c) 2007 diff --git a/tests/TestCases/Expression/EnumToString/MinBaseline.txt b/tests/TestCases/Expression/EnumToString/MinBaseline.txt index 1c048ddc4..c55a506aa 100644 --- a/tests/TestCases/Expression/EnumToString/MinBaseline.txt +++ b/tests/TestCases/Expression/EnumToString/MinBaseline.txt @@ -5,17 +5,17 @@ test.App = function() { test.App.prototype = { test: function(arg) { - var $0 = (0).toString(); - var $1 = (2).toString(); - var $2 = '$0'; - var $3 = (0).toString(); + var s1 = (0).toString(); + var s2 = (2).toString(); + var s3 = '$0'; + var s4 = (0).toString(); }, $0: function($p0, $p1, $p2, $p3) { - var $0 = $p0.toString(); - var $1 = $p1.toString(); - var $2 = $p2; - var $3 = $p3.toString(); + var mstr = $p0.toString(); + var cstr = $p1.toString(); + var sstr = $p2; + var tstr = $p3.toString(); } } diff --git a/tests/TestCases/Type/Partials/Baseline.txt b/tests/TestCases/Type/Partials/Baseline.txt index 5474356d1..6eccc12a0 100644 --- a/tests/TestCases/Type/Partials/Baseline.txt +++ b/tests/TestCases/Type/Partials/Baseline.txt @@ -20,13 +20,13 @@ test.EmptyClass = function test_EmptyClass() { //////////////////////////////////////////////////////////////////////////////// -// test._singleMemberClass +// test.SingleMemberClass -test._singleMemberClass = function test__singleMemberClass() { +test.SingleMemberClass = function test_SingleMemberClass() { } -test._singleMemberClass.prototype = { +test.SingleMemberClass.prototype = { - run: function test__singleMemberClass$run() { + run: function test_SingleMemberClass$run() { } } @@ -104,19 +104,19 @@ test.MyClass.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test._someClass +// test.SomeClass -test._someClass = function test__someClass() { +test.SomeClass = function test_SomeClass() { } -test._someClass.prototype = { +test.SomeClass.prototype = { - close: function test__someClass$close() { + close: function test_SomeClass$close() { }, - _cancel: function test__someClass$_cancel() { + _cancel: function test_SomeClass$_cancel() { }, - run: function test__someClass$run() { + run: function test_SomeClass$run() { } } @@ -138,10 +138,10 @@ test.App = function test_App() { test.EmptyClass.registerClass('test.EmptyClass'); -test._singleMemberClass.registerClass('test._singleMemberClass'); -test.DerivedMemberClass.registerClass('test.DerivedMemberClass', test._singleMemberClass); +test.SingleMemberClass.registerClass('test.SingleMemberClass'); +test.DerivedMemberClass.registerClass('test.DerivedMemberClass', test.SingleMemberClass); test.MergedMembersClass.registerClass('test.MergedMembersClass'); test.DerivedMergedMembersClass.registerClass('test.DerivedMergedMembersClass', test.MergedMembersClass); test.MyClass.registerClass('test.MyClass', null, test.IMyInterface); -test._someClass.registerClass('test._someClass'); +test.SomeClass.registerClass('test.SomeClass'); test.App.registerClass('test.App'); From e24fa5c58f74dba868753c5fbf7101dfee1ab6d6 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 9 Sep 2012 12:08:20 -0700 Subject: [PATCH 004/251] Module dependencies tracking --- .../Compiler/Compiler/ExpressionBuilder.cs | 6 ++--- src/Core/Compiler/CompilerOptions.cs | 26 ------------------- .../Compiler/Importer/MetadataImporter.cs | 9 +------ src/Core/Compiler/ScriptCompiler.cs | 19 +++++++++++--- .../Compiler/ScriptModel/Symbols/SymbolSet.cs | 14 ++++++++++ tests/TestCases/Basic/Template/Baseline.txt | 4 +-- tests/TestCases/Basic/Template/Template.js | 6 ++--- 7 files changed, 37 insertions(+), 47 deletions(-) diff --git a/src/Core/Compiler/Compiler/ExpressionBuilder.cs b/src/Core/Compiler/Compiler/ExpressionBuilder.cs index 8fbca4d99..c63ad741b 100644 --- a/src/Core/Compiler/Compiler/ExpressionBuilder.cs +++ b/src/Core/Compiler/Compiler/ExpressionBuilder.cs @@ -655,7 +655,7 @@ MethodExpression methodExpression string dependency = ((TypeSymbol)memberSymbol.Parent).DependencyName; if (String.IsNullOrEmpty(dependency) == false) { - _options.AddExecutionDependency(dependency); + _symbolSet.AddDependency(dependency); } MemberExpression expression = new MemberExpression(objectExpression, memberSymbol); @@ -853,7 +853,7 @@ private Expression ProcessNewNode(NewNode node) { } if (String.IsNullOrEmpty(type.DependencyName) == false) { - _options.AddExecutionDependency(type.DependencyName); + _symbolSet.AddDependency(type.DependencyName); } return newExpression; @@ -1295,7 +1295,7 @@ private Expression ProcessTypeofNode(TypeofNode node) { Debug.Assert(referencedType != null); if (String.IsNullOrEmpty(referencedType.DependencyName) == false) { - _options.AddExecutionDependency(referencedType.DependencyName); + _symbolSet.AddDependency(referencedType.DependencyName); } TypeSymbol typeSymbol = _symbolSet.ResolveIntrinsicType(IntrinsicType.Type); diff --git a/src/Core/Compiler/CompilerOptions.cs b/src/Core/Compiler/CompilerOptions.cs index f309fbb76..3cb26efca 100644 --- a/src/Core/Compiler/CompilerOptions.cs +++ b/src/Core/Compiler/CompilerOptions.cs @@ -30,9 +30,6 @@ public sealed class CompilerOptions { private string _testsSubnamespace; - private List _executionDependencies; - private List _referencedDependencies; - private bool _hasTestTypes; // TODO: Get rid of internal test mode/type... @@ -79,12 +76,6 @@ public bool EnableDocComments { } } - public IEnumerable ExecutionDependencies { - get { - return _executionDependencies; - } - } - public bool HasTestTypes { get { return _hasTestTypes; @@ -139,7 +130,6 @@ public ICollection References { } set { _references = value; - _referencedDependencies = null; } } @@ -197,22 +187,6 @@ public string TestsSubnamespace { } } - public void AddExecutionDependency(string scriptName) { - if (_executionDependencies == null) { - _executionDependencies = new List(); - } - if (_executionDependencies.Contains(scriptName) == false) { - _executionDependencies.Add(scriptName); - } - } - - public void AddReferencedDependency(string scriptName) { - if (_referencedDependencies == null) { - _referencedDependencies = new List(); - } - _referencedDependencies.Add(scriptName); - } - public bool Validate(out string errorMessage) { errorMessage = String.Empty; diff --git a/src/Core/Compiler/Importer/MetadataImporter.cs b/src/Core/Compiler/Importer/MetadataImporter.cs index f631ac90c..9fa20d101 100644 --- a/src/Core/Compiler/Importer/MetadataImporter.cs +++ b/src/Core/Compiler/Importer/MetadataImporter.cs @@ -660,14 +660,7 @@ private void ImportScriptAssembly(MetadataSource mdSource, string assemblyPath, scriptName = MetadataHelpers.GetScriptAssemblyName(assembly); if (String.IsNullOrEmpty(scriptName) == false) { - _options.AddReferencedDependency(scriptName); - } - - if (coreAssembly) { - // Always add an execution reference to the core assembly, since - // it contains things like the type system, and other APIs assumed by the compiler - Debug.Assert(String.IsNullOrEmpty(scriptName) == false); - _options.AddExecutionDependency(scriptName); + _symbols.AddDependency(scriptName); } foreach (TypeDefinition type in assembly.MainModule.Types) { diff --git a/src/Core/Compiler/ScriptCompiler.cs b/src/Core/Compiler/ScriptCompiler.cs index 3dd0c405f..e03c52a67 100644 --- a/src/Core/Compiler/ScriptCompiler.cs +++ b/src/Core/Compiler/ScriptCompiler.cs @@ -357,14 +357,25 @@ string IScriptInfo.GetValue(string name) { } return _symbols.ScriptName; } - if (String.CompareOrdinal(name, "ExecutionDependencies") == 0) { - if (_options.ExecutionDependencies == null) { - return String.Empty; + if (String.CompareOrdinal(name, "DependencyNames") == 0) { + bool first = true; + StringBuilder sb = new StringBuilder(); + foreach (string scriptName in _symbols.Dependencies) { + if (first == false) { + sb.Append(","); + } + sb.Append("'"); + sb.Append(scriptName); + sb.Append("'"); + first = false; } + return sb.ToString(); + } + if (String.CompareOrdinal(name, "Dependencies") == 0) { bool first = true; StringBuilder sb = new StringBuilder(); - foreach (string scriptName in _options.ExecutionDependencies) { + foreach (string scriptName in _symbols.Dependencies) { if (first == false) { sb.Append(","); } diff --git a/src/Core/Compiler/ScriptModel/Symbols/SymbolSet.cs b/src/Core/Compiler/ScriptModel/Symbols/SymbolSet.cs index 0b1abb8a9..4856a829d 100644 --- a/src/Core/Compiler/ScriptModel/Symbols/SymbolSet.cs +++ b/src/Core/Compiler/ScriptModel/Symbols/SymbolSet.cs @@ -26,6 +26,7 @@ internal sealed class SymbolSet : ISymbolTable { private MemberSymbol _entryPoint; private string _scriptName; + private List _dependencies; private Dictionary> _resources; @@ -44,9 +45,16 @@ public SymbolSet() { _namespaces.Add(_systemNamespace); _namespaceMap["System"] = _systemNamespace; + _dependencies = new List(); _resources = new Dictionary>(StringComparer.OrdinalIgnoreCase); } + public IEnumerable Dependencies { + get { + return _dependencies; + } + } + public MemberSymbol EntryPoint { get { return _entryPoint; @@ -86,6 +94,12 @@ public NamespaceSymbol SystemNamespace { } } + public void AddDependency(string scriptName) { + if (_dependencies.Contains(scriptName) == false) { + _dependencies.Add(scriptName); + } + } + public TypeSymbol CreateArrayTypeSymbol(TypeSymbol itemTypeSymbol) { if ((_arrayTypeTable != null) && (_arrayTypeTable.ContainsKey(itemTypeSymbol.FullName))) { return _arrayTypeTable[itemTypeSymbol.FullName]; diff --git a/tests/TestCases/Basic/Template/Baseline.txt b/tests/TestCases/Basic/Template/Baseline.txt index 583156e4a..9160e7d40 100644 --- a/tests/TestCases/Basic/Template/Baseline.txt +++ b/tests/TestCases/Basic/Template/Baseline.txt @@ -16,7 +16,7 @@ test.App.registerClass('test.App'); alert('debug'); -ss.checkScripts('test', 'ss'); - +define('test', [ 'ss' ], function(ss) { +}); //! Copyright (c) 2007 diff --git a/tests/TestCases/Basic/Template/Template.js b/tests/TestCases/Basic/Template/Template.js index feaaa3e73..0b36a56c3 100644 --- a/tests/TestCases/Basic/Template/Template.js +++ b/tests/TestCases/Basic/Template/Template.js @@ -7,9 +7,7 @@ alert('debug'); #endif -#if DEBUG -ss.checkScripts('#= Name ##', '#= ExecutionDependencies ##'); -#endif - +define('#= Name ##', [ #= DependencyNames ## ], function(#= Dependencies ##) { +}); //! Copyright (c) 2007 \ No newline at end of file From 74b3b8e1a1101f2793001e8d612d3d6b66cd8458 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 9 Sep 2012 13:32:34 -0700 Subject: [PATCH 005/251] Remove ScriptNamespaceAttribute --- src/Core/Compiler/Compiler/MetadataBuilder.cs | 49 +------ src/Core/Compiler/Importer/MetadataHelpers.cs | 9 -- .../Compiler/Importer/MetadataImporter.cs | 15 +-- src/Core/Compiler/ScriptCompiler.cs | 12 +- src/Core/CoreLib/CancelEventArgs.cs | 1 - .../Collections/Generic/ICollection.cs | 1 - .../Collections/Generic/IEnumerable.cs | 1 - .../Collections/Generic/IEnumerator.cs | 1 - .../Generic/IReadonlyCollection.cs | 1 - .../Generic/ObservableCollection.cs | 1 - src/Core/CoreLib/Collections/ICollection.cs | 1 - src/Core/CoreLib/Collections/IEnumerable.cs | 1 - src/Core/CoreLib/Collections/IEnumerator.cs | 1 - .../Collections/IReadonlyCollection.cs | 1 - .../Collections/ObservableCollection.cs | 1 - .../CoreLib/ComponentModel/IApplication.cs | 1 - src/Core/CoreLib/ComponentModel/IContainer.cs | 1 - .../CoreLib/ComponentModel/IEventManager.cs | 1 - .../CoreLib/ComponentModel/IInitializable.cs | 1 - src/Core/CoreLib/ComponentModel/IObserver.cs | 1 - src/Core/CoreLib/ComponentModel/Observable.cs | 1 - .../CoreLib/ComponentModel/ObserverManager.cs | 1 - src/Core/CoreLib/Delegate.cs | 1 - src/Core/CoreLib/Enum.cs | 1 - src/Core/CoreLib/EventArgs.cs | 1 - src/Core/CoreLib/Globalization/CultureInfo.cs | 1 - src/Core/CoreLib/IDisposable.cs | 1 - src/Core/CoreLib/Record.cs | 1 - src/Core/CoreLib/ScriptMetadata.cs | 26 ---- src/Core/CoreLib/StringBuilder.cs | 1 - src/Core/CoreLib/Threading/Deferred.cs | 2 - src/Core/CoreLib/Threading/Task.cs | 2 - src/Core/CoreLib/Tuple.cs | 2 - .../BingMaps/Location/GeoLocationProvider.cs | 1 - tests/ScriptSharp/ValidationTests.cs | 4 +- tests/TestCases/Basic/Conditionals/Code.cs | 1 - .../Basic/Conditionals/DebugBaseline.txt | 22 +-- .../Basic/Conditionals/TraceBaseline.txt | 22 +-- .../TestCases/Basic/DocComments/Baseline.txt | 96 ++++++------- tests/TestCases/Basic/DocComments/Code.cs | 1 - tests/TestCases/Basic/Flags/Baseline.txt | 10 +- tests/TestCases/Basic/Flags/Code.cs | 1 - tests/TestCases/Basic/Metadata/Baseline.txt | 80 +++++------ tests/TestCases/Basic/Metadata/Code.cs | 1 - .../TestCases/Basic/Minimization/Baseline.txt | 112 ++++++++-------- tests/TestCases/Basic/Minimization/Code.cs | 1 - tests/TestCases/Basic/Resources/Baseline.txt | 20 +-- tests/TestCases/Basic/Resources/Code.cs | 1 - tests/TestCases/Basic/Template/Baseline.txt | 8 +- tests/TestCases/Basic/Template/Code.cs | 1 - tests/TestCases/Basic/UnitTest/Code.cs | 1 - .../Basic/UnitTest/NonTestBaseline.txt | 18 +-- .../TestCases/Basic/UnitTest/TestBaseline.txt | 50 +++---- .../Expression/AnonymousMethods/Baseline.txt | 30 ++--- .../Expression/AnonymousMethods/Code.cs | 1 - .../Expression/Arguments/Baseline.txt | 10 +- tests/TestCases/Expression/Arguments/Code.cs | 1 - tests/TestCases/Expression/Base/Baseline.txt | 24 ++-- tests/TestCases/Expression/Base/Code.cs | 1 - .../TestCases/Expression/Binary/Baseline.txt | 28 ++-- tests/TestCases/Expression/Binary/Code.cs | 1 - tests/TestCases/Expression/Cast/Baseline.txt | 10 +- tests/TestCases/Expression/Cast/Code.cs | 1 - .../Expression/Conditional/Baseline.txt | 10 +- .../TestCases/Expression/Conditional/Code.cs | 1 - .../Expression/Delegates/Baseline.txt | 36 ++--- tests/TestCases/Expression/Delegates/Code.cs | 1 - .../Expression/Dictionary/Baseline.txt | 12 +- tests/TestCases/Expression/Dictionary/Code.cs | 1 - .../Expression/EnumToString/Code1.cs | 1 - .../Expression/EnumToString/Code2.cs | 1 - .../Expression/EnumToString/MinBaseline.txt | 8 +- .../EnumToString/NormalBaseline.txt | 34 ++--- .../TestCases/Expression/Events/Baseline.txt | 50 +++---- tests/TestCases/Expression/Events/Code.cs | 1 - .../Expression/Generics/Baseline.txt | 10 +- tests/TestCases/Expression/Generics/Code.cs | 1 - .../TestCases/Expression/GetType/Baseline.txt | 10 +- tests/TestCases/Expression/GetType/Code.cs | 1 - .../Expression/GlobalMethods/Baseline.txt | 12 +- .../Expression/GlobalMethods/Code.cs | 1 - .../Expression/InlineScript/Baseline.txt | 10 +- .../TestCases/Expression/InlineScript/Code.cs | 1 - .../Expression/LateBound/Baseline.txt | 10 +- tests/TestCases/Expression/LateBound/Code.cs | 1 - .../Expression/Literals/Baseline.txt | 12 +- tests/TestCases/Expression/Literals/Code.cs | 1 - .../TestCases/Expression/Locals/Baseline.txt | 10 +- tests/TestCases/Expression/Locals/Code.cs | 1 - .../TestCases/Expression/Members/Baseline.txt | 54 ++++---- tests/TestCases/Expression/Members/Code.cs | 1 - tests/TestCases/Expression/New/Baseline.txt | 40 +++--- tests/TestCases/Expression/New/Code.cs | 1 - .../TestCases/Expression/Number/Baseline.txt | 10 +- tests/TestCases/Expression/Number/Code.cs | 1 - .../TestCases/Expression/Script/Baseline.txt | 10 +- tests/TestCases/Expression/Script/Code.cs | 1 - .../TestCases/Expression/String/Baseline.txt | 10 +- tests/TestCases/Expression/String/Code.cs | 1 - .../TestCases/Expression/Truthy/Baseline.txt | 10 +- tests/TestCases/Expression/Truthy/Code.cs | 1 - tests/TestCases/Expression/Unary/Baseline.txt | 20 +-- tests/TestCases/Expression/Unary/Code.cs | 1 - .../Member/Constructors/Baseline.txt | 38 +++--- tests/TestCases/Member/Constructors/Code.cs | 1 - tests/TestCases/Member/Events/Baseline.txt | 28 ++-- tests/TestCases/Member/Events/Code.cs | 1 - tests/TestCases/Member/Fields/Baseline.txt | 50 +++---- tests/TestCases/Member/Fields/Code.cs | 1 - tests/TestCases/Member/Indexers/Baseline.txt | 126 +++++++++--------- tests/TestCases/Member/Indexers/Code.cs | 1 - tests/TestCases/Member/Methods/Baseline.txt | 30 ++--- tests/TestCases/Member/Methods/Code.cs | 1 - tests/TestCases/Member/Overloads/Baseline.txt | 26 ++-- tests/TestCases/Member/Overloads/Code.cs | 1 - .../TestCases/Member/Properties/Baseline.txt | 30 ++--- tests/TestCases/Member/Properties/Code.cs | 1 - .../Member/StaticConstructors/Baseline.txt | 46 +++---- .../Member/StaticConstructors/Code.cs | 1 - .../Statement/Exceptions/Baseline.txt | 10 +- tests/TestCases/Statement/Exceptions/Code.cs | 1 - .../Statement/Expression/Baseline.txt | 10 +- tests/TestCases/Statement/Expression/Code.cs | 1 - tests/TestCases/Statement/For/Baseline.txt | 10 +- tests/TestCases/Statement/For/Code.cs | 1 - .../TestCases/Statement/Foreach/Baseline.txt | 20 +-- tests/TestCases/Statement/Foreach/Code.cs | 1 - tests/TestCases/Statement/IfElse/Baseline.txt | 10 +- tests/TestCases/Statement/IfElse/Code.cs | 1 - tests/TestCases/Statement/Return/Baseline.txt | 10 +- tests/TestCases/Statement/Return/Code.cs | 1 - tests/TestCases/Statement/Switch/Baseline.txt | 18 +-- tests/TestCases/Statement/Switch/Code.cs | 1 - .../Statement/Variables/Baseline.txt | 10 +- tests/TestCases/Statement/Variables/Code.cs | 1 - tests/TestCases/Statement/While/Baseline.txt | 10 +- tests/TestCases/Statement/While/Code.cs | 1 - tests/TestCases/Type/Classes/Baseline.txt | 38 +++--- tests/TestCases/Type/Classes/Code.cs | 1 - tests/TestCases/Type/Delegates/Baseline.txt | 8 +- tests/TestCases/Type/Delegates/Code.cs | 1 - tests/TestCases/Type/Enumerator/Baseline.txt | 24 ++-- tests/TestCases/Type/Enumerator/Code.cs | 1 - tests/TestCases/Type/Enums/Baseline.txt | 80 +++++------ tests/TestCases/Type/Enums/Code.cs | 1 - tests/TestCases/Type/Globals/Baseline.txt | 6 +- tests/TestCases/Type/Globals/Code.cs | 2 +- tests/TestCases/Type/Imported/Baseline.txt | 8 +- tests/TestCases/Type/Imported/Code.cs | 1 - tests/TestCases/Type/Interfaces/Baseline.txt | 64 ++++----- tests/TestCases/Type/Interfaces/Code.cs | 1 - tests/TestCases/Type/Namespaces/Baseline.txt | 18 +-- tests/TestCases/Type/Namespaces/Code.cs | 6 +- tests/TestCases/Type/Nullable/Baseline.txt | 12 +- tests/TestCases/Type/Nullable/Code.cs | 1 - tests/TestCases/Type/Partials/Baseline.txt | 98 +++++++------- tests/TestCases/Type/Partials/Code1.cs | 1 - tests/TestCases/Type/Records/Baseline.txt | 10 +- tests/TestCases/Type/Records/Code.cs | 1 - .../Type/ScriptNamespaces/AppAssemblyInfo.cs | 1 - .../Type/ScriptNamespaces/AppBaseline.txt | 46 +++---- .../Type/ScriptNamespaces/AppFeature.cs | 2 +- .../Type/ScriptNamespaces/AppFoo.2.cs | 1 - .../ScriptNamespaces/LibraryAssemblyInfo.cs | 1 - .../Type/ScriptNamespaces/LibraryBaseline.txt | 32 +++-- .../Type/ScriptNamespaces/LibraryFeature.cs | 2 +- tests/TestCases/Type/UsingAlias/Baseline.txt | 8 +- tests/TestCases/Type/UsingAlias/Code.cs | 1 - .../Validation/ConflictingTypes/Code.cs | 1 - .../Validation/CreateInstance/Code.cs | 2 +- tests/TestCases/Validation/Exceptions/Code.cs | 2 +- .../Validation/ImplicitEnums/Code.cs | 2 +- .../TestCases/Validation/InlineScript/Code.cs | 2 +- tests/TestCases/Validation/Keywords/Code.cs | 2 +- .../TestCases/Validation/NestedTypes/Code.cs | 2 +- tests/TestCases/Validation/Overloads/Code.cs | 2 +- tests/TestCases/Validation/Properties/Code.cs | 2 +- .../TestCases/Validation/Unsupported/Code1.cs | 2 +- .../TestCases/Validation/Unsupported/Code2.cs | 2 +- 179 files changed, 952 insertions(+), 1143 deletions(-) diff --git a/src/Core/Compiler/Compiler/MetadataBuilder.cs b/src/Core/Compiler/Compiler/MetadataBuilder.cs index 26d1c7abd..6cd94d73d 100644 --- a/src/Core/Compiler/Compiler/MetadataBuilder.cs +++ b/src/Core/Compiler/Compiler/MetadataBuilder.cs @@ -297,7 +297,6 @@ public ICollection BuildMetadata(ParseNodeList compilationUnits, Sym } symbols.ScriptName = scriptName; - string assemblyScriptNamespace = GetAssemblyScriptNamespace(compilationUnits); List types = new List(); // Build all the types first. @@ -364,12 +363,6 @@ public ICollection BuildMetadata(ParseNodeList compilationUnits, Sym continue; } - // Check if we have overriding script namespace for this type. - string typeScriptNamespace = GetScriptNamespace(userTypeNode.Attributes); - if (String.IsNullOrEmpty(typeScriptNamespace)) { - typeScriptNamespace = assemblyScriptNamespace; - } - ClassSymbol partialTypeSymbol = null; bool isPartial = false; @@ -388,10 +381,6 @@ public ICollection BuildMetadata(ParseNodeList compilationUnits, Sym // Merge interesting bits of information onto the primary type symbol as well // representing this partial class BuildType(partialTypeSymbol, userTypeNode); - - if (String.IsNullOrEmpty(typeScriptNamespace) == false) { - partialTypeSymbol.ScriptNamespace = typeScriptNamespace; - } } } @@ -406,10 +395,6 @@ public ICollection BuildMetadata(ParseNodeList compilationUnits, Sym typeSymbol.SetAliases(aliases); } - if (String.IsNullOrEmpty(typeScriptNamespace) == false) { - typeSymbol.ScriptNamespace = typeScriptNamespace; - } - if (isPartial == false) { namespaceSymbol.AddType(typeSymbol); } @@ -721,10 +706,10 @@ private void BuildType(TypeSymbol typeSymbol, UserTypeNode typeNode) { if (AttributeNode.FindAttribute(attributes, "Imported") != null) { typeSymbol.SetImported(/* dependencyName */ null); - } - if (AttributeNode.FindAttribute(attributes, "IgnoreNamespace") != null) { - typeSymbol.SetIgnoreNamespace(); + if (AttributeNode.FindAttribute(attributes, "IgnoreNamespace") != null) { + typeSymbol.SetIgnoreNamespace(); + } } if (AttributeNode.FindAttribute(attributes, "PreserveName") != null) { @@ -818,30 +803,6 @@ private string GetAssemblyScriptName(ParseNodeList compilationUnits) { return null; } - private string GetAssemblyScriptNamespace(ParseNodeList compilationUnits) { - foreach (CompilationUnitNode compilationUnit in compilationUnits) { - foreach (AttributeBlockNode attribBlock in compilationUnit.Attributes) { - string scriptNamespace = GetScriptNamespace(attribBlock.Attributes); - if (scriptNamespace != null) { - return scriptNamespace; - } - } - } - return null; - } - - private string GetAssemblyScriptPrefix(ParseNodeList compilationUnits) { - foreach (CompilationUnitNode compilationUnit in compilationUnits) { - foreach (AttributeBlockNode attribBlock in compilationUnit.Attributes) { - string scriptPrefix = GetAttributeValue(attribBlock.Attributes, "ScriptQualifier"); - if (scriptPrefix != null) { - return scriptPrefix; - } - } - } - return null; - } - private string GetAttributeValue(ParseNodeList attributes, string attributeName) { AttributeNode node = AttributeNode.FindAttribute(attributes, attributeName); @@ -854,10 +815,6 @@ private string GetAttributeValue(ParseNodeList attributes, string attributeName) return null; } - private string GetScriptNamespace(ParseNodeList attributes) { - return GetAttributeValue(attributes, "ScriptNamespace"); - } - private MemberVisibility GetVisibility(MemberNode node, TypeSymbol typeSymbol) { if (typeSymbol.Type == SymbolType.Interface) { return MemberVisibility.Public; diff --git a/src/Core/Compiler/Importer/MetadataHelpers.cs b/src/Core/Compiler/Importer/MetadataHelpers.cs index d4e6d8c96..93f42b3d4 100644 --- a/src/Core/Compiler/Importer/MetadataHelpers.cs +++ b/src/Core/Compiler/Importer/MetadataHelpers.cs @@ -55,15 +55,6 @@ public static string GetScriptName(ICustomAttributeProvider attributeProvider) { return null; } - public static string GetScriptNamespace(ICustomAttributeProvider attributeProvider) { - CustomAttribute scriptNamespaceAttribute = GetAttribute(attributeProvider, "System.Runtime.CompilerServices.ScriptNamespaceAttribute"); - if (scriptNamespaceAttribute != null) { - return GetAttributeArgument(scriptNamespaceAttribute); - } - - return null; - } - public static bool IsCompilerGeneratedType(TypeDefinition type) { return GetAttribute(type, "System.Runtime.CompilerServices.CompilerGeneratedAttribute") != null; } diff --git a/src/Core/Compiler/Importer/MetadataImporter.cs b/src/Core/Compiler/Importer/MetadataImporter.cs index 9fa20d101..3cece5f27 100644 --- a/src/Core/Compiler/Importer/MetadataImporter.cs +++ b/src/Core/Compiler/Importer/MetadataImporter.cs @@ -646,7 +646,6 @@ private void ImportPseudoMembers(PseudoClassMembers memberSet, ClassSymbol class } private void ImportScriptAssembly(MetadataSource mdSource, string assemblyPath, bool coreAssembly) { - string scriptNamespace = null; string scriptName = null; AssemblyDefinition assembly; @@ -655,7 +654,6 @@ private void ImportScriptAssembly(MetadataSource mdSource, string assemblyPath, } else { assembly = mdSource.GetMetadata(assemblyPath); - scriptNamespace = MetadataHelpers.GetScriptNamespace(assembly); } scriptName = MetadataHelpers.GetScriptAssemblyName(assembly); @@ -669,7 +667,7 @@ private void ImportScriptAssembly(MetadataSource mdSource, string assemblyPath, continue; } - ImportType(mdSource, type, coreAssembly, scriptNamespace, scriptName); + ImportType(mdSource, type, coreAssembly, scriptName); } catch (Exception e) { Debug.Fail(e.ToString()); @@ -677,7 +675,7 @@ private void ImportScriptAssembly(MetadataSource mdSource, string assemblyPath, } } - private void ImportType(MetadataSource mdSource, TypeDefinition type, bool inScriptCoreAssembly, string assemblyScriptNamespace, string assemblyScriptName) { + private void ImportType(MetadataSource mdSource, TypeDefinition type, bool inScriptCoreAssembly, string assemblyScriptName) { if (type.IsPublic == false) { return; } @@ -687,13 +685,8 @@ private void ImportType(MetadataSource mdSource, TypeDefinition type, bool inScr string name = type.Name; string namespaceName = type.Namespace; - string scriptNamespace = MetadataHelpers.GetScriptNamespace(type); string scriptName = MetadataHelpers.GetScriptName(type); - if (String.IsNullOrEmpty(scriptNamespace) && (String.IsNullOrEmpty(assemblyScriptNamespace) == false)) { - scriptNamespace = assemblyScriptNamespace; - } - NamespaceSymbol namespaceSymbol = _symbols.GetNamespace(namespaceName); TypeSymbol typeSymbol = null; @@ -752,8 +745,8 @@ private void ImportType(MetadataSource mdSource, TypeDefinition type, bool inScr } typeSymbol.SetPublic(); - if (String.IsNullOrEmpty(scriptNamespace) == false) { - typeSymbol.ScriptNamespace = scriptNamespace; + if (String.IsNullOrEmpty(assemblyScriptName) == false) { + typeSymbol.ScriptNamespace = assemblyScriptName; } if (String.IsNullOrEmpty(scriptName) == false) { diff --git a/src/Core/Compiler/ScriptCompiler.cs b/src/Core/Compiler/ScriptCompiler.cs index e03c52a67..27546b27e 100644 --- a/src/Core/Compiler/ScriptCompiler.cs +++ b/src/Core/Compiler/ScriptCompiler.cs @@ -89,14 +89,8 @@ private void BuildMetadata() { MetadataBuilder mdBuilder = new MetadataBuilder(this); _appSymbols = mdBuilder.BuildMetadata(_compilationUnitList, _symbols, _options); - // Check if any of the types defined in this assembly conflict against types in - // imported assemblies. - + // Check if any of the types defined in this assembly conflict. Dictionary types = new Dictionary(); - foreach (TypeSymbol importedType in _importedSymbols) { - types[importedType.FullGeneratedName] = importedType; - } - foreach (TypeSymbol appType in _appSymbols) { if ((appType.IsApplicationType == false) || (appType.Type == SymbolType.Delegate)) { // Skip the check for types that are marked as imported, as they @@ -113,9 +107,9 @@ private void BuildMetadata() { continue; } - string name = appType.FullGeneratedName; + string name = appType.GeneratedName; if (types.ContainsKey(name)) { - string error = "The type '" + name + "' conflicts with another existing type with the same full name. This might be because a referenced assembly uses the same type, or you have multiple types with the same name across namespaces mapped to the same script namespace."; + string error = "The type '" + appType.FullName + "' conflicts with with '" + types[name].FullName + "' as they have the same name."; ((IErrorHandler)this).ReportError(error, null); } else { diff --git a/src/Core/CoreLib/CancelEventArgs.cs b/src/Core/CoreLib/CancelEventArgs.cs index c8dfdc2e8..e8863fbab 100644 --- a/src/Core/CoreLib/CancelEventArgs.cs +++ b/src/Core/CoreLib/CancelEventArgs.cs @@ -11,7 +11,6 @@ namespace System { /// /// The event argument associated with cancelable events. /// - [ScriptNamespace("ss")] [Imported] public class CancelEventArgs : EventArgs { diff --git a/src/Core/CoreLib/Collections/Generic/ICollection.cs b/src/Core/CoreLib/Collections/Generic/ICollection.cs index c5d8fe3fa..8a2753711 100644 --- a/src/Core/CoreLib/Collections/Generic/ICollection.cs +++ b/src/Core/CoreLib/Collections/Generic/ICollection.cs @@ -8,7 +8,6 @@ namespace System.Collections.Generic { [Imported] - [ScriptNamespace("ss")] [ScriptName("ICollection")] public interface ICollection : IEnumerable { diff --git a/src/Core/CoreLib/Collections/Generic/IEnumerable.cs b/src/Core/CoreLib/Collections/Generic/IEnumerable.cs index 0204fe624..b290610cb 100644 --- a/src/Core/CoreLib/Collections/Generic/IEnumerable.cs +++ b/src/Core/CoreLib/Collections/Generic/IEnumerable.cs @@ -8,7 +8,6 @@ namespace System.Collections.Generic { [Imported] - [ScriptNamespace("ss")] [ScriptName("IEnumerable")] public interface IEnumerable { diff --git a/src/Core/CoreLib/Collections/Generic/IEnumerator.cs b/src/Core/CoreLib/Collections/Generic/IEnumerator.cs index c5fe31031..e4947f5c2 100644 --- a/src/Core/CoreLib/Collections/Generic/IEnumerator.cs +++ b/src/Core/CoreLib/Collections/Generic/IEnumerator.cs @@ -8,7 +8,6 @@ namespace System.Collections.Generic { [Imported] - [ScriptNamespace("ss")] [ScriptName("IEnumerator")] public interface IEnumerator { diff --git a/src/Core/CoreLib/Collections/Generic/IReadonlyCollection.cs b/src/Core/CoreLib/Collections/Generic/IReadonlyCollection.cs index f32938f80..e715440ad 100644 --- a/src/Core/CoreLib/Collections/Generic/IReadonlyCollection.cs +++ b/src/Core/CoreLib/Collections/Generic/IReadonlyCollection.cs @@ -8,7 +8,6 @@ namespace System.Collections.Generic { [Imported] - [ScriptNamespace("ss")] [ScriptName("ICollection")] public interface IReadonlyCollection : IEnumerable { diff --git a/src/Core/CoreLib/Collections/Generic/ObservableCollection.cs b/src/Core/CoreLib/Collections/Generic/ObservableCollection.cs index 94d22451e..19c004e3b 100644 --- a/src/Core/CoreLib/Collections/Generic/ObservableCollection.cs +++ b/src/Core/CoreLib/Collections/Generic/ObservableCollection.cs @@ -9,7 +9,6 @@ namespace System.Collections.Generic { [Imported] - [ScriptNamespace("ss")] [ScriptName("ObservableCollection")] public sealed class ObservableCollection : IEnumerable { diff --git a/src/Core/CoreLib/Collections/ICollection.cs b/src/Core/CoreLib/Collections/ICollection.cs index 9e386bae7..5e4511ca5 100644 --- a/src/Core/CoreLib/Collections/ICollection.cs +++ b/src/Core/CoreLib/Collections/ICollection.cs @@ -8,7 +8,6 @@ namespace System.Collections { [Imported] - [ScriptNamespace("ss")] [ScriptName("ICollection")] public interface ICollection : IEnumerable { diff --git a/src/Core/CoreLib/Collections/IEnumerable.cs b/src/Core/CoreLib/Collections/IEnumerable.cs index 2a33d13c4..dd99c06b4 100644 --- a/src/Core/CoreLib/Collections/IEnumerable.cs +++ b/src/Core/CoreLib/Collections/IEnumerable.cs @@ -8,7 +8,6 @@ namespace System.Collections { [Imported] - [ScriptNamespace("ss")] public interface IEnumerable { IEnumerator GetEnumerator(); diff --git a/src/Core/CoreLib/Collections/IEnumerator.cs b/src/Core/CoreLib/Collections/IEnumerator.cs index 4127b595b..fe5bdf413 100644 --- a/src/Core/CoreLib/Collections/IEnumerator.cs +++ b/src/Core/CoreLib/Collections/IEnumerator.cs @@ -8,7 +8,6 @@ namespace System.Collections { [Imported] - [ScriptNamespace("ss")] public interface IEnumerator { [IntrinsicProperty] diff --git a/src/Core/CoreLib/Collections/IReadonlyCollection.cs b/src/Core/CoreLib/Collections/IReadonlyCollection.cs index 07901b436..c7e1c1f8e 100644 --- a/src/Core/CoreLib/Collections/IReadonlyCollection.cs +++ b/src/Core/CoreLib/Collections/IReadonlyCollection.cs @@ -8,7 +8,6 @@ namespace System.Collections { [Imported] - [ScriptNamespace("ss")] [ScriptName("ICollection")] public interface IReadonlyCollection : IEnumerable { diff --git a/src/Core/CoreLib/Collections/ObservableCollection.cs b/src/Core/CoreLib/Collections/ObservableCollection.cs index f2ae87ba9..a03f6c82d 100644 --- a/src/Core/CoreLib/Collections/ObservableCollection.cs +++ b/src/Core/CoreLib/Collections/ObservableCollection.cs @@ -9,7 +9,6 @@ namespace System.Collections { [Imported] - [ScriptNamespace("ss")] [ScriptName("ObservableCollection")] public sealed class ObservableCollection : IEnumerable { diff --git a/src/Core/CoreLib/ComponentModel/IApplication.cs b/src/Core/CoreLib/ComponentModel/IApplication.cs index 02c4a0e3b..17a6c2034 100644 --- a/src/Core/CoreLib/ComponentModel/IApplication.cs +++ b/src/Core/CoreLib/ComponentModel/IApplication.cs @@ -12,7 +12,6 @@ namespace System.ComponentModel { /// Defines contextual information about the current application. /// [Imported] - [ScriptNamespace("ss")] public interface IApplication { /// diff --git a/src/Core/CoreLib/ComponentModel/IContainer.cs b/src/Core/CoreLib/ComponentModel/IContainer.cs index ad1fc4b5a..ee6b66642 100644 --- a/src/Core/CoreLib/ComponentModel/IContainer.cs +++ b/src/Core/CoreLib/ComponentModel/IContainer.cs @@ -13,7 +13,6 @@ namespace System.ComponentModel { /// composition where objects can be registered and dependencies can be resolved. /// [Imported] - [ScriptNamespace("ss")] public interface IContainer { /// diff --git a/src/Core/CoreLib/ComponentModel/IEventManager.cs b/src/Core/CoreLib/ComponentModel/IEventManager.cs index e1b595fa1..57ab60618 100644 --- a/src/Core/CoreLib/ComponentModel/IEventManager.cs +++ b/src/Core/CoreLib/ComponentModel/IEventManager.cs @@ -13,7 +13,6 @@ namespace System.ComponentModel { /// listen to messages or events without being coupled to each other. /// [Imported] - [ScriptNamespace("ss")] public interface IEventManager { /// diff --git a/src/Core/CoreLib/ComponentModel/IInitializable.cs b/src/Core/CoreLib/ComponentModel/IInitializable.cs index a8a948470..576fb1897 100644 --- a/src/Core/CoreLib/ComponentModel/IInitializable.cs +++ b/src/Core/CoreLib/ComponentModel/IInitializable.cs @@ -14,7 +14,6 @@ namespace System.ComponentModel { /// initialization. /// [Imported] - [ScriptNamespace("ss")] public interface IInitializable { /// diff --git a/src/Core/CoreLib/ComponentModel/IObserver.cs b/src/Core/CoreLib/ComponentModel/IObserver.cs index 57e8ad57a..8bfe73b07 100644 --- a/src/Core/CoreLib/ComponentModel/IObserver.cs +++ b/src/Core/CoreLib/ComponentModel/IObserver.cs @@ -9,7 +9,6 @@ namespace System.ComponentModel { [Imported] - [ScriptNamespace("ss")] [ScriptName("IObserver")] public interface IObserver { diff --git a/src/Core/CoreLib/ComponentModel/Observable.cs b/src/Core/CoreLib/ComponentModel/Observable.cs index 53765677c..44fc967f4 100644 --- a/src/Core/CoreLib/ComponentModel/Observable.cs +++ b/src/Core/CoreLib/ComponentModel/Observable.cs @@ -9,7 +9,6 @@ namespace System.ComponentModel { [Imported] - [ScriptNamespace("ss")] [ScriptName("Observable")] public sealed class Observable { diff --git a/src/Core/CoreLib/ComponentModel/ObserverManager.cs b/src/Core/CoreLib/ComponentModel/ObserverManager.cs index 473235a55..35334b983 100644 --- a/src/Core/CoreLib/ComponentModel/ObserverManager.cs +++ b/src/Core/CoreLib/ComponentModel/ObserverManager.cs @@ -9,7 +9,6 @@ namespace System.ComponentModel { [Imported] - [ScriptNamespace("ss")] [ScriptName("Observable")] public static class ObserverManager { diff --git a/src/Core/CoreLib/Delegate.cs b/src/Core/CoreLib/Delegate.cs index eef11f582..97cf21b4f 100644 --- a/src/Core/CoreLib/Delegate.cs +++ b/src/Core/CoreLib/Delegate.cs @@ -8,7 +8,6 @@ namespace System { [Imported] - [ScriptNamespace("ss")] public abstract class Delegate { public static readonly Delegate Empty = null; diff --git a/src/Core/CoreLib/Enum.cs b/src/Core/CoreLib/Enum.cs index 5f31be2e2..6b0c5c79b 100644 --- a/src/Core/CoreLib/Enum.cs +++ b/src/Core/CoreLib/Enum.cs @@ -8,7 +8,6 @@ namespace System { [Imported] - [ScriptNamespace("ss")] public abstract class Enum : ValueType { } } diff --git a/src/Core/CoreLib/EventArgs.cs b/src/Core/CoreLib/EventArgs.cs index c0830b6d4..fdd6d8ead 100644 --- a/src/Core/CoreLib/EventArgs.cs +++ b/src/Core/CoreLib/EventArgs.cs @@ -10,7 +10,6 @@ namespace System { /// /// Used by event sources to pass event argument information. /// - [ScriptNamespace("ss")] [Imported] public class EventArgs { diff --git a/src/Core/CoreLib/Globalization/CultureInfo.cs b/src/Core/CoreLib/Globalization/CultureInfo.cs index 904f06c82..0df2db09f 100644 --- a/src/Core/CoreLib/Globalization/CultureInfo.cs +++ b/src/Core/CoreLib/Globalization/CultureInfo.cs @@ -8,7 +8,6 @@ namespace System.Globalization { [Imported] - [ScriptNamespace("ss")] public sealed class CultureInfo { private CultureInfo() { diff --git a/src/Core/CoreLib/IDisposable.cs b/src/Core/CoreLib/IDisposable.cs index 036a4f8e7..50b056d16 100644 --- a/src/Core/CoreLib/IDisposable.cs +++ b/src/Core/CoreLib/IDisposable.cs @@ -9,7 +9,6 @@ namespace System { // Script Equivalent: IDisposable [Imported] - [ScriptNamespace("ss")] public interface IDisposable { void Dispose(); diff --git a/src/Core/CoreLib/Record.cs b/src/Core/CoreLib/Record.cs index ecfa6191b..cfc6c4288 100644 --- a/src/Core/CoreLib/Record.cs +++ b/src/Core/CoreLib/Record.cs @@ -11,7 +11,6 @@ namespace System { [Imported] - [ScriptNamespace("ss")] public abstract class Record { /// diff --git a/src/Core/CoreLib/ScriptMetadata.cs b/src/Core/CoreLib/ScriptMetadata.cs index a082080e9..481b2eec6 100644 --- a/src/Core/CoreLib/ScriptMetadata.cs +++ b/src/Core/CoreLib/ScriptMetadata.cs @@ -67,32 +67,6 @@ public string Name { public sealed class IgnoreNamespaceAttribute : Attribute { } - /// - /// Specifies the namespace that should be used in generated script. The script namespace - /// is typically a short name, that is often shared across multiple assemblies. - /// The developer is responsible for ensuring that public types across assemblies that share - /// a script namespace are unique. - /// For internal types, the ScriptQualifier attribute can be used to provide a short prefix - /// to generate unique names. - /// - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Type, AllowMultiple = false)] - [NonScriptable] - [Imported] - public sealed class ScriptNamespaceAttribute : Attribute { - - private string _name; - - public ScriptNamespaceAttribute(string name) { - _name = name; - } - - public string Name { - get { - return _name; - } - } - } - /// /// This attribute can be placed on a static class that only contains static string /// fields representing a set of resource strings. diff --git a/src/Core/CoreLib/StringBuilder.cs b/src/Core/CoreLib/StringBuilder.cs index 30e3d1aab..698b4cbbe 100644 --- a/src/Core/CoreLib/StringBuilder.cs +++ b/src/Core/CoreLib/StringBuilder.cs @@ -11,7 +11,6 @@ namespace System { /// Provides an optimized mechanism to concatenate strings. /// [Imported] - [ScriptNamespace("ss")] public sealed class StringBuilder { /// diff --git a/src/Core/CoreLib/Threading/Deferred.cs b/src/Core/CoreLib/Threading/Deferred.cs index d18f3e5c8..416ba79d4 100644 --- a/src/Core/CoreLib/Threading/Deferred.cs +++ b/src/Core/CoreLib/Threading/Deferred.cs @@ -9,7 +9,6 @@ namespace System.Threading { [Imported] - [ScriptNamespace("ss")] public class Deferred { [IntrinsicProperty] @@ -30,7 +29,6 @@ public void Resolve() { } [Imported] - [ScriptNamespace("ss")] [ScriptName("Deferred")] public sealed class Deferred : Deferred { diff --git a/src/Core/CoreLib/Threading/Task.cs b/src/Core/CoreLib/Threading/Task.cs index 752d9ba6f..3afeb4d0d 100644 --- a/src/Core/CoreLib/Threading/Task.cs +++ b/src/Core/CoreLib/Threading/Task.cs @@ -9,7 +9,6 @@ namespace System.Threading { [Imported] - [ScriptNamespace("ss")] public class Task { internal Task() { @@ -73,7 +72,6 @@ public Task Then(Action doneCallback, Action failCallback) { } [Imported] - [ScriptNamespace("ss")] [ScriptName("Task")] public sealed class Task : Task { diff --git a/src/Core/CoreLib/Tuple.cs b/src/Core/CoreLib/Tuple.cs index e0da0d8a2..79f7852d1 100644 --- a/src/Core/CoreLib/Tuple.cs +++ b/src/Core/CoreLib/Tuple.cs @@ -9,7 +9,6 @@ namespace System { [Imported] - [ScriptNamespace("ss")] [ScriptName("Tuple")] public sealed class Tuple { @@ -39,7 +38,6 @@ public T2 Second { } [Imported] - [ScriptNamespace("ss")] [ScriptName("Tuple")] public sealed class Tuple { diff --git a/src/Libraries/Microsoft/BingMaps/Location/GeoLocationProvider.cs b/src/Libraries/Microsoft/BingMaps/Location/GeoLocationProvider.cs index 567aa4062..2021ed814 100644 --- a/src/Libraries/Microsoft/BingMaps/Location/GeoLocationProvider.cs +++ b/src/Libraries/Microsoft/BingMaps/Location/GeoLocationProvider.cs @@ -9,7 +9,6 @@ namespace Microsoft.Maps.Location { [Imported] - [ScriptNamespace("Microsoft.Maps")] public sealed class GeoLocationProvider { public GeoLocationProvider(Map map) { diff --git a/tests/ScriptSharp/ValidationTests.cs b/tests/ScriptSharp/ValidationTests.cs index 1d79daf07..f9b1432e7 100644 --- a/tests/ScriptSharp/ValidationTests.cs +++ b/tests/ScriptSharp/ValidationTests.cs @@ -16,9 +16,7 @@ public sealed class ValidationTests : CompilationTest { [TestMethod] public void TestConflictingTypes() { string expectedErrors = - "The type 'test.App' conflicts with another existing type with the same full name. " + - "This might be because a referenced assembly uses the same type, or you have multiple " + - "types with the same name across namespaces mapped to the same script namespace. "; + "The type 'OtherTests.App' conflicts with with 'ValidationTests.App' as they have the same name. "; Compilation compilation = CreateCompilation(); compilation.AddSource("Code.cs"); diff --git a/tests/TestCases/Basic/Conditionals/Code.cs b/tests/TestCases/Basic/Conditionals/Code.cs index ca5ec90bc..98dd9a947 100644 --- a/tests/TestCases/Basic/Conditionals/Code.cs +++ b/tests/TestCases/Basic/Conditionals/Code.cs @@ -3,7 +3,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace BasicTests { diff --git a/tests/TestCases/Basic/Conditionals/DebugBaseline.txt b/tests/TestCases/Basic/Conditionals/DebugBaseline.txt index eb4eaa464..21b6c1827 100644 --- a/tests/TestCases/Basic/Conditionals/DebugBaseline.txt +++ b/tests/TestCases/Basic/Conditionals/DebugBaseline.txt @@ -1,24 +1,24 @@ -Type.registerNamespace('test'); +Type.registerNamespace('BasicTests'); //////////////////////////////////////////////////////////////////////////////// -// test.MyDebug +// BasicTests.MyDebug -test.MyDebug = function test_MyDebug() { +BasicTests.MyDebug = function BasicTests_MyDebug() { } -test.MyDebug.showInfo = function test_MyDebug$showInfo() { +BasicTests.MyDebug.showInfo = function BasicTests_MyDebug$showInfo() { } -test.MyDebug.traceInfo = function test_MyDebug$traceInfo() { +BasicTests.MyDebug.traceInfo = function BasicTests_MyDebug$traceInfo() { } -test.MyDebug.logInfo = function test_MyDebug$logInfo() { +BasicTests.MyDebug.logInfo = function BasicTests_MyDebug$logInfo() { } //////////////////////////////////////////////////////////////////////////////// -// test.App +// BasicTests.App -test.App = function test_App(i) { +BasicTests.App = function BasicTests_App(i) { console.assert(false); - test.MyDebug.showInfo(); + BasicTests.MyDebug.showInfo(); while (true) { console.assert(false); } @@ -42,5 +42,5 @@ test.App = function test_App(i) { } -test.MyDebug.registerClass('test.MyDebug'); -test.App.registerClass('test.App'); +BasicTests.MyDebug.registerClass('BasicTests.MyDebug'); +BasicTests.App.registerClass('BasicTests.App'); diff --git a/tests/TestCases/Basic/Conditionals/TraceBaseline.txt b/tests/TestCases/Basic/Conditionals/TraceBaseline.txt index 68b6097d4..4b773147f 100644 --- a/tests/TestCases/Basic/Conditionals/TraceBaseline.txt +++ b/tests/TestCases/Basic/Conditionals/TraceBaseline.txt @@ -1,22 +1,22 @@ -Type.registerNamespace('test'); +Type.registerNamespace('BasicTests'); //////////////////////////////////////////////////////////////////////////////// -// test.MyDebug +// BasicTests.MyDebug -test.MyDebug = function() { +BasicTests.MyDebug = function() { } -test.MyDebug.showInfo = function() { +BasicTests.MyDebug.showInfo = function() { } -test.MyDebug.traceInfo = function() { +BasicTests.MyDebug.traceInfo = function() { } -test.MyDebug.logInfo = function() { +BasicTests.MyDebug.logInfo = function() { } //////////////////////////////////////////////////////////////////////////////// -// test.App +// BasicTests.App -test.App = function(i) { +BasicTests.App = function(i) { while (true) { } switch (i) { @@ -24,9 +24,9 @@ test.App = function(i) { break; } i++; - test.MyDebug.traceInfo(); + BasicTests.MyDebug.traceInfo(); } -test.MyDebug.registerClass('test.MyDebug'); -test.App.registerClass('test.App'); +BasicTests.MyDebug.registerClass('BasicTests.MyDebug'); +BasicTests.App.registerClass('BasicTests.App'); diff --git a/tests/TestCases/Basic/DocComments/Baseline.txt b/tests/TestCases/Basic/DocComments/Baseline.txt index 9bec2a60a..411ea20f3 100644 --- a/tests/TestCases/Basic/DocComments/Baseline.txt +++ b/tests/TestCases/Basic/DocComments/Baseline.txt @@ -1,9 +1,9 @@ -Type.registerNamespace('test'); +Type.registerNamespace('BasicTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Suit +// BasicTests.Suit -test.Suit = function() { +BasicTests.Suit = function() { /// /// Represents a card suit. /// @@ -20,42 +20,42 @@ test.Suit = function() { /// The diamonds. /// }; -test.Suit.prototype = { +BasicTests.Suit.prototype = { heart: 0, spade: 1, club: 2, diamond: 3 } -test.Suit.registerEnum('test.Suit', false); +BasicTests.Suit.registerEnum('BasicTests.Suit', false); //////////////////////////////////////////////////////////////////////////////// -// test.RecordClass +// BasicTests.RecordClass -test.$create_RecordClass = function test_RecordClass(count) { +BasicTests.$create_RecordClass = function BasicTests_RecordClass(count) { var $o = { }; return $o; } //////////////////////////////////////////////////////////////////////////////// -// test.IInterface +// BasicTests.IInterface -test.IInterface = function() { +BasicTests.IInterface = function() { /// /// Represents an interface. /// }; -test.IInterface.prototype = { +BasicTests.IInterface.prototype = { execute : null } -test.IInterface.registerInterface('test.IInterface'); +BasicTests.IInterface.registerInterface('BasicTests.IInterface'); //////////////////////////////////////////////////////////////////////////////// -// test.BaseClass +// BasicTests.BaseClass -test.BaseClass = function test_BaseClass(domElement, name, count) { +BasicTests.BaseClass = function BasicTests_BaseClass(domElement, name, count) { /// /// Represents a base class. /// @@ -84,14 +84,14 @@ test.BaseClass = function test_BaseClass(domElement, name, count) { /// this._domElement = domElement; } -test.BaseClass.get_totalCount = function test_BaseClass$get_totalCount() { +BasicTests.BaseClass.get_totalCount = function BasicTests_BaseClass$get_totalCount() { /// /// Gets the total count. /// /// return 0; } -test.BaseClass.staticMethod = function test_BaseClass$staticMethod(length) { +BasicTests.BaseClass.staticMethod = function BasicTests_BaseClass$staticMethod(length) { /// /// A static method. /// @@ -99,18 +99,18 @@ test.BaseClass.staticMethod = function test_BaseClass$staticMethod(length) { /// The length. /// } -test.BaseClass.prototype = { +BasicTests.BaseClass.prototype = { instanceField: 0, _domElement: null, - get_name: function test_BaseClass$get_name() { + get_name: function BasicTests_BaseClass$get_name() { /// /// Gets or sets the name. /// /// return null; }, - set_name: function test_BaseClass$set_name(value) { + set_name: function BasicTests_BaseClass$set_name(value) { /// /// Gets or sets the name. /// @@ -118,14 +118,14 @@ test.BaseClass.prototype = { return value; }, - get_domElement: function test_BaseClass$get_domElement() { + get_domElement: function BasicTests_BaseClass$get_domElement() { /// /// Gets or sets the element. /// /// return null; }, - set_domElement: function test_BaseClass$set_domElement(value) { + set_domElement: function BasicTests_BaseClass$set_domElement(value) { /// /// Gets or sets the element. /// @@ -133,7 +133,7 @@ test.BaseClass.prototype = { return value; }, - get_count: function test_BaseClass$get_count() { + get_count: function BasicTests_BaseClass$get_count() { /// /// Gets the count. /// @@ -141,7 +141,7 @@ test.BaseClass.prototype = { return 0; }, - get__privateName: function test_BaseClass$get__privateName() { + get__privateName: function BasicTests_BaseClass$get__privateName() { /// /// Gets the private name. /// @@ -149,14 +149,14 @@ test.BaseClass.prototype = { return null; }, - add_initialized: function test_BaseClass$add_initialized(value) { + add_initialized: function BasicTests_BaseClass$add_initialized(value) { /// /// Adds or removes a delegate for the Initialized event. /// /// this.__initialized = ss.Delegate.combine(this.__initialized, value); }, - remove_initialized: function test_BaseClass$remove_initialized(value) { + remove_initialized: function BasicTests_BaseClass$remove_initialized(value) { /// /// Adds or removes a delegate for the Initialized event. /// @@ -166,13 +166,13 @@ test.BaseClass.prototype = { __initialized: null, - method1: function test_BaseClass$method1() { + method1: function BasicTests_BaseClass$method1() { /// /// Empty method. /// }, - method2: function test_BaseClass$method2() { + method2: function BasicTests_BaseClass$method2() { /// /// Method with return value. /// @@ -180,7 +180,7 @@ test.BaseClass.prototype = { return null; }, - method3: function test_BaseClass$method3(first, last) { + method3: function BasicTests_BaseClass$method3(first, last) { /// /// Method with params. /// @@ -192,7 +192,7 @@ test.BaseClass.prototype = { /// }, - method4: function test_BaseClass$method4(count) { + method4: function BasicTests_BaseClass$method4(count) { /// /// Method with both params and return value. /// @@ -203,7 +203,7 @@ test.BaseClass.prototype = { return null; }, - onInitialized: function test_BaseClass$onInitialized() { + onInitialized: function BasicTests_BaseClass$onInitialized() { /// /// Raises the Initialized event. /// @@ -211,7 +211,7 @@ test.BaseClass.prototype = { } }, - _privateMethod: function test_BaseClass$_privateMethod(count) { + _privateMethod: function BasicTests_BaseClass$_privateMethod(count) { /// /// Private method. /// @@ -219,7 +219,7 @@ test.BaseClass.prototype = { /// The count. /// }, - get_item: function test_BaseClass$get_item(ids) { + get_item: function BasicTests_BaseClass$get_item(ids) { /// /// Gets item by identifiers. /// @@ -235,17 +235,17 @@ test.BaseClass.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.DerivedClass +// BasicTests.DerivedClass -test.DerivedClass = function test_DerivedClass() { +BasicTests.DerivedClass = function BasicTests_DerivedClass() { /// /// Represents a derived class. /// - test.DerivedClass.initializeBase(this, [ null, null, 0 ]); + BasicTests.DerivedClass.initializeBase(this, [ null, null, 0 ]); } -test.DerivedClass.prototype = { +BasicTests.DerivedClass.prototype = { - method3: function test_DerivedClass$method3(first, last) { + method3: function BasicTests_DerivedClass$method3(first, last) { /// /// Overriden method with params. /// @@ -260,9 +260,9 @@ test.DerivedClass.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.InternalClass +// BasicTests.InternalClass -test.InternalClass = function test_InternalClass() { +BasicTests.InternalClass = function BasicTests_InternalClass() { /// /// An internal class. /// @@ -270,25 +270,25 @@ test.InternalClass = function test_InternalClass() { //////////////////////////////////////////////////////////////////////////////// -// test.InternalClassWithNoComments +// BasicTests.InternalClassWithNoComments -test.InternalClassWithNoComments = function test_InternalClassWithNoComments() { +BasicTests.InternalClassWithNoComments = function BasicTests_InternalClassWithNoComments() { } //////////////////////////////////////////////////////////////////////////////// -// test.GlobalMethodsClass +// BasicTests.GlobalMethodsClass -window.run = function test_GlobalMethodsClass$run() { +window.run = function BasicTests_GlobalMethodsClass$run() { /// /// Runs. /// } -test.BaseClass.registerClass('test.BaseClass'); -test.DerivedClass.registerClass('test.DerivedClass', test.BaseClass); -test.InternalClass.registerClass('test.InternalClass'); -test.InternalClassWithNoComments.registerClass('test.InternalClassWithNoComments'); -test.BaseClass.constantField = 3; -test.BaseClass.staticField = null; +BasicTests.BaseClass.registerClass('BasicTests.BaseClass'); +BasicTests.DerivedClass.registerClass('BasicTests.DerivedClass', BasicTests.BaseClass); +BasicTests.InternalClass.registerClass('BasicTests.InternalClass'); +BasicTests.InternalClassWithNoComments.registerClass('BasicTests.InternalClassWithNoComments'); +BasicTests.BaseClass.constantField = 3; +BasicTests.BaseClass.staticField = null; diff --git a/tests/TestCases/Basic/DocComments/Code.cs b/tests/TestCases/Basic/DocComments/Code.cs index a91822eee..981788a6f 100644 --- a/tests/TestCases/Basic/DocComments/Code.cs +++ b/tests/TestCases/Basic/DocComments/Code.cs @@ -3,7 +3,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace BasicTests { diff --git a/tests/TestCases/Basic/Flags/Baseline.txt b/tests/TestCases/Basic/Flags/Baseline.txt index 74720d529..6a580de4b 100644 --- a/tests/TestCases/Basic/Flags/Baseline.txt +++ b/tests/TestCases/Basic/Flags/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('BasicTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// BasicTests.App -test.App = function() { +BasicTests.App = function() { } -test.App.prototype = { +BasicTests.App.prototype = { method1: function(i) { var j = i; @@ -19,4 +19,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +BasicTests.App.registerClass('BasicTests.App'); diff --git a/tests/TestCases/Basic/Flags/Code.cs b/tests/TestCases/Basic/Flags/Code.cs index 8efcaf1b9..1c67ab6cf 100644 --- a/tests/TestCases/Basic/Flags/Code.cs +++ b/tests/TestCases/Basic/Flags/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace BasicTests { diff --git a/tests/TestCases/Basic/Metadata/Baseline.txt b/tests/TestCases/Basic/Metadata/Baseline.txt index 7c45a622a..e85df447b 100644 --- a/tests/TestCases/Basic/Metadata/Baseline.txt +++ b/tests/TestCases/Basic/Metadata/Baseline.txt @@ -4058,54 +4058,54 @@ Script ================================================================ -Type.registerNamespace('test'); +Type.registerNamespace('BasicTests'); //////////////////////////////////////////////////////////////////////////////// -// test.AppFlags +// BasicTests.AppFlags -test.AppFlags = function() { }; -test.AppFlags.prototype = { +BasicTests.AppFlags = function() { }; +BasicTests.AppFlags.prototype = { AAA: 1, BBB: 2 } -test.AppFlags.registerEnum('test.AppFlags', true); +BasicTests.AppFlags.registerEnum('BasicTests.AppFlags', true); //////////////////////////////////////////////////////////////////////////////// -// test.Mode +// BasicTests.Mode -test.Mode = function() { }; -test.Mode.prototype = { +BasicTests.Mode = function() { }; +BasicTests.Mode.prototype = { mode1: 0, mode2: 1 } -test.Mode.registerEnum('test.Mode', false); +BasicTests.Mode.registerEnum('BasicTests.Mode', false); //////////////////////////////////////////////////////////////////////////////// -// test.IFoo +// BasicTests.IFoo -test.IFoo = function() { }; -test.IFoo.prototype = { +BasicTests.IFoo = function() { }; +BasicTests.IFoo.prototype = { } -test.IFoo.registerInterface('test.IFoo'); +BasicTests.IFoo.registerInterface('BasicTests.IFoo'); //////////////////////////////////////////////////////////////////////////////// -// test.IApp +// BasicTests.IApp -test.IApp = function() { }; -test.IApp.prototype = { +BasicTests.IApp = function() { }; +BasicTests.IApp.prototype = { run : null } -test.IApp.registerInterface('test.IApp'); +BasicTests.IApp.registerInterface('BasicTests.IApp'); //////////////////////////////////////////////////////////////////////////////// -// test.Point +// BasicTests.Point -test.$create_Point = function test_Point(x, y) { +BasicTests.$create_Point = function BasicTests_Point(x, y) { var $o = { }; $o.x = x; $o.y = y; @@ -4114,66 +4114,66 @@ test.$create_Point = function test_Point(x, y) { //////////////////////////////////////////////////////////////////////////////// -// test.App +// BasicTests.App -test.App = function test_App() { +BasicTests.App = function BasicTests_App() { } -test.App.prototype = { +BasicTests.App.prototype = { - add_event1: function test_App$add_event1(value) { + add_event1: function BasicTests_App$add_event1(value) { this.__event1 = ss.Delegate.combine(this.__event1, value); }, - remove_event1: function test_App$remove_event1(value) { + remove_event1: function BasicTests_App$remove_event1(value) { this.__event1 = ss.Delegate.remove(this.__event1, value); }, __event1: null, - add_event2: function test_App$add_event2(value) { + add_event2: function BasicTests_App$add_event2(value) { }, - remove_event2: function test_App$remove_event2(value) { + remove_event2: function BasicTests_App$remove_event2(value) { }, - run: function test_App$run() { + run: function BasicTests_App$run() { }, - _initialize: function test_App$_initialize() { + _initialize: function BasicTests_App$_initialize() { } } //////////////////////////////////////////////////////////////////////////////// -// test.AppHelper +// BasicTests.AppHelper -test.AppHelper = function test_AppHelper() { +BasicTests.AppHelper = function BasicTests_AppHelper() { } -test.AppHelper.prototype = { +BasicTests.AppHelper.prototype = { - get_prop1: function test_AppHelper$get_prop1() { + get_prop1: function BasicTests_AppHelper$get_prop1() { return 0; }, - get_prop2: function test_AppHelper$get_prop2() { + get_prop2: function BasicTests_AppHelper$get_prop2() { return 0; }, - set_prop2: function test_AppHelper$set_prop2(value) { + set_prop2: function BasicTests_AppHelper$set_prop2(value) { return value; }, - _showHelp: function test_AppHelper$_showHelp() { + _showHelp: function BasicTests_AppHelper$_showHelp() { }, - get_item: function test_AppHelper$get_item(name) { + get_item: function BasicTests_AppHelper$get_item(name) { return 0; } } //////////////////////////////////////////////////////////////////////////////// -// test.Util +// BasicTests.Util -window._showHelp = function test_Util$_showHelp() { +window._showHelp = function BasicTests_Util$_showHelp() { } -test.App.registerClass('test.App', null, test.IApp); -test.AppHelper.registerClass('test.AppHelper'); +BasicTests.App.registerClass('BasicTests.App', null, BasicTests.IApp); +BasicTests.AppHelper.registerClass('BasicTests.AppHelper'); diff --git a/tests/TestCases/Basic/Metadata/Code.cs b/tests/TestCases/Basic/Metadata/Code.cs index 6170ff312..a9883b908 100644 --- a/tests/TestCases/Basic/Metadata/Code.cs +++ b/tests/TestCases/Basic/Metadata/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace BasicTests { diff --git a/tests/TestCases/Basic/Minimization/Baseline.txt b/tests/TestCases/Basic/Minimization/Baseline.txt index 455f92d03..039678d26 100644 --- a/tests/TestCases/Basic/Minimization/Baseline.txt +++ b/tests/TestCases/Basic/Minimization/Baseline.txt @@ -36,21 +36,21 @@ Script ================================================================ -Type.registerNamespace('test'); +Type.registerNamespace('BasicTests'); -test.AppFlags = function() { }; -test.AppFlags.prototype = { +BasicTests.AppFlags = function() { }; +BasicTests.AppFlags.prototype = { AAA: 0, BBB: 1 } -test.AppFlags.registerEnum('test.AppFlags', false); +BasicTests.AppFlags.registerEnum('BasicTests.AppFlags', false); -test.IApp = function() { }; -test.IApp.registerInterface('test.IApp'); +BasicTests.IApp = function() { }; +BasicTests.IApp.registerInterface('BasicTests.IApp'); -test.$create_MyData = function(a, b) { +BasicTests.$create_MyData = function(a, b) { var $o = { }; $o.$0 = a; $o.$1 = b; @@ -62,11 +62,11 @@ window.run = function() { } -test.App = function() { - var helper = new test.AppHelper(); +BasicTests.App = function() { + var helper = new BasicTests.AppHelper(); helper.$0(); } -test.App.prototype = { +BasicTests.App.prototype = { run: function() { }, @@ -79,18 +79,18 @@ test.App.prototype = { } -test.AppHelper = function() { +BasicTests.AppHelper = function() { } -test.AppHelper.prototype = { +BasicTests.AppHelper.prototype = { $0: function() { } } -test.Bar = function() { +BasicTests.Bar = function() { } -test.Bar.prototype = { +BasicTests.Bar.prototype = { $0: function() { }, @@ -104,15 +104,15 @@ test.Bar.prototype = { } -test.Bar2 = function() { - test.Bar2.initializeBase(this); +BasicTests.Bar2 = function() { + BasicTests.Bar2.initializeBase(this); } -test.BarEx = function() { - test.BarEx.initializeBase(this); +BasicTests.BarEx = function() { + BasicTests.BarEx.initializeBase(this); } -test.BarEx.prototype = { +BasicTests.BarEx.prototype = { $2: function() { var mode = 1; @@ -120,8 +120,8 @@ test.BarEx.prototype = { $0: function() { this.$2(); - test.BarEx.callBaseMethod(this, '$0'); - var d = test.$create_MyData('a', 'b'); + BasicTests.BarEx.callBaseMethod(this, '$0'); + var d = BasicTests.$create_MyData('a', 'b'); d.$0 = d.$1; }, @@ -181,15 +181,15 @@ test.BarEx.prototype = { } -test.BarCustom = function() { - test.BarCustom.initializeBase(this); +BasicTests.BarCustom = function() { + BasicTests.BarCustom.initializeBase(this); } -test.BarCustom2 = function() { - test.BarCustom2.initializeBase(this); +BasicTests.BarCustom2 = function() { + BasicTests.BarCustom2.initializeBase(this); } -test.BarCustom2.prototype = { +BasicTests.BarCustom2.prototype = { $2: function() { return 0; @@ -204,13 +204,13 @@ test.BarCustom2.prototype = { } -test.FooBehavior = function(e, i) { - test.FooBehavior.initializeBase(this, [ e, null ]); +BasicTests.FooBehavior = function(e, i) { + BasicTests.FooBehavior.initializeBase(this, [ e, null ]); this.$1_0 = i; this.$1_1 = i * 2; this.$1_2 = i * 4; } -test.FooBehavior.prototype = { +BasicTests.FooBehavior.prototype = { $1_0: 0, $1_1: 0, $1_2: 0, @@ -226,7 +226,7 @@ test.FooBehavior.prototype = { dispose: function() { this.$1_0 = 0; - test.FooBehavior.callBaseMethod(this, 'dispose'); + BasicTests.FooBehavior.callBaseMethod(this, 'dispose'); }, $1_6: function() { @@ -241,10 +241,10 @@ test.FooBehavior.prototype = { } -test.MaskTextBox = function(e) { - test.MaskTextBox.initializeBase(this, [ e ]); +BasicTests.MaskTextBox = function(e) { + BasicTests.MaskTextBox.initializeBase(this, [ e ]); } -test.MaskTextBox.prototype = { +BasicTests.MaskTextBox.prototype = { $3_0: function() { }, @@ -254,50 +254,50 @@ test.MaskTextBox.prototype = { } -test.DerivedClass = function() { - test.DerivedClass.initializeBase(this); +BasicTests.DerivedClass = function() { + BasicTests.DerivedClass.initializeBase(this); } -test.DerivedClass.prototype = { +BasicTests.DerivedClass.prototype = { $2: function() { } } -test.BaseClass = function() { - test.BaseClass.initializeBase(this); +BasicTests.BaseClass = function() { + BasicTests.BaseClass.initializeBase(this); } -test.BaseClass.prototype = { +BasicTests.BaseClass.prototype = { $1: function() { } } -test.BaseBaseClass = function() { +BasicTests.BaseBaseClass = function() { } -test.BaseBaseClass.prototype = { +BasicTests.BaseBaseClass.prototype = { $0: function() { } } -test.ABC = function() { +BasicTests.ABC = function() { } -test.App.registerClass('test.App'); -test.AppHelper.registerClass('test.AppHelper'); -test.Bar.registerClass('test.Bar'); -test.Bar2.registerClass('test.Bar2', test.Bar); -test.BarEx.registerClass('test.BarEx', test.Bar2); -test.BarCustom.registerClass('test.BarCustom', test.Bar); -test.BarCustom2.registerClass('test.BarCustom2', test.BarCustom); -test.FooBehavior.registerClass('test.FooBehavior', ScriptFX.Behavior); -test.MaskTextBox.registerClass('test.MaskTextBox', ScriptFX.TextBox); -test.BaseBaseClass.registerClass('test.BaseBaseClass'); -test.BaseClass.registerClass('test.BaseClass', test.BaseBaseClass); -test.DerivedClass.registerClass('test.DerivedClass', test.BaseClass); -test.ABC.registerClass('test.ABC'); -test.FooBehavior.$1_3 = null; +BasicTests.App.registerClass('BasicTests.App'); +BasicTests.AppHelper.registerClass('BasicTests.AppHelper'); +BasicTests.Bar.registerClass('BasicTests.Bar'); +BasicTests.Bar2.registerClass('BasicTests.Bar2', BasicTests.Bar); +BasicTests.BarEx.registerClass('BasicTests.BarEx', BasicTests.Bar2); +BasicTests.BarCustom.registerClass('BasicTests.BarCustom', BasicTests.Bar); +BasicTests.BarCustom2.registerClass('BasicTests.BarCustom2', BasicTests.BarCustom); +BasicTests.FooBehavior.registerClass('BasicTests.FooBehavior', lib.Behavior); +BasicTests.MaskTextBox.registerClass('BasicTests.MaskTextBox', lib.TextBox); +BasicTests.BaseBaseClass.registerClass('BasicTests.BaseBaseClass'); +BasicTests.BaseClass.registerClass('BasicTests.BaseClass', BasicTests.BaseBaseClass); +BasicTests.DerivedClass.registerClass('BasicTests.DerivedClass', BasicTests.BaseClass); +BasicTests.ABC.registerClass('BasicTests.ABC'); +BasicTests.FooBehavior.$1_3 = null; diff --git a/tests/TestCases/Basic/Minimization/Code.cs b/tests/TestCases/Basic/Minimization/Code.cs index 94ded6c0f..670b0c518 100644 --- a/tests/TestCases/Basic/Minimization/Code.cs +++ b/tests/TestCases/Basic/Minimization/Code.cs @@ -4,7 +4,6 @@ using ScriptFX; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace BasicTests { diff --git a/tests/TestCases/Basic/Resources/Baseline.txt b/tests/TestCases/Basic/Resources/Baseline.txt index 46a8f360a..bbe0bcab5 100644 --- a/tests/TestCases/Basic/Resources/Baseline.txt +++ b/tests/TestCases/Basic/Resources/Baseline.txt @@ -1,17 +1,19 @@ -Type.registerNamespace('test'); +Type.registerNamespace('BasicTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// BasicTests.App -test.App = function test_App() { - var s1 = test.Strings1.string1; +BasicTests.App = function BasicTests_App() { + var s1 = Resources.Strings1.string1; } +Type.registerNamespace('Resources'); + //////////////////////////////////////////////////////////////////////////////// -// test.Strings1 +// Resources.Strings1 -test.Strings1 = { +Resources.Strings1 = { string1: 'neutral: aaa', string2: 'fr: bbb', string3: 'fr-FR: ccc' @@ -19,12 +21,12 @@ test.Strings1 = { //////////////////////////////////////////////////////////////////////////////// -// test.Strings2 +// Resources.Strings2 -test.Strings2 = { +Resources.Strings2 = { string1: 's2', string2: '1234' }; -test.App.registerClass('test.App'); +BasicTests.App.registerClass('BasicTests.App'); diff --git a/tests/TestCases/Basic/Resources/Code.cs b/tests/TestCases/Basic/Resources/Code.cs index 15d8060d6..aef5485e0 100644 --- a/tests/TestCases/Basic/Resources/Code.cs +++ b/tests/TestCases/Basic/Resources/Code.cs @@ -3,7 +3,6 @@ using Resources; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace BasicTests { diff --git a/tests/TestCases/Basic/Template/Baseline.txt b/tests/TestCases/Basic/Template/Baseline.txt index 9160e7d40..e4897a3fb 100644 --- a/tests/TestCases/Basic/Template/Baseline.txt +++ b/tests/TestCases/Basic/Template/Baseline.txt @@ -2,17 +2,17 @@ alert('some static script'); -Type.registerNamespace('test'); +Type.registerNamespace('BasicTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// BasicTests.App -test.App = function test_App() { +BasicTests.App = function BasicTests_App() { var e = document.body; } -test.App.registerClass('test.App'); +BasicTests.App.registerClass('BasicTests.App'); alert('debug'); diff --git a/tests/TestCases/Basic/Template/Code.cs b/tests/TestCases/Basic/Template/Code.cs index c877fcbc1..09fd30292 100644 --- a/tests/TestCases/Basic/Template/Code.cs +++ b/tests/TestCases/Basic/Template/Code.cs @@ -3,7 +3,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace BasicTests { diff --git a/tests/TestCases/Basic/UnitTest/Code.cs b/tests/TestCases/Basic/UnitTest/Code.cs index 2f975d647..9b08f79f8 100644 --- a/tests/TestCases/Basic/UnitTest/Code.cs +++ b/tests/TestCases/Basic/UnitTest/Code.cs @@ -4,7 +4,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace BasicTests { diff --git a/tests/TestCases/Basic/UnitTest/NonTestBaseline.txt b/tests/TestCases/Basic/UnitTest/NonTestBaseline.txt index 8c92ee524..5cef456bb 100644 --- a/tests/TestCases/Basic/UnitTest/NonTestBaseline.txt +++ b/tests/TestCases/Basic/UnitTest/NonTestBaseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('BasicTests'); //////////////////////////////////////////////////////////////////////////////// -// test.PublicClass +// BasicTests.PublicClass -test.PublicClass = function() { +BasicTests.PublicClass = function() { } -test.PublicClass.prototype = { +BasicTests.PublicClass.prototype = { format: function(i) { return '0'; @@ -18,11 +18,11 @@ test.PublicClass.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.InternalClass +// BasicTests.InternalClass -test.InternalClass = function() { +BasicTests.InternalClass = function() { } -test.InternalClass.prototype = { +BasicTests.InternalClass.prototype = { format: function(i) { return null; @@ -34,5 +34,5 @@ test.InternalClass.prototype = { } -test.PublicClass.registerClass('test.PublicClass'); -test.InternalClass.registerClass('test.InternalClass'); +BasicTests.PublicClass.registerClass('BasicTests.PublicClass'); +BasicTests.InternalClass.registerClass('BasicTests.InternalClass'); diff --git a/tests/TestCases/Basic/UnitTest/TestBaseline.txt b/tests/TestCases/Basic/UnitTest/TestBaseline.txt index 97e7b1d57..2a414143e 100644 --- a/tests/TestCases/Basic/UnitTest/TestBaseline.txt +++ b/tests/TestCases/Basic/UnitTest/TestBaseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('BasicTests'); //////////////////////////////////////////////////////////////////////////////// -// test.PublicClass +// BasicTests.PublicClass -test.PublicClass = function() { +BasicTests.PublicClass = function() { } -test.PublicClass.prototype = { +BasicTests.PublicClass.prototype = { format: function(i) { return '0'; @@ -18,11 +18,11 @@ test.PublicClass.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.InternalClass +// BasicTests.InternalClass -test.InternalClass = function() { +BasicTests.InternalClass = function() { } -test.InternalClass.prototype = { +BasicTests.InternalClass.prototype = { format: function(i) { return null; @@ -34,17 +34,19 @@ test.InternalClass.prototype = { } +Type.registerNamespace('BasicTests.Tests'); + //////////////////////////////////////////////////////////////////////////////// -// test.PublicTests +// BasicTests.Tests.PublicTests -test.PublicTests = function() { - test.PublicTests.initializeBase(this); +BasicTests.Tests.PublicTests = function() { + BasicTests.Tests.PublicTests.initializeBase(this); } -test.PublicTests.prototype = { +BasicTests.Tests.PublicTests.prototype = { testFormat: function() { QUnit.expect(1); - var testee = new test.PublicClass(); + var testee = new BasicTests.PublicClass(); var s = testee.format(0); QUnit.equal(s, '0', "Expected '0' for result."); } @@ -52,25 +54,25 @@ test.PublicTests.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.InternalTests +// BasicTests.Tests.InternalTests -test.InternalTests = function() { - test.InternalTests.initializeBase(this); +BasicTests.Tests.InternalTests = function() { + BasicTests.Tests.InternalTests.initializeBase(this); } -test.InternalTests.prototype = { +BasicTests.Tests.InternalTests.prototype = { _startTime: null, _endTime: null, testFormat: function() { QUnit.expect(1); - var testee = new test.InternalClass(); + var testee = new BasicTests.InternalClass(); var s = testee.format(0); QUnit.equal(s, '0', "Expected '0' for result."); }, testParse: function() { QUnit.expect(1); - var testee = new test.InternalClass(); + var testee = new BasicTests.InternalClass(); var i = testee.parse('0'); QUnit.equal(i, 0, 'Expected 0 for result.'); }, @@ -85,14 +87,14 @@ test.InternalTests.prototype = { } -test.PublicClass.registerClass('test.PublicClass'); -test.InternalClass.registerClass('test.InternalClass'); -test.PublicTests.registerClass('test.PublicTests'); -test.InternalTests.registerClass('test.InternalTests'); +BasicTests.PublicClass.registerClass('BasicTests.PublicClass'); +BasicTests.InternalClass.registerClass('BasicTests.InternalClass'); +BasicTests.Tests.PublicTests.registerClass('BasicTests.Tests.PublicTests'); +BasicTests.Tests.InternalTests.registerClass('BasicTests.Tests.InternalTests'); module('PublicTests', { setup: function() { - this.instance = new test.PublicTests(); + this.instance = new BasicTests.Tests.PublicTests(); }, teardown: function() { delete this.instance; @@ -105,7 +107,7 @@ test('testFormat', function() { module('InternalTests', { setup: function() { - this.instance = new test.InternalTests(); + this.instance = new BasicTests.Tests.InternalTests(); this.instance.setup(); }, teardown: function() { diff --git a/tests/TestCases/Expression/AnonymousMethods/Baseline.txt b/tests/TestCases/Expression/AnonymousMethods/Baseline.txt index c1f3ea93c..05b6fbe22 100644 --- a/tests/TestCases/Expression/AnonymousMethods/Baseline.txt +++ b/tests/TestCases/Expression/AnonymousMethods/Baseline.txt @@ -1,27 +1,27 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.SomeClass +// ExpressionTests.SomeClass -test.SomeClass = function(cb) { +ExpressionTests.SomeClass = function(cb) { } //////////////////////////////////////////////////////////////////////////////// -// test.Test +// ExpressionTests.Test -test.Test = function() { +ExpressionTests.Test = function() { } -test.Test.main = function(args) { +ExpressionTests.Test.main = function(args) { var o = {}; var name; - test.Test.doStuffStatic(o, function(i, s, b) { + ExpressionTests.Test.doStuffStatic(o, function(i, s, b) { name = s; }); } -test.Test.doStuffStatic = function(o, callback) { +ExpressionTests.Test.doStuffStatic = function(o, callback) { } -test.Test.prototype = { +ExpressionTests.Test.prototype = { _n: 0, AAA: function() { @@ -29,7 +29,7 @@ test.Test.prototype = { this.doStuff(o, ss.Delegate.create(this, function(i, s, b) { this._n = i; })); - var s = new test.SomeClass(function() { + var s = new ExpressionTests.SomeClass(function() { }); for (var i = 0; i < 10; i++) { var foo; @@ -39,13 +39,13 @@ test.Test.prototype = { this.doStuff(o, ss.Delegate.create(this, function(i, s, b) { this._n += i; })); - test.Test.doStuffStatic(o, function() { + ExpressionTests.Test.doStuffStatic(o, function() { }); - test.Test.doStuffStatic(o, ss.Delegate.create(this, function() { + ExpressionTests.Test.doStuffStatic(o, ss.Delegate.create(this, function() { this._n++; })); } - var s2 = new test.SomeClass(ss.Delegate.create(this, function() { + var s2 = new ExpressionTests.SomeClass(ss.Delegate.create(this, function() { var numbers = [ this._n ]; })); }, @@ -55,5 +55,5 @@ test.Test.prototype = { } -test.SomeClass.registerClass('test.SomeClass'); -test.Test.registerClass('test.Test'); +ExpressionTests.SomeClass.registerClass('ExpressionTests.SomeClass'); +ExpressionTests.Test.registerClass('ExpressionTests.Test'); diff --git a/tests/TestCases/Expression/AnonymousMethods/Code.cs b/tests/TestCases/Expression/AnonymousMethods/Code.cs index a66915d12..ec0855c8b 100644 --- a/tests/TestCases/Expression/AnonymousMethods/Code.cs +++ b/tests/TestCases/Expression/AnonymousMethods/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Arguments/Baseline.txt b/tests/TestCases/Expression/Arguments/Baseline.txt index fc9ea7db0..59875ea79 100644 --- a/tests/TestCases/Expression/Arguments/Baseline.txt +++ b/tests/TestCases/Expression/Arguments/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { var count = arguments.length; @@ -15,4 +15,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/Arguments/Code.cs b/tests/TestCases/Expression/Arguments/Code.cs index 7e8573e19..20ea7a4d9 100644 --- a/tests/TestCases/Expression/Arguments/Code.cs +++ b/tests/TestCases/Expression/Arguments/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Base/Baseline.txt b/tests/TestCases/Expression/Base/Baseline.txt index c2efec3aa..724c9f4d8 100644 --- a/tests/TestCases/Expression/Base/Baseline.txt +++ b/tests/TestCases/Expression/Base/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Foo +// ExpressionTests.Foo -test.Foo = function(i, j) { +ExpressionTests.Foo = function(i, j) { } -test.Foo.prototype = { +ExpressionTests.Foo.prototype = { toString: function() { return 'Foo'; @@ -18,22 +18,22 @@ test.Foo.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.Bar +// ExpressionTests.Bar -test.Bar = function(i, j, f) { - test.Bar.initializeBase(this, [ i, j ]); +ExpressionTests.Bar = function(i, j, f) { + ExpressionTests.Bar.initializeBase(this, [ i, j ]); } -test.Bar.prototype = { +ExpressionTests.Bar.prototype = { sum: function() { - return test.Bar.callBaseMethod(this, 'sum', [ 1 ]) + 1; + return ExpressionTests.Bar.callBaseMethod(this, 'sum', [ 1 ]) + 1; }, toString: function() { - return test.Bar.callBaseMethod(this, 'toString') + ' -> Bar'; + return ExpressionTests.Bar.callBaseMethod(this, 'toString') + ' -> Bar'; } } -test.Foo.registerClass('test.Foo'); -test.Bar.registerClass('test.Bar', test.Foo); +ExpressionTests.Foo.registerClass('ExpressionTests.Foo'); +ExpressionTests.Bar.registerClass('ExpressionTests.Bar', ExpressionTests.Foo); diff --git a/tests/TestCases/Expression/Base/Code.cs b/tests/TestCases/Expression/Base/Code.cs index 15190ff4d..67b2f6f94 100644 --- a/tests/TestCases/Expression/Base/Code.cs +++ b/tests/TestCases/Expression/Base/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Binary/Baseline.txt b/tests/TestCases/Expression/Binary/Baseline.txt index bad74ddf1..b01f96021 100644 --- a/tests/TestCases/Expression/Binary/Baseline.txt +++ b/tests/TestCases/Expression/Binary/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Data +// ExpressionTests.Data -test.Data = function() { +ExpressionTests.Data = function() { } -test.Data.prototype = { +ExpressionTests.Data.prototype = { _value: 0, get_value: function() { @@ -26,11 +26,11 @@ test.Data.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { get_foo: function() { return 0; @@ -47,7 +47,7 @@ test.App.prototype = { }, get_data: function() { - return new test.Data(); + return new ExpressionTests.Data(); }, set_data: function(value) { return value; @@ -58,7 +58,7 @@ test.App.prototype = { }, get_flag2: function() { - return test.Data.staticFlag; + return ExpressionTests.Data.staticFlag; }, test: function(arg1, arg2) { @@ -89,7 +89,7 @@ test.App.prototype = { abc = xyz >>> 2; abc <<= 1; xyz >>>= 1; - var d = new test.Data(); + var d = new ExpressionTests.Data(); d.set_value(d.get_value() + 5); d.set_flag((d.get_flag() | true) === 1); var o1 = null || {}; @@ -108,7 +108,7 @@ test.App.prototype = { b = (b | true) === 1; c = (c ^ true) === 1; a = (a | (a || a)) === 1; - var d = new test.Data(); + var d = new ExpressionTests.Data(); d.set_flag((d.get_flag() & true) === 1); d.set_flag((d.get_flag() | true) === 1); d.set_flag((d.get_flag() ^ true) === 1); @@ -116,6 +116,6 @@ test.App.prototype = { } -test.Data.registerClass('test.Data'); -test.App.registerClass('test.App'); -test.Data.staticFlag = false; +ExpressionTests.Data.registerClass('ExpressionTests.Data'); +ExpressionTests.App.registerClass('ExpressionTests.App'); +ExpressionTests.Data.staticFlag = false; diff --git a/tests/TestCases/Expression/Binary/Code.cs b/tests/TestCases/Expression/Binary/Code.cs index 486d4c8e0..b00e9fcbe 100644 --- a/tests/TestCases/Expression/Binary/Code.cs +++ b/tests/TestCases/Expression/Binary/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Cast/Baseline.txt b/tests/TestCases/Expression/Cast/Baseline.txt index 2467d09dc..64f33ba7d 100644 --- a/tests/TestCases/Expression/Cast/Baseline.txt +++ b/tests/TestCases/Expression/Cast/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { var f = arg / 2; @@ -34,4 +34,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/Cast/Code.cs b/tests/TestCases/Expression/Cast/Code.cs index 30ac3e5d3..064026722 100644 --- a/tests/TestCases/Expression/Cast/Code.cs +++ b/tests/TestCases/Expression/Cast/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Conditional/Baseline.txt b/tests/TestCases/Expression/Conditional/Baseline.txt index e37cbb97b..b19399a27 100644 --- a/tests/TestCases/Expression/Conditional/Baseline.txt +++ b/tests/TestCases/Expression/Conditional/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { var b = (!arg) ? true : false; @@ -18,4 +18,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/Conditional/Code.cs b/tests/TestCases/Expression/Conditional/Code.cs index 3a70a591b..fda55b7b6 100644 --- a/tests/TestCases/Expression/Conditional/Code.cs +++ b/tests/TestCases/Expression/Conditional/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Delegates/Baseline.txt b/tests/TestCases/Expression/Delegates/Baseline.txt index 55cd0eb8b..03c1114b6 100644 --- a/tests/TestCases/Expression/Delegates/Baseline.txt +++ b/tests/TestCases/Expression/Delegates/Baseline.txt @@ -1,31 +1,31 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.EventArgs +// ExpressionTests.EventArgs -test.EventArgs = function() { +ExpressionTests.EventArgs = function() { } //////////////////////////////////////////////////////////////////////////////// -// test.SomeClass +// ExpressionTests.SomeClass -test.SomeClass = function(handler) { +ExpressionTests.SomeClass = function(handler) { } //////////////////////////////////////////////////////////////////////////////// -// test.Test +// ExpressionTests.Test -test.Test = function() { +ExpressionTests.Test = function() { this._handler = ss.Delegate.create(this, this.onEvent); this._handler = ss.Delegate.create(this, this.onEvent); this._handler = ss.Delegate.create(this, this.onEvent); - this._handler = test.Test2.onGlobalEvent; - var s1 = new test.SomeClass(ss.Delegate.create(this, this.onEvent)); - var s2 = new test.SomeClass(this._handler); + this._handler = ExpressionTests.Test2.onGlobalEvent; + var s1 = new ExpressionTests.SomeClass(ss.Delegate.create(this, this.onEvent)); + var s2 = new ExpressionTests.SomeClass(this._handler); } -test.Test.prototype = { +ExpressionTests.Test.prototype = { _handler: null, doStuff: function() { @@ -40,15 +40,15 @@ test.Test.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.Test2 +// ExpressionTests.Test2 -test.Test2 = function() { +ExpressionTests.Test2 = function() { } -test.Test2.onGlobalEvent = function(sender, e) { +ExpressionTests.Test2.onGlobalEvent = function(sender, e) { } -test.EventArgs.registerClass('test.EventArgs'); -test.SomeClass.registerClass('test.SomeClass'); -test.Test.registerClass('test.Test'); -test.Test2.registerClass('test.Test2'); +ExpressionTests.EventArgs.registerClass('ExpressionTests.EventArgs'); +ExpressionTests.SomeClass.registerClass('ExpressionTests.SomeClass'); +ExpressionTests.Test.registerClass('ExpressionTests.Test'); +ExpressionTests.Test2.registerClass('ExpressionTests.Test2'); diff --git a/tests/TestCases/Expression/Delegates/Code.cs b/tests/TestCases/Expression/Delegates/Code.cs index 0eaf59565..bf316d08b 100644 --- a/tests/TestCases/Expression/Delegates/Code.cs +++ b/tests/TestCases/Expression/Delegates/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Dictionary/Baseline.txt b/tests/TestCases/Expression/Dictionary/Baseline.txt index 02ed22509..febff6e3e 100644 --- a/tests/TestCases/Expression/Dictionary/Baseline.txt +++ b/tests/TestCases/Expression/Dictionary/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { getData: function() { return null; @@ -17,7 +17,7 @@ test.App.prototype = { test: function(arg) { var dictionary1 = {}; - var dictionary2 = { xyz: 1, abc: new test.App(), 'delete': 2, 'test.': 3, '\t': 4 }; + var dictionary2 = { xyz: 1, abc: new ExpressionTests.App(), 'delete': 2, 'test.': 3, '\t': 4 }; }, test2: function(arg) { @@ -48,4 +48,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/Dictionary/Code.cs b/tests/TestCases/Expression/Dictionary/Code.cs index 73551bfa5..f9c811c3e 100644 --- a/tests/TestCases/Expression/Dictionary/Code.cs +++ b/tests/TestCases/Expression/Dictionary/Code.cs @@ -4,7 +4,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/EnumToString/Code1.cs b/tests/TestCases/Expression/EnumToString/Code1.cs index a420c7245..fe839bb60 100644 --- a/tests/TestCases/Expression/EnumToString/Code1.cs +++ b/tests/TestCases/Expression/EnumToString/Code1.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/EnumToString/Code2.cs b/tests/TestCases/Expression/EnumToString/Code2.cs index a6c7de2ff..a657b1196 100644 --- a/tests/TestCases/Expression/EnumToString/Code2.cs +++ b/tests/TestCases/Expression/EnumToString/Code2.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/EnumToString/MinBaseline.txt b/tests/TestCases/Expression/EnumToString/MinBaseline.txt index c55a506aa..16876dd1b 100644 --- a/tests/TestCases/Expression/EnumToString/MinBaseline.txt +++ b/tests/TestCases/Expression/EnumToString/MinBaseline.txt @@ -1,8 +1,8 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { var s1 = (0).toString(); @@ -20,4 +20,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/EnumToString/NormalBaseline.txt b/tests/TestCases/Expression/EnumToString/NormalBaseline.txt index 2126c3d9f..4afddba2e 100644 --- a/tests/TestCases/Expression/EnumToString/NormalBaseline.txt +++ b/tests/TestCases/Expression/EnumToString/NormalBaseline.txt @@ -1,48 +1,48 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Color +// ExpressionTests.Color -test.Color = function() { }; -test.Color.prototype = { +ExpressionTests.Color = function() { }; +ExpressionTests.Color.prototype = { red: 1, green: 2, blue: 3 } -test.Color.registerEnum('test.Color', false); +ExpressionTests.Color.registerEnum('ExpressionTests.Color', false); //////////////////////////////////////////////////////////////////////////////// -// test.State +// ExpressionTests.State -test.State = function() { }; -test.State.prototype = { +ExpressionTests.State = function() { }; +ExpressionTests.State.prototype = { starting: 'starting', running: 'running', completed: 'completed' } -test.State.registerEnum('test.State', false); +ExpressionTests.State.registerEnum('ExpressionTests.State', false); //////////////////////////////////////////////////////////////////////////////// -// test.Types +// ExpressionTests.Types -test.Types = function() { }; -test.Types.prototype = { +ExpressionTests.Types = function() { }; +ExpressionTests.Types.prototype = { none: 0, type1: 1, type2: 2, type3: 4 } -test.Types.registerEnum('test.Types', true); +ExpressionTests.Types.registerEnum('ExpressionTests.Types', true); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { var s1 = (0).toString(); @@ -60,4 +60,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/Events/Baseline.txt b/tests/TestCases/Expression/Events/Baseline.txt index be1954b23..2158ed614 100644 --- a/tests/TestCases/Expression/Events/Baseline.txt +++ b/tests/TestCases/Expression/Events/Baseline.txt @@ -1,25 +1,25 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.FooEventArgs +// ExpressionTests.FooEventArgs -test.FooEventArgs = function() { - test.FooEventArgs.initializeBase(this); +ExpressionTests.FooEventArgs = function() { + ExpressionTests.FooEventArgs.initializeBase(this); } //////////////////////////////////////////////////////////////////////////////// -// test.Button +// ExpressionTests.Button -test.Button = function() { +ExpressionTests.Button = function() { } -test.Button.add_test = function(value) { - test.Button.__test = ss.Delegate.combine(test.Button.__test, value); +ExpressionTests.Button.add_test = function(value) { + ExpressionTests.Button.__test = ss.Delegate.combine(ExpressionTests.Button.__test, value); } -test.Button.remove_test = function(value) { - test.Button.__test = ss.Delegate.remove(test.Button.__test, value); +ExpressionTests.Button.remove_test = function(value) { + ExpressionTests.Button.__test = ss.Delegate.remove(ExpressionTests.Button.__test, value); } -test.Button.prototype = { +ExpressionTests.Button.prototype = { _aaa: null, _bbb: null, @@ -59,21 +59,21 @@ test.Button.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { this._btn.add_click(ss.Delegate.create(this, this.onClickButton)); this._btn.add_click(ss.Delegate.create(this, this.onClickButton)); this._btn.add_click(ss.Delegate.create(this, this.onClickButton)); this._btn.remove_click(ss.Delegate.create(this, this.onClickButton)); this._btn.remove_click(ss.Delegate.create(this, this.onClickButton)); this._btn.remove_click(ss.Delegate.create(this, this.onClickButton)); - test.Button.add_test(test.App.onTestButton); - test.Button.add_test(test.App.onTestButton); - test.Button.add_test(test.App.onTestButton); - test.Button.remove_test(test.App.onTestButton); - test.Button.remove_test(test.App.onTestButton); - test.Button.remove_test(test.App.onTestButton); + ExpressionTests.Button.add_test(ExpressionTests.App.onTestButton); + ExpressionTests.Button.add_test(ExpressionTests.App.onTestButton); + ExpressionTests.Button.add_test(ExpressionTests.App.onTestButton); + ExpressionTests.Button.remove_test(ExpressionTests.App.onTestButton); + ExpressionTests.Button.remove_test(ExpressionTests.App.onTestButton); + ExpressionTests.Button.remove_test(ExpressionTests.App.onTestButton); this._btn.add_aaa(ss.Delegate.create(this, this.onAAAButton)); this._btn.add_aaa(ss.Delegate.create(this, this.onAAAButton)); this._btn.add_aaa(ss.Delegate.create(this, this.onAAAButton)); @@ -81,9 +81,9 @@ test.App = function() { this._btn.remove_aaa(ss.Delegate.create(this, this.onAAAButton)); this._btn.remove_aaa(ss.Delegate.create(this, this.onAAAButton)); } -test.App.onTestButton = function(sender, e) { +ExpressionTests.App.onTestButton = function(sender, e) { } -test.App.prototype = { +ExpressionTests.App.prototype = { _btn: null, onAAAButton: function(sender, e) { @@ -94,7 +94,7 @@ test.App.prototype = { } -test.FooEventArgs.registerClass('test.FooEventArgs', ss.EventArgs); -test.Button.registerClass('test.Button'); -test.App.registerClass('test.App'); -test.Button.__test = null; +ExpressionTests.FooEventArgs.registerClass('ExpressionTests.FooEventArgs', ss.EventArgs); +ExpressionTests.Button.registerClass('ExpressionTests.Button'); +ExpressionTests.App.registerClass('ExpressionTests.App'); +ExpressionTests.Button.__test = null; diff --git a/tests/TestCases/Expression/Events/Code.cs b/tests/TestCases/Expression/Events/Code.cs index 0c439c4c6..3e18a09df 100644 --- a/tests/TestCases/Expression/Events/Code.cs +++ b/tests/TestCases/Expression/Events/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Generics/Baseline.txt b/tests/TestCases/Expression/Generics/Baseline.txt index dfc6b78b0..30394e6bd 100644 --- a/tests/TestCases/Expression/Generics/Baseline.txt +++ b/tests/TestCases/Expression/Generics/Baseline.txt @@ -1,9 +1,9 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Foo +// ExpressionTests.Foo -test.Foo = function() { +ExpressionTests.Foo = function() { this._numbers = []; var s = this._numbers[10].format('{0}'); var s2 = this._numbers.getEnumerator().current.format('{0}'); @@ -29,7 +29,7 @@ test.Foo = function() { var f = JSON.parse(json).setup().run().cleanup(); var name = document.getElementById('nameTB').value; } -test.Foo.prototype = { +ExpressionTests.Foo.prototype = { _numbers: null, _func: null, @@ -47,4 +47,4 @@ test.Foo.prototype = { } -test.Foo.registerClass('test.Foo'); +ExpressionTests.Foo.registerClass('ExpressionTests.Foo'); diff --git a/tests/TestCases/Expression/Generics/Code.cs b/tests/TestCases/Expression/Generics/Code.cs index df438a2a2..4e3dc2277 100644 --- a/tests/TestCases/Expression/Generics/Code.cs +++ b/tests/TestCases/Expression/Generics/Code.cs @@ -6,7 +6,6 @@ using jQueryApi; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/GetType/Baseline.txt b/tests/TestCases/Expression/GetType/Baseline.txt index 382bddf0c..c864bef3e 100644 --- a/tests/TestCases/Expression/GetType/Baseline.txt +++ b/tests/TestCases/Expression/GetType/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { get_foo: function() { return 0; @@ -19,4 +19,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/GetType/Code.cs b/tests/TestCases/Expression/GetType/Code.cs index 3697cfa03..5ab6b1d7e 100644 --- a/tests/TestCases/Expression/GetType/Code.cs +++ b/tests/TestCases/Expression/GetType/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/GlobalMethods/Baseline.txt b/tests/TestCases/Expression/GlobalMethods/Baseline.txt index 405080a19..4bd430f2d 100644 --- a/tests/TestCases/Expression/GlobalMethods/Baseline.txt +++ b/tests/TestCases/Expression/GlobalMethods/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { eval('[ 1, 2 ]'); @@ -16,10 +16,10 @@ test.App.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.Util +// ExpressionTests.Util window.foo = function() { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/GlobalMethods/Code.cs b/tests/TestCases/Expression/GlobalMethods/Code.cs index c6b5e47ba..e746096b4 100644 --- a/tests/TestCases/Expression/GlobalMethods/Code.cs +++ b/tests/TestCases/Expression/GlobalMethods/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/InlineScript/Baseline.txt b/tests/TestCases/Expression/InlineScript/Baseline.txt index 0de43d7db..2a07bc95a 100644 --- a/tests/TestCases/Expression/InlineScript/Baseline.txt +++ b/tests/TestCases/Expression/InlineScript/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { arg + 1; @@ -18,4 +18,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/InlineScript/Code.cs b/tests/TestCases/Expression/InlineScript/Code.cs index ccaee7a64..886ecdd29 100644 --- a/tests/TestCases/Expression/InlineScript/Code.cs +++ b/tests/TestCases/Expression/InlineScript/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/LateBound/Baseline.txt b/tests/TestCases/Expression/LateBound/Baseline.txt index 8ade21051..aa43b6fa3 100644 --- a/tests/TestCases/Expression/LateBound/Baseline.txt +++ b/tests/TestCases/Expression/LateBound/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { var o; @@ -41,4 +41,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/LateBound/Code.cs b/tests/TestCases/Expression/LateBound/Code.cs index adb7b25a7..9cead415e 100644 --- a/tests/TestCases/Expression/LateBound/Code.cs +++ b/tests/TestCases/Expression/LateBound/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Literals/Baseline.txt b/tests/TestCases/Expression/Literals/Baseline.txt index 619e4cb34..b34eaed9b 100644 --- a/tests/TestCases/Expression/Literals/Baseline.txt +++ b/tests/TestCases/Expression/Literals/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { var i = 0; @@ -28,7 +28,7 @@ test.App.prototype = { var s5 = 'abc\u00a9'; var s6 = "abc'xyz"; var s7 = 'abc"xyz'; - var t = test.App; + var t = ExpressionTests.App; var t2 = Number; var t3 = Number; var t4 = Object; @@ -37,4 +37,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/Literals/Code.cs b/tests/TestCases/Expression/Literals/Code.cs index d66b6d1ce..dc7e1cbd7 100644 --- a/tests/TestCases/Expression/Literals/Code.cs +++ b/tests/TestCases/Expression/Literals/Code.cs @@ -3,7 +3,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Locals/Baseline.txt b/tests/TestCases/Expression/Locals/Baseline.txt index e1c82be80..4a2578ef9 100644 --- a/tests/TestCases/Expression/Locals/Baseline.txt +++ b/tests/TestCases/Expression/Locals/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { var x; @@ -28,4 +28,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/Locals/Code.cs b/tests/TestCases/Expression/Locals/Code.cs index 36f783c66..8356d8e2a 100644 --- a/tests/TestCases/Expression/Locals/Code.cs +++ b/tests/TestCases/Expression/Locals/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Members/Baseline.txt b/tests/TestCases/Expression/Members/Baseline.txt index 1cab1c449..8659e81f3 100644 --- a/tests/TestCases/Expression/Members/Baseline.txt +++ b/tests/TestCases/Expression/Members/Baseline.txt @@ -1,26 +1,26 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.IFoo +// ExpressionTests.IFoo -test.IFoo = function() { }; -test.IFoo.registerInterface('test.IFoo'); +ExpressionTests.IFoo = function() { }; +ExpressionTests.IFoo.registerInterface('ExpressionTests.IFoo'); //////////////////////////////////////////////////////////////////////////////// -// test.BApp +// ExpressionTests.BApp -test.BApp = function() { +ExpressionTests.BApp = function() { } //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { - test.App.initializeBase(this); +ExpressionTests.App = function() { + ExpressionTests.App.initializeBase(this); } -test.App.prototype = { +ExpressionTests.App.prototype = { _value: 0, _value2: 0, @@ -47,8 +47,8 @@ test.App.prototype = { n = this._value; this._value = n; this._value = n; - n = test.App.myDefault; - n = test.App.myDefault; + n = ExpressionTests.App.myDefault; + n = ExpressionTests.App.myDefault; n = 3; n = 3; n = 3; @@ -59,25 +59,25 @@ test.App.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.DApp +// ExpressionTests.DApp -test.DApp = function() { - test.DApp.initializeBase(this); +ExpressionTests.DApp = function() { + ExpressionTests.DApp.initializeBase(this); } -test.DApp.prototype = { +ExpressionTests.DApp.prototype = { test2: function() { var n = this.get_XYZ(); n = this.get_XYZ(); - n = test.DApp.callBaseMethod(this, 'get_XYZ'); + n = ExpressionTests.DApp.callBaseMethod(this, 'get_XYZ'); this.set_XYZ(n); this.set_XYZ(n); - test.DApp.callBaseMethod(this, 'set_XYZ', [ n ]); + ExpressionTests.DApp.callBaseMethod(this, 'set_XYZ', [ n ]); this._value2 = n; this._value2 = n; this._value2 = n; - n = test.App.myDefault2; - n = test.App.myDefault2; + n = ExpressionTests.App.myDefault2; + n = ExpressionTests.App.myDefault2; n = 3; n = 3; n = 3; @@ -99,10 +99,10 @@ test.DApp.prototype = { } -test.BApp.registerClass('test.BApp'); -test.App.registerClass('test.App', test.BApp); -test.DApp.registerClass('test.DApp', test.App); -test.BApp.myConstant = 3; -test.App.myConstant2 = 3; -test.App.myDefault = 1; -test.App.myDefault2 = 2; +ExpressionTests.BApp.registerClass('ExpressionTests.BApp'); +ExpressionTests.App.registerClass('ExpressionTests.App', ExpressionTests.BApp); +ExpressionTests.DApp.registerClass('ExpressionTests.DApp', ExpressionTests.App); +ExpressionTests.BApp.myConstant = 3; +ExpressionTests.App.myConstant2 = 3; +ExpressionTests.App.myDefault = 1; +ExpressionTests.App.myDefault2 = 2; diff --git a/tests/TestCases/Expression/Members/Code.cs b/tests/TestCases/Expression/Members/Code.cs index a6eb46815..fb26a936c 100644 --- a/tests/TestCases/Expression/Members/Code.cs +++ b/tests/TestCases/Expression/Members/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/New/Baseline.txt b/tests/TestCases/Expression/New/Baseline.txt index b3353d230..1fd19e632 100644 --- a/tests/TestCases/Expression/New/Baseline.txt +++ b/tests/TestCases/Expression/New/Baseline.txt @@ -1,9 +1,9 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Point +// ExpressionTests.Point -test.$create_Point = function(x, y) { +ExpressionTests.$create_Point = function(x, y) { var $o = { }; $o.x = x; $o.y = y; @@ -12,28 +12,28 @@ test.$create_Point = function(x, y) { //////////////////////////////////////////////////////////////////////////////// -// test.Foo +// ExpressionTests.Foo -test.Foo = function(i, j) { +ExpressionTests.Foo = function(i, j) { } //////////////////////////////////////////////////////////////////////////////// -// test.Bar +// ExpressionTests.Bar -test.Bar = function(i, j, f) { +ExpressionTests.Bar = function(i, j, f) { } //////////////////////////////////////////////////////////////////////////////// -// test.Test +// ExpressionTests.Test -test.Test = function() { +ExpressionTests.Test = function() { } -test.Test.main = function() { - var f = new test.Foo(0, 1); - var b = new test.Bar(0, 1, new test.Foo(0, 1)); - var t = new test.Test(); +ExpressionTests.Test.main = function() { + var f = new ExpressionTests.Foo(0, 1); + var b = new ExpressionTests.Bar(0, 1, new ExpressionTests.Foo(0, 1)); + var t = new ExpressionTests.Test(); var d = new Date('3/9/1976'); var items = []; var items2 = [ 1, 2 ]; @@ -44,19 +44,19 @@ test.Test.main = function() { var list3 = ['abc', 'def', 'ghi']; var list4 = [1, 2, 3]; var dates = [ new Date('1/1/2006'), new Date('1/1/2005') ]; - var p = test.$create_Point(0, 0); + var p = ExpressionTests.$create_Point(0, 0); var cd = {}; var cd2 = { abc: 123, def: true }; - var o1 = new test.Test(); - var type1 = test.Foo; + var o1 = new ExpressionTests.Test(); + var type1 = ExpressionTests.Foo; var o2 = new type1(1, 2); - var o3 = new test.Bar(1, 2, o2); + var o3 = new ExpressionTests.Bar(1, 2, o2); var f1 = new Function("alert('hello');"); var f2 = new Function('s', 'alert(s);'); var f3 = new Function('greeting', 'name', "alert(greeting + ' ' + name + '!');"); } -test.Foo.registerClass('test.Foo'); -test.Bar.registerClass('test.Bar'); -test.Test.registerClass('test.Test'); +ExpressionTests.Foo.registerClass('ExpressionTests.Foo'); +ExpressionTests.Bar.registerClass('ExpressionTests.Bar'); +ExpressionTests.Test.registerClass('ExpressionTests.Test'); diff --git a/tests/TestCases/Expression/New/Code.cs b/tests/TestCases/Expression/New/Code.cs index 53ffcc3a2..be3caaa2c 100644 --- a/tests/TestCases/Expression/New/Code.cs +++ b/tests/TestCases/Expression/New/Code.cs @@ -3,7 +3,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Number/Baseline.txt b/tests/TestCases/Expression/Number/Baseline.txt index a5e215886..6bd053c65 100644 --- a/tests/TestCases/Expression/Number/Baseline.txt +++ b/tests/TestCases/Expression/Number/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { var i = parseInt('5'); @@ -16,4 +16,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/Number/Code.cs b/tests/TestCases/Expression/Number/Code.cs index 671b6e034..d3ab65c94 100644 --- a/tests/TestCases/Expression/Number/Code.cs +++ b/tests/TestCases/Expression/Number/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Script/Baseline.txt b/tests/TestCases/Expression/Script/Baseline.txt index 388a101cb..5420db523 100644 --- a/tests/TestCases/Expression/Script/Baseline.txt +++ b/tests/TestCases/Expression/Script/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { arg = (arg || 10); @@ -16,4 +16,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/Script/Code.cs b/tests/TestCases/Expression/Script/Code.cs index f65f9111f..7f764968a 100644 --- a/tests/TestCases/Expression/Script/Code.cs +++ b/tests/TestCases/Expression/Script/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/String/Baseline.txt b/tests/TestCases/Expression/String/Baseline.txt index 9db6e2f66..442b20a05 100644 --- a/tests/TestCases/Expression/String/Baseline.txt +++ b/tests/TestCases/Expression/String/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { var s = 'Hello'; @@ -20,4 +20,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/String/Code.cs b/tests/TestCases/Expression/String/Code.cs index 89fd1daf2..d249513c6 100644 --- a/tests/TestCases/Expression/String/Code.cs +++ b/tests/TestCases/Expression/String/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Truthy/Baseline.txt b/tests/TestCases/Expression/Truthy/Baseline.txt index a9c401c86..0fcf643c4 100644 --- a/tests/TestCases/Expression/Truthy/Baseline.txt +++ b/tests/TestCases/Expression/Truthy/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { var i; @@ -61,4 +61,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/Truthy/Code.cs b/tests/TestCases/Expression/Truthy/Code.cs index 82958126a..5f56bc735 100644 --- a/tests/TestCases/Expression/Truthy/Code.cs +++ b/tests/TestCases/Expression/Truthy/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Expression/Unary/Baseline.txt b/tests/TestCases/Expression/Unary/Baseline.txt index cbe26248b..1b4acc99f 100644 --- a/tests/TestCases/Expression/Unary/Baseline.txt +++ b/tests/TestCases/Expression/Unary/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('ExpressionTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Data +// ExpressionTests.Data -test.Data = function() { +ExpressionTests.Data = function() { } -test.Data.prototype = { +ExpressionTests.Data.prototype = { _value: 0, get_value: function() { @@ -19,11 +19,11 @@ test.Data.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.App +// ExpressionTests.App -test.App = function() { +ExpressionTests.App = function() { } -test.App.prototype = { +ExpressionTests.App.prototype = { test: function(arg) { var xyz = ~arg; @@ -41,12 +41,12 @@ test.App.prototype = { var s = (!f).toString(); var num = 1.01; s = (~num).toExponential(); - var d = new test.Data(); + var d = new ExpressionTests.Data(); d.set_value(d.get_value() + 1) - 1; d.set_value(d.get_value() + 1); } } -test.Data.registerClass('test.Data'); -test.App.registerClass('test.App'); +ExpressionTests.Data.registerClass('ExpressionTests.Data'); +ExpressionTests.App.registerClass('ExpressionTests.App'); diff --git a/tests/TestCases/Expression/Unary/Code.cs b/tests/TestCases/Expression/Unary/Code.cs index d53553ce8..a86bf8113 100644 --- a/tests/TestCases/Expression/Unary/Code.cs +++ b/tests/TestCases/Expression/Unary/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ExpressionTests { diff --git a/tests/TestCases/Member/Constructors/Baseline.txt b/tests/TestCases/Member/Constructors/Baseline.txt index e2cf6043f..70c8f15e2 100644 --- a/tests/TestCases/Member/Constructors/Baseline.txt +++ b/tests/TestCases/Member/Constructors/Baseline.txt @@ -1,43 +1,43 @@ -Type.registerNamespace('test'); +Type.registerNamespace('MemberTests'); //////////////////////////////////////////////////////////////////////////////// -// test.MyClass +// MemberTests.MyClass -test.MyClass = function() { +MemberTests.MyClass = function() { this._value = 1; } -test.MyClass.prototype = { +MemberTests.MyClass.prototype = { _value: 0 } //////////////////////////////////////////////////////////////////////////////// -// test.MyClass2 +// MemberTests.MyClass2 -test.MyClass2 = function() { +MemberTests.MyClass2 = function() { } //////////////////////////////////////////////////////////////////////////////// -// test.MyClass3 +// MemberTests.MyClass3 -test.MyClass3 = function(arg, arg2) { +MemberTests.MyClass3 = function(arg, arg2) { } //////////////////////////////////////////////////////////////////////////////// -// test.MyClass4 +// MemberTests.MyClass4 -test.MyClass4 = function(arg, arg2, arg3) { - test.MyClass4.initializeBase(this, [ arg, arg2 ]); +MemberTests.MyClass4 = function(arg, arg2, arg3) { + MemberTests.MyClass4.initializeBase(this, [ arg, arg2 ]); } -test.MyClass.registerClass('test.MyClass'); -test.MyClass2.registerClass('test.MyClass2'); -test.MyClass3.registerClass('test.MyClass3'); -test.MyClass4.registerClass('test.MyClass4', test.MyClass3); -test.MyClass2.x = null; -test.MyClass2.x = 'Hello'; -test.MyClass3.c = null; -test.MyClass3.c = new test.MyClass(); +MemberTests.MyClass.registerClass('MemberTests.MyClass'); +MemberTests.MyClass2.registerClass('MemberTests.MyClass2'); +MemberTests.MyClass3.registerClass('MemberTests.MyClass3'); +MemberTests.MyClass4.registerClass('MemberTests.MyClass4', MemberTests.MyClass3); +MemberTests.MyClass2.x = null; +MemberTests.MyClass2.x = 'Hello'; +MemberTests.MyClass3.c = null; +MemberTests.MyClass3.c = new MemberTests.MyClass(); diff --git a/tests/TestCases/Member/Constructors/Code.cs b/tests/TestCases/Member/Constructors/Code.cs index 4e9a188eb..9d931183e 100644 --- a/tests/TestCases/Member/Constructors/Code.cs +++ b/tests/TestCases/Member/Constructors/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace MemberTests { diff --git a/tests/TestCases/Member/Events/Baseline.txt b/tests/TestCases/Member/Events/Baseline.txt index 797417702..a14a9bcbb 100644 --- a/tests/TestCases/Member/Events/Baseline.txt +++ b/tests/TestCases/Member/Events/Baseline.txt @@ -1,24 +1,24 @@ -Type.registerNamespace('test'); +Type.registerNamespace('MemberTests'); //////////////////////////////////////////////////////////////////////////////// -// test.EventArgs +// MemberTests.EventArgs -test.EventArgs = function() { +MemberTests.EventArgs = function() { } //////////////////////////////////////////////////////////////////////////////// -// test.Button +// MemberTests.Button -test.Button = function() { +MemberTests.Button = function() { } -test.Button.add_test = function(value) { - test.Button.__test = ss.Delegate.combine(test.Button.__test, value); +MemberTests.Button.add_test = function(value) { + MemberTests.Button.__test = ss.Delegate.combine(MemberTests.Button.__test, value); } -test.Button.remove_test = function(value) { - test.Button.__test = ss.Delegate.remove(test.Button.__test, value); +MemberTests.Button.remove_test = function(value) { + MemberTests.Button.__test = ss.Delegate.remove(MemberTests.Button.__test, value); } -test.Button.prototype = { +MemberTests.Button.prototype = { _aaa: null, add_click: function(value) { @@ -44,12 +44,12 @@ test.Button.prototype = { performClick: function() { if (this.__click != null) { - this.__click(this, new test.EventArgs()); + this.__click(this, new MemberTests.EventArgs()); } } } -test.EventArgs.registerClass('test.EventArgs'); -test.Button.registerClass('test.Button'); -test.Button.__test = null; +MemberTests.EventArgs.registerClass('MemberTests.EventArgs'); +MemberTests.Button.registerClass('MemberTests.Button'); +MemberTests.Button.__test = null; diff --git a/tests/TestCases/Member/Events/Code.cs b/tests/TestCases/Member/Events/Code.cs index 6c041f3e4..7d77b6891 100644 --- a/tests/TestCases/Member/Events/Code.cs +++ b/tests/TestCases/Member/Events/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace MemberTests { diff --git a/tests/TestCases/Member/Fields/Baseline.txt b/tests/TestCases/Member/Fields/Baseline.txt index 1de533a92..07b627987 100644 --- a/tests/TestCases/Member/Fields/Baseline.txt +++ b/tests/TestCases/Member/Fields/Baseline.txt @@ -1,20 +1,20 @@ -Type.registerNamespace('test'); +Type.registerNamespace('MemberTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Mode +// MemberTests.Mode -test.Mode = function() { }; -test.Mode.prototype = { +MemberTests.Mode = function() { }; +MemberTests.Mode.prototype = { a: 0, b: 1 } -test.Mode.registerEnum('test.Mode', false); +MemberTests.Mode.registerEnum('MemberTests.Mode', false); //////////////////////////////////////////////////////////////////////////////// -// test.Point +// MemberTests.Point -test.$create_Point = function(x, y) { +MemberTests.$create_Point = function(x, y) { var $o = { }; $o.x = x; $o.y = y; @@ -23,15 +23,15 @@ test.$create_Point = function(x, y) { //////////////////////////////////////////////////////////////////////////////// -// test.Test +// MemberTests.Test -test.Test = function() { +MemberTests.Test = function() { this._value = 2006; this.s = 'aaa'; this.s = 'bbb'; this.s = 'aaa'; } -test.Test.prototype = { +MemberTests.Test.prototype = { _value: 0, _uintValue: 0, _dblValue: 0, @@ -42,30 +42,30 @@ test.Test.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.App +// MemberTests.App -test.App = function() { - this._t = new test.Test(); +MemberTests.App = function() { + this._t = new MemberTests.Test(); } -test.App.prototype = { +MemberTests.App.prototype = { _i: 5, doTest: function() { - var t = new test.Test(); + var t = new MemberTests.Test(); t.s = 'World'; var i = 1; - test.Test.done = true; - var p = test.$create_Point(1, 10); + MemberTests.Test.done = true; + var p = MemberTests.$create_Point(1, 10); p.x = p.y; } } -test.Test.registerClass('test.Test'); -test.App.registerClass('test.App'); -test.Test.greeting = 'Hello!'; -test.Test.myNumber = 1; -test.Test.defaultValue = 'aaa'; -test.Test.done = false; -test.Test.XYZ = 1; -test.Test.key = {}; +MemberTests.Test.registerClass('MemberTests.Test'); +MemberTests.App.registerClass('MemberTests.App'); +MemberTests.Test.greeting = 'Hello!'; +MemberTests.Test.myNumber = 1; +MemberTests.Test.defaultValue = 'aaa'; +MemberTests.Test.done = false; +MemberTests.Test.XYZ = 1; +MemberTests.Test.key = {}; diff --git a/tests/TestCases/Member/Fields/Code.cs b/tests/TestCases/Member/Fields/Code.cs index 945bc9b78..92d50d0e8 100644 --- a/tests/TestCases/Member/Fields/Code.cs +++ b/tests/TestCases/Member/Fields/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace MemberTests { diff --git a/tests/TestCases/Member/Indexers/Baseline.txt b/tests/TestCases/Member/Indexers/Baseline.txt index d671d39ca..30f7d3b3a 100644 --- a/tests/TestCases/Member/Indexers/Baseline.txt +++ b/tests/TestCases/Member/Indexers/Baseline.txt @@ -1,20 +1,20 @@ -Type.registerNamespace('test'); +Type.registerNamespace('MemberTests'); //////////////////////////////////////////////////////////////////////////////// -// test.IIndexable +// MemberTests.IIndexable -test.IIndexable = function() { }; -test.IIndexable.registerInterface('test.IIndexable'); +MemberTests.IIndexable = function() { }; +MemberTests.IIndexable.registerInterface('MemberTests.IIndexable'); //////////////////////////////////////////////////////////////////////////////// -// test.Normal +// MemberTests.Normal -test.Normal = function() { +MemberTests.Normal = function() { var i = this.get_item('name'); this.set_item('name', i + 1); } -test.Normal.prototype = { +MemberTests.Normal.prototype = { n: 0, get_item: function(name) { return this.n; @@ -27,12 +27,12 @@ test.Normal.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.GetterOnly +// MemberTests.GetterOnly -test.GetterOnly = function() { +MemberTests.GetterOnly = function() { var i = this.get_item('name'); } -test.GetterOnly.prototype = { +MemberTests.GetterOnly.prototype = { n: 0, get_item: function(name) { return this.n; @@ -41,13 +41,13 @@ test.GetterOnly.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.VirtualIndexer +// MemberTests.VirtualIndexer -test.VirtualIndexer = function() { +MemberTests.VirtualIndexer = function() { var i = this.get_item('name'); this.set_item('name', i + 1); } -test.VirtualIndexer.prototype = { +MemberTests.VirtualIndexer.prototype = { n: 0, get_item: function(name) { return this.n; @@ -60,61 +60,61 @@ test.VirtualIndexer.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.OverriddenIndexer +// MemberTests.OverriddenIndexer -test.OverriddenIndexer = function() { - test.OverriddenIndexer.initializeBase(this); +MemberTests.OverriddenIndexer = function() { + MemberTests.OverriddenIndexer.initializeBase(this); var i = this.get_item('name'); this.set_item('name', i + 1); - var j = test.OverriddenIndexer.callBaseMethod(this, 'get_item', [ 'name' ]); - test.OverriddenIndexer.callBaseMethod(this, 'set_item', [ 'name', 43 ]); + var j = MemberTests.OverriddenIndexer.callBaseMethod(this, 'get_item', [ 'name' ]); + MemberTests.OverriddenIndexer.callBaseMethod(this, 'set_item', [ 'name', 43 ]); } -test.OverriddenIndexer.prototype = { +MemberTests.OverriddenIndexer.prototype = { get_item: function(name) { - return test.OverriddenIndexer.callBaseMethod(this, 'get_item', [ name ]) + 1; + return MemberTests.OverriddenIndexer.callBaseMethod(this, 'get_item', [ name ]) + 1; }, set_item: function(name, value) { - test.OverriddenIndexer.callBaseMethod(this, 'set_item', [ name, value - 1 ]); + MemberTests.OverriddenIndexer.callBaseMethod(this, 'set_item', [ name, value - 1 ]); return value; } } //////////////////////////////////////////////////////////////////////////////// -// test.AbstractIndexer +// MemberTests.AbstractIndexer -test.AbstractIndexer = function() { +MemberTests.AbstractIndexer = function() { var i = this.get_item('name'); this.set_item('name', i + 1); } -test.AbstractIndexer.prototype = { +MemberTests.AbstractIndexer.prototype = { n: 0, } //////////////////////////////////////////////////////////////////////////////// -// test.ImplementedIndexer +// MemberTests.ImplementedIndexer -test.ImplementedIndexer = function() { - test.ImplementedIndexer.initializeBase(this); +MemberTests.ImplementedIndexer = function() { + MemberTests.ImplementedIndexer.initializeBase(this); var i = this.get_item('name'); this.set_item('name', i + 1); } -test.ImplementedIndexer.prototype = { +MemberTests.ImplementedIndexer.prototype = { n: 0, } //////////////////////////////////////////////////////////////////////////////// -// test.MultipleArgs +// MemberTests.MultipleArgs -test.MultipleArgs = function() { +MemberTests.MultipleArgs = function() { var i = this.get_item('name', 'name2', 'name3'); this.set_item('name', 'name2', 'name3', i + 1); } -test.MultipleArgs.prototype = { +MemberTests.MultipleArgs.prototype = { n: 0, get_item: function(first, middle, last) { var value = first + middle + last; @@ -128,11 +128,11 @@ test.MultipleArgs.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.ImplementedIndexer2 +// MemberTests.ImplementedIndexer2 -test.ImplementedIndexer2 = function() { +MemberTests.ImplementedIndexer2 = function() { } -test.ImplementedIndexer2.prototype = { +MemberTests.ImplementedIndexer2.prototype = { get_item: function(index) { return 0; } @@ -140,26 +140,26 @@ test.ImplementedIndexer2.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.Test +// MemberTests.Test -test.Test = function() { - var ma = new test.MultipleArgs(); +MemberTests.Test = function() { + var ma = new MemberTests.MultipleArgs(); ma.set_item('1', '2', '3', ma.get_item('3', '2', '1')); - var ii = new test.ImplementedIndexer(); + var ii = new MemberTests.ImplementedIndexer(); ii.set_item('big', ii.get_item('small')); var ai = ii; ai.set_item('small', ai.get_item('big')); - var indexable = new test.ImplementedIndexer2(); + var indexable = new MemberTests.ImplementedIndexer2(); var o = indexable.get_item(0); } //////////////////////////////////////////////////////////////////////////////// -// test.A +// MemberTests.A -test.A = function() { +MemberTests.A = function() { } -test.A.prototype = { +MemberTests.A.prototype = { get_item: function(name) { return name; } @@ -167,41 +167,41 @@ test.A.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.B +// MemberTests.B -test.B = function() { - test.B.initializeBase(this); +MemberTests.B = function() { + MemberTests.B.initializeBase(this); } //////////////////////////////////////////////////////////////////////////////// -// test.C +// MemberTests.C -test.C = function() { - test.C.initializeBase(this); +MemberTests.C = function() { + MemberTests.C.initializeBase(this); } -test.C.main = function() { - var c = new test.C(); +MemberTests.C.main = function() { + var c = new MemberTests.C(); c.set_item('a', c.get_item('b')); var a = c; a.set_item('b', a.get_item('c')); } -test.C.prototype = { +MemberTests.C.prototype = { get_item: function(name) { return name; } } -test.Normal.registerClass('test.Normal'); -test.GetterOnly.registerClass('test.GetterOnly'); -test.VirtualIndexer.registerClass('test.VirtualIndexer'); -test.OverriddenIndexer.registerClass('test.OverriddenIndexer', test.VirtualIndexer); -test.AbstractIndexer.registerClass('test.AbstractIndexer'); -test.ImplementedIndexer.registerClass('test.ImplementedIndexer', test.AbstractIndexer); -test.MultipleArgs.registerClass('test.MultipleArgs'); -test.ImplementedIndexer2.registerClass('test.ImplementedIndexer2', null, test.IIndexable); -test.Test.registerClass('test.Test'); -test.A.registerClass('test.A'); -test.B.registerClass('test.B', test.A); -test.C.registerClass('test.C', test.B); +MemberTests.Normal.registerClass('MemberTests.Normal'); +MemberTests.GetterOnly.registerClass('MemberTests.GetterOnly'); +MemberTests.VirtualIndexer.registerClass('MemberTests.VirtualIndexer'); +MemberTests.OverriddenIndexer.registerClass('MemberTests.OverriddenIndexer', MemberTests.VirtualIndexer); +MemberTests.AbstractIndexer.registerClass('MemberTests.AbstractIndexer'); +MemberTests.ImplementedIndexer.registerClass('MemberTests.ImplementedIndexer', MemberTests.AbstractIndexer); +MemberTests.MultipleArgs.registerClass('MemberTests.MultipleArgs'); +MemberTests.ImplementedIndexer2.registerClass('MemberTests.ImplementedIndexer2', null, MemberTests.IIndexable); +MemberTests.Test.registerClass('MemberTests.Test'); +MemberTests.A.registerClass('MemberTests.A'); +MemberTests.B.registerClass('MemberTests.B', MemberTests.A); +MemberTests.C.registerClass('MemberTests.C', MemberTests.B); diff --git a/tests/TestCases/Member/Indexers/Code.cs b/tests/TestCases/Member/Indexers/Code.cs index 4278413ba..daef6a951 100644 --- a/tests/TestCases/Member/Indexers/Code.cs +++ b/tests/TestCases/Member/Indexers/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace MemberTests { diff --git a/tests/TestCases/Member/Methods/Baseline.txt b/tests/TestCases/Member/Methods/Baseline.txt index 37ca16502..18cf4a691 100644 --- a/tests/TestCases/Member/Methods/Baseline.txt +++ b/tests/TestCases/Member/Methods/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('MemberTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Test +// MemberTests.Test -test.Test = function() { +MemberTests.Test = function() { } -test.Test.prototype = { +MemberTests.Test.prototype = { do1: function() { }, @@ -29,7 +29,7 @@ test.Test.prototype = { toString: function() { window.m1(); - var x = new test.X(); + var x = new MemberTests.X(); $.fn.extend(x, 10); return null; } @@ -37,14 +37,14 @@ test.Test.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.Foo +// MemberTests.Foo window.doStuff = function() { } //////////////////////////////////////////////////////////////////////////////// -// test.Bar +// MemberTests.Bar window.m1 = function() { } @@ -53,23 +53,23 @@ window.m2 = function() { //////////////////////////////////////////////////////////////////////////////// -// test.FooBar +// MemberTests.FooBar window.doStuff2 = function() { } //////////////////////////////////////////////////////////////////////////////// -// test.FooBar2 +// MemberTests.FooBar2 //////////////////////////////////////////////////////////////////////////////// -// test.X +// MemberTests.X -test.X = function() { +MemberTests.X = function() { } -test.X.prototype = { +MemberTests.X.prototype = { update: function(i) { } @@ -77,7 +77,7 @@ test.X.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.Plugin +// MemberTests.Plugin $.fn.extend = function(x, i) { x.update(i); @@ -85,8 +85,8 @@ $.fn.extend = function(x, i) { } -test.Test.registerClass('test.Test'); -test.X.registerClass('test.X'); +MemberTests.Test.registerClass('MemberTests.Test'); +MemberTests.X.registerClass('MemberTests.X'); alert('Startup code in FooBar'); (function () { var timeStamp = new Date().getMilliseconds(); diff --git a/tests/TestCases/Member/Methods/Code.cs b/tests/TestCases/Member/Methods/Code.cs index 8f7c37b86..09ac405b5 100644 --- a/tests/TestCases/Member/Methods/Code.cs +++ b/tests/TestCases/Member/Methods/Code.cs @@ -3,7 +3,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace MemberTests { diff --git a/tests/TestCases/Member/Overloads/Baseline.txt b/tests/TestCases/Member/Overloads/Baseline.txt index 2abc04b74..65bf3a7fa 100644 --- a/tests/TestCases/Member/Overloads/Baseline.txt +++ b/tests/TestCases/Member/Overloads/Baseline.txt @@ -1,13 +1,13 @@ -Type.registerNamespace('test'); +Type.registerNamespace('MemberTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Test +// MemberTests.Test -test.Test = function(name) { +MemberTests.Test = function(name) { } -test.Test.doSomething = function(o) { +MemberTests.Test.doSomething = function(o) { } -test.Test.prototype = { +MemberTests.Test.prototype = { invoke: function(successCallback, errorCallback, context) { } @@ -15,13 +15,13 @@ test.Test.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.App +// MemberTests.App -test.App = function() { - test.Test.doSomething(); - test.Test.doSomething(null); - var t1 = new test.Test(); - var t2 = new test.Test('test'); +MemberTests.App = function() { + MemberTests.Test.doSomething(); + MemberTests.Test.doSomething(null); + var t1 = new MemberTests.Test(); + var t2 = new MemberTests.Test('test'); var cb1 = null; var cb2 = null; t1.invoke(cb1); @@ -30,5 +30,5 @@ test.App = function() { } -test.Test.registerClass('test.Test'); -test.App.registerClass('test.App'); +MemberTests.Test.registerClass('MemberTests.Test'); +MemberTests.App.registerClass('MemberTests.App'); diff --git a/tests/TestCases/Member/Overloads/Code.cs b/tests/TestCases/Member/Overloads/Code.cs index a45d93b1d..dafda5028 100644 --- a/tests/TestCases/Member/Overloads/Code.cs +++ b/tests/TestCases/Member/Overloads/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace MemberTests { diff --git a/tests/TestCases/Member/Properties/Baseline.txt b/tests/TestCases/Member/Properties/Baseline.txt index dadd20526..2567984c1 100644 --- a/tests/TestCases/Member/Properties/Baseline.txt +++ b/tests/TestCases/Member/Properties/Baseline.txt @@ -1,22 +1,22 @@ -Type.registerNamespace('test'); +Type.registerNamespace('MemberTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Test +// MemberTests.Test -test.Test = function() { +MemberTests.Test = function() { this.set_XYZ(1); this.set_XYZ(this.get_name().length); this.set_XYZ(this.get_name().length); - var v = test.Test.get_staticProp(); - v = test.Test.get_staticProp(); + var v = MemberTests.Test.get_staticProp(); + v = MemberTests.Test.get_staticProp(); } -test.Test.get_staticProp = function() { +MemberTests.Test.get_staticProp = function() { return 2006; } -test.Test.set_staticProp = function(value) { +MemberTests.Test.set_staticProp = function(value) { return value; } -test.Test.prototype = { +MemberTests.Test.prototype = { get_XYZ: function() { return 0; @@ -40,18 +40,18 @@ test.Test.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.Test2 +// MemberTests.Test2 -test.Test2 = function() { - test.Test2.initializeBase(this); - var n = test.Test2.callBaseMethod(this, 'get_XYZ'); +MemberTests.Test2 = function() { + MemberTests.Test2.initializeBase(this); + var n = MemberTests.Test2.callBaseMethod(this, 'get_XYZ'); if (n === this.get_XYZ()) { } if (this.get_XYZ() === n) { } - n = test.Test.get_staticProp(); + n = MemberTests.Test.get_staticProp(); } -test.Test.registerClass('test.Test'); -test.Test2.registerClass('test.Test2', test.Test); +MemberTests.Test.registerClass('MemberTests.Test'); +MemberTests.Test2.registerClass('MemberTests.Test2', MemberTests.Test); diff --git a/tests/TestCases/Member/Properties/Code.cs b/tests/TestCases/Member/Properties/Code.cs index 52f18604b..f4fba32e7 100644 --- a/tests/TestCases/Member/Properties/Code.cs +++ b/tests/TestCases/Member/Properties/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace MemberTests { diff --git a/tests/TestCases/Member/StaticConstructors/Baseline.txt b/tests/TestCases/Member/StaticConstructors/Baseline.txt index 652b197b3..4dadf0e69 100644 --- a/tests/TestCases/Member/StaticConstructors/Baseline.txt +++ b/tests/TestCases/Member/StaticConstructors/Baseline.txt @@ -1,56 +1,56 @@ -Type.registerNamespace('test'); +Type.registerNamespace('MemberTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Behavior +// MemberTests.Behavior -test.Behavior = function(e, name) { +MemberTests.Behavior = function(e, name) { } //////////////////////////////////////////////////////////////////////////////// -// test.MyClass +// MemberTests.MyClass -test.MyClass = function(d) { +MemberTests.MyClass = function(d) { } //////////////////////////////////////////////////////////////////////////////// -// test.MyClassEmpty +// MemberTests.MyClassEmpty -test.MyClassEmpty = function() { +MemberTests.MyClassEmpty = function() { } //////////////////////////////////////////////////////////////////////////////// -// test.MyClassSimple +// MemberTests.MyClassSimple -test.MyClassSimple = function() { +MemberTests.MyClassSimple = function() { } //////////////////////////////////////////////////////////////////////////////// -// test.MyClassSimpleMulti +// MemberTests.MyClassSimpleMulti -test.MyClassSimpleMulti = function() { +MemberTests.MyClassSimpleMulti = function() { } //////////////////////////////////////////////////////////////////////////////// -// test.MyBehavior +// MemberTests.MyBehavior -test.MyBehavior = function(element) { - test.MyBehavior.initializeBase(this, [ element, 'myBehavior' ]); +MemberTests.MyBehavior = function(element) { + MemberTests.MyBehavior.initializeBase(this, [ element, 'myBehavior' ]); } -test.Behavior.registerClass('test.Behavior'); -test.MyClass.registerClass('test.MyClass'); -test.MyClassEmpty.registerClass('test.MyClassEmpty'); -test.MyClassSimple.registerClass('test.MyClassSimple'); -test.MyClassSimpleMulti.registerClass('test.MyClassSimpleMulti'); -test.MyBehavior.registerClass('test.MyBehavior', test.Behavior); -test.MyClass.instance = null; -test.MyClass.instance = new test.MyClass(Date.get_now()); +MemberTests.Behavior.registerClass('MemberTests.Behavior'); +MemberTests.MyClass.registerClass('MemberTests.MyClass'); +MemberTests.MyClassEmpty.registerClass('MemberTests.MyClassEmpty'); +MemberTests.MyClassSimple.registerClass('MemberTests.MyClassSimple'); +MemberTests.MyClassSimpleMulti.registerClass('MemberTests.MyClassSimpleMulti'); +MemberTests.MyBehavior.registerClass('MemberTests.MyBehavior', MemberTests.Behavior); +MemberTests.MyClass.instance = null; +MemberTests.MyClass.instance = new MemberTests.MyClass(Date.get_now()); alert('simple static ctor'); alert('simple static ctor with multiple statements'); document.getElementById('foo').innerHTML = '...'; @@ -60,5 +60,5 @@ document.getElementById('foo').innerHTML = '...'; if (!b) { return; } - new test.MyBehavior(e); + new MemberTests.MyBehavior(e); })(); diff --git a/tests/TestCases/Member/StaticConstructors/Code.cs b/tests/TestCases/Member/StaticConstructors/Code.cs index 0d8be9b09..1291c0f39 100644 --- a/tests/TestCases/Member/StaticConstructors/Code.cs +++ b/tests/TestCases/Member/StaticConstructors/Code.cs @@ -3,7 +3,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace MemberTests { diff --git a/tests/TestCases/Statement/Exceptions/Baseline.txt b/tests/TestCases/Statement/Exceptions/Baseline.txt index 53ab15055..ea2ce95e0 100644 --- a/tests/TestCases/Statement/Exceptions/Baseline.txt +++ b/tests/TestCases/Statement/Exceptions/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('StatementTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// StatementTests.App -test.App = function() { +StatementTests.App = function() { } -test.App.prototype = { +StatementTests.App.prototype = { test: function(arg) { if (arg == null) { @@ -40,4 +40,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +StatementTests.App.registerClass('StatementTests.App'); diff --git a/tests/TestCases/Statement/Exceptions/Code.cs b/tests/TestCases/Statement/Exceptions/Code.cs index 7ccc3ca05..724c4a755 100644 --- a/tests/TestCases/Statement/Exceptions/Code.cs +++ b/tests/TestCases/Statement/Exceptions/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace StatementTests { diff --git a/tests/TestCases/Statement/Expression/Baseline.txt b/tests/TestCases/Statement/Expression/Baseline.txt index d66592a2d..d8b2aa1be 100644 --- a/tests/TestCases/Statement/Expression/Baseline.txt +++ b/tests/TestCases/Statement/Expression/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('StatementTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// StatementTests.App -test.App = function() { +StatementTests.App = function() { } -test.App.prototype = { +StatementTests.App.prototype = { test: function(arg) { var x; @@ -16,4 +16,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +StatementTests.App.registerClass('StatementTests.App'); diff --git a/tests/TestCases/Statement/Expression/Code.cs b/tests/TestCases/Statement/Expression/Code.cs index bbd8aad1f..536633fb9 100644 --- a/tests/TestCases/Statement/Expression/Code.cs +++ b/tests/TestCases/Statement/Expression/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace StatementTests { diff --git a/tests/TestCases/Statement/For/Baseline.txt b/tests/TestCases/Statement/For/Baseline.txt index 7a9f4d6b6..c02c5c957 100644 --- a/tests/TestCases/Statement/For/Baseline.txt +++ b/tests/TestCases/Statement/For/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('StatementTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// StatementTests.App -test.App = function() { +StatementTests.App = function() { } -test.App.prototype = { +StatementTests.App.prototype = { test: function(arg) { for (var i = 0; i < 10; i++) { @@ -29,4 +29,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +StatementTests.App.registerClass('StatementTests.App'); diff --git a/tests/TestCases/Statement/For/Code.cs b/tests/TestCases/Statement/For/Code.cs index fdd58b2b3..7eec7e65b 100644 --- a/tests/TestCases/Statement/For/Code.cs +++ b/tests/TestCases/Statement/For/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace StatementTests { diff --git a/tests/TestCases/Statement/Foreach/Baseline.txt b/tests/TestCases/Statement/Foreach/Baseline.txt index 5132203ec..18fbb2a01 100644 --- a/tests/TestCases/Statement/Foreach/Baseline.txt +++ b/tests/TestCases/Statement/Foreach/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('StatementTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Set +// StatementTests.Set -test.Set = function() { +StatementTests.Set = function() { } -test.Set.prototype = { +StatementTests.Set.prototype = { _items: null, getEnumerator: function() { @@ -15,11 +15,11 @@ test.Set.prototype = { //////////////////////////////////////////////////////////////////////////////// -// test.App +// StatementTests.App -test.App = function() { +StatementTests.App = function() { } -test.App.prototype = { +StatementTests.App.prototype = { test: function(arg) { var items = [ 1, 2, 3 ]; @@ -35,7 +35,7 @@ test.App.prototype = { var entry = { key: $key3, value: $dict2[$key3] }; var s = entry.key + ' = ' + entry.value; } - var s = new test.Set(); + var s = new StatementTests.Set(); var $enum4 = ss.IEnumerator.getEnumerator(s); while ($enum4.moveNext()) { var o = $enum4.current; @@ -52,5 +52,5 @@ test.App.prototype = { } -test.Set.registerClass('test.Set', null, ss.IEnumerable); -test.App.registerClass('test.App'); +StatementTests.Set.registerClass('StatementTests.Set', null, ss.IEnumerable); +StatementTests.App.registerClass('StatementTests.App'); diff --git a/tests/TestCases/Statement/Foreach/Code.cs b/tests/TestCases/Statement/Foreach/Code.cs index 99848e49d..5bd8464f7 100644 --- a/tests/TestCases/Statement/Foreach/Code.cs +++ b/tests/TestCases/Statement/Foreach/Code.cs @@ -3,7 +3,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace StatementTests { diff --git a/tests/TestCases/Statement/IfElse/Baseline.txt b/tests/TestCases/Statement/IfElse/Baseline.txt index 7baef40b1..8472c8e53 100644 --- a/tests/TestCases/Statement/IfElse/Baseline.txt +++ b/tests/TestCases/Statement/IfElse/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('StatementTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// StatementTests.App -test.App = function() { +StatementTests.App = function() { } -test.App.prototype = { +StatementTests.App.prototype = { testMethod: function(boolValue, numValue) { if (boolValue) { @@ -31,4 +31,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +StatementTests.App.registerClass('StatementTests.App'); diff --git a/tests/TestCases/Statement/IfElse/Code.cs b/tests/TestCases/Statement/IfElse/Code.cs index 9fe6d6a5b..52c36c838 100644 --- a/tests/TestCases/Statement/IfElse/Code.cs +++ b/tests/TestCases/Statement/IfElse/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace StatementTests { diff --git a/tests/TestCases/Statement/Return/Baseline.txt b/tests/TestCases/Statement/Return/Baseline.txt index b5654610d..d4da250df 100644 --- a/tests/TestCases/Statement/Return/Baseline.txt +++ b/tests/TestCases/Statement/Return/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('StatementTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// StatementTests.App -test.App = function() { +StatementTests.App = function() { } -test.App.prototype = { +StatementTests.App.prototype = { test1: function(arg) { return 0; @@ -28,4 +28,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +StatementTests.App.registerClass('StatementTests.App'); diff --git a/tests/TestCases/Statement/Return/Code.cs b/tests/TestCases/Statement/Return/Code.cs index 001285eae..d48d59ef6 100644 --- a/tests/TestCases/Statement/Return/Code.cs +++ b/tests/TestCases/Statement/Return/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace StatementTests { diff --git a/tests/TestCases/Statement/Switch/Baseline.txt b/tests/TestCases/Statement/Switch/Baseline.txt index 5a6622784..c94aa22ec 100644 --- a/tests/TestCases/Statement/Switch/Baseline.txt +++ b/tests/TestCases/Statement/Switch/Baseline.txt @@ -1,22 +1,22 @@ -Type.registerNamespace('test'); +Type.registerNamespace('StatementTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Mode +// StatementTests.Mode -test.Mode = function() { }; -test.Mode.prototype = { +StatementTests.Mode = function() { }; +StatementTests.Mode.prototype = { foo: 0, bar: 1 } -test.Mode.registerEnum('test.Mode', false); +StatementTests.Mode.registerEnum('StatementTests.Mode', false); //////////////////////////////////////////////////////////////////////////////// -// test.App +// StatementTests.App -test.App = function() { +StatementTests.App = function() { } -test.App.prototype = { +StatementTests.App.prototype = { test: function(arg, m) { var i; @@ -56,4 +56,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +StatementTests.App.registerClass('StatementTests.App'); diff --git a/tests/TestCases/Statement/Switch/Code.cs b/tests/TestCases/Statement/Switch/Code.cs index b6d4a1096..489ddf7d1 100644 --- a/tests/TestCases/Statement/Switch/Code.cs +++ b/tests/TestCases/Statement/Switch/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace StatementTests { diff --git a/tests/TestCases/Statement/Variables/Baseline.txt b/tests/TestCases/Statement/Variables/Baseline.txt index f93ecac15..05c3f0b2d 100644 --- a/tests/TestCases/Statement/Variables/Baseline.txt +++ b/tests/TestCases/Statement/Variables/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('StatementTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// StatementTests.App -test.App = function() { +StatementTests.App = function() { } -test.App.prototype = { +StatementTests.App.prototype = { test: function() { var i = 0; @@ -34,4 +34,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +StatementTests.App.registerClass('StatementTests.App'); diff --git a/tests/TestCases/Statement/Variables/Code.cs b/tests/TestCases/Statement/Variables/Code.cs index d910b4c08..21846fbc2 100644 --- a/tests/TestCases/Statement/Variables/Code.cs +++ b/tests/TestCases/Statement/Variables/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace StatementTests { diff --git a/tests/TestCases/Statement/While/Baseline.txt b/tests/TestCases/Statement/While/Baseline.txt index 0b07a14db..3ee0d275f 100644 --- a/tests/TestCases/Statement/While/Baseline.txt +++ b/tests/TestCases/Statement/While/Baseline.txt @@ -1,11 +1,11 @@ -Type.registerNamespace('test'); +Type.registerNamespace('StatementTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// StatementTests.App -test.App = function() { +StatementTests.App = function() { } -test.App.prototype = { +StatementTests.App.prototype = { test: function(arg) { var i; @@ -26,4 +26,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +StatementTests.App.registerClass('StatementTests.App'); diff --git a/tests/TestCases/Statement/While/Code.cs b/tests/TestCases/Statement/While/Code.cs index 38f52deec..ee1b38bad 100644 --- a/tests/TestCases/Statement/While/Code.cs +++ b/tests/TestCases/Statement/While/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace StatementTests { diff --git a/tests/TestCases/Type/Classes/Baseline.txt b/tests/TestCases/Type/Classes/Baseline.txt index a64e404af..749ef4109 100644 --- a/tests/TestCases/Type/Classes/Baseline.txt +++ b/tests/TestCases/Type/Classes/Baseline.txt @@ -1,45 +1,45 @@ -Type.registerNamespace('test'); +Type.registerNamespace('TypeTests'); //////////////////////////////////////////////////////////////////////////////// -// test.FooBarBaz +// TypeTests.FooBarBaz -test.FooBarBaz = function test_FooBarBaz() { +TypeTests.FooBarBaz = function TypeTests_FooBarBaz() { } //////////////////////////////////////////////////////////////////////////////// -// test.MyClass +// TypeTests.MyClass -test.MyClass = function test_MyClass() { - test.FooBarBaz = new test.FooBarBaz(); +TypeTests.MyClass = function TypeTests_MyClass() { + TypeTests.FooBarBaz = new TypeTests.FooBarBaz(); } //////////////////////////////////////////////////////////////////////////////// -// test.MyClass2 +// TypeTests.MyClass2 -test.MyClass2 = function test_MyClass2() { - test.MyClass2.initializeBase(this); +TypeTests.MyClass2 = function TypeTests_MyClass2() { + TypeTests.MyClass2.initializeBase(this); } //////////////////////////////////////////////////////////////////////////////// -// test.MyClass3 +// TypeTests.MyClass3 -test.MyClass3 = function test_MyClass3() { +TypeTests.MyClass3 = function TypeTests_MyClass3() { } //////////////////////////////////////////////////////////////////////////////// -// test.MyClass4 +// TypeTests.MyClass4 -test.MyClass4 = function test_MyClass4() { - test.MyClass4.initializeBase(this); +TypeTests.MyClass4 = function TypeTests_MyClass4() { + TypeTests.MyClass4.initializeBase(this); } -test.FooBarBaz.registerClass('test.FooBarBaz'); -test.MyClass.registerClass('test.MyClass'); -test.MyClass2.registerClass('test.MyClass2', test.MyClass); -test.MyClass3.registerClass('test.MyClass3', null, ss.IDisposable); -test.MyClass4.registerClass('test.MyClass4', test.MyClass, ss.IDisposable); +TypeTests.FooBarBaz.registerClass('TypeTests.FooBarBaz'); +TypeTests.MyClass.registerClass('TypeTests.MyClass'); +TypeTests.MyClass2.registerClass('TypeTests.MyClass2', TypeTests.MyClass); +TypeTests.MyClass3.registerClass('TypeTests.MyClass3', null, ss.IDisposable); +TypeTests.MyClass4.registerClass('TypeTests.MyClass4', TypeTests.MyClass, ss.IDisposable); diff --git a/tests/TestCases/Type/Classes/Code.cs b/tests/TestCases/Type/Classes/Code.cs index f08eff4f6..ebd7042b6 100644 --- a/tests/TestCases/Type/Classes/Code.cs +++ b/tests/TestCases/Type/Classes/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace TypeTests { diff --git a/tests/TestCases/Type/Delegates/Baseline.txt b/tests/TestCases/Type/Delegates/Baseline.txt index de838d13c..04e558d28 100644 --- a/tests/TestCases/Type/Delegates/Baseline.txt +++ b/tests/TestCases/Type/Delegates/Baseline.txt @@ -1,10 +1,10 @@ -Type.registerNamespace('test'); +Type.registerNamespace('TypeTests'); //////////////////////////////////////////////////////////////////////////////// -// test.EventArgs +// TypeTests.EventArgs -test.EventArgs = function test_EventArgs() { +TypeTests.EventArgs = function TypeTests_EventArgs() { } -test.EventArgs.registerClass('test.EventArgs'); +TypeTests.EventArgs.registerClass('TypeTests.EventArgs'); diff --git a/tests/TestCases/Type/Delegates/Code.cs b/tests/TestCases/Type/Delegates/Code.cs index 538b4e3c9..b196525b8 100644 --- a/tests/TestCases/Type/Delegates/Code.cs +++ b/tests/TestCases/Type/Delegates/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace TypeTests { diff --git a/tests/TestCases/Type/Enumerator/Baseline.txt b/tests/TestCases/Type/Enumerator/Baseline.txt index 7f1c0c25d..12882b599 100644 --- a/tests/TestCases/Type/Enumerator/Baseline.txt +++ b/tests/TestCases/Type/Enumerator/Baseline.txt @@ -1,29 +1,29 @@ -Type.registerNamespace('test'); +Type.registerNamespace('TypeTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App1 +// TypeTests.App1 -test.App1 = function test_App1() { +TypeTests.App1 = function TypeTests_App1() { } -test.App1.prototype = { +TypeTests.App1.prototype = { - getEnumerator: function test_App1$getEnumerator() { + getEnumerator: function TypeTests_App1$getEnumerator() { return null; } } //////////////////////////////////////////////////////////////////////////////// -// test.App +// TypeTests.App -test.App = function test_App() { +TypeTests.App = function TypeTests_App() { } -test.App.prototype = { +TypeTests.App.prototype = { - test1: function test_App$test1(arg) { + test1: function TypeTests_App$test1(arg) { }, - test: function test_App$test(arg) { + test: function TypeTests_App$test(arg) { var a; var b; var s = new Array(5); @@ -45,5 +45,5 @@ test.App.prototype = { } -test.App1.registerClass('test.App1', null, ss.IEnumerable); -test.App.registerClass('test.App'); +TypeTests.App1.registerClass('TypeTests.App1', null, ss.IEnumerable); +TypeTests.App.registerClass('TypeTests.App'); diff --git a/tests/TestCases/Type/Enumerator/Code.cs b/tests/TestCases/Type/Enumerator/Code.cs index ba46929b5..970e9f48b 100644 --- a/tests/TestCases/Type/Enumerator/Code.cs +++ b/tests/TestCases/Type/Enumerator/Code.cs @@ -3,7 +3,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace TypeTests { diff --git a/tests/TestCases/Type/Enums/Baseline.txt b/tests/TestCases/Type/Enums/Baseline.txt index 5287edb4d..822317911 100644 --- a/tests/TestCases/Type/Enums/Baseline.txt +++ b/tests/TestCases/Type/Enums/Baseline.txt @@ -1,94 +1,94 @@ -Type.registerNamespace('test'); +Type.registerNamespace('TypeTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Colors +// TypeTests.Colors -test.Colors = function() { }; -test.Colors.prototype = { +TypeTests.Colors = function() { }; +TypeTests.Colors.prototype = { red: 0, green: 1, blue: 2 } -test.Colors.registerEnum('test.Colors', false); +TypeTests.Colors.registerEnum('TypeTests.Colors', false); //////////////////////////////////////////////////////////////////////////////// -// test.Sequence +// TypeTests.Sequence -test.Sequence = function() { }; -test.Sequence.prototype = { +TypeTests.Sequence = function() { }; +TypeTests.Sequence.prototype = { item1: 1, item2: 2, item3: 3, item4: 5 } -test.Sequence.registerEnum('test.Sequence', false); +TypeTests.Sequence.registerEnum('TypeTests.Sequence', false); //////////////////////////////////////////////////////////////////////////////// -// test.Mode +// TypeTests.Mode -test.Mode = function() { }; -test.Mode.prototype = { +TypeTests.Mode = function() { }; +TypeTests.Mode.prototype = { Public: 1, Protected: 2, Private: 4 } -test.Mode.registerEnum('test.Mode', true); +TypeTests.Mode.registerEnum('TypeTests.Mode', true); //////////////////////////////////////////////////////////////////////////////// -// test.UInt32Mask +// TypeTests.UInt32Mask -test.UInt32Mask = function() { }; -test.UInt32Mask.prototype = { +TypeTests.UInt32Mask = function() { }; +TypeTests.UInt32Mask.prototype = { v: 4026531840, a: 4278190080 } -test.UInt32Mask.registerEnum('test.UInt32Mask', false); +TypeTests.UInt32Mask.registerEnum('TypeTests.UInt32Mask', false); //////////////////////////////////////////////////////////////////////////////// -// test.ShortMask +// TypeTests.ShortMask -test.ShortMask = function() { }; -test.ShortMask.prototype = { +TypeTests.ShortMask = function() { }; +TypeTests.ShortMask.prototype = { v: 1, a: 4096 } -test.ShortMask.registerEnum('test.ShortMask', false); +TypeTests.ShortMask.registerEnum('TypeTests.ShortMask', false); //////////////////////////////////////////////////////////////////////////////// -// test.Errors +// TypeTests.Errors -test.Errors = function() { }; -test.Errors.prototype = { +TypeTests.Errors = function() { }; +TypeTests.Errors.prototype = { S_OK: 0, S_FALSE: 1, E_FAIL: -1 } -test.Errors.registerEnum('test.Errors', false); +TypeTests.Errors.registerEnum('TypeTests.Errors', false); //////////////////////////////////////////////////////////////////////////////// -// test.Size +// TypeTests.Size -test.Size = function() { }; -test.Size.prototype = { +TypeTests.Size = function() { }; +TypeTests.Size.prototype = { small: 'small', Medium: 'Medium', large: 'large' } -test.Size.registerEnum('test.Size', false); +TypeTests.Size.registerEnum('TypeTests.Size', false); //////////////////////////////////////////////////////////////////////////////// -// test.App +// TypeTests.App -test.App = function test_App() { +TypeTests.App = function TypeTests_App() { } -test.App.main = function test_App$main() { +TypeTests.App.main = function TypeTests_App$main() { var m = 1; m = 1 | 4; var c = 0; @@ -96,15 +96,15 @@ test.App.main = function test_App$main() { //////////////////////////////////////////////////////////////////////////////// -// test.App2 +// TypeTests.App2 -test.App2 = function test_App2() { +TypeTests.App2 = function TypeTests_App2() { } -test.App2.prototype = { +TypeTests.App2.prototype = { _httpMethod: null, _sortMode: null, - run: function test_App2$run() { + run: function TypeTests_App2$run() { var method = 'POST'; this.run1('GET'); this.run2('status'); @@ -113,14 +113,14 @@ test.App2.prototype = { var s = 'Medium'; }, - run1: function test_App2$run1(m) { + run1: function TypeTests_App2$run1(m) { var s = m; }, - run2: function test_App2$run2(m) { + run2: function TypeTests_App2$run2(m) { } } -test.App.registerClass('test.App'); -test.App2.registerClass('test.App2'); +TypeTests.App.registerClass('TypeTests.App'); +TypeTests.App2.registerClass('TypeTests.App2'); diff --git a/tests/TestCases/Type/Enums/Code.cs b/tests/TestCases/Type/Enums/Code.cs index 581b62b0d..7ccf17595 100644 --- a/tests/TestCases/Type/Enums/Code.cs +++ b/tests/TestCases/Type/Enums/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace TypeTests { diff --git a/tests/TestCases/Type/Globals/Baseline.txt b/tests/TestCases/Type/Globals/Baseline.txt index 735befa49..0668873f0 100644 --- a/tests/TestCases/Type/Globals/Baseline.txt +++ b/tests/TestCases/Type/Globals/Baseline.txt @@ -64,9 +64,9 @@ MyClass4.prototype = { Type.registerNamespace('Foo'); //////////////////////////////////////////////////////////////////////////////// -// Foo.MyClass +// Foo.MyClassF -Foo.MyClass = function Foo_MyClass() { +Foo.MyClassF = function Foo_MyClassF() { } @@ -74,4 +74,4 @@ MyClass.registerClass('MyClass'); MyClass2.registerClass('MyClass2', MyClass); MyClass3.registerClass('MyClass3', null, ss.IDisposable); MyClass4.registerClass('MyClass4', MyClass, ss.IDisposable); -Foo.MyClass.registerClass('Foo.MyClass'); +Foo.MyClassF.registerClass('Foo.MyClassF'); diff --git a/tests/TestCases/Type/Globals/Code.cs b/tests/TestCases/Type/Globals/Code.cs index f949c127f..fe9ad3da6 100644 --- a/tests/TestCases/Type/Globals/Code.cs +++ b/tests/TestCases/Type/Globals/Code.cs @@ -31,7 +31,7 @@ public enum MyEnum { namespace Foo { - public class MyClass { + public class MyClassF { } } diff --git a/tests/TestCases/Type/Imported/Baseline.txt b/tests/TestCases/Type/Imported/Baseline.txt index 09cd0aed4..124c55e57 100644 --- a/tests/TestCases/Type/Imported/Baseline.txt +++ b/tests/TestCases/Type/Imported/Baseline.txt @@ -1,9 +1,9 @@ -Type.registerNamespace('test'); +Type.registerNamespace('TypeTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// TypeTests.App -test.App = function() { +TypeTests.App = function() { var elem = document.getElementById('foo'); var s = elem.myString; elem['Smith'] = elem['Joe']; @@ -14,4 +14,4 @@ test.App = function() { } -test.App.registerClass('test.App'); +TypeTests.App.registerClass('TypeTests.App'); diff --git a/tests/TestCases/Type/Imported/Code.cs b/tests/TestCases/Type/Imported/Code.cs index 9798fa743..e590f61b3 100644 --- a/tests/TestCases/Type/Imported/Code.cs +++ b/tests/TestCases/Type/Imported/Code.cs @@ -4,7 +4,6 @@ using System.Xml; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace TypeTests { diff --git a/tests/TestCases/Type/Interfaces/Baseline.txt b/tests/TestCases/Type/Interfaces/Baseline.txt index e4e79d061..fe598fefd 100644 --- a/tests/TestCases/Type/Interfaces/Baseline.txt +++ b/tests/TestCases/Type/Interfaces/Baseline.txt @@ -1,85 +1,85 @@ -Type.registerNamespace('test'); +Type.registerNamespace('TypeTests'); //////////////////////////////////////////////////////////////////////////////// -// test.IMarker +// TypeTests.IMarker -test.IMarker = function() { }; -test.IMarker.prototype = { +TypeTests.IMarker = function() { }; +TypeTests.IMarker.prototype = { } -test.IMarker.registerInterface('test.IMarker'); +TypeTests.IMarker.registerInterface('TypeTests.IMarker'); //////////////////////////////////////////////////////////////////////////////// -// test.ISerializable +// TypeTests.ISerializable -test.ISerializable = function() { }; -test.ISerializable.prototype = { +TypeTests.ISerializable = function() { }; +TypeTests.ISerializable.prototype = { serialize : null } -test.ISerializable.registerInterface('test.ISerializable'); +TypeTests.ISerializable.registerInterface('TypeTests.ISerializable'); //////////////////////////////////////////////////////////////////////////////// -// test.IRunnable +// TypeTests.IRunnable -test.IRunnable = function() { }; -test.IRunnable.prototype = { +TypeTests.IRunnable = function() { }; +TypeTests.IRunnable.prototype = { get_canRun : null, run : null } -test.IRunnable.registerInterface('test.IRunnable'); +TypeTests.IRunnable.registerInterface('TypeTests.IRunnable'); //////////////////////////////////////////////////////////////////////////////// -// test.MyObject +// TypeTests.MyObject -test.MyObject = function test_MyObject() { +TypeTests.MyObject = function TypeTests_MyObject() { } -test.MyObject.prototype = { +TypeTests.MyObject.prototype = { - dispose: function test_MyObject$dispose() { + dispose: function TypeTests_MyObject$dispose() { } } //////////////////////////////////////////////////////////////////////////////// -// test.MyObject2 +// TypeTests.MyObject2 -test.MyObject2 = function test_MyObject2() { - test.MyObject2.initializeBase(this); +TypeTests.MyObject2 = function TypeTests_MyObject2() { + TypeTests.MyObject2.initializeBase(this); } -test.MyObject2.prototype = { +TypeTests.MyObject2.prototype = { - get_canRun: function test_MyObject2$get_canRun() { + get_canRun: function TypeTests_MyObject2$get_canRun() { return true; }, - run: function test_MyObject2$run() { + run: function TypeTests_MyObject2$run() { } } //////////////////////////////////////////////////////////////////////////////// -// test.Foo +// TypeTests.Foo -test.Foo = function test_Foo() { +TypeTests.Foo = function TypeTests_Foo() { } -test.Foo.prototype = { +TypeTests.Foo.prototype = { - get_canRun: function test_Foo$get_canRun() { + get_canRun: function TypeTests_Foo$get_canRun() { return true; }, - run: function test_Foo$run() { + run: function TypeTests_Foo$run() { }, - serialize: function test_Foo$serialize() { + serialize: function TypeTests_Foo$serialize() { return null; } } -test.MyObject.registerClass('test.MyObject', null, ss.IDisposable); -test.MyObject2.registerClass('test.MyObject2', test.MyObject, test.IRunnable); -test.Foo.registerClass('test.Foo', null, test.IMarker, test.ISerializable, test.IRunnable); +TypeTests.MyObject.registerClass('TypeTests.MyObject', null, ss.IDisposable); +TypeTests.MyObject2.registerClass('TypeTests.MyObject2', TypeTests.MyObject, TypeTests.IRunnable); +TypeTests.Foo.registerClass('TypeTests.Foo', null, TypeTests.IMarker, TypeTests.ISerializable, TypeTests.IRunnable); diff --git a/tests/TestCases/Type/Interfaces/Code.cs b/tests/TestCases/Type/Interfaces/Code.cs index 2616cecc5..9cf97de84 100644 --- a/tests/TestCases/Type/Interfaces/Code.cs +++ b/tests/TestCases/Type/Interfaces/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace TypeTests { diff --git a/tests/TestCases/Type/Namespaces/Baseline.txt b/tests/TestCases/Type/Namespaces/Baseline.txt index 5a6b1ac68..fdf5957af 100644 --- a/tests/TestCases/Type/Namespaces/Baseline.txt +++ b/tests/TestCases/Type/Namespaces/Baseline.txt @@ -26,18 +26,18 @@ TypeTests.Sub1.YourClass.prototype = { Type.registerNamespace('TypeTests'); //////////////////////////////////////////////////////////////////////////////// -// TypeTests.YourClass +// TypeTests.YourClass1 -TypeTests.YourClass = function TypeTests_YourClass() { +TypeTests.YourClass1 = function TypeTests_YourClass1() { } Type.registerNamespace('MyApp.Foo'); //////////////////////////////////////////////////////////////////////////////// -// MyApp.Foo.MyClass +// MyApp.Foo.MyClassF -MyApp.Foo.MyClass = function MyApp_Foo_MyClass() { +MyApp.Foo.MyClassF = function MyApp_Foo_MyClassF() { } @@ -68,9 +68,9 @@ MyCompany.Utility.prototype = { Type.registerNamespace('MyCompany.MyProduct'); //////////////////////////////////////////////////////////////////////////////// -// MyCompany.MyProduct.Utility +// MyCompany.MyProduct.UtilityP -MyCompany.MyProduct.Utility = function MyCompany_MyProduct_Utility() { +MyCompany.MyProduct.UtilityP = function MyCompany_MyProduct_UtilityP() { } @@ -87,9 +87,9 @@ MyCompany.MyProduct.MyComponent.Component = function MyCompany_MyProduct_MyCompo TypeTests.Sub1.Sub2.MyClass.registerClass('TypeTests.Sub1.Sub2.MyClass'); TypeTests.Sub1.YourClass.registerClass('TypeTests.Sub1.YourClass'); -TypeTests.YourClass.registerClass('TypeTests.YourClass'); -MyApp.Foo.MyClass.registerClass('MyApp.Foo.MyClass'); +TypeTests.YourClass1.registerClass('TypeTests.YourClass1'); +MyApp.Foo.MyClassF.registerClass('MyApp.Foo.MyClassF'); MyApp.Test.registerClass('MyApp.Test'); MyCompany.Utility.registerClass('MyCompany.Utility'); -MyCompany.MyProduct.Utility.registerClass('MyCompany.MyProduct.Utility'); +MyCompany.MyProduct.UtilityP.registerClass('MyCompany.MyProduct.UtilityP'); MyCompany.MyProduct.MyComponent.Component.registerClass('MyCompany.MyProduct.MyComponent.Component'); diff --git a/tests/TestCases/Type/Namespaces/Code.cs b/tests/TestCases/Type/Namespaces/Code.cs index 2c2fb0f68..1904ff743 100644 --- a/tests/TestCases/Type/Namespaces/Code.cs +++ b/tests/TestCases/Type/Namespaces/Code.cs @@ -25,13 +25,13 @@ public void Run() { namespace TypeTests { - public class YourClass { + public class YourClass1 { } } namespace MyApp.Foo { - public class MyClass { + public class MyClassF { } } @@ -58,7 +58,7 @@ public void Run() { namespace MyCompany.MyProduct { - public class Utility { + public class UtilityP { } } diff --git a/tests/TestCases/Type/Nullable/Baseline.txt b/tests/TestCases/Type/Nullable/Baseline.txt index d0014eccd..5e0026c5c 100644 --- a/tests/TestCases/Type/Nullable/Baseline.txt +++ b/tests/TestCases/Type/Nullable/Baseline.txt @@ -1,13 +1,13 @@ -Type.registerNamespace('test'); +Type.registerNamespace('TypeTests'); //////////////////////////////////////////////////////////////////////////////// -// test.App +// TypeTests.App -test.App = function test_App() { +TypeTests.App = function TypeTests_App() { } -test.App.prototype = { +TypeTests.App.prototype = { - method: function test_App$method() { + method: function TypeTests_App$method() { var i = 10; var b = true; var flag; @@ -29,4 +29,4 @@ test.App.prototype = { } -test.App.registerClass('test.App'); +TypeTests.App.registerClass('TypeTests.App'); diff --git a/tests/TestCases/Type/Nullable/Code.cs b/tests/TestCases/Type/Nullable/Code.cs index 3701ba0b4..7efde2a84 100644 --- a/tests/TestCases/Type/Nullable/Code.cs +++ b/tests/TestCases/Type/Nullable/Code.cs @@ -3,7 +3,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace TypeTests { diff --git a/tests/TestCases/Type/Partials/Baseline.txt b/tests/TestCases/Type/Partials/Baseline.txt index 6eccc12a0..711f39776 100644 --- a/tests/TestCases/Type/Partials/Baseline.txt +++ b/tests/TestCases/Type/Partials/Baseline.txt @@ -1,130 +1,130 @@ -Type.registerNamespace('test'); +Type.registerNamespace('TypeTests'); //////////////////////////////////////////////////////////////////////////////// -// test.IMyInterface +// TypeTests.IMyInterface -test.IMyInterface = function() { }; -test.IMyInterface.prototype = { +TypeTests.IMyInterface = function() { }; +TypeTests.IMyInterface.prototype = { start : null, Stop : null, resume : null } -test.IMyInterface.registerInterface('test.IMyInterface'); +TypeTests.IMyInterface.registerInterface('TypeTests.IMyInterface'); //////////////////////////////////////////////////////////////////////////////// -// test.EmptyClass +// TypeTests.EmptyClass -test.EmptyClass = function test_EmptyClass() { +TypeTests.EmptyClass = function TypeTests_EmptyClass() { } //////////////////////////////////////////////////////////////////////////////// -// test.SingleMemberClass +// TypeTests.SingleMemberClass -test.SingleMemberClass = function test_SingleMemberClass() { +TypeTests.SingleMemberClass = function TypeTests_SingleMemberClass() { } -test.SingleMemberClass.prototype = { +TypeTests.SingleMemberClass.prototype = { - run: function test_SingleMemberClass$run() { + run: function TypeTests_SingleMemberClass$run() { } } //////////////////////////////////////////////////////////////////////////////// -// test.DerivedMemberClass +// TypeTests.DerivedMemberClass -test.DerivedMemberClass = function test_DerivedMemberClass() { - test.DerivedMemberClass.initializeBase(this); +TypeTests.DerivedMemberClass = function TypeTests_DerivedMemberClass() { + TypeTests.DerivedMemberClass.initializeBase(this); } //////////////////////////////////////////////////////////////////////////////// -// test.MergedMembersClass +// TypeTests.MergedMembersClass -test.MergedMembersClass = function test_MergedMembersClass() { +TypeTests.MergedMembersClass = function TypeTests_MergedMembersClass() { } -test.MergedMembersClass.prototype = { +TypeTests.MergedMembersClass.prototype = { foo: false, bar: null, - testMethod: function test_MergedMembersClass$testMethod() { + testMethod: function TypeTests_MergedMembersClass$testMethod() { return null; } } //////////////////////////////////////////////////////////////////////////////// -// test.DerivedMergedMembersClass +// TypeTests.DerivedMergedMembersClass -test.DerivedMergedMembersClass = function test_DerivedMergedMembersClass() { - test.DerivedMergedMembersClass.initializeBase(this); +TypeTests.DerivedMergedMembersClass = function TypeTests_DerivedMergedMembersClass() { + TypeTests.DerivedMergedMembersClass.initializeBase(this); this.name = this.bar + this.bar + 'Name'; } -test.DerivedMergedMembersClass.prototype = { +TypeTests.DerivedMergedMembersClass.prototype = { name: null, value: null, - testMethod: function test_DerivedMergedMembersClass$testMethod() { + testMethod: function TypeTests_DerivedMergedMembersClass$testMethod() { return null; }, - testMethod2: function test_DerivedMergedMembersClass$testMethod2() { + testMethod2: function TypeTests_DerivedMergedMembersClass$testMethod2() { return this.get_item('foo'); }, - someMethod: function test_DerivedMergedMembersClass$someMethod() { + someMethod: function TypeTests_DerivedMergedMembersClass$someMethod() { var e1 = document.getElementById(this.bar); var e2 = document.getElementById(this.name); var e3 = document.getElementById(this.bar); - var s = this.testMethod() + test.DerivedMergedMembersClass.callBaseMethod(this, 'testMethod'); + var s = this.testMethod() + TypeTests.DerivedMergedMembersClass.callBaseMethod(this, 'testMethod'); }, - get_item: function test_DerivedMergedMembersClass$get_item(s) { + get_item: function TypeTests_DerivedMergedMembersClass$get_item(s) { return s; } } //////////////////////////////////////////////////////////////////////////////// -// test.MyClass +// TypeTests.MyClass -test.MyClass = function test_MyClass() { +TypeTests.MyClass = function TypeTests_MyClass() { } -test.MyClass.prototype = { +TypeTests.MyClass.prototype = { - start: function test_MyClass$start() { + start: function TypeTests_MyClass$start() { }, - Stop: function test_MyClass$Stop() { + Stop: function TypeTests_MyClass$Stop() { }, - resume: function test_MyClass$resume() { + resume: function TypeTests_MyClass$resume() { } } //////////////////////////////////////////////////////////////////////////////// -// test.SomeClass +// TypeTests.SomeClass -test.SomeClass = function test_SomeClass() { +TypeTests.SomeClass = function TypeTests_SomeClass() { } -test.SomeClass.prototype = { +TypeTests.SomeClass.prototype = { - close: function test_SomeClass$close() { + close: function TypeTests_SomeClass$close() { }, - _cancel: function test_SomeClass$_cancel() { + _cancel: function TypeTests_SomeClass$_cancel() { }, - run: function test_SomeClass$run() { + run: function TypeTests_SomeClass$run() { } } //////////////////////////////////////////////////////////////////////////////// -// test.App +// TypeTests.App -test.App = function test_App() { +TypeTests.App = function TypeTests_App() { var s; s.run(); var d; @@ -137,11 +137,11 @@ test.App = function test_App() { } -test.EmptyClass.registerClass('test.EmptyClass'); -test.SingleMemberClass.registerClass('test.SingleMemberClass'); -test.DerivedMemberClass.registerClass('test.DerivedMemberClass', test.SingleMemberClass); -test.MergedMembersClass.registerClass('test.MergedMembersClass'); -test.DerivedMergedMembersClass.registerClass('test.DerivedMergedMembersClass', test.MergedMembersClass); -test.MyClass.registerClass('test.MyClass', null, test.IMyInterface); -test.SomeClass.registerClass('test.SomeClass'); -test.App.registerClass('test.App'); +TypeTests.EmptyClass.registerClass('TypeTests.EmptyClass'); +TypeTests.SingleMemberClass.registerClass('TypeTests.SingleMemberClass'); +TypeTests.DerivedMemberClass.registerClass('TypeTests.DerivedMemberClass', TypeTests.SingleMemberClass); +TypeTests.MergedMembersClass.registerClass('TypeTests.MergedMembersClass'); +TypeTests.DerivedMergedMembersClass.registerClass('TypeTests.DerivedMergedMembersClass', TypeTests.MergedMembersClass); +TypeTests.MyClass.registerClass('TypeTests.MyClass', null, TypeTests.IMyInterface); +TypeTests.SomeClass.registerClass('TypeTests.SomeClass'); +TypeTests.App.registerClass('TypeTests.App'); diff --git a/tests/TestCases/Type/Partials/Code1.cs b/tests/TestCases/Type/Partials/Code1.cs index e6ca81a5f..444752c88 100644 --- a/tests/TestCases/Type/Partials/Code1.cs +++ b/tests/TestCases/Type/Partials/Code1.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace TypeTests { diff --git a/tests/TestCases/Type/Records/Baseline.txt b/tests/TestCases/Type/Records/Baseline.txt index d1c96ccc8..eed9c7e14 100644 --- a/tests/TestCases/Type/Records/Baseline.txt +++ b/tests/TestCases/Type/Records/Baseline.txt @@ -1,9 +1,9 @@ -Type.registerNamespace('test'); +Type.registerNamespace('TypeTests'); //////////////////////////////////////////////////////////////////////////////// -// test.Point +// TypeTests.Point -test.$create_Point = function test_Point(x, y) { +TypeTests.$create_Point = function TypeTests_Point(x, y) { var $o = { }; $o.x = x; $o.y = y; @@ -12,8 +12,8 @@ test.$create_Point = function test_Point(x, y) { //////////////////////////////////////////////////////////////////////////////// -// test.Pair +// TypeTests.Pair -test.$create_Pair = function test_Pair() { return {}; } +TypeTests.$create_Pair = function TypeTests_Pair() { return {}; } diff --git a/tests/TestCases/Type/Records/Code.cs b/tests/TestCases/Type/Records/Code.cs index c4dc87fcb..4571de0ad 100644 --- a/tests/TestCases/Type/Records/Code.cs +++ b/tests/TestCases/Type/Records/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace TypeTests { diff --git a/tests/TestCases/Type/ScriptNamespaces/AppAssemblyInfo.cs b/tests/TestCases/Type/ScriptNamespaces/AppAssemblyInfo.cs index 0b34758e9..c058305f9 100644 --- a/tests/TestCases/Type/ScriptNamespaces/AppAssemblyInfo.cs +++ b/tests/TestCases/Type/ScriptNamespaces/AppAssemblyInfo.cs @@ -10,4 +10,3 @@ [assembly: AssemblyTitle("My.App")] [assembly: AssemblyDescription("MyApp")] [assembly: ScriptAssembly("App")] -[assembly: ScriptNamespace("MA")] diff --git a/tests/TestCases/Type/ScriptNamespaces/AppBaseline.txt b/tests/TestCases/Type/ScriptNamespaces/AppBaseline.txt index b4aa6d17e..ea1760caa 100644 --- a/tests/TestCases/Type/ScriptNamespaces/AppBaseline.txt +++ b/tests/TestCases/Type/ScriptNamespaces/AppBaseline.txt @@ -1,24 +1,20 @@ -Type.registerNamespace('MAF'); - -Type.registerNamespace('MA'); - -Type.registerNamespace('Test'); +Type.registerNamespace('My.App'); //////////////////////////////////////////////////////////////////////////////// -// MAF.AppFeature +// My.App.AppFeature -MAF.AppFeature = function MAF_AppFeature(name) { +My.App.AppFeature = function My_App_AppFeature(name) { this._name = name; - this._feature = new MLF.Feature(name); + this._feature = new Lib.Feature(name); } -MAF.AppFeature.prototype = { +My.App.AppFeature.prototype = { _name: null, _feature: null, - get_name: function MAF_AppFeature$get_name() { + get_name: function My_App_AppFeature$get_name() { return this._name; }, - set_name: function MAF_AppFeature$set_name(value) { + set_name: function My_App_AppFeature$set_name(value) { this._name = value; return value; } @@ -26,27 +22,27 @@ MAF.AppFeature.prototype = { //////////////////////////////////////////////////////////////////////////////// -// MA.MyApp +// My.App.MyApp -MA.MyApp = function MA_MyApp(name, appFeatureName, libName, libFeatureName) { +My.App.MyApp = function My_App_MyApp(name, appFeatureName, libName, libFeatureName) { this._name = name; - this._appfeature = new MAF.AppFeature(appFeatureName); - this._lib = new ML.MyLib('lib1', libName); - this._lib.set_feature(new MLF.Feature(libFeatureName)); + this._appfeature = new My.App.AppFeature(appFeatureName); + this._lib = new Lib.MyLib('lib1', libName); + this._lib.set_feature(new Lib.Feature(libFeatureName)); } -MA.MyApp.prototype = { +My.App.MyApp.prototype = { _name: null, _appfeature: null, _lib: null, - get_name: function MA_MyApp$get_name() { + get_name: function My_App_MyApp$get_name() { return this._name; }, - get_lib: function MA_MyApp$get_lib() { + get_lib: function My_App_MyApp$get_lib() { return this._lib; }, - set_lib: function MA_MyApp$set_lib(value) { + set_lib: function My_App_MyApp$set_lib(value) { this._lib = value; return value; } @@ -54,12 +50,12 @@ MA.MyApp.prototype = { //////////////////////////////////////////////////////////////////////////////// -// Test.Foo +// My.App.Foo -Test.Foo = function Test_Foo() { +My.App.Foo = function My_App_Foo() { } -MAF.AppFeature.registerClass('MAF.AppFeature'); -MA.MyApp.registerClass('MA.MyApp'); -Test.Foo.registerClass('Test.Foo'); +My.App.AppFeature.registerClass('My.App.AppFeature'); +My.App.MyApp.registerClass('My.App.MyApp'); +My.App.Foo.registerClass('My.App.Foo'); diff --git a/tests/TestCases/Type/ScriptNamespaces/AppFeature.cs b/tests/TestCases/Type/ScriptNamespaces/AppFeature.cs index 5d400b007..56a461332 100644 --- a/tests/TestCases/Type/ScriptNamespaces/AppFeature.cs +++ b/tests/TestCases/Type/ScriptNamespaces/AppFeature.cs @@ -3,7 +3,7 @@ using My.Lib; namespace My.App { - [ScriptNamespace("MAF")] + public class AppFeature { string _name; Feature _feature; diff --git a/tests/TestCases/Type/ScriptNamespaces/AppFoo.2.cs b/tests/TestCases/Type/ScriptNamespaces/AppFoo.2.cs index 4c722f254..10e076728 100644 --- a/tests/TestCases/Type/ScriptNamespaces/AppFoo.2.cs +++ b/tests/TestCases/Type/ScriptNamespaces/AppFoo.2.cs @@ -4,7 +4,6 @@ namespace My.App { - [ScriptNamespace("Test")] public partial class Foo { } } diff --git a/tests/TestCases/Type/ScriptNamespaces/LibraryAssemblyInfo.cs b/tests/TestCases/Type/ScriptNamespaces/LibraryAssemblyInfo.cs index f8716a28d..4a55c2e5d 100644 --- a/tests/TestCases/Type/ScriptNamespaces/LibraryAssemblyInfo.cs +++ b/tests/TestCases/Type/ScriptNamespaces/LibraryAssemblyInfo.cs @@ -8,4 +8,3 @@ [assembly: AssemblyTitle("My.Lib")] [assembly: AssemblyDescription("MyLib")] [assembly: ScriptAssembly("Lib")] -[assembly: ScriptNamespace("ML")] diff --git a/tests/TestCases/Type/ScriptNamespaces/LibraryBaseline.txt b/tests/TestCases/Type/ScriptNamespaces/LibraryBaseline.txt index a1f473456..387df14f1 100644 --- a/tests/TestCases/Type/ScriptNamespaces/LibraryBaseline.txt +++ b/tests/TestCases/Type/ScriptNamespaces/LibraryBaseline.txt @@ -1,20 +1,18 @@ -Type.registerNamespace('MLF'); - -Type.registerNamespace('ML'); +Type.registerNamespace('My.Lib'); //////////////////////////////////////////////////////////////////////////////// -// MLF.Feature +// My.Lib.Feature -MLF.Feature = function MLF_Feature(name) { +My.Lib.Feature = function My_Lib_Feature(name) { this._name = name; } -MLF.Feature.prototype = { +My.Lib.Feature.prototype = { _name: null, - get_name: function MLF_Feature$get_name() { + get_name: function My_Lib_Feature$get_name() { return this._name; }, - set_name: function MLF_Feature$set_name(value) { + set_name: function My_Lib_Feature$set_name(value) { this._name = value; return value; } @@ -22,29 +20,29 @@ MLF.Feature.prototype = { //////////////////////////////////////////////////////////////////////////////// -// ML.MyLib +// My.Lib.MyLib -ML.MyLib = function ML_MyLib(name, featureName) { +My.Lib.MyLib = function My_Lib_MyLib(name, featureName) { this._name = name; - this._feature = new MLF.Feature(featureName); + this._feature = new My.Lib.Feature(featureName); } -ML.MyLib.prototype = { +My.Lib.MyLib.prototype = { _name: null, _feature: null, - get_name: function ML_MyLib$get_name() { + get_name: function My_Lib_MyLib$get_name() { return this._name; }, - get_feature: function ML_MyLib$get_feature() { + get_feature: function My_Lib_MyLib$get_feature() { return this._feature; }, - set_feature: function ML_MyLib$set_feature(value) { + set_feature: function My_Lib_MyLib$set_feature(value) { this._feature = value; return value; } } -MLF.Feature.registerClass('MLF.Feature'); -ML.MyLib.registerClass('ML.MyLib'); +My.Lib.Feature.registerClass('My.Lib.Feature'); +My.Lib.MyLib.registerClass('My.Lib.MyLib'); diff --git a/tests/TestCases/Type/ScriptNamespaces/LibraryFeature.cs b/tests/TestCases/Type/ScriptNamespaces/LibraryFeature.cs index fd362e263..47f833796 100644 --- a/tests/TestCases/Type/ScriptNamespaces/LibraryFeature.cs +++ b/tests/TestCases/Type/ScriptNamespaces/LibraryFeature.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; namespace My.Lib { - [ScriptNamespace("MLF")] + public class Feature { string _name; diff --git a/tests/TestCases/Type/UsingAlias/Baseline.txt b/tests/TestCases/Type/UsingAlias/Baseline.txt index fec6f793a..9e4a3dc97 100644 --- a/tests/TestCases/Type/UsingAlias/Baseline.txt +++ b/tests/TestCases/Type/UsingAlias/Baseline.txt @@ -1,13 +1,13 @@ -Type.registerNamespace('test'); +Type.registerNamespace('TypeTests'); //////////////////////////////////////////////////////////////////////////////// -// test.MyClass +// TypeTests.MyClass -test.MyClass = function test_MyClass() { +TypeTests.MyClass = function TypeTests_MyClass() { var body = document.body; var head = document.getElementsByTagName('head')[0]; head.appendChild(body); } -test.MyClass.registerClass('test.MyClass'); +TypeTests.MyClass.registerClass('TypeTests.MyClass'); diff --git a/tests/TestCases/Type/UsingAlias/Code.cs b/tests/TestCases/Type/UsingAlias/Code.cs index b4510d699..c479ca736 100644 --- a/tests/TestCases/Type/UsingAlias/Code.cs +++ b/tests/TestCases/Type/UsingAlias/Code.cs @@ -4,7 +4,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace TypeTests { diff --git a/tests/TestCases/Validation/ConflictingTypes/Code.cs b/tests/TestCases/Validation/ConflictingTypes/Code.cs index d51b1b728..14b9b1c04 100644 --- a/tests/TestCases/Validation/ConflictingTypes/Code.cs +++ b/tests/TestCases/Validation/ConflictingTypes/Code.cs @@ -2,7 +2,6 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] namespace ValidationTests { diff --git a/tests/TestCases/Validation/CreateInstance/Code.cs b/tests/TestCases/Validation/CreateInstance/Code.cs index 466ad9fde..f503f9ef8 100644 --- a/tests/TestCases/Validation/CreateInstance/Code.cs +++ b/tests/TestCases/Validation/CreateInstance/Code.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] + namespace ValidationTests { diff --git a/tests/TestCases/Validation/Exceptions/Code.cs b/tests/TestCases/Validation/Exceptions/Code.cs index cf8de7a90..90250447e 100644 --- a/tests/TestCases/Validation/Exceptions/Code.cs +++ b/tests/TestCases/Validation/Exceptions/Code.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] + namespace ValidationTests { diff --git a/tests/TestCases/Validation/ImplicitEnums/Code.cs b/tests/TestCases/Validation/ImplicitEnums/Code.cs index 88676860a..2a609dd84 100644 --- a/tests/TestCases/Validation/ImplicitEnums/Code.cs +++ b/tests/TestCases/Validation/ImplicitEnums/Code.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] + namespace ValidationTests { diff --git a/tests/TestCases/Validation/InlineScript/Code.cs b/tests/TestCases/Validation/InlineScript/Code.cs index 738742e99..28de5655f 100644 --- a/tests/TestCases/Validation/InlineScript/Code.cs +++ b/tests/TestCases/Validation/InlineScript/Code.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] + namespace ValidationTests { diff --git a/tests/TestCases/Validation/Keywords/Code.cs b/tests/TestCases/Validation/Keywords/Code.cs index 8c5d9e092..8140ab316 100644 --- a/tests/TestCases/Validation/Keywords/Code.cs +++ b/tests/TestCases/Validation/Keywords/Code.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] + namespace ValidationTests { diff --git a/tests/TestCases/Validation/NestedTypes/Code.cs b/tests/TestCases/Validation/NestedTypes/Code.cs index fdb94f884..b745728b7 100644 --- a/tests/TestCases/Validation/NestedTypes/Code.cs +++ b/tests/TestCases/Validation/NestedTypes/Code.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] + namespace ValidationTests { diff --git a/tests/TestCases/Validation/Overloads/Code.cs b/tests/TestCases/Validation/Overloads/Code.cs index 9649431aa..4053a0e33 100644 --- a/tests/TestCases/Validation/Overloads/Code.cs +++ b/tests/TestCases/Validation/Overloads/Code.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] + namespace ValidationTests { diff --git a/tests/TestCases/Validation/Properties/Code.cs b/tests/TestCases/Validation/Properties/Code.cs index 1ac164236..952ce78b3 100644 --- a/tests/TestCases/Validation/Properties/Code.cs +++ b/tests/TestCases/Validation/Properties/Code.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] + namespace ValidationTests { diff --git a/tests/TestCases/Validation/Unsupported/Code1.cs b/tests/TestCases/Validation/Unsupported/Code1.cs index 7b745ae34..c185b2947 100644 --- a/tests/TestCases/Validation/Unsupported/Code1.cs +++ b/tests/TestCases/Validation/Unsupported/Code1.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] + namespace ValidationTests { diff --git a/tests/TestCases/Validation/Unsupported/Code2.cs b/tests/TestCases/Validation/Unsupported/Code2.cs index edfac2735..328f846da 100644 --- a/tests/TestCases/Validation/Unsupported/Code2.cs +++ b/tests/TestCases/Validation/Unsupported/Code2.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] -[assembly: ScriptNamespace("test")] + namespace ValidationTests { From 97c66150abf0cf6db7b8c4d82e1f6603ca31a02f Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 9 Sep 2012 15:52:50 -0700 Subject: [PATCH 006/251] Add ScriptDependencyAttribute --- src/Core/Compiler/Compiler/MetadataBuilder.cs | 6 ++++- src/Core/Compiler/Importer/MetadataHelpers.cs | 9 +++++++ .../Compiler/Importer/MetadataImporter.cs | 6 ++++- src/Core/CoreLib/ScriptMetadata.cs | 22 ++++++++++++++++ tests/ScriptSharp/BasicTests.cs | 21 +++++++++++++++ tests/TestCases/Basic/Dependencies/Code1.cs | 19 ++++++++++++++ .../Basic/Dependencies/Code1Baseline.txt | 18 +++++++++++++ tests/TestCases/Basic/Dependencies/Code2.cs | 21 +++++++++++++++ .../Basic/Dependencies/Code2Baseline.txt | 20 +++++++++++++++ tests/TestCases/Basic/Dependencies/Lib.bat | 3 +++ tests/TestCases/Basic/Dependencies/Lib1.cs | 14 ++++++++++ tests/TestCases/Basic/Dependencies/Lib1.dll | Bin 0 -> 3072 bytes tests/TestCases/Basic/Dependencies/Lib2.cs | 15 +++++++++++ tests/TestCases/Basic/Dependencies/Lib2.dll | Bin 0 -> 3072 bytes tests/TestCases/Basic/Dependencies/Lib3.cs | 24 ++++++++++++++++++ tests/TestCases/Basic/Dependencies/Lib3.dll | Bin 0 -> 3072 bytes .../TestCases/Basic/Dependencies/Template.js | 6 +++++ 17 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 tests/TestCases/Basic/Dependencies/Code1.cs create mode 100644 tests/TestCases/Basic/Dependencies/Code1Baseline.txt create mode 100644 tests/TestCases/Basic/Dependencies/Code2.cs create mode 100644 tests/TestCases/Basic/Dependencies/Code2Baseline.txt create mode 100644 tests/TestCases/Basic/Dependencies/Lib.bat create mode 100644 tests/TestCases/Basic/Dependencies/Lib1.cs create mode 100644 tests/TestCases/Basic/Dependencies/Lib1.dll create mode 100644 tests/TestCases/Basic/Dependencies/Lib2.cs create mode 100644 tests/TestCases/Basic/Dependencies/Lib2.dll create mode 100644 tests/TestCases/Basic/Dependencies/Lib3.cs create mode 100644 tests/TestCases/Basic/Dependencies/Lib3.dll create mode 100644 tests/TestCases/Basic/Dependencies/Template.js diff --git a/src/Core/Compiler/Compiler/MetadataBuilder.cs b/src/Core/Compiler/Compiler/MetadataBuilder.cs index 6cd94d73d..f6c7dc2fa 100644 --- a/src/Core/Compiler/Compiler/MetadataBuilder.cs +++ b/src/Core/Compiler/Compiler/MetadataBuilder.cs @@ -705,11 +705,15 @@ private void BuildType(TypeSymbol typeSymbol, UserTypeNode typeNode) { ParseNodeList attributes = typeNode.Attributes; if (AttributeNode.FindAttribute(attributes, "Imported") != null) { - typeSymbol.SetImported(/* dependencyName */ null); + string dependencyName = GetAttributeValue(attributes, "ScriptDependency"); + typeSymbol.SetImported(dependencyName); if (AttributeNode.FindAttribute(attributes, "IgnoreNamespace") != null) { typeSymbol.SetIgnoreNamespace(); } + else { + typeSymbol.ScriptNamespace = dependencyName; + } } if (AttributeNode.FindAttribute(attributes, "PreserveName") != null) { diff --git a/src/Core/Compiler/Importer/MetadataHelpers.cs b/src/Core/Compiler/Importer/MetadataHelpers.cs index 93f42b3d4..9daa71472 100644 --- a/src/Core/Compiler/Importer/MetadataHelpers.cs +++ b/src/Core/Compiler/Importer/MetadataHelpers.cs @@ -46,6 +46,15 @@ public static string GetScriptAssemblyName(ICustomAttributeProvider attributePro return null; } + public static string GetScriptDependencyName(ICustomAttributeProvider attributeProvider) { + CustomAttribute scriptAssemblyAttribute = GetAttribute(attributeProvider, "System.Runtime.CompilerServices.ScriptDependencyAttribute"); + if (scriptAssemblyAttribute != null) { + return GetAttributeArgument(scriptAssemblyAttribute); + } + + return null; + } + public static string GetScriptName(ICustomAttributeProvider attributeProvider) { CustomAttribute scriptAssemblyAttribute = GetAttribute(attributeProvider, "System.Runtime.CompilerServices.ScriptNameAttribute"); if (scriptAssemblyAttribute != null) { diff --git a/src/Core/Compiler/Importer/MetadataImporter.cs b/src/Core/Compiler/Importer/MetadataImporter.cs index 3cece5f27..55406a8a3 100644 --- a/src/Core/Compiler/Importer/MetadataImporter.cs +++ b/src/Core/Compiler/Importer/MetadataImporter.cs @@ -736,13 +736,17 @@ private void ImportType(MetadataSource mdSource, TypeDefinition type, bool inScr typeSymbol.AddGenericParameters(genericArguments); } - typeSymbol.SetImported(assemblyScriptName); + string dependencyName = MetadataHelpers.GetScriptDependencyName(type); + typeSymbol.SetImported(dependencyName); typeSymbol.SetMetadataToken(type, inScriptCoreAssembly); bool ignoreNamespace = MetadataHelpers.ShouldIgnoreNamespace(type); if (ignoreNamespace) { typeSymbol.SetIgnoreNamespace(); } + else { + typeSymbol.ScriptNamespace = dependencyName; + } typeSymbol.SetPublic(); if (String.IsNullOrEmpty(assemblyScriptName) == false) { diff --git a/src/Core/CoreLib/ScriptMetadata.cs b/src/Core/CoreLib/ScriptMetadata.cs index 481b2eec6..f5a04a27e 100644 --- a/src/Core/CoreLib/ScriptMetadata.cs +++ b/src/Core/CoreLib/ScriptMetadata.cs @@ -56,6 +56,28 @@ public string Name { } } + /// + /// Marks a type with a script dependency that is required at runtime. + /// The specified name is used as the name of the dependency, and the runtime identifier. + /// + [AttributeUsage(AttributeTargets.Type, Inherited = false, AllowMultiple = false)] + [NonScriptable] + [Imported] + public sealed class ScriptDependencyAttribute : Attribute { + + private string _name; + + public ScriptDependencyAttribute(string name) { + _name = name; + } + + public string Name { + get { + return _name; + } + } + } + /// /// This attribute indicates that the namespace of type within a system assembly /// should be ignored at script generation time. It is useful for creating namespaces diff --git a/tests/ScriptSharp/BasicTests.cs b/tests/ScriptSharp/BasicTests.cs index ab68eb7f1..52ba1f874 100644 --- a/tests/ScriptSharp/BasicTests.cs +++ b/tests/ScriptSharp/BasicTests.cs @@ -29,6 +29,27 @@ public void TestConditionals() { }, "TraceBaseline.txt"); } + [TestMethod] + public void TestDependencies() { + RunTest((c) => { + c.AddReference("Lib1.dll"). + AddReference("Lib2.dll"). + AddReference("Lib3.dll"). + AddTemplate("Template.js"). + AddSource("Code1.cs"); + c.Options.DebugFlavor = true; + }, "Code1Baseline.txt"); + + RunTest((c) => { + c.AddReference("Lib1.dll"). + AddReference("Lib2.dll"). + AddReference("Lib3.dll"). + AddTemplate("Template.js"). + AddSource("Code2.cs"); + c.Options.DebugFlavor = true; + }, "Code2Baseline.txt"); + } + [TestMethod] public void TestDocComments() { RunTest((c) => { diff --git a/tests/TestCases/Basic/Dependencies/Code1.cs b/tests/TestCases/Basic/Dependencies/Code1.cs new file mode 100644 index 000000000..b882ea75b --- /dev/null +++ b/tests/TestCases/Basic/Dependencies/Code1.cs @@ -0,0 +1,19 @@ +using System; +using System.Html; +using System.Runtime.CompilerServices; +using Library1; +using Library2; +using Library3; + +[assembly: ScriptAssembly("test")] + +namespace BasicTests { + + public class App { + + public App() { + Component1 c1 = new Component1(); + Component1 c2 = new Component2(); + } + } +} diff --git a/tests/TestCases/Basic/Dependencies/Code1Baseline.txt b/tests/TestCases/Basic/Dependencies/Code1Baseline.txt new file mode 100644 index 000000000..57bfba6d8 --- /dev/null +++ b/tests/TestCases/Basic/Dependencies/Code1Baseline.txt @@ -0,0 +1,18 @@ +define('test', [ 'ss','lib1' ], function(ss,lib1) { + + +Type.registerNamespace('BasicTests'); + +//////////////////////////////////////////////////////////////////////////////// +// BasicTests.App + +BasicTests.App = function BasicTests_App() { + var c1 = new lib1.Component1(); + var c2 = new Component2(); +} + + +BasicTests.App.registerClass('BasicTests.App'); + +}); + diff --git a/tests/TestCases/Basic/Dependencies/Code2.cs b/tests/TestCases/Basic/Dependencies/Code2.cs new file mode 100644 index 000000000..741d4fc21 --- /dev/null +++ b/tests/TestCases/Basic/Dependencies/Code2.cs @@ -0,0 +1,21 @@ +using System; +using System.Html; +using System.Runtime.CompilerServices; +using Library1; +using Library2; +using Library3; + +[assembly: ScriptAssembly("test")] + +namespace BasicTests { + + public class App { + + public App() { + Component1 c1 = new Component1(); + Component2 c2 = new Component2(); + Component3 c3 = new Component3(); + Component4 c4 = new Component4(); + } + } +} diff --git a/tests/TestCases/Basic/Dependencies/Code2Baseline.txt b/tests/TestCases/Basic/Dependencies/Code2Baseline.txt new file mode 100644 index 000000000..94eedd067 --- /dev/null +++ b/tests/TestCases/Basic/Dependencies/Code2Baseline.txt @@ -0,0 +1,20 @@ +define('test', [ 'ss','lib1','comp3','comp4' ], function(ss,lib1,comp3,comp4) { + + +Type.registerNamespace('BasicTests'); + +//////////////////////////////////////////////////////////////////////////////// +// BasicTests.App + +BasicTests.App = function BasicTests_App() { + var c1 = new lib1.Component1(); + var c2 = new Component2(); + var c3 = new comp3.Component3(); + var c4 = new Component4(); +} + + +BasicTests.App.registerClass('BasicTests.App'); + +}); + diff --git a/tests/TestCases/Basic/Dependencies/Lib.bat b/tests/TestCases/Basic/Dependencies/Lib.bat new file mode 100644 index 000000000..20c1d5600 --- /dev/null +++ b/tests/TestCases/Basic/Dependencies/Lib.bat @@ -0,0 +1,3 @@ +csc.exe /t:library /noconfig /nologo /nostdlib /r:..\..\..\..\bin\Debug\mscorlib.dll /out:Lib1.dll Lib1.cs +csc.exe /t:library /noconfig /nologo /nostdlib /r:..\..\..\..\bin\Debug\mscorlib.dll /out:Lib2.dll Lib2.cs +csc.exe /t:library /noconfig /nologo /nostdlib /r:..\..\..\..\bin\Debug\mscorlib.dll /out:Lib3.dll Lib3.cs diff --git a/tests/TestCases/Basic/Dependencies/Lib1.cs b/tests/TestCases/Basic/Dependencies/Lib1.cs new file mode 100644 index 000000000..43862f90c --- /dev/null +++ b/tests/TestCases/Basic/Dependencies/Lib1.cs @@ -0,0 +1,14 @@ +using System; +using System.Runtime.CompilerServices; + +[assembly: ScriptAssembly("lib1")] + +namespace Library1 { + + [Imported] + public class Component1 { + + public Component1() { + } + } +} diff --git a/tests/TestCases/Basic/Dependencies/Lib1.dll b/tests/TestCases/Basic/Dependencies/Lib1.dll new file mode 100644 index 0000000000000000000000000000000000000000..ebc05a0982cd47c249847c67c7d5e1e7283d431a GIT binary patch literal 3072 zcmeHJ&1+m$6#u=+H0HyGN=4d5^(ASs6nV@v16l~_B$--AGbVJ}P)ebhH*=jnc^|`l zZ%P6paiMf)7cN|ge}Z;VB#4TOE(%g`FG9gTz_mh~{?2`GGLzC)3R1ernYrhlbME>0 zojdp5q;}~Bh5+O_wzq*T&O&9wpUyV9Jn_bl6Sy^ccXG>Gx;uIPsu$ZG9kq2Mu$zrA zj1t>bw(f?u7uuEOx*bF<`|W#H>9PShP*176-yohBHcPNLQm>bImO*GvPC)TepP(XnoF*f^3TYHQXlEUV*P`7ow!9_v1Rp(Lvtqn z70h7*hsnoSUATjB9Ks?a4kEuv*Io39(O%lIS$MN2&(@+=*H?2`^4y}+@_j5uK_?1T zm=wjP8+xONAZ|w5_gvIB;zR{lc0X3l1Wq%FbY^qTb;HC9lq2z;uXJ7MYhF{us5iCO zN#^5N1+Kp_pK!lX{PU)KM*{pZ$i_c8M2uYY}i z>8BrV)4|HymNk)={Tj89C$^#lU7s?chJ7ot-PZ@D-Z=!WEJnKG`?ZD_rfn)^wn4nN zk1^id=E2xK`TyDhIpg5D#pdpe=`Aii#x8#Hc3dn2vpLaHn$49ctfG!9QWeYi zkb0H;UCKf~=l_1tyJg0ZvD4X{=RAkne|Ox=D<0NbElMtAT(z|5h^AMUhc0+T{fWjvG8nTyGoi zMRwZ3hC$TERbqmA#MV0SnDKBOn$9TPLp keq(wD#O)K6{hx8t(;hvi9kA2?8E&3@PWAT6yihyv5XfoeRR910 literal 0 HcmV?d00001 diff --git a/tests/TestCases/Basic/Dependencies/Lib2.cs b/tests/TestCases/Basic/Dependencies/Lib2.cs new file mode 100644 index 000000000..32046ba55 --- /dev/null +++ b/tests/TestCases/Basic/Dependencies/Lib2.cs @@ -0,0 +1,15 @@ +using System; +using System.Runtime.CompilerServices; + +[assembly: ScriptAssembly("")] + +namespace Library2 { + + [Imported] + [IgnoreNamespace] + public class Component2 { + + public Component2() { + } + } +} diff --git a/tests/TestCases/Basic/Dependencies/Lib2.dll b/tests/TestCases/Basic/Dependencies/Lib2.dll new file mode 100644 index 0000000000000000000000000000000000000000..62081dfd194045519ceb7c598bb3e6fa30ef63f8 GIT binary patch literal 3072 zcmeHJO=w(I6#m|167$oBN<}K7z9cP{B9C!0poI`8Kedh~ozQ8E6tQ_TbDh5Oeun$r zlmm2ShGe@dt!Z~AMFkbGgH=7n$%co{c)DF%~9n5 z4jH+SLc}2X8`>tPU1$W=>jIVEe9lxck=~`>h6q*Q!)%|Z1KI=*43zs2Y+!r{K2H6m zA>B#TwS@Z55|eADfPciNdDGFcZgJVruPst3|AN z&9c+>eXK-5Hwsmll*Oi9y;VjKw<7I(O*FRRLp zbVKQ@UQ5Mjw6xbvmf~0iO@C`C;a6z(5@jNy#$Y;8?c7}JgppQf+(5-$x25t0jMye` z=atugIr-VQ^-r$v{C>Ol@fD1}ck`#uFMj>ycLZ2P+p?yM($&$lwYV{xm;1fQcCHUg z{qvgJF0Dj*)%Vw3FHBpYlxdM5c8}4Ix&1kQU%Gb(1#(;q;Eua{-2Nenh*?mqkFBB0K{ zmE7AznLFCF%L@t|H~Fk_y<^ZTth9?QlTinknG?))S}?xrnO&+D-~A4XcJCM!Q^yAP zMvUBJy$Qd--fHqXq#odTvuBC*#zY3p+h~uR8EI Dt|ssi literal 0 HcmV?d00001 diff --git a/tests/TestCases/Basic/Dependencies/Lib3.cs b/tests/TestCases/Basic/Dependencies/Lib3.cs new file mode 100644 index 000000000..aa24b48d2 --- /dev/null +++ b/tests/TestCases/Basic/Dependencies/Lib3.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.CompilerServices; + +[assembly: ScriptAssembly("")] + +namespace Library3 { + + [Imported] + [ScriptDependency("comp3")] + public class Component3 { + + public Component3() { + } + } + + [Imported] + [ScriptDependency("comp4")] + [IgnoreNamespace] + public class Component4 { + + public Component4() { + } + } +} diff --git a/tests/TestCases/Basic/Dependencies/Lib3.dll b/tests/TestCases/Basic/Dependencies/Lib3.dll new file mode 100644 index 0000000000000000000000000000000000000000..c947bbd88d992f321d941a33c2be4c01e6112dce GIT binary patch literal 3072 zcmeHJ&2Jk;6#uPbm&BnFC>08-fQ{UWQmU1~K7fd*lejHL`BI#gDxfy&_24Yp4{LW_ zH5cRyZ~zI891!Bh5e^7N2qX?1xb(&!fW#4`p15!z{NC(3>y!e5145$D-Z$^P`OW*9 zov~N9-@^oeBAZ>-#!-`aI!vmb@M$o5Ug4uUW- zJIag(f$0WjbG>c)VOLqlkC#tnt~V|KE5-y`kF0KtqJ59T{IoHhCUq>eUaN34`84PYK4z+zNR#y27NG&WpRE)1kamFk50$?mnDjjcpQQf6 zm~JKNWvDZwK@ z!Jw7bfg#85s8`xaUGhVys*Pjh$iFG31CW; zUryKXP+C)osf_EG*+B=E!IHaWej-mQSLB;t+Sx zTUx*G&}!i6k-V@Pb_bq%9xHCAW_3Le%c0*70~I7Su|;;YSIcd6_^}g4p4<FHV$? z_0DU`Nnkli7-cqVa}Xr1uPkxpdMawG=!Wa47;PtV`^jP)E5GCIEhgN^&LB}bI9iMw zC90d7Q+QMLRnS#|Gq#}B3&KdP*}jVVwxjYTQrCp3t9yIv=a;^n-CX<0e6s!J=id-u6ivgJDawA84U`;aTFXVgHYL54)$AOI!!?mjk$z93^ODb8Uk;^_{L#)G|TklR_|gLoZKB(8^D4bs*Dy2aw4zr zZoN)^0h^RsJUeUDTjUqBbM#g5_OGMUG+Ha;`Am^}eax-4%9%Il)kZ`=F7FOSp8;Ow zc@;XPFVii~+O)=;w~-JRQcLO6;s@MygE=KcxwQB0;_0TwR5AM0(V+~SV@AdyzRBn@ zPpA0lABkfUTji~lW3Lb!5uN8!~JE(D0mv*@| zfipUv70&lGdYP5>v8OZYVV9nuU*`qwdp)yD)#7{9LDBv=MqSsj!L=bH4_I%)9XMJ| rUWe2KJfqhvvfh|TpLu)C%KXc9Qqw*9mpWjk{~308Dc+<1Uk82z$f5#{ literal 0 HcmV?d00001 diff --git a/tests/TestCases/Basic/Dependencies/Template.js b/tests/TestCases/Basic/Dependencies/Template.js new file mode 100644 index 000000000..6e6a2a198 --- /dev/null +++ b/tests/TestCases/Basic/Dependencies/Template.js @@ -0,0 +1,6 @@ +define('#= Name ##', [ #= DependencyNames ## ], function(#= Dependencies ##) { + +#include[as-is] "%code%" + +}); + \ No newline at end of file From b1da2f231163c0eb806b2068699e93a5fdc88999 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 9 Sep 2012 16:01:07 -0700 Subject: [PATCH 007/251] Remove ScriptNamespace test ... no longer needed. --- tests/ScriptSharp/TypeTests.cs | 20 ------ .../Type/ScriptNamespaces/AppAssemblyInfo.cs | 12 ---- .../Type/ScriptNamespaces/AppBaseline.txt | 61 ------------------ .../Type/ScriptNamespaces/AppFeature.cs | 23 ------- .../Type/ScriptNamespaces/AppFoo.1.cs | 8 --- .../Type/ScriptNamespaces/AppFoo.2.cs | 9 --- .../Type/ScriptNamespaces/AppMyApp.cs | 28 -------- tests/TestCases/Type/ScriptNamespaces/Lib.dll | Bin 3584 -> 0 bytes .../Type/ScriptNamespaces/Library.bat | 1 - .../ScriptNamespaces/LibraryAssemblyInfo.cs | 10 --- .../Type/ScriptNamespaces/LibraryBaseline.txt | 48 -------------- .../Type/ScriptNamespaces/LibraryFeature.cs | 18 ------ .../Type/ScriptNamespaces/LibraryMyLib.cs | 23 ------- 13 files changed, 261 deletions(-) delete mode 100644 tests/TestCases/Type/ScriptNamespaces/AppAssemblyInfo.cs delete mode 100644 tests/TestCases/Type/ScriptNamespaces/AppBaseline.txt delete mode 100644 tests/TestCases/Type/ScriptNamespaces/AppFeature.cs delete mode 100644 tests/TestCases/Type/ScriptNamespaces/AppFoo.1.cs delete mode 100644 tests/TestCases/Type/ScriptNamespaces/AppFoo.2.cs delete mode 100644 tests/TestCases/Type/ScriptNamespaces/AppMyApp.cs delete mode 100644 tests/TestCases/Type/ScriptNamespaces/Lib.dll delete mode 100644 tests/TestCases/Type/ScriptNamespaces/Library.bat delete mode 100644 tests/TestCases/Type/ScriptNamespaces/LibraryAssemblyInfo.cs delete mode 100644 tests/TestCases/Type/ScriptNamespaces/LibraryBaseline.txt delete mode 100644 tests/TestCases/Type/ScriptNamespaces/LibraryFeature.cs delete mode 100644 tests/TestCases/Type/ScriptNamespaces/LibraryMyLib.cs diff --git a/tests/ScriptSharp/TypeTests.cs b/tests/ScriptSharp/TypeTests.cs index ee60c48ad..15af0e2d8 100644 --- a/tests/ScriptSharp/TypeTests.cs +++ b/tests/ScriptSharp/TypeTests.cs @@ -102,26 +102,6 @@ public void TestRecords() { }); } - [TestMethod] - public void TestScriptNamespaces() { - RunTest((c) => { - c.AddSource("LibraryAssemblyInfo.cs"). - AddSource("LibraryFeature.cs"). - AddSource("LibraryMyLib.cs"); - c.Options.DebugFlavor = true; - }, "LibraryBaseline.txt"); - - RunTest((c) => { - c.AddReference("Lib.dll"). - AddSource("AppAssemblyInfo.cs"). - AddSource("AppFeature.cs"). - AddSource("AppMyApp.cs"). - AddSource("AppFoo.1.cs"). - AddSource("AppFoo.2.cs"); - c.Options.DebugFlavor = true; - }, "AppBaseline.txt"); - } - [TestMethod] public void TestUsingAlias() { RunTest((c) => { diff --git a/tests/TestCases/Type/ScriptNamespaces/AppAssemblyInfo.cs b/tests/TestCases/Type/ScriptNamespaces/AppAssemblyInfo.cs deleted file mode 100644 index c058305f9..000000000 --- a/tests/TestCases/Type/ScriptNamespaces/AppAssemblyInfo.cs +++ /dev/null @@ -1,12 +0,0 @@ -// AssemblyInfo.cs -// -// Assembly Metadata -// - -using System; -using System.Reflection; -using System.Runtime.CompilerServices; - -[assembly: AssemblyTitle("My.App")] -[assembly: AssemblyDescription("MyApp")] -[assembly: ScriptAssembly("App")] diff --git a/tests/TestCases/Type/ScriptNamespaces/AppBaseline.txt b/tests/TestCases/Type/ScriptNamespaces/AppBaseline.txt deleted file mode 100644 index ea1760caa..000000000 --- a/tests/TestCases/Type/ScriptNamespaces/AppBaseline.txt +++ /dev/null @@ -1,61 +0,0 @@ -Type.registerNamespace('My.App'); - -//////////////////////////////////////////////////////////////////////////////// -// My.App.AppFeature - -My.App.AppFeature = function My_App_AppFeature(name) { - this._name = name; - this._feature = new Lib.Feature(name); -} -My.App.AppFeature.prototype = { - _name: null, - _feature: null, - - get_name: function My_App_AppFeature$get_name() { - return this._name; - }, - set_name: function My_App_AppFeature$set_name(value) { - this._name = value; - return value; - } -} - - -//////////////////////////////////////////////////////////////////////////////// -// My.App.MyApp - -My.App.MyApp = function My_App_MyApp(name, appFeatureName, libName, libFeatureName) { - this._name = name; - this._appfeature = new My.App.AppFeature(appFeatureName); - this._lib = new Lib.MyLib('lib1', libName); - this._lib.set_feature(new Lib.Feature(libFeatureName)); -} -My.App.MyApp.prototype = { - _name: null, - _appfeature: null, - _lib: null, - - get_name: function My_App_MyApp$get_name() { - return this._name; - }, - - get_lib: function My_App_MyApp$get_lib() { - return this._lib; - }, - set_lib: function My_App_MyApp$set_lib(value) { - this._lib = value; - return value; - } -} - - -//////////////////////////////////////////////////////////////////////////////// -// My.App.Foo - -My.App.Foo = function My_App_Foo() { -} - - -My.App.AppFeature.registerClass('My.App.AppFeature'); -My.App.MyApp.registerClass('My.App.MyApp'); -My.App.Foo.registerClass('My.App.Foo'); diff --git a/tests/TestCases/Type/ScriptNamespaces/AppFeature.cs b/tests/TestCases/Type/ScriptNamespaces/AppFeature.cs deleted file mode 100644 index 56a461332..000000000 --- a/tests/TestCases/Type/ScriptNamespaces/AppFeature.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Runtime.CompilerServices; -using My.Lib; - -namespace My.App { - - public class AppFeature { - string _name; - Feature _feature; - - public string Name { - get { return _name; } - set { _name = value; } - } - - public AppFeature(string name) { - _name = name; - _feature = new Feature(name); - } - } -} - - diff --git a/tests/TestCases/Type/ScriptNamespaces/AppFoo.1.cs b/tests/TestCases/Type/ScriptNamespaces/AppFoo.1.cs deleted file mode 100644 index 7c5186043..000000000 --- a/tests/TestCases/Type/ScriptNamespaces/AppFoo.1.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; -using My.Lib; - -namespace My.App { - - public partial class Foo { - } -} diff --git a/tests/TestCases/Type/ScriptNamespaces/AppFoo.2.cs b/tests/TestCases/Type/ScriptNamespaces/AppFoo.2.cs deleted file mode 100644 index 10e076728..000000000 --- a/tests/TestCases/Type/ScriptNamespaces/AppFoo.2.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Runtime.CompilerServices; -using My.Lib; - -namespace My.App { - - public partial class Foo { - } -} diff --git a/tests/TestCases/Type/ScriptNamespaces/AppMyApp.cs b/tests/TestCases/Type/ScriptNamespaces/AppMyApp.cs deleted file mode 100644 index 19a8b434d..000000000 --- a/tests/TestCases/Type/ScriptNamespaces/AppMyApp.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using My.Lib; - -namespace My.App { - - public sealed class MyApp { - - private string _name; - private AppFeature _appfeature; - private MyLib _lib; - - public string Name { - get { return _name; } - } - - public MyLib Lib { - get { return _lib; } - set { _lib = value; } - } - - public MyApp(string name, string appFeatureName, string libName, string libFeatureName) { - _name = name; - _appfeature = new AppFeature(appFeatureName); - _lib = new MyLib("lib1", libName); - _lib.Feature = new Feature(libFeatureName); - } - } -} diff --git a/tests/TestCases/Type/ScriptNamespaces/Lib.dll b/tests/TestCases/Type/ScriptNamespaces/Lib.dll deleted file mode 100644 index 7f3c1a4e7207c4987b71ac4f3e7a846fdc182bff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3584 zcmeHJPiP!f82`Q5KiMYDQd88bpcB(*8ev>X#0pwB$u_k$+mvpaN)gi8%`}-XyAx(+ zLxWU8QSl-cJb4olFCO$zq?HCr>9q&JgSQqGuU@R;_|LrgICndt--lvH#AoRe<`q=X2Wi^ z{K%|3X3%b#Zp*C9*372A=ve*zz55gB6NiBrmB9~R-Iz^xy8~mePZfYXH8MF44U?Fh zWlkX`7bDJ_oX%fXY;aO9BZKk>z#jeASrajK!7ohYwD4u%dJ>nI;^i!`dxzpb3MRk` zwnu^To7)m#Mb7z%awSJXo38V&{i!}{1!2&jS?5+JBL~$DOp)rc6*!(xN1f|gDh2DV z#OXIl?T%qeUpXW<13BC=xdr!7qWm9YZ%OHG8UF~3ce!MHUqF8JIT)D>B8^TPBdocX z+rCWQ~=^ zUV2rE%fTc4iFpmZ$Fm^NxbU?oa9c~Ec$_DWw0r1O4IAY7Heu+~Pz$M6^)i+d@@Om{tdxQd)k#^~b`yXcrgl5uac=J5(jd_}&-XQVeY z-NJ41kE`4CPW`1)#T*ClB$2eF_Fzy;2AipHh@DTVP5lW|qCYHD&`yp z%}aan{`V?$TQ8SL$ahQ22W+NSZM_QfG0lb)46j!n5_!#V05B+=iWH;!% zWAMf0kh6)0!t*KnTGd}{d(I)uxOHpM^Dyn$Q9E!@UAL&>BD5Jc{J=Fk#AAjmQt6bqnVbJn>4g#WCgAY_IJ=10}9HF5bvG>74Vplk2xI z5r$5)?yb+ck>^ZAe2?qx$k|p`oUjqNtK!-*rYP-JkKR1jS5#ppY{SRip~SDm75Zj*uwtwRKd5+K)plF)5j&242gGY@7-o5=`vWb>-2v>2 zzoK20#5ZW^9(r+-Z^zqZV9^jM9*f2}nR(Q(KzbM_$sNTkj#EBLI!#{2X7;x~)7wic z67oi}%IB^NR%_+%RYbKB5Xa>m?hvzubMUo&KW{oSgXhW+B!4-Z>96Gut=?Z>qgj3 zMJ;b6?I~5PG6(6x5|)Vq{qs1e^O#Na(jmc3^Abra|2zJ;jyu6PpL@1hbHtO{Sw$y* rsYQAvHBYe4ke*HU&tpdBzs522;ke%pnDM`f<(Kal=wbYW*nz(Q(o#=P diff --git a/tests/TestCases/Type/ScriptNamespaces/Library.bat b/tests/TestCases/Type/ScriptNamespaces/Library.bat deleted file mode 100644 index 479316237..000000000 --- a/tests/TestCases/Type/ScriptNamespaces/Library.bat +++ /dev/null @@ -1 +0,0 @@ -csc.exe /t:library /noconfig /nologo /nostdlib /r:..\..\..\..\bin\Debug\mscorlib.dll /out:Lib.dll Library*.cs diff --git a/tests/TestCases/Type/ScriptNamespaces/LibraryAssemblyInfo.cs b/tests/TestCases/Type/ScriptNamespaces/LibraryAssemblyInfo.cs deleted file mode 100644 index 4a55c2e5d..000000000 --- a/tests/TestCases/Type/ScriptNamespaces/LibraryAssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -// AssemblyInfo.cs -// - -using System; -using System.Reflection; -using System.Runtime.CompilerServices; - -[assembly: AssemblyTitle("My.Lib")] -[assembly: AssemblyDescription("MyLib")] -[assembly: ScriptAssembly("Lib")] diff --git a/tests/TestCases/Type/ScriptNamespaces/LibraryBaseline.txt b/tests/TestCases/Type/ScriptNamespaces/LibraryBaseline.txt deleted file mode 100644 index 387df14f1..000000000 --- a/tests/TestCases/Type/ScriptNamespaces/LibraryBaseline.txt +++ /dev/null @@ -1,48 +0,0 @@ -Type.registerNamespace('My.Lib'); - -//////////////////////////////////////////////////////////////////////////////// -// My.Lib.Feature - -My.Lib.Feature = function My_Lib_Feature(name) { - this._name = name; -} -My.Lib.Feature.prototype = { - _name: null, - - get_name: function My_Lib_Feature$get_name() { - return this._name; - }, - set_name: function My_Lib_Feature$set_name(value) { - this._name = value; - return value; - } -} - - -//////////////////////////////////////////////////////////////////////////////// -// My.Lib.MyLib - -My.Lib.MyLib = function My_Lib_MyLib(name, featureName) { - this._name = name; - this._feature = new My.Lib.Feature(featureName); -} -My.Lib.MyLib.prototype = { - _name: null, - _feature: null, - - get_name: function My_Lib_MyLib$get_name() { - return this._name; - }, - - get_feature: function My_Lib_MyLib$get_feature() { - return this._feature; - }, - set_feature: function My_Lib_MyLib$set_feature(value) { - this._feature = value; - return value; - } -} - - -My.Lib.Feature.registerClass('My.Lib.Feature'); -My.Lib.MyLib.registerClass('My.Lib.MyLib'); diff --git a/tests/TestCases/Type/ScriptNamespaces/LibraryFeature.cs b/tests/TestCases/Type/ScriptNamespaces/LibraryFeature.cs deleted file mode 100644 index 47f833796..000000000 --- a/tests/TestCases/Type/ScriptNamespaces/LibraryFeature.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Runtime.CompilerServices; - -namespace My.Lib { - - public class Feature { - string _name; - - public string Name { - get { return _name; } - set { _name = value; } - } - - public Feature(string name) { - _name = name; - } - } -} diff --git a/tests/TestCases/Type/ScriptNamespaces/LibraryMyLib.cs b/tests/TestCases/Type/ScriptNamespaces/LibraryMyLib.cs deleted file mode 100644 index 220bfedaf..000000000 --- a/tests/TestCases/Type/ScriptNamespaces/LibraryMyLib.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; - -namespace My.Lib { - - public sealed class MyLib { - private string _name; - private Feature _feature; - - public MyLib(string name, string featureName) { - _name = name; - _feature = new Feature(featureName); - } - - public string Name { - get { return _name; } - } - - public Feature Feature { - get { return _feature; } - set { _feature = value; } - } - } -} From 4b7d0d51634c4469cee6d03466ffd9c53fa0bc8b Mon Sep 17 00:00:00 2001 From: Nikhil Kothari Date: Tue, 11 Sep 2012 14:19:09 -0700 Subject: [PATCH 008/251] Update ordering of types --- src/Core/Compiler/ScriptModel/Symbols/SymbolType.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Core/Compiler/ScriptModel/Symbols/SymbolType.cs b/src/Core/Compiler/ScriptModel/Symbols/SymbolType.cs index a91aa5744..094dc2614 100644 --- a/src/Core/Compiler/ScriptModel/Symbols/SymbolType.cs +++ b/src/Core/Compiler/ScriptModel/Symbols/SymbolType.cs @@ -11,17 +11,17 @@ internal enum SymbolType { Namespace = 0, - Class = 1, + Delegate = 1, - Interface = 2, + Enumeration = 2, - Enumeration = 3, + Resources = 3, - Delegate = 4, + Interface = 4, Record = 5, - Resources = 6, + Class = 6, Field = 7, From e1503b32964e265865cdc362273483abd7943566 Mon Sep 17 00:00:00 2001 From: Nikhil Kothari Date: Tue, 11 Sep 2012 14:31:14 -0700 Subject: [PATCH 009/251] Improve private member name generation --- .../ScriptModel/Symbols/SymbolObfuscator.cs | 9 +++++++-- src/Core/Compiler/Utility.cs | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Core/Compiler/ScriptModel/Symbols/SymbolObfuscator.cs b/src/Core/Compiler/ScriptModel/Symbols/SymbolObfuscator.cs index f85de90ce..8abaa720e 100644 --- a/src/Core/Compiler/ScriptModel/Symbols/SymbolObfuscator.cs +++ b/src/Core/Compiler/ScriptModel/Symbols/SymbolObfuscator.cs @@ -11,10 +11,15 @@ namespace ScriptSharp.ScriptModel { internal sealed class SymbolObfuscator : ISymbolTransformer { private static string GenerateName(int index, int offset) { + // Shorten the name - the use of "$" ensures it won't conflict with a + // name in the source code. + + string name = Utility.CreateEncodedName(index, /* useDigits */ true); + if (offset == 0) { - return String.Format("${0:X}", index); + return "$" + name; } - return String.Format("${0:X}_{1:X}", offset, index); + return Utility.CreateEncodedName(offset, /* useDigits */ false) + "$" + name; } private string TransformMember(MemberSymbol memberSymbol) { diff --git a/src/Core/Compiler/Utility.cs b/src/Core/Compiler/Utility.cs index 89f04f4c0..43ac5f924 100644 --- a/src/Core/Compiler/Utility.cs +++ b/src/Core/Compiler/Utility.cs @@ -14,6 +14,9 @@ namespace ScriptSharp { internal static class Utility { + private static readonly string Base64Alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_"; + private static readonly string Base54Alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_"; + private static readonly string[] ScriptKeywords = new string[] { // Current keywords @@ -77,6 +80,23 @@ public static string CreateCamelCaseName(string name) { } } + public static string CreateEncodedName(int number, bool useDigits) { + string alphabet = useDigits ? Base64Alphabet : Base54Alphabet; + if (number == 0) { + return alphabet[0].ToString(); + } + + string name = String.Empty; + while (number > 0) { + int remainder = number % alphabet.Length; + number = (int)(number / alphabet.Length); + + name = alphabet[remainder] + name; + } + + return name; + } + public static string GetResourceFileLocale(string fileName) { string extension = Path.GetExtension(fileName); From 517c3b9fbb2a834c8a6ff750f708d9cf793831d4 Mon Sep 17 00:00:00 2001 From: Nikhil Kothari Date: Thu, 13 Sep 2012 14:05:12 -0700 Subject: [PATCH 010/251] New runtime (wip) and optimized/minimal amd loader --- .gitignore | 1 + src/Core/Scripts/Loader.js | 307 +++++ src/Core/Scripts/Runtime.js | 15 +- src/Core/Scripts/Runtime/TypeSystem.js | 97 ++ src/Core/Scripts/Scripts.csproj | 9 +- tests/Runtime/Core/Compilation.cs | 75 ++ tests/Runtime/Core/FileStreamSource.cs | 51 + tests/Runtime/Core/RuntimeTest.cs | 73 ++ tests/Runtime/Properties/AssemblyInfo.cs | 20 + tests/Runtime/Runtime.csproj | 95 ++ tests/Runtime/TypeSystemTests.cs | 20 + tests/ScriptSharpTests.sln | 36 +- tests/TestSite/Code/OOP.cs | 106 ++ tests/TestSite/QUnit.css | 112 ++ tests/TestSite/QUnit.js | 1043 +++++++++++++++++ tests/TestSite/QUnitExt.js | 59 + tests/TestSite/TestOOP.htm | 117 ++ ...tSharp.testsettings => Tests.testsettings} | 0 18 files changed, 2207 insertions(+), 29 deletions(-) create mode 100644 src/Core/Scripts/Loader.js create mode 100644 tests/Runtime/Core/Compilation.cs create mode 100644 tests/Runtime/Core/FileStreamSource.cs create mode 100644 tests/Runtime/Core/RuntimeTest.cs create mode 100644 tests/Runtime/Properties/AssemblyInfo.cs create mode 100644 tests/Runtime/Runtime.csproj create mode 100644 tests/Runtime/TypeSystemTests.cs create mode 100644 tests/TestSite/Code/OOP.cs create mode 100644 tests/TestSite/QUnit.css create mode 100644 tests/TestSite/QUnit.js create mode 100644 tests/TestSite/QUnitExt.js create mode 100644 tests/TestSite/TestOOP.htm rename tests/{ScriptSharp.testsettings => Tests.testsettings} (100%) diff --git a/.gitignore b/.gitignore index 76acd2c3a..4bcbe901a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ obj/ *.cache *.trx packages/ +Tests/*/Scripts TestResults/ diff --git a/src/Core/Scripts/Loader.js b/src/Core/Scripts/Loader.js new file mode 100644 index 000000000..391122d88 --- /dev/null +++ b/src/Core/Scripts/Loader.js @@ -0,0 +1,307 @@ +(function(global) { + "use strict"; + + // Helpers + + function each(items, action) { + var results = []; + for (var i = 0, len = items.length; i < len; i++) { + results.push(action(items[i], i)); + } + return results; + } + + // Script management + // Each script has a name, and an associated url or script text. + // Scripts can be registered in advance using script tags on the page, + // either with a url: + // + // or with text: + // + // The use of text/script ensures the script does not run immediately. + // + // If a script has not been explicitly registered, a url can be created + // using a convention. The current convention is simply: + // /scripts/.js. + // + // Script registration provides additional capabilities: + // Auto-loading: If data-autoload is set to true, then the script is + // automatically loaded on startup. + // Pre-loading: If data-preload="true" is set, then after all startup + // scripts have been loaded, any preloadable scripts are + // loaded (but not executed). + // Pre-loading is only supported on scripts from the same + // domain. + // Local storage: If data-store is set on a script with inline text with + // the version of the script, it is saved to local storage. + // A scripts cookie is updated to indicate the client has + // a copy of the script, allowing the server to generate + // a script tag with data-store set to 'load'. This allows + // inlining the script on the first request which saves + // roundtrips, and not paying the price of inlining on + // subsequent requests. + // + // TODO: Improve convention + provide ability to customize/replace it. + // Provide ability to plug in other types of loaders (like for css + // and templates). + + var _xdomainRegex = /^https?:\/\/.*/; + var _storageCookie = !!window.localStorage ? (document.scriptCookie || 'scripts') : null; + + var _scripts = {}; + var _startupScripts = []; + var _deferredScripts = []; + function _getScript(name) { + var script = _scripts[name]; + if (!script) { + // Create a script object with a url based on convention + script = _scripts[name] = { name: name, src: '/scripts/' + name + '.js' }; + } + return script; + } + function _loadScriptConfiguration() { + var scriptElements = document.getElementsByTagName('script'); + for (var i = 0, count = scriptElements.length; i < count; i++) { + var scriptElement = scriptElements[i]; + if (scriptElement.type == 'text/script') { + var name = scriptElement.getAttribute('data-name'); + var inline = false; + if (!name) { + // If there was no name set, assume this script has inline text, + // generate a name, so it can be managed, and include it as a + // startup script that is auto-loaded. + + name = 's' + (new Date()).valueOf(); + inline = true; + } + + var script = _scripts[name] = { + name: name, + src: scriptElement.getAttribute('data-src') + }; + + if (!script.src) { + // No src was specified, so use script text instead. + var text; + + var storage = _storageCookie ? scriptElement.getAttribute('data-store') : null; + if (storage == 'load') { + // Storage was set to load, so load script text from local storage. + text = _loadLocalScript(name); + } + else { + // Use the inlined script text. + text = scriptElement.text; + if (storage) { + // Storage was specified, so save the text to local storage for use + // on a subsequent page load, and use the value of the storage attribute + // as the version marker to communicate to the server that we + // have a particular script in storage. + + _saveLocalScript(name, text, storage); + } + } + + if (inline) { + // Assumption is if the name wasn't specified on the script tag, then + // it wasn't specified in the define call either. Patch up the script + // text to use the auto-generated module name for the module name + // specified in the call to define (so that the callbacks associated + // with this module get invoked when the script executes). + + text = text.replace('define([', 'define(\'' + script.name + '\', ['); + } + script.text = text; + script.useText = true; + } + + if (inline || scriptElement.hasAttribute('data-autoload')) { + _startupScripts.push(script.name); + } + if (!_xdomainRegex.test(script.src) && scriptElement.hasAttribute('data-preload')) { + _deferredScripts.push(script.name); + } + } + } + } + function _loadLocalScript(name) { + return localStorage['script.' + name]; + } + function _saveLocalScript(name, text, version) { + localStorage['script.' + name] = text; + + // Save the fact that we have stored this script into the local storage + // by updating the index with the new script information, and using + // the index as the value of the cookie sent to the server as well. + var scriptIndex = localStorage['script.$']; + + scriptIndex = scriptIndex ? JSON.parse(scriptIndex) : {}; + scriptIndex[name] = version; + + scriptIndex = JSON.stringify(scriptIndex); + localStorage['script.$'] = scriptIndex; + + // A cookie with 180 days = 60 * 60 * 24 * 180 seconds + document.cookie = _storageCookie + '=' + encodeURIComponent(scriptIndex) + + '; max-age=15552000; path=/'; + } + function _downloadScript(name) { + var script = _scripts[name]; + + var downloader = new XMLHttpRequest(); + downloader.onreadystatechange = function() { + if (downloader.readyState == 4) { + downloader.onreadystatechange = null; + + if (downloader.status == 200) { + script.useText = true; + script.text = downloader.responseText; + } + } + }; + downloader.open('GET', script.src, true); + downloader.send(); + } + + + // Script loading + // Scripts are loaded by creating script elements and inserting + // into the document's head element. + // Scripts can either be loaded from a url (using the src attribute) + // or loaded from previously loaded script text (using the text property). + // + // The assumption is the script uses the AMD pattern, so doesn't need + // to be tracked - the call to define will indicate the script has been + // loaded and executed. + // + // TODO: Provide ability to plug in a shim for scripts that don't follow + // the AMD pattern. + + function _loadScript(scriptName) { + var script = _getScript(scriptName); + + var scriptElement = document.createElement('script'); + scriptElement.type = 'text/javascript'; + if (script.useText) { + scriptElement.text = script.text; + } + else { + scriptElement.src = script.src; + } + document.getElementsByTagName('head')[0].appendChild(scriptElement); + } + + + // Module management + + var _modules = {}; + function _getModule(name) { + return _modules[name] || + (_modules[name] = { name: name, exports: null, callbacks: [], loading: false }); + } + function _loadModule(name, callback) { + var module = _getModule(name); + + if (module.callbacks) { + // Module hasn't loaded yet, since we're still hanging on + // to dependents, so add this callback to the list. + + module.callbacks.push(callback); + + if (!module.loading) { + // Kick off loading the module if this is the first dependent. + module.loading = true; + _loadScript(name); + } + + return 0; + } + + // Module is already loaded, so invoke the callback but use a + // setTimeout to mimic how the callback is invoked asynchronously + // in the usual case when the module hasn't already been loaded. + return setTimeout(callback, 0); + } + function _completeModule(name, exports) { + var module = _modules[name]; + + var callbacks = module.callbacks; + module.callbacks = null; + + module.exports = exports; + module.loading = false; + + each(callbacks, function(callback) { + callback(); + }); + } + + + // Exported APIs + // As per the AMD pattern, we're exporting require and define. + // Our version of define only works with explicitly specified + // module names (which is anyway true if individual modules are + // combined into a single script on the server). + + function require(dependencyNames, callback) { + dependencyNames = dependencyNames || []; + + var dependencyCount = dependencyNames.length; + if (dependencyCount == 0) { + callback.apply(global); + return; + } + + var dependenciesAvailable = 0; + var localCallback = function() { + dependenciesAvailable++; + if (dependenciesAvailable == dependencyCount) { + var dependencies = each(dependencyNames, function(dependencyName) { + return _getModule(dependencyName).exports; + }); + + callback.apply(global, dependencies); + } + }; + + each(dependencyNames, function(dependencyName) { + _loadModule(dependencyName, localCallback); + }); + } + + global.require = require; + global.define = function(name, dependencyNames, callback) { + require(dependencyNames, function() { + _completeModule(name, callback.apply(global, arguments)); + }); + } + + + // Bootstrapping + // If the document has already loaded (i.e. when this script was + // dynamically added to the DOM), go ahead and run startup immediately. + // Otherwise hookup to the DOMContentLoaded event on the document + // which is when the DOM is ready for programmatic access, or if + // this is an older browser, simply do the next best thing - wait for + // the page to be loaded completely. + + function _startup() { + _loadScriptConfiguration(); + require(_startupScripts, function(startupObjects) { + each(_deferredScripts, function(name) { + _downloadScript(name); + }); + }); + } + + if (document.addEventListener) { + document.readyState == 'complete' ? + _startup() : + document.addEventListener('DOMContentLoaded', _startup, false); + } + else if (window.attachEvent) { + window.attachEvent('onload', function() { + _startup(); + }); + } +})(window); diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js index c5c4cc7de..dff9cdc4a 100644 --- a/src/Core/Scripts/Runtime.js +++ b/src/Core/Scripts/Runtime.js @@ -5,6 +5,8 @@ define('ss', [], function() { "use strict"; +var global = this; + // TODO: Inline and remove function isUndefined(o) { return (o === undefined); @@ -43,7 +45,18 @@ return extend(ss, { isNullOrUndefined: isNullOrUndefined, isValue: isValue, - module: module + module: module, + isClass: isClass, + isInterface: isInterface, + getType: getType, + baseType: getBaseType, + interfaces: getInterfaces, + canCast: canCast, + safeCast: safeCast, + canAssign: canAssign, + isOfType: isOfType, + typeName: getTypeName, + type: parseType }); }); diff --git a/src/Core/Scripts/Runtime/TypeSystem.js b/src/Core/Scripts/Runtime/TypeSystem.js index 28f62ae4c..6d50ef796 100644 --- a/src/Core/Scripts/Runtime/TypeSystem.js +++ b/src/Core/Scripts/Runtime/TypeSystem.js @@ -38,12 +38,109 @@ function createType(typeName, typeInfo, typeRegistry) { type.$type = _interfaceMarker; } + type.$name = typeName; return typeRegistry[typeName] = type; } return typeInfo; } +function isClass(fn) { + return fn.$type == _classMarker; +} + +function isInterface(fn) { + return fn.$type == _interfaceMarker; +} + +function getType(instance) { + var ctor = null; + + // NOTE: We have to catch exceptions because the constructor + // cannot be looked up on native COM objects + try { + ctor = instance.constructor; + } + catch (ex) { + } + if (!ctor || !ctor.$type) { + ctor = Object; + } + return ctor; +} + +function getBaseType(type) { + return type.$base || Object; +} + +function getInterfaces(type) { + return type.$interfaces || []; +} + +function canAssign(type, otherType) { + // Checks if the specified type is equal to otherType, + // or is a parent of otherType + + if ((type == Object) || (type == otherType)) { + return true; + } + if (type.$type == _classMarker) { + var baseType = otherType.$base; + while (baseType) { + if (type == baseType) { + return true; + } + baseType = baseType.$base; + } + } + else if (type.$type == _interfaceMarker) { + var baseType = otherType; + while (baseType) { + var interfaces = baseType.$interfaces; + if (interfaces && (interfaces.indexOf(type) >= 0)) { + return true; + } + baseType = baseType.$base; + } + } + return false; +} + +function isOfType(instance, type) { + // Checks if the specified instance is of the specified type + + if (!isValue(instance)) { + return false; + } + + if ((type == Object) || (instance instanceof type)) { + return true; + } + + var instanceType = getType(instance); + return canAssign(type, instanceType); +} + +function canCast(instance, type) { + return isOfType(instance, type); +} + +function safeCast(instance, type) { + return isOfType(instance, type) ? instance : null; +} + +function getTypeName(type) { + return type.$name; +} + +function parseType(s) { + var nsIndex = s.indexOf('.'); + var ns = nsIndex > 0 ? _modules[s.substr(0, nsIndex)] : global; + var name = nsIndex > 0 ? s.substr(nsIndex + 1) : s; + + return ns ? ns[name] : null; +} + function module(name, implementation, exports) { var registry = _modules[name] = {}; diff --git a/src/Core/Scripts/Scripts.csproj b/src/Core/Scripts/Scripts.csproj index 85b3bad1b..9683e3a44 100644 --- a/src/Core/Scripts/Scripts.csproj +++ b/src/Core/Scripts/Scripts.csproj @@ -14,15 +14,22 @@ ..\..\..\bin\Release\ + + + + - + + + + diff --git a/tests/Runtime/Core/Compilation.cs b/tests/Runtime/Core/Compilation.cs new file mode 100644 index 000000000..091728009 --- /dev/null +++ b/tests/Runtime/Core/Compilation.cs @@ -0,0 +1,75 @@ +// Compilation.cs +// Script#/Tests/Runtime +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using ScriptSharp; + +namespace Runtime.Tests.Core { + + public sealed class Compilation : IErrorHandler { + + private List _references; + private List _sources; + private IStreamSource _output; + + private CompilerOptions _options; + + private List _errors; + + public Compilation(string outputPath) { + _references = new List(); + _sources = new List(); + _output = new FileStreamSource(outputPath, writable: true); + + _options = new CompilerOptions(); + _options.DebugFlavor = true; + _options.Minimize = false; + } + + public bool HasErrors { + get { + return _errors.Count != 0; + } + } + + public Compilation AddReference(string path) { + _references.Add(path); + return this; + } + + public Compilation AddSource(string path) { + FileStreamSource sourceInput = new FileStreamSource(path, writable: false); + _sources.Add(sourceInput); + + return this; + } + + public bool Execute() { + _options.References = _references; + _options.Sources = _sources.Cast().ToList(); + _options.ScriptFile = _output; + + ScriptCompiler compiler = new ScriptCompiler(this); + return compiler.Compile(_options); + } + + #region Implementation of IErrorHandler + + void IErrorHandler.ReportError(string errorMessage, string location) { + if (_errors == null) { + _errors = new List(); + } + + string error = errorMessage + " " + location; + _errors.Add(error); + } + + #endregion + } +} diff --git a/tests/Runtime/Core/FileStreamSource.cs b/tests/Runtime/Core/FileStreamSource.cs new file mode 100644 index 000000000..8660afd44 --- /dev/null +++ b/tests/Runtime/Core/FileStreamSource.cs @@ -0,0 +1,51 @@ +// FileStreamSource.cs +// Script#/Tests/Runtime +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.IO; +using ScriptSharp; + +namespace Runtime.Tests.Core { + + public sealed class FileStreamSource : IStreamSource { + + private string _path; + private bool _writable; + + public FileStreamSource(string path, bool writable) { + _path = path; + _writable = writable; + } + + #region Implementation of IStreamSource + + string IStreamSource.FullName { + get { + return _path; + } + } + + string IStreamSource.Name { + get { + return Path.GetFileNameWithoutExtension(_path); + } + } + + void IStreamSource.CloseStream(Stream stream) { + stream.Close(); + } + + Stream IStreamSource.GetStream() { + if (_writable) { + return new FileStream(_path, FileMode.Create, FileAccess.ReadWrite, FileShare.None); + } + else { + return new FileStream(_path, FileMode.Open, FileAccess.Read, FileShare.Read); + } + } + + #endregion + } +} diff --git a/tests/Runtime/Core/RuntimeTest.cs b/tests/Runtime/Core/RuntimeTest.cs new file mode 100644 index 000000000..65224c431 --- /dev/null +++ b/tests/Runtime/Core/RuntimeTest.cs @@ -0,0 +1,73 @@ +// RuntimeTest.cs +// Script#/Tests/Runtime +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using ScriptSharp.Testing; + +namespace Runtime.Tests.Core { + + public abstract class RuntimeTest { + + private static readonly WebTest _webTest; + private static readonly string[] _scripts = new string[] { + "ss.debug.js", "ssloader.debug.js" + }; + private static readonly string[] _codeFiles = new string[] { + "OOP.cs" + }; + + private const int _port = 3976; + + private TestContext _context; + + static RuntimeTest() { + string assemblyPath = typeof(RuntimeTest).Assembly.GetModules()[0].FullyQualifiedName; + string binDirectory = Path.GetFullPath(Path.Combine(assemblyPath, "..\\..\\..\\..\\..\\bin\\Debug\\")); + + string webRoot = Path.GetFullPath(Path.Combine(assemblyPath, "..\\..\\..\\..\\TestSite\\")); + string scriptsDirectory = Path.Combine(webRoot, "Scripts"); + string codeDirectory = Path.Combine(webRoot, "Code"); + + Directory.CreateDirectory(scriptsDirectory); + foreach (string script in _scripts) { + File.Copy(Path.Combine(binDirectory, script), Path.Combine(scriptsDirectory, script), overwrite: true); + } + + string mscorlibPath = Path.Combine(binDirectory, "mscorlib.dll"); + foreach (string codeFile in _codeFiles) { + string script = Path.GetFileNameWithoutExtension(codeFile) + Path.ChangeExtension(".cs", ".js"); + + Compilation compilation = new Compilation(Path.Combine(scriptsDirectory, script)); + compilation.AddReference(mscorlibPath) + .AddSource(Path.Combine(codeDirectory, codeFile)) + .Execute(); + } + + _webTest = new WebTest(); + _webTest.StartWebServer(webRoot, _port); + } + + public TestContext TestContext { + get { + return _context; + } + set { + _context = value; + } + } + + protected void RunTest(string url) { + Uri testUri = _webTest.GetTestUri(url); + + WebTestResult result = _webTest.RunTest(testUri, WebBrowser.Chrome); + Assert.IsTrue(result.Succeeded, "Log:\r\n" + result.Log); + } + } +} diff --git a/tests/Runtime/Properties/AssemblyInfo.cs b/tests/Runtime/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..54745d1c5 --- /dev/null +++ b/tests/Runtime/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +// AssemblyInfo.cs +// Script#/Tests/Runtime +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Runtime.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Script#")] +[assembly: AssemblyCopyright("Copyright © Script# 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/tests/Runtime/Runtime.csproj b/tests/Runtime/Runtime.csproj new file mode 100644 index 000000000..e27f7c54a --- /dev/null +++ b/tests/Runtime/Runtime.csproj @@ -0,0 +1,95 @@ + + + + Debug + AnyCPU + {B3055BB4-FB7A-4DDD-9D8D-BC8A405514AD} + Library + Properties + Runtime.Tests + Runtime.Tests + v4.0 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\bin\Debug\ScriptSharp.dll + + + ..\..\bin\Debug\ScriptSharp.Testing.dll + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + + + + + + False + + + False + + + False + + + False + + + + + + + + \ No newline at end of file diff --git a/tests/Runtime/TypeSystemTests.cs b/tests/Runtime/TypeSystemTests.cs new file mode 100644 index 000000000..4d15cc52c --- /dev/null +++ b/tests/Runtime/TypeSystemTests.cs @@ -0,0 +1,20 @@ +// TypeSystemTests.cs +// Script#/Tests/Runtime +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Runtime.Tests.Core; + +namespace Runtime.Tests { + + [TestClass] + public class TypeSystemTests : RuntimeTest { + + [TestMethod] + public void TestOOP() { + RunTest("/TestOOP.htm"); + } + } +} diff --git a/tests/ScriptSharpTests.sln b/tests/ScriptSharpTests.sln index 8fcdb92c6..607dc4fa5 100644 --- a/tests/ScriptSharpTests.sln +++ b/tests/ScriptSharpTests.sln @@ -1,33 +1,15 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptSharp", "ScriptSharp\ScriptSharp.csproj", "{0E3485F3-D66D-4907-BDB9-D61D34F97538}" EndProject -Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "CoreLib", "CoreLib\", "{956971CD-A3AA-4C69-BF6E-A42A580B08CB}" - ProjectSection(WebsiteProperties) = preProject - TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0" - Debug.AspNetCompiler.VirtualPath = "/CoreLib" - Debug.AspNetCompiler.PhysicalPath = "CoreLib\" - Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\CoreLib\" - Debug.AspNetCompiler.Updateable = "true" - Debug.AspNetCompiler.ForceOverwrite = "true" - Debug.AspNetCompiler.FixedNames = "false" - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.VirtualPath = "/CoreLib" - Release.AspNetCompiler.PhysicalPath = "CoreLib\" - Release.AspNetCompiler.TargetPath = "PrecompiledWeb\CoreLib\" - Release.AspNetCompiler.Updateable = "true" - Release.AspNetCompiler.ForceOverwrite = "true" - Release.AspNetCompiler.FixedNames = "false" - Release.AspNetCompiler.Debug = "False" - VWDPort = "23597" - EndProjectSection -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{37D238E7-539B-497A-98D7-760DAFCF6527}" ProjectSection(SolutionItems) = preProject - ScriptSharp.testsettings = ScriptSharp.testsettings + Tests.testsettings = Tests.testsettings EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime", "Runtime\Runtime.csproj", "{B3055BB4-FB7A-4DDD-9D8D-BC8A405514AD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -38,10 +20,10 @@ Global {0E3485F3-D66D-4907-BDB9-D61D34F97538}.Debug|Any CPU.Build.0 = Debug|Any CPU {0E3485F3-D66D-4907-BDB9-D61D34F97538}.Release|Any CPU.ActiveCfg = Release|Any CPU {0E3485F3-D66D-4907-BDB9-D61D34F97538}.Release|Any CPU.Build.0 = Release|Any CPU - {956971CD-A3AA-4C69-BF6E-A42A580B08CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {956971CD-A3AA-4C69-BF6E-A42A580B08CB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {956971CD-A3AA-4C69-BF6E-A42A580B08CB}.Release|Any CPU.ActiveCfg = Debug|Any CPU - {956971CD-A3AA-4C69-BF6E-A42A580B08CB}.Release|Any CPU.Build.0 = Debug|Any CPU + {B3055BB4-FB7A-4DDD-9D8D-BC8A405514AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B3055BB4-FB7A-4DDD-9D8D-BC8A405514AD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B3055BB4-FB7A-4DDD-9D8D-BC8A405514AD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B3055BB4-FB7A-4DDD-9D8D-BC8A405514AD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/tests/TestSite/Code/OOP.cs b/tests/TestSite/Code/OOP.cs new file mode 100644 index 000000000..f739b2b7c --- /dev/null +++ b/tests/TestSite/Code/OOP.cs @@ -0,0 +1,106 @@ +using System; +using System.Runtime.CompilerServices; +using Test; + +[assembly:ScriptAssembly("oop")] + +namespace Test { + + public interface IMammal { + } + + public interface IPet { + + string Name { + get; + } + + string Owner { + get; + } + } + + public class Animal { + + private string _species; + + public Animal(string species) { + _species = species; + } + + public string Species { + get { + return _species; + } + } + } + + public class Cat : Animal, IMammal { + + public Cat() : base("Cat") { + } + + public virtual string Speak() { + return "meow"; + } + } +} + +namespace Test.More { + + public interface ICharacter { + } + + public class Garfield : Cat, IPet, ICharacter { + + public string Name { + get { + return "Garfield"; + } + } + + public string Owner { + get { + return "Jon"; + } + } + + public override string Speak() { + return base.Speak() + "\r\n" + + "Translation: " + + "I am fat, lazy, and cynical, but still, a favorite cat..."; + } + } + + public class Comic { + + private string _name; + private ICharacter _star; + + public Comic(string name, ICharacter star) { + _name = name; + _star = star; + } + + public string Name { + get { + return _name; + } + } + + public ICharacter Star { + get { + return _star; + } + } + } +} + +namespace Test.Misc { + + public interface IObject { + } + + public class Zoo { + } +} diff --git a/tests/TestSite/QUnit.css b/tests/TestSite/QUnit.css new file mode 100644 index 000000000..a9b4f5903 --- /dev/null +++ b/tests/TestSite/QUnit.css @@ -0,0 +1,112 @@ +ol#qunit-tests { + font-family:Calibri, Helvetica, Arial; + margin:0; + padding:0; + list-style-position:inside; + font-size: smaller; +} +ol#qunit-tests li{ + padding:0.4em 0.5em 0.4em 2.5em; + border-bottom:1px solid #fff; + font-size:small; + list-style-position:inside; +} +ol#qunit-tests li ol{ + box-shadow: inset 0px 2px 13px #999; + -moz-box-shadow: inset 0px 2px 13px #999; + -webkit-box-shadow: inset 0px 2px 13px #999; + margin-top:0.5em; + margin-left:0; + padding:0.5em; + background-color:#fff; +} +ol#qunit-tests li li{ + border-bottom:none; + margin:0.5em; + background-color:#fff; + list-style-position: inside; + padding:0.4em 0.5em 0.4em 0.5em; +} +ol#qunit-tests li li.pass{ + border-left:26px solid #C6E746; + background-color:#fff; + color:#5E740B; +} +ol#qunit-tests li li.fail{ + border-left:26px solid #EE5757; + background-color:#fff; + color:#710909; +} +ol#qunit-tests li.pass{ + background-color:#D2E0E6; + color:#528CE0; +} +ol#qunit-tests li.fail{ + background-color:#EE5757; + color:#000; +} +ol#qunit-tests li strong { + cursor:pointer; +} +h1#qunit-header{ + background-color:#0d3349; + margin:0; + padding:0.5em 0 0.5em 1em; + color:#fff; + font-family:Calibri, Helvetica, Arial; + border-top-right-radius:15px; + border-top-left-radius:15px; + -moz-border-radius-topright:15px; + -moz-border-radius-topleft:15px; + -webkit-border-top-right-radius:15px; + -webkit-border-top-left-radius:15px; + text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 1px; +} +h2#qunit-banner{ + font-family:Calibri, Helvetica, Arial; + height:5px; + margin:0; + padding:0; +} +h2#qunit-banner.qunit-pass{ + background-color:#C6E746; +} +h2#qunit-banner.qunit-fail, #qunit-testrunner-toolbar { + background-color:#EE5757; +} +#qunit-testrunner-toolbar { + font-family:Calibri, Helvetica, Arial; + padding:0; + padding:0em 0 0.5em 2em; + font-size: small; +} +h2#qunit-userAgent { + font-family:Calibri, Helvetica, Arial; + background-color:#2b81af; + margin:0; + padding:0; + color:#fff; + font-size: small; + padding:0.5em 0 0.5em 2.5em; + text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; +} +p#qunit-testresult{ + font-family:Calibri, Helvetica, Arial; + margin:0; + font-size: small; + color:#2b81af; + border-bottom-right-radius:15px; + border-bottom-left-radius:15px; + -moz-border-radius-bottomright:15px; + -moz-border-radius-bottomleft:15px; + -webkit-border-bottom-right-radius:15px; + -webkit-border-bottom-left-radius:15px; + background-color:#D2E0E6; + padding:0.5em 0.5em 0.5em 2.5em; +} +strong b.fail{ + color:#710909; +} +strong b.pass{ + color:#5E740B; +} diff --git a/tests/TestSite/QUnit.js b/tests/TestSite/QUnit.js new file mode 100644 index 000000000..f2704148e --- /dev/null +++ b/tests/TestSite/QUnit.js @@ -0,0 +1,1043 @@ +/* + * QUnit - A JavaScript Unit Testing Framework + * + * http://docs.jquery.com/QUnit + * + * Copyright (c) 2009 John Resig, Jörn Zaefferer + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + */ + +(function(window) { + +var QUnit = { + + // Initialize the configuration options + init: function() { + config = { + stats: { all: 0, bad: 0 }, + moduleStats: { all: 0, bad: 0 }, + started: +new Date, + blocking: false, + autorun: false, + assertions: [], + filters: [], + queue: [] + }; + + var tests = id("qunit-tests"), + banner = id("qunit-banner"), + result = id("qunit-testresult"); + + if ( tests ) { + tests.innerHTML = ""; + } + + if ( banner ) { + banner.className = ""; + } + + if ( result ) { + result.parentNode.removeChild( result ); + } + }, + + // call on start of module test to prepend name to all tests + module: function(name, testEnvironment) { + config.currentModule = name; + + synchronize(function() { + if ( config.currentModule ) { + QUnit.moduleDone( config.currentModule, config.moduleStats.bad, config.moduleStats.all ); + } + + config.currentModule = name; + config.moduleTestEnvironment = testEnvironment; + config.moduleStats = { all: 0, bad: 0 }; + + QUnit.moduleStart( name, testEnvironment ); + }); + }, + + asyncTest: function(testName, expected, callback) { + if ( arguments.length === 2 ) { + callback = expected; + expected = 0; + } + + QUnit.test(testName, expected, callback, true); + }, + + test: function(testName, expected, callback, async) { + var name = testName, testEnvironment, testEnvironmentArg; + + if ( arguments.length === 2 ) { + callback = expected; + expected = null; + } + // is 2nd argument a testEnvironment? + if ( expected && typeof expected === 'object') { + testEnvironmentArg = expected; + expected = null; + } + + if ( config.currentModule ) { + name = config.currentModule + " module: " + name; + } + + if ( !validTest(name) ) { + return; + } + + synchronize(function() { + QUnit.testStart( testName ); + + testEnvironment = extend({ + setup: function() {}, + teardown: function() {} + }, config.moduleTestEnvironment); + if (testEnvironmentArg) { + extend(testEnvironment,testEnvironmentArg); + } + + // allow utility functions to access the current test environment + QUnit.current_testEnvironment = testEnvironment; + + config.assertions = []; + config.expected = expected; + + try { + if ( !config.pollution ) { + saveGlobal(); + } + + testEnvironment.setup.call(testEnvironment); + } catch(e) { + QUnit.ok( false, "Setup failed on " + name + ": " + e.message ); + } + + if ( async ) { + QUnit.stop(); + } + + try { + callback.call(testEnvironment); + } catch(e) { + fail("Test " + name + " died, exception and test follows", e, callback); + QUnit.ok( false, "Died on test #" + (config.assertions.length + 1) + ": " + e.message ); + // else next test will carry the responsibility + saveGlobal(); + + // Restart the tests if they're blocking + if ( config.blocking ) { + start(); + } + } + }); + + synchronize(function() { + try { + checkPollution(); + testEnvironment.teardown.call(testEnvironment); + } catch(e) { + QUnit.ok( false, "Teardown failed on " + name + ": " + e.message ); + } + + try { + QUnit.reset(); + } catch(e) { + fail("reset() failed, following Test " + name + ", exception and reset fn follows", e, reset); + } + + if ( config.expected && config.expected != config.assertions.length ) { + QUnit.ok( false, "Expected " + config.expected + " assertions, but " + config.assertions.length + " were run" ); + } + + var good = 0, bad = 0, + tests = id("qunit-tests"); + + config.stats.all += config.assertions.length; + config.moduleStats.all += config.assertions.length; + + if ( tests ) { + var ol = document.createElement("ol"); + ol.style.display = "none"; + + for ( var i = 0; i < config.assertions.length; i++ ) { + var assertion = config.assertions[i]; + + var li = document.createElement("li"); + li.className = assertion.result ? "pass" : "fail"; + li.appendChild(document.createTextNode(assertion.message || "(no message)")); + ol.appendChild( li ); + + if ( assertion.result ) { + good++; + } else { + bad++; + config.stats.bad++; + config.moduleStats.bad++; + } + } + + var b = document.createElement("strong"); + b.innerHTML = name + " (" + bad + ", " + good + ", " + config.assertions.length + ")"; + + addEvent(b, "click", function() { + var next = b.nextSibling, display = next.style.display; + next.style.display = display === "none" ? "block" : "none"; + }); + + addEvent(b, "dblclick", function(e) { + var target = e && e.target ? e.target : window.event.srcElement; + if ( target.nodeName.toLowerCase() === "strong" ) { + var text = "", node = target.firstChild; + + while ( node.nodeType === 3 ) { + text += node.nodeValue; + node = node.nextSibling; + } + + text = text.replace(/(^\s*|\s*$)/g, ""); + + if ( window.location ) { + window.location.href = window.location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent(text); + } + } + }); + + var li = document.createElement("li"); + li.className = bad ? "fail" : "pass"; + li.appendChild( b ); + li.appendChild( ol ); + tests.appendChild( li ); + + if ( bad ) { + var toolbar = id("qunit-testrunner-toolbar"); + if ( toolbar ) { + toolbar.style.display = "block"; + id("qunit-filter-pass").disabled = null; + id("qunit-filter-missing").disabled = null; + } + } + + } else { + for ( var i = 0; i < config.assertions.length; i++ ) { + if ( !config.assertions[i].result ) { + bad++; + config.stats.bad++; + config.moduleStats.bad++; + } + } + } + + QUnit.testDone( testName, bad, config.assertions.length ); + + if ( !window.setTimeout && !config.queue.length ) { + done(); + } + }); + + if ( window.setTimeout && !config.doneTimer ) { + config.doneTimer = window.setTimeout(function(){ + if ( !config.queue.length ) { + done(); + } else { + synchronize( done ); + } + }, 13); + } + }, + + /** + * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through. + */ + expect: function(asserts) { + config.expected = asserts; + }, + + /** + * Asserts true. + * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" ); + */ + ok: function(a, msg) { + QUnit.log(a, msg); + + config.assertions.push({ + result: !!a, + message: msg + }); + }, + + /** + * Checks that the first two arguments are equal, with an optional message. + * Prints out both actual and expected values. + * + * Prefered to ok( actual == expected, message ) + * + * @example equal( format("Received {0} bytes.", 2), "Received 2 bytes." ); + * + * @param Object actual + * @param Object expected + * @param String message (optional) + */ + equal: function(actual, expected, message) { + push(expected == actual, actual, expected, message); + }, + + notEqual: function(actual, expected, message) { + push(expected != actual, actual, expected, message); + }, + + deepEqual: function(a, b, message) { + push(QUnit.equiv(a, b), a, b, message); + }, + + notDeepEqual: function(a, b, message) { + push(!QUnit.equiv(a, b), a, b, message); + }, + + strictEqual: function(actual, expected, message) { + push(expected === actual, actual, expected, message); + }, + + notStrictEqual: function(actual, expected, message) { + push(expected !== actual, actual, expected, message); + }, + + start: function() { + // A slight delay, to avoid any current callbacks + if ( window.setTimeout ) { + window.setTimeout(function() { + if ( config.timeout ) { + clearTimeout(config.timeout); + } + + config.blocking = false; + process(); + }, 13); + } else { + config.blocking = false; + process(); + } + }, + + stop: function(timeout) { + config.blocking = true; + + if ( timeout && window.setTimeout ) { + config.timeout = window.setTimeout(function() { + QUnit.ok( false, "Test timed out" ); + QUnit.start(); + }, timeout); + } + }, + + /** + * Resets the test setup. Useful for tests that modify the DOM. + */ + reset: function() { + if ( window.jQuery ) { + jQuery("#main").html( config.fixture ); + jQuery.event.global = {}; + jQuery.ajaxSettings = extend({}, config.ajaxSettings); + } + }, + + /** + * Trigger an event on an element. + * + * @example triggerEvent( document.body, "click" ); + * + * @param DOMElement elem + * @param String type + */ + triggerEvent: function( elem, type, event ) { + if ( document.createEvent ) { + event = document.createEvent("MouseEvents"); + event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView, + 0, 0, 0, 0, 0, false, false, false, false, 0, null); + elem.dispatchEvent( event ); + + } else if ( elem.fireEvent ) { + elem.fireEvent("on"+type); + } + }, + + // Safe object type checking + is: function( type, obj ) { + return Object.prototype.toString.call( obj ) === "[object "+ type +"]"; + }, + + // Logging callbacks + done: function(failures, total) {}, + log: function(result, message) {}, + testStart: function(name) {}, + testDone: function(name, failures, total) {}, + moduleStart: function(name, testEnvironment) {}, + moduleDone: function(name, failures, total) {} +}; + +// Backwards compatibility, deprecated +QUnit.equals = QUnit.equal; +QUnit.same = QUnit.deepEqual; + +// Maintain internal state +var config = { + // The queue of tests to run + queue: [], + + // block until document ready + blocking: true +}; + +// Load paramaters +(function() { + var location = window.location || { search: "", protocol: "file:" }, + GETParams = location.search.slice(1).split('&'); + + for ( var i = 0; i < GETParams.length; i++ ) { + GETParams[i] = decodeURIComponent( GETParams[i] ); + if ( GETParams[i] === "noglobals" ) { + GETParams.splice( i, 1 ); + i--; + config.noglobals = true; + } else if ( GETParams[i].search('=') > -1 ) { + GETParams.splice( i, 1 ); + i--; + } + } + + // restrict modules/tests by get parameters + config.filters = GETParams; + + // Figure out if we're running the tests from a server or not + QUnit.isLocal = !!(location.protocol === 'file:'); +})(); + +// Expose the API as global variables, unless an 'exports' +// object exists, in that case we assume we're in CommonJS +if ( typeof exports === "undefined" || typeof require === "undefined" ) { + extend(window, QUnit); + window.QUnit = QUnit; +} else { + extend(exports, QUnit); + exports.QUnit = QUnit; +} + +if ( typeof document === "undefined" || document.readyState === "complete" ) { + config.autorun = true; +} + +addEvent(window, "load", function() { + // Initialize the config, saving the execution queue + var oldconfig = extend({}, config); + QUnit.init(); + extend(config, oldconfig); + + config.blocking = false; + + var userAgent = id("qunit-userAgent"); + if ( userAgent ) { + userAgent.innerHTML = navigator.userAgent; + } + + var toolbar = id("qunit-testrunner-toolbar"); + if ( toolbar ) { + toolbar.style.display = "none"; + + var filter = document.createElement("input"); + filter.type = "checkbox"; + filter.id = "qunit-filter-pass"; + filter.disabled = true; + addEvent( filter, "click", function() { + var li = document.getElementsByTagName("li"); + for ( var i = 0; i < li.length; i++ ) { + if ( li[i].className.indexOf("pass") > -1 ) { + li[i].style.display = filter.checked ? "none" : ""; + } + } + }); + toolbar.appendChild( filter ); + + var label = document.createElement("label"); + label.setAttribute("for", "qunit-filter-pass"); + label.innerHTML = "Hide passed tests"; + toolbar.appendChild( label ); + + var missing = document.createElement("input"); + missing.type = "checkbox"; + missing.id = "qunit-filter-missing"; + missing.disabled = true; + addEvent( missing, "click", function() { + var li = document.getElementsByTagName("li"); + for ( var i = 0; i < li.length; i++ ) { + if ( li[i].className.indexOf("fail") > -1 && li[i].innerHTML.indexOf('missing test - untested code is broken code') > - 1 ) { + li[i].parentNode.parentNode.style.display = missing.checked ? "none" : "block"; + } + } + }); + toolbar.appendChild( missing ); + + label = document.createElement("label"); + label.setAttribute("for", "qunit-filter-missing"); + label.innerHTML = "Hide missing tests (untested code is broken code)"; + toolbar.appendChild( label ); + } + + var main = id('main'); + if ( main ) { + config.fixture = main.innerHTML; + } + + if ( window.jQuery ) { + config.ajaxSettings = window.jQuery.ajaxSettings; + } + + QUnit.start(); +}); + +function done() { + if ( config.doneTimer && window.clearTimeout ) { + window.clearTimeout( config.doneTimer ); + config.doneTimer = null; + } + + if ( config.queue.length ) { + config.doneTimer = window.setTimeout(function(){ + if ( !config.queue.length ) { + done(); + } else { + synchronize( done ); + } + }, 13); + + return; + } + + config.autorun = true; + + // Log the last module results + if ( config.currentModule ) { + QUnit.moduleDone( config.currentModule, config.moduleStats.bad, config.moduleStats.all ); + } + + var banner = id("qunit-banner"), + tests = id("qunit-tests"), + html = ['Tests completed in ', + +new Date - config.started, ' milliseconds.
', + '', config.stats.all - config.stats.bad, ' tests of ', config.stats.all, ' passed, ', config.stats.bad,' failed.'].join(''); + + if ( banner ) { + banner.className = (config.stats.bad ? "qunit-fail" : "qunit-pass"); + } + + if ( tests ) { + var result = id("qunit-testresult"); + + if ( !result ) { + result = document.createElement("p"); + result.id = "qunit-testresult"; + result.className = "result"; + tests.parentNode.insertBefore( result, tests.nextSibling ); + } + + result.innerHTML = html; + } + + QUnit.done( config.stats.bad, config.stats.all ); +} + +function validTest( name ) { + var i = config.filters.length, + run = false; + + if ( !i ) { + return true; + } + + while ( i-- ) { + var filter = config.filters[i], + not = filter.charAt(0) == '!'; + + if ( not ) { + filter = filter.slice(1); + } + + if ( name.indexOf(filter) !== -1 ) { + return !not; + } + + if ( not ) { + run = true; + } + } + + return run; +} + +function push(result, actual, expected, message) { + message = message || (result ? "okay" : "failed"); + QUnit.ok( result, result ? message + ": " + expected : message + ", expected: " + QUnit.jsDump.parse(expected) + " result: " + QUnit.jsDump.parse(actual) ); +} + +function synchronize( callback ) { + config.queue.push( callback ); + + if ( config.autorun && !config.blocking ) { + process(); + } +} + +function process() { + while ( config.queue.length && !config.blocking ) { + config.queue.shift()(); + } +} + +function saveGlobal() { + config.pollution = []; + + if ( config.noglobals ) { + for ( var key in window ) { + config.pollution.push( key ); + } + } +} + +function checkPollution( name ) { + var old = config.pollution; + saveGlobal(); + + var newGlobals = diff( old, config.pollution ); + if ( newGlobals.length > 0 ) { + ok( false, "Introduced global variable(s): " + newGlobals.join(", ") ); + config.expected++; + } + + var deletedGlobals = diff( config.pollution, old ); + if ( deletedGlobals.length > 0 ) { + ok( false, "Deleted global variable(s): " + deletedGlobals.join(", ") ); + config.expected++; + } +} + +// returns a new Array with the elements that are in a but not in b +function diff( a, b ) { + var result = a.slice(); + for ( var i = 0; i < result.length; i++ ) { + for ( var j = 0; j < b.length; j++ ) { + if ( result[i] === b[j] ) { + result.splice(i, 1); + i--; + break; + } + } + } + return result; +} + +function fail(message, exception, callback) { + if ( typeof console !== "undefined" && console.error && console.warn ) { + console.error(message); + console.error(exception); + console.warn(callback.toString()); + + } else if ( window.opera && opera.postError ) { + opera.postError(message, exception, callback.toString); + } +} + +function extend(a, b) { + for ( var prop in b ) { + a[prop] = b[prop]; + } + + return a; +} + +function addEvent(elem, type, fn) { + if ( elem.addEventListener ) { + elem.addEventListener( type, fn, false ); + } else if ( elem.attachEvent ) { + elem.attachEvent( "on" + type, fn ); + } else { + fn(); + } +} + +function id(name) { + return !!(typeof document !== "undefined" && document && document.getElementById) && + document.getElementById( name ); +} + +// Test for equality any JavaScript type. +// Discussions and reference: http://philrathe.com/articles/equiv +// Test suites: http://philrathe.com/tests/equiv +// Author: Philippe Rathé +QUnit.equiv = function () { + + var innerEquiv; // the real equiv function + var callers = []; // stack to decide between skip/abort functions + + + // Determine what is o. + function hoozit(o) { + if (QUnit.is("String", o)) { + return "string"; + + } else if (QUnit.is("Boolean", o)) { + return "boolean"; + + } else if (QUnit.is("Number", o)) { + + if (isNaN(o)) { + return "nan"; + } else { + return "number"; + } + + } else if (typeof o === "undefined") { + return "undefined"; + + // consider: typeof null === object + } else if (o === null) { + return "null"; + + // consider: typeof [] === object + } else if (QUnit.is( "Array", o)) { + return "array"; + + // consider: typeof new Date() === object + } else if (QUnit.is( "Date", o)) { + return "date"; + + // consider: /./ instanceof Object; + // /./ instanceof RegExp; + // typeof /./ === "function"; // => false in IE and Opera, + // true in FF and Safari + } else if (QUnit.is( "RegExp", o)) { + return "regexp"; + + } else if (typeof o === "object") { + return "object"; + + } else if (QUnit.is( "Function", o)) { + return "function"; + } else { + return undefined; + } + } + + // Call the o related callback with the given arguments. + function bindCallbacks(o, callbacks, args) { + var prop = hoozit(o); + if (prop) { + if (hoozit(callbacks[prop]) === "function") { + return callbacks[prop].apply(callbacks, args); + } else { + return callbacks[prop]; // or undefined + } + } + } + + var callbacks = function () { + + // for string, boolean, number and null + function useStrictEquality(b, a) { + if (b instanceof a.constructor || a instanceof b.constructor) { + // to catch short annotaion VS 'new' annotation of a declaration + // e.g. var i = 1; + // var j = new Number(1); + return a == b; + } else { + return a === b; + } + } + + return { + "string": useStrictEquality, + "boolean": useStrictEquality, + "number": useStrictEquality, + "null": useStrictEquality, + "undefined": useStrictEquality, + + "nan": function (b) { + return isNaN(b); + }, + + "date": function (b, a) { + return hoozit(b) === "date" && a.valueOf() === b.valueOf(); + }, + + "regexp": function (b, a) { + return hoozit(b) === "regexp" && + a.source === b.source && // the regex itself + a.global === b.global && // and its modifers (gmi) ... + a.ignoreCase === b.ignoreCase && + a.multiline === b.multiline; + }, + + // - skip when the property is a method of an instance (OOP) + // - abort otherwise, + // initial === would have catch identical references anyway + "function": function () { + var caller = callers[callers.length - 1]; + return caller !== Object && + typeof caller !== "undefined"; + }, + + "array": function (b, a) { + var i; + var len; + + // b could be an object literal here + if ( ! (hoozit(b) === "array")) { + return false; + } + + len = a.length; + if (len !== b.length) { // safe and faster + return false; + } + for (i = 0; i < len; i++) { + if ( ! innerEquiv(a[i], b[i])) { + return false; + } + } + return true; + }, + + "object": function (b, a) { + var i; + var eq = true; // unless we can proove it + var aProperties = [], bProperties = []; // collection of strings + + // comparing constructors is more strict than using instanceof + if ( a.constructor !== b.constructor) { + return false; + } + + // stack constructor before traversing properties + callers.push(a.constructor); + + for (i in a) { // be strict: don't ensures hasOwnProperty and go deep + + aProperties.push(i); // collect a's properties + + if ( ! innerEquiv(a[i], b[i])) { + eq = false; + break; + } + } + + callers.pop(); // unstack, we are done + + for (i in b) { + bProperties.push(i); // collect b's properties + } + + // Ensures identical properties name + return eq && innerEquiv(aProperties.sort(), bProperties.sort()); + } + }; + }(); + + innerEquiv = function () { // can take multiple arguments + var args = Array.prototype.slice.apply(arguments); + if (args.length < 2) { + return true; // end transition + } + + return (function (a, b) { + if (a === b) { + return true; // catch the most you can + } else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || hoozit(a) !== hoozit(b)) { + return false; // don't lose time with error prone cases + } else { + return bindCallbacks(a, callbacks, [b, a]); + } + + // apply transition with (1..n) arguments + })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1)); + }; + + return innerEquiv; + +}(); + +/** + * jsDump + * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com + * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) + * Date: 5/15/2008 + * @projectDescription Advanced and extensible data dumping for Javascript. + * @version 1.0.0 + * @author Ariel Flesler + * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html} + */ +QUnit.jsDump = (function() { + function quote( str ) { + return '"' + str.toString().replace(/"/g, '\\"') + '"'; + }; + function literal( o ) { + return o + ''; + }; + function join( pre, arr, post ) { + var s = jsDump.separator(), + base = jsDump.indent(), + inner = jsDump.indent(1); + if ( arr.join ) + arr = arr.join( ',' + s + inner ); + if ( !arr ) + return pre + post; + return [ pre, inner + arr, base + post ].join(s); + }; + function array( arr ) { + var i = arr.length, ret = Array(i); + this.up(); + while ( i-- ) + ret[i] = this.parse( arr[i] ); + this.down(); + return join( '[', ret, ']' ); + }; + + var reName = /^function (\w+)/; + + var jsDump = { + parse:function( obj, type ) { //type is used mostly internally, you can fix a (custom)type in advance + var parser = this.parsers[ type || this.typeOf(obj) ]; + type = typeof parser; + + return type == 'function' ? parser.call( this, obj ) : + type == 'string' ? parser : + this.parsers.error; + }, + typeOf:function( obj ) { + var type; + if ( obj === null ) { + type = "null"; + } else if (typeof obj === "undefined") { + type = "undefined"; + } else if (QUnit.is("RegExp", obj)) { + type = "regexp"; + } else if (QUnit.is("Date", obj)) { + type = "date"; + } else if (QUnit.is("Function", obj)) { + type = "function"; + } else if (QUnit.is("Array", obj)) { + type = "array"; + } else if (QUnit.is("Window", obj) || QUnit.is("global", obj)) { + type = "window"; + } else if (QUnit.is("HTMLDocument", obj)) { + type = "document"; + } else if (QUnit.is("HTMLCollection", obj) || QUnit.is("NodeList", obj)) { + type = "nodelist"; + } else if (/^\[object HTML/.test(Object.prototype.toString.call( obj ))) { + type = "node"; + } else { + type = typeof obj; + } + return type; + }, + separator:function() { + return this.multiline ? this.HTML ? '
' : '\n' : this.HTML ? ' ' : ' '; + }, + indent:function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing + if ( !this.multiline ) + return ''; + var chr = this.indentChar; + if ( this.HTML ) + chr = chr.replace(/\t/g,' ').replace(/ /g,' '); + return Array( this._depth_ + (extra||0) ).join(chr); + }, + up:function( a ) { + this._depth_ += a || 1; + }, + down:function( a ) { + this._depth_ -= a || 1; + }, + setParser:function( name, parser ) { + this.parsers[name] = parser; + }, + // The next 3 are exposed so you can use them + quote:quote, + literal:literal, + join:join, + // + _depth_: 1, + // This is the list of parsers, to modify them, use jsDump.setParser + parsers:{ + window: '[Window]', + document: '[Document]', + error:'[ERROR]', //when no parser is found, shouldn't happen + unknown: '[Unknown]', + 'null':'null', + undefined:'undefined', + 'function':function( fn ) { + var ret = 'function', + name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE + if ( name ) + ret += ' ' + name; + ret += '('; + + ret = [ ret, this.parse( fn, 'functionArgs' ), '){'].join(''); + return join( ret, this.parse(fn,'functionCode'), '}' ); + }, + array: array, + nodelist: array, + arguments: array, + object:function( map ) { + var ret = [ ]; + this.up(); + for ( var key in map ) + ret.push( this.parse(key,'key') + ': ' + this.parse(map[key]) ); + this.down(); + return join( '{', ret, '}' ); + }, + node:function( node ) { + var open = this.HTML ? '<' : '<', + close = this.HTML ? '>' : '>'; + + var tag = node.nodeName.toLowerCase(), + ret = open + tag; + + for ( var a in this.DOMAttrs ) { + var val = node[this.DOMAttrs[a]]; + if ( val ) + ret += ' ' + a + '=' + this.parse( val, 'attribute' ); + } + return ret + close + open + '/' + tag + close; + }, + functionArgs:function( fn ) {//function calls it internally, it's the arguments part of the function + var l = fn.length; + if ( !l ) return ''; + + var args = Array(l); + while ( l-- ) + args[l] = String.fromCharCode(97+l);//97 is 'a' + return ' ' + args.join(', ') + ' '; + }, + key:quote, //object calls it internally, the key part of an item in a map + functionCode:'[code]', //function calls it internally, it's the content of the function + attribute:quote, //node calls it internally, it's an html attribute value + string:quote, + date:quote, + regexp:literal, //regex + number:literal, + 'boolean':literal + }, + DOMAttrs:{//attributes to dump from nodes, name=>realName + id:'id', + name:'name', + 'class':'className' + }, + HTML:true,//if true, entities are escaped ( <, >, \t, space and \n ) + indentChar:' ',//indentation unit + multiline:true //if true, items in a collection, are separated by a \n, else just a space. + }; + + return jsDump; +})(); + +})(this); diff --git a/tests/TestSite/QUnitExt.js b/tests/TestSite/QUnitExt.js new file mode 100644 index 000000000..2e268d688 --- /dev/null +++ b/tests/TestSite/QUnitExt.js @@ -0,0 +1,59 @@ +(function() { + var currentModule = null; + var logData = ''; + + function appendLog(logText) { + logData = logData + logText + '\r\n'; + + var logHolder = document.getElementById('qunit-log'); + if (logHolder) { + logHolder.value = logData; + } + } + + QUnit.log = function(result, message) { + if (arguments.length === 1) { + message = arguments[0]; + } + appendLog(' ' + message); + } + + QUnit.done = function(failures, total) { + appendLog('\r\nCompleted; ' + 'failures = ' + failures + '; total = ' + total); + + var logUrl = '/log/' + ((failures === 0) ? 'success' : 'failure'); + var xhr = new XMLHttpRequest(); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4) { + window.open('', '_self', ''); + window.close(); + } + }; + xhr.open('POST', logUrl, /* async */ false); + xhr.setRequestHeader('Content-Type', 'text/plain'); + xhr.send(logData); + } + + QUnit.testStart = function(name) { + appendLog(' Test Started: ' + name); + } + + QUnit.testDone = function(name, failures, total) { + appendLog(' Test Done: ' + name + '; failures = ' + failures + '; total = ' + total); + appendLog(''); + } + + QUnit.moduleStart = function(name, testEnv) { + currentModule = name; + appendLog('Module Started: ' + name); + } + + QUnit.moduleDone = function(name, failures, total) { + if (name === currentModule) { + appendLog('Module Done: ' + name + '; failures = ' + failures + '; total = ' + total + '\r\n'); + appendLog(''); + appendLog(''); + } + currentModule = null; + } +})(); diff --git a/tests/TestSite/TestOOP.htm b/tests/TestSite/TestOOP.htm new file mode 100644 index 000000000..d3ab7a389 --- /dev/null +++ b/tests/TestSite/TestOOP.htm @@ -0,0 +1,117 @@ + + + + TypeSystemTests - OOP + + + + + +

Test Results

+

+

+
    +
    + + + + + + + + + diff --git a/tests/ScriptSharp.testsettings b/tests/Tests.testsettings similarity index 100% rename from tests/ScriptSharp.testsettings rename to tests/Tests.testsettings From f66fca38b32e9546d31d57844cb4795d7d511287 Mon Sep 17 00:00:00 2001 From: Nikhil Kothari Date: Thu, 13 Sep 2012 19:25:10 -0700 Subject: [PATCH 011/251] More runtime stuff --- src/Core/Scripts/Runtime.js | 32 ++- src/Core/Scripts/Runtime/Array.js | 138 ++++++++++ src/Core/Scripts/Runtime/Contracts.js | 19 ++ src/Core/Scripts/Runtime/Enumerator.js | 18 ++ src/Core/Scripts/Runtime/EventArgs.js | 8 + src/Core/Scripts/Runtime/Object.js | 35 +++ src/Core/Scripts/Runtime/Observable.js | 122 +++++++++ src/Core/Scripts/Runtime/StringBuilder.js | 31 +++ src/Core/Scripts/Runtime/Task.js | 139 ++++++++++ src/Core/Scripts/Scripts.csproj | 9 +- tests/Runtime/BCLTests.cs | 30 +++ tests/Runtime/Runtime.csproj | 1 + tests/TestSite/QUnitExt.js | 14 +- tests/TestSite/TestObservable.htm | 140 ++++++++++ tests/TestSite/TestStringBuilder.htm | 72 ++++++ tests/TestSite/TestTasks.htm | 297 ++++++++++++++++++++++ 16 files changed, 1097 insertions(+), 8 deletions(-) create mode 100644 src/Core/Scripts/Runtime/Array.js create mode 100644 src/Core/Scripts/Runtime/Contracts.js create mode 100644 src/Core/Scripts/Runtime/Enumerator.js create mode 100644 src/Core/Scripts/Runtime/EventArgs.js create mode 100644 src/Core/Scripts/Runtime/Object.js create mode 100644 src/Core/Scripts/Runtime/Observable.js create mode 100644 src/Core/Scripts/Runtime/StringBuilder.js create mode 100644 src/Core/Scripts/Runtime/Task.js create mode 100644 tests/Runtime/BCLTests.cs create mode 100644 tests/TestSite/TestObservable.htm create mode 100644 tests/TestSite/TestStringBuilder.htm create mode 100644 tests/TestSite/TestTasks.htm diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js index dff9cdc4a..b4a70b164 100644 --- a/src/Core/Scripts/Runtime.js +++ b/src/Core/Scripts/Runtime.js @@ -33,10 +33,40 @@ function extend(o, items) { return o; } +#include "Runtime\Object.js" +#include "Runtime\Array.js" #include "Runtime\Console.js" + +#include "Runtime\EventArgs.js" #include "Runtime\TypeSystem.js" +#include "Runtime\Contracts.js" +#include "Runtime\Enumerator.js" +#include "Runtime\StringBuilder.js" +#include "Runtime\Observable.js" +#include "Runtime\Task.js" + +var ss = module('ss', null, { + IDisposable: [ IDisposable ], + IEnumerable: [ IEnumerable ], + IEnumerator: [ IEnumerator ], + IObserver: [ IObserver ], + IApplication: [ IApplication ], + IContainer: [ IContainer ], + IObjectFactory: [ IObjectFactory ], + IEventManager: [ IEventManager ], + IInitializable: [ IInitializable ], + ArrayEnumerator: [ ArrayEnumerator, ArrayEnumerator$, null, IEnumerator ], + EventArgs: [ EventArgs, { } ], + CancelEventArgs: [ CancelEventArgs, { }, EventArgs ], + StringBuilder: [ StringBuilder, StringBuilder$ ], + Observable: [ Observable, Observable$ ], + ObservableCollection: [ ObservableCollection, ObservableCollection$, null, IEnumerable ], + Task: [ Task, Task$ ], + Deferred: [ Deferred, Deferred$ ] +}); + +EventArgs.Empty = new EventArgs(); -var ss = module('ss'); return extend(ss, { version: '0.7.6.0', diff --git a/src/Core/Scripts/Runtime/Array.js b/src/Core/Scripts/Runtime/Array.js new file mode 100644 index 000000000..b30b6a502 --- /dev/null +++ b/src/Core/Scripts/Runtime/Array.js @@ -0,0 +1,138 @@ +// Array Extensions + +extend(Array.prototype, { + add: function(item) { + this[this.length] = item; + }, + + addRange: function(items) { + this.push.apply(this, items); + }, + + clear: function() { + this.length = 0; + }, + + clone: function() { + if (this.length === 1) { + return [this[0]]; + } + else { + return Array.apply(null, this); + } + }, + + contains: function(item) { + var index = this.indexOf(item); + return (index >= 0); + }, + + dequeue: function() { + return this.shift(); + }, + + enqueue: function(item) { + // We record that this array instance is a queue, so we + // can implement the right behavior in the peek method. + this._queue = true; + this.push(item); + }, + + peek: function() { + if (this.length) { + var index = this._queue ? 0 : this.length - 1; + return this[index]; + } + return null; + }, + + extract: function(index, count) { + if (!count) { + return this.slice(index); + } + return this.slice(index, index + count); + }, + + getEnumerator: function() { + return new ArrayEnumerator(this); + }, + + groupBy: function(callback, instance) { + var length = this.length; + var groups = []; + var keys = {}; + for (var i = 0; i < length; i++) { + if (i in this) { + var key = callback.call(instance, this[i], i); + if (String.isNullOrEmpty(key)) { + continue; + } + var items = keys[key]; + if (!items) { + items = []; + items.key = key; + + keys[key] = items; + groups.add(items); + } + items.add(this[i]); + } + } + return groups; + }, + + index: function(callback, instance) { + var length = this.length; + var items = {}; + for (var i = 0; i < length; i++) { + if (i in this) { + var key = callback.call(instance, this[i], i); + if (String.isNullOrEmpty(key)) { + continue; + } + items[key] = this[i]; + } + } + return items; + }, + + insert: function(index, item) { + this.splice(index, 0, item); + }, + + insertRange: function(index, items) { + if (index === 0) { + this.unshift.apply(this, items); + } + else { + for (var i = 0; i < items.length; i++) { + this.splice(index + i, 0, items[i]); + } + } + }, + + remove: function(item) { + var index = this.indexOf(item); + if (index >= 0) { + this.splice(index, 1); + return true; + } + return false; + }, + + removeAt: function(index) { + this.splice(index, 1); + }, + + removeRange: function(index, count) { + return this.splice(index, count); + } +}); + +Array.parse = function(s) { + return eval('(' + s + ')'); +} + +Array.toArray = function(obj) { + return Array.prototype.slice.call(obj); +} diff --git a/src/Core/Scripts/Runtime/Contracts.js b/src/Core/Scripts/Runtime/Contracts.js new file mode 100644 index 000000000..a8ca5f926 --- /dev/null +++ b/src/Core/Scripts/Runtime/Contracts.js @@ -0,0 +1,19 @@ +// Contracts + +function IDisposable() { } +function IEnumerable() { } +function IEnumerator() { } +function IObserver() { } +function IApplication() { } +function IContainer() { } +function IObjectFactory() { } +function IEventManager() { } +function IInitializable() { } + +IEnumerator.getEnumerator = function(enumerable) { + if (enumerable) { + return enumerable.getEnumerator ? enumerable.getEnumerator() : new ArrayEnumerator(enumerable); + } + return null; +} + diff --git a/src/Core/Scripts/Runtime/Enumerator.js b/src/Core/Scripts/Runtime/Enumerator.js new file mode 100644 index 000000000..2e8fb1d8b --- /dev/null +++ b/src/Core/Scripts/Runtime/Enumerator.js @@ -0,0 +1,18 @@ +// Enumerator + +function ArrayEnumerator(array) { + this._array = array; + this._index = -1; + this.current = null; +} +var ArrayEnumerator$ = { + moveNext: function() { + this._index++; + this.current = this._array[this._index]; + return (this._index < this._array.length); + }, + reset: function() { + this._index = -1; + this.current = null; + } +} diff --git a/src/Core/Scripts/Runtime/EventArgs.js b/src/Core/Scripts/Runtime/EventArgs.js new file mode 100644 index 000000000..3f909a637 --- /dev/null +++ b/src/Core/Scripts/Runtime/EventArgs.js @@ -0,0 +1,8 @@ +// EventArgs + +function EventArgs() { +} + +function CancelEventArgs() { + this.cancel = false; +} diff --git a/src/Core/Scripts/Runtime/Object.js b/src/Core/Scripts/Runtime/Object.js new file mode 100644 index 000000000..c9125bb64 --- /dev/null +++ b/src/Core/Scripts/Runtime/Object.js @@ -0,0 +1,35 @@ +// Object Extensions + +Object.clearKeys = function(d) { + for (var n in d) { + delete d[n]; + } +} + +Object.keyExists = function(d, key) { + return d[key] !== undefined; +} + +if (!Object.keys) { + Object.keys = function(d) { + var keys = []; + for (var n in d) { + keys.push(n); + } + return keys; + } + + Object.getKeyCount = function(d) { + var count = 0; + for (var n in d) { + count++; + } + return count; + } +} +else { + Object.getKeyCount = function(d) { + return Object.keys(d).length; + } +} + diff --git a/src/Core/Scripts/Runtime/Observable.js b/src/Core/Scripts/Runtime/Observable.js new file mode 100644 index 000000000..a5d9025e7 --- /dev/null +++ b/src/Core/Scripts/Runtime/Observable.js @@ -0,0 +1,122 @@ +// Observable + +var _observerStack = []; +var _observerRegistration = { + dispose: function() { + _observerStack.pop(); + } +} +function _captureObservers(observers) { + var registeredObservers = _observerStack; + var observerCount = registeredObservers.length; + + if (observerCount) { + observers = observers || []; + for (var i = 0; i < observerCount; i++) { + var observer = registeredObservers[i]; + if (!observers.contains(observer)) { + observers.push(observer); + } + } + return observers; + } + return null; +} +function _invalidateObservers(observers) { + for (var i = 0, len = observers.length; i < len; i++) { + observers[i].invalidateObserver(); + } +} + +function Observable(v) { + this._v = v; + this._observers = null; +} +var Observable$ = { + + getValue: function() { + this._observers = _captureObservers(this._observers); + return this._v; + }, + setValue: function(v) { + if (this._v !== v) { + this._v = v; + + var observers = this._observers; + if (observers) { + this._observers = null; + _invalidateObservers(observers); + } + } + } +}; +Observable.registerObserver = function(o) { + _observerStack.push(o); + return _observerRegistration; +} + + +function ObservableCollection(items) { + this._items = items || []; + this._observers = null; +} +var ObservableCollection$ = { + + get_item: function (index) { + this._observers = _captureObservers(this._observers); + return this._items[index]; + }, + set_item: function(index, item) { + this._items[index] = item; + this._updated(); + }, + get_length: function() { + this._observers = _captureObservers(this._observers); + return this._items.length; + }, + add: function(item) { + this._items.push(item); + this._updated(); + }, + clear: function() { + this._items.clear(); + this._updated(); + }, + contains: function(item) { + return this._items.contains(item); + }, + getEnumerator: function() { + this._observers = _captureObservers(this._observers); + // TODO: Change this + return this._items.getEnumerator(); + }, + indexOf: function(item) { + return this._items.indexOf(item); + }, + insert: function(index, item) { + this._items.insert(index, item); + this._updated(); + }, + remove: function(item) { + if (this._items.remove(item)) { + this._updated(); + return true; + } + return false; + }, + removeAt: function(index) { + this._items.removeAt(index); + this._updated(); + }, + toArray: function() { + return this._items; + }, + _updated: function() { + var observers = this._observers; + if (observers) { + this._observers = null; + _invalidateObservers(observers); + } + } +} + diff --git a/src/Core/Scripts/Runtime/StringBuilder.js b/src/Core/Scripts/Runtime/StringBuilder.js new file mode 100644 index 000000000..eaf8c799f --- /dev/null +++ b/src/Core/Scripts/Runtime/StringBuilder.js @@ -0,0 +1,31 @@ +// StringBuilder + +function StringBuilder(s) { + this._parts = ss.isNullOrUndefined(s) || s === '' ? [] : [s]; + this.isEmpty = this._parts.length == 0; +} +var StringBuilder$ = { + append: function(s) { + if (!isNullOrUndefined(s) && s !== '') { + this._parts.push(s); + this.isEmpty = false; + } + return this; + }, + + appendLine: function(s) { + this.append(s); + this.append('\r\n'); + this.isEmpty = false; + return this; + }, + + clear: function() { + this._parts = []; + this.isEmpty = true; + }, + + toString: function(s) { + return this._parts.join(s || ''); + } +}; diff --git a/src/Core/Scripts/Runtime/Task.js b/src/Core/Scripts/Runtime/Task.js new file mode 100644 index 000000000..b44b85915 --- /dev/null +++ b/src/Core/Scripts/Runtime/Task.js @@ -0,0 +1,139 @@ +// Task + +function Task(result) { + this._continuations = ss.isValue(result) ? + (this.status = 'done', null) : + (this.status = 'pending', []); + this.result = result; + this.error = null; +} +var Task$ = { + get_completed: function() { + return this.status != 'pending'; + }, + continueWith: function(continuation) { + if (this._continuations) { + this._continuations.push(continuation); + } + else { + var self = this; + setTimeout(function() { continuation(self); }, 0); + } + return this; + }, + done: function(callback) { + return this.continueWith(function(t) { + if (t.status == 'done') { + callback(t.result); + } + }); + }, + fail: function(callback) { + return this.continueWith(function(t) { + if (t.status == 'failed') { + callback(t.error); + } + }); + }, + then: function(doneCallback, failCallback) { + return this.continueWith(function(t) { + t.status == 'done' ? doneCallback(t.result) : failCallback(t.error); + }); + }, + _update: function(result, error) { + if (this.status == 'pending') { + if (error) { + this.error = error; + this.status = 'failed'; + } + else { + this.result = result; + this.status = 'done'; + } + + var continuations = this._continuations; + this._continuations = null; + + for (var i = 0, c = continuations.length; i < c; i++) { + continuations[i](this); + } + } + } +}; + +function _joinTasks(tasks, any) { + tasks = Array.toArray(tasks); + + var count = tasks.length; + + var interval = 0; + if ((count > 1) && (typeof tasks[0] == 'number')) { + interval = tasks[0]; + tasks = tasks.slice(1); + count--; + } + + var joinTask = new Task(); + var seen = 0; + + function continuation(t) { + if (joinTask.status == 'pending') { + seen++; + if (any) { + joinTask._update(t); + } + else if (seen == count) { + joinTask._update(true); + } + } + } + + function timeout() { + if (joinTask.status == 'pending') { + if (any) { + joinTask._update(null); + } + else { + joinTask._update(false); + } + } + } + + if (interval != 0) { + setTimeout(timeout, interval); + } + + for (var i = 0; i < count; i++) { + tasks[i].continueWith(continuation); + } + + return joinTask; +} +Task.all = function() { + return _joinTasks(arguments, false); +} +Task.any = function() { + return _joinTasks(arguments, true); +} +Task.delay = function(timeout) { + var timerTask = new Task(); + + setTimeout(function() { + timerTask._update(true); + }, timeout); + + return timerTask; +} + + +function Deferred(result) { + this.task = new Task(result); +} +var Deferred$ = { + resolve: function(result) { + this.task._update(result); + }, + reject: function(error) { + this.task._update(null, error || new Error()); + } +}; diff --git a/src/Core/Scripts/Scripts.csproj b/src/Core/Scripts/Scripts.csproj index 9683e3a44..e4da5a3ab 100644 --- a/src/Core/Scripts/Scripts.csproj +++ b/src/Core/Scripts/Scripts.csproj @@ -19,14 +19,21 @@ + + + + + + + + - diff --git a/tests/Runtime/BCLTests.cs b/tests/Runtime/BCLTests.cs new file mode 100644 index 000000000..8afb072af --- /dev/null +++ b/tests/Runtime/BCLTests.cs @@ -0,0 +1,30 @@ +// BCLTests.cs +// Script#/Tests/Runtime +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Runtime.Tests.Core; + +namespace Runtime.Tests { + + [TestClass] + public class BCLTests : RuntimeTest { + + [TestMethod] + public void TestObservable() { + RunTest("/TestObservable.htm"); + } + + [TestMethod] + public void TestStringBuilder() { + RunTest("/TestStringBuilder.htm"); + } + + [TestMethod] + public void TestTasks() { + RunTest("/TestTasks.htm"); + } + } +} diff --git a/tests/Runtime/Runtime.csproj b/tests/Runtime/Runtime.csproj index e27f7c54a..994682d3e 100644 --- a/tests/Runtime/Runtime.csproj +++ b/tests/Runtime/Runtime.csproj @@ -59,6 +59,7 @@ + diff --git a/tests/TestSite/QUnitExt.js b/tests/TestSite/QUnitExt.js index 2e268d688..f212bc0d3 100644 --- a/tests/TestSite/QUnitExt.js +++ b/tests/TestSite/QUnitExt.js @@ -23,12 +23,14 @@ var logUrl = '/log/' + ((failures === 0) ? 'success' : 'failure'); var xhr = new XMLHttpRequest(); - xhr.onreadystatechange = function() { - if (xhr.readyState == 4) { - window.open('', '_self', ''); - window.close(); - } - }; + if (failures === 0) { + xhr.onreadystatechange = function() { + if (xhr.readyState == 4) { + window.open('', '_self', ''); + window.close(); + } + }; + } xhr.open('POST', logUrl, /* async */ false); xhr.setRequestHeader('Content-Type', 'text/plain'); xhr.send(logData); diff --git a/tests/TestSite/TestObservable.htm b/tests/TestSite/TestObservable.htm new file mode 100644 index 000000000..3206c4cec --- /dev/null +++ b/tests/TestSite/TestObservable.htm @@ -0,0 +1,140 @@ + + + + BCLTests - Observable + + + + + +

    Test Results

    +

    +

    +
      +
      + + + + + + + diff --git a/tests/TestSite/TestStringBuilder.htm b/tests/TestSite/TestStringBuilder.htm new file mode 100644 index 000000000..ff43cb5c4 --- /dev/null +++ b/tests/TestSite/TestStringBuilder.htm @@ -0,0 +1,72 @@ + + + + BCLTests - StringBuilder + + + + + +

      Test Results

      +

      +

      +
        +
        + + + + + + + diff --git a/tests/TestSite/TestTasks.htm b/tests/TestSite/TestTasks.htm new file mode 100644 index 000000000..d6760b72d --- /dev/null +++ b/tests/TestSite/TestTasks.htm @@ -0,0 +1,297 @@ + + + + BCLTests - Tasks + + + + + +

        Test Results

        +

        +

        +
          +
          + + + + + + + From 2ee6e759483a66a320d21d5bae73e1a10b2962e4 Mon Sep 17 00:00:00 2001 From: Nikhil Kothari Date: Fri, 14 Sep 2012 15:28:57 -0700 Subject: [PATCH 012/251] Add delegate functionality to runtime --- src/Core/Scripts/Runtime.js | 5 +- src/Core/Scripts/Runtime/Delegate.js | 116 ++++++++++++++++++++ src/Core/Scripts/Scripts.csproj | 1 + tests/TestSite/TestDelegates.htm | 151 +++++++++++++++++++++++++++ 4 files changed, 272 insertions(+), 1 deletion(-) create mode 100644 src/Core/Scripts/Runtime/Delegate.js create mode 100644 tests/TestSite/TestDelegates.htm diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js index b4a70b164..f683d2836 100644 --- a/src/Core/Scripts/Runtime.js +++ b/src/Core/Scripts/Runtime.js @@ -37,8 +37,9 @@ function extend(o, items) { #include "Runtime\Array.js" #include "Runtime\Console.js" -#include "Runtime\EventArgs.js" #include "Runtime\TypeSystem.js" +#include "Runtime\Delegate.js" +#include "Runtime\EventArgs.js" #include "Runtime\Contracts.js" #include "Runtime\Enumerator.js" #include "Runtime\StringBuilder.js" @@ -56,6 +57,7 @@ var ss = module('ss', null, { IEventManager: [ IEventManager ], IInitializable: [ IInitializable ], ArrayEnumerator: [ ArrayEnumerator, ArrayEnumerator$, null, IEnumerator ], + Delegate: [ Delegate, { } ], EventArgs: [ EventArgs, { } ], CancelEventArgs: [ CancelEventArgs, { }, EventArgs ], StringBuilder: [ StringBuilder, StringBuilder$ ], @@ -65,6 +67,7 @@ var ss = module('ss', null, { Deferred: [ Deferred, Deferred$ ] }); +Delegate.empty = function() { }; EventArgs.Empty = new EventArgs(); return extend(ss, { diff --git a/src/Core/Scripts/Runtime/Delegate.js b/src/Core/Scripts/Runtime/Delegate.js new file mode 100644 index 000000000..630568288 --- /dev/null +++ b/src/Core/Scripts/Runtime/Delegate.js @@ -0,0 +1,116 @@ +// Delegate + +function _delegateContains(targets, object, method) { + for (var i = 0; i < targets.length; i += 2) { + if (targets[i] === object && targets[i + 1] === method) { + return true; + } + } + return false; +} + +function _createDelegate(targets) { + var delegate = function() { + if (targets.length == 2) { + return targets[1].apply(targets[0], arguments); + } + else { + var clone = targets.clone(); + for (var i = 0; i < clone.length; i += 2) { + if (_delegateContains(targets, clone[i], clone[i + 1])) { + clone[i + 1].apply(clone[i], arguments); + } + } + return null; + } + }; + delegate._targets = targets; + + return delegate; +} + +function Delegate() { +} + +Delegate.create = function(object, method) { + if (!object) { + return method; + } + return _createDelegate([object, method]); +} + +Delegate.combine = function(delegate1, delegate2) { + if (!delegate1) { + if (!delegate2._targets) { + return Delegate.create(null, delegate2); + } + return delegate2; + } + if (!delegate2) { + if (!delegate1._targets) { + return sDelegate.create(null, delegate1); + } + return delegate1; + } + + var targets1 = delegate1._targets ? delegate1._targets : [null, delegate1]; + var targets2 = delegate2._targets ? delegate2._targets : [null, delegate2]; + + return _createDelegate(targets1.concat(targets2)); +} + +Delegate.remove = function(delegate1, delegate2) { + if (!delegate1 || (delegate1 === delegate2)) { + return null; + } + if (!delegate2) { + return delegate1; + } + + var targets = delegate1._targets; + var object = null; + var method; + if (delegate2._targets) { + object = delegate2._targets[0]; + method = delegate2._targets[1]; + } + else { + method = delegate2; + } + + for (var i = 0; i < targets.length; i += 2) { + if ((targets[i] === object) && (targets[i + 1] === method)) { + if (targets.length == 2) { + return null; + } + targets.splice(i, 2); + return _createDelegate(targets); + } + } + + return delegate1; +} + +Delegate.createExport = function(delegate, multiUse, name) { + // Generate a unique name if one is not specified + name = name || '__' + (new Date()).valueOf(); + + // Exported delegates go on global object (so they are callable using a simple identifier). + + // Multi-use delegates are exported directly; for the rest a stub is exported, and the stub + // first deletes, and then invokes the actual delegate. + global[name] = multiUse ? delegate : function() { + try { delete global[name]; } catch(e) { global[name] = undefined; } + delegate.apply(null, arguments); + }; + + return name; +} + +Delegate.deleteExport = function(name) { + delete global[name]; +} + +Delegate.clearExport = function(name) { + global[name] = Delegate.empty; +} diff --git a/src/Core/Scripts/Scripts.csproj b/src/Core/Scripts/Scripts.csproj index e4da5a3ab..99a1bcf27 100644 --- a/src/Core/Scripts/Scripts.csproj +++ b/src/Core/Scripts/Scripts.csproj @@ -20,6 +20,7 @@
          + diff --git a/tests/TestSite/TestDelegates.htm b/tests/TestSite/TestDelegates.htm new file mode 100644 index 000000000..0834a6696 --- /dev/null +++ b/tests/TestSite/TestDelegates.htm @@ -0,0 +1,151 @@ + + + + TypeSystemTests - Delegates + + + + + +

          Test Results

          +

          +

          +
            +
            + + + + + + From e7889bcfc8c1b213200c51e5a55c07fd3746fb1b Mon Sep 17 00:00:00 2001 From: Nikhil Kothari Date: Fri, 14 Sep 2012 16:32:17 -0700 Subject: [PATCH 013/251] Simplify delegate implementation --- src/Core/CoreLib/CoreLib.csproj | 1 + src/Core/CoreLib/Delegate.cs | 17 ++-- src/Core/CoreLib/Export.cs | 30 ++++++ src/Core/CoreLib/Type.cs | 6 -- src/Core/Scripts/Runtime.js | 2 +- src/Core/Scripts/Runtime/Delegate.js | 138 +++++++++++---------------- tests/Runtime/TypeSystemTests.cs | 5 + tests/TestSite/TestDelegates.htm | 39 +++++--- 8 files changed, 127 insertions(+), 111 deletions(-) create mode 100644 src/Core/CoreLib/Export.cs diff --git a/src/Core/CoreLib/CoreLib.csproj b/src/Core/CoreLib/CoreLib.csproj index f8dd6d256..6f7945d13 100644 --- a/src/Core/CoreLib/CoreLib.csproj +++ b/src/Core/CoreLib/CoreLib.csproj @@ -78,6 +78,7 @@ + diff --git a/src/Core/CoreLib/Delegate.cs b/src/Core/CoreLib/Delegate.cs index 97cf21b4f..1b4897dca 100644 --- a/src/Core/CoreLib/Delegate.cs +++ b/src/Core/CoreLib/Delegate.cs @@ -10,6 +10,7 @@ namespace System { [Imported] public abstract class Delegate { + [PreserveCase] public static readonly Delegate Empty = null; protected Delegate(object target, string method) { @@ -18,9 +19,6 @@ protected Delegate(object target, string method) { protected Delegate(Type target, string method) { } - public static void ClearExport(string name) { - } - public static Delegate Combine(Delegate a, Delegate b) { return null; } @@ -29,19 +27,24 @@ public static Delegate Create(object instance, Function f) { return null; } - public static string CreateExport(Delegate d) { + [ScriptName("publish")] + public static Export Export(Delegate d) { return null; } - public static string CreateExport(Delegate d, bool multiUse) { + [ScriptName("publish")] + public static Export Export(Delegate d, bool multiUse) { return null; } - public static string CreateExport(Delegate d, bool multiUse, string name) { + [ScriptName("publish")] + public static Export Export(Delegate d, bool multiUse, string name) { return null; } - public static void DeleteExport(string name) { + [ScriptName("publish")] + public static Export Export(Delegate d, bool multiUse, string name, object root) { + return null; } public static Delegate Remove(Delegate source, Delegate value) { diff --git a/src/Core/CoreLib/Export.cs b/src/Core/CoreLib/Export.cs new file mode 100644 index 000000000..3ac5c6323 --- /dev/null +++ b/src/Core/CoreLib/Export.cs @@ -0,0 +1,30 @@ +// Export.cs +// Script#/Libraries/CoreLib +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System.Runtime.CompilerServices; + +namespace System { + + [Imported] + [IgnoreNamespace] + public sealed class Export : IDisposable { + + private Export() { + } + + [IntrinsicProperty] + public string Name { + get { + return null; + } + } + + public void Clear() { + } + + public void Dispose() { + } + } +} diff --git a/src/Core/CoreLib/Type.cs b/src/Core/CoreLib/Type.cs index 9a7802682..683f2bd77 100644 --- a/src/Core/CoreLib/Type.cs +++ b/src/Core/CoreLib/Type.cs @@ -22,12 +22,6 @@ public Type BaseType { } } - public string FullName { - get { - return null; - } - } - public string Name { get { return null; diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js index f683d2836..d3470a873 100644 --- a/src/Core/Scripts/Runtime.js +++ b/src/Core/Scripts/Runtime.js @@ -67,7 +67,7 @@ var ss = module('ss', null, { Deferred: [ Deferred, Deferred$ ] }); -Delegate.empty = function() { }; +Delegate.Empty = function() { }; EventArgs.Empty = new EventArgs(); return extend(ss, { diff --git a/src/Core/Scripts/Runtime/Delegate.js b/src/Core/Scripts/Runtime/Delegate.js index 630568288..38bf4ed0a 100644 --- a/src/Core/Scripts/Runtime/Delegate.js +++ b/src/Core/Scripts/Runtime/Delegate.js @@ -1,116 +1,90 @@ // Delegate -function _delegateContains(targets, object, method) { - for (var i = 0; i < targets.length; i += 2) { - if (targets[i] === object && targets[i + 1] === method) { - return true; - } - } - return false; -} - -function _createDelegate(targets) { - var delegate = function() { - if (targets.length == 2) { - return targets[1].apply(targets[0], arguments); - } - else { - var clone = targets.clone(); - for (var i = 0; i < clone.length; i += 2) { - if (_delegateContains(targets, clone[i], clone[i + 1])) { - clone[i + 1].apply(clone[i], arguments); - } - } - return null; +function _createDelegate(fnList) { + var d = function() { + var args = arguments; + var result = null; + for (var i = 0, l = fnList.length; i < l; i++) { + result = args.length ? fnList[i].apply(null, args) : fnList[i].call(null); } + return result; }; - delegate._targets = targets; - - return delegate; + d._fnList = fnList; + return d; } function Delegate() { } -Delegate.create = function(object, method) { - if (!object) { - return method; +Delegate.create = function(o, fn) { + if (!o) { + return fn; } - return _createDelegate([object, method]); + + // Create a function that invokes the specified function, in the + // context of the specified object. + return function() { + return fn.apply(o, arguments); + }; } -Delegate.combine = function(delegate1, delegate2) { - if (!delegate1) { - if (!delegate2._targets) { - return Delegate.create(null, delegate2); - } - return delegate2; +Delegate.combine = function(delegate, value) { + if (!delegate) { + return value; } - if (!delegate2) { - if (!delegate1._targets) { - return sDelegate.create(null, delegate1); - } - return delegate1; + if (!value) { + return delegate; } - var targets1 = delegate1._targets ? delegate1._targets : [null, delegate1]; - var targets2 = delegate2._targets ? delegate2._targets : [null, delegate2]; - - return _createDelegate(targets1.concat(targets2)); + var fnList = [].concat(delegate._fnList || delegate, value); + return _createDelegate(fnList); } -Delegate.remove = function(delegate1, delegate2) { - if (!delegate1 || (delegate1 === delegate2)) { +Delegate.remove = function(delegate, value) { + if (!delegate) { return null; } - if (!delegate2) { - return delegate1; + if (!value) { + return delegate; } - var targets = delegate1._targets; - var object = null; - var method; - if (delegate2._targets) { - object = delegate2._targets[0]; - method = delegate2._targets[1]; - } - else { - method = delegate2; - } - - for (var i = 0; i < targets.length; i += 2) { - if ((targets[i] === object) && (targets[i + 1] === method)) { - if (targets.length == 2) { - return null; - } - targets.splice(i, 2); - return _createDelegate(targets); + var fnList = delegate._fnList || [delegate]; + var index = fnList.indexOf(value); + if (index >= 0) { + if (fnList.length == 1) { + return null; } - } - return delegate1; + fnList = index ? fnList.slice(0, index).concat(fnList.slice(index + 1)) : fnList.slice(1); + return _createDelegate(fnList); + } + return delegate; } -Delegate.createExport = function(delegate, multiUse, name) { +Delegate.publish = function(fn, multiUse, name, root) { // Generate a unique name if one is not specified name = name || '__' + (new Date()).valueOf(); - // Exported delegates go on global object (so they are callable using a simple identifier). + // If unspecified, exported delegates go on the global object + // (so they are callable using a simple identifier). + root = root || global; + + var exp = { + name: name, + clear: function() { + root[name] = Delegate.Empty; + }, + dispose: function() { + try { delete root[name]; } catch (e) { root[name] = undefined; } + } + }; // Multi-use delegates are exported directly; for the rest a stub is exported, and the stub // first deletes, and then invokes the actual delegate. - global[name] = multiUse ? delegate : function() { - try { delete global[name]; } catch(e) { global[name] = undefined; } - delegate.apply(null, arguments); + root[name] = multiUse ? fn : function() { + exp.dispose(); + return fn.apply(null, arguments); }; - return name; -} - -Delegate.deleteExport = function(name) { - delete global[name]; -} - -Delegate.clearExport = function(name) { - global[name] = Delegate.empty; + return exp; } diff --git a/tests/Runtime/TypeSystemTests.cs b/tests/Runtime/TypeSystemTests.cs index 4d15cc52c..151b11996 100644 --- a/tests/Runtime/TypeSystemTests.cs +++ b/tests/Runtime/TypeSystemTests.cs @@ -12,6 +12,11 @@ namespace Runtime.Tests { [TestClass] public class TypeSystemTests : RuntimeTest { + [TestMethod] + public void TestDelegates() { + RunTest("/TestDelegates.htm"); + } + [TestMethod] public void TestOOP() { RunTest("/TestOOP.htm"); diff --git a/tests/TestSite/TestDelegates.htm b/tests/TestSite/TestDelegates.htm index 0834a6696..cdf825ff6 100644 --- a/tests/TestSite/TestDelegates.htm +++ b/tests/TestSite/TestDelegates.htm @@ -74,7 +74,7 @@

            test('testEmpty', function() { var tc = new TargetClass(); var delegate = ss.Delegate.create(tc, tc.instanceCallback1); - delegate = ss.Delegate.remove(delegate, ss.Delegate.create(tc, tc.instanceCallback1)); + delegate = ss.Delegate.remove(delegate, delegate); QUnit.equal(delegate, null); }); @@ -125,26 +125,35 @@

            var delegate = ss.Delegate.combine(delegate1, ss.Delegate.combine(delegate2, delegate3)); delegate(delegate); - QUnit.equal(logs.length, 2); + // delegate1 removes delegate2 from the delegate it is passed in. + // This test makes sure that removing a delegate from a delegate chain + // while the delegate is being invoked doesn't affect the delegate chain + // being invoked! + + QUnit.equal(logs.length, 3); }); - test('testExports', function() { + test('testPublish', function() { var logs = setupLog(); var delegate = ss.Delegate.create(null, function() { log('delegate invoked') }); - var name = ss.Delegate.createExport(delegate, /* multiUse */ true, 'xyz'); - QUnit.equal(window[name] !== null, true, 'Expected window member'); - window[name](); - QUnit.equal(window[name] !== null, true, 'Expected window member since it was multiuse'); - - ss.Delegate.deleteExport(name); - QUnit.equal(!window[name], true, 'Did not expect window member since it was deleted'); - - var name = ss.Delegate.createExport(delegate); - QUnit.equal(window[name] !== null, true, 'Expected window member'); - window[name](); - QUnit.equal(!window[name], true, 'Did not expect window member since it was deleted'); + var api = ss.Delegate.publish(delegate, /* multiUse */ true, 'xyz'); + QUnit.equal(api.name, 'xyz', 'Expected published delegate to be named "xyz"'); + QUnit.equal(window[api.name] !== null, true, 'Expected window member'); + window[api.name](); + QUnit.equal(window[api.name] !== null, true, 'Expected window member since it was multiuse'); + + api.clear(); + QUnit.equal(window[api.name] !== null, true, 'Expected window member'); + api.dispose(); + QUnit.equal(!window[api.name], true, 'Did not expect window member since it was deleted'); + + // Test single use delegate + api = ss.Delegate.publish(delegate); + QUnit.equal(window[api.name] !== null, true, 'Expected window member'); + window[api.name](); + QUnit.equal(!window[api.name], true, 'Did not expect window member since it was deleted'); }); }); From 475d0b4a8283e6f75b088c135dda408cb3c2ece6 Mon Sep 17 00:00:00 2001 From: Nikhil Kothari Date: Fri, 14 Sep 2012 16:33:18 -0700 Subject: [PATCH 014/251] Add culture info to runtime script --- src/Core/CoreLib/Globalization/CultureInfo.cs | 6 ++ .../CoreLib/Globalization/DateFormatInfo.cs | 19 +++++ .../CoreLib/Globalization/NumberFormatInfo.cs | 32 +++++++-- src/Core/Scripts/Runtime.js | 8 ++- src/Core/Scripts/Runtime/Culture.js | 72 +++++++++++++++++++ src/Core/Scripts/Scripts.csproj | 1 + 6 files changed, 133 insertions(+), 5 deletions(-) create mode 100644 src/Core/Scripts/Runtime/Culture.js diff --git a/src/Core/CoreLib/Globalization/CultureInfo.cs b/src/Core/CoreLib/Globalization/CultureInfo.cs index 0df2db09f..1e7700fe9 100644 --- a/src/Core/CoreLib/Globalization/CultureInfo.cs +++ b/src/Core/CoreLib/Globalization/CultureInfo.cs @@ -3,11 +3,13 @@ // This source code is subject to terms and conditions of the Apache License, Version 2.0. // +using System; using System.Runtime.CompilerServices; namespace System.Globalization { [Imported] + [ScriptName("culture")] public sealed class CultureInfo { private CultureInfo() { @@ -15,6 +17,7 @@ private CultureInfo() { [PreserveCase] [IntrinsicProperty] + [ScriptName("current")] public static CultureInfo CurrentCulture { get { return null; @@ -22,6 +25,7 @@ public static CultureInfo CurrentCulture { } [IntrinsicProperty] + [ScriptName("dtf")] public DateFormatInfo DateFormat { get { return null; @@ -30,6 +34,7 @@ public DateFormatInfo DateFormat { [PreserveCase] [IntrinsicProperty] + [ScriptName("neutral")] public static CultureInfo InvariantCulture { get { return null; @@ -44,6 +49,7 @@ public string Name { } [IntrinsicProperty] + [ScriptName("nf")] public NumberFormatInfo NumberFormat { get { return null; diff --git a/src/Core/CoreLib/Globalization/DateFormatInfo.cs b/src/Core/CoreLib/Globalization/DateFormatInfo.cs index be191f07d..453e2a8ca 100644 --- a/src/Core/CoreLib/Globalization/DateFormatInfo.cs +++ b/src/Core/CoreLib/Globalization/DateFormatInfo.cs @@ -3,6 +3,7 @@ // This source code is subject to terms and conditions of the Apache License, Version 2.0. // +using System; using System.Runtime.CompilerServices; namespace System.Globalization { @@ -15,6 +16,7 @@ private DateFormatInfo() { } [IntrinsicProperty] + [ScriptName("am")] public string AMDesignator { get { return null; @@ -22,6 +24,7 @@ public string AMDesignator { } [IntrinsicProperty] + [ScriptName("pm")] public string PMDesignator { get { return null; @@ -29,6 +32,7 @@ public string PMDesignator { } [IntrinsicProperty] + [ScriptName("ds")] public string DateSeparator { get { return null; @@ -36,6 +40,7 @@ public string DateSeparator { } [IntrinsicProperty] + [ScriptName("ts")] public string TimeSeparator { get { return null; @@ -43,6 +48,7 @@ public string TimeSeparator { } [IntrinsicProperty] + [ScriptName("gmt")] public string GMTDateTimePattern { get { return null; @@ -50,6 +56,7 @@ public string GMTDateTimePattern { } [IntrinsicProperty] + [ScriptName("uni")] public string UniversalDateTimePattern { get { return null; @@ -57,6 +64,7 @@ public string UniversalDateTimePattern { } [IntrinsicProperty] + [ScriptName("sort")] public string SortableDateTimePattern { get { return null; @@ -64,6 +72,7 @@ public string SortableDateTimePattern { } [IntrinsicProperty] + [ScriptName("dt")] public string DateTimePattern { get { return null; @@ -71,6 +80,7 @@ public string DateTimePattern { } [IntrinsicProperty] + [ScriptName("ld")] public string LongDatePattern { get { return null; @@ -78,6 +88,7 @@ public string LongDatePattern { } [IntrinsicProperty] + [ScriptName("sd")] public string ShortDatePattern { get { return null; @@ -85,6 +96,7 @@ public string ShortDatePattern { } [IntrinsicProperty] + [ScriptName("lt")] public string LongTimePattern { get { return null; @@ -92,6 +104,7 @@ public string LongTimePattern { } [IntrinsicProperty] + [ScriptName("st")] public string ShortTimePattern { get { return null; @@ -99,6 +112,7 @@ public string ShortTimePattern { } [IntrinsicProperty] + [ScriptName("day0")] public int FirstDayOfWeek { get { return 0; @@ -106,6 +120,7 @@ public int FirstDayOfWeek { } [IntrinsicProperty] + [ScriptName("day")] public string[] DayNames { get { return null; @@ -113,6 +128,7 @@ public string[] DayNames { } [IntrinsicProperty] + [ScriptName("sday")] public string[] ShortDayNames { get { return null; @@ -120,6 +136,7 @@ public string[] ShortDayNames { } [IntrinsicProperty] + [ScriptName("mday")] public string[] MinimizedDayNames { get { return null; @@ -127,6 +144,7 @@ public string[] MinimizedDayNames { } [IntrinsicProperty] + [ScriptName("mon")] public string[] MonthNames { get { return null; @@ -134,6 +152,7 @@ public string[] MonthNames { } [IntrinsicProperty] + [ScriptName("smon")] public string[] ShortMonthNames { get { return null; diff --git a/src/Core/CoreLib/Globalization/NumberFormatInfo.cs b/src/Core/CoreLib/Globalization/NumberFormatInfo.cs index d017fc396..081b85ec1 100644 --- a/src/Core/CoreLib/Globalization/NumberFormatInfo.cs +++ b/src/Core/CoreLib/Globalization/NumberFormatInfo.cs @@ -3,6 +3,7 @@ // This source code is subject to terms and conditions of the Apache License, Version 2.0. // +using System; using System.Runtime.CompilerServices; namespace System.Globalization { @@ -15,6 +16,7 @@ private NumberFormatInfo() { } [IntrinsicProperty] + [ScriptName("nan")] public string NaNSymbol { get { return null; @@ -22,6 +24,7 @@ public string NaNSymbol { } [IntrinsicProperty] + [ScriptName("neg")] public string NegativeSign { get { return null; @@ -29,6 +32,7 @@ public string NegativeSign { } [IntrinsicProperty] + [ScriptName("pos")] public string PositiveSign { get { return null; @@ -36,6 +40,7 @@ public string PositiveSign { } [IntrinsicProperty] + [ScriptName("negInf")] public string NegativeInfinityText { get { return null; @@ -43,6 +48,7 @@ public string NegativeInfinityText { } [IntrinsicProperty] + [ScriptName("posInf")] public string PositiveInfinityText { get { return null; @@ -50,6 +56,7 @@ public string PositiveInfinityText { } [IntrinsicProperty] + [ScriptName("per")] public string PercentSymbol { get { return null; @@ -57,6 +64,7 @@ public string PercentSymbol { } [IntrinsicProperty] + [ScriptName("perGW")] public int[] PercentGroupSizes { get { return null; @@ -64,6 +72,7 @@ public int[] PercentGroupSizes { } [IntrinsicProperty] + [ScriptName("perDD")] public int PercentDecimalDigits { get { return 0; @@ -71,6 +80,7 @@ public int PercentDecimalDigits { } [IntrinsicProperty] + [ScriptName("perDS")] public string PercentDecimalSeparator { get { return null; @@ -78,6 +88,7 @@ public string PercentDecimalSeparator { } [IntrinsicProperty] + [ScriptName("perGS")] public string PercentGroupSeparator { get { return null; @@ -85,20 +96,23 @@ public string PercentGroupSeparator { } [IntrinsicProperty] - public string PercentPositivePattern { + [ScriptName("perNP")] + public string PercentNegativePattern { get { return null; } } [IntrinsicProperty] - public string PercentNegativePattern { + [ScriptName("perPP")] + public string PercentPositivePattern { get { return null; } } [IntrinsicProperty] + [ScriptName("cur")] public string CurrencySymbol { get { return null; @@ -106,6 +120,7 @@ public string CurrencySymbol { } [IntrinsicProperty] + [ScriptName("curGW")] public int[] CurrencyGroupSizes { get { return null; @@ -113,6 +128,7 @@ public int[] CurrencyGroupSizes { } [IntrinsicProperty] + [ScriptName("curDD")] public int CurrencyDecimalDigits { get { return 0; @@ -120,6 +136,7 @@ public int CurrencyDecimalDigits { } [IntrinsicProperty] + [ScriptName("curDS")] public string CurrencyDecimalSeparator { get { return null; @@ -127,6 +144,7 @@ public string CurrencyDecimalSeparator { } [IntrinsicProperty] + [ScriptName("curGS")] public string CurrencyGroupSeparator { get { return null; @@ -134,20 +152,23 @@ public string CurrencyGroupSeparator { } [IntrinsicProperty] - public string CurrencyPositivePattern { + [ScriptName("curNP")] + public string CurrencyNegativePattern { get { return null; } } [IntrinsicProperty] - public string CurrencyNegativePattern { + [ScriptName("curPP")] + public string CurrencyPositivePattern { get { return null; } } [IntrinsicProperty] + [ScriptName("gw")] public int[] NumberGroupSizes { get { return null; @@ -155,6 +176,7 @@ public int[] NumberGroupSizes { } [IntrinsicProperty] + [ScriptName("dd")] public int NumberDecimalDigits { get { return 0; @@ -162,6 +184,7 @@ public int NumberDecimalDigits { } [IntrinsicProperty] + [ScriptName("ds")] public string NumberDecimalSeparator { get { return null; @@ -169,6 +192,7 @@ public string NumberDecimalSeparator { } [IntrinsicProperty] + [ScriptName("gs")] public string NumberGroupSeparator { get { return null; diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js index d3470a873..9192d44f0 100644 --- a/src/Core/Scripts/Runtime.js +++ b/src/Core/Scripts/Runtime.js @@ -45,6 +45,7 @@ function extend(o, items) { #include "Runtime\StringBuilder.js" #include "Runtime\Observable.js" #include "Runtime\Task.js" +#include "Runtime\Culture.js" var ss = module('ss', null, { IDisposable: [ IDisposable ], @@ -89,7 +90,12 @@ return extend(ss, { canAssign: canAssign, isOfType: isOfType, typeName: getTypeName, - type: parseType + type: parseType, + + culture: { + neutral: neutralCulture, + current: currentCulture + } }); }); diff --git a/src/Core/Scripts/Runtime/Culture.js b/src/Core/Scripts/Runtime/Culture.js new file mode 100644 index 000000000..87e61be5a --- /dev/null +++ b/src/Core/Scripts/Runtime/Culture.js @@ -0,0 +1,72 @@ +// Culture + +var neutralCulture = { + name: '', + // numberFormat + nf: { + nan: 'NaN', // naNSymbol + neg: '-', // negativeSign + pos: '+', // positiveSign + negInf: '-Infinity', // negativeInfinityText + posInf: 'Infinity', // positiveInfinityText + gw: [3], // numberGroupSizes + dd: 2, // numberDecimalDigits + ds: '.', // numberDecimalSeparator + gs: ',', // numberGroupSeparator + + per: '%', // percentSymbol + perGW: [3], // percentGroupSizes + perDD: 2, // percentDecimalDigits + perDS: '.', // percentDecimalSeparator + perGS: ',', // percentGroupSeparator + perPP: '{0} %', // percentPositivePattern + perNP: '-{0} %', // percentNegativePattern + + cur: '$', // currencySymbol + curGW: [3], // currencyGroupSizes + curDD: 2, // currencyDecimalDigits + curDS: '.', // currencyDecimalSeparator + curGS: ',', // currencyGroupSeparator + curNP: '(${0})', // currencyNegativePattern + curPP: '${0}' // currencyPositivePattern + }, + // dateFormat + dtf: { + am: 'AM', // amDesignator + pm: 'PM', // pmDesignator + + ds: '/', // dateSeparator + ts: ':', // timeSeparator + + gmt: 'ddd, dd MMM yyyy HH:mm:ss \'GMT\'', // gmtDateTimePattern + uni: 'yyyy-MM-dd HH:mm:ssZ', // universalDateTimePattern + sort: 'yyyy-MM-ddTHH:mm:ss', // sortableDateTimePattern + dt: 'dddd, MMMM dd, yyyy h:mm:ss tt', // dateTimePattern + + ld: 'dddd, MMMM dd, yyyy', // longDatePattern + sd: 'M/d/yyyy', // shortDatePattern + + lt: 'h:mm:ss tt', // longTimePattern + st: 'h:mm tt', // shortTimePattern + + day0: 0, // firstDayOfWeek + day: ['Sunday', 'Monday', 'Tuesday', + 'Wednesday', 'Thursday', + 'Friday', 'Saturday'], // dayNames + sday: ['Sun', 'Mon', 'Tue', 'Wed', + 'Thu', 'Fri', 'Sat'], // shortDayNames + mday: ['Su', 'Mo', 'Tu', 'We', + 'Th', 'Fr', 'Sa'], // minimizedDayNames + + mon: ['January', 'February', 'March', + 'April', 'May', 'June', 'July', + 'August', 'September', 'October', + 'November', 'December', ''], // monthNames + smon: ['Jan', 'Feb', 'Mar', 'Apr', + 'May', 'Jun', 'Jul', 'Aug', + 'Sep', 'Oct', 'Nov', 'Dec', ''] // shortMonthNames + } +}; + +var currentCulture = { name: 'en-us', dtf: neutralCulture.dtf, nf: neutralCulture.nf }; + diff --git a/src/Core/Scripts/Scripts.csproj b/src/Core/Scripts/Scripts.csproj index 99a1bcf27..6970a5129 100644 --- a/src/Core/Scripts/Scripts.csproj +++ b/src/Core/Scripts/Scripts.csproj @@ -20,6 +20,7 @@
            + From 237cb14d96419841ed3430f17a5e89765bec7e7c Mon Sep 17 00:00:00 2001 From: Nikhil Kothari Date: Fri, 14 Sep 2012 16:57:00 -0700 Subject: [PATCH 015/251] More runtime script functionality --- src/Core/Scripts/Runtime.js | 6 + src/Core/Scripts/Runtime/Array.js | 4 - src/Core/Scripts/Runtime/Error.js | 48 +++++ src/Core/Scripts/Runtime/Format.js | 315 +++++++++++++++++++++++++++++ src/Core/Scripts/Runtime/Parse.js | 34 ++++ src/Core/Scripts/Runtime/String.js | 118 +++++++++++ src/Core/Scripts/Runtime/Tuple.js | 10 + src/Core/Scripts/Scripts.csproj | 5 + 8 files changed, 536 insertions(+), 4 deletions(-) create mode 100644 src/Core/Scripts/Runtime/Error.js create mode 100644 src/Core/Scripts/Runtime/Format.js create mode 100644 src/Core/Scripts/Runtime/Parse.js create mode 100644 src/Core/Scripts/Runtime/String.js create mode 100644 src/Core/Scripts/Runtime/Tuple.js diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js index 9192d44f0..23d13aa5a 100644 --- a/src/Core/Scripts/Runtime.js +++ b/src/Core/Scripts/Runtime.js @@ -35,7 +35,9 @@ function extend(o, items) { #include "Runtime\Object.js" #include "Runtime\Array.js" +#include "Runtime\String.js" #include "Runtime\Console.js" +#include "Runtime\Error.js" #include "Runtime\TypeSystem.js" #include "Runtime\Delegate.js" @@ -44,8 +46,11 @@ function extend(o, items) { #include "Runtime\Enumerator.js" #include "Runtime\StringBuilder.js" #include "Runtime\Observable.js" +#include "Runtime\Tuple.js" #include "Runtime\Task.js" #include "Runtime\Culture.js" +#include "Runtime\Parse.js" +#include "Runtime\Format.js" var ss = module('ss', null, { IDisposable: [ IDisposable ], @@ -64,6 +69,7 @@ var ss = module('ss', null, { StringBuilder: [ StringBuilder, StringBuilder$ ], Observable: [ Observable, Observable$ ], ObservableCollection: [ ObservableCollection, ObservableCollection$, null, IEnumerable ], + Tuple: [ Tuple, { } ], Task: [ Task, Task$ ], Deferred: [ Deferred, Deferred$ ] }); diff --git a/src/Core/Scripts/Runtime/Array.js b/src/Core/Scripts/Runtime/Array.js index b30b6a502..478418f62 100644 --- a/src/Core/Scripts/Runtime/Array.js +++ b/src/Core/Scripts/Runtime/Array.js @@ -129,10 +129,6 @@ extend(Array.prototype, { } }); -Array.parse = function(s) { - return eval('(' + s + ')'); -} - Array.toArray = function(obj) { return Array.prototype.slice.call(obj); } diff --git a/src/Core/Scripts/Runtime/Error.js b/src/Core/Scripts/Runtime/Error.js new file mode 100644 index 000000000..f88bb8e2d --- /dev/null +++ b/src/Core/Scripts/Runtime/Error.js @@ -0,0 +1,48 @@ +// Error Extensions + +Error.prototype.popStackFrame = function Error$popStackFrame() { + if (isNullOrUndefined(this.stack) || + isNullOrUndefined(this.fileName) || + isNullOrUndefined(this.lineNumber)) { + return; + } + + var stackFrames = this.stack.split('\n'); + var currentFrame = stackFrames[0]; + var pattern = this.fileName + ':' + this.lineNumber; + while (!isNullOrUndefined(currentFrame) && + currentFrame.indexOf(pattern) === -1) { + stackFrames.shift(); + currentFrame = stackFrames[0]; + } + + var nextFrame = stackFrames[1]; + if (isNullOrUndefined(nextFrame)) { + return; + } + + var nextFrameParts = nextFrame.match(/@(.*):(\d+)$/); + if (isNullOrUndefined(nextFrameParts)) { + return; + } + + stackFrames.shift(); + this.stack = stackFrames.join('\n'); + this.fileName = nextFrameParts[1]; + this.lineNumber = parseInt(nextFrameParts[2], 10); +} + +Error.createError = function(message, errorInfo, innerException) { + var e = new Error(message); + if (errorInfo) { + for (var v in errorInfo) { + e[v] = errorInfo[v]; + } + } + if (innerException) { + e.innerException = innerException; + } + + e.popStackFrame(); + return e; +} diff --git a/src/Core/Scripts/Runtime/Format.js b/src/Core/Scripts/Runtime/Format.js new file mode 100644 index 000000000..932ed9f41 --- /dev/null +++ b/src/Core/Scripts/Runtime/Format.js @@ -0,0 +1,315 @@ +// Formatting Helpers + +function _commaFormatNumber(number, groups, decimal, comma) { + var decimalPart = null; + var decimalIndex = number.indexOf(decimal); + if (decimalIndex > 0) { + decimalPart = number.substr(decimalIndex); + number = number.substr(0, decimalIndex); + } + + var negative = number.startsWith('-'); + if (negative) { + number = number.substr(1); + } + + var groupIndex = 0; + var groupSize = groups[groupIndex]; + if (number.length < groupSize) { + return decimalPart ? number + decimalPart : number; + } + + var index = number.length; + var s = ''; + var done = false; + while (!done) { + var length = groupSize; + var startIndex = index - length; + if (startIndex < 0) { + groupSize += startIndex; + length += startIndex; + startIndex = 0; + done = true; + } + if (!length) { + break; + } + + var part = number.substr(startIndex, length); + if (s.length) { + s = part + comma + s; + } + else { + s = part; + } + index -= length; + + if (groupIndex < groups.length - 1) { + groupIndex++; + groupSize = groups[groupIndex]; + } + } + + if (negative) { + s = '-' + s; + } + return decimalPart ? s + decimalPart : s; +} + +_formatters['Number'] = function(number, format, culture) { + var nf = culture.nf; + var s = ''; + var precision = -1; + + if (format.length > 1) { + precision = parseInt(format.substr(1)); + } + + var fs = format.charAt(0); + switch (fs) { + case 'd': case 'D': + s = parseInt(Math.abs(number)).toString(); + if (precision != -1) { + s = s.padLeft(precision, '0'); + } + if (number < 0) { + s = '-' + s; + } + break; + case 'x': case 'X': + s = parseInt(Math.abs(number)).toString(16); + if (fs == 'X') { + s = s.toUpperCase(); + } + if (precision != -1) { + s = s.padLeft(precision, '0'); + } + break; + case 'e': case 'E': + if (precision == -1) { + s = number.toExponential(); + } + else { + s = number.toExponential(precision); + } + if (fs == 'E') { + s = s.toUpperCase(); + } + break; + case 'f': case 'F': + case 'n': case 'N': + if (precision == -1) { + precision = nf.dd; + } + s = number.toFixed(precision).toString(); + if (precision && (nf.ds != '.')) { + var index = s.indexOf('.'); + s = s.substr(0, index) + nf.ds + s.substr(index + 1); + } + if ((fs == 'n') || (fs == 'N')) { + s = _commaFormatNumber(s, nf.gw, nf.ds, nf.gs); + } + break; + case 'c': case 'C': + if (precision == -1) { + precision = nf.curDD; + } + s = Math.abs(number).toFixed(precision).toString(); + if (precision && (nf.curDS != '.')) { + var index = s.indexOf('.'); + s = s.substr(0, index) + nf.curDS + s.substr(index + 1); + } + s = _commaFormatNumber(s, nf.curGW, nf.curDS, nf.curGS); + if (number < 0) { + s = String.format(culture, nf.curNP, s); + } + else { + s = String.format(culture, nf.curPP, s); + } + break; + case 'p': case 'P': + if (precision == -1) { + precision = nf.perDD; + } + s = (Math.abs(number) * 100.0).toFixed(precision).toString(); + if (precision && (nf.perDS != '.')) { + var index = s.indexOf('.'); + s = s.substr(0, index) + nf.perDS + s.substr(index + 1); + } + s = _commaFormatNumber(s, nf.perGW, nf.perDS, nf.perGS); + if (number < 0) { + s = String.format(culture, nf.perNP, s); + } + else { + s = String.format(culture, nf.perPP, s); + } + break; + } + + return s; +} + + +var _dateFormatRE = /'.*?[^\\]'|dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|y|hh|h|HH|H|mm|m|ss|s|tt|t|fff|ff|f|zzz|zz|z/g; + +_formatters['Date'] = function(dt, format, culture) { + if (format == 'iso') { + return dt.toISOString(); + } + else if (format.charAt(0) == 'i') { + var fnName = 'String'; + switch (format) { + case 'id': fnName = 'DateString'; break; + case 'it': fnName = 'TimeString'; break; + } + return culture == neutralCulture ? dt['to' + fnName]() : dt['toLocale' + fnName](); + } + + var dtf = culture.dtf; + + if (format.length == 1) { + switch (format) { + case 'f': format = dtf.ld + ' ' + dtf.st; break; + case 'F': format = dtf.dt; break; + + case 'd': format = dtf.sd; break; + case 'D': format = dtf.ld; break; + + case 't': format = dtf.st; break; + case 'T': format = dtf.lt; break; + + case 'g': format = dtf.sd + ' ' + dtf.st; break; + case 'G': format = dtf.sd + ' ' + dtf.lt; break; + + case 'R': case 'r': + dtf = ss.neutralCulture.dtf; + format = dtf.gmt; + break; + case 'u': format = dtf.uni; break; + case 'U': + format = dtf.dt; + dt = new Date(dt.getUTCFullYear(), dt.getUTCMonth(), dt.getUTCDate(), + dt.getUTCHours(), dt.getUTCMinutes(), dt.getUTCSeconds(), dt.getUTCMilliseconds()); + break; + + case 's': format = dtf.sort; break; + } + } + + if (format.charAt(0) == '%') { + format = format.substr(1); + } + + var sb = new ss.StringBuilder(); + + _dateFormatRE.lastIndex = 0; + while (true) { + var index = _dateFormatRE.lastIndex; + var match = _dateFormatRE.exec(format); + + sb.append(format.slice(index, match ? match.index : format.length)); + if (!match) { + break; + } + + var fs = match[0]; + var part = fs; + switch (fs) { + case 'dddd': + part = dtf.day[dt.getDay()]; + break; + case 'ddd': + part = dtf.sday[dt.getDay()]; + break; + case 'dd': + part = dt.getDate().toString().padLeft(2, '0'); + break; + case 'd': + part = dt.getDate(); + break; + case 'MMMM': + part = dtf.mon[dt.getMonth()]; + break; + case 'MMM': + part = dtf.smon[dt.getMonth()]; + break; + case 'MM': + part = (dt.getMonth() + 1).toString().padLeft(2, '0'); + break; + case 'M': + part = (dt.getMonth() + 1); + break; + case 'yyyy': + part = dt.getFullYear(); + break; + case 'yy': + part = (dt.getFullYear() % 100).toString().padLeft(2, '0'); + break; + case 'y': + part = (dt.getFullYear() % 100); + break; + case 'h': case 'hh': + part = dt.getHours() % 12; + if (!part) { + part = '12'; + } + else if (fs == 'hh') { + part = part.toString().padLeft(2, '0'); + } + break; + case 'HH': + part = dt.getHours().toString().padLeft(2, '0'); + break; + case 'H': + part = dt.getHours(); + break; + case 'mm': + part = dt.getMinutes().toString().padLeft(2, '0'); + break; + case 'm': + part = dt.getMinutes(); + break; + case 'ss': + part = dt.getSeconds().toString().padLeft(2, '0'); + break; + case 's': + part = dt.getSeconds(); + break; + case 't': case 'tt': + part = (dt.getHours() < 12) ? dtf.am : dtf.pm; + if (fs == 't') { + part = part.charAt(0); + } + break; + case 'fff': + part = dt.getMilliseconds().toString().padLeft(3, '0'); + break; + case 'ff': + part = dt.getMilliseconds().toString().padLeft(3).substr(0, 2); + break; + case 'f': + part = dt.getMilliseconds().toString().padLeft(3).charAt(0); + break; + case 'z': + part = dt.getTimezoneOffset() / 60; + part = ((part >= 0) ? '-' : '+') + Math.floor(Math.abs(part)); + break; + case 'zz': case 'zzz': + part = dt.getTimezoneOffset() / 60; + part = ((part >= 0) ? '-' : '+') + Math.floor(Math.abs(part)).toString().padLeft(2, '0'); + if (fs == 'zzz') { + part += dtf.ts + Math.abs(dt.getTimezoneOffset() % 60).toString().padLeft(2, '0'); + } + break; + default: + if (part.charAt(0) == '\'') { + part = part.substr(1, part.length - 2).replace(/\\'/g, '\''); + } + break; + } + sb.append(part); + } + + return sb.toString(); +} + diff --git a/src/Core/Scripts/Runtime/Parse.js b/src/Core/Scripts/Runtime/Parse.js new file mode 100644 index 000000000..48bf9bd04 --- /dev/null +++ b/src/Core/Scripts/Runtime/Parse.js @@ -0,0 +1,34 @@ +// Parsing Helpers + +Number.parse = function(s) { + if (!s || !s.length) { + return 0; + } + if ((s.indexOf('.') >= 0) || (s.indexOf('e') >= 0) || + s.endsWith('f') || s.endsWith('F')) { + return parseFloat(s); + } + return parseInt(s, 10); +} + +Boolean.parse = function(s) { + return (s.toLowerCase() == 'true'); +} + +RegExp.parse = function(s) { + if (s[0] == '/') { + var endSlashIndex = s.lastIndexOf('/'); + if (endSlashIndex > 1) { + var expression = s.substring(1, endSlashIndex); + var flags = s.substr(endSlashIndex + 1); + return new RegExp(expression, flags); + } + } + + return null; +} + +Array.parse = function(s) { + return eval('(' + s + ')'); +} + diff --git a/src/Core/Scripts/Runtime/String.js b/src/Core/Scripts/Runtime/String.js new file mode 100644 index 000000000..81d511768 --- /dev/null +++ b/src/Core/Scripts/Runtime/String.js @@ -0,0 +1,118 @@ +// String Extensions + +var _formatPlaceHolderRE = /(\{[^\}^\{]+\})/g; +var _formatters = { +}; + +function stringFromChar(ch, count) { + return count ? new Array(count + 1).join(ch) : ch; +} + +extend(String, { + fromChar: stringFromChar, + concat: function() { + return Array.prototype.join.call(arguments, ''); + }, + compare: function(s1, s2, ignoreCase) { + s1 = s1 || ''; + s2 = s2 || ''; + + if (ignoreCase) { + s1 = s1.toUpperCase(); + s2 = s2.toUpperCase(); + } + + return (s1 == s2) ? 0 : (s1 < s2) ? -1 : 1; + }, + format: function(cultureOrFormat) { + var culture = neutralCulture; + var format = cultureOrFormat; + var values = Array.prototype.slice.call(arguments, 1); + + if (cultureOrFormat.constructor != String) { + culture = cultureOrFormat; + format = values[0]; + values = values.slice(1); + } + + return format.replace(_formatPlaceHolderRE, + function(str, match) { + var index = parseInt(match.substr(1), 10); + var value = values[index]; + if (!isValue(value)) { + return ''; + } + + var formatter = _formatters[value.constructor.name]; + if (formatter) { + var formatSpec = ''; + var formatIndex = match.indexOf(':'); + if (formatIndex > 0) { + formatSpec = match.substring(formatIndex + 1, match.length - 1); + } + if (formatSpec && (formatSpec != 'i')) { + return formatter(value, formatSpec, culture); + } + } + return culture == neutralCulture ? value.toString() : value.toLocaleString(); + }); + } +}); + +extend(String.prototype, { + endsWith: function(suffix) { + if (!suffix.length) { + return true; + } + if (suffix.length > this.length) { + return false; + } + return this.substr(-suffix.length) == suffix; + }, + startsWith: function(prefix) { + if (!prefix.length) { + return true; + } + if (prefix.length > this.length) { + return false; + } + return this.substr(0, prefix.length) == prefix; + }, + padLeft: function(totalWidth, ch) { + return (this.length < totalWidth) ? stringFromChar(ch || ' ', totalWidth - this.length) + this : this.valueOf(); + }, + padRight: function(totalWidth, ch) { + return (this.length < totalWidth) ? this + stringFromChar(ch || ' ', totalWidth - this.length) : this.valueOf(); + }, + trimEnd: function() { + return this.replace(/\s*$/, ''); + }, + trimStart: function() { + return this.replace(/^\s*/, ''); + }, + insert: function(index, value) { + if (!value) { + return this.valueOf(); + } + if (!index) { + return value + this; + } + return this.substr(0, index) + value + this.substr(index); + }, + remove: function(index, count) { + if (!count || ((index + count) > this.length)) { + return this.substr(0, index); + } + return this.substr(0, index) + this.substr(index + count); + }, + replaceAll: function(oldValue, newValue) { + return this.split(oldValue).join(newValue || ''); + } +}); + +if (!String.prototype.trim) { + String.prototype.trim = function() { + return this.trimEnd().trimStart(); + } +} + diff --git a/src/Core/Scripts/Runtime/Tuple.js b/src/Core/Scripts/Runtime/Tuple.js new file mode 100644 index 000000000..b2b61d4cb --- /dev/null +++ b/src/Core/Scripts/Runtime/Tuple.js @@ -0,0 +1,10 @@ +// Tuple + +function Tuple(first, second, third) { + this.first = first; + this.second = second; + if (arguments.length == 3) { + this.third = third; + } +} + diff --git a/src/Core/Scripts/Scripts.csproj b/src/Core/Scripts/Scripts.csproj index 6970a5129..c4b4193e1 100644 --- a/src/Core/Scripts/Scripts.csproj +++ b/src/Core/Scripts/Scripts.csproj @@ -20,16 +20,21 @@ + + + + + From ad0ec46c29b019c62c0a5bd40baffef608c17b31 Mon Sep 17 00:00:00 2001 From: Nikhil Kothari Date: Fri, 14 Sep 2012 17:33:11 -0700 Subject: [PATCH 016/251] More runtime stuff + tests --- src/Core/Scripts/Runtime.js | 2 + src/Core/Scripts/Runtime/Date.js | 17 +++++ src/Core/Scripts/Runtime/Math.js | 6 ++ src/Core/Scripts/Runtime/String.js | 97 ++++++++++++++++++++++------ src/Core/Scripts/Scripts.csproj | 2 + tests/Runtime/ExtensionTests.cs | 30 +++++++++ tests/Runtime/Runtime.csproj | 1 + tests/TestSite/TestArray.htm | 32 +++++++++ tests/TestSite/TestObject.htm | 56 ++++++++++++++++ tests/TestSite/TestString.htm | 100 +++++++++++++++++++++++++++++ 10 files changed, 323 insertions(+), 20 deletions(-) create mode 100644 src/Core/Scripts/Runtime/Date.js create mode 100644 src/Core/Scripts/Runtime/Math.js create mode 100644 tests/Runtime/ExtensionTests.cs create mode 100644 tests/TestSite/TestArray.htm create mode 100644 tests/TestSite/TestObject.htm create mode 100644 tests/TestSite/TestString.htm diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js index 23d13aa5a..787784bb4 100644 --- a/src/Core/Scripts/Runtime.js +++ b/src/Core/Scripts/Runtime.js @@ -38,6 +38,8 @@ function extend(o, items) { #include "Runtime\String.js" #include "Runtime\Console.js" #include "Runtime\Error.js" +#include "Runtime\Date.js" +#include "Runtime\Math.js" #include "Runtime\TypeSystem.js" #include "Runtime\Delegate.js" diff --git a/src/Core/Scripts/Runtime/Date.js b/src/Core/Scripts/Runtime/Date.js new file mode 100644 index 000000000..cccd60d00 --- /dev/null +++ b/src/Core/Scripts/Runtime/Date.js @@ -0,0 +1,17 @@ +// Date + +Date.Empty = null; + +Date.get_now = function() { + return new Date(); +} + +Date.get_today = function() { + var d = new Date(); + return new Date(d.getFullYear(), d.getMonth(), d.getDate()); +} + +Date.isEmpty = function(d) { + return (d === null) || (d.valueOf() === 0); +} + diff --git a/src/Core/Scripts/Runtime/Math.js b/src/Core/Scripts/Runtime/Math.js new file mode 100644 index 000000000..7cfe128a9 --- /dev/null +++ b/src/Core/Scripts/Runtime/Math.js @@ -0,0 +1,6 @@ +// Math + +Math.truncate = function(n) { + return (n >= 0) ? Math.floor(n) : Math.ceil(n); +} + diff --git a/src/Core/Scripts/Runtime/String.js b/src/Core/Scripts/Runtime/String.js index 81d511768..e371749b1 100644 --- a/src/Core/Scripts/Runtime/String.js +++ b/src/Core/Scripts/Runtime/String.js @@ -24,6 +24,9 @@ extend(String, { return (s1 == s2) ? 0 : (s1 < s2) ? -1 : 1; }, + equals: function(s1, s2, ignoreCase) { + return String.compare(s1, s2, ignoreCase) == 0; + }, format: function(cultureOrFormat) { var culture = neutralCulture; var format = cultureOrFormat; @@ -56,10 +59,19 @@ extend(String, { } return culture == neutralCulture ? value.toString() : value.toLocaleString(); }); + }, + isNullOrEmpty: function(s) { + return !s || !s.length; + }, + isNullOrWhiteSpace: function(s) { + return String.isNullOrEmpty(s) || s.trim() === ""; } }); extend(String.prototype, { + compareTo: function(s, ignoreCase) { + return String.Compare(this, s, ignoreCase); + }, endsWith: function(suffix) { if (!suffix.length) { return true; @@ -69,26 +81,26 @@ extend(String.prototype, { } return this.substr(-suffix.length) == suffix; }, - startsWith: function(prefix) { - if (!prefix.length) { - return true; + indexOfAny: function(chars, startIndex, count) { + var length = this.length; + if (!length) { + return -1; } - if (prefix.length > this.length) { - return false; + + startIndex = startIndex || 0; + count = count || length; + + var endIndex = startIndex + count - 1; + if (endIndex >= length) { + endIndex = length - 1; } - return this.substr(0, prefix.length) == prefix; - }, - padLeft: function(totalWidth, ch) { - return (this.length < totalWidth) ? stringFromChar(ch || ' ', totalWidth - this.length) + this : this.valueOf(); - }, - padRight: function(totalWidth, ch) { - return (this.length < totalWidth) ? this + stringFromChar(ch || ' ', totalWidth - this.length) : this.valueOf(); - }, - trimEnd: function() { - return this.replace(/\s*$/, ''); - }, - trimStart: function() { - return this.replace(/^\s*/, ''); + + for (var i = startIndex; i <= endIndex; i++) { + if (chars.indexOf(this.charAt(i)) >= 0) { + return i; + } + } + return -1; }, insert: function(index, value) { if (!value) { @@ -97,7 +109,36 @@ extend(String.prototype, { if (!index) { return value + this; } - return this.substr(0, index) + value + this.substr(index); + var s1 = this.substr(0, index); + var s2 = this.substr(index); + return s1 + value + s2; + }, + lastIndexOfAny: function(chars, startIndex, count) { + var length = this.length; + if (!length) { + return -1; + } + + startIndex = startIndex || length - 1; + count = count || length; + + var endIndex = startIndex - count + 1; + if (endIndex < 0) { + endIndex = 0; + } + + for (var i = startIndex; i >= endIndex; i--) { + if (chars.indexOf(this.charAt(i)) >= 0) { + return i; + } + } + return -1; + }, + padLeft: function(totalWidth, ch) { + return (this.length < totalWidth) ? stringFromChar(ch || ' ', totalWidth - this.length) + this : this.valueOf(); + }, + padRight: function(totalWidth, ch) { + return (this.length < totalWidth) ? this + stringFromChar(ch || ' ', totalWidth - this.length) : this.valueOf(); }, remove: function(index, count) { if (!count || ((index + count) > this.length)) { @@ -106,7 +147,23 @@ extend(String.prototype, { return this.substr(0, index) + this.substr(index + count); }, replaceAll: function(oldValue, newValue) { - return this.split(oldValue).join(newValue || ''); + newValue = newValue || ''; + return this.split(oldValue).join(newValue); + }, + startsWith: function(prefix) { + if (!prefix.length) { + return true; + } + if (prefix.length > this.length) { + return false; + } + return this.substr(0, prefix.length) == prefix; + }, + trimEnd: function() { + return this.replace(/\s*$/, ''); + }, + trimStart: function() { + return this.replace(/^\s*/, ''); } }); diff --git a/src/Core/Scripts/Scripts.csproj b/src/Core/Scripts/Scripts.csproj index c4b4193e1..d6ecad61a 100644 --- a/src/Core/Scripts/Scripts.csproj +++ b/src/Core/Scripts/Scripts.csproj @@ -20,6 +20,8 @@ + + diff --git a/tests/Runtime/ExtensionTests.cs b/tests/Runtime/ExtensionTests.cs new file mode 100644 index 000000000..f209dbce7 --- /dev/null +++ b/tests/Runtime/ExtensionTests.cs @@ -0,0 +1,30 @@ +// ExtensionTests.cs +// Script#/Tests/Runtime +// This source code is subject to terms and conditions of the Apache License, Version 2.0. +// + +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Runtime.Tests.Core; + +namespace Runtime.Tests { + + [TestClass] + public class ExtensionTests : RuntimeTest { + + [TestMethod] + public void TestArray() { + RunTest("/TestArray.htm"); + } + + [TestMethod] + public void TestObject() { + RunTest("/TestObject.htm"); + } + + [TestMethod] + public void TestString() { + RunTest("/TestString.htm"); + } + } +} diff --git a/tests/Runtime/Runtime.csproj b/tests/Runtime/Runtime.csproj index 994682d3e..d6a572e2f 100644 --- a/tests/Runtime/Runtime.csproj +++ b/tests/Runtime/Runtime.csproj @@ -60,6 +60,7 @@ + diff --git a/tests/TestSite/TestArray.htm b/tests/TestSite/TestArray.htm new file mode 100644 index 000000000..5dc725d65 --- /dev/null +++ b/tests/TestSite/TestArray.htm @@ -0,0 +1,32 @@ + + + + TestExtensions - Array + + + + + +

            Test Results

            +

            +

            +
              +
              + + + + + + + diff --git a/tests/TestSite/TestObject.htm b/tests/TestSite/TestObject.htm new file mode 100644 index 000000000..4d99a24b3 --- /dev/null +++ b/tests/TestSite/TestObject.htm @@ -0,0 +1,56 @@ + + + + ExtensionTests - Object + + + + + +

              Test Results

              +

              +

              +
                +
                + + + + + + diff --git a/tests/TestSite/TestString.htm b/tests/TestSite/TestString.htm new file mode 100644 index 000000000..d0baa0c9f --- /dev/null +++ b/tests/TestSite/TestString.htm @@ -0,0 +1,100 @@ + + + + ExtensionTests - String + + + + + +

                Test Results

                +

                +

                +
                  +
                  + + + + + + From 20e30565caab51da5b8d037c4b62da8503810cad Mon Sep 17 00:00:00 2001 From: Nikhil Kothari Date: Fri, 14 Sep 2012 17:34:22 -0700 Subject: [PATCH 017/251] Remove various Format/LocaleFormat methods Replace String.LocaleFormat w. Format overload instead. Remove HtmlEncode/Decode --- src/Core/CoreLib/Byte.cs | 8 -------- src/Core/CoreLib/Date.cs | 9 +-------- src/Core/CoreLib/Double.cs | 8 -------- src/Core/CoreLib/Int16.cs | 8 -------- src/Core/CoreLib/Int32.cs | 8 -------- src/Core/CoreLib/Int64.cs | 8 -------- src/Core/CoreLib/Number.cs | 8 -------- src/Core/CoreLib/SByte.cs | 8 -------- src/Core/CoreLib/Single.cs | 8 -------- src/Core/CoreLib/String.cs | 19 ++++--------------- src/Core/CoreLib/UInt16.cs | 8 -------- src/Core/CoreLib/UInt32.cs | 8 -------- src/Core/CoreLib/UInt64.cs | 8 -------- 13 files changed, 5 insertions(+), 111 deletions(-) diff --git a/src/Core/CoreLib/Byte.cs b/src/Core/CoreLib/Byte.cs index d58139790..b7de102aa 100644 --- a/src/Core/CoreLib/Byte.cs +++ b/src/Core/CoreLib/Byte.cs @@ -15,14 +15,6 @@ namespace System { [ScriptName("Number")] public struct Byte { - public string Format(string format) { - return null; - } - - public string LocaleFormat(string format) { - return null; - } - /// /// Converts the value to its string representation. /// diff --git a/src/Core/CoreLib/Date.cs b/src/Core/CoreLib/Date.cs index 468e0c6f2..dc0ced859 100644 --- a/src/Core/CoreLib/Date.cs +++ b/src/Core/CoreLib/Date.cs @@ -17,6 +17,7 @@ public sealed class Date { /// /// Represents a null date. /// + [PreserveCase] public static readonly Date Empty; /// @@ -112,10 +113,6 @@ public static Date Today { } } - public string Format(string format) { - return null; - } - public int GetDate() { return 0; } @@ -192,10 +189,6 @@ public static bool IsEmpty(Date d) { return false; } - public string LocaleFormat(string format) { - return null; - } - [ScriptName("parseDate")] public static Date Parse(string value) { return null; diff --git a/src/Core/CoreLib/Double.cs b/src/Core/CoreLib/Double.cs index 3e98b170a..094037644 100644 --- a/src/Core/CoreLib/Double.cs +++ b/src/Core/CoreLib/Double.cs @@ -15,14 +15,6 @@ namespace System { [ScriptName("Number")] public struct Double { - public string Format(string format) { - return null; - } - - public string LocaleFormat(string format) { - return null; - } - [ScriptAlias("parseFloat")] public static double Parse(string s) { return 0; diff --git a/src/Core/CoreLib/Int16.cs b/src/Core/CoreLib/Int16.cs index 431f6f916..ef1835feb 100644 --- a/src/Core/CoreLib/Int16.cs +++ b/src/Core/CoreLib/Int16.cs @@ -15,14 +15,6 @@ namespace System { [ScriptName("Number")] public struct Int16 { - public string Format(string format) { - return null; - } - - public string LocaleFormat(string format) { - return null; - } - /// /// Converts the value to its string representation. /// diff --git a/src/Core/CoreLib/Int32.cs b/src/Core/CoreLib/Int32.cs index 3745cb01f..818fd3992 100644 --- a/src/Core/CoreLib/Int32.cs +++ b/src/Core/CoreLib/Int32.cs @@ -15,14 +15,6 @@ namespace System { [ScriptName("Number")] public struct Int32 { - public string Format(string format) { - return null; - } - - public string LocaleFormat(string format) { - return null; - } - [ScriptAlias("parseInt")] public static int Parse(string s) { return 0; diff --git a/src/Core/CoreLib/Int64.cs b/src/Core/CoreLib/Int64.cs index bd7117d65..c09ed79e4 100644 --- a/src/Core/CoreLib/Int64.cs +++ b/src/Core/CoreLib/Int64.cs @@ -15,14 +15,6 @@ namespace System { [ScriptName("Number")] public struct Int64 { - public string Format(string format) { - return null; - } - - public string LocaleFormat(string format) { - return null; - } - /// /// Converts the value to its string representation. /// diff --git a/src/Core/CoreLib/Number.cs b/src/Core/CoreLib/Number.cs index dccaf45ee..3dd63cde9 100644 --- a/src/Core/CoreLib/Number.cs +++ b/src/Core/CoreLib/Number.cs @@ -29,10 +29,6 @@ public sealed class Number { [PreserveCase] public const int POSITIVE_INFINITY = 0; - public string Format(string format) { - return null; - } - [ScriptAlias("isFinite")] public static bool IsFinite(Number n) { return false; @@ -43,10 +39,6 @@ public static bool IsNaN(Number n) { return false; } - public string LocaleFormat(string format) { - return null; - } - public static Number Parse(string s) { return null; } diff --git a/src/Core/CoreLib/SByte.cs b/src/Core/CoreLib/SByte.cs index 0565ecd57..73205d13f 100644 --- a/src/Core/CoreLib/SByte.cs +++ b/src/Core/CoreLib/SByte.cs @@ -15,14 +15,6 @@ namespace System { [ScriptName("Number")] public struct SByte { - public string Format(string format) { - return null; - } - - public string LocaleFormat(string format) { - return null; - } - /// /// Converts the value to its string representation. /// diff --git a/src/Core/CoreLib/Single.cs b/src/Core/CoreLib/Single.cs index 4556144f3..3a900b773 100644 --- a/src/Core/CoreLib/Single.cs +++ b/src/Core/CoreLib/Single.cs @@ -17,14 +17,6 @@ namespace System { [ScriptName("Number")] public struct Single { - public string Format(string format) { - return null; - } - - public string LocaleFormat(string format) { - return null; - } - [ScriptAlias("parseFloat")] public static float Parse(string s) { return 0; diff --git a/src/Core/CoreLib/String.cs b/src/Core/CoreLib/String.cs index e6b28f70d..dc65dd9b1 100644 --- a/src/Core/CoreLib/String.cs +++ b/src/Core/CoreLib/String.cs @@ -4,6 +4,7 @@ // using System.ComponentModel; +using System.Globalization; using System.Runtime.CompilerServices; namespace System { @@ -192,19 +193,15 @@ public static string Format(string format, params object[] values) { return null; } - public static string FromChar(char ch, int count) { + public static string Format(CultureInfo culture, string format, params object[] values) { return null; } - public static string FromCharCode(params int[] charCodes) { - return null; - } - - public string HtmlDecode() { + public static string FromChar(char ch, int count) { return null; } - public string HtmlEncode() { + public static string FromCharCode(params int[] charCodes) { return null; } @@ -276,14 +273,6 @@ public int LastIndexOfAny(char[] ch, int startIndex, int count) { return 0; } - public int LocaleCompare(string string2) { - return 0; - } - - public static string LocaleFormat(string format, params object[] values) { - return null; - } - public string[] Match(RegularExpression regex) { return null; } diff --git a/src/Core/CoreLib/UInt16.cs b/src/Core/CoreLib/UInt16.cs index 69c95865b..1dfa68241 100644 --- a/src/Core/CoreLib/UInt16.cs +++ b/src/Core/CoreLib/UInt16.cs @@ -15,14 +15,6 @@ namespace System { [ScriptName("Number")] public struct UInt16 { - public string Format(string format) { - return null; - } - - public string LocaleFormat(string format) { - return null; - } - /// /// Converts the value to its string representation. /// diff --git a/src/Core/CoreLib/UInt32.cs b/src/Core/CoreLib/UInt32.cs index 59fc0975c..72c956ccc 100644 --- a/src/Core/CoreLib/UInt32.cs +++ b/src/Core/CoreLib/UInt32.cs @@ -15,14 +15,6 @@ namespace System { [ScriptName("Number")] public struct UInt32 { - public string Format(string format) { - return null; - } - - public string LocaleFormat(string format) { - return null; - } - /// /// Converts the value to its string representation. /// diff --git a/src/Core/CoreLib/UInt64.cs b/src/Core/CoreLib/UInt64.cs index 95769d7b1..13120a487 100644 --- a/src/Core/CoreLib/UInt64.cs +++ b/src/Core/CoreLib/UInt64.cs @@ -15,14 +15,6 @@ namespace System { [ScriptName("Number")] public struct UInt64 { - public string Format(string format) { - return null; - } - - public string LocaleFormat(string format) { - return null; - } - /// /// Converts the value to its string representation. /// From fc8ca2e888f4bdf537fa124e97f3df654d307ac1 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Fri, 14 Sep 2012 20:52:41 -0700 Subject: [PATCH 018/251] Remove old tests --- tests/CoreLib/QUnit.css | 112 --- tests/CoreLib/QUnit.js | 1043 --------------------------- tests/CoreLib/QUnitExt.js | 44 -- tests/CoreLib/TestArray.htm | 29 - tests/CoreLib/TestDelegate.htm | 148 ---- tests/CoreLib/TestEnum.htm | 46 -- tests/CoreLib/TestOOP.htm | 112 --- tests/CoreLib/TestOOP.js | 94 --- tests/CoreLib/TestObject.htm | 54 -- tests/CoreLib/TestObservable.htm | 136 ---- tests/CoreLib/TestStartup.htm | 52 -- tests/CoreLib/TestString.htm | 108 --- tests/CoreLib/TestStringBuilder.htm | 68 -- tests/CoreLib/TestTask.htm | 295 -------- tests/CoreLib/Tests.htm | 52 -- 15 files changed, 2393 deletions(-) delete mode 100644 tests/CoreLib/QUnit.css delete mode 100644 tests/CoreLib/QUnit.js delete mode 100644 tests/CoreLib/QUnitExt.js delete mode 100644 tests/CoreLib/TestArray.htm delete mode 100644 tests/CoreLib/TestDelegate.htm delete mode 100644 tests/CoreLib/TestEnum.htm delete mode 100644 tests/CoreLib/TestOOP.htm delete mode 100644 tests/CoreLib/TestOOP.js delete mode 100644 tests/CoreLib/TestObject.htm delete mode 100644 tests/CoreLib/TestObservable.htm delete mode 100644 tests/CoreLib/TestStartup.htm delete mode 100644 tests/CoreLib/TestString.htm delete mode 100644 tests/CoreLib/TestStringBuilder.htm delete mode 100644 tests/CoreLib/TestTask.htm delete mode 100644 tests/CoreLib/Tests.htm diff --git a/tests/CoreLib/QUnit.css b/tests/CoreLib/QUnit.css deleted file mode 100644 index a9b4f5903..000000000 --- a/tests/CoreLib/QUnit.css +++ /dev/null @@ -1,112 +0,0 @@ -ol#qunit-tests { - font-family:Calibri, Helvetica, Arial; - margin:0; - padding:0; - list-style-position:inside; - font-size: smaller; -} -ol#qunit-tests li{ - padding:0.4em 0.5em 0.4em 2.5em; - border-bottom:1px solid #fff; - font-size:small; - list-style-position:inside; -} -ol#qunit-tests li ol{ - box-shadow: inset 0px 2px 13px #999; - -moz-box-shadow: inset 0px 2px 13px #999; - -webkit-box-shadow: inset 0px 2px 13px #999; - margin-top:0.5em; - margin-left:0; - padding:0.5em; - background-color:#fff; -} -ol#qunit-tests li li{ - border-bottom:none; - margin:0.5em; - background-color:#fff; - list-style-position: inside; - padding:0.4em 0.5em 0.4em 0.5em; -} -ol#qunit-tests li li.pass{ - border-left:26px solid #C6E746; - background-color:#fff; - color:#5E740B; -} -ol#qunit-tests li li.fail{ - border-left:26px solid #EE5757; - background-color:#fff; - color:#710909; -} -ol#qunit-tests li.pass{ - background-color:#D2E0E6; - color:#528CE0; -} -ol#qunit-tests li.fail{ - background-color:#EE5757; - color:#000; -} -ol#qunit-tests li strong { - cursor:pointer; -} -h1#qunit-header{ - background-color:#0d3349; - margin:0; - padding:0.5em 0 0.5em 1em; - color:#fff; - font-family:Calibri, Helvetica, Arial; - border-top-right-radius:15px; - border-top-left-radius:15px; - -moz-border-radius-topright:15px; - -moz-border-radius-topleft:15px; - -webkit-border-top-right-radius:15px; - -webkit-border-top-left-radius:15px; - text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 1px; -} -h2#qunit-banner{ - font-family:Calibri, Helvetica, Arial; - height:5px; - margin:0; - padding:0; -} -h2#qunit-banner.qunit-pass{ - background-color:#C6E746; -} -h2#qunit-banner.qunit-fail, #qunit-testrunner-toolbar { - background-color:#EE5757; -} -#qunit-testrunner-toolbar { - font-family:Calibri, Helvetica, Arial; - padding:0; - padding:0em 0 0.5em 2em; - font-size: small; -} -h2#qunit-userAgent { - font-family:Calibri, Helvetica, Arial; - background-color:#2b81af; - margin:0; - padding:0; - color:#fff; - font-size: small; - padding:0.5em 0 0.5em 2.5em; - text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; -} -p#qunit-testresult{ - font-family:Calibri, Helvetica, Arial; - margin:0; - font-size: small; - color:#2b81af; - border-bottom-right-radius:15px; - border-bottom-left-radius:15px; - -moz-border-radius-bottomright:15px; - -moz-border-radius-bottomleft:15px; - -webkit-border-bottom-right-radius:15px; - -webkit-border-bottom-left-radius:15px; - background-color:#D2E0E6; - padding:0.5em 0.5em 0.5em 2.5em; -} -strong b.fail{ - color:#710909; -} -strong b.pass{ - color:#5E740B; -} diff --git a/tests/CoreLib/QUnit.js b/tests/CoreLib/QUnit.js deleted file mode 100644 index f2704148e..000000000 --- a/tests/CoreLib/QUnit.js +++ /dev/null @@ -1,1043 +0,0 @@ -/* - * QUnit - A JavaScript Unit Testing Framework - * - * http://docs.jquery.com/QUnit - * - * Copyright (c) 2009 John Resig, Jörn Zaefferer - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. - */ - -(function(window) { - -var QUnit = { - - // Initialize the configuration options - init: function() { - config = { - stats: { all: 0, bad: 0 }, - moduleStats: { all: 0, bad: 0 }, - started: +new Date, - blocking: false, - autorun: false, - assertions: [], - filters: [], - queue: [] - }; - - var tests = id("qunit-tests"), - banner = id("qunit-banner"), - result = id("qunit-testresult"); - - if ( tests ) { - tests.innerHTML = ""; - } - - if ( banner ) { - banner.className = ""; - } - - if ( result ) { - result.parentNode.removeChild( result ); - } - }, - - // call on start of module test to prepend name to all tests - module: function(name, testEnvironment) { - config.currentModule = name; - - synchronize(function() { - if ( config.currentModule ) { - QUnit.moduleDone( config.currentModule, config.moduleStats.bad, config.moduleStats.all ); - } - - config.currentModule = name; - config.moduleTestEnvironment = testEnvironment; - config.moduleStats = { all: 0, bad: 0 }; - - QUnit.moduleStart( name, testEnvironment ); - }); - }, - - asyncTest: function(testName, expected, callback) { - if ( arguments.length === 2 ) { - callback = expected; - expected = 0; - } - - QUnit.test(testName, expected, callback, true); - }, - - test: function(testName, expected, callback, async) { - var name = testName, testEnvironment, testEnvironmentArg; - - if ( arguments.length === 2 ) { - callback = expected; - expected = null; - } - // is 2nd argument a testEnvironment? - if ( expected && typeof expected === 'object') { - testEnvironmentArg = expected; - expected = null; - } - - if ( config.currentModule ) { - name = config.currentModule + " module: " + name; - } - - if ( !validTest(name) ) { - return; - } - - synchronize(function() { - QUnit.testStart( testName ); - - testEnvironment = extend({ - setup: function() {}, - teardown: function() {} - }, config.moduleTestEnvironment); - if (testEnvironmentArg) { - extend(testEnvironment,testEnvironmentArg); - } - - // allow utility functions to access the current test environment - QUnit.current_testEnvironment = testEnvironment; - - config.assertions = []; - config.expected = expected; - - try { - if ( !config.pollution ) { - saveGlobal(); - } - - testEnvironment.setup.call(testEnvironment); - } catch(e) { - QUnit.ok( false, "Setup failed on " + name + ": " + e.message ); - } - - if ( async ) { - QUnit.stop(); - } - - try { - callback.call(testEnvironment); - } catch(e) { - fail("Test " + name + " died, exception and test follows", e, callback); - QUnit.ok( false, "Died on test #" + (config.assertions.length + 1) + ": " + e.message ); - // else next test will carry the responsibility - saveGlobal(); - - // Restart the tests if they're blocking - if ( config.blocking ) { - start(); - } - } - }); - - synchronize(function() { - try { - checkPollution(); - testEnvironment.teardown.call(testEnvironment); - } catch(e) { - QUnit.ok( false, "Teardown failed on " + name + ": " + e.message ); - } - - try { - QUnit.reset(); - } catch(e) { - fail("reset() failed, following Test " + name + ", exception and reset fn follows", e, reset); - } - - if ( config.expected && config.expected != config.assertions.length ) { - QUnit.ok( false, "Expected " + config.expected + " assertions, but " + config.assertions.length + " were run" ); - } - - var good = 0, bad = 0, - tests = id("qunit-tests"); - - config.stats.all += config.assertions.length; - config.moduleStats.all += config.assertions.length; - - if ( tests ) { - var ol = document.createElement("ol"); - ol.style.display = "none"; - - for ( var i = 0; i < config.assertions.length; i++ ) { - var assertion = config.assertions[i]; - - var li = document.createElement("li"); - li.className = assertion.result ? "pass" : "fail"; - li.appendChild(document.createTextNode(assertion.message || "(no message)")); - ol.appendChild( li ); - - if ( assertion.result ) { - good++; - } else { - bad++; - config.stats.bad++; - config.moduleStats.bad++; - } - } - - var b = document.createElement("strong"); - b.innerHTML = name + " (" + bad + ", " + good + ", " + config.assertions.length + ")"; - - addEvent(b, "click", function() { - var next = b.nextSibling, display = next.style.display; - next.style.display = display === "none" ? "block" : "none"; - }); - - addEvent(b, "dblclick", function(e) { - var target = e && e.target ? e.target : window.event.srcElement; - if ( target.nodeName.toLowerCase() === "strong" ) { - var text = "", node = target.firstChild; - - while ( node.nodeType === 3 ) { - text += node.nodeValue; - node = node.nextSibling; - } - - text = text.replace(/(^\s*|\s*$)/g, ""); - - if ( window.location ) { - window.location.href = window.location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent(text); - } - } - }); - - var li = document.createElement("li"); - li.className = bad ? "fail" : "pass"; - li.appendChild( b ); - li.appendChild( ol ); - tests.appendChild( li ); - - if ( bad ) { - var toolbar = id("qunit-testrunner-toolbar"); - if ( toolbar ) { - toolbar.style.display = "block"; - id("qunit-filter-pass").disabled = null; - id("qunit-filter-missing").disabled = null; - } - } - - } else { - for ( var i = 0; i < config.assertions.length; i++ ) { - if ( !config.assertions[i].result ) { - bad++; - config.stats.bad++; - config.moduleStats.bad++; - } - } - } - - QUnit.testDone( testName, bad, config.assertions.length ); - - if ( !window.setTimeout && !config.queue.length ) { - done(); - } - }); - - if ( window.setTimeout && !config.doneTimer ) { - config.doneTimer = window.setTimeout(function(){ - if ( !config.queue.length ) { - done(); - } else { - synchronize( done ); - } - }, 13); - } - }, - - /** - * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through. - */ - expect: function(asserts) { - config.expected = asserts; - }, - - /** - * Asserts true. - * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" ); - */ - ok: function(a, msg) { - QUnit.log(a, msg); - - config.assertions.push({ - result: !!a, - message: msg - }); - }, - - /** - * Checks that the first two arguments are equal, with an optional message. - * Prints out both actual and expected values. - * - * Prefered to ok( actual == expected, message ) - * - * @example equal( format("Received {0} bytes.", 2), "Received 2 bytes." ); - * - * @param Object actual - * @param Object expected - * @param String message (optional) - */ - equal: function(actual, expected, message) { - push(expected == actual, actual, expected, message); - }, - - notEqual: function(actual, expected, message) { - push(expected != actual, actual, expected, message); - }, - - deepEqual: function(a, b, message) { - push(QUnit.equiv(a, b), a, b, message); - }, - - notDeepEqual: function(a, b, message) { - push(!QUnit.equiv(a, b), a, b, message); - }, - - strictEqual: function(actual, expected, message) { - push(expected === actual, actual, expected, message); - }, - - notStrictEqual: function(actual, expected, message) { - push(expected !== actual, actual, expected, message); - }, - - start: function() { - // A slight delay, to avoid any current callbacks - if ( window.setTimeout ) { - window.setTimeout(function() { - if ( config.timeout ) { - clearTimeout(config.timeout); - } - - config.blocking = false; - process(); - }, 13); - } else { - config.blocking = false; - process(); - } - }, - - stop: function(timeout) { - config.blocking = true; - - if ( timeout && window.setTimeout ) { - config.timeout = window.setTimeout(function() { - QUnit.ok( false, "Test timed out" ); - QUnit.start(); - }, timeout); - } - }, - - /** - * Resets the test setup. Useful for tests that modify the DOM. - */ - reset: function() { - if ( window.jQuery ) { - jQuery("#main").html( config.fixture ); - jQuery.event.global = {}; - jQuery.ajaxSettings = extend({}, config.ajaxSettings); - } - }, - - /** - * Trigger an event on an element. - * - * @example triggerEvent( document.body, "click" ); - * - * @param DOMElement elem - * @param String type - */ - triggerEvent: function( elem, type, event ) { - if ( document.createEvent ) { - event = document.createEvent("MouseEvents"); - event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView, - 0, 0, 0, 0, 0, false, false, false, false, 0, null); - elem.dispatchEvent( event ); - - } else if ( elem.fireEvent ) { - elem.fireEvent("on"+type); - } - }, - - // Safe object type checking - is: function( type, obj ) { - return Object.prototype.toString.call( obj ) === "[object "+ type +"]"; - }, - - // Logging callbacks - done: function(failures, total) {}, - log: function(result, message) {}, - testStart: function(name) {}, - testDone: function(name, failures, total) {}, - moduleStart: function(name, testEnvironment) {}, - moduleDone: function(name, failures, total) {} -}; - -// Backwards compatibility, deprecated -QUnit.equals = QUnit.equal; -QUnit.same = QUnit.deepEqual; - -// Maintain internal state -var config = { - // The queue of tests to run - queue: [], - - // block until document ready - blocking: true -}; - -// Load paramaters -(function() { - var location = window.location || { search: "", protocol: "file:" }, - GETParams = location.search.slice(1).split('&'); - - for ( var i = 0; i < GETParams.length; i++ ) { - GETParams[i] = decodeURIComponent( GETParams[i] ); - if ( GETParams[i] === "noglobals" ) { - GETParams.splice( i, 1 ); - i--; - config.noglobals = true; - } else if ( GETParams[i].search('=') > -1 ) { - GETParams.splice( i, 1 ); - i--; - } - } - - // restrict modules/tests by get parameters - config.filters = GETParams; - - // Figure out if we're running the tests from a server or not - QUnit.isLocal = !!(location.protocol === 'file:'); -})(); - -// Expose the API as global variables, unless an 'exports' -// object exists, in that case we assume we're in CommonJS -if ( typeof exports === "undefined" || typeof require === "undefined" ) { - extend(window, QUnit); - window.QUnit = QUnit; -} else { - extend(exports, QUnit); - exports.QUnit = QUnit; -} - -if ( typeof document === "undefined" || document.readyState === "complete" ) { - config.autorun = true; -} - -addEvent(window, "load", function() { - // Initialize the config, saving the execution queue - var oldconfig = extend({}, config); - QUnit.init(); - extend(config, oldconfig); - - config.blocking = false; - - var userAgent = id("qunit-userAgent"); - if ( userAgent ) { - userAgent.innerHTML = navigator.userAgent; - } - - var toolbar = id("qunit-testrunner-toolbar"); - if ( toolbar ) { - toolbar.style.display = "none"; - - var filter = document.createElement("input"); - filter.type = "checkbox"; - filter.id = "qunit-filter-pass"; - filter.disabled = true; - addEvent( filter, "click", function() { - var li = document.getElementsByTagName("li"); - for ( var i = 0; i < li.length; i++ ) { - if ( li[i].className.indexOf("pass") > -1 ) { - li[i].style.display = filter.checked ? "none" : ""; - } - } - }); - toolbar.appendChild( filter ); - - var label = document.createElement("label"); - label.setAttribute("for", "qunit-filter-pass"); - label.innerHTML = "Hide passed tests"; - toolbar.appendChild( label ); - - var missing = document.createElement("input"); - missing.type = "checkbox"; - missing.id = "qunit-filter-missing"; - missing.disabled = true; - addEvent( missing, "click", function() { - var li = document.getElementsByTagName("li"); - for ( var i = 0; i < li.length; i++ ) { - if ( li[i].className.indexOf("fail") > -1 && li[i].innerHTML.indexOf('missing test - untested code is broken code') > - 1 ) { - li[i].parentNode.parentNode.style.display = missing.checked ? "none" : "block"; - } - } - }); - toolbar.appendChild( missing ); - - label = document.createElement("label"); - label.setAttribute("for", "qunit-filter-missing"); - label.innerHTML = "Hide missing tests (untested code is broken code)"; - toolbar.appendChild( label ); - } - - var main = id('main'); - if ( main ) { - config.fixture = main.innerHTML; - } - - if ( window.jQuery ) { - config.ajaxSettings = window.jQuery.ajaxSettings; - } - - QUnit.start(); -}); - -function done() { - if ( config.doneTimer && window.clearTimeout ) { - window.clearTimeout( config.doneTimer ); - config.doneTimer = null; - } - - if ( config.queue.length ) { - config.doneTimer = window.setTimeout(function(){ - if ( !config.queue.length ) { - done(); - } else { - synchronize( done ); - } - }, 13); - - return; - } - - config.autorun = true; - - // Log the last module results - if ( config.currentModule ) { - QUnit.moduleDone( config.currentModule, config.moduleStats.bad, config.moduleStats.all ); - } - - var banner = id("qunit-banner"), - tests = id("qunit-tests"), - html = ['Tests completed in ', - +new Date - config.started, ' milliseconds.
                  ', - '', config.stats.all - config.stats.bad, ' tests of ', config.stats.all, ' passed, ', config.stats.bad,' failed.'].join(''); - - if ( banner ) { - banner.className = (config.stats.bad ? "qunit-fail" : "qunit-pass"); - } - - if ( tests ) { - var result = id("qunit-testresult"); - - if ( !result ) { - result = document.createElement("p"); - result.id = "qunit-testresult"; - result.className = "result"; - tests.parentNode.insertBefore( result, tests.nextSibling ); - } - - result.innerHTML = html; - } - - QUnit.done( config.stats.bad, config.stats.all ); -} - -function validTest( name ) { - var i = config.filters.length, - run = false; - - if ( !i ) { - return true; - } - - while ( i-- ) { - var filter = config.filters[i], - not = filter.charAt(0) == '!'; - - if ( not ) { - filter = filter.slice(1); - } - - if ( name.indexOf(filter) !== -1 ) { - return !not; - } - - if ( not ) { - run = true; - } - } - - return run; -} - -function push(result, actual, expected, message) { - message = message || (result ? "okay" : "failed"); - QUnit.ok( result, result ? message + ": " + expected : message + ", expected: " + QUnit.jsDump.parse(expected) + " result: " + QUnit.jsDump.parse(actual) ); -} - -function synchronize( callback ) { - config.queue.push( callback ); - - if ( config.autorun && !config.blocking ) { - process(); - } -} - -function process() { - while ( config.queue.length && !config.blocking ) { - config.queue.shift()(); - } -} - -function saveGlobal() { - config.pollution = []; - - if ( config.noglobals ) { - for ( var key in window ) { - config.pollution.push( key ); - } - } -} - -function checkPollution( name ) { - var old = config.pollution; - saveGlobal(); - - var newGlobals = diff( old, config.pollution ); - if ( newGlobals.length > 0 ) { - ok( false, "Introduced global variable(s): " + newGlobals.join(", ") ); - config.expected++; - } - - var deletedGlobals = diff( config.pollution, old ); - if ( deletedGlobals.length > 0 ) { - ok( false, "Deleted global variable(s): " + deletedGlobals.join(", ") ); - config.expected++; - } -} - -// returns a new Array with the elements that are in a but not in b -function diff( a, b ) { - var result = a.slice(); - for ( var i = 0; i < result.length; i++ ) { - for ( var j = 0; j < b.length; j++ ) { - if ( result[i] === b[j] ) { - result.splice(i, 1); - i--; - break; - } - } - } - return result; -} - -function fail(message, exception, callback) { - if ( typeof console !== "undefined" && console.error && console.warn ) { - console.error(message); - console.error(exception); - console.warn(callback.toString()); - - } else if ( window.opera && opera.postError ) { - opera.postError(message, exception, callback.toString); - } -} - -function extend(a, b) { - for ( var prop in b ) { - a[prop] = b[prop]; - } - - return a; -} - -function addEvent(elem, type, fn) { - if ( elem.addEventListener ) { - elem.addEventListener( type, fn, false ); - } else if ( elem.attachEvent ) { - elem.attachEvent( "on" + type, fn ); - } else { - fn(); - } -} - -function id(name) { - return !!(typeof document !== "undefined" && document && document.getElementById) && - document.getElementById( name ); -} - -// Test for equality any JavaScript type. -// Discussions and reference: http://philrathe.com/articles/equiv -// Test suites: http://philrathe.com/tests/equiv -// Author: Philippe Rathé -QUnit.equiv = function () { - - var innerEquiv; // the real equiv function - var callers = []; // stack to decide between skip/abort functions - - - // Determine what is o. - function hoozit(o) { - if (QUnit.is("String", o)) { - return "string"; - - } else if (QUnit.is("Boolean", o)) { - return "boolean"; - - } else if (QUnit.is("Number", o)) { - - if (isNaN(o)) { - return "nan"; - } else { - return "number"; - } - - } else if (typeof o === "undefined") { - return "undefined"; - - // consider: typeof null === object - } else if (o === null) { - return "null"; - - // consider: typeof [] === object - } else if (QUnit.is( "Array", o)) { - return "array"; - - // consider: typeof new Date() === object - } else if (QUnit.is( "Date", o)) { - return "date"; - - // consider: /./ instanceof Object; - // /./ instanceof RegExp; - // typeof /./ === "function"; // => false in IE and Opera, - // true in FF and Safari - } else if (QUnit.is( "RegExp", o)) { - return "regexp"; - - } else if (typeof o === "object") { - return "object"; - - } else if (QUnit.is( "Function", o)) { - return "function"; - } else { - return undefined; - } - } - - // Call the o related callback with the given arguments. - function bindCallbacks(o, callbacks, args) { - var prop = hoozit(o); - if (prop) { - if (hoozit(callbacks[prop]) === "function") { - return callbacks[prop].apply(callbacks, args); - } else { - return callbacks[prop]; // or undefined - } - } - } - - var callbacks = function () { - - // for string, boolean, number and null - function useStrictEquality(b, a) { - if (b instanceof a.constructor || a instanceof b.constructor) { - // to catch short annotaion VS 'new' annotation of a declaration - // e.g. var i = 1; - // var j = new Number(1); - return a == b; - } else { - return a === b; - } - } - - return { - "string": useStrictEquality, - "boolean": useStrictEquality, - "number": useStrictEquality, - "null": useStrictEquality, - "undefined": useStrictEquality, - - "nan": function (b) { - return isNaN(b); - }, - - "date": function (b, a) { - return hoozit(b) === "date" && a.valueOf() === b.valueOf(); - }, - - "regexp": function (b, a) { - return hoozit(b) === "regexp" && - a.source === b.source && // the regex itself - a.global === b.global && // and its modifers (gmi) ... - a.ignoreCase === b.ignoreCase && - a.multiline === b.multiline; - }, - - // - skip when the property is a method of an instance (OOP) - // - abort otherwise, - // initial === would have catch identical references anyway - "function": function () { - var caller = callers[callers.length - 1]; - return caller !== Object && - typeof caller !== "undefined"; - }, - - "array": function (b, a) { - var i; - var len; - - // b could be an object literal here - if ( ! (hoozit(b) === "array")) { - return false; - } - - len = a.length; - if (len !== b.length) { // safe and faster - return false; - } - for (i = 0; i < len; i++) { - if ( ! innerEquiv(a[i], b[i])) { - return false; - } - } - return true; - }, - - "object": function (b, a) { - var i; - var eq = true; // unless we can proove it - var aProperties = [], bProperties = []; // collection of strings - - // comparing constructors is more strict than using instanceof - if ( a.constructor !== b.constructor) { - return false; - } - - // stack constructor before traversing properties - callers.push(a.constructor); - - for (i in a) { // be strict: don't ensures hasOwnProperty and go deep - - aProperties.push(i); // collect a's properties - - if ( ! innerEquiv(a[i], b[i])) { - eq = false; - break; - } - } - - callers.pop(); // unstack, we are done - - for (i in b) { - bProperties.push(i); // collect b's properties - } - - // Ensures identical properties name - return eq && innerEquiv(aProperties.sort(), bProperties.sort()); - } - }; - }(); - - innerEquiv = function () { // can take multiple arguments - var args = Array.prototype.slice.apply(arguments); - if (args.length < 2) { - return true; // end transition - } - - return (function (a, b) { - if (a === b) { - return true; // catch the most you can - } else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || hoozit(a) !== hoozit(b)) { - return false; // don't lose time with error prone cases - } else { - return bindCallbacks(a, callbacks, [b, a]); - } - - // apply transition with (1..n) arguments - })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1)); - }; - - return innerEquiv; - -}(); - -/** - * jsDump - * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com - * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) - * Date: 5/15/2008 - * @projectDescription Advanced and extensible data dumping for Javascript. - * @version 1.0.0 - * @author Ariel Flesler - * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html} - */ -QUnit.jsDump = (function() { - function quote( str ) { - return '"' + str.toString().replace(/"/g, '\\"') + '"'; - }; - function literal( o ) { - return o + ''; - }; - function join( pre, arr, post ) { - var s = jsDump.separator(), - base = jsDump.indent(), - inner = jsDump.indent(1); - if ( arr.join ) - arr = arr.join( ',' + s + inner ); - if ( !arr ) - return pre + post; - return [ pre, inner + arr, base + post ].join(s); - }; - function array( arr ) { - var i = arr.length, ret = Array(i); - this.up(); - while ( i-- ) - ret[i] = this.parse( arr[i] ); - this.down(); - return join( '[', ret, ']' ); - }; - - var reName = /^function (\w+)/; - - var jsDump = { - parse:function( obj, type ) { //type is used mostly internally, you can fix a (custom)type in advance - var parser = this.parsers[ type || this.typeOf(obj) ]; - type = typeof parser; - - return type == 'function' ? parser.call( this, obj ) : - type == 'string' ? parser : - this.parsers.error; - }, - typeOf:function( obj ) { - var type; - if ( obj === null ) { - type = "null"; - } else if (typeof obj === "undefined") { - type = "undefined"; - } else if (QUnit.is("RegExp", obj)) { - type = "regexp"; - } else if (QUnit.is("Date", obj)) { - type = "date"; - } else if (QUnit.is("Function", obj)) { - type = "function"; - } else if (QUnit.is("Array", obj)) { - type = "array"; - } else if (QUnit.is("Window", obj) || QUnit.is("global", obj)) { - type = "window"; - } else if (QUnit.is("HTMLDocument", obj)) { - type = "document"; - } else if (QUnit.is("HTMLCollection", obj) || QUnit.is("NodeList", obj)) { - type = "nodelist"; - } else if (/^\[object HTML/.test(Object.prototype.toString.call( obj ))) { - type = "node"; - } else { - type = typeof obj; - } - return type; - }, - separator:function() { - return this.multiline ? this.HTML ? '
                  ' : '\n' : this.HTML ? ' ' : ' '; - }, - indent:function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing - if ( !this.multiline ) - return ''; - var chr = this.indentChar; - if ( this.HTML ) - chr = chr.replace(/\t/g,' ').replace(/ /g,' '); - return Array( this._depth_ + (extra||0) ).join(chr); - }, - up:function( a ) { - this._depth_ += a || 1; - }, - down:function( a ) { - this._depth_ -= a || 1; - }, - setParser:function( name, parser ) { - this.parsers[name] = parser; - }, - // The next 3 are exposed so you can use them - quote:quote, - literal:literal, - join:join, - // - _depth_: 1, - // This is the list of parsers, to modify them, use jsDump.setParser - parsers:{ - window: '[Window]', - document: '[Document]', - error:'[ERROR]', //when no parser is found, shouldn't happen - unknown: '[Unknown]', - 'null':'null', - undefined:'undefined', - 'function':function( fn ) { - var ret = 'function', - name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE - if ( name ) - ret += ' ' + name; - ret += '('; - - ret = [ ret, this.parse( fn, 'functionArgs' ), '){'].join(''); - return join( ret, this.parse(fn,'functionCode'), '}' ); - }, - array: array, - nodelist: array, - arguments: array, - object:function( map ) { - var ret = [ ]; - this.up(); - for ( var key in map ) - ret.push( this.parse(key,'key') + ': ' + this.parse(map[key]) ); - this.down(); - return join( '{', ret, '}' ); - }, - node:function( node ) { - var open = this.HTML ? '<' : '<', - close = this.HTML ? '>' : '>'; - - var tag = node.nodeName.toLowerCase(), - ret = open + tag; - - for ( var a in this.DOMAttrs ) { - var val = node[this.DOMAttrs[a]]; - if ( val ) - ret += ' ' + a + '=' + this.parse( val, 'attribute' ); - } - return ret + close + open + '/' + tag + close; - }, - functionArgs:function( fn ) {//function calls it internally, it's the arguments part of the function - var l = fn.length; - if ( !l ) return ''; - - var args = Array(l); - while ( l-- ) - args[l] = String.fromCharCode(97+l);//97 is 'a' - return ' ' + args.join(', ') + ' '; - }, - key:quote, //object calls it internally, the key part of an item in a map - functionCode:'[code]', //function calls it internally, it's the content of the function - attribute:quote, //node calls it internally, it's an html attribute value - string:quote, - date:quote, - regexp:literal, //regex - number:literal, - 'boolean':literal - }, - DOMAttrs:{//attributes to dump from nodes, name=>realName - id:'id', - name:'name', - 'class':'className' - }, - HTML:true,//if true, entities are escaped ( <, >, \t, space and \n ) - indentChar:' ',//indentation unit - multiline:true //if true, items in a collection, are separated by a \n, else just a space. - }; - - return jsDump; -})(); - -})(this); diff --git a/tests/CoreLib/QUnitExt.js b/tests/CoreLib/QUnitExt.js deleted file mode 100644 index fa1d73b9a..000000000 --- a/tests/CoreLib/QUnitExt.js +++ /dev/null @@ -1,44 +0,0 @@ -(function() { - var currentModule = null; - var logData = ''; - - function appendLog(logText) { - logData = logData + logText + '\r\n'; - - var logHolder = document.getElementById('qunit-log'); - if (logHolder) { - logHolder.value = logData; - } - } - - QUnit.log = function(result, message) { - if (arguments.length === 1) { - message = arguments[0]; - } - appendLog(' ' + message); - } - - QUnit.done = function(failures, total) { - appendLog('\r\nCompleted; ' + 'failures = ' + failures + '; total = ' + total); - } - - QUnit.testStart = function(name) { - appendLog(' Test Started: ' + name); - } - - QUnit.testDone = function(name, failures, total) { - appendLog(' Test Done: ' + name + '; failures = ' + failures + '; total = ' + total); - } - - QUnit.moduleStart = function(name, testEnv) { - currentModule = name; - appendLog('Module Started: ' + name); - } - - QUnit.moduleDone = function(name, failures, total) { - if (name === currentModule) { - appendLog('Module Done: ' + name + '; failures = ' + failures + '; total = ' + total + '\r\n'); - } - currentModule = null; - } -})(); diff --git a/tests/CoreLib/TestArray.htm b/tests/CoreLib/TestArray.htm deleted file mode 100644 index 6589857ba..000000000 --- a/tests/CoreLib/TestArray.htm +++ /dev/null @@ -1,29 +0,0 @@ - - - - Test - Array - - - - - -

                  Test Results

                  -

                  -

                  -
                    -
                    - - - - - diff --git a/tests/CoreLib/TestDelegate.htm b/tests/CoreLib/TestDelegate.htm deleted file mode 100644 index e369968fe..000000000 --- a/tests/CoreLib/TestDelegate.htm +++ /dev/null @@ -1,148 +0,0 @@ - - - - Test - Delegate - - - - - -

                    Test Results

                    -

                    -

                    -
                      -
                      - - - - - diff --git a/tests/CoreLib/TestEnum.htm b/tests/CoreLib/TestEnum.htm deleted file mode 100644 index f1d06eb24..000000000 --- a/tests/CoreLib/TestEnum.htm +++ /dev/null @@ -1,46 +0,0 @@ - - - - Test - Enum - - - - - -

                      Test Results

                      -

                      -

                      -
                        -
                        - - - - - diff --git a/tests/CoreLib/TestOOP.htm b/tests/CoreLib/TestOOP.htm deleted file mode 100644 index a576bb95e..000000000 --- a/tests/CoreLib/TestOOP.htm +++ /dev/null @@ -1,112 +0,0 @@ - - - - Test - OOP - - - - - -

                        Test Results

                        -

                        -

                        -
                          -
                          - - - - - - diff --git a/tests/CoreLib/TestOOP.js b/tests/CoreLib/TestOOP.js deleted file mode 100644 index eb54a34de..000000000 --- a/tests/CoreLib/TestOOP.js +++ /dev/null @@ -1,94 +0,0 @@ -Type.registerNamespace('Test'); -Type.registerNamespace('Test.More'); - -//////////////////////////////////////////////////////////////////////////////// -// Test.IMammal - -Test.IMammal = function() { }; -Test.IMammal.prototype = { - -} -Test.IMammal.registerInterface('Test.IMammal'); - - -//////////////////////////////////////////////////////////////////////////////// -// Test.IPet - -Test.IPet = function() { }; -Test.IPet.prototype = { - get_name : null, - get_owner : null -} -Test.IPet.registerInterface('Test.IPet'); - - -//////////////////////////////////////////////////////////////////////////////// -// Test.Animal - -Test.Animal = function Test_Animal(species) { - this._species = species; -} -Test.Animal.prototype = { - _species: null, - - get_species: function Test_Animal$get_species() { - return this._species; - } -} - - -//////////////////////////////////////////////////////////////////////////////// -// Test.Cat - -Test.Cat = function Test_Cat() { - Test.Cat.initializeBase(this, [ 'Cat' ]); -} -Test.Cat.prototype = { - - speak: function Test_Cat$speak() { - return 'meow'; - } -} - - -//////////////////////////////////////////////////////////////////////////////// -// Test.Garfield - -Test.Garfield = function Test_Garfield() { - Test.Garfield.initializeBase(this); -} -Test.Garfield.prototype = { - - get_name: function Test_Garfield$get_name() { - return 'Garfield'; - }, - - get_owner: function Test_Garfield$get_owner() { - return 'Jon'; - }, - - speak: function Test_Garfield$speak() { - return Test.Garfield.callBaseMethod(this, 'speak') + '\r\n' + 'I am fat, lazy, and cynical, but still, a favorite cat...'; - } -} - - -//////////////////////////////////////////////////////////////////////////////// -// Test.More.Comic - -Test.More.Comic = function(name) { - this._name = name; -} -Test.More.Comic.prototype = { - - get_name: function() { - return this._name; - } -} - - - -Test.Animal.registerClass('Test.Animal'); -Test.Cat.registerClass('Test.Cat', Test.Animal, Test.IMammal); -Test.Garfield.registerClass('Test.Garfield', Test.Cat, Test.IPet); -Test.More.Comic.registerClass('Test.More.Comic'); diff --git a/tests/CoreLib/TestObject.htm b/tests/CoreLib/TestObject.htm deleted file mode 100644 index 1ad2fbab5..000000000 --- a/tests/CoreLib/TestObject.htm +++ /dev/null @@ -1,54 +0,0 @@ - - - - Test - Object - - - - - -

                          Test Results

                          -

                          -

                          -
                            -
                            - - - - - diff --git a/tests/CoreLib/TestObservable.htm b/tests/CoreLib/TestObservable.htm deleted file mode 100644 index 8ab72de5f..000000000 --- a/tests/CoreLib/TestObservable.htm +++ /dev/null @@ -1,136 +0,0 @@ - - - - Test - Observable - - - - - -

                            Test Results

                            -

                            -

                            -
                              -
                              - - - - - diff --git a/tests/CoreLib/TestStartup.htm b/tests/CoreLib/TestStartup.htm deleted file mode 100644 index 85c698ea2..000000000 --- a/tests/CoreLib/TestStartup.htm +++ /dev/null @@ -1,52 +0,0 @@ - - - - Test - Startup - - - - - -

                              Test Results

                              -

                              -

                              -
                                -
                                - - - - - - - diff --git a/tests/CoreLib/TestString.htm b/tests/CoreLib/TestString.htm deleted file mode 100644 index a7ff3ef1d..000000000 --- a/tests/CoreLib/TestString.htm +++ /dev/null @@ -1,108 +0,0 @@ - - - - Test - String - - - - - -

                                Test Results

                                -

                                -

                                -
                                  -
                                  - - - - - diff --git a/tests/CoreLib/TestStringBuilder.htm b/tests/CoreLib/TestStringBuilder.htm deleted file mode 100644 index 0108553ac..000000000 --- a/tests/CoreLib/TestStringBuilder.htm +++ /dev/null @@ -1,68 +0,0 @@ - - - - Test - StringBuilder - - - - - -

                                  Test Results

                                  -

                                  -

                                  -
                                    -
                                    - - - - - diff --git a/tests/CoreLib/TestTask.htm b/tests/CoreLib/TestTask.htm deleted file mode 100644 index e37d041c1..000000000 --- a/tests/CoreLib/TestTask.htm +++ /dev/null @@ -1,295 +0,0 @@ - - - - Test - Task - - - - - -

                                    Test Results

                                    -

                                    -

                                    -
                                      -
                                      - - - - - diff --git a/tests/CoreLib/Tests.htm b/tests/CoreLib/Tests.htm deleted file mode 100644 index 1508b141f..000000000 --- a/tests/CoreLib/Tests.htm +++ /dev/null @@ -1,52 +0,0 @@ - - - - Tests - - - -

                                      mscorlib.js Tests

                                      -
                                      -

                                      Infrastructure

                                      -
                                      -
                                      TestStartup
                                      -
                                      Tests startup/loader functionlity
                                      -
                                      -
                                      -

                                      Type System

                                      -
                                      -
                                      TestOOP
                                      -
                                      Tests classes, interfaces and related APIs
                                      -
                                      TestDelegate
                                      -
                                      Tests delegates
                                      -
                                      TestEnum
                                      -
                                      Tests enums
                                      -
                                      -
                                      -

                                      Script Extensions

                                      -
                                      -
                                      TestObject
                                      -
                                      Tests object extensions
                                      -
                                      TestString
                                      -
                                      Tests string extensions
                                      -
                                      TestArray
                                      -
                                      Tests array extensions
                                      -
                                      -
                                      -

                                      Script BCL

                                      -
                                      -
                                      TestStringBuilder
                                      -
                                      Test StringBuilder functionality
                                      -
                                      TestObservable
                                      -
                                      Test Observable and change notifications
                                      -
                                      TestTask
                                      -
                                      Test Deferred and Task
                                      -
                                      - - From ff458bb05a52416816e776f4407273eb3031c3b3 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sat, 15 Sep 2012 02:23:57 -0700 Subject: [PATCH 019/251] First round of script generation changes [wip] - AMD pattern, and new type system - Cleanup debug mode output by not outputing debug fn names --- src/Core/Compiler/Compiler.csproj | 1 - src/Core/Compiler/Compiler/CodeBuilder.cs | 7 +- .../Compiler/ImplementationBuilder.cs | 21 +- src/Core/Compiler/Compiler/MetadataBuilder.cs | 2 +- .../Compiler/Generator/DocCommentGenerator.cs | 40 +- .../Compiler/Generator/ExpressionGenerator.cs | 156 +++-- .../Compiler/Generator/MemberGenerator.cs | 183 ++---- .../Compiler/Generator/NamespaceGenerator.cs | 65 --- .../Compiler/Generator/ScriptGenerator.cs | 217 +++++-- .../Compiler/Generator/ScriptTextWriter.cs | 52 +- .../Compiler/Generator/StatementGenerator.cs | 157 ++--- src/Core/Compiler/Generator/TypeGenerator.cs | 388 ++++--------- src/Core/Compiler/ScriptCompiler.cs | 39 +- .../ScriptModel/Symbols/SymbolSetDumper.cs | 8 +- .../ScriptModel/Symbols/TypeSymbol.cs | 20 +- tests/ScriptSharp/BasicTests.cs | 2 - .../Basic/Conditionals/DebugBaseline.txt | 62 +- .../Basic/Conditionals/TraceBaseline.txt | 52 +- .../Basic/Dependencies/Code1Baseline.txt | 24 +- .../Basic/Dependencies/Code2Baseline.txt | 24 +- .../TestCases/Basic/Dependencies/Template.js | 6 - .../TestCases/Basic/DocComments/Baseline.txt | 385 ++++++------- tests/TestCases/Basic/Flags/Baseline.txt | 33 +- tests/TestCases/Basic/Metadata/Baseline.txt | 545 +++++++----------- .../TestCases/Basic/Minimization/Baseline.txt | 421 +++++++------- tests/TestCases/Basic/Resources/Baseline.txt | 50 +- tests/TestCases/Basic/Simple/Baseline.txt | 87 ++- tests/TestCases/Basic/Template/Baseline.txt | 22 +- tests/TestCases/Basic/UnitTest/Code.cs | 3 + .../Basic/UnitTest/NonTestBaseline.txt | 50 +- .../TestCases/Basic/UnitTest/TestBaseline.txt | 153 ++--- .../Expression/AnonymousMethods/Baseline.txt | 89 +-- .../Expression/Arguments/Baseline.txt | 30 +- tests/TestCases/Expression/Base/Baseline.txt | 50 +- .../TestCases/Expression/Binary/Baseline.txt | 169 +++--- tests/TestCases/Expression/Cast/Baseline.txt | 68 ++- .../Expression/Conditional/Baseline.txt | 36 +- .../Expression/Delegates/Baseline.txt | 78 +-- .../Expression/Dictionary/Baseline.txt | 76 +-- .../Expression/EnumToString/MinBaseline.txt | 40 +- .../EnumToString/NormalBaseline.txt | 71 ++- .../TestCases/Expression/Events/Baseline.txt | 127 ++-- .../Expression/Generics/Baseline.txt | 48 +- tests/TestCases/Expression/Generics/Code.cs | 8 +- .../TestCases/Expression/GetType/Baseline.txt | 33 +- .../Expression/GlobalMethods/Baseline.txt | 37 +- .../Expression/InlineScript/Baseline.txt | 36 +- .../Expression/LateBound/Baseline.txt | 82 +-- .../Expression/Literals/Baseline.txt | 74 +-- .../TestCases/Expression/Locals/Baseline.txt | 49 +- .../TestCases/Expression/Members/Baseline.txt | 168 +++--- tests/TestCases/Expression/New/Baseline.txt | 74 ++- .../TestCases/Expression/Number/Baseline.txt | 32 +- .../TestCases/Expression/Script/Baseline.txt | 32 +- tests/TestCases/Expression/Script/Code.cs | 2 +- .../TestCases/Expression/String/Baseline.txt | 40 +- .../TestCases/Expression/Truthy/Baseline.txt | 122 ++-- tests/TestCases/Expression/Unary/Baseline.txt | 82 +-- tests/TestCases/Library/jQuery/Baseline.txt | 60 +- .../Member/Constructors/Baseline.txt | 70 ++- tests/TestCases/Member/Events/Baseline.txt | 78 +-- tests/TestCases/Member/Fields/Baseline.txt | 105 ++-- tests/TestCases/Member/Fields/Code.cs | 1 - tests/TestCases/Member/Indexers/Baseline.txt | 275 ++++----- tests/TestCases/Member/Methods/Baseline.txt | 107 ++-- tests/TestCases/Member/Overloads/Baseline.txt | 48 +- .../TestCases/Member/Properties/Baseline.txt | 67 ++- .../Member/StaticConstructors/Baseline.txt | 101 ++-- .../Statement/Exceptions/Baseline.txt | 75 +-- .../Statement/Expression/Baseline.txt | 32 +- tests/TestCases/Statement/For/Baseline.txt | 58 +- .../TestCases/Statement/Foreach/Baseline.txt | 88 +-- tests/TestCases/Statement/IfElse/Baseline.txt | 62 +- tests/TestCases/Statement/Return/Baseline.txt | 46 +- tests/TestCases/Statement/Switch/Baseline.txt | 100 ++-- .../Statement/Variables/Baseline.txt | 58 +- tests/TestCases/Statement/While/Baseline.txt | 52 +- tests/TestCases/Type/Classes/Baseline.txt | 76 ++- tests/TestCases/Type/Classes/Code.cs | 2 +- tests/TestCases/Type/Delegates/Baseline.txt | 22 +- tests/TestCases/Type/Enumerator/Baseline.txt | 81 +-- tests/TestCases/Type/Enumerator/Code.cs | 4 +- tests/TestCases/Type/Enums/Baseline.txt | 140 +++-- tests/TestCases/Type/Globals/Baseline.txt | 110 ++-- tests/TestCases/Type/Imported/Baseline.txt | 22 +- tests/TestCases/Type/Interfaces/Baseline.txt | 108 ++-- tests/TestCases/Type/Namespaces/Baseline.txt | 124 ++-- tests/TestCases/Type/Nullable/Baseline.txt | 60 +- tests/TestCases/Type/Partials/Baseline.txt | 205 ++++--- tests/TestCases/Type/Records/Baseline.txt | 26 +- tests/TestCases/Type/UsingAlias/Baseline.txt | 22 +- 91 files changed, 3732 insertions(+), 3781 deletions(-) delete mode 100644 src/Core/Compiler/Generator/NamespaceGenerator.cs delete mode 100644 tests/TestCases/Basic/Dependencies/Template.js diff --git a/src/Core/Compiler/Compiler.csproj b/src/Core/Compiler/Compiler.csproj index 7f14af864..6355628d5 100644 --- a/src/Core/Compiler/Compiler.csproj +++ b/src/Core/Compiler/Compiler.csproj @@ -465,7 +465,6 @@ - diff --git a/src/Core/Compiler/Compiler/CodeBuilder.cs b/src/Core/Compiler/Compiler/CodeBuilder.cs index b1860caa8..4c42e4181 100644 --- a/src/Core/Compiler/Compiler/CodeBuilder.cs +++ b/src/Core/Compiler/Compiler/CodeBuilder.cs @@ -115,9 +115,12 @@ private void BuildCode(EventSymbol eventSymbol) { private void BuildCode(FieldSymbol fieldSymbol) { ImplementationBuilder implBuilder = new ImplementationBuilder(_options, _errorHandler); - fieldSymbol.AddImplementation(implBuilder.BuildField(fieldSymbol)); + SymbolImplementation implementation = implBuilder.BuildField(fieldSymbol); - _implementations.Add(fieldSymbol.Implementation); + if (implementation != null) { + fieldSymbol.AddImplementation(implementation); + _implementations.Add(fieldSymbol.Implementation); + } } private void BuildCode(IndexerSymbol indexerSymbol) { diff --git a/src/Core/Compiler/Compiler/ImplementationBuilder.cs b/src/Core/Compiler/Compiler/ImplementationBuilder.cs index 6840b5ce9..ab6eb5f62 100644 --- a/src/Core/Compiler/Compiler/ImplementationBuilder.cs +++ b/src/Core/Compiler/Compiler/ImplementationBuilder.cs @@ -104,7 +104,7 @@ public SymbolImplementation BuildField(FieldSymbol fieldSymbol) { _rootScope = new SymbolScope((ISymbolTable)fieldSymbol.Parent); _currentScope = _rootScope; - Expression initializerExpression; + Expression initializerExpression = null; FieldDeclarationNode fieldDeclarationNode = (FieldDeclarationNode)fieldSymbol.ParseContext; Debug.Assert(fieldDeclarationNode != null); @@ -150,15 +150,22 @@ public SymbolImplementation BuildField(FieldSymbol fieldSymbol) { defaultValue = false; } - initializerExpression = - new LiteralExpression(symbolSet.ResolveIntrinsicType(IntrinsicType.Object), - defaultValue); + if (defaultValue != null) { + initializerExpression = + new LiteralExpression(symbolSet.ResolveIntrinsicType(IntrinsicType.Object), + defaultValue); + fieldSymbol.SetImplementationState(/* hasInitializer */ true); + } } - List statements = new List(); - statements.Add(new ExpressionStatement(initializerExpression, /* isFragment */ true)); + if (initializerExpression != null) { + List statements = new List(); + statements.Add(new ExpressionStatement(initializerExpression, /* isFragment */ true)); + + return new SymbolImplementation(statements, null); + } - return new SymbolImplementation(statements, null); + return null; } public SymbolImplementation BuildMethod(MethodSymbol methodSymbol) { diff --git a/src/Core/Compiler/Compiler/MetadataBuilder.cs b/src/Core/Compiler/Compiler/MetadataBuilder.cs index f6c7dc2fa..ee3d1271d 100644 --- a/src/Core/Compiler/Compiler/MetadataBuilder.cs +++ b/src/Core/Compiler/Compiler/MetadataBuilder.cs @@ -84,7 +84,7 @@ private FieldSymbol BuildField(FieldDeclarationNode fieldNode, TypeSymbol typeSy if (fieldNode.Initializers.Count != 0) { VariableInitializerNode initializer = (VariableInitializerNode)fieldNode.Initializers[0]; - if ((initializer.Value != null) && (initializer.Value.NodeType != ParseNodeType.Literal)) { + if (initializer.Value != null) { symbol.SetImplementationState(/* hasInitializer */ true); } } diff --git a/src/Core/Compiler/Generator/DocCommentGenerator.cs b/src/Core/Compiler/Generator/DocCommentGenerator.cs index bc6ce1f2e..a3e7b9fdb 100644 --- a/src/Core/Compiler/Generator/DocCommentGenerator.cs +++ b/src/Core/Compiler/Generator/DocCommentGenerator.cs @@ -3,14 +3,14 @@ // This source code is subject to terms and conditions of the Apache License, Version 2.0. // -namespace ScriptSharp.Generator { +using System; +using System.Diagnostics; +using System.IO; +using System.Text; +using System.Xml; +using ScriptSharp.ScriptModel; - using System; - using System.Diagnostics; - using System.IO; - using System.Text; - using System.Xml; - using ScriptSharp.ScriptModel; +namespace ScriptSharp.Generator { internal static class DocCommentGenerator { @@ -22,7 +22,7 @@ public static void GenerateComment(ScriptGenerator generator, Symbol symbol) { GenerateClassComment(writer, (ClassSymbol)symbol); break; case SymbolType.Enumeration: - GenerateEnumerationComment(writer, (EnumerationSymbol)symbol); + // No-op - no doc-comments get generated for enums. break; case SymbolType.Event: GenerateEventComment(writer, (EventSymbol)symbol); @@ -74,7 +74,7 @@ private static void GenerateFormattedComment(ScriptTextWriter writer, string tex } private static void GenerateInterfaceComment(ScriptTextWriter writer, InterfaceSymbol interfaceSymbol) { - writer.WriteNewLine(); + writer.WriteLine(); writer.Indent++; GenerateSummaryComment(writer, interfaceSymbol); @@ -100,28 +100,6 @@ private static void GenerateEventComment(ScriptTextWriter writer, EventSymbol ev writer.WriteLine("/// ", eventSymbol.Parameters[0].Name); } - private static void GenerateEnumerationComment(ScriptTextWriter writer, EnumerationSymbol enumSymbol) { - writer.WriteNewLine(); - writer.Indent++; - - GenerateSummaryComment(writer, enumSymbol); - - foreach (MemberSymbol memberSymbol in enumSymbol.Members) { - EnumerationFieldSymbol fieldSymbol = memberSymbol as EnumerationFieldSymbol; - if (fieldSymbol != null) { - writer.WriteLine( - "/// ", - fieldSymbol.GeneratedName); - - GenerateFormattedComment(writer, fieldSymbol.Documentation); - - writer.WriteLine("/// "); - } - } - - writer.Indent--; - } - private static void GenerateFieldComment(ScriptTextWriter writer, FieldSymbol fieldSymbol) { writer.Write("/// 0) { - writer.WriteTrimmed(", "); + writer.Write(", "); } if (obfuscateParams) { if (paramIndex == 0) { @@ -269,9 +286,7 @@ private static void GenerateDelegateExpression(ScriptGenerator generator, Member paramIndex++; } } - writer.Write(")"); - writer.WriteTrimmed(" {"); - writer.WriteLine(); + writer.WriteLine(") {"); writer.Indent++; CodeGenerator.GenerateScript(generator, anonymousMethod); writer.Indent--; @@ -396,7 +411,7 @@ public static void GenerateExpressionList(ScriptGenerator generator, MemberSymbo bool firstExpression = true; foreach (Expression expression in expressions) { if (firstExpression == false) { - writer.WriteTrimmed(", "); + writer.Write(", "); } GenerateExpression(generator, symbol, expression); firstExpression = false; @@ -413,11 +428,11 @@ private static void GenerateExpressionListAsNameValuePairs(ScriptGenerator gener foreach (Expression expression in expressions) { if ((firstExpression == false) && (valueExpression == false)) { - writer.WriteTrimmed(", "); + writer.Write(", "); } if (valueExpression) { - writer.WriteTrimmed(": "); + writer.Write(": "); GenerateExpression(generator, symbol, expression); valueExpression = false; @@ -467,13 +482,21 @@ private static void GenerateIndexerExpression(ScriptGenerator generator, MemberS else if (expression.ObjectReference is BaseExpression) { Debug.Assert(symbol.Parent is ClassSymbol); - writer.Write(((ClassSymbol)symbol.Parent).FullGeneratedName); - writer.Write(".callBaseMethod(this, 'get_"); + ClassSymbol baseClass = ((ClassSymbol)symbol.Parent).BaseClass; + Debug.Assert(baseClass != null); + + writer.Write(baseClass.FullGeneratedName); + if (baseClass.IsApplicationType) { + writer.Write("$."); + } + else { + writer.Write(".prototype."); + } + writer.Write("get_"); writer.Write(expression.Indexer.GeneratedName); - writer.Write("',"); - writer.WriteTrimmed(" [ "); + writer.Write(".call(this, "); GenerateExpressionList(generator, symbol, expression.Indices); - writer.WriteTrimmed(" ])"); + writer.Write(")"); } else { GenerateExpression(generator, expression.Indexer, expression.ObjectReference); @@ -593,7 +616,7 @@ private static void GenerateLateBoundExpression(ScriptGenerator generator, Membe writer.Write("]"); } - writer.WriteTrimmed(" = "); + writer.Write(" = "); GenerateExpressionList(generator, symbol, expression.Parameters); break; case LateBoundOperation.DeleteField: @@ -626,10 +649,7 @@ private static void GenerateLateBoundExpression(ScriptGenerator generator, Membe writer.Write("]"); } - writer.Write(")"); - writer.WriteTrimmed(" === "); - writer.Write("'function'"); - writer.Write(")"); + writer.Write(") === 'function')"); break; } } @@ -664,9 +684,9 @@ private static void GenerateLiteralExpression(ScriptGenerator generator, MemberS textValue = "[]"; } else { - writer.WriteTrimmed("[ "); + writer.Write("[ "); GenerateExpressionList(generator, symbol, (Expression[])value); - writer.WriteTrimmed(" ]"); + writer.Write(" ]"); } } else { @@ -700,15 +720,21 @@ private static void GenerateMethodExpression(ScriptGenerator generator, MemberSy Debug.Assert(symbol.Parent is ClassSymbol); Debug.Assert(expression.Method.IsGlobalMethod == false); - writer.Write(((ClassSymbol)symbol.Parent).FullGeneratedName); - writer.Write(".callBaseMethod(this, '"); + ClassSymbol baseClass = ((ClassSymbol)symbol.Parent).BaseClass; + Debug.Assert(baseClass != null); + + writer.Write(baseClass.FullGeneratedName); + if (baseClass.IsApplicationType) { + writer.Write("$."); + } + else { + writer.Write(".prototype."); + } writer.Write(expression.Method.GeneratedName); - writer.Write("'"); + writer.Write(".call(this"); if ((expression.Parameters != null) && (expression.Parameters.Count != 0)) { - writer.Write(","); - writer.WriteTrimmed(" [ "); + writer.Write(", "); GenerateExpressionList(generator, symbol, expression.Parameters); - writer.WriteTrimmed(" ]"); } writer.Write(")"); } @@ -767,19 +793,14 @@ private static void GenerateNewExpression(ScriptGenerator generator, MemberSymbo writer.Write("{}"); } else { - writer.WriteTrimmed("{ "); + writer.Write("{ "); GenerateExpressionListAsNameValuePairs(generator, symbol, expression.Parameters); - writer.WriteTrimmed(" }"); + writer.Write(" }"); } return; } else if (expression.AssociatedType.Type == SymbolType.Record) { - if (expression.AssociatedType.IgnoreNamespace == false) { - writer.Write(expression.AssociatedType.GeneratedNamespace); - writer.Write("."); - } - writer.Write("$create_"); - writer.Write(expression.AssociatedType.GeneratedName); + writer.Write(expression.AssociatedType.FullGeneratedName); writer.Write("("); if (expression.Parameters != null) { GenerateExpressionList(generator, symbol, expression.Parameters); @@ -811,10 +832,19 @@ private static void GeneratePropertyExpression(ScriptGenerator generator, Member if (expression.ObjectReference is BaseExpression) { Debug.Assert(symbol.Parent is ClassSymbol); - writer.Write(((ClassSymbol)symbol.Parent).FullGeneratedName); - writer.Write(".callBaseMethod(this, 'get_"); + ClassSymbol baseClass = ((ClassSymbol)symbol.Parent).BaseClass; + Debug.Assert(baseClass != null); + + writer.Write(baseClass.FullGeneratedName); + if (baseClass.IsApplicationType) { + writer.Write("$."); + } + else { + writer.Write(".prototype."); + } + writer.Write("get_"); writer.Write(expression.Property.GeneratedName); - writer.Write("')"); + writer.Write(".call(this)"); } else { ExpressionGenerator.GenerateExpression(generator, symbol, expression.ObjectReference); @@ -854,18 +884,18 @@ private static void GenerateUnaryExpression(ScriptGenerator generator, MemberSym writer.Write(propExpression.Property.GeneratedName); writer.Write("()"); if ((expression.Operator == Operator.PreIncrement) || (expression.Operator == Operator.PostIncrement)) { - writer.WriteTrimmed(" + "); + writer.Write(" + "); fudgeOperator = " - "; } else { - writer.WriteTrimmed(" - "); + writer.Write(" - "); fudgeOperator = " + "; } writer.Write("1"); writer.Write(")"); if ((expression.Operator == Operator.PreIncrement) || (expression.Operator == Operator.PreDecrement)) { - writer.WriteTrimmed(fudgeOperator); + writer.Write(fudgeOperator); writer.Write("1"); } diff --git a/src/Core/Compiler/Generator/MemberGenerator.cs b/src/Core/Compiler/Generator/MemberGenerator.cs index a9181fb7c..a6193fefe 100644 --- a/src/Core/Compiler/Generator/MemberGenerator.cs +++ b/src/Core/Compiler/Generator/MemberGenerator.cs @@ -17,12 +17,6 @@ private static void GenerateEvent(ScriptGenerator generator, string typeName, Ev ScriptTextWriter writer = generator.Writer; ParameterSymbol valueParameter = eventSymbol.Parameters[0]; - if (generator.Options.Minimize) { - bool obfuscateParams = !eventSymbol.IsPublic; - if (obfuscateParams) { - valueParameter.SetTransformedName("$p0"); - } - } string eventName = eventSymbol.GeneratedName; string fieldName = eventName; @@ -56,23 +50,14 @@ private static void GenerateEvent(ScriptGenerator generator, string typeName, Ev writer.Write("add_"); writer.Write(eventName); if (instanceMember) { - writer.WriteTrimmed(": "); + writer.Write(": "); } else { - writer.WriteTrimmed(" = "); + writer.Write(" = "); } - writer.Write("function"); - if (generator.Options.DebugFlavor) { - writer.Write(" "); - writer.Write(typeName.Replace(".", "_")); - writer.Write("$add_"); - writer.Write(eventName); - } - writer.Write("("); + writer.Write("function("); writer.Write(valueParameter.GeneratedName); - writer.Write(")"); - writer.WriteTrimmed(" {"); - writer.WriteNewLine(); + writer.WriteLine(") {"); writer.Indent++; if (generator.Options.EnableDocComments) { @@ -81,13 +66,11 @@ private static void GenerateEvent(ScriptGenerator generator, string typeName, Ev if (eventSymbol.DefaultImplementation) { writer.Write(fieldReference); - writer.WriteTrimmed(" = "); - writer.Write("ss.Delegate.combine("); + writer.Write(" = ss.Delegate.combine("); writer.Write(fieldReference); - writer.WriteTrimmed(", "); + writer.Write(", "); writer.Write(valueParameter.GeneratedName); - writer.Write(");"); - writer.WriteNewLine(); + writer.WriteLine(");"); } else { CodeGenerator.GenerateScript(generator, eventSymbol, /* add */ true); @@ -96,12 +79,11 @@ private static void GenerateEvent(ScriptGenerator generator, string typeName, Ev writer.Write("}"); if (instanceMember == false) { - writer.WriteSignificantNewLine(); + writer.WriteLine(); } if (instanceMember) { - writer.Write(","); - writer.WriteNewLine(); + writer.WriteLine(","); } else { writer.Write(typeName); @@ -110,23 +92,14 @@ private static void GenerateEvent(ScriptGenerator generator, string typeName, Ev writer.Write("remove_"); writer.Write(eventName); if (instanceMember) { - writer.WriteTrimmed(": "); + writer.Write(": "); } else { - writer.WriteTrimmed(" = "); - } - writer.Write("function"); - if (generator.Options.DebugFlavor) { - writer.Write(" "); - writer.Write(typeName.Replace(".", "_")); - writer.Write("$remove_"); - writer.Write(eventName); + writer.Write(" = "); } - writer.Write("("); + writer.Write("function("); writer.Write(valueParameter.GeneratedName); - writer.Write(")"); - writer.WriteTrimmed(" {"); - writer.WriteNewLine(); + writer.WriteLine(") {"); writer.Indent++; if (generator.Options.EnableDocComments) { @@ -135,13 +108,11 @@ private static void GenerateEvent(ScriptGenerator generator, string typeName, Ev if (eventSymbol.DefaultImplementation) { writer.Write(fieldReference); - writer.WriteTrimmed(" = "); - writer.Write("ss.Delegate.remove("); + writer.Write(" = ss.Delegate.remove("); writer.Write(fieldReference); - writer.WriteTrimmed(", "); + writer.Write(", "); writer.Write(valueParameter.GeneratedName); - writer.Write(");"); - writer.WriteNewLine(); + writer.WriteLine(");"); } else { CodeGenerator.GenerateScript(generator, eventSymbol, /* add */ false); @@ -150,7 +121,7 @@ private static void GenerateEvent(ScriptGenerator generator, string typeName, Ev writer.Write("}"); if (instanceMember == false) { - writer.WriteSignificantNewLine(); + writer.WriteLine(); } } @@ -166,16 +137,15 @@ private static void GenerateField(ScriptGenerator generator, string typeName, Fi writer.Write(fieldSymbol.GeneratedName); if (instanceMember) { - writer.WriteTrimmed(": "); + writer.Write(": "); } else { - writer.WriteTrimmed(" = "); + writer.Write(" = "); } CodeGenerator.GenerateScript(generator, fieldSymbol); if (instanceMember == false) { - writer.Write(";"); - writer.WriteNewLine(); + writer.WriteLine(";"); } } @@ -204,33 +174,23 @@ private static void GenerateIndexer(ScriptGenerator generator, string typeName, writer.Write("get_"); writer.Write(indexerSymbol.GeneratedName); if (instanceMember) { - writer.WriteTrimmed(": "); + writer.Write(": "); } else { - writer.WriteTrimmed(" = "); - } - - writer.Write("function"); - if (generator.Options.DebugFlavor) { - writer.Write(" "); - writer.Write(typeName.Replace(".", "_")); - writer.Write("$get_"); - writer.Write(indexerSymbol.GeneratedName); + writer.Write(" = "); } - writer.Write("("); + writer.Write("function("); for (int i = 0; i < indexerSymbol.Parameters.Count - 1; i++) { ParameterSymbol parameterSymbol = indexerSymbol.Parameters[i]; if (i > 0) { - writer.WriteTrimmed(", "); + writer.Write(", "); } writer.Write(parameterSymbol.GeneratedName); } - writer.Write(")"); - writer.WriteTrimmed(" {"); - writer.WriteNewLine(); + writer.WriteLine(") {"); writer.Indent++; if (generator.Options.EnableDocComments) { @@ -242,13 +202,12 @@ private static void GenerateIndexer(ScriptGenerator generator, string typeName, writer.Write("}"); if (instanceMember == false) { - writer.WriteSignificantNewLine(); + writer.WriteLine(); } if (indexerSymbol.IsReadOnly == false) { if (instanceMember) { - writer.Write(","); - writer.WriteNewLine(); + writer.WriteLine(","); } else { writer.Write(typeName); @@ -258,29 +217,20 @@ private static void GenerateIndexer(ScriptGenerator generator, string typeName, writer.Write("set_"); writer.Write(indexerSymbol.GeneratedName); if (instanceMember) { - writer.WriteTrimmed(": "); + writer.Write(": "); } else { - writer.WriteTrimmed(" = "); - } - writer.Write("function"); - if (generator.Options.DebugFlavor) { - writer.Write(" "); - writer.Write(typeName.Replace(".", "_")); - writer.Write("$set_"); - writer.Write(indexerSymbol.GeneratedName); + writer.Write(" = "); } - writer.Write("("); + writer.Write("function("); for (int i = 0; i < indexerSymbol.Parameters.Count; i++) { ParameterSymbol parameterSymbol = indexerSymbol.Parameters[i]; if (i > 0) { - writer.WriteTrimmed(", "); + writer.Write(", "); } writer.Write(parameterSymbol.GeneratedName); } - writer.Write(")"); - writer.WriteTrimmed(" {"); - writer.WriteNewLine(); + writer.WriteLine(") {"); writer.Indent++; if (generator.Options.EnableDocComments) { @@ -290,13 +240,12 @@ private static void GenerateIndexer(ScriptGenerator generator, string typeName, CodeGenerator.GenerateScript(generator, (IndexerSymbol)indexerSymbol, /* getter */ false); writer.Write("return "); writer.Write(indexerSymbol.Parameters[indexerSymbol.Parameters.Count - 1].GeneratedName); - writer.Write(";"); - writer.WriteNewLine(); + writer.WriteLine(";"); writer.Indent--; writer.Write("}"); if (instanceMember == false) { - writer.WriteSignificantNewLine(); + writer.WriteLine(); } } } @@ -316,7 +265,7 @@ private static void GenerateMethod(ScriptGenerator generator, string typeName, M mixinRoot = ((ClassSymbol)methodSymbol.Parent).MixinRoot; } if (String.IsNullOrEmpty(mixinRoot)) { - mixinRoot = "window"; + mixinRoot = "this"; } writer.Write(mixinRoot); @@ -330,20 +279,13 @@ private static void GenerateMethod(ScriptGenerator generator, string typeName, M writer.Write(methodSymbol.GeneratedName); if (instanceMember) { - writer.WriteTrimmed(": "); + writer.Write(": "); } else { - writer.WriteTrimmed(" = "); + writer.Write(" = "); } - writer.Write("function"); - if (generator.Options.DebugFlavor) { - writer.Write(" "); - writer.Write(typeName.Replace(".", "_")); - writer.Write("$"); - writer.Write(methodSymbol.GeneratedName); - } - writer.Write("("); + writer.Write("function("); if (methodSymbol.Parameters != null) { bool obfuscateParams = false; if (generator.Options.Minimize) { @@ -353,7 +295,7 @@ private static void GenerateMethod(ScriptGenerator generator, string typeName, M int paramIndex = 0; foreach (ParameterSymbol parameterSymbol in methodSymbol.Parameters) { if (paramIndex > 0) { - writer.WriteTrimmed(", "); + writer.Write(", "); } if (obfuscateParams) { parameterSymbol.SetTransformedName("$p" + paramIndex); @@ -363,9 +305,7 @@ private static void GenerateMethod(ScriptGenerator generator, string typeName, M paramIndex++; } } - writer.WriteTrimmed(") "); - writer.Write("{"); - writer.WriteNewLine(); + writer.WriteLine(") {"); writer.Indent++; if (generator.Options.EnableDocComments) { @@ -377,7 +317,7 @@ private static void GenerateMethod(ScriptGenerator generator, string typeName, M writer.Write("}"); if (instanceMember == false) { - writer.WriteSignificantNewLine(); + writer.WriteLine(); } } @@ -398,21 +338,12 @@ private static void GenerateProperty(ScriptGenerator generator, string typeName, writer.Write("get_"); writer.Write(propertySymbol.GeneratedName); if (instanceMember) { - writer.WriteTrimmed(": "); + writer.Write(": "); } else { - writer.WriteTrimmed(" = "); + writer.Write(" = "); } - writer.Write("function"); - if (generator.Options.DebugFlavor) { - writer.Write(" "); - writer.Write(typeName.Replace(".", "_")); - writer.Write("$get_"); - writer.Write(propertySymbol.GeneratedName); - } - writer.Write("()"); - writer.WriteTrimmed(" {"); - writer.WriteNewLine(); + writer.WriteLine("function() {"); writer.Indent++; if (generator.Options.EnableDocComments) { @@ -424,7 +355,7 @@ private static void GenerateProperty(ScriptGenerator generator, string typeName, writer.Write("}"); if (instanceMember == false) { - writer.WriteSignificantNewLine(); + writer.WriteLine(); } if (propertySymbol.IsReadOnly == false) { @@ -437,8 +368,7 @@ private static void GenerateProperty(ScriptGenerator generator, string typeName, } if (instanceMember) { - writer.Write(","); - writer.WriteNewLine(); + writer.WriteLine(","); } else { writer.Write(typeName); @@ -448,23 +378,14 @@ private static void GenerateProperty(ScriptGenerator generator, string typeName, writer.Write("set_"); writer.Write(propertySymbol.GeneratedName); if (instanceMember) { - writer.WriteTrimmed(": "); + writer.Write(": "); } else { - writer.WriteTrimmed(" = "); - } - writer.Write("function"); - if (generator.Options.DebugFlavor) { - writer.Write(" "); - writer.Write(typeName.Replace(".", "_")); - writer.Write("$set_"); - writer.Write(propertySymbol.GeneratedName); + writer.Write(" = "); } - writer.Write("("); + writer.Write("function("); writer.Write(valueParameter.GeneratedName); - writer.Write(")"); - writer.WriteTrimmed(" {"); - writer.WriteNewLine(); + writer.WriteLine(") {"); writer.Indent++; if (generator.Options.EnableDocComments) { @@ -475,12 +396,12 @@ private static void GenerateProperty(ScriptGenerator generator, string typeName, writer.Write("return "); writer.Write(valueParameter.GeneratedName); writer.Write(";"); - writer.WriteNewLine(); + writer.WriteLine(); writer.Indent--; writer.Write("}"); if (instanceMember == false) { - writer.WriteSignificantNewLine(); + writer.WriteLine(); } } } diff --git a/src/Core/Compiler/Generator/NamespaceGenerator.cs b/src/Core/Compiler/Generator/NamespaceGenerator.cs deleted file mode 100644 index b1d09bc89..000000000 --- a/src/Core/Compiler/Generator/NamespaceGenerator.cs +++ /dev/null @@ -1,65 +0,0 @@ -// NamespaceGenerator.cs -// Script#/Core/Compiler -// This source code is subject to terms and conditions of the Apache License, Version 2.0. -// - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using ScriptSharp; -using ScriptSharp.ScriptModel; - -namespace ScriptSharp.Generator { - - internal static class NamespaceGenerator { - - public static void GenerateScript(ScriptGenerator generator, NamespaceSymbol namespaceSymbol, Dictionary generatedNamespaces) { - Debug.Assert(generator != null); - Debug.Assert(namespaceSymbol != null); - Debug.Assert(namespaceSymbol.HasApplicationTypes); - - ScriptTextWriter writer = generator.Writer; - - // First generate enums and interfaces which do not have cross-dependencies - // (Classes for example, might have dependencies on enums) - - foreach (TypeSymbol type in namespaceSymbol.Types) { - if (type.IsApplicationType) { - if (type.IsTestType && (generator.Options.IncludeTests == false)) { - continue; - } - - string namespaceName = type.GeneratedNamespace; - if ((namespaceName.Length != 0) && - (generatedNamespaces.ContainsKey(namespaceName) == false)) { - writer.Write("Type.registerNamespace('"); - writer.Write(namespaceName); - writer.Write("');"); - writer.WriteNewLine(); - writer.WriteNewLine(); - generatedNamespaces[namespaceName] = true; - } - } - - if (type.IsApplicationType && - ((type.Type == SymbolType.Enumeration) || - (type.Type == SymbolType.Interface) || - (type.Type == SymbolType.Record) || - (type.Type == SymbolType.Resources))) { - TypeGenerator.GenerateScript(generator, type); - } - } - - foreach (TypeSymbol type in namespaceSymbol.Types) { - if (type.IsApplicationType && (type.Type == SymbolType.Class)) { - if (type.IsTestType && (generator.Options.IncludeTests == false)) { - continue; - } - - TypeGenerator.GenerateScript(generator, type); - } - } - } - } -} diff --git a/src/Core/Compiler/Generator/ScriptGenerator.cs b/src/Core/Compiler/Generator/ScriptGenerator.cs index 849b55fa8..a6aa1d33e 100644 --- a/src/Core/Compiler/Generator/ScriptGenerator.cs +++ b/src/Core/Compiler/Generator/ScriptGenerator.cs @@ -18,24 +18,14 @@ internal sealed class ScriptGenerator { private ScriptTextWriter _writer; private CompilerOptions _options; - private IErrorHandler _errorHandler; + private SymbolSet _symbols; - private List _classes; - - public ScriptGenerator(TextWriter writer, CompilerOptions options, IErrorHandler errorHandler) { + public ScriptGenerator(TextWriter writer, CompilerOptions options, SymbolSet symbols) { Debug.Assert(writer != null); - _writer = new ScriptTextWriter(writer, options); + _writer = new ScriptTextWriter(writer); _options = options; - _errorHandler = errorHandler; - - _classes = new List(); - } - - public IErrorHandler ErrorHandler { - get { - return _errorHandler; - } + _symbols = symbols; } public CompilerOptions Options { @@ -50,59 +40,190 @@ public ScriptTextWriter Writer { } } - public void AddGeneratedClass(ClassSymbol classSymbol) { - Debug.Assert(classSymbol != null); - _classes.Add(classSymbol); - } + public void GenerateScript(SymbolSet symbolSet) { + Debug.Assert(symbolSet != null); - private void GenerateClassRegistration(ClassSymbol classSymbol, List generatedClasses) { - Debug.Assert(classSymbol != null); + List types = new List(); + List publicTypes = new List(); + List internalTypes = new List(); - if (generatedClasses.Contains(classSymbol)) { - return; + foreach (NamespaceSymbol namespaceSymbol in symbolSet.Namespaces) { + if (namespaceSymbol.HasApplicationTypes) { + foreach (TypeSymbol type in namespaceSymbol.Types) { + if (type.IsApplicationType == false) { + continue; + } + + if (type.Type == SymbolType.Delegate) { + // Nothing needs to be generated for delegate types. + continue; + } + + if (type.IsTestType && (_options.IncludeTests == false)) { + continue; + } + + if ((type.Type == SymbolType.Enumeration) && (type.IsPublic == false)) { + // Internal enums can be skipped since their values have been inlined. + continue; + } + + types.Add(type); + if (type.IsPublic) { + publicTypes.Add(type); + } + else { + internalTypes.Add(type); + } + } + } } - ClassSymbol baseClass = classSymbol.BaseClass; - if ((baseClass != null) && baseClass.IsApplicationType) { - GenerateClassRegistration(baseClass, generatedClasses); - } + // Sort the types, so similar types of types are grouped, and parent classes + // come before derived classes. + types.Sort(new TypeComparer()); - TypeGenerator.GenerateClassRegistrationScript(this, classSymbol); - generatedClasses.Add(classSymbol); - } + string moduleName = symbolSet.ScriptName; - public void GenerateScript(SymbolSet symbolSet) { - Debug.Assert(symbolSet != null); + _writer.Write("define('"); + _writer.Write(moduleName); + _writer.Write("', ["); - Dictionary generatedNamespaces = new Dictionary(); - foreach (NamespaceSymbol namespaceSymbol in symbolSet.Namespaces) { - if (namespaceSymbol.HasApplicationTypes) { - NamespaceGenerator.GenerateScript(this, namespaceSymbol, generatedNamespaces); + bool firstDependency = true; + foreach (string dependency in _symbols.Dependencies) { + if (firstDependency == false) { + _writer.Write(", "); } + _writer.Write("'" + dependency + "'"); + firstDependency = false; } - List generatedClasses = new List(_classes.Count); - foreach (ClassSymbol generatedClass in _classes) { - if (generatedClass.HasGlobalMethods == false) { - GenerateClassRegistration(generatedClass, generatedClasses); + _writer.Write("], function("); + + firstDependency = true; + foreach (string dependency in _symbols.Dependencies) { + if (firstDependency == false) { + _writer.Write(", "); } + _writer.Write(dependency); + firstDependency = false; + } + + _writer.WriteLine(") {"); + _writer.Indent++; + _writer.WriteLine("\'use strict';"); + _writer.WriteLine(); + + foreach (TypeSymbol type in types) { + TypeGenerator.GenerateScript(this, type); } - // TODO: Couple of line-breaks would be nice here - // but only if there are any classes with static - // ctors or members + _writer.Write("var $" + moduleName + " = ss.module('"); + _writer.Write(symbolSet.ScriptName); + _writer.Write("',"); + if (internalTypes.Count != 0) { + _writer.WriteLine(); + _writer.Indent++; + _writer.WriteLine("{"); + _writer.Indent++; + bool firstType = true; + foreach (TypeSymbol type in types) { + if (type.IsPublic == false) { + if ((type.Type == SymbolType.Class) && + ((ClassSymbol)type).HasGlobalMethods) { + continue; + } + + if (firstType == false) { + _writer.WriteLine(","); + } + TypeGenerator.GenerateRegistrationScript(this, type); + firstType = false; + } + } + _writer.Indent--; + _writer.WriteLine(); + _writer.Write("},"); + _writer.Indent--; + } + else { + _writer.Write(" null,"); + } + if (publicTypes.Count != 0) { + _writer.WriteLine(); + _writer.Indent++; + _writer.WriteLine("{"); + _writer.Indent++; + bool firstType = true; + foreach (TypeSymbol type in types) { + if (type.IsPublic) { + if ((type.Type == SymbolType.Class) && + ((ClassSymbol)type).HasGlobalMethods) { + continue; + } + + if (firstType == false) { + _writer.WriteLine(","); + } + TypeGenerator.GenerateRegistrationScript(this, type); + firstType = false; + } + } + _writer.Indent--; + _writer.WriteLine(); + _writer.Write("}"); + _writer.Indent--; + } + else { + _writer.Write(" null"); + } + _writer.WriteLine(");"); + _writer.WriteLine(); - foreach (ClassSymbol generatedClass in _classes) { - TypeGenerator.GenerateClassConstructorScript(this, generatedClass); + foreach (TypeSymbol type in types) { + if (type.Type == SymbolType.Class) { + TypeGenerator.GenerateClassConstructorScript(this, (ClassSymbol)type); + } } - if (Options.IncludeTests) { - foreach (ClassSymbol generatedClass in _classes) { - if (generatedClass.IsTestClass) { - TestGenerator.GenerateScript(this, generatedClass); + if (_options.IncludeTests) { + foreach (TypeSymbol type in types) { + ClassSymbol classSymbol = type as ClassSymbol; + if ((classSymbol != null) && classSymbol.IsTestClass) { + TestGenerator.GenerateScript(this, classSymbol); } } } + + _writer.WriteLine(); + _writer.WriteLine("return $" + moduleName + ";"); + + _writer.Indent--; + _writer.WriteLine("});"); + } + + + private sealed class TypeComparer : IComparer { + + public int Compare(TypeSymbol x, TypeSymbol y) { + if (x.Type != y.Type) { + // If types are different, then use the symbol type to + // similar types of types together. + return (int)x.Type - (int)y.Type; + } + + if (x.Type == SymbolType.Class) { + // For classes, sort by inheritance depth. This is a crude + // way to ensure the base class for a class is generated + // first, without specifically looking at the inheritance + // chain for any particular type. A parent class with lesser + // inheritance depth has to by definition come first. + + return ((ClassSymbol)x).InheritanceDepth - ((ClassSymbol)y).InheritanceDepth; + } + + return 0; + } } } } diff --git a/src/Core/Compiler/Generator/ScriptTextWriter.cs b/src/Core/Compiler/Generator/ScriptTextWriter.cs index 4eadfdc66..a1b324ae2 100644 --- a/src/Core/Compiler/Generator/ScriptTextWriter.cs +++ b/src/Core/Compiler/Generator/ScriptTextWriter.cs @@ -1,4 +1,4 @@ -// IndentedTextWriter.cs +// ScriptTextWriter.cs // Script#/Core/Compiler // This source code is subject to terms and conditions of the Apache License, Version 2.0. // @@ -14,7 +14,6 @@ namespace ScriptSharp.Generator { internal sealed class ScriptTextWriter : TextWriter { private TextWriter _writer; - private bool _minimize; private int _indentLevel; private bool _tabsPending; @@ -24,21 +23,12 @@ internal sealed class ScriptTextWriter : TextWriter { private int _globalIndentLevel; private bool _globalTabsPending; - public ScriptTextWriter(TextWriter writer, CompilerOptions options) + public ScriptTextWriter(TextWriter writer) : base(CultureInfo.InvariantCulture) { _writer = writer; _globalWriter = writer; -#if DEBUG - _minimize = options.Minimize && (options.InternalTestMode == false); -#else - _minimize = options.Minimize; -#endif - if (_minimize) { - NewLine = "\n"; - } - - _tabString = " "; + _tabString = " "; _indentLevel = 0; _tabsPending = false; } @@ -81,10 +71,8 @@ public override void Flush() { private void OutputTabs() { if (_tabsPending) { - if (_minimize == false) { - for (int i = 0; i < _indentLevel; i++) { - _writer.Write(_tabString); - } + for (int i = 0; i < _indentLevel; i++) { + _writer.Write(_tabString); } _tabsPending = false; } @@ -173,8 +161,9 @@ public override void Write(string format, params object[] arg) { _writer.Write(format, arg); } - public void WriteLineNoTabs(string s) { - _writer.WriteLine(s); + public override void WriteLine() { + _writer.WriteLine(); + _tabsPending = true; } public override void WriteLine(string s) { @@ -183,12 +172,6 @@ public override void WriteLine(string s) { _tabsPending = true; } - public override void WriteLine() { - OutputTabs(); - _writer.WriteLine(); - _tabsPending = true; - } - public override void WriteLine(bool value) { OutputTabs(); _writer.WriteLine(value); @@ -266,24 +249,5 @@ public override void WriteLine(UInt32 value) { _writer.WriteLine(value); _tabsPending = true; } - - public void WriteSignificantNewLine() { - WriteLine(); - } - - public void WriteNewLine() { - if (_minimize == false) { - WriteLine(); - } - } - - public void WriteTrimmed(string text) { - if (_minimize == false) { - Write(text); - } - else { - Write(text.Trim()); - } - } } } diff --git a/src/Core/Compiler/Generator/StatementGenerator.cs b/src/Core/Compiler/Generator/StatementGenerator.cs index ff5261917..2ae351569 100644 --- a/src/Core/Compiler/Generator/StatementGenerator.cs +++ b/src/Core/Compiler/Generator/StatementGenerator.cs @@ -23,23 +23,23 @@ private static void GenerateBlockStatement(ScriptGenerator generator, MemberSymb private static void GenerateBreakStatement(ScriptGenerator generator, MemberSymbol symbol, BreakStatement statement) { ScriptTextWriter writer = generator.Writer; writer.Write("break;"); - writer.WriteNewLine(); + writer.WriteLine(); } private static void GenerateContinueStatement(ScriptGenerator generator, MemberSymbol symbol, ContinueStatement statement) { ScriptTextWriter writer = generator.Writer; writer.Write("continue;"); - writer.WriteNewLine(); + writer.WriteLine(); } private static void GenerateErrorStatement(ScriptGenerator generator, MemberSymbol symbol, ErrorStatement statement) { ScriptTextWriter writer = generator.Writer; writer.Write("// ERROR: "); writer.Write(statement.Message); - writer.WriteSignificantNewLine(); + writer.WriteLine(); writer.Write("// ERROR: at "); writer.Write(statement.Location); - writer.WriteSignificantNewLine(); + writer.WriteLine(); } private static void GenerateExpressionStatement(ScriptGenerator generator, MemberSymbol symbol, ExpressionStatement statement) { @@ -48,7 +48,7 @@ private static void GenerateExpressionStatement(ScriptGenerator generator, Membe ExpressionGenerator.GenerateExpression(generator, symbol, statement.Expression); if (statement.IsFragment == false) { writer.Write(";"); - writer.WriteNewLine(); + writer.WriteLine(); } } @@ -59,7 +59,7 @@ private static void GenerateForStatement(ScriptGenerator generator, MemberSymbol ScriptTextWriter writer = generator.Writer; - writer.WriteTrimmed("for "); + writer.Write("for "); writer.Write("("); if (statement.Initializers != null) { ExpressionGenerator.GenerateExpressionList(generator, symbol, statement.Initializers); @@ -67,22 +67,20 @@ private static void GenerateForStatement(ScriptGenerator generator, MemberSymbol else if (statement.Variables != null) { GenerateVariableDeclarations(generator, symbol, statement.Variables); } - writer.WriteTrimmed("; "); + writer.Write("; "); if (statement.Condition != null) { ExpressionGenerator.GenerateExpression(generator, symbol, statement.Condition); } - writer.WriteTrimmed("; "); + writer.Write("; "); if (statement.Increments != null) { ExpressionGenerator.GenerateExpressionList(generator, symbol, statement.Increments); } - writer.WriteTrimmed(") "); - writer.Write("{"); - writer.WriteNewLine(); + writer.WriteLine(") {"); writer.Indent++; GenerateStatement(generator, symbol, statement.Body); writer.Indent--; writer.Write("}"); - writer.WriteNewLine(); + writer.WriteLine(); } private static void GenerateForInStatement(ScriptGenerator generator, MemberSymbol symbol, ForInStatement statement) { @@ -91,70 +89,58 @@ private static void GenerateForInStatement(ScriptGenerator generator, MemberSymb if (statement.IsDictionaryEnumeration) { writer.Write("var "); writer.Write(statement.DictionaryVariable.GeneratedName); - writer.WriteTrimmed(" = "); + writer.Write(" = "); ExpressionGenerator.GenerateExpression(generator, symbol, statement.CollectionExpression); writer.Write(";"); - writer.WriteNewLine(); + writer.WriteLine(); - writer.WriteTrimmed("for "); - writer.Write("(var "); + writer.Write("for (var "); writer.Write(statement.LoopVariable.GeneratedName); writer.Write(" in "); writer.Write(statement.DictionaryVariable.GeneratedName); - writer.WriteTrimmed(") "); - writer.Write("{"); - writer.WriteNewLine(); + writer.WriteLine(") {"); writer.Indent++; writer.Write("var "); writer.Write(statement.ItemVariable.GeneratedName); - writer.WriteTrimmed(" = "); - writer.WriteTrimmed("{ "); - writer.WriteTrimmed("key: "); + writer.Write(" = { key: "); writer.Write(statement.LoopVariable.GeneratedName); - writer.WriteTrimmed(", "); - writer.WriteTrimmed("value: "); + writer.Write(", value: "); writer.Write(statement.DictionaryVariable.GeneratedName); writer.Write("["); writer.Write(statement.LoopVariable.GeneratedName); - writer.Write("]"); - writer.WriteTrimmed(" };"); - writer.WriteNewLine(); + writer.WriteLine("] };"); GenerateStatement(generator, symbol, statement.Body); writer.Indent--; - writer.Write("}"); - writer.WriteNewLine(); + writer.WriteLine("}"); } else { writer.Write("var "); writer.Write(statement.LoopVariable.GeneratedName); - writer.WriteTrimmed(" = "); + writer.Write(" = "); writer.Write("ss.IEnumerator.getEnumerator("); ExpressionGenerator.GenerateExpression(generator, symbol, statement.CollectionExpression); writer.Write(");"); - writer.WriteNewLine(); + writer.WriteLine(); - writer.WriteTrimmed("while "); - writer.Write("("); + writer.Write("while ("); writer.Write(statement.LoopVariable.GeneratedName); - writer.WriteTrimmed(".moveNext()) "); - writer.Write("{"); - writer.WriteNewLine(); + writer.WriteLine(".moveNext()) {"); writer.Indent++; writer.Write("var "); writer.Write(statement.ItemVariable.GeneratedName); - writer.WriteTrimmed(" = "); + writer.Write(" = "); writer.Write(statement.LoopVariable.GeneratedName); writer.Write(".current;"); - writer.WriteNewLine(); + writer.WriteLine(); GenerateStatement(generator, symbol, statement.Body); writer.Indent--; writer.Write("}"); - writer.WriteNewLine(); + writer.WriteLine(); } } @@ -165,19 +151,16 @@ private static void GenerateIfElseStatement(ScriptGenerator generator, MemberSym ScriptTextWriter writer = generator.Writer; - writer.WriteTrimmed("if "); - writer.Write("("); + writer.Write("if ("); ExpressionGenerator.GenerateExpression(generator, symbol, statement.Condition); - writer.WriteTrimmed(") "); - writer.Write("{"); - writer.WriteNewLine(); + writer.WriteLine(") {"); if (statement.IfStatement != null) { writer.Indent++; GenerateStatement(generator, symbol, statement.IfStatement); writer.Indent--; } writer.Write("}"); - writer.WriteNewLine(); + writer.WriteLine(); if (statement.ElseStatement != null) { bool writeEndBlock = false; @@ -185,17 +168,14 @@ private static void GenerateIfElseStatement(ScriptGenerator generator, MemberSym writer.Write("else "); } else { - writer.WriteTrimmed("else "); - writer.Write("{"); - writer.WriteNewLine(); + writer.WriteLine("else {"); writeEndBlock = true; writer.Indent++; } GenerateStatement(generator, symbol, statement.ElseStatement); if (writeEndBlock) { writer.Indent--; - writer.Write("}"); - writer.WriteNewLine(); + writer.WriteLine("}"); } } } @@ -206,12 +186,10 @@ private static void GenerateReturnStatement(ScriptGenerator generator, MemberSym if (statement.Value != null) { writer.Write("return "); ExpressionGenerator.GenerateExpression(generator, symbol, statement.Value); - writer.Write(";"); - writer.WriteNewLine(); + writer.WriteLine(";"); } else { - writer.Write("return;"); - writer.WriteNewLine(); + writer.WriteLine("return;"); } } @@ -270,26 +248,21 @@ public static void GenerateStatement(ScriptGenerator generator, MemberSymbol sym private static void GenerateSwitchStatement(ScriptGenerator generator, MemberSymbol symbol, SwitchStatement statement) { ScriptTextWriter writer = generator.Writer; - writer.WriteTrimmed("switch "); - writer.Write("("); + writer.Write("switch ("); ExpressionGenerator.GenerateExpression(generator, symbol, statement.Condition); - writer.WriteTrimmed(") "); - writer.Write("{"); - writer.WriteNewLine(); + writer.WriteLine(") {"); writer.Indent++; foreach (SwitchGroup group in statement.Groups) { if (group.Cases != null) { foreach (Expression caseExpression in group.Cases) { writer.Write("case "); ExpressionGenerator.GenerateExpression(generator, symbol, caseExpression); - writer.Write(":"); - writer.WriteNewLine(); + writer.WriteLine(":"); } } if (group.IncludeDefault) { - writer.Write("default:"); - writer.WriteNewLine(); + writer.WriteLine("default:"); } writer.Indent++; @@ -299,8 +272,7 @@ private static void GenerateSwitchStatement(ScriptGenerator generator, MemberSym writer.Indent--; } writer.Indent--; - writer.Write("}"); - writer.WriteNewLine(); + writer.WriteLine("}"); } private static void GenerateThrowStatement(ScriptGenerator generator, MemberSymbol symbol, ThrowStatement statement) { @@ -308,43 +280,32 @@ private static void GenerateThrowStatement(ScriptGenerator generator, MemberSymb writer.Write("throw "); ExpressionGenerator.GenerateExpression(generator, symbol, statement.Value); - writer.Write(";"); - writer.WriteNewLine(); + writer.WriteLine(";"); } private static void GenerateTryCatchFinallyStatement(ScriptGenerator generator, MemberSymbol symbol, TryCatchFinallyStatement statement) { ScriptTextWriter writer = generator.Writer; - writer.WriteTrimmed("try "); - writer.Write("{"); - writer.WriteNewLine(); + writer.WriteLine("try {"); writer.Indent++; GenerateStatement(generator, symbol, statement.Body); writer.Indent--; - writer.Write("}"); - writer.WriteNewLine(); + writer.WriteLine("}"); if (statement.Catch != null) { - writer.WriteTrimmed("catch "); - writer.Write("("); + writer.Write("catch ("); writer.Write(statement.ExceptionVariable.GeneratedName); - writer.WriteTrimmed(") "); - writer.Write("{"); - writer.WriteNewLine(); + writer.WriteLine(") {"); writer.Indent++; GenerateStatement(generator, symbol, statement.Catch); writer.Indent--; - writer.Write("}"); - writer.WriteNewLine(); + writer.WriteLine("}"); } if (statement.Finally != null) { - writer.WriteTrimmed("finally "); - writer.Write("{"); - writer.WriteNewLine(); + writer.WriteLine("finally {"); writer.Indent++; GenerateStatement(generator, symbol, statement.Finally); writer.Indent--; - writer.Write("}"); - writer.WriteNewLine(); + writer.WriteLine("}"); } } @@ -356,13 +317,13 @@ private static void GenerateVariableDeclarations(ScriptGenerator generator, Memb writer.Write("var "); foreach (VariableSymbol variableSymbol in statement.Variables) { if (firstVariable == false) { - writer.WriteTrimmed(", "); + writer.Write(", "); } writer.Write(variableSymbol.GeneratedName); if (variableSymbol.Value != null) { - writer.WriteTrimmed(" = "); + writer.Write(" = "); ExpressionGenerator.GenerateExpression(generator, symbol, variableSymbol.Value); } @@ -374,8 +335,7 @@ private static void GenerateVariableDeclarationStatement(ScriptGenerator generat ScriptTextWriter writer = generator.Writer; GenerateVariableDeclarations(generator, symbol, statement); - writer.Write(";"); - writer.WriteNewLine(); + writer.WriteLine(";"); } private static void GenerateWhileStatement(ScriptGenerator generator, MemberSymbol symbol, WhileStatement statement) { @@ -386,17 +346,12 @@ private static void GenerateWhileStatement(ScriptGenerator generator, MemberSymb ScriptTextWriter writer = generator.Writer; if (statement.PreCondition) { - writer.WriteTrimmed("while "); - writer.Write("("); + writer.Write("while ("); ExpressionGenerator.GenerateExpression(generator, symbol, statement.Condition); - writer.WriteTrimmed(") "); - writer.Write("{"); - writer.WriteNewLine(); + writer.WriteLine(") {"); } else { - writer.WriteTrimmed("do "); - writer.Write("{"); - writer.WriteNewLine(); + writer.WriteLine("do {"); } writer.Indent++; @@ -404,16 +359,12 @@ private static void GenerateWhileStatement(ScriptGenerator generator, MemberSymb writer.Indent--; if (statement.PreCondition) { - writer.Write("}"); - writer.WriteNewLine(); + writer.WriteLine("}"); } else { - writer.WriteTrimmed("} "); - writer.WriteTrimmed("while "); - writer.Write("("); + writer.Write("} while ("); ExpressionGenerator.GenerateExpression(generator, symbol, statement.Condition); - writer.Write(");"); - writer.WriteNewLine(); + writer.WriteLine(");"); } } } diff --git a/src/Core/Compiler/Generator/TypeGenerator.cs b/src/Core/Compiler/Generator/TypeGenerator.cs index eb667d64b..b18454777 100644 --- a/src/Core/Compiler/Generator/TypeGenerator.cs +++ b/src/Core/Compiler/Generator/TypeGenerator.cs @@ -14,40 +14,23 @@ namespace ScriptSharp.Generator { internal static class TypeGenerator { private static void GenerateClass(ScriptGenerator generator, ClassSymbol classSymbol) { - if (classSymbol.HasGlobalMethods) { - GenerateGlobalMethods(generator, classSymbol); - generator.AddGeneratedClass(classSymbol); - return; - } - ScriptTextWriter writer = generator.Writer; string name = classSymbol.FullGeneratedName; - if (classSymbol.Namespace.Length == 0) { - writer.Write("window."); - } - + writer.Write("function "); writer.Write(name); - writer.WriteTrimmed(" = "); - writer.Write("function"); - if (generator.Options.DebugFlavor) { - writer.Write(" "); - writer.Write(name.Replace(".", "_")); - } writer.Write("("); if ((classSymbol.Constructor != null) && (classSymbol.Constructor.Parameters != null)) { bool firstParameter = true; foreach (ParameterSymbol parameterSymbol in classSymbol.Constructor.Parameters) { if (firstParameter == false) { - writer.WriteTrimmed(", "); + writer.Write(", "); } writer.Write(parameterSymbol.GeneratedName); firstParameter = false; } } - writer.WriteTrimmed(") "); - writer.Write("{"); - writer.WriteNewLine(); + writer.WriteLine(") {"); writer.Indent++; if (generator.Options.EnableDocComments) { @@ -61,24 +44,23 @@ private static void GenerateClass(ScriptGenerator generator, ClassSymbol classSy if (fieldSymbol.HasInitializer) { writer.Write("this."); writer.Write(fieldSymbol.GeneratedName); - writer.WriteTrimmed(" = "); + writer.Write(" = "); CodeGenerator.GenerateScript(generator, fieldSymbol); writer.Write(";"); - writer.WriteNewLine(); + writer.WriteLine(); } } } if (classSymbol.Constructor != null) { CodeGenerator.GenerateScript(generator, classSymbol.Constructor); } - else if (classSymbol.BaseClass != null) { - writer.Write(classSymbol.FullGeneratedName); - writer.Write(".initializeBase(this);"); - writer.WriteNewLine(); + else if ((classSymbol.BaseClass != null) && (classSymbol.IsTestClass == false)) { + writer.Write(classSymbol.BaseClass.FullGeneratedName); + writer.Write(".call(this);"); + writer.WriteLine(); } writer.Indent--; - writer.Write("}"); - writer.WriteSignificantNewLine(); + writer.WriteLine("}"); foreach (MemberSymbol memberSymbol in classSymbol.Members) { if ((memberSymbol.Type != SymbolType.Field) && @@ -87,13 +69,15 @@ private static void GenerateClass(ScriptGenerator generator, ClassSymbol classSy } } - bool hasPrototypeMembers = false; + writer.Write("var "); + writer.Write(name); + writer.WriteLine("$ = {"); + writer.Indent++; + bool firstMember = true; - bool lastMemberWasField = true; foreach (MemberSymbol memberSymbol in classSymbol.Members) { if ((memberSymbol.Visibility & MemberVisibility.Static) == 0) { - if ((memberSymbol.Type == SymbolType.Field) && - ((FieldSymbol)memberSymbol).HasInitializer) { + if (memberSymbol.Type == SymbolType.Field) { continue; } @@ -102,86 +86,36 @@ private static void GenerateClass(ScriptGenerator generator, ClassSymbol classSy continue; } - if (hasPrototypeMembers == false) { - hasPrototypeMembers = true; - - writer.Write(name); - writer.Write(".prototype"); - writer.WriteTrimmed(" = "); - writer.Write("{"); - writer.WriteNewLine(); - writer.Indent++; - } - if (firstMember == false) { - writer.Write(","); - writer.WriteNewLine(); - } - if ((lastMemberWasField == false) || !(memberSymbol is FieldSymbol)) { - writer.WriteNewLine(); + writer.WriteLine(","); } MemberGenerator.GenerateScript(generator, memberSymbol); - lastMemberWasField = (memberSymbol is FieldSymbol); firstMember = false; } } if (classSymbol.Indexer != null) { - if (hasPrototypeMembers == false) { - hasPrototypeMembers = true; - - writer.Write(name); - writer.Write(".prototype"); - writer.WriteTrimmed(" = "); - writer.Write("{"); - writer.WriteNewLine(); - writer.Indent++; - - } if (firstMember == false) { - writer.Write(","); - writer.WriteNewLine(); + writer.WriteLine(","); } MemberGenerator.GenerateScript(generator, classSymbol.Indexer); } - if (hasPrototypeMembers) { - writer.Indent--; - writer.WriteNewLine(); - writer.Write("}"); - writer.WriteSignificantNewLine(); - } - - generator.AddGeneratedClass(classSymbol); - } - - private static void GenerateDelegate(ScriptGenerator generator, DelegateSymbol delegateSymbol) { - // No-op - // There is currently nothing to generate for a particular delegate type + writer.Indent--; + writer.WriteLine(); + writer.Write("};"); + writer.WriteLine(); } private static void GenerateEnumeration(ScriptGenerator generator, EnumerationSymbol enumSymbol) { ScriptTextWriter writer = generator.Writer; + string enumName = enumSymbol.FullGeneratedName; - if (enumSymbol.Namespace.Length == 0) { - writer.Write("window."); - } - + writer.Write("var "); writer.Write(enumSymbol.FullGeneratedName); - writer.WriteTrimmed(" = "); - writer.Write("function()"); - writer.WriteTrimmed(" { "); - - if (generator.Options.EnableDocComments) { - DocCommentGenerator.GenerateComment(generator, enumSymbol); - } - - writer.Write("};"); - writer.WriteNewLine(); - writer.Write(enumSymbol.FullGeneratedName); - writer.Write(".prototype = {"); + writer.Write(" = {"); writer.Indent++; bool firstValue = true; @@ -192,12 +126,12 @@ private static void GenerateEnumeration(ScriptGenerator generator, EnumerationSy } if (firstValue == false) { - writer.WriteTrimmed(", "); + writer.Write(", "); } - writer.WriteNewLine(); + writer.WriteLine(); writer.Write(fieldSymbol.GeneratedName); - writer.WriteTrimmed(": "); + writer.Write(": "); if (enumSymbol.UseNamedValues) { writer.Write(Utility.QuoteString(enumSymbol.CreateNamedValue(fieldSymbol))); } @@ -208,97 +142,18 @@ private static void GenerateEnumeration(ScriptGenerator generator, EnumerationSy } writer.Indent--; - writer.WriteNewLine(); - writer.WriteTrimmed("}"); - writer.WriteSignificantNewLine(); - - writer.Write(enumSymbol.FullGeneratedName); - writer.Write(".registerEnum('"); - writer.Write(enumSymbol.FullGeneratedName); - writer.WriteTrimmed("', "); - writer.Write(enumSymbol.Flags ? "true" : "false"); - writer.Write(");"); - writer.WriteNewLine(); + writer.WriteLine(); + writer.Write("};"); + writer.WriteLine(); } private static void GenerateInterface(ScriptGenerator generator, InterfaceSymbol interfaceSymbol) { ScriptTextWriter writer = generator.Writer; string interfaceName = interfaceSymbol.FullGeneratedName; - if (interfaceSymbol.Namespace.Length == 0) { - writer.Write("window."); - } - + writer.Write("function "); writer.Write(interfaceName); - writer.WriteTrimmed(" = "); - writer.Write("function()"); - writer.WriteTrimmed(" { "); - - if (generator.Options.EnableDocComments) { - DocCommentGenerator.GenerateComment(generator, interfaceSymbol); - } - - writer.Write("};"); - writer.WriteNewLine(); - - if (generator.Options.DebugFlavor) { - writer.Write(interfaceName); - writer.Write(".prototype = {"); - writer.WriteLine(); - writer.Indent++; - bool firstMember = true; - foreach (MemberSymbol member in interfaceSymbol.Members) { - if (firstMember == false) { - writer.Write(","); - writer.WriteLine(); - } - - if (member.Type == SymbolType.Property) { - writer.Write("get_"); - writer.Write(member.GeneratedName); - writer.WriteTrimmed(" : "); - writer.Write("null"); - - if (((PropertySymbol)member).IsReadOnly == false) { - writer.Write(","); - writer.WriteLine(); - - writer.Write("set_"); - writer.Write(member.GeneratedName); - writer.WriteTrimmed(" : "); - writer.Write("null"); - } - } - else if (member.Type == SymbolType.Event) { - writer.Write("add_"); - writer.Write(member.GeneratedName); - writer.WriteTrimmed(" : "); - writer.Write("null,"); - writer.WriteLine(); - - writer.Write("remove_"); - writer.Write(member.GeneratedName); - writer.WriteTrimmed(" : "); - writer.Write("null"); - } - else { - writer.Write(member.GeneratedName); - writer.WriteTrimmed(" : "); - writer.Write("null"); - } - firstMember = false; - } - writer.Indent--; - writer.WriteLine(); - writer.Write("}"); - writer.WriteSignificantNewLine(); - } - - writer.Write(interfaceName); - writer.Write(".registerInterface('"); - writer.Write(interfaceName); - writer.Write("');"); - writer.WriteNewLine(); + writer.WriteLine("() { }"); } public static void GenerateClassConstructorScript(ScriptGenerator generator, ClassSymbol classSymbol) { @@ -308,13 +163,17 @@ public static void GenerateClassConstructorScript(ScriptGenerator generator, Cla foreach (MemberSymbol memberSymbol in classSymbol.Members) { if ((memberSymbol.Type == SymbolType.Field) && ((memberSymbol.Visibility & MemberVisibility.Static) != 0)) { - if (((FieldSymbol)memberSymbol).IsConstant && + FieldSymbol fieldSymbol = (FieldSymbol)memberSymbol; + + if (fieldSymbol.IsConstant && ((memberSymbol.Visibility & (MemberVisibility.Public | MemberVisibility.Protected)) == 0)) { // PrivateInstance/Internal constant fields are omitted since they have been inlined continue; } - MemberGenerator.GenerateScript(generator, memberSymbol); + if (fieldSymbol.HasInitializer) { + MemberGenerator.GenerateScript(generator, memberSymbol); + } } } @@ -325,62 +184,16 @@ public static void GenerateClassConstructorScript(ScriptGenerator generator, Cla bool requiresFunctionScope = implementation.DeclaresVariables; if (requiresFunctionScope) { - writer.Write("(function"); - writer.WriteTrimmed(" () "); - writer.Write("{"); - writer.WriteNewLine(); + writer.WriteLine("(function() {"); writer.Indent++; } CodeGenerator.GenerateScript(generator, classSymbol.StaticConstructor); if (requiresFunctionScope) { writer.Indent--; writer.Write("})();"); - writer.WriteSignificantNewLine(); - } - } - } - - public static void GenerateClassRegistrationScript(ScriptGenerator generator, ClassSymbol classSymbol) { - // NOTE: This is emitted towards the end of the script file as opposed to immediately after the - // class definition, because it allows us to reference other class (base class, interfaces) - // without having to do a manual topological sort to get the ordering of class definitions - // that would be needed otherwise. - - ScriptTextWriter writer = generator.Writer; - string name = classSymbol.FullGeneratedName; - - writer.Write(name); - writer.Write(".registerClass('"); - writer.Write(name); - writer.Write("'"); - - // TODO: We need to introduce the notion of a base class that only exists in the metadata - // and not at runtime. At that point this check of IsTestClass can be generalized. - if (classSymbol.IsTestClass) { - writer.Write(");"); - writer.WriteNewLine(); - - return; - } - - if (classSymbol.BaseClass != null) { - writer.WriteTrimmed(", "); - writer.Write(classSymbol.BaseClass.FullGeneratedName); - } - - if (classSymbol.Interfaces != null) { - if (classSymbol.BaseClass == null) { - writer.WriteTrimmed(", "); - writer.Write("null"); - } - foreach (InterfaceSymbol interfaceSymbol in classSymbol.Interfaces) { - writer.WriteTrimmed(", "); - writer.Write(interfaceSymbol.FullGeneratedName); + writer.WriteLine(); } } - - writer.Write(");"); - writer.WriteNewLine(); } private static void GenerateGlobalMethods(ScriptGenerator generator, ClassSymbol classSymbol) { @@ -394,23 +207,10 @@ private static void GenerateGlobalMethods(ScriptGenerator generator, ClassSymbol private static void GenerateRecord(ScriptGenerator generator, RecordSymbol recordSymbol) { ScriptTextWriter writer = generator.Writer; - string recordName = recordSymbol.GeneratedName; + string recordName = recordSymbol.FullGeneratedName; - if ((recordSymbol.Namespace.Length == 0) || recordSymbol.IgnoreNamespace) { - writer.Write("window."); - } - else { - writer.Write(recordSymbol.GeneratedNamespace); - writer.Write("."); - } - writer.Write("$create_"); + writer.Write("function "); writer.Write(recordName); - writer.WriteTrimmed(" = "); - writer.Write("function"); - if (generator.Options.DebugFlavor) { - writer.Write(" "); - writer.Write(recordSymbol.FullGeneratedName.Replace(".", "_")); - } writer.Write("("); if (recordSymbol.Constructor != null) { ConstructorSymbol ctorSymbol = recordSymbol.Constructor; @@ -419,43 +219,86 @@ private static void GenerateRecord(ScriptGenerator generator, RecordSymbol recor bool firstParameter = true; foreach (ParameterSymbol parameterSymbol in ctorSymbol.Parameters) { if (firstParameter == false) { - writer.WriteTrimmed(", "); + writer.Write(", "); } writer.Write(parameterSymbol.GeneratedName); firstParameter = false; } } } - writer.WriteTrimmed(")"); - writer.WriteTrimmed(" {"); + writer.Write(") {"); if (recordSymbol.Constructor != null) { writer.Indent++; - writer.WriteNewLine(); - writer.Write("var $o"); - writer.WriteTrimmed(" = "); - writer.WriteTrimmed("{ "); - writer.Write("};"); - writer.WriteNewLine(); + writer.WriteLine(); + writer.WriteLine("var $o = {};"); CodeGenerator.GenerateScript(generator, recordSymbol.Constructor); writer.Write("return $o;"); - writer.WriteNewLine(); + writer.WriteLine(); writer.Indent--; } else { - writer.WriteTrimmed(" return {}; "); + writer.Write(" return {}; "); } writer.Write("}"); - writer.WriteSignificantNewLine(); + writer.WriteLine(); + } + + public static void GenerateRegistrationScript(ScriptGenerator generator, TypeSymbol typeSymbol) { + ClassSymbol classSymbol = typeSymbol as ClassSymbol; + + if ((classSymbol != null) && classSymbol.HasGlobalMethods) { + return; + } + + ScriptTextWriter writer = generator.Writer; + + writer.Write(typeSymbol.GeneratedName); + writer.Write(": "); + + switch (typeSymbol.Type) { + case SymbolType.Class: + writer.Write("[ "); + writer.Write(typeSymbol.FullGeneratedName); + writer.Write(", "); + writer.Write(typeSymbol.FullGeneratedName); + writer.Write("$, "); + if ((classSymbol.BaseClass == null) || classSymbol.IsTestClass) { + // TODO: We need to introduce the notion of a base class that only exists in the metadata + // and not at runtime. At that point this check of IsTestClass can be generalized. + + writer.Write("null"); + } + else { + writer.Write(classSymbol.BaseClass.FullGeneratedName); + } + if (classSymbol.Interfaces != null) { + foreach (InterfaceSymbol interfaceSymbol in classSymbol.Interfaces) { + writer.Write(", "); + writer.Write(interfaceSymbol.FullGeneratedName); + } + } + writer.Write(" ]"); + break; + case SymbolType.Interface: + writer.Write("[ "); + writer.Write(typeSymbol.FullGeneratedName); + writer.Write(" ]"); + break; + case SymbolType.Record: + case SymbolType.Resources: + case SymbolType.Enumeration: + writer.Write(typeSymbol.FullGeneratedName); + break; + } } private static void GenerateResources(ScriptGenerator generator, ResourcesSymbol resourcesSymbol) { ScriptTextWriter writer = generator.Writer; string resourcesName = resourcesSymbol.FullGeneratedName; + writer.Write("var "); writer.Write(resourcesName); - writer.WriteTrimmed(" = "); - writer.WriteTrimmed("{ "); - writer.WriteNewLine(); + writer.WriteLine(" = {"); writer.Indent++; bool firstValue = true; @@ -468,7 +311,7 @@ private static void GenerateResources(ScriptGenerator generator, ResourcesSymbol } writer.Write(member.GeneratedName); - writer.WriteTrimmed(": "); + writer.Write(": "); writer.Write(Utility.QuoteString((string)member.Value)); firstValue = false; @@ -477,7 +320,7 @@ private static void GenerateResources(ScriptGenerator generator, ResourcesSymbol writer.Indent--; writer.WriteLine(); writer.Write("};"); - writer.WriteNewLine(); + writer.WriteLine(); } public static void GenerateScript(ScriptGenerator generator, TypeSymbol typeSymbol) { @@ -485,22 +328,19 @@ public static void GenerateScript(ScriptGenerator generator, TypeSymbol typeSymb Debug.Assert(typeSymbol != null); Debug.Assert(typeSymbol.IsApplicationType); - if ((typeSymbol.Type == SymbolType.Enumeration) && (typeSymbol.IsPublic == false)) { - // Internal enums can be skipped since their values have been inlined. - return; - } - ScriptTextWriter writer = generator.Writer; - if (generator.Options.Minimize == false) { - writer.WriteLine(new String('/', 80)); - writer.WriteLine("// " + typeSymbol.FullGeneratedName); - writer.WriteLine(); - } + writer.WriteLine("// " + typeSymbol.FullName); + writer.WriteLine(); switch (typeSymbol.Type) { case SymbolType.Class: - GenerateClass(generator, (ClassSymbol)typeSymbol); + if (((ClassSymbol)typeSymbol).HasGlobalMethods) { + GenerateGlobalMethods(generator, (ClassSymbol)typeSymbol); + } + else { + GenerateClass(generator, (ClassSymbol)typeSymbol); + } break; case SymbolType.Interface: GenerateInterface(generator, (InterfaceSymbol)typeSymbol); @@ -509,7 +349,7 @@ public static void GenerateScript(ScriptGenerator generator, TypeSymbol typeSymb GenerateEnumeration(generator, (EnumerationSymbol)typeSymbol); break; case SymbolType.Delegate: - GenerateDelegate(generator, (DelegateSymbol)typeSymbol); + // No-op ... there is currently nothing to generate for a particular delegate type break; case SymbolType.Record: GenerateRecord(generator, (RecordSymbol)typeSymbol); @@ -519,8 +359,8 @@ public static void GenerateScript(ScriptGenerator generator, TypeSymbol typeSymb break; } - writer.WriteNewLine(); - writer.WriteNewLine(); + writer.WriteLine(); + writer.WriteLine(); } } } diff --git a/src/Core/Compiler/ScriptCompiler.cs b/src/Core/Compiler/ScriptCompiler.cs index 27546b27e..f24785d32 100644 --- a/src/Core/Compiler/ScriptCompiler.cs +++ b/src/Core/Compiler/ScriptCompiler.cs @@ -146,11 +146,17 @@ private void BuildMetadata() { } #endif // DEBUG + ISymbolTransformer transformer = null; if (_options.Minimize) { - SymbolObfuscator obfuscator = new SymbolObfuscator(); - SymbolSetTransformer obfuscationTransformer = new SymbolSetTransformer(obfuscator); + transformer = new SymbolObfuscator(); + } + else if (_options.DebugFlavor) { + transformer = new SymbolInternalizer(); + } - ICollection obfuscatedSymbols = obfuscationTransformer.TransformSymbolSet(_symbols, /* useInheritanceOrder */ true); + if (transformer != null) { + SymbolSetTransformer symbolSetTransformer = new SymbolSetTransformer(transformer); + ICollection transformedSymbols = symbolSetTransformer.TransformSymbolSet(_symbols, /* useInheritanceOrder */ true); #if DEBUG if (_options.InternalTestType == "minimizationMap") { @@ -159,21 +165,14 @@ private void BuildMetadata() { testWriter.WriteLine("Minimization Map"); testWriter.WriteLine("================================================================"); - List sortedObfuscatedSymbols = new List(obfuscatedSymbols); - sortedObfuscatedSymbols.Sort(delegate(Symbol s1, Symbol s2) { + List sortedTransformedSymbols = new List(transformedSymbols); + sortedTransformedSymbols.Sort(delegate(Symbol s1, Symbol s2) { return String.Compare(s1.Name, s2.Name); }); - foreach (Symbol obfuscatedSymbol in sortedObfuscatedSymbols) { - if (obfuscatedSymbol is TypeSymbol) { - TypeSymbol typeSymbol = (TypeSymbol)obfuscatedSymbol; - - testWriter.WriteLine("Type '" + typeSymbol.FullName + "' renamed to '" + typeSymbol.GeneratedName + "'"); - } - else { - Debug.Assert(obfuscatedSymbol is MemberSymbol); - testWriter.WriteLine(" Member '" + obfuscatedSymbol.Name + "' renamed to '" + obfuscatedSymbol.GeneratedName + "'"); - } + foreach (Symbol transformedSymbol in sortedTransformedSymbols) { + Debug.Assert(transformedSymbol is MemberSymbol); + testWriter.WriteLine(" Member '" + transformedSymbol.Name + "' renamed to '" + transformedSymbol.GeneratedName + "'"); } testWriter.WriteLine(); @@ -183,14 +182,6 @@ private void BuildMetadata() { } #endif // DEBUG } - else { - if (_options.DebugFlavor) { - SymbolInternalizer internalizer = new SymbolInternalizer(); - SymbolSetTransformer internalizingTransformer = new SymbolSetTransformer(internalizer); - - internalizingTransformer.TransformSymbolSet(_symbols, /* useInheritanceOrder */ true); - } - } } public bool Compile(CompilerOptions options) { @@ -287,7 +278,7 @@ private void GenerateScript() { } private void GenerateScriptCore(TextWriter writer) { - ScriptGenerator scriptGenerator = new ScriptGenerator(writer, _options, this); + ScriptGenerator scriptGenerator = new ScriptGenerator(writer, _options, _symbols); scriptGenerator.GenerateScript(_symbols); } diff --git a/src/Core/Compiler/ScriptModel/Symbols/SymbolSetDumper.cs b/src/Core/Compiler/ScriptModel/Symbols/SymbolSetDumper.cs index 89f82b73a..db1e860bc 100644 --- a/src/Core/Compiler/ScriptModel/Symbols/SymbolSetDumper.cs +++ b/src/Core/Compiler/ScriptModel/Symbols/SymbolSetDumper.cs @@ -28,13 +28,13 @@ private void DumpClass(ClassSymbol classSymbol) { if (classSymbol.BaseClass != null) { _writer.Write("BaseClass: "); - _writer.WriteLine(classSymbol.BaseClass.FullName); + _writer.WriteLine(classSymbol.BaseClass.Name); } if (classSymbol.Interfaces != null) { _writer.WriteLine("Interfaces:"); _writer.Indent++; foreach (InterfaceSymbol interfaceSymbol in classSymbol.Interfaces) { - _writer.WriteLine(interfaceSymbol.FullName); + _writer.WriteLine(interfaceSymbol.Name); } _writer.Indent--; } @@ -100,7 +100,7 @@ private void DumpMember(MemberSymbol memberSymbol) { _writer.Indent++; _writer.Write("AssociatedType: "); - _writer.WriteLine(memberSymbol.AssociatedType.FullName); + _writer.WriteLine(memberSymbol.AssociatedType.Name); _writer.Write("Visibility: "); _writer.WriteLine(memberSymbol.Visibility.ToString()); _writer.Write("Generated Name: "); @@ -182,7 +182,7 @@ private void DumpNamespace(NamespaceSymbol namespaceSymbol) { private void DumpParameter(ParameterSymbol parameterSymbol) { _writer.Write("AssociatedType: "); - _writer.WriteLine(parameterSymbol.ValueType.FullName); + _writer.WriteLine(parameterSymbol.ValueType.Name); _writer.Write("Mode: "); _writer.WriteLine(parameterSymbol.Mode.ToString()); } diff --git a/src/Core/Compiler/ScriptModel/Symbols/TypeSymbol.cs b/src/Core/Compiler/ScriptModel/Symbols/TypeSymbol.cs index 8860de4a8..7b9d95b4e 100644 --- a/src/Core/Compiler/ScriptModel/Symbols/TypeSymbol.cs +++ b/src/Core/Compiler/ScriptModel/Symbols/TypeSymbol.cs @@ -72,7 +72,12 @@ public string FullGeneratedName { if (_ignoreNamespace == false) { string namespaceName = GeneratedNamespace; if (namespaceName.Length != 0) { - return namespaceName + "." + GeneratedName; + if (IsApplicationType) { + return namespaceName + "$" + GeneratedName; + } + else { + return namespaceName + "." + GeneratedName; + } } } return GeneratedName; @@ -81,11 +86,9 @@ public string FullGeneratedName { public string FullName { get { - if (_ignoreNamespace == false) { - string namespaceName = Namespace; - if (namespaceName.Length != 0) { - return namespaceName + "." + Name; - } + string namespaceName = Namespace; + if (namespaceName.Length != 0) { + return namespaceName + "." + Name; } return Name; } @@ -93,7 +96,10 @@ public string FullName { public string GeneratedNamespace { get { - return _scriptNamespace != null ? _scriptNamespace : Namespace; + if (IsApplicationType) { + return Namespace.Replace(".", "$"); + } + return _scriptNamespace != null ? _scriptNamespace : String.Empty; } } diff --git a/tests/ScriptSharp/BasicTests.cs b/tests/ScriptSharp/BasicTests.cs index 52ba1f874..b7c5f131e 100644 --- a/tests/ScriptSharp/BasicTests.cs +++ b/tests/ScriptSharp/BasicTests.cs @@ -35,7 +35,6 @@ public void TestDependencies() { c.AddReference("Lib1.dll"). AddReference("Lib2.dll"). AddReference("Lib3.dll"). - AddTemplate("Template.js"). AddSource("Code1.cs"); c.Options.DebugFlavor = true; }, "Code1Baseline.txt"); @@ -44,7 +43,6 @@ public void TestDependencies() { c.AddReference("Lib1.dll"). AddReference("Lib2.dll"). AddReference("Lib3.dll"). - AddTemplate("Template.js"). AddSource("Code2.cs"); c.Options.DebugFlavor = true; }, "Code2Baseline.txt"); diff --git a/tests/TestCases/Basic/Conditionals/DebugBaseline.txt b/tests/TestCases/Basic/Conditionals/DebugBaseline.txt index 21b6c1827..252ee44b0 100644 --- a/tests/TestCases/Basic/Conditionals/DebugBaseline.txt +++ b/tests/TestCases/Basic/Conditionals/DebugBaseline.txt @@ -1,46 +1,58 @@ -Type.registerNamespace('BasicTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.MyDebug + // BasicTests.MyDebug -BasicTests.MyDebug = function BasicTests_MyDebug() { -} -BasicTests.MyDebug.showInfo = function BasicTests_MyDebug$showInfo() { -} -BasicTests.MyDebug.traceInfo = function BasicTests_MyDebug$traceInfo() { -} -BasicTests.MyDebug.logInfo = function BasicTests_MyDebug$logInfo() { -} + function BasicTests$MyDebug() { + } + BasicTests$MyDebug.showInfo = function() { + } + BasicTests$MyDebug.traceInfo = function() { + } + BasicTests$MyDebug.logInfo = function() { + } + var BasicTests$MyDebug$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.App -BasicTests.App = function BasicTests_App(i) { + // BasicTests.App + + function BasicTests$App(i) { console.assert(false); - BasicTests.MyDebug.showInfo(); + BasicTests$MyDebug.showInfo(); while (true) { - console.assert(false); + console.assert(false); } switch (i) { - case 0: - console.assert(false); - break; + case 0: + console.assert(false); + break; } console.assert(!!i); console.assert(!!i); i++; if (false) { - console.log('Debug spew'); + console.log('Debug spew'); } while (false) { - console.log('.'); + console.log('.'); } for (var i = 0; i < 10; i++) { - console.log('.'); + console.log('.'); } -} + } + var BasicTests$App$ = { + + }; + + + var $test = ss.module('test', null, + { + MyDebug: [ BasicTests$MyDebug, BasicTests$MyDebug$, null ], + App: [ BasicTests$App, BasicTests$App$, null ] + }); -BasicTests.MyDebug.registerClass('BasicTests.MyDebug'); -BasicTests.App.registerClass('BasicTests.App'); + return $test; +}); diff --git a/tests/TestCases/Basic/Conditionals/TraceBaseline.txt b/tests/TestCases/Basic/Conditionals/TraceBaseline.txt index 4b773147f..4937c90dd 100644 --- a/tests/TestCases/Basic/Conditionals/TraceBaseline.txt +++ b/tests/TestCases/Basic/Conditionals/TraceBaseline.txt @@ -1,32 +1,44 @@ -Type.registerNamespace('BasicTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.MyDebug + // BasicTests.MyDebug -BasicTests.MyDebug = function() { -} -BasicTests.MyDebug.showInfo = function() { -} -BasicTests.MyDebug.traceInfo = function() { -} -BasicTests.MyDebug.logInfo = function() { -} + function BasicTests$MyDebug() { + } + BasicTests$MyDebug.showInfo = function() { + } + BasicTests$MyDebug.traceInfo = function() { + } + BasicTests$MyDebug.logInfo = function() { + } + var BasicTests$MyDebug$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.App -BasicTests.App = function(i) { + // BasicTests.App + + function BasicTests$App(i) { while (true) { } switch (i) { - case 0: - break; + case 0: + break; } i++; - BasicTests.MyDebug.traceInfo(); -} + BasicTests$MyDebug.traceInfo(); + } + var BasicTests$App$ = { + + }; + + + var $test = ss.module('test', null, + { + MyDebug: [ BasicTests$MyDebug, BasicTests$MyDebug$, null ], + App: [ BasicTests$App, BasicTests$App$, null ] + }); -BasicTests.MyDebug.registerClass('BasicTests.MyDebug'); -BasicTests.App.registerClass('BasicTests.App'); + return $test; +}); diff --git a/tests/TestCases/Basic/Dependencies/Code1Baseline.txt b/tests/TestCases/Basic/Dependencies/Code1Baseline.txt index 57bfba6d8..dae1dcada 100644 --- a/tests/TestCases/Basic/Dependencies/Code1Baseline.txt +++ b/tests/TestCases/Basic/Dependencies/Code1Baseline.txt @@ -1,18 +1,22 @@ -define('test', [ 'ss','lib1' ], function(ss,lib1) { +define('test', ['ss', 'lib1'], function(ss, lib1) { + 'use strict'; + // BasicTests.App -Type.registerNamespace('BasicTests'); - -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.App - -BasicTests.App = function BasicTests_App() { + function BasicTests$App() { var c1 = new lib1.Component1(); var c2 = new Component2(); -} + } + var BasicTests$App$ = { + + }; + + var $test = ss.module('test', null, + { + App: [ BasicTests$App, BasicTests$App$, null ] + }); -BasicTests.App.registerClass('BasicTests.App'); + return $test; }); - diff --git a/tests/TestCases/Basic/Dependencies/Code2Baseline.txt b/tests/TestCases/Basic/Dependencies/Code2Baseline.txt index 94eedd067..c1e5d1988 100644 --- a/tests/TestCases/Basic/Dependencies/Code2Baseline.txt +++ b/tests/TestCases/Basic/Dependencies/Code2Baseline.txt @@ -1,20 +1,24 @@ -define('test', [ 'ss','lib1','comp3','comp4' ], function(ss,lib1,comp3,comp4) { +define('test', ['ss', 'lib1', 'comp3', 'comp4'], function(ss, lib1, comp3, comp4) { + 'use strict'; + // BasicTests.App -Type.registerNamespace('BasicTests'); - -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.App - -BasicTests.App = function BasicTests_App() { + function BasicTests$App() { var c1 = new lib1.Component1(); var c2 = new Component2(); var c3 = new comp3.Component3(); var c4 = new Component4(); -} + } + var BasicTests$App$ = { + + }; + + var $test = ss.module('test', null, + { + App: [ BasicTests$App, BasicTests$App$, null ] + }); -BasicTests.App.registerClass('BasicTests.App'); + return $test; }); - diff --git a/tests/TestCases/Basic/Dependencies/Template.js b/tests/TestCases/Basic/Dependencies/Template.js deleted file mode 100644 index 6e6a2a198..000000000 --- a/tests/TestCases/Basic/Dependencies/Template.js +++ /dev/null @@ -1,6 +0,0 @@ -define('#= Name ##', [ #= DependencyNames ## ], function(#= Dependencies ##) { - -#include[as-is] "%code%" - -}); - \ No newline at end of file diff --git a/tests/TestCases/Basic/DocComments/Baseline.txt b/tests/TestCases/Basic/DocComments/Baseline.txt index 411ea20f3..ccd9f49ba 100644 --- a/tests/TestCases/Basic/DocComments/Baseline.txt +++ b/tests/TestCases/Basic/DocComments/Baseline.txt @@ -1,61 +1,32 @@ -Type.registerNamespace('BasicTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.Suit + // BasicTests.Suit -BasicTests.Suit = function() { - /// - /// Represents a card suit. - /// - /// - /// The hearts. - /// - /// - /// The spades. - /// - /// - /// The clubs. - /// - /// - /// The diamonds. - /// -}; -BasicTests.Suit.prototype = { + var BasicTests$Suit = { heart: 0, spade: 1, club: 2, diamond: 3 -} -BasicTests.Suit.registerEnum('BasicTests.Suit', false); + }; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.RecordClass + // BasicTests.IInterface -BasicTests.$create_RecordClass = function BasicTests_RecordClass(count) { - var $o = { }; - return $o; -} + function BasicTests$IInterface() { } -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.IInterface + // BasicTests.RecordClass -BasicTests.IInterface = function() { - /// - /// Represents an interface. - /// -}; -BasicTests.IInterface.prototype = { - execute : null -} -BasicTests.IInterface.registerInterface('BasicTests.IInterface'); + function BasicTests$RecordClass(count) { + var $o = {}; + return $o; + } -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.BaseClass + // BasicTests.BaseClass -BasicTests.BaseClass = function BasicTests_BaseClass(domElement, name, count) { + function BasicTests$BaseClass(domElement, name, count) { /// /// Represents a base class. /// @@ -82,213 +53,211 @@ BasicTests.BaseClass = function BasicTests_BaseClass(domElement, name, count) { /// /// /// + this.instanceField = 0; this._domElement = domElement; -} -BasicTests.BaseClass.get_totalCount = function BasicTests_BaseClass$get_totalCount() { + } + BasicTests$BaseClass.get_totalCount = function() { /// /// Gets the total count. /// /// return 0; -} -BasicTests.BaseClass.staticMethod = function BasicTests_BaseClass$staticMethod(length) { + } + BasicTests$BaseClass.staticMethod = function(length) { /// /// A static method. /// /// /// The length. /// -} -BasicTests.BaseClass.prototype = { - instanceField: 0, - _domElement: null, - - get_name: function BasicTests_BaseClass$get_name() { - /// - /// Gets or sets the name. - /// - /// - return null; + } + var BasicTests$BaseClass$ = { + get_name: function() { + /// + /// Gets or sets the name. + /// + /// + return null; }, - set_name: function BasicTests_BaseClass$set_name(value) { - /// - /// Gets or sets the name. - /// - /// - return value; + set_name: function(value) { + /// + /// Gets or sets the name. + /// + /// + return value; }, - - get_domElement: function BasicTests_BaseClass$get_domElement() { - /// - /// Gets or sets the element. - /// - /// - return null; + get_domElement: function() { + /// + /// Gets or sets the element. + /// + /// + return null; }, - set_domElement: function BasicTests_BaseClass$set_domElement(value) { - /// - /// Gets or sets the element. - /// - /// - return value; + set_domElement: function(value) { + /// + /// Gets or sets the element. + /// + /// + return value; }, - - get_count: function BasicTests_BaseClass$get_count() { - /// - /// Gets the count. - /// - /// - return 0; + get_count: function() { + /// + /// Gets the count. + /// + /// + return 0; }, - - get__privateName: function BasicTests_BaseClass$get__privateName() { - /// - /// Gets the private name. - /// - /// - return null; + get__privateName: function() { + /// + /// Gets the private name. + /// + /// + return null; }, - - add_initialized: function BasicTests_BaseClass$add_initialized(value) { - /// - /// Adds or removes a delegate for the Initialized event. - /// - /// - this.__initialized = ss.Delegate.combine(this.__initialized, value); + add_initialized: function(value) { + /// + /// Adds or removes a delegate for the Initialized event. + /// + /// + this.__initialized = ss.Delegate.combine(this.__initialized, value); }, - remove_initialized: function BasicTests_BaseClass$remove_initialized(value) { - /// - /// Adds or removes a delegate for the Initialized event. - /// - /// - this.__initialized = ss.Delegate.remove(this.__initialized, value); + remove_initialized: function(value) { + /// + /// Adds or removes a delegate for the Initialized event. + /// + /// + this.__initialized = ss.Delegate.remove(this.__initialized, value); }, - - __initialized: null, - - method1: function BasicTests_BaseClass$method1() { - /// - /// Empty method. - /// + method1: function() { + /// + /// Empty method. + /// }, - - method2: function BasicTests_BaseClass$method2() { - /// - /// Method with return value. - /// - /// - return null; + method2: function() { + /// + /// Method with return value. + /// + /// + return null; }, - - method3: function BasicTests_BaseClass$method3(first, last) { - /// - /// Method with params. - /// - /// - /// The first name. - /// - /// - /// The last name. - /// + method3: function(first, last) { + /// + /// Method with params. + /// + /// + /// The first name. + /// + /// + /// The last name. + /// }, - - method4: function BasicTests_BaseClass$method4(count) { - /// - /// Method with both params and return value. - /// - /// - /// The count. - /// - /// - return null; + method4: function(count) { + /// + /// Method with both params and return value. + /// + /// + /// The count. + /// + /// + return null; }, - - onInitialized: function BasicTests_BaseClass$onInitialized() { - /// - /// Raises the Initialized event. - /// - if (this.__initialized != null) { - } + onInitialized: function() { + /// + /// Raises the Initialized event. + /// + if (this.__initialized != null) { + } }, - - _privateMethod: function BasicTests_BaseClass$_privateMethod(count) { - /// - /// Private method. - /// - /// - /// The count. - /// + _privateMethod: function(count) { + /// + /// Private method. + /// + /// + /// The count. + /// }, - get_item: function BasicTests_BaseClass$get_item(ids) { - /// - /// Gets item by identifiers. - /// - /// - /// The identifiers. - /// - /// - /// - /// - return null; + get_item: function(ids) { + /// + /// Gets item by identifiers. + /// + /// + /// The identifiers. + /// + /// + /// + /// + return null; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.DerivedClass + // BasicTests.InternalClass -BasicTests.DerivedClass = function BasicTests_DerivedClass() { + function BasicTests$InternalClass() { /// - /// Represents a derived class. + /// An internal class. /// - BasicTests.DerivedClass.initializeBase(this, [ null, null, 0 ]); -} -BasicTests.DerivedClass.prototype = { - - method3: function BasicTests_DerivedClass$method3(first, last) { - /// - /// Overriden method with params. - /// - /// - /// The first name. - /// - /// - /// The last name. - /// - } -} + } + var BasicTests$InternalClass$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.InternalClass -BasicTests.InternalClass = function BasicTests_InternalClass() { - /// - /// An internal class. - /// -} + // BasicTests.InternalClassWithNoComments + function BasicTests$InternalClassWithNoComments() { + } + var BasicTests$InternalClassWithNoComments$ = { -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.InternalClassWithNoComments + }; -BasicTests.InternalClassWithNoComments = function BasicTests_InternalClassWithNoComments() { -} + // BasicTests.GlobalMethodsClass -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.GlobalMethodsClass - -window.run = function BasicTests_GlobalMethodsClass$run() { + this.run = function() { /// /// Runs. /// -} + } + + + // BasicTests.DerivedClass + + function BasicTests$DerivedClass() { + /// + /// Represents a derived class. + /// + BasicTests$BaseClass.call(this, null, null, 0); + } + var BasicTests$DerivedClass$ = { + method3: function(first, last) { + /// + /// Overriden method with params. + /// + /// + /// The first name. + /// + /// + /// The last name. + /// + } + }; + + + var $test = ss.module('test', + { + InternalClass: [ BasicTests$InternalClass, BasicTests$InternalClass$, null ], + InternalClassWithNoComments: [ BasicTests$InternalClassWithNoComments, BasicTests$InternalClassWithNoComments$, null ] + }, + { + Suit: BasicTests$Suit, + IInterface: [ BasicTests$IInterface ], + RecordClass: BasicTests$RecordClass, + BaseClass: [ BasicTests$BaseClass, BasicTests$BaseClass$, null ], + DerivedClass: [ BasicTests$DerivedClass, BasicTests$DerivedClass$, BasicTests$BaseClass ] + }); + BasicTests$BaseClass.constantField = 3; -BasicTests.BaseClass.registerClass('BasicTests.BaseClass'); -BasicTests.DerivedClass.registerClass('BasicTests.DerivedClass', BasicTests.BaseClass); -BasicTests.InternalClass.registerClass('BasicTests.InternalClass'); -BasicTests.InternalClassWithNoComments.registerClass('BasicTests.InternalClassWithNoComments'); -BasicTests.BaseClass.constantField = 3; -BasicTests.BaseClass.staticField = null; + return $test; +}); diff --git a/tests/TestCases/Basic/Flags/Baseline.txt b/tests/TestCases/Basic/Flags/Baseline.txt index 6a580de4b..81d37d8ce 100644 --- a/tests/TestCases/Basic/Flags/Baseline.txt +++ b/tests/TestCases/Basic/Flags/Baseline.txt @@ -1,22 +1,27 @@ -Type.registerNamespace('BasicTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.App + // BasicTests.App -BasicTests.App = function() { -} -BasicTests.App.prototype = { - + function BasicTests$App() { + } + var BasicTests$App$ = { method1: function(i) { - var j = i; - var x = j++; + var j = i; + var x = j++; }, - method2: function(i) { - var j = 10; - var x = j++; + var j = 10; + var x = j++; } -} + }; -BasicTests.App.registerClass('BasicTests.App'); + var $test = ss.module('test', null, + { + App: [ BasicTests$App, BasicTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Basic/Metadata/Baseline.txt b/tests/TestCases/Basic/Metadata/Baseline.txt index e85df447b..830c7a03b 100644 --- a/tests/TestCases/Basic/Metadata/Baseline.txt +++ b/tests/TestCases/Basic/Metadata/Baseline.txt @@ -13,10 +13,10 @@ Types: Generated Name: App Global Methods: False Interfaces: - BasicTests.IApp + IApp Constructor: Constructor: - AssociatedType: BasicTests.App + AssociatedType: App Visibility: Public Generated Name: Members: @@ -140,7 +140,7 @@ Types: Global Methods: False Constructor: Constructor: - AssociatedType: BasicTests.Point + AssociatedType: Point Visibility: Public Generated Name: Parameters:Parameter: x @@ -279,6 +279,7 @@ Types: Public: True Generated Name: arguments Global Methods: False + BaseClass: Object Indexer: Indexer: Item AssociatedType: Object @@ -311,6 +312,7 @@ Types: Public: True Generated Name: Array Global Methods: False + BaseClass: Object Indexer: Indexer: Item AssociatedType: Object @@ -359,7 +361,7 @@ Types: Generated Name: forEach Abstract: False Method: GetEnumerator - AssociatedType: System.Collections.IEnumerator + AssociatedType: IEnumerator Visibility: Public Generated Name: getEnumerator Abstract: False @@ -467,16 +469,6 @@ Types: Generated Name: Number Global Methods: False Members: - Method: Format - AssociatedType: String - Visibility: Public - Generated Name: format - Abstract: False - Method: LocaleFormat - AssociatedType: String - Visibility: Public - Generated Name: localeFormat - Abstract: False Method: ToString AssociatedType: String Visibility: Public @@ -499,7 +491,7 @@ Types: Public: True Generated Name: CancelEventArgs Global Methods: False - BaseClass: System.EventArgs + BaseClass: EventArgs Members: Field: Cancel AssociatedType: Boolean @@ -529,11 +521,12 @@ Types: Public: True Generated Name: Date Global Methods: False + BaseClass: Object Members: Field: Empty AssociatedType: Date Visibility: Public, Static - Generated Name: empty + Generated Name: Empty Property: Now AssociatedType: Date Visibility: Public, Static @@ -546,11 +539,6 @@ Types: Generated Name: today ReadOnly: True Abstract: False - Method: Format - AssociatedType: String - Visibility: Public - Generated Name: format - Abstract: False Method: GetDate AssociatedType: Int32 Visibility: Public @@ -646,11 +634,6 @@ Types: Visibility: Public, Static Generated Name: isEmpty Abstract: False - Method: LocaleFormat - AssociatedType: String - Visibility: Public - Generated Name: localeFormat - Abstract: False Method: Parse AssociatedType: Date Visibility: Public, Static @@ -804,38 +787,29 @@ Types: Public: True Generated Name: Delegate Global Methods: False + BaseClass: Object Members: Field: Empty - AssociatedType: System.Delegate - Visibility: Public, Static - Generated Name: empty - Method: ClearExport - AssociatedType: Void + AssociatedType: Delegate Visibility: Public, Static - Generated Name: clearExport - Abstract: False + Generated Name: Empty Method: Combine - AssociatedType: System.Delegate + AssociatedType: Delegate Visibility: Public, Static Generated Name: combine Abstract: False Method: Create - AssociatedType: System.Delegate + AssociatedType: Delegate Visibility: Public, Static Generated Name: create Abstract: False - Method: CreateExport - AssociatedType: String - Visibility: Public, Static - Generated Name: createExport - Abstract: False - Method: DeleteExport - AssociatedType: Void + Method: Export + AssociatedType: Export Visibility: Public, Static - Generated Name: deleteExport + Generated Name: publish Abstract: False Method: Remove - AssociatedType: System.Delegate + AssociatedType: Delegate Visibility: Public, Static Generated Name: remove Abstract: False @@ -846,16 +820,6 @@ Types: Generated Name: Number Global Methods: False Members: - Method: Format - AssociatedType: String - Visibility: Public - Generated Name: format - Abstract: False - Method: LocaleFormat - AssociatedType: String - Visibility: Public - Generated Name: localeFormat - Abstract: False Method: Parse AssociatedType: Double Visibility: Public, Static @@ -889,9 +853,10 @@ Types: Public: True Generated Name: EventArgs Global Methods: False + BaseClass: Object Members: Field: Empty - AssociatedType: System.EventArgs + AssociatedType: EventArgs Visibility: Public, Static Generated Name: Empty @@ -922,6 +887,7 @@ Types: Public: True Generated Name: Error Global Methods: False + BaseClass: Object Indexer: Indexer: Item AssociatedType: Object @@ -948,6 +914,28 @@ Types: Generated Name: Error.createError Abstract: False + Class: Export + Application Type: False + Public: True + Generated Name: Export + Global Methods: False + BaseClass: Object + Members: + Field: Name + AssociatedType: String + Visibility: Public + Generated Name: name + Method: Clear + AssociatedType: Void + Visibility: Public + Generated Name: clear + Abstract: False + Method: Dispose + AssociatedType: Void + Visibility: Public + Generated Name: dispose + Abstract: False + Delegate: Func`1 Application Type: False Public: True @@ -1052,6 +1040,7 @@ Types: Public: True Generated Name: Function Global Methods: False + BaseClass: Object Members: Field: Length AssociatedType: Int32 @@ -1085,16 +1074,6 @@ Types: Generated Name: Number Global Methods: False Members: - Method: Format - AssociatedType: String - Visibility: Public - Generated Name: format - Abstract: False - Method: LocaleFormat - AssociatedType: String - Visibility: Public - Generated Name: localeFormat - Abstract: False Method: ToString AssociatedType: String Visibility: Public @@ -1107,16 +1086,6 @@ Types: Generated Name: Number Global Methods: False Members: - Method: Format - AssociatedType: String - Visibility: Public - Generated Name: format - Abstract: False - Method: LocaleFormat - AssociatedType: String - Visibility: Public - Generated Name: localeFormat - Abstract: False Method: Parse AssociatedType: Int32 Visibility: Public, Static @@ -1134,16 +1103,6 @@ Types: Generated Name: Number Global Methods: False Members: - Method: Format - AssociatedType: String - Visibility: Public - Generated Name: format - Abstract: False - Method: LocaleFormat - AssociatedType: String - Visibility: Public - Generated Name: localeFormat - Abstract: False Method: ToString AssociatedType: String Visibility: Public @@ -1155,6 +1114,7 @@ Types: Public: True Generated Name: Math Global Methods: False + BaseClass: Object Members: Field: E AssociatedType: Double @@ -1313,6 +1273,7 @@ Types: Public: True Generated Name: Number Global Methods: False + BaseClass: Object Members: Field: MAX_VALUE AssociatedType: Int32 @@ -1334,11 +1295,6 @@ Types: AssociatedType: Int32 Visibility: Public, Static Generated Name: POSITIVE_INFINITY - Method: Format - AssociatedType: String - Visibility: Public - Generated Name: format - Abstract: False Method: IsFinite AssociatedType: Boolean Visibility: Public, Static @@ -1349,11 +1305,6 @@ Types: Visibility: Public, Static Generated Name: isNaN Abstract: False - Method: LocaleFormat - AssociatedType: String - Visibility: Public - Generated Name: localeFormat - Abstract: False Method: Parse AssociatedType: Number Visibility: Public, Static @@ -1422,6 +1373,7 @@ Types: Public: True Generated Name: Record Global Methods: False + BaseClass: Object Members: Class: RegularExpression @@ -1429,6 +1381,7 @@ Types: Public: True Generated Name: RegExp Global Methods: False + BaseClass: Object Members: Field: LastIndex AssociatedType: Int32 @@ -1476,16 +1429,6 @@ Types: Generated Name: Number Global Methods: False Members: - Method: Format - AssociatedType: String - Visibility: Public - Generated Name: format - Abstract: False - Method: LocaleFormat - AssociatedType: String - Visibility: Public - Generated Name: localeFormat - Abstract: False Method: ToString AssociatedType: String Visibility: Public @@ -1497,6 +1440,7 @@ Types: Public: True Generated Name: Script Global Methods: True + BaseClass: Object Members: Method: Boolean AssociatedType: Boolean @@ -1640,16 +1584,6 @@ Types: Generated Name: Number Global Methods: False Members: - Method: Format - AssociatedType: String - Visibility: Public - Generated Name: format - Abstract: False - Method: LocaleFormat - AssociatedType: String - Visibility: Public - Generated Name: localeFormat - Abstract: False Method: Parse AssociatedType: Single Visibility: Public, Static @@ -1676,6 +1610,7 @@ Types: Public: True Generated Name: String Global Methods: False + BaseClass: Object Indexer: Indexer: Item AssociatedType: Char @@ -1767,16 +1702,6 @@ Types: Visibility: Public, Static Generated Name: fromCharCode Abstract: False - Method: HtmlDecode - AssociatedType: String - Visibility: Public - Generated Name: htmlDecode - Abstract: False - Method: HtmlEncode - AssociatedType: String - Visibility: Public - Generated Name: htmlEncode - Abstract: False Method: IndexOf AssociatedType: Int32 Visibility: Public @@ -1812,16 +1737,6 @@ Types: Visibility: Public Generated Name: lastIndexOfAny Abstract: False - Method: LocaleCompare - AssociatedType: Int32 - Visibility: Public - Generated Name: localeCompare - Abstract: False - Method: LocaleFormat - AssociatedType: String - Visibility: Public, Static - Generated Name: localeFormat - Abstract: False Method: Match AssociatedType: Array Visibility: Public @@ -1928,18 +1843,19 @@ Types: Public: True Generated Name: StringBuilder Global Methods: False + BaseClass: Object Members: Field: IsEmpty AssociatedType: Boolean Visibility: Public Generated Name: isEmpty Method: Append - AssociatedType: System.StringBuilder + AssociatedType: StringBuilder Visibility: Public Generated Name: append Abstract: False Method: AppendLine - AssociatedType: System.StringBuilder + AssociatedType: StringBuilder Visibility: Public Generated Name: appendLine Abstract: False @@ -1970,6 +1886,7 @@ Types: Public: True Generated Name: Tuple Global Methods: False + BaseClass: Object Members: Field: First AssociatedType: T1 @@ -1985,6 +1902,7 @@ Types: Public: True Generated Name: Tuple Global Methods: False + BaseClass: Object Members: Field: First AssociatedType: T1 @@ -2004,6 +1922,7 @@ Types: Public: True Generated Name: Type Global Methods: False + BaseClass: Object Members: Property: BaseType AssociatedType: Type @@ -2011,12 +1930,6 @@ Types: Generated Name: baseType ReadOnly: True Abstract: False - Property: FullName - AssociatedType: String - Visibility: Public - Generated Name: fullName - ReadOnly: True - Abstract: False Property: Name AssociatedType: String Visibility: Public @@ -2073,16 +1986,6 @@ Types: Generated Name: Number Global Methods: False Members: - Method: Format - AssociatedType: String - Visibility: Public - Generated Name: format - Abstract: False - Method: LocaleFormat - AssociatedType: String - Visibility: Public - Generated Name: localeFormat - Abstract: False Method: ToString AssociatedType: String Visibility: Public @@ -2095,16 +1998,6 @@ Types: Generated Name: Number Global Methods: False Members: - Method: Format - AssociatedType: String - Visibility: Public - Generated Name: format - Abstract: False - Method: LocaleFormat - AssociatedType: String - Visibility: Public - Generated Name: localeFormat - Abstract: False Method: ToString AssociatedType: String Visibility: Public @@ -2117,16 +2010,6 @@ Types: Generated Name: Number Global Methods: False Members: - Method: Format - AssociatedType: String - Visibility: Public - Generated Name: format - Abstract: False - Method: LocaleFormat - AssociatedType: String - Visibility: Public - Generated Name: localeFormat - Abstract: False Method: ToString AssociatedType: String Visibility: Public @@ -2171,6 +2054,7 @@ Types: Public: True Generated Name: Array Global Methods: False + BaseClass: Object Indexer: Indexer: Item AssociatedType: Object @@ -2223,7 +2107,7 @@ Types: Generated Name: forEach Abstract: False Method: GetEnumerator - AssociatedType: System.Collections.IEnumerator + AssociatedType: IEnumerator Visibility: Public Generated Name: getEnumerator Abstract: False @@ -2333,6 +2217,7 @@ Types: Public: True Generated Name: Array Global Methods: False + BaseClass: Object Indexer: Indexer: Item AssociatedType: Object @@ -2396,7 +2281,7 @@ Types: Generated Name: forEach Abstract: False Method: GetEnumerator - AssociatedType: System.Collections.IEnumerator + AssociatedType: IEnumerator Visibility: Public Generated Name: getEnumerator Abstract: False @@ -2533,6 +2418,7 @@ Types: Public: True Generated Name: Object Global Methods: False + BaseClass: Object Indexer: Indexer: Item AssociatedType: Object @@ -2604,6 +2490,7 @@ Types: Public: True Generated Name: DictionaryEntry Global Methods: False + BaseClass: Object Members: Field: Key AssociatedType: String @@ -2630,7 +2517,7 @@ Types: Generated Name: IEnumerable Members: Method: GetEnumerator - AssociatedType: System.Collections.IEnumerator + AssociatedType: IEnumerator Visibility: Public Generated Name: getEnumerator Abstract: True @@ -2670,6 +2557,7 @@ Types: Public: True Generated Name: ObservableCollection Global Methods: False + BaseClass: Object Indexer: Indexer: Item AssociatedType: Object @@ -2700,7 +2588,7 @@ Types: Generated Name: contains Abstract: False Method: GetEnumerator - AssociatedType: System.Collections.IEnumerator + AssociatedType: IEnumerator Visibility: Public Generated Name: getEnumerator Abstract: False @@ -2735,6 +2623,7 @@ Types: Public: True Generated Name: Array Global Methods: False + BaseClass: Object Members: Field: Count AssociatedType: Int32 @@ -2771,6 +2660,7 @@ Types: Public: True Generated Name: Array Global Methods: False + BaseClass: Object Members: Field: Count AssociatedType: Int32 @@ -2822,6 +2712,7 @@ Types: Public: True Generated Name: Object Global Methods: False + BaseClass: Object Indexer: Indexer: Item AssociatedType: TValue @@ -2837,7 +2728,7 @@ Types: ReadOnly: True Abstract: False Property: Keys - AssociatedType: System.Collections.Generic.IReadonlyCollection`1 + AssociatedType: IReadonlyCollection`1 Visibility: Public Generated Name: keys ReadOnly: True @@ -2863,7 +2754,7 @@ Types: Generated Name: getDictionary Abstract: False Method: GetEnumerator - AssociatedType: System.Collections.Generic.IEnumerator`1 + AssociatedType: IEnumerator`1 Visibility: Public Generated Name: getEnumerator Abstract: False @@ -2894,7 +2785,7 @@ Types: Generated Name: IEnumerable Members: Method: GetEnumerator - AssociatedType: System.Collections.Generic.IEnumerator`1 + AssociatedType: IEnumerator`1 Visibility: Public Generated Name: getEnumerator Abstract: True @@ -2934,6 +2825,7 @@ Types: Public: True Generated Name: Object Global Methods: False + BaseClass: Object Members: Field: Key AssociatedType: TKey @@ -2949,6 +2841,7 @@ Types: Public: True Generated Name: Array Global Methods: False + BaseClass: Object Indexer: Indexer: Item AssociatedType: T @@ -3012,7 +2905,7 @@ Types: Generated Name: forEach Abstract: False Method: GetEnumerator - AssociatedType: System.Collections.Generic.IEnumerator`1 + AssociatedType: IEnumerator`1 Visibility: Public Generated Name: getEnumerator Abstract: False @@ -3139,6 +3032,7 @@ Types: Public: True Generated Name: Array Global Methods: False + BaseClass: Object Indexer: Indexer: Item AssociatedType: T @@ -3181,7 +3075,7 @@ Types: Generated Name: forEach Abstract: False Method: GetEnumerator - AssociatedType: System.Collections.Generic.IEnumerator`1 + AssociatedType: IEnumerator`1 Visibility: Public Generated Name: getEnumerator Abstract: False @@ -3303,6 +3197,7 @@ Types: Public: True Generated Name: ObservableCollection Global Methods: False + BaseClass: Object Indexer: Indexer: Item AssociatedType: T @@ -3333,7 +3228,7 @@ Types: Generated Name: contains Abstract: False Method: GetEnumerator - AssociatedType: System.Collections.Generic.IEnumerator`1 + AssociatedType: IEnumerator`1 Visibility: Public Generated Name: getEnumerator Abstract: False @@ -3368,6 +3263,7 @@ Types: Public: True Generated Name: Array Global Methods: False + BaseClass: Object Members: Field: Count AssociatedType: Int32 @@ -3404,6 +3300,7 @@ Types: Public: True Generated Name: Array Global Methods: False + BaseClass: Object Members: Field: Count AssociatedType: Int32 @@ -3524,6 +3421,7 @@ Types: Public: True Generated Name: Observable Global Methods: False + BaseClass: Object Members: Method: GetValue AssociatedType: T @@ -3541,9 +3439,10 @@ Types: Public: True Generated Name: Observable Global Methods: False + BaseClass: Object Members: Method: RegisterObserver - AssociatedType: System.IDisposable + AssociatedType: IDisposable Visibility: Public, Static Generated Name: registerObserver Abstract: False @@ -3557,6 +3456,7 @@ Types: Public: True Generated Name: console Global Methods: False + BaseClass: Object Members: Method: Assert AssociatedType: Void @@ -3587,21 +3487,22 @@ Types: Class: CultureInfo Application Type: False Public: True - Generated Name: CultureInfo + Generated Name: culture Global Methods: False + BaseClass: Object Members: Field: CurrentCulture - AssociatedType: System.Globalization.CultureInfo + AssociatedType: CultureInfo Visibility: Public, Static - Generated Name: CurrentCulture + Generated Name: current Field: DateFormat AssociatedType: DateFormatInfo Visibility: Public - Generated Name: dateFormat + Generated Name: dtf Field: InvariantCulture - AssociatedType: System.Globalization.CultureInfo + AssociatedType: CultureInfo Visibility: Public, Static - Generated Name: InvariantCulture + Generated Name: neutral Field: Name AssociatedType: String Visibility: Public @@ -3609,185 +3510,187 @@ Types: Field: NumberFormat AssociatedType: NumberFormatInfo Visibility: Public - Generated Name: numberFormat + Generated Name: nf Class: DateFormatInfo Application Type: False Public: True Generated Name: DateFormatInfo Global Methods: False + BaseClass: Object Members: Field: AMDesignator AssociatedType: String Visibility: Public - Generated Name: amDesignator + Generated Name: am Field: PMDesignator AssociatedType: String Visibility: Public - Generated Name: pmDesignator + Generated Name: pm Field: DateSeparator AssociatedType: String Visibility: Public - Generated Name: dateSeparator + Generated Name: ds Field: TimeSeparator AssociatedType: String Visibility: Public - Generated Name: timeSeparator + Generated Name: ts Field: GMTDateTimePattern AssociatedType: String Visibility: Public - Generated Name: gmtDateTimePattern + Generated Name: gmt Field: UniversalDateTimePattern AssociatedType: String Visibility: Public - Generated Name: universalDateTimePattern + Generated Name: uni Field: SortableDateTimePattern AssociatedType: String Visibility: Public - Generated Name: sortableDateTimePattern + Generated Name: sort Field: DateTimePattern AssociatedType: String Visibility: Public - Generated Name: dateTimePattern + Generated Name: dt Field: LongDatePattern AssociatedType: String Visibility: Public - Generated Name: longDatePattern + Generated Name: ld Field: ShortDatePattern AssociatedType: String Visibility: Public - Generated Name: shortDatePattern + Generated Name: sd Field: LongTimePattern AssociatedType: String Visibility: Public - Generated Name: longTimePattern + Generated Name: lt Field: ShortTimePattern AssociatedType: String Visibility: Public - Generated Name: shortTimePattern + Generated Name: st Field: FirstDayOfWeek AssociatedType: Int32 Visibility: Public - Generated Name: firstDayOfWeek + Generated Name: day0 Field: DayNames AssociatedType: Array Visibility: Public - Generated Name: dayNames + Generated Name: day Field: ShortDayNames AssociatedType: Array Visibility: Public - Generated Name: shortDayNames + Generated Name: sday Field: MinimizedDayNames AssociatedType: Array Visibility: Public - Generated Name: minimizedDayNames + Generated Name: mday Field: MonthNames AssociatedType: Array Visibility: Public - Generated Name: monthNames + Generated Name: mon Field: ShortMonthNames AssociatedType: Array Visibility: Public - Generated Name: shortMonthNames + Generated Name: smon Class: NumberFormatInfo Application Type: False Public: True Generated Name: NumberFormatInfo Global Methods: False + BaseClass: Object Members: Field: NaNSymbol AssociatedType: String Visibility: Public - Generated Name: naNSymbol + Generated Name: nan Field: NegativeSign AssociatedType: String Visibility: Public - Generated Name: negativeSign + Generated Name: neg Field: PositiveSign AssociatedType: String Visibility: Public - Generated Name: positiveSign + Generated Name: pos Field: NegativeInfinityText AssociatedType: String Visibility: Public - Generated Name: negativeInfinityText + Generated Name: negInf Field: PositiveInfinityText AssociatedType: String Visibility: Public - Generated Name: positiveInfinityText + Generated Name: posInf Field: PercentSymbol AssociatedType: String Visibility: Public - Generated Name: percentSymbol + Generated Name: per Field: PercentGroupSizes AssociatedType: Array Visibility: Public - Generated Name: percentGroupSizes + Generated Name: perGW Field: PercentDecimalDigits AssociatedType: Int32 Visibility: Public - Generated Name: percentDecimalDigits + Generated Name: perDD Field: PercentDecimalSeparator AssociatedType: String Visibility: Public - Generated Name: percentDecimalSeparator + Generated Name: perDS Field: PercentGroupSeparator AssociatedType: String Visibility: Public - Generated Name: percentGroupSeparator - Field: PercentPositivePattern + Generated Name: perGS + Field: PercentNegativePattern AssociatedType: String Visibility: Public - Generated Name: percentPositivePattern - Field: PercentNegativePattern + Generated Name: perNP + Field: PercentPositivePattern AssociatedType: String Visibility: Public - Generated Name: percentNegativePattern + Generated Name: perPP Field: CurrencySymbol AssociatedType: String Visibility: Public - Generated Name: currencySymbol + Generated Name: cur Field: CurrencyGroupSizes AssociatedType: Array Visibility: Public - Generated Name: currencyGroupSizes + Generated Name: curGW Field: CurrencyDecimalDigits AssociatedType: Int32 Visibility: Public - Generated Name: currencyDecimalDigits + Generated Name: curDD Field: CurrencyDecimalSeparator AssociatedType: String Visibility: Public - Generated Name: currencyDecimalSeparator + Generated Name: curDS Field: CurrencyGroupSeparator AssociatedType: String Visibility: Public - Generated Name: currencyGroupSeparator - Field: CurrencyPositivePattern + Generated Name: curGS + Field: CurrencyNegativePattern AssociatedType: String Visibility: Public - Generated Name: currencyPositivePattern - Field: CurrencyNegativePattern + Generated Name: curNP + Field: CurrencyPositivePattern AssociatedType: String Visibility: Public - Generated Name: currencyNegativePattern + Generated Name: curPP Field: NumberGroupSizes AssociatedType: Array Visibility: Public - Generated Name: numberGroupSizes + Generated Name: gw Field: NumberDecimalDigits AssociatedType: Int32 Visibility: Public - Generated Name: numberDecimalDigits + Generated Name: dd Field: NumberDecimalSeparator AssociatedType: String Visibility: Public - Generated Name: numberDecimalSeparator + Generated Name: ds Field: NumberGroupSeparator AssociatedType: String Visibility: Public - Generated Name: numberGroupSeparator + Generated Name: gs Namespace: System.Serialization @@ -3798,6 +3701,7 @@ Types: Public: True Generated Name: JSON Global Methods: False + BaseClass: Object Members: Method: Parse AssociatedType: Object @@ -3846,6 +3750,7 @@ Types: Public: True Generated Name: Assert Global Methods: False + BaseClass: Object Members: Method: AreEqual AssociatedType: Void @@ -3873,6 +3778,7 @@ Types: Public: True Generated Name: TestClass Global Methods: False + BaseClass: Object Members: Method: Cleanup AssociatedType: Void @@ -3890,6 +3796,7 @@ Types: Public: True Generated Name: TestEngine Global Methods: False + BaseClass: Object Members: Method: Log AssociatedType: Void @@ -3921,9 +3828,10 @@ Types: Public: True Generated Name: Deferred Global Methods: False + BaseClass: Object Members: Field: Task - AssociatedType: System.Threading.Task + AssociatedType: Task Visibility: Public Generated Name: task Method: Reject @@ -3942,10 +3850,10 @@ Types: Public: True Generated Name: Deferred Global Methods: False - BaseClass: System.Threading.Deferred + BaseClass: Deferred Members: Field: Task - AssociatedType: System.Threading.Task`1 + AssociatedType: Task`1 Visibility: Public Generated Name: task Method: Resolve @@ -3959,6 +3867,7 @@ Types: Public: True Generated Name: Task Global Methods: False + BaseClass: Object Members: Property: Completed AssociatedType: Boolean @@ -3975,37 +3884,37 @@ Types: Visibility: Public Generated Name: status Method: All - AssociatedType: System.Threading.Task`1 + AssociatedType: Task`1 Visibility: Public, Static Generated Name: all Abstract: False Method: Any - AssociatedType: System.Threading.Task`1 + AssociatedType: Task`1 Visibility: Public, Static Generated Name: any Abstract: False Method: ContinueWith - AssociatedType: System.Threading.Task + AssociatedType: Task Visibility: Public Generated Name: continueWith Abstract: False Method: Delay - AssociatedType: System.Threading.Task + AssociatedType: Task Visibility: Public, Static Generated Name: delay Abstract: False Method: Done - AssociatedType: System.Threading.Task + AssociatedType: Task Visibility: Public Generated Name: done Abstract: False Method: Fail - AssociatedType: System.Threading.Task + AssociatedType: Task Visibility: Public Generated Name: fail Abstract: False Method: Then - AssociatedType: System.Threading.Task + AssociatedType: Task Visibility: Public Generated Name: then Abstract: False @@ -4015,19 +3924,19 @@ Types: Public: True Generated Name: Task Global Methods: False - BaseClass: System.Threading.Task + BaseClass: Task Members: Field: Result AssociatedType: T Visibility: Public Generated Name: result Method: ContinueWith - AssociatedType: System.Threading.Task`1 + AssociatedType: Task`1 Visibility: Public Generated Name: continueWith Abstract: False Method: Done - AssociatedType: System.Threading.Task`1 + AssociatedType: Task`1 Visibility: Public Generated Name: done Abstract: False @@ -4058,122 +3967,108 @@ Script ================================================================ -Type.registerNamespace('BasicTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.AppFlags + // BasicTests.AppFlags -BasicTests.AppFlags = function() { }; -BasicTests.AppFlags.prototype = { + var BasicTests$AppFlags = { AAA: 1, BBB: 2 -} -BasicTests.AppFlags.registerEnum('BasicTests.AppFlags', true); + }; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.Mode + // BasicTests.Mode -BasicTests.Mode = function() { }; -BasicTests.Mode.prototype = { + var BasicTests$Mode = { mode1: 0, mode2: 1 -} -BasicTests.Mode.registerEnum('BasicTests.Mode', false); - + }; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.IFoo -BasicTests.IFoo = function() { }; -BasicTests.IFoo.prototype = { + // BasicTests.IFoo -} -BasicTests.IFoo.registerInterface('BasicTests.IFoo'); + function BasicTests$IFoo() { } -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.IApp + // BasicTests.IApp -BasicTests.IApp = function() { }; -BasicTests.IApp.prototype = { - run : null -} -BasicTests.IApp.registerInterface('BasicTests.IApp'); + function BasicTests$IApp() { } -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.Point + // BasicTests.Point -BasicTests.$create_Point = function BasicTests_Point(x, y) { - var $o = { }; + function BasicTests$Point(x, y) { + var $o = {}; $o.x = x; $o.y = y; return $o; -} + } -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.App + // BasicTests.App -BasicTests.App = function BasicTests_App() { -} -BasicTests.App.prototype = { - - add_event1: function BasicTests_App$add_event1(value) { - this.__event1 = ss.Delegate.combine(this.__event1, value); + function BasicTests$App() { + } + var BasicTests$App$ = { + add_event1: function(value) { + this.__event1 = ss.Delegate.combine(this.__event1, value); }, - remove_event1: function BasicTests_App$remove_event1(value) { - this.__event1 = ss.Delegate.remove(this.__event1, value); + remove_event1: function(value) { + this.__event1 = ss.Delegate.remove(this.__event1, value); }, - - __event1: null, - - add_event2: function BasicTests_App$add_event2(value) { + add_event2: function(value) { }, - remove_event2: function BasicTests_App$remove_event2(value) { + remove_event2: function(value) { }, - - run: function BasicTests_App$run() { + run: function() { }, - - _initialize: function BasicTests_App$_initialize() { + _initialize: function() { } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.AppHelper + // BasicTests.AppHelper -BasicTests.AppHelper = function BasicTests_AppHelper() { -} -BasicTests.AppHelper.prototype = { - - get_prop1: function BasicTests_AppHelper$get_prop1() { - return 0; + function BasicTests$AppHelper() { + } + var BasicTests$AppHelper$ = { + get_prop1: function() { + return 0; }, - - get_prop2: function BasicTests_AppHelper$get_prop2() { - return 0; + get_prop2: function() { + return 0; }, - set_prop2: function BasicTests_AppHelper$set_prop2(value) { - return value; + set_prop2: function(value) { + return value; }, - - _showHelp: function BasicTests_AppHelper$_showHelp() { + _showHelp: function() { }, - get_item: function BasicTests_AppHelper$get_item(name) { - return 0; + get_item: function(name) { + return 0; } -} + }; + + // BasicTests.Util -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.Util + this._showHelp = function() { + } -window._showHelp = function BasicTests_Util$_showHelp() { -} + + var $test = ss.module('test', + { + IFoo: [ BasicTests$IFoo ], + Point: BasicTests$Point, + AppHelper: [ BasicTests$AppHelper, BasicTests$AppHelper$, null ] + }, + { + AppFlags: BasicTests$AppFlags, + Mode: BasicTests$Mode, + IApp: [ BasicTests$IApp ], + App: [ BasicTests$App, BasicTests$App$, null, BasicTests$IApp ] + }); -BasicTests.App.registerClass('BasicTests.App', null, BasicTests.IApp); -BasicTests.AppHelper.registerClass('BasicTests.AppHelper'); + return $test; +}); diff --git a/tests/TestCases/Basic/Minimization/Baseline.txt b/tests/TestCases/Basic/Minimization/Baseline.txt index 039678d26..77d5e08b7 100644 --- a/tests/TestCases/Basic/Minimization/Baseline.txt +++ b/tests/TestCases/Basic/Minimization/Baseline.txt @@ -1,10 +1,10 @@ Minimization Map ================================================================ - Member '__valueChanged' renamed to '$1_5' - Member '_intVal' renamed to '$1_0' - Member '_intVal2' renamed to '$1_1' - Member '_intVal3' renamed to '$1_2' - Member '_strVal' renamed to '$1_3' + Member '__valueChanged' renamed to 'c$5' + Member '_intVal' renamed to 'c$0' + Member '_intVal2' renamed to 'c$1' + Member '_intVal3' renamed to 'c$2' + Member '_strVal' renamed to 'c$3' Member 'Alpha' renamed to '$0' Member 'Dispose' renamed to '$1' Member 'DoStuff' renamed to '$0' @@ -18,10 +18,10 @@ Minimization Map Member 'Foo' renamed to '$2' Member 'Initialize' renamed to '$0' Member 'Numeric' renamed to '$1' - Member 'OnClicked' renamed to '$3_1' - Member 'OnValueChanged' renamed to '$1_6' - Member 'OnValueChanged' renamed to '$3_0' - Member 'Property1' renamed to '$1_7' + Member 'OnClicked' renamed to 'e$1' + Member 'OnValueChanged' renamed to 'e$0' + Member 'OnValueChanged' renamed to 'c$6' + Member 'Property1' renamed to 'c$7' Member 'Setup' renamed to '$2' Member 'ShowHelp' renamed to '$0' Member 'string1' renamed to '$0' @@ -29,275 +29,300 @@ Minimization Map Member 'Stuff' renamed to '$5' Member 'StuffProperty' renamed to '$6' Member 'ToString' renamed to 'toString' - Member 'ValueChanged' renamed to '$1_4' + Member 'ValueChanged' renamed to 'c$4' Script ================================================================ -Type.registerNamespace('BasicTests'); +define('test', ['ss', 'lib'], function(ss, lib) { + 'use strict'; -BasicTests.AppFlags = function() { }; -BasicTests.AppFlags.prototype = { + // BasicTests.AppFlags + + var BasicTests$AppFlags = { AAA: 0, BBB: 1 -} -BasicTests.AppFlags.registerEnum('BasicTests.AppFlags', false); + }; + + + // BasicTests.IApp + function BasicTests$IApp() { } -BasicTests.IApp = function() { }; -BasicTests.IApp.registerInterface('BasicTests.IApp'); + // BasicTests.MyData -BasicTests.$create_MyData = function(a, b) { - var $o = { }; + function BasicTests$MyData(a, b) { + var $o = {}; $o.$0 = a; $o.$1 = b; return $o; -} + } + + + // BasicTests.GlobalMethodsClass + + this.run = function() { + } + + + // BasicTests.BaseBaseClass + + function BasicTests$BaseBaseClass() { + } + var BasicTests$BaseBaseClass$ = { + $0: function() { + } + }; -window.run = function() { -} + // BasicTests.ABC + function BasicTests$ABC() { + } + var BasicTests$ABC$ = { -BasicTests.App = function() { - var helper = new BasicTests.AppHelper(); + }; + + + // BasicTests.AppHelper + + function BasicTests$AppHelper() { + } + var BasicTests$AppHelper$ = { + $0: function() { + } + }; + + + // BasicTests.App + + function BasicTests$App() { + var helper = new BasicTests$AppHelper(); helper.$0(); -} -BasicTests.App.prototype = { - + } + var BasicTests$App$ = { run: function() { }, - $0: function() { }, - $1: function() { } -} - + }; -BasicTests.AppHelper = function() { -} -BasicTests.AppHelper.prototype = { - - $0: function() { - } -} + // BasicTests.Bar -BasicTests.Bar = function() { -} -BasicTests.Bar.prototype = { - + function BasicTests$Bar() { + } + var BasicTests$Bar$ = { $0: function() { }, - toString: function() { - return null; + return null; }, - $1: function($p0) { } -} + }; -BasicTests.Bar2 = function() { - BasicTests.Bar2.initializeBase(this); -} + // BasicTests.Bar2 + function BasicTests$Bar2() { + BasicTests$Bar.call(this); + } + var BasicTests$Bar2$ = { -BasicTests.BarEx = function() { - BasicTests.BarEx.initializeBase(this); -} -BasicTests.BarEx.prototype = { - + }; + + + // BasicTests.BaseClass + + function BasicTests$BaseClass() { + BasicTests$BaseBaseClass.call(this); + } + var BasicTests$BaseClass$ = { + $1: function() { + } + }; + + + // BasicTests.BarCustom + + function BasicTests$BarCustom() { + BasicTests$Bar.call(this); + } + var BasicTests$BarCustom$ = { + + }; + + + // BasicTests.BarEx + + function BasicTests$BarEx() { + BasicTests$Bar2.call(this); + } + var BasicTests$BarEx$ = { $2: function() { - var mode = 1; + var mode = 1; }, - $0: function() { - this.$2(); - BasicTests.BarEx.callBaseMethod(this, '$0'); - var d = BasicTests.$create_MyData('a', 'b'); - d.$0 = d.$1; + this.$2(); + BasicTests$Bar2$.$0.call(this); + var d = BasicTests$MyData('a', 'b'); + d.$0 = d.$1; }, - $3: function($p0) { - $p0 = $p0 + 2; + $p0 = $p0 + 2; }, - $4: function($p0) { - var numericValue = $p0 + 1; - var stringValue = $p0.toString(); - var value = 0; - this.$1(ss.Delegate.create(this, function($p1_0, $p1_1) { - this.$1(function($p2_0, $p2_1) { - var value = 11; - return $p2_0; - }); - var value = 10; - var value2 = 11; - return numericValue + $p1_0 + stringValue + $p1_1 + value; - })); + var numericValue = $p0 + 1; + var stringValue = $p0.toString(); + var value = 0; + this.$1(ss.Delegate.create(this, function($p1_0, $p1_1) { + this.$1(function($p2_0, $p2_1) { + var value = 11; + return $p2_0; + }); + var value = 10; + var value2 = 11; + return numericValue + $p1_0 + stringValue + $p1_1 + value; + })); }, - get_$5: function() { - return 0; + return 0; }, set_$5: function($p0) { - var x = $p0; - return $p0; + var x = $p0; + return $p0; }, - get_$6: function() { - this.$1(ss.Delegate.create(this, function($p1_0, $p1_1) { - this.$1(function($p2_0, $p2_1) { - var value = 11; - return $p2_0; - }); - var value = 10; - var value2 = 11; - return $p1_0 + $p1_1 + value; - })); - return 0; + this.$1(ss.Delegate.create(this, function($p1_0, $p1_1) { + this.$1(function($p2_0, $p2_1) { + var value = 11; + return $p2_0; + }); + var value = 10; + var value2 = 11; + return $p1_0 + $p1_1 + value; + })); + return 0; }, set_$6: function($p0) { - var numericValue = $p0 + 1; - var stringValue = $p0.toString(); - this.$1(ss.Delegate.create(this, function($p1_0, $p1_1) { - this.$1(function($p2_0, $p2_1) { - var value1 = 11; - return $p2_0; - }); - var value2 = 10; - var value3 = 11; - return numericValue + $p1_0 + stringValue + $p1_1 + $p0 + value3; - })); - return $p0; + var numericValue = $p0 + 1; + var stringValue = $p0.toString(); + this.$1(ss.Delegate.create(this, function($p1_0, $p1_1) { + this.$1(function($p2_0, $p2_1) { + var value1 = 11; + return $p2_0; + }); + var value2 = 10; + var value3 = 11; + return numericValue + $p1_0 + stringValue + $p1_1 + $p0 + value3; + })); + return $p0; } -} - + }; -BasicTests.BarCustom = function() { - BasicTests.BarCustom.initializeBase(this); -} + // BasicTests.BarCustom2 -BasicTests.BarCustom2 = function() { - BasicTests.BarCustom2.initializeBase(this); -} -BasicTests.BarCustom2.prototype = { - + function BasicTests$BarCustom2() { + BasicTests$BarCustom.call(this); + } + var BasicTests$BarCustom2$ = { $2: function() { - return 0; + return 0; }, - baz: function() { - return 0; + return 0; }, - xyz: function() { } -} - - -BasicTests.FooBehavior = function(e, i) { - BasicTests.FooBehavior.initializeBase(this, [ e, null ]); - this.$1_0 = i; - this.$1_1 = i * 2; - this.$1_2 = i * 4; -} -BasicTests.FooBehavior.prototype = { - $1_0: 0, - $1_1: 0, - $1_2: 0, - - add_$1_4: function($p0) { - this.$1_5 = ss.Delegate.combine(this.$1_5, $p0); + }; + + + // BasicTests.FooBehavior + + function BasicTests$FooBehavior(e, i) { + this.c$0 = 0; + this.c$1 = 0; + this.c$2 = 0; + lib.Behavior.call(this, e, null); + this.c$0 = i; + this.c$1 = i * 2; + this.c$2 = i * 4; + } + var BasicTests$FooBehavior$ = { + add_c$4: function(value) { + this.c$5 = ss.Delegate.combine(this.c$5, value); }, - remove_$1_4: function($p0) { - this.$1_5 = ss.Delegate.remove(this.$1_5, $p0); + remove_c$4: function(value) { + this.c$5 = ss.Delegate.remove(this.c$5, value); }, - - $1_5: null, - dispose: function() { - this.$1_0 = 0; - BasicTests.FooBehavior.callBaseMethod(this, 'dispose'); + this.c$0 = 0; + lib.Behavior.prototype.dispose.call(this); }, - - $1_6: function() { + c$6: function() { }, - - get_$1_7: function() { - return null; + get_c$7: function() { + return null; }, get_item: function($p0) { - return 0; + return 0; } -} - + }; -BasicTests.MaskTextBox = function(e) { - BasicTests.MaskTextBox.initializeBase(this, [ e ]); -} -BasicTests.MaskTextBox.prototype = { - - $3_0: function() { - }, - - $3_1: function() { - } -} + // BasicTests.DerivedClass -BasicTests.DerivedClass = function() { - BasicTests.DerivedClass.initializeBase(this); -} -BasicTests.DerivedClass.prototype = { - + function BasicTests$DerivedClass() { + BasicTests$BaseClass.call(this); + } + var BasicTests$DerivedClass$ = { $2: function() { } -} + }; -BasicTests.BaseClass = function() { - BasicTests.BaseClass.initializeBase(this); -} -BasicTests.BaseClass.prototype = { - - $1: function() { + // BasicTests.MaskTextBox + + function BasicTests$MaskTextBox(e) { + lib.TextBox.call(this, e); + } + var BasicTests$MaskTextBox$ = { + e$0: function() { + }, + e$1: function() { } -} + }; + + + var $test = ss.module('test', + { + IApp: [ BasicTests$IApp ], + MyData: BasicTests$MyData, + BaseBaseClass: [ BasicTests$BaseBaseClass, BasicTests$BaseBaseClass$, null ], + ABC: [ BasicTests$ABC, BasicTests$ABC$, null ], + AppHelper: [ BasicTests$AppHelper, BasicTests$AppHelper$, null ], + Bar: [ BasicTests$Bar, BasicTests$Bar$, null ], + Bar2: [ BasicTests$Bar2, BasicTests$Bar2$, BasicTests$Bar ], + BaseClass: [ BasicTests$BaseClass, BasicTests$BaseClass$, BasicTests$BaseBaseClass ], + BarCustom: [ BasicTests$BarCustom, BasicTests$BarCustom$, BasicTests$Bar ], + BarEx: [ BasicTests$BarEx, BasicTests$BarEx$, BasicTests$Bar2 ], + BarCustom2: [ BasicTests$BarCustom2, BasicTests$BarCustom2$, BasicTests$BarCustom ], + DerivedClass: [ BasicTests$DerivedClass, BasicTests$DerivedClass$, BasicTests$BaseClass ], + MaskTextBox: [ BasicTests$MaskTextBox, BasicTests$MaskTextBox$, lib.TextBox ] + }, + { + AppFlags: BasicTests$AppFlags, + App: [ BasicTests$App, BasicTests$App$, null ], + FooBehavior: [ BasicTests$FooBehavior, BasicTests$FooBehavior$, lib.Behavior ] + }); -BasicTests.BaseBaseClass = function() { -} -BasicTests.BaseBaseClass.prototype = { - - $0: function() { - } -} - - -BasicTests.ABC = function() { -} - - -BasicTests.App.registerClass('BasicTests.App'); -BasicTests.AppHelper.registerClass('BasicTests.AppHelper'); -BasicTests.Bar.registerClass('BasicTests.Bar'); -BasicTests.Bar2.registerClass('BasicTests.Bar2', BasicTests.Bar); -BasicTests.BarEx.registerClass('BasicTests.BarEx', BasicTests.Bar2); -BasicTests.BarCustom.registerClass('BasicTests.BarCustom', BasicTests.Bar); -BasicTests.BarCustom2.registerClass('BasicTests.BarCustom2', BasicTests.BarCustom); -BasicTests.FooBehavior.registerClass('BasicTests.FooBehavior', lib.Behavior); -BasicTests.MaskTextBox.registerClass('BasicTests.MaskTextBox', lib.TextBox); -BasicTests.BaseBaseClass.registerClass('BasicTests.BaseBaseClass'); -BasicTests.BaseClass.registerClass('BasicTests.BaseClass', BasicTests.BaseBaseClass); -BasicTests.DerivedClass.registerClass('BasicTests.DerivedClass', BasicTests.BaseClass); -BasicTests.ABC.registerClass('BasicTests.ABC'); -BasicTests.FooBehavior.$1_3 = null; + return $test; +}); diff --git a/tests/TestCases/Basic/Resources/Baseline.txt b/tests/TestCases/Basic/Resources/Baseline.txt index bbe0bcab5..fa61b3edd 100644 --- a/tests/TestCases/Basic/Resources/Baseline.txt +++ b/tests/TestCases/Basic/Resources/Baseline.txt @@ -1,32 +1,42 @@ -Type.registerNamespace('BasicTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.App + // Resources.Strings1 -BasicTests.App = function BasicTests_App() { - var s1 = Resources.Strings1.string1; -} - - -Type.registerNamespace('Resources'); - -//////////////////////////////////////////////////////////////////////////////// -// Resources.Strings1 - -Resources.Strings1 = { + var Resources$Strings1 = { string1: 'neutral: aaa', string2: 'fr: bbb', string3: 'fr-FR: ccc' -}; + }; -//////////////////////////////////////////////////////////////////////////////// -// Resources.Strings2 + // Resources.Strings2 -Resources.Strings2 = { + var Resources$Strings2 = { string1: 's2', string2: '1234' -}; + }; + + + // BasicTests.App + + function BasicTests$App() { + var s1 = Resources$Strings1.string1; + } + var BasicTests$App$ = { + + }; + + + var $test = ss.module('test', + { + Strings1: Resources$Strings1 + }, + { + Strings2: Resources$Strings2, + App: [ BasicTests$App, BasicTests$App$, null ] + }); -BasicTests.App.registerClass('BasicTests.App'); + return $test; +}); diff --git a/tests/TestCases/Basic/Simple/Baseline.txt b/tests/TestCases/Basic/Simple/Baseline.txt index a753696fc..5c043b344 100644 --- a/tests/TestCases/Basic/Simple/Baseline.txt +++ b/tests/TestCases/Basic/Simple/Baseline.txt @@ -1,75 +1,72 @@ -Type.registerNamespace('Basic'); +define('basic', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// Basic.EventArgs + // Basic.EventArgs -Basic.EventArgs = function() { -} + function Basic$EventArgs() { + } + var Basic$EventArgs$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// Basic.Button -Basic.Button = function(text) { + // Basic.Button + + function Basic$Button(text) { this._text = text; -} -Basic.Button.prototype = { - _text: null, - + } + var Basic$Button$ = { add_click: function(value) { - this.__click = ss.Delegate.combine(this.__click, value); + this.__click = ss.Delegate.combine(this.__click, value); }, remove_click: function(value) { - this.__click = ss.Delegate.remove(this.__click, value); + this.__click = ss.Delegate.remove(this.__click, value); }, - - __click: null, - get_text: function() { - return this._text; + return this._text; }, - performClick: function() { - if (this.__click != null) { - this.__click(this, Basic.EventArgs.Empty); - } + if (this.__click != null) { + this.__click(this, Basic$EventArgs.Empty); + } } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// Basic.App + // Basic.App -Basic.App = function() { - this._btn1 = new Basic.Button('OK'); + function Basic$App() { + this._btn1 = new Basic$Button('OK'); this._btn1.add_click(ss.Delegate.create(this, this.onClickButton)); this._btn1.add_click(ss.Delegate.create(this, this.onClickButtonDup)); - this._btn2 = new Basic.Button('Cancel'); + this._btn2 = new Basic$Button('Cancel'); this._btn2.add_click(ss.Delegate.create(this, this.onClickButton)); -} -Basic.App.main = function(args) { - var theApp = new Basic.App(); + } + Basic$App.main = function(args) { + var theApp = new Basic$App(); theApp._btn1.performClick(); theApp._btn2.performClick(); -} -Basic.App.prototype = { - _btn1: null, - _btn2: null, - + } + var Basic$App$ = { echo: function(s) { }, - onClickButton: function(sender, e) { - this.echo((sender).get_text() + ' was clicked!'); + this.echo((sender).get_text() + ' was clicked!'); }, - onClickButtonDup: function(sender, e) { - this.echo((sender).get_text() + ' was clicked as well!'); + this.echo((sender).get_text() + ' was clicked as well!'); } -} + }; + + + var $basic = ss.module('basic', null, + { + EventArgs: [ Basic$EventArgs, Basic$EventArgs$, null ], + Button: [ Basic$Button, Basic$Button$, null ], + App: [ Basic$App, Basic$App$, null ] + }); + Basic$EventArgs.Empty = new Basic$EventArgs(); -Basic.EventArgs.registerClass('Basic.EventArgs'); -Basic.Button.registerClass('Basic.Button'); -Basic.App.registerClass('Basic.App'); -Basic.EventArgs.Empty = new Basic.EventArgs(); + return $basic; +}); diff --git a/tests/TestCases/Basic/Template/Baseline.txt b/tests/TestCases/Basic/Template/Baseline.txt index e4897a3fb..749a4ee36 100644 --- a/tests/TestCases/Basic/Template/Baseline.txt +++ b/tests/TestCases/Basic/Template/Baseline.txt @@ -2,17 +2,27 @@ alert('some static script'); -Type.registerNamespace('BasicTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.App + // BasicTests.App -BasicTests.App = function BasicTests_App() { + function BasicTests$App() { var e = document.body; -} + } + var BasicTests$App$ = { + }; -BasicTests.App.registerClass('BasicTests.App'); + + var $test = ss.module('test', null, + { + App: [ BasicTests$App, BasicTests$App$, null ] + }); + + + return $test; +}); alert('debug'); diff --git a/tests/TestCases/Basic/UnitTest/Code.cs b/tests/TestCases/Basic/UnitTest/Code.cs index 9b08f79f8..29797e84b 100644 --- a/tests/TestCases/Basic/UnitTest/Code.cs +++ b/tests/TestCases/Basic/UnitTest/Code.cs @@ -22,6 +22,9 @@ internal class InternalClass { namespace BasicTests.Tests { + internal sealed class Foo { + } + internal sealed class PublicTests : TestClass { public void TestFormat() { diff --git a/tests/TestCases/Basic/UnitTest/NonTestBaseline.txt b/tests/TestCases/Basic/UnitTest/NonTestBaseline.txt index 5cef456bb..5fc1e7f94 100644 --- a/tests/TestCases/Basic/UnitTest/NonTestBaseline.txt +++ b/tests/TestCases/Basic/UnitTest/NonTestBaseline.txt @@ -1,38 +1,42 @@ -Type.registerNamespace('BasicTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.PublicClass + // BasicTests.PublicClass -BasicTests.PublicClass = function() { -} -BasicTests.PublicClass.prototype = { - + function BasicTests$PublicClass() { + } + var BasicTests$PublicClass$ = { format: function(i) { - return '0'; + return '0'; }, - parse: function(s) { - return 0; + return 0; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.InternalClass + // BasicTests.InternalClass -BasicTests.InternalClass = function() { -} -BasicTests.InternalClass.prototype = { - + function BasicTests$InternalClass() { + } + var BasicTests$InternalClass$ = { format: function(i) { - return null; + return null; }, - parse: function(s) { - return 0; + return 0; } -} + }; -BasicTests.PublicClass.registerClass('BasicTests.PublicClass'); -BasicTests.InternalClass.registerClass('BasicTests.InternalClass'); + var $test = ss.module('test', + { + InternalClass: [ BasicTests$InternalClass, BasicTests$InternalClass$, null ] + }, + { + PublicClass: [ BasicTests$PublicClass, BasicTests$PublicClass$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Basic/UnitTest/TestBaseline.txt b/tests/TestCases/Basic/UnitTest/TestBaseline.txt index 2a414143e..b9546d41b 100644 --- a/tests/TestCases/Basic/UnitTest/TestBaseline.txt +++ b/tests/TestCases/Basic/UnitTest/TestBaseline.txt @@ -1,124 +1,125 @@ -Type.registerNamespace('BasicTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.PublicClass + // BasicTests.PublicClass -BasicTests.PublicClass = function() { -} -BasicTests.PublicClass.prototype = { - + function BasicTests$PublicClass() { + } + var BasicTests$PublicClass$ = { format: function(i) { - return '0'; + return '0'; }, - parse: function(s) { - return 0; + return 0; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.InternalClass + // BasicTests.InternalClass -BasicTests.InternalClass = function() { -} -BasicTests.InternalClass.prototype = { - + function BasicTests$InternalClass() { + } + var BasicTests$InternalClass$ = { format: function(i) { - return null; + return null; }, - parse: function(s) { - return 0; + return 0; } -} + }; -Type.registerNamespace('BasicTests.Tests'); + // BasicTests.Tests.Foo -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.Tests.PublicTests + function BasicTests$Tests$Foo() { + } + var BasicTests$Tests$Foo$ = { -BasicTests.Tests.PublicTests = function() { - BasicTests.Tests.PublicTests.initializeBase(this); -} -BasicTests.Tests.PublicTests.prototype = { - + }; + + + // BasicTests.Tests.PublicTests + + function BasicTests$Tests$PublicTests() { + } + var BasicTests$Tests$PublicTests$ = { testFormat: function() { - QUnit.expect(1); - var testee = new BasicTests.PublicClass(); - var s = testee.format(0); - QUnit.equal(s, '0', "Expected '0' for result."); + QUnit.expect(1); + var testee = new BasicTests$PublicClass(); + var s = testee.format(0); + QUnit.equal(s, '0', "Expected '0' for result."); } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// BasicTests.Tests.InternalTests + // BasicTests.Tests.InternalTests -BasicTests.Tests.InternalTests = function() { - BasicTests.Tests.InternalTests.initializeBase(this); -} -BasicTests.Tests.InternalTests.prototype = { - _startTime: null, - _endTime: null, - + function BasicTests$Tests$InternalTests() { + } + var BasicTests$Tests$InternalTests$ = { testFormat: function() { - QUnit.expect(1); - var testee = new BasicTests.InternalClass(); - var s = testee.format(0); - QUnit.equal(s, '0', "Expected '0' for result."); + QUnit.expect(1); + var testee = new BasicTests$InternalClass(); + var s = testee.format(0); + QUnit.equal(s, '0', "Expected '0' for result."); }, - testParse: function() { - QUnit.expect(1); - var testee = new BasicTests.InternalClass(); - var i = testee.parse('0'); - QUnit.equal(i, 0, 'Expected 0 for result.'); + QUnit.expect(1); + var testee = new BasicTests$InternalClass(); + var i = testee.parse('0'); + QUnit.equal(i, 0, 'Expected 0 for result.'); }, - setup: function() { - this._startTime = Date.get_now(); + this._startTime = Date.get_now(); }, - cleanup: function() { - this._endTime = Date.get_now(); + this._endTime = Date.get_now(); } -} + }; -BasicTests.PublicClass.registerClass('BasicTests.PublicClass'); -BasicTests.InternalClass.registerClass('BasicTests.InternalClass'); -BasicTests.Tests.PublicTests.registerClass('BasicTests.Tests.PublicTests'); -BasicTests.Tests.InternalTests.registerClass('BasicTests.Tests.InternalTests'); + var $test = ss.module('test', + { + InternalClass: [ BasicTests$InternalClass, BasicTests$InternalClass$, null ], + Foo: [ BasicTests$Tests$Foo, BasicTests$Tests$Foo$, null ], + PublicTests: [ BasicTests$Tests$PublicTests, BasicTests$Tests$PublicTests$, null ], + InternalTests: [ BasicTests$Tests$InternalTests, BasicTests$Tests$InternalTests$, null ] + }, + { + PublicClass: [ BasicTests$PublicClass, BasicTests$PublicClass$, null ] + }); + -module('PublicTests', { + module('PublicTests', { setup: function() { - this.instance = new BasicTests.Tests.PublicTests(); + this.instance = new BasicTests$Tests$PublicTests(); }, teardown: function() { - delete this.instance; + delete this.instance; } -}); + }); -test('testFormat', function() { + test('testFormat', function() { this.instance.testFormat(); -}); + }); -module('InternalTests', { + module('InternalTests', { setup: function() { - this.instance = new BasicTests.Tests.InternalTests(); - this.instance.setup(); + this.instance = new BasicTests$Tests$InternalTests(); + this.instance.setup(); }, teardown: function() { - this.instance.cleanup(); - delete this.instance; + this.instance.cleanup(); + delete this.instance; } -}); + }); -test('testFormat', function() { + test('testFormat', function() { this.instance.testFormat(); -}); -test('testParse', function() { + }); + test('testParse', function() { this.instance.testParse(); + }); + + return $test; }); diff --git a/tests/TestCases/Expression/AnonymousMethods/Baseline.txt b/tests/TestCases/Expression/AnonymousMethods/Baseline.txt index 05b6fbe22..4c50dbf00 100644 --- a/tests/TestCases/Expression/AnonymousMethods/Baseline.txt +++ b/tests/TestCases/Expression/AnonymousMethods/Baseline.txt @@ -1,59 +1,66 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.SomeClass + // ExpressionTests.SomeClass -ExpressionTests.SomeClass = function(cb) { -} + function ExpressionTests$SomeClass(cb) { + } + var ExpressionTests$SomeClass$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Test -ExpressionTests.Test = function() { -} -ExpressionTests.Test.main = function(args) { + // ExpressionTests.Test + + function ExpressionTests$Test() { + this._n = 0; + } + ExpressionTests$Test.main = function(args) { var o = {}; var name; - ExpressionTests.Test.doStuffStatic(o, function(i, s, b) { - name = s; + ExpressionTests$Test.doStuffStatic(o, function(i, s, b) { + name = s; }); -} -ExpressionTests.Test.doStuffStatic = function(o, callback) { -} -ExpressionTests.Test.prototype = { - _n: 0, - + } + ExpressionTests$Test.doStuffStatic = function(o, callback) { + } + var ExpressionTests$Test$ = { AAA: function() { - var o = {}; + var o = {}; + this.doStuff(o, ss.Delegate.create(this, function(i, s, b) { + this._n = i; + })); + var s = new ExpressionTests$SomeClass(function() { + }); + for (var i = 0; i < 10; i++) { + var foo; + this.doStuff(o, function(i, s, b) { + foo = i + s; + }); this.doStuff(o, ss.Delegate.create(this, function(i, s, b) { - this._n = i; + this._n += i; })); - var s = new ExpressionTests.SomeClass(function() { + ExpressionTests$Test.doStuffStatic(o, function() { }); - for (var i = 0; i < 10; i++) { - var foo; - this.doStuff(o, function(i, s, b) { - foo = i + s; - }); - this.doStuff(o, ss.Delegate.create(this, function(i, s, b) { - this._n += i; - })); - ExpressionTests.Test.doStuffStatic(o, function() { - }); - ExpressionTests.Test.doStuffStatic(o, ss.Delegate.create(this, function() { - this._n++; - })); - } - var s2 = new ExpressionTests.SomeClass(ss.Delegate.create(this, function() { - var numbers = [ this._n ]; + ExpressionTests$Test.doStuffStatic(o, ss.Delegate.create(this, function() { + this._n++; })); + } + var s2 = new ExpressionTests$SomeClass(ss.Delegate.create(this, function() { + var numbers = [ this._n ]; + })); }, - doStuff: function(o, callback) { } -} + }; + + + var $test = ss.module('test', null, + { + SomeClass: [ ExpressionTests$SomeClass, ExpressionTests$SomeClass$, null ], + Test: [ ExpressionTests$Test, ExpressionTests$Test$, null ] + }); -ExpressionTests.SomeClass.registerClass('ExpressionTests.SomeClass'); -ExpressionTests.Test.registerClass('ExpressionTests.Test'); + return $test; +}); diff --git a/tests/TestCases/Expression/Arguments/Baseline.txt b/tests/TestCases/Expression/Arguments/Baseline.txt index 59875ea79..40a756d12 100644 --- a/tests/TestCases/Expression/Arguments/Baseline.txt +++ b/tests/TestCases/Expression/Arguments/Baseline.txt @@ -1,18 +1,24 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - var count = arguments.length; - var value = arguments[0]; - var items = Array.toArray(arguments); + var count = arguments.length; + var value = arguments[0]; + var items = Array.toArray(arguments); } -} + }; -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/Base/Baseline.txt b/tests/TestCases/Expression/Base/Baseline.txt index 724c9f4d8..747bb5a07 100644 --- a/tests/TestCases/Expression/Base/Baseline.txt +++ b/tests/TestCases/Expression/Base/Baseline.txt @@ -1,39 +1,41 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Foo + // ExpressionTests.Foo -ExpressionTests.Foo = function(i, j) { -} -ExpressionTests.Foo.prototype = { - + function ExpressionTests$Foo(i, j) { + } + var ExpressionTests$Foo$ = { toString: function() { - return 'Foo'; + return 'Foo'; }, - sum: function(i) { - return 0; + return 0; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Bar + // ExpressionTests.Bar -ExpressionTests.Bar = function(i, j, f) { - ExpressionTests.Bar.initializeBase(this, [ i, j ]); -} -ExpressionTests.Bar.prototype = { - + function ExpressionTests$Bar(i, j, f) { + ExpressionTests$Foo.call(this, i, j); + } + var ExpressionTests$Bar$ = { sum: function() { - return ExpressionTests.Bar.callBaseMethod(this, 'sum', [ 1 ]) + 1; + return ExpressionTests$Foo$.sum.call(this, 1) + 1; }, - toString: function() { - return ExpressionTests.Bar.callBaseMethod(this, 'toString') + ' -> Bar'; + return ExpressionTests$Foo$.toString.call(this) + ' -> Bar'; } -} + }; -ExpressionTests.Foo.registerClass('ExpressionTests.Foo'); -ExpressionTests.Bar.registerClass('ExpressionTests.Bar', ExpressionTests.Foo); + var $test = ss.module('test', null, + { + Foo: [ ExpressionTests$Foo, ExpressionTests$Foo$, null ], + Bar: [ ExpressionTests$Bar, ExpressionTests$Bar$, ExpressionTests$Foo ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/Binary/Baseline.txt b/tests/TestCases/Expression/Binary/Baseline.txt index b01f96021..aac674cef 100644 --- a/tests/TestCases/Expression/Binary/Baseline.txt +++ b/tests/TestCases/Expression/Binary/Baseline.txt @@ -1,121 +1,118 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Data + // ExpressionTests.Data -ExpressionTests.Data = function() { -} -ExpressionTests.Data.prototype = { - _value: 0, - + function ExpressionTests$Data() { + this._value = 0; + } + var ExpressionTests$Data$ = { get_value: function() { - return this._value; + return this._value; }, set_value: function(value) { - this._value = value; - return value; + this._value = value; + return value; }, - get_flag: function() { - return true; + return true; }, set_flag: function(value) { - return value; + return value; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { get_foo: function() { - return 0; + return 0; }, set_foo: function(value) { - return value; + return value; }, - get_bar: function() { - return 0; + return 0; }, set_bar: function(value) { - return value; + return value; }, - get_data: function() { - return new ExpressionTests.Data(); + return new ExpressionTests$Data(); }, set_data: function(value) { - return value; + return value; }, - get_flag1: function() { - return this.get_data().get_flag(); + return this.get_data().get_flag(); }, - get_flag2: function() { - return ExpressionTests.Data.staticFlag; + return ExpressionTests$Data.staticFlag; }, - test: function(arg1, arg2) { - var sum = arg1 + arg2; - sum += arg2 * -1; - sum = arg1 - arg2; - sum = arg1 * arg2; - sum = arg1 / arg2; - sum = arg1 ^ arg2; - sum = arg1 >> 2; - sum *= arg2; - sum ^= arg2; - var f = arg1; - var s = (f + 1).toExponential(); - var len = (10 + s).length; - var b = (f < 10); - sum = arg1 + (arg2 + 1) * 10; - sum = arg1 + (arg2 + ~arg1) * (arg1 - 10); - var b2 = Type.canCast(sum, Number); - var o = Type.safeCast(b, ss.IDisposable); - this.set_foo(this.get_foo() + 10); - this.set_foo(this.get_foo() - this.get_bar()); - sum = sum << 1; - sum <<= 1; - var xyz; - var abc; - abc = xyz << 1; - abc = xyz >>> 2; - abc <<= 1; - xyz >>>= 1; - var d = new ExpressionTests.Data(); - d.set_value(d.get_value() + 5); - d.set_flag((d.get_flag() | true) === 1); - var o1 = null || {}; - var s2 = (10).toString(); - s2 = (100).toString(); - s2 = true.toString(); - s2 = (10.1).toString(); - s2 = 'aaa'; + var sum = arg1 + arg2; + sum += arg2 * -1; + sum = arg1 - arg2; + sum = arg1 * arg2; + sum = arg1 / arg2; + sum = arg1 ^ arg2; + sum = arg1 >> 2; + sum *= arg2; + sum ^= arg2; + var f = arg1; + var s = (f + 1).toExponential(); + var len = (10 + s).length; + var b = (f < 10); + sum = arg1 + (arg2 + 1) * 10; + sum = arg1 + (arg2 + ~arg1) * (arg1 - 10); + var b2 = Type.canCast(sum, Number); + var o = Type.safeCast(b, ss.IDisposable); + this.set_foo(this.get_foo() + 10); + this.set_foo(this.get_foo() - this.get_bar()); + sum = sum << 1; + sum <<= 1; + var xyz; + var abc; + abc = xyz << 1; + abc = xyz >>> 2; + abc <<= 1; + xyz >>>= 1; + var d = new ExpressionTests$Data(); + d.set_value(d.get_value() + 5); + d.set_flag((d.get_flag() | true) === 1); + var o1 = null || {}; + var s2 = (10).toString(); + s2 = (100).toString(); + s2 = true.toString(); + s2 = (10.1).toString(); + s2 = 'aaa'; }, - bitwiseBooleans: function() { - var a = (true & false) === 1; - var b = (true | false) === 1; - var c = (true ^ false) === 1; - a = (a & true) === 1; - b = (b | true) === 1; - c = (c ^ true) === 1; - a = (a | (a || a)) === 1; - var d = new ExpressionTests.Data(); - d.set_flag((d.get_flag() & true) === 1); - d.set_flag((d.get_flag() | true) === 1); - d.set_flag((d.get_flag() ^ true) === 1); + var a = (true & false) === 1; + var b = (true | false) === 1; + var c = (true ^ false) === 1; + a = (a & true) === 1; + b = (b | true) === 1; + c = (c ^ true) === 1; + a = (a | (a || a)) === 1; + var d = new ExpressionTests$Data(); + d.set_flag((d.get_flag() & true) === 1); + d.set_flag((d.get_flag() | true) === 1); + d.set_flag((d.get_flag() ^ true) === 1); } -} + }; -ExpressionTests.Data.registerClass('ExpressionTests.Data'); -ExpressionTests.App.registerClass('ExpressionTests.App'); -ExpressionTests.Data.staticFlag = false; + var $test = ss.module('test', null, + { + Data: [ ExpressionTests$Data, ExpressionTests$Data$, null ], + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + ExpressionTests$Data.staticFlag = false; + + return $test; +}); diff --git a/tests/TestCases/Expression/Cast/Baseline.txt b/tests/TestCases/Expression/Cast/Baseline.txt index 64f33ba7d..feb1259c9 100644 --- a/tests/TestCases/Expression/Cast/Baseline.txt +++ b/tests/TestCases/Expression/Cast/Baseline.txt @@ -1,37 +1,43 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - var f = arg / 2; - var d = 0.25; - var i = parseInt(f); - var j = parseInt(d); - var f2 = d; - var a = 1; - var b = 2; - var n1 = a / b; - var n2 = parseInt((a / b)); - var d2 = a / b; - var action = function() { - }; - var secondAction = Type.safeCast(action, Function); - if (Type.canCast(action, Function)) { - } - var cb = Type.safeCast(action, Function); - if (Type.canCast(action, Function)) { - cb = action; - } - var action2 = Type.safeCast(action, Function); - if (action2 != null) { - } + var f = arg / 2; + var d = 0.25; + var i = parseInt(f); + var j = parseInt(d); + var f2 = d; + var a = 1; + var b = 2; + var n1 = a / b; + var n2 = parseInt((a / b)); + var d2 = a / b; + var action = function() { + }; + var secondAction = Type.safeCast(action, Function); + if (Type.canCast(action, Function)) { + } + var cb = Type.safeCast(action, Function); + if (Type.canCast(action, Function)) { + cb = action; + } + var action2 = Type.safeCast(action, Function); + if (action2 != null) { + } } -} + }; -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/Conditional/Baseline.txt b/tests/TestCases/Expression/Conditional/Baseline.txt index b19399a27..c8d1a3d50 100644 --- a/tests/TestCases/Expression/Conditional/Baseline.txt +++ b/tests/TestCases/Expression/Conditional/Baseline.txt @@ -1,21 +1,27 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - var b = (!arg) ? true : false; - b = (!arg) ? true : false; - var n = (!arg) ? --arg : ++arg; - n = (!arg) ? ((b) ? 10 : (arg - 1)) : 100; - var s = (n > 50) ? 'xyz' : 'abc'; - var l = (s != null) ? s.length : 'Hello'.length; + var b = (!arg) ? true : false; + b = (!arg) ? true : false; + var n = (!arg) ? --arg : ++arg; + n = (!arg) ? ((b) ? 10 : (arg - 1)) : 100; + var s = (n > 50) ? 'xyz' : 'abc'; + var l = (s != null) ? s.length : 'Hello'.length; } -} + }; -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/Delegates/Baseline.txt b/tests/TestCases/Expression/Delegates/Baseline.txt index 03c1114b6..efbdadabc 100644 --- a/tests/TestCases/Expression/Delegates/Baseline.txt +++ b/tests/TestCases/Expression/Delegates/Baseline.txt @@ -1,54 +1,64 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.EventArgs + // ExpressionTests.EventArgs -ExpressionTests.EventArgs = function() { -} + function ExpressionTests$EventArgs() { + } + var ExpressionTests$EventArgs$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.SomeClass -ExpressionTests.SomeClass = function(handler) { -} + // ExpressionTests.SomeClass + function ExpressionTests$SomeClass(handler) { + } + var ExpressionTests$SomeClass$ = { -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Test + }; -ExpressionTests.Test = function() { + + // ExpressionTests.Test + + function ExpressionTests$Test() { this._handler = ss.Delegate.create(this, this.onEvent); this._handler = ss.Delegate.create(this, this.onEvent); this._handler = ss.Delegate.create(this, this.onEvent); - this._handler = ExpressionTests.Test2.onGlobalEvent; - var s1 = new ExpressionTests.SomeClass(ss.Delegate.create(this, this.onEvent)); - var s2 = new ExpressionTests.SomeClass(this._handler); -} -ExpressionTests.Test.prototype = { - _handler: null, - + this._handler = ExpressionTests$Test2.onGlobalEvent; + var s1 = new ExpressionTests$SomeClass(ss.Delegate.create(this, this.onEvent)); + var s2 = new ExpressionTests$SomeClass(this._handler); + } + var ExpressionTests$Test$ = { doStuff: function() { - if (this._handler != null) { - this._handler(this, null); - } + if (this._handler != null) { + this._handler(this, null); + } }, - onEvent: function(sender, e) { } -} + }; + + + // ExpressionTests.Test2 + + function ExpressionTests$Test2() { + } + ExpressionTests$Test2.onGlobalEvent = function(sender, e) { + } + var ExpressionTests$Test2$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Test2 -ExpressionTests.Test2 = function() { -} -ExpressionTests.Test2.onGlobalEvent = function(sender, e) { -} + var $test = ss.module('test', null, + { + EventArgs: [ ExpressionTests$EventArgs, ExpressionTests$EventArgs$, null ], + SomeClass: [ ExpressionTests$SomeClass, ExpressionTests$SomeClass$, null ], + Test: [ ExpressionTests$Test, ExpressionTests$Test$, null ], + Test2: [ ExpressionTests$Test2, ExpressionTests$Test2$, null ] + }); -ExpressionTests.EventArgs.registerClass('ExpressionTests.EventArgs'); -ExpressionTests.SomeClass.registerClass('ExpressionTests.SomeClass'); -ExpressionTests.Test.registerClass('ExpressionTests.Test'); -ExpressionTests.Test2.registerClass('ExpressionTests.Test2'); + return $test; +}); diff --git a/tests/TestCases/Expression/Dictionary/Baseline.txt b/tests/TestCases/Expression/Dictionary/Baseline.txt index febff6e3e..f435d89ac 100644 --- a/tests/TestCases/Expression/Dictionary/Baseline.txt +++ b/tests/TestCases/Expression/Dictionary/Baseline.txt @@ -1,51 +1,53 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { getData: function() { - return null; + return null; }, - getData2: function() { - return null; + return null; }, - test: function(arg) { - var dictionary1 = {}; - var dictionary2 = { xyz: 1, abc: new ExpressionTests.App(), 'delete': 2, 'test.': 3, '\t': 4 }; + var dictionary1 = {}; + var dictionary2 = { xyz: 1, abc: new ExpressionTests$App(), 'delete': 2, 'test.': 3, '\t': 4 }; }, - test2: function(arg) { - var dictionary1 = { aaa: 123, xyz: true }; - var key = 'blah'; - var c = Object.getKeyCount(dictionary1); - var c2 = Object.getKeyCount(this.getData()); - var b = Object.keyExists(dictionary1, 'aaa'); - delete dictionary1.aaa; - delete dictionary1['Proxy-Connection']; - delete dictionary1[key]; - Object.clearKeys(dictionary1); - var keys = Object.keys(dictionary1); + var dictionary1 = { aaa: 123, xyz: true }; + var key = 'blah'; + var c = Object.getKeyCount(dictionary1); + var c2 = Object.getKeyCount(this.getData()); + var b = Object.keyExists(dictionary1, 'aaa'); + delete dictionary1.aaa; + delete dictionary1['Proxy-Connection']; + delete dictionary1[key]; + Object.clearKeys(dictionary1); + var keys = Object.keys(dictionary1); }, - test3: function(arg) { - var dictionary1 = { aaa: 123, xyz: true }; - var key = 'blah'; - var c = Object.getKeyCount(dictionary1); - var c2 = Object.getKeyCount(this.getData2()); - var b = Object.keyExists(dictionary1, 'aaa'); - delete dictionary1.aaa; - delete dictionary1['Proxy-Connection']; - delete dictionary1[key]; - Object.clearKeys(dictionary1); - var keys = Object.keys(dictionary1); + var dictionary1 = { aaa: 123, xyz: true }; + var key = 'blah'; + var c = Object.getKeyCount(dictionary1); + var c2 = Object.getKeyCount(this.getData2()); + var b = Object.keyExists(dictionary1, 'aaa'); + delete dictionary1.aaa; + delete dictionary1['Proxy-Connection']; + delete dictionary1[key]; + Object.clearKeys(dictionary1); + var keys = Object.keys(dictionary1); } -} + }; -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/EnumToString/MinBaseline.txt b/tests/TestCases/Expression/EnumToString/MinBaseline.txt index 16876dd1b..5d1ec9410 100644 --- a/tests/TestCases/Expression/EnumToString/MinBaseline.txt +++ b/tests/TestCases/Expression/EnumToString/MinBaseline.txt @@ -1,23 +1,31 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + // ExpressionTests.App + + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - var s1 = (0).toString(); - var s2 = (2).toString(); - var s3 = '$0'; - var s4 = (0).toString(); + var s1 = (0).toString(); + var s2 = (2).toString(); + var s3 = '$0'; + var s4 = (0).toString(); }, - $0: function($p0, $p1, $p2, $p3) { - var mstr = $p0.toString(); - var cstr = $p1.toString(); - var sstr = $p2; - var tstr = $p3.toString(); + var mstr = $p0.toString(); + var cstr = $p1.toString(); + var sstr = $p2; + var tstr = $p3.toString(); } -} + }; + + + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); -ExpressionTests.App.registerClass('ExpressionTests.App'); + return $test; +}); diff --git a/tests/TestCases/Expression/EnumToString/NormalBaseline.txt b/tests/TestCases/Expression/EnumToString/NormalBaseline.txt index 4afddba2e..beb65ce8b 100644 --- a/tests/TestCases/Expression/EnumToString/NormalBaseline.txt +++ b/tests/TestCases/Expression/EnumToString/NormalBaseline.txt @@ -1,63 +1,62 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Color + // ExpressionTests.Color -ExpressionTests.Color = function() { }; -ExpressionTests.Color.prototype = { + var ExpressionTests$Color = { red: 1, green: 2, blue: 3 -} -ExpressionTests.Color.registerEnum('ExpressionTests.Color', false); + }; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.State + // ExpressionTests.State -ExpressionTests.State = function() { }; -ExpressionTests.State.prototype = { + var ExpressionTests$State = { starting: 'starting', running: 'running', completed: 'completed' -} -ExpressionTests.State.registerEnum('ExpressionTests.State', false); + }; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Types + // ExpressionTests.Types -ExpressionTests.Types = function() { }; -ExpressionTests.Types.prototype = { + var ExpressionTests$Types = { none: 0, type1: 1, type2: 2, type3: 4 -} -ExpressionTests.Types.registerEnum('ExpressionTests.Types', true); + }; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - var s1 = (0).toString(); - var s2 = (2).toString(); - var s3 = 'starting'; - var s4 = (0).toString(); + var s1 = (0).toString(); + var s2 = (2).toString(); + var s3 = 'starting'; + var s4 = (0).toString(); }, - display: function(m, c, s, t) { - var mstr = m.toString(); - var cstr = c.toString(); - var sstr = s; - var tstr = t.toString(); + var mstr = m.toString(); + var cstr = c.toString(); + var sstr = s; + var tstr = t.toString(); } -} + }; -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + Color: ExpressionTests$Color, + State: ExpressionTests$State, + Types: ExpressionTests$Types, + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/Events/Baseline.txt b/tests/TestCases/Expression/Events/Baseline.txt index 2158ed614..866559378 100644 --- a/tests/TestCases/Expression/Events/Baseline.txt +++ b/tests/TestCases/Expression/Events/Baseline.txt @@ -1,100 +1,97 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.FooEventArgs + // ExpressionTests.Button -ExpressionTests.FooEventArgs = function() { - ExpressionTests.FooEventArgs.initializeBase(this); -} - - -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Button - -ExpressionTests.Button = function() { -} -ExpressionTests.Button.add_test = function(value) { - ExpressionTests.Button.__test = ss.Delegate.combine(ExpressionTests.Button.__test, value); -} -ExpressionTests.Button.remove_test = function(value) { - ExpressionTests.Button.__test = ss.Delegate.remove(ExpressionTests.Button.__test, value); -} -ExpressionTests.Button.prototype = { - _aaa: null, - _bbb: null, - + function ExpressionTests$Button() { + } + ExpressionTests$Button.add_test = function(value) { + ExpressionTests$Button.__test = ss.Delegate.combine(ExpressionTests$Button.__test, value); + } + ExpressionTests$Button.remove_test = function(value) { + ExpressionTests$Button.__test = ss.Delegate.remove(ExpressionTests$Button.__test, value); + } + var ExpressionTests$Button$ = { add_click: function(value) { - this.__click = ss.Delegate.combine(this.__click, value); + this.__click = ss.Delegate.combine(this.__click, value); }, remove_click: function(value) { - this.__click = ss.Delegate.remove(this.__click, value); + this.__click = ss.Delegate.remove(this.__click, value); }, - - __click: null, - add_aaa: function(value) { - if (this._aaa == null) { - this._aaa = value; - } - else { - this._aaa = ss.Delegate.combine(this._aaa, value); - } + if (this._aaa == null) { + this._aaa = value; + } + else { + this._aaa = ss.Delegate.combine(this._aaa, value); + } }, remove_aaa: function(value) { - this._aaa = ss.Delegate.remove(this._aaa, value); + this._aaa = ss.Delegate.remove(this._aaa, value); }, - add_bbb: function(value) { - if (this._bbb == null) { - this._bbb = value; - } - else { - this._bbb = ss.Delegate.combine(this._bbb, value); - } + if (this._bbb == null) { + this._bbb = value; + } + else { + this._bbb = ss.Delegate.combine(this._bbb, value); + } }, remove_bbb: function(value) { - this._bbb = ss.Delegate.remove(this._bbb, value); + this._bbb = ss.Delegate.remove(this._bbb, value); } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { + function ExpressionTests$App() { this._btn.add_click(ss.Delegate.create(this, this.onClickButton)); this._btn.add_click(ss.Delegate.create(this, this.onClickButton)); this._btn.add_click(ss.Delegate.create(this, this.onClickButton)); this._btn.remove_click(ss.Delegate.create(this, this.onClickButton)); this._btn.remove_click(ss.Delegate.create(this, this.onClickButton)); this._btn.remove_click(ss.Delegate.create(this, this.onClickButton)); - ExpressionTests.Button.add_test(ExpressionTests.App.onTestButton); - ExpressionTests.Button.add_test(ExpressionTests.App.onTestButton); - ExpressionTests.Button.add_test(ExpressionTests.App.onTestButton); - ExpressionTests.Button.remove_test(ExpressionTests.App.onTestButton); - ExpressionTests.Button.remove_test(ExpressionTests.App.onTestButton); - ExpressionTests.Button.remove_test(ExpressionTests.App.onTestButton); + ExpressionTests$Button.add_test(ExpressionTests$App.onTestButton); + ExpressionTests$Button.add_test(ExpressionTests$App.onTestButton); + ExpressionTests$Button.add_test(ExpressionTests$App.onTestButton); + ExpressionTests$Button.remove_test(ExpressionTests$App.onTestButton); + ExpressionTests$Button.remove_test(ExpressionTests$App.onTestButton); + ExpressionTests$Button.remove_test(ExpressionTests$App.onTestButton); this._btn.add_aaa(ss.Delegate.create(this, this.onAAAButton)); this._btn.add_aaa(ss.Delegate.create(this, this.onAAAButton)); this._btn.add_aaa(ss.Delegate.create(this, this.onAAAButton)); this._btn.remove_aaa(ss.Delegate.create(this, this.onAAAButton)); this._btn.remove_aaa(ss.Delegate.create(this, this.onAAAButton)); this._btn.remove_aaa(ss.Delegate.create(this, this.onAAAButton)); -} -ExpressionTests.App.onTestButton = function(sender, e) { -} -ExpressionTests.App.prototype = { - _btn: null, - + } + ExpressionTests$App.onTestButton = function(sender, e) { + } + var ExpressionTests$App$ = { onAAAButton: function(sender, e) { }, - onClickButton: function(sender, e) { } -} + }; + + + // ExpressionTests.FooEventArgs + + function ExpressionTests$FooEventArgs() { + ss.EventArgs.call(this); + } + var ExpressionTests$FooEventArgs$ = { + + }; + + + var $test = ss.module('test', null, + { + Button: [ ExpressionTests$Button, ExpressionTests$Button$, null ], + App: [ ExpressionTests$App, ExpressionTests$App$, null ], + FooEventArgs: [ ExpressionTests$FooEventArgs, ExpressionTests$FooEventArgs$, ss.EventArgs ] + }); -ExpressionTests.FooEventArgs.registerClass('ExpressionTests.FooEventArgs', ss.EventArgs); -ExpressionTests.Button.registerClass('ExpressionTests.Button'); -ExpressionTests.App.registerClass('ExpressionTests.App'); -ExpressionTests.Button.__test = null; + return $test; +}); diff --git a/tests/TestCases/Expression/Generics/Baseline.txt b/tests/TestCases/Expression/Generics/Baseline.txt index 30394e6bd..6d82700d4 100644 --- a/tests/TestCases/Expression/Generics/Baseline.txt +++ b/tests/TestCases/Expression/Generics/Baseline.txt @@ -1,50 +1,52 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss', 'jQuery'], function(ss, jQuery) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Foo + // ExpressionTests.Foo -ExpressionTests.Foo = function() { + function ExpressionTests$Foo() { this._numbers = []; - var s = this._numbers[10].format('{0}'); - var s2 = this._numbers.getEnumerator().current.format('{0}'); + var s = this._numbers[10].toString(10); + var s2 = this._numbers.getEnumerator().current.toString(10); var s3 = this._numbers.reduce(function(accumulated, item) { - return accumulated + item; - }, 0).format('{0}'); + return accumulated + item; + }, 0).toString(10); var s4 = encodeURIComponent(this._func(10)); var f2 = this._func; f2(11).trim(); var d = {}; - var s5 = $.extend(d, d)['abc'].format('{0}'); + var s5 = $.extend(d, d)['abc'].toString(10); var keys = Object.getKeyCount(d); var b = Object.keyExists(d, 'abc'); delete d.abc; var $dict1 = d; for (var $key2 in $dict1) { - var de = { key: $key2, value: $dict1[$key2] }; + var de = { key: $key2, value: $dict1[$key2] }; } $.ajax('http://example.com').success(function(html) { - alert(html); + alert(html); }); var json = ''; var f = JSON.parse(json).setup().run().cleanup(); var name = document.getElementById('nameTB').value; -} -ExpressionTests.Foo.prototype = { - _numbers: null, - _func: null, - + } + var ExpressionTests$Foo$ = { cleanup: function() { - return this; + return this; }, - run: function() { - return this; + return this; }, - setup: function() { - return this; + return this; } -} + }; -ExpressionTests.Foo.registerClass('ExpressionTests.Foo'); + var $test = ss.module('test', null, + { + Foo: [ ExpressionTests$Foo, ExpressionTests$Foo$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/Generics/Code.cs b/tests/TestCases/Expression/Generics/Code.cs index 4e3dc2277..00512ddd1 100644 --- a/tests/TestCases/Expression/Generics/Code.cs +++ b/tests/TestCases/Expression/Generics/Code.cs @@ -17,9 +17,9 @@ public class Foo { public Foo() { _numbers = new List(); - string s = _numbers[10].Format("{0}"); - string s2 = _numbers.GetEnumerator().Current.Format("{0}"); - string s3 = _numbers.Reduce(delegate(int accumulated, int item) { return accumulated + item; }, 0).Format("{0}"); + string s = _numbers[10].ToString(10); + string s2 = _numbers.GetEnumerator().Current.ToString(10); + string s3 = _numbers.Reduce(delegate(int accumulated, int item) { return accumulated + item; }, 0).ToString(10); string s4 = _func(10).EncodeUriComponent(); @@ -27,7 +27,7 @@ public Foo() { f2(11).Trim(); Dictionary d = new Dictionary(); - string s5 = jQuery.ExtendDictionary(d, d)["abc"].Format("{0}"); + string s5 = jQuery.ExtendDictionary(d, d)["abc"].ToString(10); int keys = d.Count; bool b = d.ContainsKey("abc"); d.Remove("abc"); diff --git a/tests/TestCases/Expression/GetType/Baseline.txt b/tests/TestCases/Expression/GetType/Baseline.txt index c864bef3e..5655a7676 100644 --- a/tests/TestCases/Expression/GetType/Baseline.txt +++ b/tests/TestCases/Expression/GetType/Baseline.txt @@ -1,22 +1,27 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { get_foo: function() { - return 0; + return 0; }, - test: function(x) { - var t = Type.getInstanceType(x); - var t2 = Type.getInstanceType(x.toString()); - var t3 = Type.getInstanceType(this.get_foo()); + var t = Type.getInstanceType(x); + var t2 = Type.getInstanceType(x.toString()); + var t3 = Type.getInstanceType(this.get_foo()); } -} + }; -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/GlobalMethods/Baseline.txt b/tests/TestCases/Expression/GlobalMethods/Baseline.txt index 4bd430f2d..34cc160a5 100644 --- a/tests/TestCases/Expression/GlobalMethods/Baseline.txt +++ b/tests/TestCases/Expression/GlobalMethods/Baseline.txt @@ -1,25 +1,30 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - eval('[ 1, 2 ]'); - foo(); - setTimeout(foo, 0); + eval('[ 1, 2 ]'); + foo(); + setTimeout(foo, 0); } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Util + // ExpressionTests.Util -window.foo = function() { -} + this.foo = function() { + } -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/InlineScript/Baseline.txt b/tests/TestCases/Expression/InlineScript/Baseline.txt index 2a07bc95a..e12a95318 100644 --- a/tests/TestCases/Expression/InlineScript/Baseline.txt +++ b/tests/TestCases/Expression/InlineScript/Baseline.txt @@ -1,21 +1,27 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - arg + 1; - var i = arg + 1; - var j = arg + 1; - var k = arg + 1; - var a = 10; - alert(a + a); + arg + 1; + var i = arg + 1; + var j = arg + 1; + var k = arg + 1; + var a = 10; + alert(a + a); } -} + }; -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/LateBound/Baseline.txt b/tests/TestCases/Expression/LateBound/Baseline.txt index aa43b6fa3..e493861bb 100644 --- a/tests/TestCases/Expression/LateBound/Baseline.txt +++ b/tests/TestCases/Expression/LateBound/Baseline.txt @@ -1,44 +1,50 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - var o; - var b; - o[arg](); - o.xyz(); - o['Proxy-Connection'](); - o.xyz(0); - o.xyz(0, arg); - b = (typeof(o[arg]) === 'function'); - b = (typeof(o.xyz) === 'function'); - b = (typeof(Object.xyz) === 'function'); - o[arg] = 0; - o.abc = 0; - o['Proxy-Connection'] = 0; - var v = o[arg]; - v = o.abc; - v = o['Proxy-Connection']; - b = (arg in o); - b = ('abc' in o); - b = ('abc' in Object); - delete o.xyz; - delete o['Proxy-Connection']; - delete o[arg]; - var t = typeof(o); - if (typeof(o) === 'object') { - } - if ((typeof(o.execute) === 'function')) { - } - globalMethod(); - globalMethod('xyz'); + var o; + var b; + o[arg](); + o.xyz(); + o['Proxy-Connection'](); + o.xyz(0); + o.xyz(0, arg); + b = (typeof(o[arg]) === 'function'); + b = (typeof(o.xyz) === 'function'); + b = (typeof(Object.xyz) === 'function'); + o[arg] = 0; + o.abc = 0; + o['Proxy-Connection'] = 0; + var v = o[arg]; + v = o.abc; + v = o['Proxy-Connection']; + b = (arg in o); + b = ('abc' in o); + b = ('abc' in Object); + delete o.xyz; + delete o['Proxy-Connection']; + delete o[arg]; + var t = typeof(o); + if (typeof(o) === 'object') { + } + if ((typeof(o.execute) === 'function')) { + } + globalMethod(); + globalMethod('xyz'); } -} + }; -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/Literals/Baseline.txt b/tests/TestCases/Expression/Literals/Baseline.txt index b34eaed9b..999dcc99d 100644 --- a/tests/TestCases/Expression/Literals/Baseline.txt +++ b/tests/TestCases/Expression/Literals/Baseline.txt @@ -1,40 +1,46 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - var i = 0; - i = -1; - i = 1; - i = 1000000; - var n = 10000; - var f = 1; - var d = 1.01; - var d2 = 0.5; - var d3 = -0.5; - var b = true; - b = false; - var ch = '\n'; - ch = 'a'; - var s = 'Hello'; - var s2 = 'Hello\r\n'; - var s3 = 'abc' + '123'; - var s4 = "abc\"def'xyz"; - var s5 = 'abc\u00a9'; - var s6 = "abc'xyz"; - var s7 = 'abc"xyz'; - var t = ExpressionTests.App; - var t2 = Number; - var t3 = Number; - var t4 = Object; - var items = [ 1, 2, 3 ]; + var i = 0; + i = -1; + i = 1; + i = 1000000; + var n = 10000; + var f = 1; + var d = 1.01; + var d2 = 0.5; + var d3 = -0.5; + var b = true; + b = false; + var ch = '\n'; + ch = 'a'; + var s = 'Hello'; + var s2 = 'Hello\r\n'; + var s3 = 'abc' + '123'; + var s4 = "abc\"def'xyz"; + var s5 = 'abc\u00a9'; + var s6 = "abc'xyz"; + var s7 = 'abc"xyz'; + var t = ExpressionTests$App; + var t2 = Number; + var t3 = Number; + var t4 = Object; + var items = [ 1, 2, 3 ]; } -} + }; -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/Locals/Baseline.txt b/tests/TestCases/Expression/Locals/Baseline.txt index 4a2578ef9..3a7eeaac7 100644 --- a/tests/TestCases/Expression/Locals/Baseline.txt +++ b/tests/TestCases/Expression/Locals/Baseline.txt @@ -1,31 +1,36 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - var x; - var i = x.length; - while (i >= 0) { - var x2 = x.substring(0); - for (var j = 0; j < 1; j++) { - } - var j = x2; - i = j.length; - } - while (i >= 0) { - var x2 = '...'; + var x; + var i = x.length; + while (i >= 0) { + var x2 = x.substring(0); + for (var j = 0; j < 1; j++) { } + var j = x2; + i = j.length; + } + while (i >= 0) { + var x2 = '...'; + } }, - test2: function(arg1, arg2) { - arg2 = arg1; + arg2 = arg1; } -} + }; + + + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); -ExpressionTests.App.registerClass('ExpressionTests.App'); + return $test; +}); diff --git a/tests/TestCases/Expression/Members/Baseline.txt b/tests/TestCases/Expression/Members/Baseline.txt index 8659e81f3..d3968982e 100644 --- a/tests/TestCases/Expression/Members/Baseline.txt +++ b/tests/TestCases/Expression/Members/Baseline.txt @@ -1,108 +1,110 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.IFoo + // ExpressionTests.IFoo -ExpressionTests.IFoo = function() { }; -ExpressionTests.IFoo.registerInterface('ExpressionTests.IFoo'); + function ExpressionTests$IFoo() { } -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.BApp + // ExpressionTests.BApp -ExpressionTests.BApp = function() { -} + function ExpressionTests$BApp() { + } + var ExpressionTests$BApp$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App -ExpressionTests.App = function() { - ExpressionTests.App.initializeBase(this); -} -ExpressionTests.App.prototype = { - _value: 0, - _value2: 0, - + // ExpressionTests.App + + function ExpressionTests$App() { + this._value = 0; + this._value2 = 0; + ExpressionTests$BApp.call(this); + } + var ExpressionTests$App$ = { get_XYZ: function() { - return 1; + return 1; }, set_XYZ: function(value) { - return value; + return value; }, - test: function(arg) { - var s = ''; - var n = s.length; - var n2 = Number.MAX_VALUE; - var m = 0; - n = this.get_XYZ(); - n = this.get_XYZ(); - this.set_XYZ(n); - this.set_XYZ(n); - var a; - n = a.get_XYZ(); - a.set_XYZ(n); - n = this._value; - n = this._value; - this._value = n; - this._value = n; - n = ExpressionTests.App.myDefault; - n = ExpressionTests.App.myDefault; - n = 3; - n = 3; - n = 3; - n = 3; - n = 3; + var s = ''; + var n = s.length; + var n2 = Number.MAX_VALUE; + var m = 0; + n = this.get_XYZ(); + n = this.get_XYZ(); + this.set_XYZ(n); + this.set_XYZ(n); + var a; + n = a.get_XYZ(); + a.set_XYZ(n); + n = this._value; + n = this._value; + this._value = n; + this._value = n; + n = ExpressionTests$App.myDefault; + n = ExpressionTests$App.myDefault; + n = 3; + n = 3; + n = 3; + n = 3; + n = 3; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.DApp + // ExpressionTests.DApp -ExpressionTests.DApp = function() { - ExpressionTests.DApp.initializeBase(this); -} -ExpressionTests.DApp.prototype = { - + function ExpressionTests$DApp() { + ExpressionTests$App.call(this); + } + var ExpressionTests$DApp$ = { test2: function() { - var n = this.get_XYZ(); - n = this.get_XYZ(); - n = ExpressionTests.DApp.callBaseMethod(this, 'get_XYZ'); - this.set_XYZ(n); - this.set_XYZ(n); - ExpressionTests.DApp.callBaseMethod(this, 'set_XYZ', [ n ]); - this._value2 = n; - this._value2 = n; - this._value2 = n; - n = ExpressionTests.App.myDefault2; - n = ExpressionTests.App.myDefault2; - n = 3; - n = 3; - n = 3; - n = 3; - n = 3; - n = 3; + var n = this.get_XYZ(); + n = this.get_XYZ(); + n = ExpressionTests$App$.get_XYZ.call(this); + this.set_XYZ(n); + this.set_XYZ(n); + ExpressionTests$App$.set_XYZ.call(this, n); + this._value2 = n; + this._value2 = n; + this._value2 = n; + n = ExpressionTests$App.myDefault2; + n = ExpressionTests$App.myDefault2; + n = 3; + n = 3; + n = 3; + n = 3; + n = 3; + n = 3; }, - test3: function() { - var i = [ 1, 2 ]; - i[0] = 1; - i[1] = i[0]; - i[i[0]] = 20; + var i = [ 1, 2 ]; + i[0] = 1; + i[1] = i[0]; + i[i[0]] = 20; }, - test4: function(foo) { - foo.bar(); + foo.bar(); } -} + }; + + + var $test = ss.module('test', null, + { + IFoo: [ ExpressionTests$IFoo ], + BApp: [ ExpressionTests$BApp, ExpressionTests$BApp$, null ], + App: [ ExpressionTests$App, ExpressionTests$App$, ExpressionTests$BApp ], + DApp: [ ExpressionTests$DApp, ExpressionTests$DApp$, ExpressionTests$App ] + }); + ExpressionTests$BApp.myConstant = 3; + ExpressionTests$App.myConstant2 = 3; + ExpressionTests$App.myDefault = 1; + ExpressionTests$App.myDefault2 = 2; -ExpressionTests.BApp.registerClass('ExpressionTests.BApp'); -ExpressionTests.App.registerClass('ExpressionTests.App', ExpressionTests.BApp); -ExpressionTests.DApp.registerClass('ExpressionTests.DApp', ExpressionTests.App); -ExpressionTests.BApp.myConstant = 3; -ExpressionTests.App.myConstant2 = 3; -ExpressionTests.App.myDefault = 1; -ExpressionTests.App.myDefault2 = 2; + return $test; +}); diff --git a/tests/TestCases/Expression/New/Baseline.txt b/tests/TestCases/Expression/New/Baseline.txt index 1fd19e632..ba2fb6f50 100644 --- a/tests/TestCases/Expression/New/Baseline.txt +++ b/tests/TestCases/Expression/New/Baseline.txt @@ -1,39 +1,42 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Point + // ExpressionTests.Point -ExpressionTests.$create_Point = function(x, y) { - var $o = { }; + function ExpressionTests$Point(x, y) { + var $o = {}; $o.x = x; $o.y = y; return $o; -} + } -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Foo + // ExpressionTests.Foo -ExpressionTests.Foo = function(i, j) { -} + function ExpressionTests$Foo(i, j) { + } + var ExpressionTests$Foo$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Bar -ExpressionTests.Bar = function(i, j, f) { -} + // ExpressionTests.Bar + function ExpressionTests$Bar(i, j, f) { + } + var ExpressionTests$Bar$ = { -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Test + }; -ExpressionTests.Test = function() { -} -ExpressionTests.Test.main = function() { - var f = new ExpressionTests.Foo(0, 1); - var b = new ExpressionTests.Bar(0, 1, new ExpressionTests.Foo(0, 1)); - var t = new ExpressionTests.Test(); + + // ExpressionTests.Test + + function ExpressionTests$Test() { + } + ExpressionTests$Test.main = function() { + var f = new ExpressionTests$Foo(0, 1); + var b = new ExpressionTests$Bar(0, 1, new ExpressionTests$Foo(0, 1)); + var t = new ExpressionTests$Test(); var d = new Date('3/9/1976'); var items = []; var items2 = [ 1, 2 ]; @@ -44,19 +47,30 @@ ExpressionTests.Test.main = function() { var list3 = ['abc', 'def', 'ghi']; var list4 = [1, 2, 3]; var dates = [ new Date('1/1/2006'), new Date('1/1/2005') ]; - var p = ExpressionTests.$create_Point(0, 0); + var p = ExpressionTests$Point(0, 0); var cd = {}; var cd2 = { abc: 123, def: true }; - var o1 = new ExpressionTests.Test(); - var type1 = ExpressionTests.Foo; + var o1 = new ExpressionTests$Test(); + var type1 = ExpressionTests$Foo; var o2 = new type1(1, 2); - var o3 = new ExpressionTests.Bar(1, 2, o2); + var o3 = new ExpressionTests$Bar(1, 2, o2); var f1 = new Function("alert('hello');"); var f2 = new Function('s', 'alert(s);'); var f3 = new Function('greeting', 'name', "alert(greeting + ' ' + name + '!');"); -} + } + var ExpressionTests$Test$ = { + + }; + + + var $test = ss.module('test', null, + { + Point: ExpressionTests$Point, + Foo: [ ExpressionTests$Foo, ExpressionTests$Foo$, null ], + Bar: [ ExpressionTests$Bar, ExpressionTests$Bar$, null ], + Test: [ ExpressionTests$Test, ExpressionTests$Test$, null ] + }); -ExpressionTests.Foo.registerClass('ExpressionTests.Foo'); -ExpressionTests.Bar.registerClass('ExpressionTests.Bar'); -ExpressionTests.Test.registerClass('ExpressionTests.Test'); + return $test; +}); diff --git a/tests/TestCases/Expression/Number/Baseline.txt b/tests/TestCases/Expression/Number/Baseline.txt index 6bd053c65..b10e085e8 100644 --- a/tests/TestCases/Expression/Number/Baseline.txt +++ b/tests/TestCases/Expression/Number/Baseline.txt @@ -1,19 +1,25 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - var i = parseInt('5'); - var f = parseFloat('5.3'); - var b1 = isNaN(0); - var b2 = isFinite(3); + var i = parseInt('5'); + var f = parseFloat('5.3'); + var b1 = isNaN(0); + var b2 = isFinite(3); } -} + }; -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/Script/Baseline.txt b/tests/TestCases/Expression/Script/Baseline.txt index 5420db523..07b784599 100644 --- a/tests/TestCases/Expression/Script/Baseline.txt +++ b/tests/TestCases/Expression/Script/Baseline.txt @@ -1,19 +1,25 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - arg = (arg || 10); - arg = (arg || 10 || 100); - var s = (arg || 10).format('{0}'); - var b = !!arg; + arg = (arg || 10); + arg = (arg || 10 || 100); + var s = (arg || 10).toString(10); + var b = !!arg; } -} + }; -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/Script/Code.cs b/tests/TestCases/Expression/Script/Code.cs index 7f764968a..df208a69c 100644 --- a/tests/TestCases/Expression/Script/Code.cs +++ b/tests/TestCases/Expression/Script/Code.cs @@ -10,7 +10,7 @@ public class App { public void Test(int arg) { arg = Script.Value(arg, 10); arg = Script.Value(arg, 10, 100); - string s = Script.Value(arg, 10).Format("{0}"); + string s = Script.Value(arg, 10).ToString(10); bool b = Script.Boolean(arg); } } diff --git a/tests/TestCases/Expression/String/Baseline.txt b/tests/TestCases/Expression/String/Baseline.txt index 442b20a05..4514fc463 100644 --- a/tests/TestCases/Expression/String/Baseline.txt +++ b/tests/TestCases/Expression/String/Baseline.txt @@ -1,23 +1,29 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - var s = 'Hello'; - var s2; - s2 = escape(s); - s = unescape(s2); - s2 = encodeURI(s); - s = decodeURI(s2); - s2 = encodeURIComponent(s); - s = decodeURIComponent(s2); + var s = 'Hello'; + var s2; + s2 = escape(s); + s = unescape(s2); + s2 = encodeURI(s); + s = decodeURI(s2); + s2 = encodeURIComponent(s); + s = decodeURIComponent(s2); } -} + }; -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/Truthy/Baseline.txt b/tests/TestCases/Expression/Truthy/Baseline.txt index 0fcf643c4..0d986b6c3 100644 --- a/tests/TestCases/Expression/Truthy/Baseline.txt +++ b/tests/TestCases/Expression/Truthy/Baseline.txt @@ -1,64 +1,70 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - var i; - var j; - var f; - var o; - var s; - if (!i) { - } - if (!!i) { - } - if (i === 1) { - } - if (i === j) { - } - if (!!s.length) { - } - if (!s) { - } - if (!!s) { - } - if (!s) { - } - if (!!s) { - } - if (!!f) { - } - if (!f) { - } - if (!f) { - } - if (!!f) { - } - if (f === f) { - } - if (o == null) { - } - if (o != null) { - } - if ((s + s) != null) { - } - if ((s + s) == null) { - } - if (!!(i % 2)) { - } - if (!(i % 2)) { - } - if (!(i % 2)) { - } - if (!i++) { - } + var i; + var j; + var f; + var o; + var s; + if (!i) { + } + if (!!i) { + } + if (i === 1) { + } + if (i === j) { + } + if (!!s.length) { + } + if (!s) { + } + if (!!s) { + } + if (!s) { + } + if (!!s) { + } + if (!!f) { + } + if (!f) { + } + if (!f) { + } + if (!!f) { + } + if (f === f) { + } + if (o == null) { + } + if (o != null) { + } + if ((s + s) != null) { + } + if ((s + s) == null) { + } + if (!!(i % 2)) { + } + if (!(i % 2)) { + } + if (!(i % 2)) { + } + if (!i++) { + } } -} + }; -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/Unary/Baseline.txt b/tests/TestCases/Expression/Unary/Baseline.txt index 1b4acc99f..530b249f6 100644 --- a/tests/TestCases/Expression/Unary/Baseline.txt +++ b/tests/TestCases/Expression/Unary/Baseline.txt @@ -1,52 +1,56 @@ -Type.registerNamespace('ExpressionTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.Data + // ExpressionTests.Data -ExpressionTests.Data = function() { -} -ExpressionTests.Data.prototype = { - _value: 0, - + function ExpressionTests$Data() { + this._value = 0; + } + var ExpressionTests$Data$ = { get_value: function() { - return this._value; + return this._value; }, set_value: function(value) { - this._value = value; - return value; + this._value = value; + return value; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// ExpressionTests.App + // ExpressionTests.App -ExpressionTests.App = function() { -} -ExpressionTests.App.prototype = { - + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { test: function(arg) { - var xyz = ~arg; - var f = (!arg); - f = !f; - var m = arg; - m++; - var n = ++m; - m--; - n = --m; - n = -m; - n = m; - n = 1; - n = 1 + (2); - var s = (!f).toString(); - var num = 1.01; - s = (~num).toExponential(); - var d = new ExpressionTests.Data(); - d.set_value(d.get_value() + 1) - 1; - d.set_value(d.get_value() + 1); + var xyz = ~arg; + var f = (!arg); + f = !f; + var m = arg; + m++; + var n = ++m; + m--; + n = --m; + n = -m; + n = m; + n = 1; + n = 1 + (2); + var s = (!f).toString(); + var num = 1.01; + s = (~num).toExponential(); + var d = new ExpressionTests$Data(); + d.set_value(d.get_value() + 1) - 1; + d.set_value(d.get_value() + 1); } -} + }; -ExpressionTests.Data.registerClass('ExpressionTests.Data'); -ExpressionTests.App.registerClass('ExpressionTests.App'); + var $test = ss.module('test', null, + { + Data: [ ExpressionTests$Data, ExpressionTests$Data$, null ], + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Library/jQuery/Baseline.txt b/tests/TestCases/Library/jQuery/Baseline.txt index 79797f338..83f221328 100644 --- a/tests/TestCases/Library/jQuery/Baseline.txt +++ b/tests/TestCases/Library/jQuery/Baseline.txt @@ -1,39 +1,51 @@ -//////////////////////////////////////////////////////////////////////////////// -// MyApp +define('test', ['ss', 'jQuery'], function(ss, jQuery) { + 'use strict'; -window.MyApp = function MyApp() { -} -MyApp._alertData = function MyApp$_alertData(url) { + // MyApp + + function MyApp() { + } + MyApp._alertData = function(url) { $.ajax({ url: url, type: 'GET', dataType: 'html', contentType: 'application/json', processData: false, success: function(result, textData, xhr) { - var s = xhr.responseText; - alert(s); - xyz(s); + var s = xhr.responseText; + alert(s); + xyz(s); }, error: function(xhr, textData, e) { - console.log(xhr.status); + console.log(xhr.status); } }); -} -MyApp.postData = function MyApp$postData(url, data, succesCallback, errorCallback, returnType, requestType) { + } + MyApp.postData = function(url, data, succesCallback, errorCallback, returnType, requestType) { returnType = returnType || 'text'; requestType = requestType || 'POST'; $.ajax({ cache: false, data: data, dataType: returnType, error: function(req, textStatus, error) { - if (!ss.isNullOrUndefined(errorCallback)) { - errorCallback(req, textStatus, error); - } + if (!ss.isNullOrUndefined(errorCallback)) { + errorCallback(req, textStatus, error); + } }, success: function(dataSuccess, textStatus, request) { - if (ss.isNullOrUndefined(succesCallback)) { - $(document).append(dataSuccess); - } - else { - succesCallback(dataSuccess, textStatus, request); - } + if (ss.isNullOrUndefined(succesCallback)) { + $(document).append(dataSuccess); + } + else { + succesCallback(dataSuccess, textStatus, request); + } }, type: requestType, url: url }); -} + } + var MyApp$ = { + + }; -MyApp.registerClass('MyApp'); -(function () { + var $test = ss.module('test', null, + { + MyApp: [ MyApp, MyApp$, null ] + }); + + (function() { $('div').addClass('foo'); $('span').addClass('bar').addClass('baz'); var o = $('.special').foo(); $('.special').html(''); -})(); + })(); + + return $test; +}); diff --git a/tests/TestCases/Member/Constructors/Baseline.txt b/tests/TestCases/Member/Constructors/Baseline.txt index 70c8f15e2..1020f6a4e 100644 --- a/tests/TestCases/Member/Constructors/Baseline.txt +++ b/tests/TestCases/Member/Constructors/Baseline.txt @@ -1,43 +1,55 @@ -Type.registerNamespace('MemberTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.MyClass + // MemberTests.MyClass -MemberTests.MyClass = function() { + function MemberTests$MyClass() { + this._value = 0; this._value = 1; -} -MemberTests.MyClass.prototype = { - _value: 0 -} + } + var MemberTests$MyClass$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.MyClass2 -MemberTests.MyClass2 = function() { -} + // MemberTests.MyClass2 + function MemberTests$MyClass2() { + } + var MemberTests$MyClass2$ = { -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.MyClass3 + }; -MemberTests.MyClass3 = function(arg, arg2) { -} + // MemberTests.MyClass3 -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.MyClass4 + function MemberTests$MyClass3(arg, arg2) { + } + var MemberTests$MyClass3$ = { -MemberTests.MyClass4 = function(arg, arg2, arg3) { - MemberTests.MyClass4.initializeBase(this, [ arg, arg2 ]); -} + }; -MemberTests.MyClass.registerClass('MemberTests.MyClass'); -MemberTests.MyClass2.registerClass('MemberTests.MyClass2'); -MemberTests.MyClass3.registerClass('MemberTests.MyClass3'); -MemberTests.MyClass4.registerClass('MemberTests.MyClass4', MemberTests.MyClass3); -MemberTests.MyClass2.x = null; -MemberTests.MyClass2.x = 'Hello'; -MemberTests.MyClass3.c = null; -MemberTests.MyClass3.c = new MemberTests.MyClass(); + // MemberTests.MyClass4 + + function MemberTests$MyClass4(arg, arg2, arg3) { + MemberTests$MyClass3.call(this, arg, arg2); + } + var MemberTests$MyClass4$ = { + + }; + + + var $test = ss.module('test', null, + { + MyClass: [ MemberTests$MyClass, MemberTests$MyClass$, null ], + MyClass2: [ MemberTests$MyClass2, MemberTests$MyClass2$, null ], + MyClass3: [ MemberTests$MyClass3, MemberTests$MyClass3$, null ], + MyClass4: [ MemberTests$MyClass4, MemberTests$MyClass4$, MemberTests$MyClass3 ] + }); + + MemberTests$MyClass2.x = 'Hello'; + MemberTests$MyClass3.c = new MemberTests$MyClass(); + + return $test; +}); diff --git a/tests/TestCases/Member/Events/Baseline.txt b/tests/TestCases/Member/Events/Baseline.txt index a14a9bcbb..c4a23a963 100644 --- a/tests/TestCases/Member/Events/Baseline.txt +++ b/tests/TestCases/Member/Events/Baseline.txt @@ -1,55 +1,57 @@ -Type.registerNamespace('MemberTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.EventArgs + // MemberTests.EventArgs -MemberTests.EventArgs = function() { -} + function MemberTests$EventArgs() { + } + var MemberTests$EventArgs$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.Button -MemberTests.Button = function() { -} -MemberTests.Button.add_test = function(value) { - MemberTests.Button.__test = ss.Delegate.combine(MemberTests.Button.__test, value); -} -MemberTests.Button.remove_test = function(value) { - MemberTests.Button.__test = ss.Delegate.remove(MemberTests.Button.__test, value); -} -MemberTests.Button.prototype = { - _aaa: null, - + // MemberTests.Button + + function MemberTests$Button() { + } + MemberTests$Button.add_test = function(value) { + MemberTests$Button.__test = ss.Delegate.combine(MemberTests$Button.__test, value); + } + MemberTests$Button.remove_test = function(value) { + MemberTests$Button.__test = ss.Delegate.remove(MemberTests$Button.__test, value); + } + var MemberTests$Button$ = { add_click: function(value) { - this.__click = ss.Delegate.combine(this.__click, value); + this.__click = ss.Delegate.combine(this.__click, value); }, remove_click: function(value) { - this.__click = ss.Delegate.remove(this.__click, value); + this.__click = ss.Delegate.remove(this.__click, value); }, - - __click: null, - add_aaa: function(value) { - if (this._aaa == null) { - this._aaa = value; - } - else { - this._aaa = ss.Delegate.combine(this._aaa, value); - } + if (this._aaa == null) { + this._aaa = value; + } + else { + this._aaa = ss.Delegate.combine(this._aaa, value); + } }, remove_aaa: function(value) { - this._aaa = ss.Delegate.remove(this._aaa, value); + this._aaa = ss.Delegate.remove(this._aaa, value); }, - performClick: function() { - if (this.__click != null) { - this.__click(this, new MemberTests.EventArgs()); - } + if (this.__click != null) { + this.__click(this, new MemberTests$EventArgs()); + } } -} + }; + + + var $test = ss.module('test', null, + { + EventArgs: [ MemberTests$EventArgs, MemberTests$EventArgs$, null ], + Button: [ MemberTests$Button, MemberTests$Button$, null ] + }); -MemberTests.EventArgs.registerClass('MemberTests.EventArgs'); -MemberTests.Button.registerClass('MemberTests.Button'); -MemberTests.Button.__test = null; + return $test; +}); diff --git a/tests/TestCases/Member/Fields/Baseline.txt b/tests/TestCases/Member/Fields/Baseline.txt index 07b627987..61e368176 100644 --- a/tests/TestCases/Member/Fields/Baseline.txt +++ b/tests/TestCases/Member/Fields/Baseline.txt @@ -1,71 +1,76 @@ -Type.registerNamespace('MemberTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.Mode + // MemberTests.Mode -MemberTests.Mode = function() { }; -MemberTests.Mode.prototype = { + var MemberTests$Mode = { a: 0, b: 1 -} -MemberTests.Mode.registerEnum('MemberTests.Mode', false); + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.Point + // MemberTests.Point -MemberTests.$create_Point = function(x, y) { - var $o = { }; + function MemberTests$Point(x, y) { + var $o = {}; $o.x = x; $o.y = y; return $o; -} + } -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.Test + // MemberTests.Test -MemberTests.Test = function() { + function MemberTests$Test() { + this._value = 0; + this._uintValue = 0; + this._dblValue = 0; + this._enumValue = 0; + this._boolValue = false; this._value = 2006; this.s = 'aaa'; this.s = 'bbb'; this.s = 'aaa'; -} -MemberTests.Test.prototype = { - _value: 0, - _uintValue: 0, - _dblValue: 0, - _enumValue: 0, - _boolValue: false, - s: null -} - - -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.App - -MemberTests.App = function() { - this._t = new MemberTests.Test(); -} -MemberTests.App.prototype = { - _i: 5, - + } + var MemberTests$Test$ = { + + }; + + + // MemberTests.App + + function MemberTests$App() { + this._t = new MemberTests$Test(); + this._i = 5; + } + var MemberTests$App$ = { doTest: function() { - var t = new MemberTests.Test(); - t.s = 'World'; - var i = 1; - MemberTests.Test.done = true; - var p = MemberTests.$create_Point(1, 10); - p.x = p.y; + var t = new MemberTests$Test(); + t.s = 'World'; + var i = 1; + MemberTests$Test.done = true; + var p = MemberTests$Point(1, 10); + p.x = p.y; } -} + }; + + + var $test = ss.module('test', + { + Point: MemberTests$Point + }, + { + Mode: MemberTests$Mode, + Test: [ MemberTests$Test, MemberTests$Test$, null ], + App: [ MemberTests$App, MemberTests$App$, null ] + }); + MemberTests$Test.greeting = 'Hello!'; + MemberTests$Test.myNumber = 1; + MemberTests$Test.defaultValue = 'aaa'; + MemberTests$Test.done = false; + MemberTests$Test.XYZ = 1; + MemberTests$Test.key = {}; -MemberTests.Test.registerClass('MemberTests.Test'); -MemberTests.App.registerClass('MemberTests.App'); -MemberTests.Test.greeting = 'Hello!'; -MemberTests.Test.myNumber = 1; -MemberTests.Test.defaultValue = 'aaa'; -MemberTests.Test.done = false; -MemberTests.Test.XYZ = 1; -MemberTests.Test.key = {}; + return $test; +}); diff --git a/tests/TestCases/Member/Fields/Code.cs b/tests/TestCases/Member/Fields/Code.cs index 92d50d0e8..0d07bef47 100644 --- a/tests/TestCases/Member/Fields/Code.cs +++ b/tests/TestCases/Member/Fields/Code.cs @@ -8,7 +8,6 @@ namespace MemberTests { public enum Mode { A = 0, B = 1 }; public class Test { - public static readonly string Greeting = "Hello!"; public const int MyNumber = 1; diff --git a/tests/TestCases/Member/Indexers/Baseline.txt b/tests/TestCases/Member/Indexers/Baseline.txt index 30f7d3b3a..1a72c9264 100644 --- a/tests/TestCases/Member/Indexers/Baseline.txt +++ b/tests/TestCases/Member/Indexers/Baseline.txt @@ -1,207 +1,208 @@ -Type.registerNamespace('MemberTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.IIndexable + // MemberTests.IIndexable -MemberTests.IIndexable = function() { }; -MemberTests.IIndexable.registerInterface('MemberTests.IIndexable'); + function MemberTests$IIndexable() { } -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.Normal + // MemberTests.Normal -MemberTests.Normal = function() { + function MemberTests$Normal() { + this.n = 0; var i = this.get_item('name'); this.set_item('name', i + 1); -} -MemberTests.Normal.prototype = { - n: 0, + } + var MemberTests$Normal$ = { get_item: function(name) { - return this.n; + return this.n; }, set_item: function(name, value) { - this.n = value; - return value; + this.n = value; + return value; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.GetterOnly + // MemberTests.GetterOnly -MemberTests.GetterOnly = function() { + function MemberTests$GetterOnly() { + this.n = 0; var i = this.get_item('name'); -} -MemberTests.GetterOnly.prototype = { - n: 0, + } + var MemberTests$GetterOnly$ = { get_item: function(name) { - return this.n; + return this.n; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.VirtualIndexer + // MemberTests.VirtualIndexer -MemberTests.VirtualIndexer = function() { + function MemberTests$VirtualIndexer() { + this.n = 0; var i = this.get_item('name'); this.set_item('name', i + 1); -} -MemberTests.VirtualIndexer.prototype = { - n: 0, + } + var MemberTests$VirtualIndexer$ = { get_item: function(name) { - return this.n; + return this.n; }, set_item: function(name, value) { - this.n = value; - return value; + this.n = value; + return value; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.OverriddenIndexer + // MemberTests.AbstractIndexer -MemberTests.OverriddenIndexer = function() { - MemberTests.OverriddenIndexer.initializeBase(this); + function MemberTests$AbstractIndexer() { + this.n = 0; var i = this.get_item('name'); this.set_item('name', i + 1); - var j = MemberTests.OverriddenIndexer.callBaseMethod(this, 'get_item', [ 'name' ]); - MemberTests.OverriddenIndexer.callBaseMethod(this, 'set_item', [ 'name', 43 ]); -} -MemberTests.OverriddenIndexer.prototype = { - get_item: function(name) { - return MemberTests.OverriddenIndexer.callBaseMethod(this, 'get_item', [ name ]) + 1; - }, - set_item: function(name, value) { - MemberTests.OverriddenIndexer.callBaseMethod(this, 'set_item', [ name, value - 1 ]); - return value; - } -} - - -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.AbstractIndexer - -MemberTests.AbstractIndexer = function() { - var i = this.get_item('name'); - this.set_item('name', i + 1); -} -MemberTests.AbstractIndexer.prototype = { - n: 0, - -} - - -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.ImplementedIndexer + } + var MemberTests$AbstractIndexer$ = { -MemberTests.ImplementedIndexer = function() { - MemberTests.ImplementedIndexer.initializeBase(this); - var i = this.get_item('name'); - this.set_item('name', i + 1); -} -MemberTests.ImplementedIndexer.prototype = { - n: 0, + }; -} + // MemberTests.MultipleArgs -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.MultipleArgs - -MemberTests.MultipleArgs = function() { + function MemberTests$MultipleArgs() { + this.n = 0; var i = this.get_item('name', 'name2', 'name3'); this.set_item('name', 'name2', 'name3', i + 1); -} -MemberTests.MultipleArgs.prototype = { - n: 0, + } + var MemberTests$MultipleArgs$ = { get_item: function(first, middle, last) { - var value = first + middle + last; - return value.length; + var value = first + middle + last; + return value.length; }, set_item: function(first, middle, last, value) { - this.n = value; - return value; + this.n = value; + return value; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.ImplementedIndexer2 + // MemberTests.ImplementedIndexer2 -MemberTests.ImplementedIndexer2 = function() { -} -MemberTests.ImplementedIndexer2.prototype = { + function MemberTests$ImplementedIndexer2() { + } + var MemberTests$ImplementedIndexer2$ = { get_item: function(index) { - return 0; + return 0; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.Test + // MemberTests.Test -MemberTests.Test = function() { - var ma = new MemberTests.MultipleArgs(); + function MemberTests$Test() { + var ma = new MemberTests$MultipleArgs(); ma.set_item('1', '2', '3', ma.get_item('3', '2', '1')); - var ii = new MemberTests.ImplementedIndexer(); + var ii = new MemberTests$ImplementedIndexer(); ii.set_item('big', ii.get_item('small')); var ai = ii; ai.set_item('small', ai.get_item('big')); - var indexable = new MemberTests.ImplementedIndexer2(); + var indexable = new MemberTests$ImplementedIndexer2(); var o = indexable.get_item(0); -} + } + var MemberTests$Test$ = { + + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.A + // MemberTests.A -MemberTests.A = function() { -} -MemberTests.A.prototype = { + function MemberTests$A() { + } + var MemberTests$A$ = { get_item: function(name) { - return name; + return name; } -} + }; + + + // MemberTests.OverriddenIndexer + + function MemberTests$OverriddenIndexer() { + MemberTests$VirtualIndexer.call(this); + var i = this.get_item('name'); + this.set_item('name', i + 1); + var j = MemberTests$VirtualIndexer$.get_item.call(this, 'name'); + MemberTests$VirtualIndexer$.set_item.call(this, 'name', 43); + } + var MemberTests$OverriddenIndexer$ = { + get_item: function(name) { + return MemberTests$VirtualIndexer$.get_item.call(this, name) + 1; + }, + set_item: function(name, value) { + MemberTests$VirtualIndexer$.set_item.call(this, name, value - 1); + return value; + } + }; + + + // MemberTests.ImplementedIndexer + + function MemberTests$ImplementedIndexer() { + this.n = 0; + MemberTests$AbstractIndexer.call(this); + var i = this.get_item('name'); + this.set_item('name', i + 1); + } + var MemberTests$ImplementedIndexer$ = { + + }; + + // MemberTests.B -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.B + function MemberTests$B() { + MemberTests$A.call(this); + } + var MemberTests$B$ = { -MemberTests.B = function() { - MemberTests.B.initializeBase(this); -} + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.C + // MemberTests.C -MemberTests.C = function() { - MemberTests.C.initializeBase(this); -} -MemberTests.C.main = function() { - var c = new MemberTests.C(); + function MemberTests$C() { + MemberTests$B.call(this); + } + MemberTests$C.main = function() { + var c = new MemberTests$C(); c.set_item('a', c.get_item('b')); var a = c; a.set_item('b', a.get_item('c')); -} -MemberTests.C.prototype = { + } + var MemberTests$C$ = { get_item: function(name) { - return name; + return name; } -} - - -MemberTests.Normal.registerClass('MemberTests.Normal'); -MemberTests.GetterOnly.registerClass('MemberTests.GetterOnly'); -MemberTests.VirtualIndexer.registerClass('MemberTests.VirtualIndexer'); -MemberTests.OverriddenIndexer.registerClass('MemberTests.OverriddenIndexer', MemberTests.VirtualIndexer); -MemberTests.AbstractIndexer.registerClass('MemberTests.AbstractIndexer'); -MemberTests.ImplementedIndexer.registerClass('MemberTests.ImplementedIndexer', MemberTests.AbstractIndexer); -MemberTests.MultipleArgs.registerClass('MemberTests.MultipleArgs'); -MemberTests.ImplementedIndexer2.registerClass('MemberTests.ImplementedIndexer2', null, MemberTests.IIndexable); -MemberTests.Test.registerClass('MemberTests.Test'); -MemberTests.A.registerClass('MemberTests.A'); -MemberTests.B.registerClass('MemberTests.B', MemberTests.A); -MemberTests.C.registerClass('MemberTests.C', MemberTests.B); + }; + + + var $test = ss.module('test', null, + { + IIndexable: [ MemberTests$IIndexable ], + Normal: [ MemberTests$Normal, MemberTests$Normal$, null ], + GetterOnly: [ MemberTests$GetterOnly, MemberTests$GetterOnly$, null ], + VirtualIndexer: [ MemberTests$VirtualIndexer, MemberTests$VirtualIndexer$, null ], + AbstractIndexer: [ MemberTests$AbstractIndexer, MemberTests$AbstractIndexer$, null ], + MultipleArgs: [ MemberTests$MultipleArgs, MemberTests$MultipleArgs$, null ], + ImplementedIndexer2: [ MemberTests$ImplementedIndexer2, MemberTests$ImplementedIndexer2$, null, MemberTests$IIndexable ], + Test: [ MemberTests$Test, MemberTests$Test$, null ], + A: [ MemberTests$A, MemberTests$A$, null ], + OverriddenIndexer: [ MemberTests$OverriddenIndexer, MemberTests$OverriddenIndexer$, MemberTests$VirtualIndexer ], + ImplementedIndexer: [ MemberTests$ImplementedIndexer, MemberTests$ImplementedIndexer$, MemberTests$AbstractIndexer ], + B: [ MemberTests$B, MemberTests$B$, MemberTests$A ], + C: [ MemberTests$C, MemberTests$C$, MemberTests$B ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Member/Methods/Baseline.txt b/tests/TestCases/Member/Methods/Baseline.txt index 18cf4a691..79f8759fd 100644 --- a/tests/TestCases/Member/Methods/Baseline.txt +++ b/tests/TestCases/Member/Methods/Baseline.txt @@ -1,94 +1,89 @@ -Type.registerNamespace('MemberTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.Test + // MemberTests.Test -MemberTests.Test = function() { -} -MemberTests.Test.prototype = { - + function MemberTests$Test() { + } + var MemberTests$Test$ = { do1: function() { }, - do2: function() { - return 0; + return 0; }, - do3: function(i, j) { - return i; + return i; }, - run: function() { - this.do1(); - var v = this.do2(); - var s = String.fromCharCode(0); - s = String.fromCharCode(32, 65, 66); - var i = s.indexOf('A'); - i = s.indexOf('A', 1); + this.do1(); + var v = this.do2(); + var s = String.fromCharCode(0); + s = String.fromCharCode(32, 65, 66); + var i = s.indexOf('A'); + i = s.indexOf('A', 1); }, - toString: function() { - window.m1(); - var x = new MemberTests.X(); - $.fn.extend(x, 10); - return null; + window.m1(); + var x = new MemberTests$X(); + $.fn.extend(x, 10); + return null; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.Foo + // MemberTests.Foo -window.doStuff = function() { -} + this.doStuff = function() { + } -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.Bar + // MemberTests.Bar -window.m1 = function() { -} -window.m2 = function() { -} + window.m1 = function() { + } + window.m2 = function() { + } -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.FooBar + // MemberTests.FooBar -window.doStuff2 = function() { -} + this.doStuff2 = function() { + } -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.FooBar2 + // MemberTests.FooBar2 -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.X + // MemberTests.X -MemberTests.X = function() { -} -MemberTests.X.prototype = { - + function MemberTests$X() { + } + var MemberTests$X$ = { update: function(i) { } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.Plugin + // MemberTests.Plugin -$.fn.extend = function(x, i) { + $.fn.extend = function(x, i) { x.update(i); return x; -} + } -MemberTests.Test.registerClass('MemberTests.Test'); -MemberTests.X.registerClass('MemberTests.X'); -alert('Startup code in FooBar'); -(function () { + var $test = ss.module('test', null, + { + Test: [ MemberTests$Test, MemberTests$Test$, null ], + X: [ MemberTests$X, MemberTests$X$, null ] + }); + + alert('Startup code in FooBar'); + (function() { var timeStamp = new Date().getMilliseconds(); alert('Startup code in FooBar: ' + timeStamp); -})(); + })(); + + return $test; +}); diff --git a/tests/TestCases/Member/Overloads/Baseline.txt b/tests/TestCases/Member/Overloads/Baseline.txt index 65bf3a7fa..607cbf52c 100644 --- a/tests/TestCases/Member/Overloads/Baseline.txt +++ b/tests/TestCases/Member/Overloads/Baseline.txt @@ -1,34 +1,42 @@ -Type.registerNamespace('MemberTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.Test + // MemberTests.Test -MemberTests.Test = function(name) { -} -MemberTests.Test.doSomething = function(o) { -} -MemberTests.Test.prototype = { - + function MemberTests$Test(name) { + } + MemberTests$Test.doSomething = function(o) { + } + var MemberTests$Test$ = { invoke: function(successCallback, errorCallback, context) { } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.App + // MemberTests.App -MemberTests.App = function() { - MemberTests.Test.doSomething(); - MemberTests.Test.doSomething(null); - var t1 = new MemberTests.Test(); - var t2 = new MemberTests.Test('test'); + function MemberTests$App() { + MemberTests$Test.doSomething(); + MemberTests$Test.doSomething(null); + var t1 = new MemberTests$Test(); + var t2 = new MemberTests$Test('test'); var cb1 = null; var cb2 = null; t1.invoke(cb1); t1.invoke(cb1, cb2); t2.invoke(cb1, cb2, t1); -} + } + var MemberTests$App$ = { + }; -MemberTests.Test.registerClass('MemberTests.Test'); -MemberTests.App.registerClass('MemberTests.App'); + + var $test = ss.module('test', null, + { + Test: [ MemberTests$Test, MemberTests$Test$, null ], + App: [ MemberTests$App, MemberTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Member/Properties/Baseline.txt b/tests/TestCases/Member/Properties/Baseline.txt index 2567984c1..5f88c6179 100644 --- a/tests/TestCases/Member/Properties/Baseline.txt +++ b/tests/TestCases/Member/Properties/Baseline.txt @@ -1,57 +1,62 @@ -Type.registerNamespace('MemberTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.Test + // MemberTests.Test -MemberTests.Test = function() { + function MemberTests$Test() { this.set_XYZ(1); this.set_XYZ(this.get_name().length); this.set_XYZ(this.get_name().length); - var v = MemberTests.Test.get_staticProp(); - v = MemberTests.Test.get_staticProp(); -} -MemberTests.Test.get_staticProp = function() { + var v = MemberTests$Test.get_staticProp(); + v = MemberTests$Test.get_staticProp(); + } + MemberTests$Test.get_staticProp = function() { return 2006; -} -MemberTests.Test.set_staticProp = function(value) { + } + MemberTests$Test.set_staticProp = function(value) { return value; -} -MemberTests.Test.prototype = { - + } + var MemberTests$Test$ = { get_XYZ: function() { - return 0; + return 0; }, set_XYZ: function(value) { - return value; + return value; }, - get_isFoo: function() { - return true; + return true; }, - get_name: function() { - return 'nk'; + return 'nk'; }, - get_isInitialized: function() { - return false; + return false; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.Test2 + // MemberTests.Test2 -MemberTests.Test2 = function() { - MemberTests.Test2.initializeBase(this); - var n = MemberTests.Test2.callBaseMethod(this, 'get_XYZ'); + function MemberTests$Test2() { + MemberTests$Test.call(this); + var n = MemberTests$Test$.get_XYZ.call(this); if (n === this.get_XYZ()) { } if (this.get_XYZ() === n) { } - n = MemberTests.Test.get_staticProp(); -} + n = MemberTests$Test.get_staticProp(); + } + var MemberTests$Test2$ = { + }; -MemberTests.Test.registerClass('MemberTests.Test'); -MemberTests.Test2.registerClass('MemberTests.Test2', MemberTests.Test); + + var $test = ss.module('test', null, + { + Test: [ MemberTests$Test, MemberTests$Test$, null ], + Test2: [ MemberTests$Test2, MemberTests$Test2$, MemberTests$Test ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Member/StaticConstructors/Baseline.txt b/tests/TestCases/Member/StaticConstructors/Baseline.txt index 4dadf0e69..d08192974 100644 --- a/tests/TestCases/Member/StaticConstructors/Baseline.txt +++ b/tests/TestCases/Member/StaticConstructors/Baseline.txt @@ -1,64 +1,83 @@ -Type.registerNamespace('MemberTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.Behavior + // MemberTests.Behavior -MemberTests.Behavior = function(e, name) { -} + function MemberTests$Behavior(e, name) { + } + var MemberTests$Behavior$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.MyClass -MemberTests.MyClass = function(d) { -} + // MemberTests.MyClass + function MemberTests$MyClass(d) { + } + var MemberTests$MyClass$ = { -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.MyClassEmpty + }; -MemberTests.MyClassEmpty = function() { -} + // MemberTests.MyClassEmpty -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.MyClassSimple + function MemberTests$MyClassEmpty() { + } + var MemberTests$MyClassEmpty$ = { -MemberTests.MyClassSimple = function() { -} + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.MyClassSimpleMulti + // MemberTests.MyClassSimple -MemberTests.MyClassSimpleMulti = function() { -} + function MemberTests$MyClassSimple() { + } + var MemberTests$MyClassSimple$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// MemberTests.MyBehavior -MemberTests.MyBehavior = function(element) { - MemberTests.MyBehavior.initializeBase(this, [ element, 'myBehavior' ]); -} + // MemberTests.MyClassSimpleMulti + function MemberTests$MyClassSimpleMulti() { + } + var MemberTests$MyClassSimpleMulti$ = { -MemberTests.Behavior.registerClass('MemberTests.Behavior'); -MemberTests.MyClass.registerClass('MemberTests.MyClass'); -MemberTests.MyClassEmpty.registerClass('MemberTests.MyClassEmpty'); -MemberTests.MyClassSimple.registerClass('MemberTests.MyClassSimple'); -MemberTests.MyClassSimpleMulti.registerClass('MemberTests.MyClassSimpleMulti'); -MemberTests.MyBehavior.registerClass('MemberTests.MyBehavior', MemberTests.Behavior); -MemberTests.MyClass.instance = null; -MemberTests.MyClass.instance = new MemberTests.MyClass(Date.get_now()); -alert('simple static ctor'); -alert('simple static ctor with multiple statements'); -document.getElementById('foo').innerHTML = '...'; -(function () { + }; + + + // MemberTests.MyBehavior + + function MemberTests$MyBehavior(element) { + MemberTests$Behavior.call(this, element, 'myBehavior'); + } + var MemberTests$MyBehavior$ = { + + }; + + + var $test = ss.module('test', null, + { + Behavior: [ MemberTests$Behavior, MemberTests$Behavior$, null ], + MyClass: [ MemberTests$MyClass, MemberTests$MyClass$, null ], + MyClassEmpty: [ MemberTests$MyClassEmpty, MemberTests$MyClassEmpty$, null ], + MyClassSimple: [ MemberTests$MyClassSimple, MemberTests$MyClassSimple$, null ], + MyClassSimpleMulti: [ MemberTests$MyClassSimpleMulti, MemberTests$MyClassSimpleMulti$, null ], + MyBehavior: [ MemberTests$MyBehavior, MemberTests$MyBehavior$, MemberTests$Behavior ] + }); + + MemberTests$MyClass.instance = new MemberTests$MyClass(Date.get_now()); + alert('simple static ctor'); + alert('simple static ctor with multiple statements'); + document.getElementById('foo').innerHTML = '...'; + (function() { var e = document.body; var b = true; if (!b) { - return; + return; } - new MemberTests.MyBehavior(e); -})(); + new MemberTests$MyBehavior(e); + })(); + + return $test; +}); diff --git a/tests/TestCases/Statement/Exceptions/Baseline.txt b/tests/TestCases/Statement/Exceptions/Baseline.txt index ea2ce95e0..3683b795d 100644 --- a/tests/TestCases/Statement/Exceptions/Baseline.txt +++ b/tests/TestCases/Statement/Exceptions/Baseline.txt @@ -1,43 +1,48 @@ -Type.registerNamespace('StatementTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// StatementTests.App + // StatementTests.App -StatementTests.App = function() { -} -StatementTests.App.prototype = { - + function StatementTests$App() { + } + var StatementTests$App$ = { test: function(arg) { - if (arg == null) { - throw new Error('null'); - } + if (arg == null) { + throw new Error('null'); + } }, - test2: function() { - try { - } - catch (e) { - } - try { - } - catch (e) { - } - finally { - } - try { - } - finally { - } - try { - } - catch ($e1) { - } - try { - } - catch ($e2) { - } + try { + } + catch (e) { + } + try { + } + catch (e) { + } + finally { + } + try { + } + finally { + } + try { + } + catch ($e1) { + } + try { + } + catch ($e2) { + } } -} + }; -StatementTests.App.registerClass('StatementTests.App'); + var $test = ss.module('test', null, + { + App: [ StatementTests$App, StatementTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Statement/Expression/Baseline.txt b/tests/TestCases/Statement/Expression/Baseline.txt index d8b2aa1be..027f21103 100644 --- a/tests/TestCases/Statement/Expression/Baseline.txt +++ b/tests/TestCases/Statement/Expression/Baseline.txt @@ -1,19 +1,25 @@ -Type.registerNamespace('StatementTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// StatementTests.App + // StatementTests.App -StatementTests.App = function() { -} -StatementTests.App.prototype = { - + function StatementTests$App() { + } + var StatementTests$App$ = { test: function(arg) { - var x; - arg = x.length; - arg++; - x = arg.toString(); + var x; + arg = x.length; + arg++; + x = arg.toString(); } -} + }; -StatementTests.App.registerClass('StatementTests.App'); + var $test = ss.module('test', null, + { + App: [ StatementTests$App, StatementTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Statement/For/Baseline.txt b/tests/TestCases/Statement/For/Baseline.txt index c02c5c957..15bc96ffd 100644 --- a/tests/TestCases/Statement/For/Baseline.txt +++ b/tests/TestCases/Statement/For/Baseline.txt @@ -1,32 +1,38 @@ -Type.registerNamespace('StatementTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// StatementTests.App + // StatementTests.App -StatementTests.App = function() { -} -StatementTests.App.prototype = { - + function StatementTests$App() { + } + var StatementTests$App$ = { test: function(arg) { - for (var i = 0; i < 10; i++) { - } - var x = 10; - var y = 100; - for (; x < y; x++) { - } - for (; x < y; ) { - } - for (var j = 1, k = 1; ; j++, k--) { - } - for (x = 1; x < 100; ) { - } - for (x = arg; x < 100; x++) { - } - for (x = 1; x < 2; x++) { - var z = x; - } + for (var i = 0; i < 10; i++) { + } + var x = 10; + var y = 100; + for (; x < y; x++) { + } + for (; x < y; ) { + } + for (var j = 1, k = 1; ; j++, k--) { + } + for (x = 1; x < 100; ) { + } + for (x = arg; x < 100; x++) { + } + for (x = 1; x < 2; x++) { + var z = x; + } } -} + }; -StatementTests.App.registerClass('StatementTests.App'); + var $test = ss.module('test', null, + { + App: [ StatementTests$App, StatementTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Statement/Foreach/Baseline.txt b/tests/TestCases/Statement/Foreach/Baseline.txt index 18fbb2a01..24a4a3dd1 100644 --- a/tests/TestCases/Statement/Foreach/Baseline.txt +++ b/tests/TestCases/Statement/Foreach/Baseline.txt @@ -1,56 +1,58 @@ -Type.registerNamespace('StatementTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// StatementTests.Set + // StatementTests.Set -StatementTests.Set = function() { -} -StatementTests.Set.prototype = { - _items: null, - + function StatementTests$Set() { + } + var StatementTests$Set$ = { getEnumerator: function() { - return this._items.getEnumerator(); + return this._items.getEnumerator(); } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// StatementTests.App + // StatementTests.App -StatementTests.App = function() { -} -StatementTests.App.prototype = { - + function StatementTests$App() { + } + var StatementTests$App$ = { test: function(arg) { - var items = [ 1, 2, 3 ]; - var sum = 0; - var $enum1 = ss.IEnumerator.getEnumerator(items); - while ($enum1.moveNext()) { - var i = $enum1.current; - sum += i; - } - var d = {}; - var $dict2 = d; - for (var $key3 in $dict2) { - var entry = { key: $key3, value: $dict2[$key3] }; - var s = entry.key + ' = ' + entry.value; - } - var s = new StatementTests.Set(); - var $enum4 = ss.IEnumerator.getEnumerator(s); - while ($enum4.moveNext()) { - var o = $enum4.current; - this.doStuff(o); - } + var items = [ 1, 2, 3 ]; + var sum = 0; + var $enum1 = ss.IEnumerator.getEnumerator(items); + while ($enum1.moveNext()) { + var i = $enum1.current; + sum += i; + } + var d = {}; + var $dict2 = d; + for (var $key3 in $dict2) { + var entry = { key: $key3, value: $dict2[$key3] }; + var s = entry.key + ' = ' + entry.value; + } + var s = new StatementTests$Set(); + var $enum4 = ss.IEnumerator.getEnumerator(s); + while ($enum4.moveNext()) { + var o = $enum4.current; + this.doStuff(o); + } }, - doStuff: function(o) { - var $dict1 = o; - for (var $key2 in $dict1) { - var entry = { key: $key2, value: $dict1[$key2] }; - } + var $dict1 = o; + for (var $key2 in $dict1) { + var entry = { key: $key2, value: $dict1[$key2] }; + } } -} + }; -StatementTests.Set.registerClass('StatementTests.Set', null, ss.IEnumerable); -StatementTests.App.registerClass('StatementTests.App'); + var $test = ss.module('test', null, + { + Set: [ StatementTests$Set, StatementTests$Set$, null, ss.IEnumerable ], + App: [ StatementTests$App, StatementTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Statement/IfElse/Baseline.txt b/tests/TestCases/Statement/IfElse/Baseline.txt index 8472c8e53..90f79571e 100644 --- a/tests/TestCases/Statement/IfElse/Baseline.txt +++ b/tests/TestCases/Statement/IfElse/Baseline.txt @@ -1,34 +1,40 @@ -Type.registerNamespace('StatementTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// StatementTests.App + // StatementTests.App -StatementTests.App = function() { -} -StatementTests.App.prototype = { - + function StatementTests$App() { + } + var StatementTests$App$ = { testMethod: function(boolValue, numValue) { - if (boolValue) { - } - if (boolValue) { - boolValue = false; - } - if (boolValue) { - } - else { - } - if (numValue === 1) { - } - else if (numValue === 2) { - } - if (numValue === 1) { - } - else if (numValue === 2) { - } - else { - } + if (boolValue) { + } + if (boolValue) { + boolValue = false; + } + if (boolValue) { + } + else { + } + if (numValue === 1) { + } + else if (numValue === 2) { + } + if (numValue === 1) { + } + else if (numValue === 2) { + } + else { + } } -} + }; -StatementTests.App.registerClass('StatementTests.App'); + var $test = ss.module('test', null, + { + App: [ StatementTests$App, StatementTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Statement/Return/Baseline.txt b/tests/TestCases/Statement/Return/Baseline.txt index d4da250df..1155354c4 100644 --- a/tests/TestCases/Statement/Return/Baseline.txt +++ b/tests/TestCases/Statement/Return/Baseline.txt @@ -1,31 +1,35 @@ -Type.registerNamespace('StatementTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// StatementTests.App + // StatementTests.App -StatementTests.App = function() { -} -StatementTests.App.prototype = { - + function StatementTests$App() { + } + var StatementTests$App$ = { test1: function(arg) { - return 0; + return 0; }, - test2: function(arg) { - return arg; + return arg; }, - test3: function(a) { - if (a) { - return; - } - var i; - switch (i) { - case 0: - return; - } + if (a) { + return; + } + var i; + switch (i) { + case 0: + return; + } } -} + }; -StatementTests.App.registerClass('StatementTests.App'); + var $test = ss.module('test', null, + { + App: [ StatementTests$App, StatementTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Statement/Switch/Baseline.txt b/tests/TestCases/Statement/Switch/Baseline.txt index c94aa22ec..78e3b9139 100644 --- a/tests/TestCases/Statement/Switch/Baseline.txt +++ b/tests/TestCases/Statement/Switch/Baseline.txt @@ -1,59 +1,63 @@ -Type.registerNamespace('StatementTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// StatementTests.Mode + // StatementTests.Mode -StatementTests.Mode = function() { }; -StatementTests.Mode.prototype = { + var StatementTests$Mode = { foo: 0, bar: 1 -} -StatementTests.Mode.registerEnum('StatementTests.Mode', false); + }; -//////////////////////////////////////////////////////////////////////////////// -// StatementTests.App + // StatementTests.App -StatementTests.App = function() { -} -StatementTests.App.prototype = { - + function StatementTests$App() { + } + var StatementTests$App$ = { test: function(arg, m) { - var i; - switch (i) { - case 0: - i = 0; - break; - case 1: - i = 2; - break; - case 2: - break; - case 3: - case 4: - i = 4; - break; - default: - i = 5; - break; - } - switch (arg) { - case 0: - i = 0; - break; - case 1: - default: - i = 2; - break; - } - switch (m) { - case 0: - break; - case 1: - break; - } + var i; + switch (i) { + case 0: + i = 0; + break; + case 1: + i = 2; + break; + case 2: + break; + case 3: + case 4: + i = 4; + break; + default: + i = 5; + break; + } + switch (arg) { + case 0: + i = 0; + break; + case 1: + default: + i = 2; + break; + } + switch (m) { + case 0: + break; + case 1: + break; + } } -} + }; -StatementTests.App.registerClass('StatementTests.App'); + var $test = ss.module('test', null, + { + Mode: StatementTests$Mode, + App: [ StatementTests$App, StatementTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Statement/Variables/Baseline.txt b/tests/TestCases/Statement/Variables/Baseline.txt index 05c3f0b2d..c0cc76410 100644 --- a/tests/TestCases/Statement/Variables/Baseline.txt +++ b/tests/TestCases/Statement/Variables/Baseline.txt @@ -1,37 +1,41 @@ -Type.registerNamespace('StatementTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// StatementTests.App + // StatementTests.App -StatementTests.App = function() { -} -StatementTests.App.prototype = { - + function StatementTests$App() { + } + var StatementTests$App$ = { test: function() { - var i = 0; - var b = true; - var x = i + 10; - var y, z; - var a = 1, c, d, e = c; + var i = 0; + var b = true; + var x = i + 10; + var y, z; + var a = 1, c, d, e = c; }, - test2: function(arg) { - var a = 1; - var b = arg; - while (a < b) { - var x = a - b; - a++; - } - while (a >= b) { - var x = 'Hello World'; - var foo = x.length; - } + var a = 1; + var b = arg; + while (a < b) { + var x = a - b; + a++; + } + while (a >= b) { + var x = 'Hello World'; + var foo = x.length; + } }, - test3: function(arg1, arg2) { - var value = arg1 + arg2; + var value = arg1 + arg2; } -} + }; -StatementTests.App.registerClass('StatementTests.App'); + var $test = ss.module('test', null, + { + App: [ StatementTests$App, StatementTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Statement/While/Baseline.txt b/tests/TestCases/Statement/While/Baseline.txt index 3ee0d275f..232c6cace 100644 --- a/tests/TestCases/Statement/While/Baseline.txt +++ b/tests/TestCases/Statement/While/Baseline.txt @@ -1,29 +1,35 @@ -Type.registerNamespace('StatementTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// StatementTests.App + // StatementTests.App -StatementTests.App = function() { -} -StatementTests.App.prototype = { - + function StatementTests$App() { + } + var StatementTests$App$ = { test: function(arg) { - var i; - while (i < arg) { - } - while (i < arg) { - i++; - } - while (arg === i) { - break; - } - do { - i--; - } while (i > 0); - do { - } while (!!i); + var i; + while (i < arg) { + } + while (i < arg) { + i++; + } + while (arg === i) { + break; + } + do { + i--; + } while (i > 0); + do { + } while (!!i); } -} + }; -StatementTests.App.registerClass('StatementTests.App'); + var $test = ss.module('test', null, + { + App: [ StatementTests$App, StatementTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Type/Classes/Baseline.txt b/tests/TestCases/Type/Classes/Baseline.txt index 749ef4109..05cd958a6 100644 --- a/tests/TestCases/Type/Classes/Baseline.txt +++ b/tests/TestCases/Type/Classes/Baseline.txt @@ -1,45 +1,63 @@ -Type.registerNamespace('TypeTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.FooBarBaz + // TypeTests.Foo -TypeTests.FooBarBaz = function TypeTests_FooBarBaz() { -} + function TypeTests$FooBarBaz() { + } + var TypeTests$FooBarBaz$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.MyClass -TypeTests.MyClass = function TypeTests_MyClass() { - TypeTests.FooBarBaz = new TypeTests.FooBarBaz(); -} + // TypeTests.MyClass + function TypeTests$MyClass() { + var f = new TypeTests$FooBarBaz(); + } + var TypeTests$MyClass$ = { -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.MyClass2 + }; -TypeTests.MyClass2 = function TypeTests_MyClass2() { - TypeTests.MyClass2.initializeBase(this); -} + // TypeTests.MyClass3 -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.MyClass3 + function TypeTests$MyClass3() { + } + var TypeTests$MyClass3$ = { -TypeTests.MyClass3 = function TypeTests_MyClass3() { -} + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.MyClass4 + // TypeTests.MyClass2 -TypeTests.MyClass4 = function TypeTests_MyClass4() { - TypeTests.MyClass4.initializeBase(this); -} + function TypeTests$MyClass2() { + TypeTests$MyClass.call(this); + } + var TypeTests$MyClass2$ = { + }; -TypeTests.FooBarBaz.registerClass('TypeTests.FooBarBaz'); -TypeTests.MyClass.registerClass('TypeTests.MyClass'); -TypeTests.MyClass2.registerClass('TypeTests.MyClass2', TypeTests.MyClass); -TypeTests.MyClass3.registerClass('TypeTests.MyClass3', null, ss.IDisposable); -TypeTests.MyClass4.registerClass('TypeTests.MyClass4', TypeTests.MyClass, ss.IDisposable); + + // TypeTests.MyClass4 + + function TypeTests$MyClass4() { + TypeTests$MyClass.call(this); + } + var TypeTests$MyClass4$ = { + + }; + + + var $test = ss.module('test', null, + { + FooBarBaz: [ TypeTests$FooBarBaz, TypeTests$FooBarBaz$, null ], + MyClass: [ TypeTests$MyClass, TypeTests$MyClass$, null ], + MyClass3: [ TypeTests$MyClass3, TypeTests$MyClass3$, null, ss.IDisposable ], + MyClass2: [ TypeTests$MyClass2, TypeTests$MyClass2$, TypeTests$MyClass ], + MyClass4: [ TypeTests$MyClass4, TypeTests$MyClass4$, TypeTests$MyClass, ss.IDisposable ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Type/Classes/Code.cs b/tests/TestCases/Type/Classes/Code.cs index ebd7042b6..8fb84036d 100644 --- a/tests/TestCases/Type/Classes/Code.cs +++ b/tests/TestCases/Type/Classes/Code.cs @@ -10,7 +10,7 @@ public class Foo { } public class MyClass { - public MyClass() { Foo = new Foo(); } + public MyClass() { Foo f = new Foo(); } } public class MyClass2 : MyClass { diff --git a/tests/TestCases/Type/Delegates/Baseline.txt b/tests/TestCases/Type/Delegates/Baseline.txt index 04e558d28..bf7be2836 100644 --- a/tests/TestCases/Type/Delegates/Baseline.txt +++ b/tests/TestCases/Type/Delegates/Baseline.txt @@ -1,10 +1,20 @@ -Type.registerNamespace('TypeTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.EventArgs + // TypeTests.EventArgs -TypeTests.EventArgs = function TypeTests_EventArgs() { -} + function TypeTests$EventArgs() { + } + var TypeTests$EventArgs$ = { + }; -TypeTests.EventArgs.registerClass('TypeTests.EventArgs'); + + var $test = ss.module('test', null, + { + EventArgs: [ TypeTests$EventArgs, TypeTests$EventArgs$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Type/Enumerator/Baseline.txt b/tests/TestCases/Type/Enumerator/Baseline.txt index 12882b599..76c892a59 100644 --- a/tests/TestCases/Type/Enumerator/Baseline.txt +++ b/tests/TestCases/Type/Enumerator/Baseline.txt @@ -1,49 +1,52 @@ -Type.registerNamespace('TypeTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.App1 + // TypeTests.App1 -TypeTests.App1 = function TypeTests_App1() { -} -TypeTests.App1.prototype = { - - getEnumerator: function TypeTests_App1$getEnumerator() { - return null; + function TypeTests$App1() { + } + var TypeTests$App1$ = { + getEnumerator: function() { + return null; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.App + // TypeTests.App -TypeTests.App = function TypeTests_App() { -} -TypeTests.App.prototype = { - - test1: function TypeTests_App$test1(arg) { + function TypeTests$App() { + } + var TypeTests$App$ = { + test1: function(arg) { }, - - test: function TypeTests_App$test(arg) { - var a; - var b; - var s = new Array(5); - var a1 = a.getEnumerator(); - a1 = b.getEnumerator(); - a1 = s.getEnumerator(); - var $enum1 = ss.IEnumerator.getEnumerator(s); - while ($enum1.moveNext()) { - var str = $enum1.current; - var s1 = str; - } - var app1; - var $enum2 = ss.IEnumerator.getEnumerator(app1); - while ($enum2.moveNext()) { - var str = $enum2.current; - var s1 = str; - } + test: function(arg) { + var a; + var b; + var s = new Array(5); + var a1 = a.getEnumerator(); + a1 = b.getEnumerator(); + a1 = s.getEnumerator(); + var $enum1 = ss.IEnumerator.getEnumerator(s); + while ($enum1.moveNext()) { + var str = $enum1.current; + var s1 = str; + } + var app1; + var $enum2 = ss.IEnumerator.getEnumerator(app1); + while ($enum2.moveNext()) { + var str = $enum2.current; + var s1 = str; + } } -} + }; -TypeTests.App1.registerClass('TypeTests.App1', null, ss.IEnumerable); -TypeTests.App.registerClass('TypeTests.App'); + var $test = ss.module('test', null, + { + App1: [ TypeTests$App1, TypeTests$App1$, null, ss.IEnumerable ], + App: [ TypeTests$App, TypeTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Type/Enumerator/Code.cs b/tests/TestCases/Type/Enumerator/Code.cs index 970e9f48b..512d88171 100644 --- a/tests/TestCases/Type/Enumerator/Code.cs +++ b/tests/TestCases/Type/Enumerator/Code.cs @@ -28,8 +28,8 @@ public void Test(int arg) { string s1 = str; } - App1 app1; - foreach (string str in app1) { + App1 app1; + foreach (string str in app1) { string s1 = str; } } diff --git a/tests/TestCases/Type/Enums/Baseline.txt b/tests/TestCases/Type/Enums/Baseline.txt index 822317911..4124c4084 100644 --- a/tests/TestCases/Type/Enums/Baseline.txt +++ b/tests/TestCases/Type/Enums/Baseline.txt @@ -1,126 +1,116 @@ -Type.registerNamespace('TypeTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.Colors + // TypeTests.Colors -TypeTests.Colors = function() { }; -TypeTests.Colors.prototype = { + var TypeTests$Colors = { red: 0, green: 1, blue: 2 -} -TypeTests.Colors.registerEnum('TypeTests.Colors', false); + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.Sequence + // TypeTests.Sequence -TypeTests.Sequence = function() { }; -TypeTests.Sequence.prototype = { + var TypeTests$Sequence = { item1: 1, item2: 2, item3: 3, item4: 5 -} -TypeTests.Sequence.registerEnum('TypeTests.Sequence', false); + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.Mode + // TypeTests.Mode -TypeTests.Mode = function() { }; -TypeTests.Mode.prototype = { + var TypeTests$Mode = { Public: 1, Protected: 2, Private: 4 -} -TypeTests.Mode.registerEnum('TypeTests.Mode', true); + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.UInt32Mask + // TypeTests.UInt32Mask -TypeTests.UInt32Mask = function() { }; -TypeTests.UInt32Mask.prototype = { + var TypeTests$UInt32Mask = { v: 4026531840, a: 4278190080 -} -TypeTests.UInt32Mask.registerEnum('TypeTests.UInt32Mask', false); + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.ShortMask + // TypeTests.ShortMask -TypeTests.ShortMask = function() { }; -TypeTests.ShortMask.prototype = { + var TypeTests$ShortMask = { v: 1, a: 4096 -} -TypeTests.ShortMask.registerEnum('TypeTests.ShortMask', false); + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.Errors + // TypeTests.Errors -TypeTests.Errors = function() { }; -TypeTests.Errors.prototype = { + var TypeTests$Errors = { S_OK: 0, S_FALSE: 1, E_FAIL: -1 -} -TypeTests.Errors.registerEnum('TypeTests.Errors', false); + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.Size + // TypeTests.Size -TypeTests.Size = function() { }; -TypeTests.Size.prototype = { + var TypeTests$Size = { small: 'small', Medium: 'Medium', large: 'large' -} -TypeTests.Size.registerEnum('TypeTests.Size', false); + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.App + // TypeTests.App -TypeTests.App = function TypeTests_App() { -} -TypeTests.App.main = function TypeTests_App$main() { + function TypeTests$App() { + } + TypeTests$App.main = function() { var m = 1; m = 1 | 4; var c = 0; -} - - -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.App2 - -TypeTests.App2 = function TypeTests_App2() { -} -TypeTests.App2.prototype = { - _httpMethod: null, - _sortMode: null, - - run: function TypeTests_App2$run() { - var method = 'POST'; - this.run1('GET'); - this.run2('status'); - this.run2('Group'); - this.run2('Ct'); - var s = 'Medium'; + } + var TypeTests$App$ = { + + }; + + + // TypeTests.App2 + + function TypeTests$App2() { + } + var TypeTests$App2$ = { + run: function() { + var method = 'POST'; + this.run1('GET'); + this.run2('status'); + this.run2('Group'); + this.run2('Ct'); + var s = 'Medium'; }, - - run1: function TypeTests_App2$run1(m) { - var s = m; + run1: function(m) { + var s = m; }, - - run2: function TypeTests_App2$run2(m) { + run2: function(m) { } -} + }; + + + var $test = ss.module('test', null, + { + Colors: TypeTests$Colors, + Sequence: TypeTests$Sequence, + Mode: TypeTests$Mode, + UInt32Mask: TypeTests$UInt32Mask, + ShortMask: TypeTests$ShortMask, + Errors: TypeTests$Errors, + Size: TypeTests$Size, + App: [ TypeTests$App, TypeTests$App$, null ], + App2: [ TypeTests$App2, TypeTests$App2$, null ] + }); -TypeTests.App.registerClass('TypeTests.App'); -TypeTests.App2.registerClass('TypeTests.App2'); + return $test; +}); diff --git a/tests/TestCases/Type/Globals/Baseline.txt b/tests/TestCases/Type/Globals/Baseline.txt index 0668873f0..3c2d67dbb 100644 --- a/tests/TestCases/Type/Globals/Baseline.txt +++ b/tests/TestCases/Type/Globals/Baseline.txt @@ -1,77 +1,85 @@ -//////////////////////////////////////////////////////////////////////////////// -// MyRecord +define('test', ['ss'], function(ss) { + 'use strict'; -window.$create_MyRecord = function MyRecord() { return {}; } + // MyEnum + var MyEnum = { + }; -//////////////////////////////////////////////////////////////////////////////// -// MyEnum -window.MyEnum = function() { }; -MyEnum.prototype = { -} -MyEnum.registerEnum('MyEnum', false); + // IXyzInterface + function IXyzInterface() { } -//////////////////////////////////////////////////////////////////////////////// -// IXyzInterface -window.IXyzInterface = function() { }; -IXyzInterface.prototype = { + // MyRecord -} -IXyzInterface.registerInterface('IXyzInterface'); + function MyRecord() { return {}; } -//////////////////////////////////////////////////////////////////////////////// -// MyClass + // MyClass -window.MyClass = function MyClass() { -} + function MyClass() { + } + var MyClass$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// MyClass2 -window.MyClass2 = function MyClass2() { - MyClass2.initializeBase(this); -} + // MyClass3 + function MyClass3() { + } + var MyClass3$ = { -//////////////////////////////////////////////////////////////////////////////// -// MyClass3 + }; -window.MyClass3 = function MyClass3() { -} + // Foo.MyClassF -//////////////////////////////////////////////////////////////////////////////// -// MyClass4 + function Foo$MyClassF() { + } + var Foo$MyClassF$ = { -window.MyClass4 = function MyClass4() { - MyClass4.initializeBase(this); -} -MyClass4.prototype = { - - someMethod: function MyClass4$someMethod() { - var xyz = null; - var c2 = new MyClass2(); - xyz = Type.safeCast(c2, IXyzInterface); - } -} + }; + + + // MyClass2 + + function MyClass2() { + MyClass.call(this); + } + var MyClass2$ = { + }; -Type.registerNamespace('Foo'); -//////////////////////////////////////////////////////////////////////////////// -// Foo.MyClassF + // MyClass4 + + function MyClass4() { + MyClass.call(this); + } + var MyClass4$ = { + someMethod: function() { + var xyz = null; + var c2 = new MyClass2(); + xyz = Type.safeCast(c2, IXyzInterface); + } + }; + -Foo.MyClassF = function Foo_MyClassF() { -} + var $test = ss.module('test', null, + { + MyEnum: MyEnum, + IXyzInterface: [ IXyzInterface ], + MyRecord: MyRecord, + MyClass: [ MyClass, MyClass$, null ], + MyClass3: [ MyClass3, MyClass3$, null, ss.IDisposable ], + MyClassF: [ Foo$MyClassF, Foo$MyClassF$, null ], + MyClass2: [ MyClass2, MyClass2$, MyClass ], + MyClass4: [ MyClass4, MyClass4$, MyClass, ss.IDisposable ] + }); -MyClass.registerClass('MyClass'); -MyClass2.registerClass('MyClass2', MyClass); -MyClass3.registerClass('MyClass3', null, ss.IDisposable); -MyClass4.registerClass('MyClass4', MyClass, ss.IDisposable); -Foo.MyClassF.registerClass('Foo.MyClassF'); + return $test; +}); diff --git a/tests/TestCases/Type/Imported/Baseline.txt b/tests/TestCases/Type/Imported/Baseline.txt index 124c55e57..b916da9cf 100644 --- a/tests/TestCases/Type/Imported/Baseline.txt +++ b/tests/TestCases/Type/Imported/Baseline.txt @@ -1,9 +1,9 @@ -Type.registerNamespace('TypeTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.App + // TypeTests.App -TypeTests.App = function() { + function TypeTests$App() { var elem = document.getElementById('foo'); var s = elem.myString; elem['Smith'] = elem['Joe']; @@ -11,7 +11,17 @@ TypeTests.App = function() { var parser = new DOMParser(); var doc = parser.parseFromString('', 'text/xml'); var d = Date.parseDate('1/1/2010'); -} + } + var TypeTests$App$ = { + }; -TypeTests.App.registerClass('TypeTests.App'); + + var $test = ss.module('test', null, + { + App: [ TypeTests$App, TypeTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Type/Interfaces/Baseline.txt b/tests/TestCases/Type/Interfaces/Baseline.txt index fe598fefd..b7478f116 100644 --- a/tests/TestCases/Type/Interfaces/Baseline.txt +++ b/tests/TestCases/Type/Interfaces/Baseline.txt @@ -1,85 +1,71 @@ -Type.registerNamespace('TypeTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.IMarker + // TypeTests.IMarker -TypeTests.IMarker = function() { }; -TypeTests.IMarker.prototype = { + function TypeTests$IMarker() { } -} -TypeTests.IMarker.registerInterface('TypeTests.IMarker'); + // TypeTests.ISerializable -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.ISerializable + function TypeTests$ISerializable() { } -TypeTests.ISerializable = function() { }; -TypeTests.ISerializable.prototype = { - serialize : null -} -TypeTests.ISerializable.registerInterface('TypeTests.ISerializable'); + // TypeTests.IRunnable -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.IRunnable + function TypeTests$IRunnable() { } -TypeTests.IRunnable = function() { }; -TypeTests.IRunnable.prototype = { - get_canRun : null, - run : null -} -TypeTests.IRunnable.registerInterface('TypeTests.IRunnable'); + // TypeTests.MyObject -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.MyObject - -TypeTests.MyObject = function TypeTests_MyObject() { -} -TypeTests.MyObject.prototype = { - - dispose: function TypeTests_MyObject$dispose() { + function TypeTests$MyObject() { + } + var TypeTests$MyObject$ = { + dispose: function() { } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.MyObject2 + // TypeTests.Foo -TypeTests.MyObject2 = function TypeTests_MyObject2() { - TypeTests.MyObject2.initializeBase(this); -} -TypeTests.MyObject2.prototype = { - - get_canRun: function TypeTests_MyObject2$get_canRun() { - return true; + function TypeTests$Foo() { + } + var TypeTests$Foo$ = { + get_canRun: function() { + return true; + }, + run: function() { }, - - run: function TypeTests_MyObject2$run() { + serialize: function() { + return null; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.Foo + // TypeTests.MyObject2 -TypeTests.Foo = function TypeTests_Foo() { -} -TypeTests.Foo.prototype = { - - get_canRun: function TypeTests_Foo$get_canRun() { - return true; - }, - - run: function TypeTests_Foo$run() { + function TypeTests$MyObject2() { + TypeTests$MyObject.call(this); + } + var TypeTests$MyObject2$ = { + get_canRun: function() { + return true; }, - - serialize: function TypeTests_Foo$serialize() { - return null; + run: function() { } -} + }; + + + var $test = ss.module('test', null, + { + IMarker: [ TypeTests$IMarker ], + ISerializable: [ TypeTests$ISerializable ], + IRunnable: [ TypeTests$IRunnable ], + MyObject: [ TypeTests$MyObject, TypeTests$MyObject$, null, ss.IDisposable ], + Foo: [ TypeTests$Foo, TypeTests$Foo$, null, TypeTests$IMarker, TypeTests$ISerializable, TypeTests$IRunnable ], + MyObject2: [ TypeTests$MyObject2, TypeTests$MyObject2$, TypeTests$MyObject, TypeTests$IRunnable ] + }); -TypeTests.MyObject.registerClass('TypeTests.MyObject', null, ss.IDisposable); -TypeTests.MyObject2.registerClass('TypeTests.MyObject2', TypeTests.MyObject, TypeTests.IRunnable); -TypeTests.Foo.registerClass('TypeTests.Foo', null, TypeTests.IMarker, TypeTests.ISerializable, TypeTests.IRunnable); + return $test; +}); diff --git a/tests/TestCases/Type/Namespaces/Baseline.txt b/tests/TestCases/Type/Namespaces/Baseline.txt index fdf5957af..3e9726616 100644 --- a/tests/TestCases/Type/Namespaces/Baseline.txt +++ b/tests/TestCases/Type/Namespaces/Baseline.txt @@ -1,95 +1,97 @@ -Type.registerNamespace('TypeTests.Sub1.Sub2'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.Sub1.Sub2.MyClass + // TypeTests.Sub1.Sub2.MyClass -TypeTests.Sub1.Sub2.MyClass = function TypeTests_Sub1_Sub2_MyClass() { - var yc = new TypeTests.Sub1.YourClass(); + function TypeTests$Sub1$Sub2$MyClass() { + var yc = new TypeTests$Sub1$YourClass(); yc.run(); -} + } + var TypeTests$Sub1$Sub2$MyClass$ = { + }; -Type.registerNamespace('TypeTests.Sub1'); -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.Sub1.YourClass + // TypeTests.Sub1.YourClass -TypeTests.Sub1.YourClass = function TypeTests_Sub1_YourClass() { -} -TypeTests.Sub1.YourClass.prototype = { - - run: function TypeTests_Sub1_YourClass$run() { + function TypeTests$Sub1$YourClass() { + } + var TypeTests$Sub1$YourClass$ = { + run: function() { } -} + }; -Type.registerNamespace('TypeTests'); + // TypeTests.YourClass1 -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.YourClass1 + function TypeTests$YourClass1() { + } + var TypeTests$YourClass1$ = { -TypeTests.YourClass1 = function TypeTests_YourClass1() { -} + }; -Type.registerNamespace('MyApp.Foo'); + // MyApp.Foo.MyClassF -//////////////////////////////////////////////////////////////////////////////// -// MyApp.Foo.MyClassF + function MyApp$Foo$MyClassF() { + } + var MyApp$Foo$MyClassF$ = { -MyApp.Foo.MyClassF = function MyApp_Foo_MyClassF() { -} + }; -Type.registerNamespace('MyApp'); + // MyApp.Test -//////////////////////////////////////////////////////////////////////////////// -// MyApp.Test + function MyApp$Test() { + var c = new TypeTests$Sub1$Sub2$MyClass(); + } + var MyApp$Test$ = { -MyApp.Test = function MyApp_Test() { - var c = new TypeTests.Sub1.Sub2.MyClass(); -} + }; -Type.registerNamespace('MyCompany'); + // MyCompany.Utility -//////////////////////////////////////////////////////////////////////////////// -// MyCompany.Utility - -MyCompany.Utility = function MyCompany_Utility() { -} -MyCompany.Utility.prototype = { - - run: function MyCompany_Utility$run() { + function MyCompany$Utility() { + } + var MyCompany$Utility$ = { + run: function() { } -} - + }; -Type.registerNamespace('MyCompany.MyProduct'); -//////////////////////////////////////////////////////////////////////////////// -// MyCompany.MyProduct.UtilityP + // MyCompany.MyProduct.UtilityP -MyCompany.MyProduct.UtilityP = function MyCompany_MyProduct_UtilityP() { -} + function MyCompany$MyProduct$UtilityP() { + } + var MyCompany$MyProduct$UtilityP$ = { + }; -Type.registerNamespace('MyCompany.MyProduct.MyComponent'); -//////////////////////////////////////////////////////////////////////////////// -// MyCompany.MyProduct.MyComponent.Component + // MyCompany.MyProduct.MyComponent.Component -MyCompany.MyProduct.MyComponent.Component = function MyCompany_MyProduct_MyComponent_Component() { - var u = new MyCompany.Utility(); + function MyCompany$MyProduct$MyComponent$Component() { + var u = new MyCompany$Utility(); u.run(); -} + } + var MyCompany$MyProduct$MyComponent$Component$ = { + + }; + + + var $test = ss.module('test', null, + { + MyClass: [ TypeTests$Sub1$Sub2$MyClass, TypeTests$Sub1$Sub2$MyClass$, null ], + YourClass: [ TypeTests$Sub1$YourClass, TypeTests$Sub1$YourClass$, null ], + YourClass1: [ TypeTests$YourClass1, TypeTests$YourClass1$, null ], + MyClassF: [ MyApp$Foo$MyClassF, MyApp$Foo$MyClassF$, null ], + Test: [ MyApp$Test, MyApp$Test$, null ], + Utility: [ MyCompany$Utility, MyCompany$Utility$, null ], + UtilityP: [ MyCompany$MyProduct$UtilityP, MyCompany$MyProduct$UtilityP$, null ], + Component: [ MyCompany$MyProduct$MyComponent$Component, MyCompany$MyProduct$MyComponent$Component$, null ] + }); -TypeTests.Sub1.Sub2.MyClass.registerClass('TypeTests.Sub1.Sub2.MyClass'); -TypeTests.Sub1.YourClass.registerClass('TypeTests.Sub1.YourClass'); -TypeTests.YourClass1.registerClass('TypeTests.YourClass1'); -MyApp.Foo.MyClassF.registerClass('MyApp.Foo.MyClassF'); -MyApp.Test.registerClass('MyApp.Test'); -MyCompany.Utility.registerClass('MyCompany.Utility'); -MyCompany.MyProduct.UtilityP.registerClass('MyCompany.MyProduct.UtilityP'); -MyCompany.MyProduct.MyComponent.Component.registerClass('MyCompany.MyProduct.MyComponent.Component'); + return $test; +}); diff --git a/tests/TestCases/Type/Nullable/Baseline.txt b/tests/TestCases/Type/Nullable/Baseline.txt index 5e0026c5c..c4ad80d25 100644 --- a/tests/TestCases/Type/Nullable/Baseline.txt +++ b/tests/TestCases/Type/Nullable/Baseline.txt @@ -1,32 +1,38 @@ -Type.registerNamespace('TypeTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.App + // TypeTests.App -TypeTests.App = function TypeTests_App() { -} -TypeTests.App.prototype = { - - method: function TypeTests_App$method() { - var i = 10; - var b = true; - var flag; - var num; - var num2; - var num3 = 100; - var xyz = false; - var ch; - var hasValue = ss.isValue(xyz) || ss.isValue(num3); - var num3_ = num3; - var f = (ss.isValue(flag)) ? flag : true; - xyz = true; - num2 = 10; - num = 1; - var boolVal = (flag || false); - var textVal = (ch || ''); - var numVal = (num3 || 0); + function TypeTests$App() { + } + var TypeTests$App$ = { + method: function() { + var i = 10; + var b = true; + var flag; + var num; + var num2; + var num3 = 100; + var xyz = false; + var ch; + var hasValue = ss.isValue(xyz) || ss.isValue(num3); + var num3_ = num3; + var f = (ss.isValue(flag)) ? flag : true; + xyz = true; + num2 = 10; + num = 1; + var boolVal = (flag || false); + var textVal = (ch || ''); + var numVal = (num3 || 0); } -} + }; -TypeTests.App.registerClass('TypeTests.App'); + var $test = ss.module('test', null, + { + App: [ TypeTests$App, TypeTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Type/Partials/Baseline.txt b/tests/TestCases/Type/Partials/Baseline.txt index 711f39776..f3f0a81bd 100644 --- a/tests/TestCases/Type/Partials/Baseline.txt +++ b/tests/TestCases/Type/Partials/Baseline.txt @@ -1,130 +1,73 @@ -Type.registerNamespace('TypeTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.IMyInterface + // TypeTests.IMyInterface -TypeTests.IMyInterface = function() { }; -TypeTests.IMyInterface.prototype = { - start : null, - Stop : null, - resume : null -} -TypeTests.IMyInterface.registerInterface('TypeTests.IMyInterface'); + function TypeTests$IMyInterface() { } -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.EmptyClass + // TypeTests.EmptyClass -TypeTests.EmptyClass = function TypeTests_EmptyClass() { -} + function TypeTests$EmptyClass() { + } + var TypeTests$EmptyClass$ = { + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.SingleMemberClass -TypeTests.SingleMemberClass = function TypeTests_SingleMemberClass() { -} -TypeTests.SingleMemberClass.prototype = { - - run: function TypeTests_SingleMemberClass$run() { - } -} - - -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.DerivedMemberClass - -TypeTests.DerivedMemberClass = function TypeTests_DerivedMemberClass() { - TypeTests.DerivedMemberClass.initializeBase(this); -} - - -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.MergedMembersClass + // TypeTests.SingleMemberClass -TypeTests.MergedMembersClass = function TypeTests_MergedMembersClass() { -} -TypeTests.MergedMembersClass.prototype = { - foo: false, - bar: null, - - testMethod: function TypeTests_MergedMembersClass$testMethod() { - return null; + function TypeTests$SingleMemberClass() { + } + var TypeTests$SingleMemberClass$ = { + run: function() { } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.DerivedMergedMembersClass + // TypeTests.MergedMembersClass -TypeTests.DerivedMergedMembersClass = function TypeTests_DerivedMergedMembersClass() { - TypeTests.DerivedMergedMembersClass.initializeBase(this); - this.name = this.bar + this.bar + 'Name'; -} -TypeTests.DerivedMergedMembersClass.prototype = { - name: null, - value: null, - - testMethod: function TypeTests_DerivedMergedMembersClass$testMethod() { - return null; - }, - - testMethod2: function TypeTests_DerivedMergedMembersClass$testMethod2() { - return this.get_item('foo'); - }, - - someMethod: function TypeTests_DerivedMergedMembersClass$someMethod() { - var e1 = document.getElementById(this.bar); - var e2 = document.getElementById(this.name); - var e3 = document.getElementById(this.bar); - var s = this.testMethod() + TypeTests.DerivedMergedMembersClass.callBaseMethod(this, 'testMethod'); - }, - get_item: function TypeTests_DerivedMergedMembersClass$get_item(s) { - return s; + function TypeTests$MergedMembersClass() { + this.foo = false; + } + var TypeTests$MergedMembersClass$ = { + testMethod: function() { + return null; } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.MyClass + // TypeTests.MyClass -TypeTests.MyClass = function TypeTests_MyClass() { -} -TypeTests.MyClass.prototype = { - - start: function TypeTests_MyClass$start() { + function TypeTests$MyClass() { + } + var TypeTests$MyClass$ = { + start: function() { }, - - Stop: function TypeTests_MyClass$Stop() { + Stop: function() { }, - - resume: function TypeTests_MyClass$resume() { + resume: function() { } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.SomeClass + // TypeTests.SomeClass -TypeTests.SomeClass = function TypeTests_SomeClass() { -} -TypeTests.SomeClass.prototype = { - - close: function TypeTests_SomeClass$close() { + function TypeTests$SomeClass() { + } + var TypeTests$SomeClass$ = { + close: function() { }, - - _cancel: function TypeTests_SomeClass$_cancel() { + _cancel: function() { }, - - run: function TypeTests_SomeClass$run() { + run: function() { } -} + }; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.App + // TypeTests.App -TypeTests.App = function TypeTests_App() { + function TypeTests$App() { var s; s.run(); var d; @@ -134,14 +77,62 @@ TypeTests.App = function TypeTests_App() { mc.start(); mc.Stop(); mc.resume(); -} + } + var TypeTests$App$ = { + + }; + + // TypeTests.DerivedMemberClass -TypeTests.EmptyClass.registerClass('TypeTests.EmptyClass'); -TypeTests.SingleMemberClass.registerClass('TypeTests.SingleMemberClass'); -TypeTests.DerivedMemberClass.registerClass('TypeTests.DerivedMemberClass', TypeTests.SingleMemberClass); -TypeTests.MergedMembersClass.registerClass('TypeTests.MergedMembersClass'); -TypeTests.DerivedMergedMembersClass.registerClass('TypeTests.DerivedMergedMembersClass', TypeTests.MergedMembersClass); -TypeTests.MyClass.registerClass('TypeTests.MyClass', null, TypeTests.IMyInterface); -TypeTests.SomeClass.registerClass('TypeTests.SomeClass'); -TypeTests.App.registerClass('TypeTests.App'); + function TypeTests$DerivedMemberClass() { + TypeTests$SingleMemberClass.call(this); + } + var TypeTests$DerivedMemberClass$ = { + + }; + + + // TypeTests.DerivedMergedMembersClass + + function TypeTests$DerivedMergedMembersClass() { + TypeTests$MergedMembersClass.call(this); + this.name = this.bar + this.bar + 'Name'; + } + var TypeTests$DerivedMergedMembersClass$ = { + testMethod: function() { + return null; + }, + testMethod2: function() { + return this.get_item('foo'); + }, + someMethod: function() { + var e1 = document.getElementById(this.bar); + var e2 = document.getElementById(this.name); + var e3 = document.getElementById(this.bar); + var s = this.testMethod() + TypeTests$MergedMembersClass$.testMethod.call(this); + }, + get_item: function(s) { + return s; + } + }; + + + var $test = ss.module('test', + { + SingleMemberClass: [ TypeTests$SingleMemberClass, TypeTests$SingleMemberClass$, null ], + SomeClass: [ TypeTests$SomeClass, TypeTests$SomeClass$, null ] + }, + { + IMyInterface: [ TypeTests$IMyInterface ], + EmptyClass: [ TypeTests$EmptyClass, TypeTests$EmptyClass$, null ], + MergedMembersClass: [ TypeTests$MergedMembersClass, TypeTests$MergedMembersClass$, null ], + MyClass: [ TypeTests$MyClass, TypeTests$MyClass$, null, TypeTests$IMyInterface ], + App: [ TypeTests$App, TypeTests$App$, null ], + DerivedMemberClass: [ TypeTests$DerivedMemberClass, TypeTests$DerivedMemberClass$, TypeTests$SingleMemberClass ], + DerivedMergedMembersClass: [ TypeTests$DerivedMergedMembersClass, TypeTests$DerivedMergedMembersClass$, TypeTests$MergedMembersClass ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Type/Records/Baseline.txt b/tests/TestCases/Type/Records/Baseline.txt index eed9c7e14..5a35f1736 100644 --- a/tests/TestCases/Type/Records/Baseline.txt +++ b/tests/TestCases/Type/Records/Baseline.txt @@ -1,19 +1,27 @@ -Type.registerNamespace('TypeTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.Point + // TypeTests.Point -TypeTests.$create_Point = function TypeTests_Point(x, y) { - var $o = { }; + function TypeTests$Point(x, y) { + var $o = {}; $o.x = x; $o.y = y; return $o; -} + } -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.Pair + // TypeTests.Pair -TypeTests.$create_Pair = function TypeTests_Pair() { return {}; } + function TypeTests$Pair() { return {}; } + var $test = ss.module('test', null, + { + Point: TypeTests$Point, + Pair: TypeTests$Pair + }); + + + return $test; +}); diff --git a/tests/TestCases/Type/UsingAlias/Baseline.txt b/tests/TestCases/Type/UsingAlias/Baseline.txt index 9e4a3dc97..8908a027e 100644 --- a/tests/TestCases/Type/UsingAlias/Baseline.txt +++ b/tests/TestCases/Type/UsingAlias/Baseline.txt @@ -1,13 +1,23 @@ -Type.registerNamespace('TypeTests'); +define('test', ['ss'], function(ss) { + 'use strict'; -//////////////////////////////////////////////////////////////////////////////// -// TypeTests.MyClass + // TypeTests.MyClass -TypeTests.MyClass = function TypeTests_MyClass() { + function TypeTests$MyClass() { var body = document.body; var head = document.getElementsByTagName('head')[0]; head.appendChild(body); -} + } + var TypeTests$MyClass$ = { + }; -TypeTests.MyClass.registerClass('TypeTests.MyClass'); + + var $test = ss.module('test', null, + { + MyClass: [ TypeTests$MyClass, TypeTests$MyClass$, null ] + }); + + + return $test; +}); From a63480d55a908ca1e6b46083eec611648f86bf8b Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sat, 15 Sep 2012 12:08:37 -0700 Subject: [PATCH 020/251] Add JSON literal return scenario --- tests/TestCases/Statement/Return/Baseline.txt | 3 +++ tests/TestCases/Statement/Return/Code.cs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/tests/TestCases/Statement/Return/Baseline.txt b/tests/TestCases/Statement/Return/Baseline.txt index 1155354c4..b3ea0ecb9 100644 --- a/tests/TestCases/Statement/Return/Baseline.txt +++ b/tests/TestCases/Statement/Return/Baseline.txt @@ -21,6 +21,9 @@ define('test', ['ss'], function(ss) { case 0: return; } + }, + test4: function() { + return { a: 123, b: '456' }; } }; diff --git a/tests/TestCases/Statement/Return/Code.cs b/tests/TestCases/Statement/Return/Code.cs index d48d59ef6..dd6289a94 100644 --- a/tests/TestCases/Statement/Return/Code.cs +++ b/tests/TestCases/Statement/Return/Code.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Runtime.CompilerServices; [assembly: ScriptAssembly("test")] @@ -26,5 +27,9 @@ public void Test3(bool a) { return; } } + + public Dictionary Test4() { + return new Dictionary("a", 123, "b", "456"); + } } } From 7ec93a6e76eae21b1dee313d9155befcac509976 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sat, 15 Sep 2012 12:10:14 -0700 Subject: [PATCH 021/251] Update script generation for new type related APIs --- .../Compiler/Compiler/ExpressionBuilder.cs | 24 +++++-- .../Compiler/Generator/ExpressionGenerator.cs | 2 +- .../Compiler/Importer/MetadataImporter.cs | 67 ++++++++++--------- src/Core/CoreLib/Type.cs | 5 ++ src/Core/Scripts/Runtime.js | 9 +-- src/Core/Scripts/Runtime/TypeSystem.js | 32 +++------ tests/TestCases/Basic/Metadata/Baseline.txt | 56 +++++++++++----- .../TestCases/Expression/Binary/Baseline.txt | 4 +- tests/TestCases/Expression/Cast/Baseline.txt | 10 +-- .../TestCases/Expression/GetType/Baseline.txt | 14 +++- tests/TestCases/Expression/GetType/Code.cs | 11 +++ tests/TestCases/Type/Globals/Baseline.txt | 2 +- tests/TestSite/TestOOP.htm | 32 ++++----- 13 files changed, 160 insertions(+), 108 deletions(-) diff --git a/src/Core/Compiler/Compiler/ExpressionBuilder.cs b/src/Core/Compiler/Compiler/ExpressionBuilder.cs index c63ad741b..b3c20e675 100644 --- a/src/Core/Compiler/Compiler/ExpressionBuilder.cs +++ b/src/Core/Compiler/Compiler/ExpressionBuilder.cs @@ -961,16 +961,32 @@ private Expression ProcessOpenParenExpressionNode(BinaryExpressionNode node) { method.Name.Equals("GetType", StringComparison.Ordinal)) { // Since we can't extend object's prototype, we need to transform the // natural c# syntax into a static method. - // Object.GetType instance method becomes Type.GetInstanceType static method + // Object.GetType instance method becomes Script.GetType static method - TypeSymbol typeSymbol = typeType; + method = (MethodSymbol)scriptType.GetMember("GetType"); + Debug.Assert(method != null); + + methodExpression = new MethodExpression(new TypeExpression(scriptType, SymbolFilter.Public | SymbolFilter.StaticMembers), + method); + methodExpression.AddParameterValue(memberExpression.ObjectReference); + return methodExpression; + } + else if ((method.Parent == typeType) && + (method.Name.Equals("IsAssignableFrom", StringComparison.Ordinal) || + method.Name.Equals("IsInstanceOfType", StringComparison.Ordinal))) { + Debug.Assert(args.Count == 1); + + // These need to get mapped over to the methods on the Script type, since + // we are minimizing extensions to built-in script types. - method = (MethodSymbol)typeSymbol.GetMember("GetInstanceType"); + method = (MethodSymbol)scriptType.GetMember(method.Name); Debug.Assert(method != null); - methodExpression = new MethodExpression(new TypeExpression(typeSymbol, SymbolFilter.Public | SymbolFilter.StaticMembers), + methodExpression = new MethodExpression(new TypeExpression(scriptType, SymbolFilter.Public | SymbolFilter.StaticMembers), method); methodExpression.AddParameterValue(memberExpression.ObjectReference); + methodExpression.AddParameterValue(args[0]); + return methodExpression; } else if ((method.Parent == objectType) && diff --git a/src/Core/Compiler/Generator/ExpressionGenerator.cs b/src/Core/Compiler/Generator/ExpressionGenerator.cs index ece310eba..e547a613f 100644 --- a/src/Core/Compiler/Generator/ExpressionGenerator.cs +++ b/src/Core/Compiler/Generator/ExpressionGenerator.cs @@ -150,7 +150,7 @@ private static void GenerateBinaryExpression(ScriptGenerator generator, MemberSy TypeExpression typeExpression = expression.RightOperand as TypeExpression; Debug.Assert(typeExpression != null); - writer.Write("Type."); + writer.Write("ss."); if (expression.Operator == Operator.Is) { writer.Write("canCast("); } diff --git a/src/Core/Compiler/Importer/MetadataImporter.cs b/src/Core/Compiler/Importer/MetadataImporter.cs index 55406a8a3..86146d8e9 100644 --- a/src/Core/Compiler/Importer/MetadataImporter.cs +++ b/src/Core/Compiler/Importer/MetadataImporter.cs @@ -112,9 +112,6 @@ private ICollection ImportAssemblies(MetadataSource mdSource) { ImportPseudoMembers(PseudoClassMembers.Object, (ClassSymbol)typeSymbol); } - else if (typeSymbol.Name.Equals("Type", StringComparison.Ordinal)) { - ImportPseudoMembers(PseudoClassMembers.Type, (ClassSymbol)typeSymbol); - } else if (typeSymbol.Name.Equals("Dictionary", StringComparison.Ordinal)) { // The Dictionary class contains static methods at runtime, rather // than instance methods. @@ -528,6 +525,12 @@ private void ImportPseudoMembers(PseudoClassMembers memberSet, ClassSymbol class TypeSymbol stringType = (TypeSymbol)((ISymbolTable)_symbols.SystemNamespace).FindSymbol("String", null, SymbolFilter.Types); Debug.Assert(stringType != null); + TypeSymbol objectType = (TypeSymbol)((ISymbolTable)_symbols.SystemNamespace).FindSymbol("Object", null, SymbolFilter.Types); + Debug.Assert(objectType != null); + + TypeSymbol typeType = (TypeSymbol)((ISymbolTable)_symbols.SystemNamespace).FindSymbol("Type", null, SymbolFilter.Types); + Debug.Assert(objectType != null); + // Define the Escape, Unescape, encodeURI, decodeURI, encodeURIComponent, decodeURIComponent methods MethodSymbol escapeMethod = new MethodSymbol("Escape", classSymbol, stringType, MemberVisibility.Public | MemberVisibility.Static); classSymbol.AddMember(escapeMethod); @@ -551,6 +554,32 @@ private void ImportPseudoMembers(PseudoClassMembers memberSet, ClassSymbol class decodeURIComponentMethod.SetTransformedName("decodeURIComponent"); classSymbol.AddMember(decodeURIComponentMethod); + // GetType + // Define the Script.GetType static method which provides the functionality of + // Object.GetType instance method. We don't extend Object.prototype in script to add + // GetType, since we want to keep Object's protoype clean of any extensions. + + MethodSymbol getTypeMethod = new MethodSymbol("GetType", classSymbol, typeType, MemberVisibility.Public | MemberVisibility.Static); + getTypeMethod.SetAlias("ss.typeOf"); + getTypeMethod.AddParameter(new ParameterSymbol("instance", getTypeMethod, objectType, ParameterMode.In)); + classSymbol.AddMember(getTypeMethod); + + // IsInstanceOfType - Type.IsInstanceOfType gets mapped to this + + MethodSymbol isInstanceOfTypeMethod = new MethodSymbol("IsInstanceOfType", classSymbol, boolType, MemberVisibility.Public | MemberVisibility.Static); + isInstanceOfTypeMethod.SetAlias("ss.instanceOf"); + isInstanceOfTypeMethod.AddParameter(new ParameterSymbol("type", isInstanceOfTypeMethod, typeType, ParameterMode.In)); + isInstanceOfTypeMethod.AddParameter(new ParameterSymbol("instance", isInstanceOfTypeMethod, objectType, ParameterMode.In)); + classSymbol.AddMember(isInstanceOfTypeMethod); + + // IsAssignableFrom - Type.IsAssignableFrom gets mapped to this + + MethodSymbol isAssignableFromMethod = new MethodSymbol("IsAssignableFrom", classSymbol, boolType, MemberVisibility.Public | MemberVisibility.Static); + isAssignableFromMethod.SetAlias("ss.canAssign"); + isAssignableFromMethod.AddParameter(new ParameterSymbol("type", isAssignableFromMethod, typeType, ParameterMode.In)); + isAssignableFromMethod.AddParameter(new ParameterSymbol("otherType", isAssignableFromMethod, typeType, ParameterMode.In)); + classSymbol.AddMember(isAssignableFromMethod); + return; } @@ -565,26 +594,6 @@ private void ImportPseudoMembers(PseudoClassMembers memberSet, ClassSymbol class return; } - if (memberSet == PseudoClassMembers.Type) { - // Define the Type.GetInstanceType static method which provides the functionality of - // Object.GetType instance method. We don't extend Object.prototype in script to add - // GetType, since we want to keep Object's protoype clean of any extensions. - // - // We create this symbol here, so that later the ExpressionBuilder can transform - // calls to Object.GetType to this. - TypeSymbol objectType = (TypeSymbol)((ISymbolTable)_symbols.SystemNamespace).FindSymbol("Object", null, SymbolFilter.Types); - Debug.Assert(objectType != null); - - TypeSymbol typeType = (TypeSymbol)((ISymbolTable)_symbols.SystemNamespace).FindSymbol("Type", null, SymbolFilter.Types); - Debug.Assert(objectType != null); - - MethodSymbol getTypeMethod = new MethodSymbol("GetInstanceType", classSymbol, typeType, MemberVisibility.Public | MemberVisibility.Static); - getTypeMethod.AddParameter(new ParameterSymbol("instance", getTypeMethod, objectType, ParameterMode.In)); - classSymbol.AddMember(getTypeMethod); - - return; - } - if (memberSet == PseudoClassMembers.Dictionary) { TypeSymbol intType = (TypeSymbol)((ISymbolTable)_symbols.SystemNamespace).FindSymbol("Int32", null, SymbolFilter.Types); Debug.Assert(intType != null); @@ -823,17 +832,15 @@ private TypeSymbol ResolveType(TypeReference type) { private enum PseudoClassMembers { - Type = 0, - - Script = 1, + Script, - Dictionary = 2, + Dictionary, - Arguments = 3, + Arguments, - Object = 4, + Object, - String = 5 + String } } } diff --git a/src/Core/CoreLib/Type.cs b/src/Core/CoreLib/Type.cs index 683f2bd77..795ad27a4 100644 --- a/src/Core/CoreLib/Type.cs +++ b/src/Core/CoreLib/Type.cs @@ -16,12 +16,16 @@ namespace System { [Imported] public sealed class Type { + [ScriptName("$base")] + [IntrinsicProperty] public Type BaseType { get { return null; } } + [ScriptName("$name")] + [IntrinsicProperty] public string Name { get { return null; @@ -38,6 +42,7 @@ public Dictionary Prototype { } } + [ScriptAlias("ss.type")] public static Type GetType(string typeName) { return null; } diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js index 787784bb4..7c30f61ff 100644 --- a/src/Core/Scripts/Runtime.js +++ b/src/Core/Scripts/Runtime.js @@ -90,15 +90,12 @@ return extend(ss, { module: module, isClass: isClass, isInterface: isInterface, - getType: getType, - baseType: getBaseType, - interfaces: getInterfaces, + typeOf: typeOf, + type: type, canCast: canCast, safeCast: safeCast, canAssign: canAssign, - isOfType: isOfType, - typeName: getTypeName, - type: parseType, + instanceOf: instanceOf, culture: { neutral: neutralCulture, diff --git a/src/Core/Scripts/Runtime/TypeSystem.js b/src/Core/Scripts/Runtime/TypeSystem.js index 6d50ef796..1e0768ce3 100644 --- a/src/Core/Scripts/Runtime/TypeSystem.js +++ b/src/Core/Scripts/Runtime/TypeSystem.js @@ -53,7 +53,7 @@ function isInterface(fn) { return fn.$type == _interfaceMarker; } -function getType(instance) { +function typeOf(instance) { var ctor = null; // NOTE: We have to catch exceptions because the constructor @@ -69,12 +69,12 @@ function getType(instance) { return ctor; } -function getBaseType(type) { - return type.$base || Object; -} +function type(s) { + var nsIndex = s.indexOf('.'); + var ns = nsIndex > 0 ? _modules[s.substr(0, nsIndex)] : global; + var name = nsIndex > 0 ? s.substr(nsIndex + 1) : s; -function getInterfaces(type) { - return type.$interfaces || []; + return ns ? ns[name] : null; } function canAssign(type, otherType) { @@ -106,7 +106,7 @@ function canAssign(type, otherType) { return false; } -function isOfType(instance, type) { +function instanceOf(type, instance) { // Checks if the specified instance is of the specified type if (!isValue(instance)) { @@ -117,28 +117,16 @@ function isOfType(instance, type) { return true; } - var instanceType = getType(instance); + var instanceType = typeOf(instance); return canAssign(type, instanceType); } function canCast(instance, type) { - return isOfType(instance, type); + return instanceOf(type, instance); } function safeCast(instance, type) { - return isOfType(instance, type) ? instance : null; -} - -function getTypeName(type) { - return type.$name; -} - -function parseType(s) { - var nsIndex = s.indexOf('.'); - var ns = nsIndex > 0 ? _modules[s.substr(0, nsIndex)] : global; - var name = nsIndex > 0 ? s.substr(nsIndex + 1) : s; - - return ns ? ns[name] : null; + return instanceOf(type, instance) ? instance : null; } function module(name, implementation, exports) { diff --git a/tests/TestCases/Basic/Metadata/Baseline.txt b/tests/TestCases/Basic/Metadata/Baseline.txt index 830c7a03b..07b2efd51 100644 --- a/tests/TestCases/Basic/Metadata/Baseline.txt +++ b/tests/TestCases/Basic/Metadata/Baseline.txt @@ -1577,6 +1577,39 @@ Types: Visibility: Public, Static Generated Name: decodeURIComponent Abstract: False + Method: GetType + AssociatedType: Type + Visibility: Public, Static + Generated Name: ss.typeOf + Abstract: False + Parameters: + Parameter: instance + AssociatedType: Object + Mode: In + Method: IsInstanceOfType + AssociatedType: Boolean + Visibility: Public, Static + Generated Name: ss.instanceOf + Abstract: False + Parameters: + Parameter: type + AssociatedType: Type + Mode: In + Parameter: instance + AssociatedType: Object + Mode: In + Method: IsAssignableFrom + AssociatedType: Boolean + Visibility: Public, Static + Generated Name: ss.canAssign + Abstract: False + Parameters: + Parameter: type + AssociatedType: Type + Mode: In + Parameter: otherType + AssociatedType: Type + Mode: In Class: Single Application Type: False @@ -1924,18 +1957,14 @@ Types: Global Methods: False BaseClass: Object Members: - Property: BaseType + Field: BaseType AssociatedType: Type Visibility: Public - Generated Name: baseType - ReadOnly: True - Abstract: False - Property: Name + Generated Name: $base + Field: Name AssociatedType: String Visibility: Public - Generated Name: name - ReadOnly: True - Abstract: False + Generated Name: $name Field: Prototype AssociatedType: Dictionary Visibility: Public @@ -1943,7 +1972,7 @@ Types: Method: GetType AssociatedType: Type Visibility: Public, Static - Generated Name: getType + Generated Name: ss.type Abstract: False Method: IsAssignableFrom AssociatedType: Boolean @@ -1970,15 +1999,6 @@ Types: Visibility: Public, Static Generated Name: getTypeFromHandle Abstract: False - Method: GetInstanceType - AssociatedType: Type - Visibility: Public, Static - Generated Name: getInstanceType - Abstract: False - Parameters: - Parameter: instance - AssociatedType: Object - Mode: In Class: UInt16 Application Type: False diff --git a/tests/TestCases/Expression/Binary/Baseline.txt b/tests/TestCases/Expression/Binary/Baseline.txt index aac674cef..6b62681d7 100644 --- a/tests/TestCases/Expression/Binary/Baseline.txt +++ b/tests/TestCases/Expression/Binary/Baseline.txt @@ -68,8 +68,8 @@ define('test', ['ss'], function(ss) { var b = (f < 10); sum = arg1 + (arg2 + 1) * 10; sum = arg1 + (arg2 + ~arg1) * (arg1 - 10); - var b2 = Type.canCast(sum, Number); - var o = Type.safeCast(b, ss.IDisposable); + var b2 = ss.canCast(sum, Number); + var o = ss.safeCast(b, ss.IDisposable); this.set_foo(this.get_foo() + 10); this.set_foo(this.get_foo() - this.get_bar()); sum = sum << 1; diff --git a/tests/TestCases/Expression/Cast/Baseline.txt b/tests/TestCases/Expression/Cast/Baseline.txt index feb1259c9..6e6116f69 100644 --- a/tests/TestCases/Expression/Cast/Baseline.txt +++ b/tests/TestCases/Expression/Cast/Baseline.txt @@ -19,14 +19,14 @@ define('test', ['ss'], function(ss) { var d2 = a / b; var action = function() { }; - var secondAction = Type.safeCast(action, Function); - if (Type.canCast(action, Function)) { + var secondAction = ss.safeCast(action, Function); + if (ss.canCast(action, Function)) { } - var cb = Type.safeCast(action, Function); - if (Type.canCast(action, Function)) { + var cb = ss.safeCast(action, Function); + if (ss.canCast(action, Function)) { cb = action; } - var action2 = Type.safeCast(action, Function); + var action2 = ss.safeCast(action, Function); if (action2 != null) { } } diff --git a/tests/TestCases/Expression/GetType/Baseline.txt b/tests/TestCases/Expression/GetType/Baseline.txt index 5655a7676..f174f4f38 100644 --- a/tests/TestCases/Expression/GetType/Baseline.txt +++ b/tests/TestCases/Expression/GetType/Baseline.txt @@ -10,9 +10,17 @@ define('test', ['ss'], function(ss) { return 0; }, test: function(x) { - var t = Type.getInstanceType(x); - var t2 = Type.getInstanceType(x.toString()); - var t3 = Type.getInstanceType(this.get_foo()); + var t = ss.typeOf(x); + var t2 = ss.typeOf(x.toString()); + var t3 = ss.typeOf(this.get_foo()); + var t4 = ss.type('String'); + var t5 = ss.type('test.Foo'); + var b1 = ss.canAssign((Object), ExpressionTests$App); + var b2 = ss.canAssign((ss.IDisposable), ExpressionTests$App); + var b3 = ss.canAssign(t, ExpressionTests$App); + var b4 = ss.instanceOf((ExpressionTests$App), new ExpressionTests$App()); + var b5 = ss.instanceOf((ss.IDisposable), new ExpressionTests$App()); + var b6 = ss.instanceOf(t, new ExpressionTests$App()); } }; diff --git a/tests/TestCases/Expression/GetType/Code.cs b/tests/TestCases/Expression/GetType/Code.cs index 5ab6b1d7e..b69d7d823 100644 --- a/tests/TestCases/Expression/GetType/Code.cs +++ b/tests/TestCases/Expression/GetType/Code.cs @@ -13,6 +13,17 @@ public void Test(object x) { Type t = x.GetType(); Type t2 = x.ToString().GetType(); Type t3 = Foo.GetType(); + + Type t4 = Type.GetType("String"); + Type t5 = Type.GetType("test.Foo"); + + bool b1 = typeof(Object).IsAssignableFrom(typeof(App)); + bool b2 = typeof(IDisposable).IsAssignableFrom(typeof(App)); + bool b3 = t.IsAssignableFrom(typeof(App)); + + bool b4 = typeof(App).IsInstanceOfType(new App()); + bool b5 = typeof(IDisposable).IsInstanceOfType(new App()); + bool b6 = t.IsInstanceOfType(new App()); } } } diff --git a/tests/TestCases/Type/Globals/Baseline.txt b/tests/TestCases/Type/Globals/Baseline.txt index 3c2d67dbb..5d0927f9f 100644 --- a/tests/TestCases/Type/Globals/Baseline.txt +++ b/tests/TestCases/Type/Globals/Baseline.txt @@ -63,7 +63,7 @@ define('test', ['ss'], function(ss) { someMethod: function() { var xyz = null; var c2 = new MyClass2(); - xyz = Type.safeCast(c2, IXyzInterface); + xyz = ss.safeCast(c2, IXyzInterface); } }; diff --git a/tests/TestSite/TestOOP.htm b/tests/TestSite/TestOOP.htm index d3ab7a389..416fe7225 100644 --- a/tests/TestSite/TestOOP.htm +++ b/tests/TestSite/TestOOP.htm @@ -42,22 +42,22 @@

                                      QUnit.equal(ss.canAssign(Object, oop.Cat), true, 'Cat should be assignable to an Object'); }); - test('isOfType', function() { + test('instanceOf', function() { var c = new oop.Cat(); var g = new oop.Garfield(); - QUnit.equal(ss.isOfType(c, oop.Animal), true, 'Cat instance should be an Animal instance'); - QUnit.equal(ss.isOfType(c, oop.IMammal), true, 'Cat instance should be an IMammal instance'); - QUnit.equal(ss.isOfType(g, oop.IMammal), true, 'Garfield instance should be an IMammal instance'); - QUnit.equal(ss.isOfType(c, oop.Zoo), false, 'Cat instance should not be a Zoo instance'); - QUnit.equal(ss.isOfType(c, oop.IPet), false, 'Cat instance should not be an IPet instance'); - QUnit.equal(ss.isOfType(c, Object), true, 'Cat instance should not be an Object instance'); + QUnit.equal(ss.instanceOf(oop.Animal, c), true, 'Cat instance should be an Animal instance'); + QUnit.equal(ss.instanceOf(oop.IMammal, c), true, 'Cat instance should be an IMammal instance'); + QUnit.equal(ss.instanceOf(oop.IMammal, g), true, 'Garfield instance should be an IMammal instance'); + QUnit.equal(ss.instanceOf(oop.Zoo, c), false, 'Cat instance should not be a Zoo instance'); + QUnit.equal(ss.instanceOf(oop.IPet, c), false, 'Cat instance should not be an IPet instance'); + QUnit.equal(ss.instanceOf(Object, c), true, 'Cat instance should not be an Object instance'); }); test('baseType', function() { - QUnit.equal(ss.typeName(ss.baseType(oop.Cat)), 'Animal', 'Cat\'s base type should be Animal'); - QUnit.equal(ss.baseType(oop.Animal), Object, 'Animal\'s base type should be Object'); - QUnit.equal(ss.baseType(Object), Object, 'Object\'s base type should be Object'); + QUnit.equal(oop.Cat.$base.$name, 'Animal', 'Cat\'s base type should be Animal'); + QUnit.equal(oop.Animal.$base, Object, 'Animal\'s base type should be Object'); + QUnit.equal(Object.$base, undefined, 'Object\'s base type should not be set'); }); test('canCast and safeCast', function() { @@ -81,20 +81,20 @@

                                      QUnit.equal(g.speak(), 'meow\r\nTranslation: I am fat, lazy, and cynical, but still, a favorite cat...', 'Garfield meows and says something cute'); }); - test('getType', function() { + test('typeOf', function() { var g = new oop.Garfield(); - QUnit.equal(ss.getType(g), oop.Garfield, "Expected Garfield instance."); + QUnit.equal(ss.typeOf(g), oop.Garfield, "Expected Garfield instance."); var c = new oop.Comic(); - QUnit.equal(ss.getType(c), oop.Comic, "Expected Comic instance."); + QUnit.equal(ss.typeOf(c), oop.Comic, "Expected Comic instance."); }); - test('typeNames', function() { + test('type names', function() { var g = new oop.Garfield(); - QUnit.equal(ss.typeName(ss.getType(g)), 'Garfield', "Expected 'Garfield' for type name."); + QUnit.equal(ss.typeOf(g).$name, 'Garfield', "Expected 'Garfield' for type name."); var c = new oop.Comic(); - QUnit.equal(ss.typeName(ss.getType(c)), 'Comic', "Expected 'Comic' for type name."); + QUnit.equal(ss.typeOf(c).$name, 'Comic', "Expected 'Comic' for type name."); }); test('type parsing', function() { From 370a55da26c6d52b67f4849c256b6123cb0cf85b Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sat, 15 Sep 2012 14:36:57 -0700 Subject: [PATCH 022/251] Use function-binding based implementation to simplify delegates at runtime --- .../Compiler/Generator/ExpressionGenerator.cs | 7 ++- .../Compiler/Generator/MemberGenerator.cs | 4 +- src/Core/CoreLib/Delegate.cs | 16 +++---- src/Core/CoreLib/Export.cs | 2 +- src/Core/Scripts/Runtime.js | 39 +++++----------- src/Core/Scripts/Runtime/Delegate.js | 45 +++++++++---------- src/Core/Scripts/Runtime/Math.js | 6 --- src/Core/Scripts/Runtime/Misc.js | 35 +++++++++++++++ src/Core/Scripts/Scripts.csproj | 2 +- .../TestCases/Basic/DocComments/Baseline.txt | 4 +- tests/TestCases/Basic/Metadata/Baseline.txt | 20 ++++----- .../TestCases/Basic/Minimization/Baseline.txt | 16 +++---- tests/TestCases/Basic/Simple/Baseline.txt | 10 ++--- .../Expression/AnonymousMethods/Baseline.txt | 16 +++---- .../Expression/Delegates/Baseline.txt | 10 +++-- tests/TestCases/Expression/Delegates/Code.cs | 3 ++ .../TestCases/Expression/Events/Baseline.txt | 40 ++++++++--------- tests/TestCases/Member/Events/Baseline.txt | 12 ++--- tests/TestSite/TestDelegates.htm | 38 ++++++++-------- 19 files changed, 167 insertions(+), 158 deletions(-) delete mode 100644 src/Core/Scripts/Runtime/Math.js create mode 100644 src/Core/Scripts/Runtime/Misc.js diff --git a/src/Core/Compiler/Generator/ExpressionGenerator.cs b/src/Core/Compiler/Generator/ExpressionGenerator.cs index e547a613f..7f085ed52 100644 --- a/src/Core/Compiler/Generator/ExpressionGenerator.cs +++ b/src/Core/Compiler/Generator/ExpressionGenerator.cs @@ -248,10 +248,7 @@ private static void GenerateDelegateExpression(ScriptGenerator generator, Member if ((expression.Method.Visibility & MemberVisibility.Static) == 0) { createDelegate = true; - - writer.Write("ss.Delegate.create("); - ExpressionGenerator.GenerateExpression(generator, symbol, expression.ObjectReference); - writer.Write(", "); + writer.Write("ss.bind("); } AnonymousMethodSymbol anonymousMethod = expression.Method as AnonymousMethodSymbol; @@ -294,6 +291,8 @@ private static void GenerateDelegateExpression(ScriptGenerator generator, Member } if (createDelegate) { + writer.Write(", "); + ExpressionGenerator.GenerateExpression(generator, symbol, expression.ObjectReference); writer.Write(")"); } } diff --git a/src/Core/Compiler/Generator/MemberGenerator.cs b/src/Core/Compiler/Generator/MemberGenerator.cs index a6193fefe..245edfd70 100644 --- a/src/Core/Compiler/Generator/MemberGenerator.cs +++ b/src/Core/Compiler/Generator/MemberGenerator.cs @@ -66,7 +66,7 @@ private static void GenerateEvent(ScriptGenerator generator, string typeName, Ev if (eventSymbol.DefaultImplementation) { writer.Write(fieldReference); - writer.Write(" = ss.Delegate.combine("); + writer.Write(" = ss.bindAdd("); writer.Write(fieldReference); writer.Write(", "); writer.Write(valueParameter.GeneratedName); @@ -108,7 +108,7 @@ private static void GenerateEvent(ScriptGenerator generator, string typeName, Ev if (eventSymbol.DefaultImplementation) { writer.Write(fieldReference); - writer.Write(" = ss.Delegate.remove("); + writer.Write(" = ss.bindSub("); writer.Write(fieldReference); writer.Write(", "); writer.Write(valueParameter.GeneratedName); diff --git a/src/Core/CoreLib/Delegate.cs b/src/Core/CoreLib/Delegate.cs index 1b4897dca..1e3239eb2 100644 --- a/src/Core/CoreLib/Delegate.cs +++ b/src/Core/CoreLib/Delegate.cs @@ -10,43 +10,43 @@ namespace System { [Imported] public abstract class Delegate { - [PreserveCase] - public static readonly Delegate Empty = null; - protected Delegate(object target, string method) { } protected Delegate(Type target, string method) { } + [ScriptAlias("ss.bindAdd")] public static Delegate Combine(Delegate a, Delegate b) { return null; } - public static Delegate Create(object instance, Function f) { + [ScriptAlias("ss.bind")] + public static Delegate Create(Function f, object instance) { return null; } - [ScriptName("publish")] + [ScriptAlias("ss.bindExport")] public static Export Export(Delegate d) { return null; } - [ScriptName("publish")] + [ScriptAlias("ss.bindExport")] public static Export Export(Delegate d, bool multiUse) { return null; } - [ScriptName("publish")] + [ScriptAlias("ss.bindExport")] public static Export Export(Delegate d, bool multiUse, string name) { return null; } - [ScriptName("publish")] + [ScriptAlias("ss.bindExport")] public static Export Export(Delegate d, bool multiUse, string name, object root) { return null; } + [ScriptAlias("ss.bindSub")] public static Delegate Remove(Delegate source, Delegate value) { return null; } diff --git a/src/Core/CoreLib/Export.cs b/src/Core/CoreLib/Export.cs index 3ac5c6323..8075feea4 100644 --- a/src/Core/CoreLib/Export.cs +++ b/src/Core/CoreLib/Export.cs @@ -21,7 +21,7 @@ public string Name { } } - public void Clear() { + public void Detach() { } public void Dispose() { diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js index 7c30f61ff..8c9acc357 100644 --- a/src/Core/Scripts/Runtime.js +++ b/src/Core/Scripts/Runtime.js @@ -7,31 +7,8 @@ define('ss', [], function() { var global = this; -// TODO: Inline and remove -function isUndefined(o) { - return (o === undefined); -} - -// TODO: Inline and remove -function isNull(o) { - return (o === null); -} - -// TODO: Use !isValue -function isNullOrUndefined(o) { - return (o === null) || (o === undefined); -} - -function isValue(o) { - return (o !== null) && (o !== undefined); -} - -function extend(o, items) { - for (var n in items) { - o[n] = items[n]; - } - return o; -} +#include "Runtime\Misc.js" +#include "Runtime\Delegate.js" #include "Runtime\Object.js" #include "Runtime\Array.js" @@ -39,10 +16,8 @@ function extend(o, items) { #include "Runtime\Console.js" #include "Runtime\Error.js" #include "Runtime\Date.js" -#include "Runtime\Math.js" #include "Runtime\TypeSystem.js" -#include "Runtime\Delegate.js" #include "Runtime\EventArgs.js" #include "Runtime\Contracts.js" #include "Runtime\Enumerator.js" @@ -65,7 +40,6 @@ var ss = module('ss', null, { IEventManager: [ IEventManager ], IInitializable: [ IInitializable ], ArrayEnumerator: [ ArrayEnumerator, ArrayEnumerator$, null, IEnumerator ], - Delegate: [ Delegate, { } ], EventArgs: [ EventArgs, { } ], CancelEventArgs: [ CancelEventArgs, { }, EventArgs ], StringBuilder: [ StringBuilder, StringBuilder$ ], @@ -76,7 +50,6 @@ var ss = module('ss', null, { Deferred: [ Deferred, Deferred$ ] }); -Delegate.Empty = function() { }; EventArgs.Empty = new EventArgs(); return extend(ss, { @@ -87,7 +60,15 @@ return extend(ss, { isNullOrUndefined: isNullOrUndefined, isValue: isValue, + extend: extend, + + bind: bind, + bindAdd: bindAdd, + bindSub: bindSub, + bindExport: bindExport, + module: module, + isClass: isClass, isInterface: isInterface, typeOf: typeOf, diff --git a/src/Core/Scripts/Runtime/Delegate.js b/src/Core/Scripts/Runtime/Delegate.js index 38bf4ed0a..31eb41cca 100644 --- a/src/Core/Scripts/Runtime/Delegate.js +++ b/src/Core/Scripts/Runtime/Delegate.js @@ -1,6 +1,6 @@ -// Delegate +// Delegate Functionality -function _createDelegate(fnList) { +function _bindList(fnList) { var d = function() { var args = arguments; var result = null; @@ -13,10 +13,7 @@ function _createDelegate(fnList) { return d; } -function Delegate() { -} - -Delegate.create = function(o, fn) { +function bind(fn, o) { if (!o) { return fn; } @@ -28,27 +25,27 @@ Delegate.create = function(o, fn) { }; } -Delegate.combine = function(delegate, value) { - if (!delegate) { +function bindAdd(binding, value) { + if (!binding) { return value; } if (!value) { - return delegate; + return binding; } - var fnList = [].concat(delegate._fnList || delegate, value); - return _createDelegate(fnList); + var fnList = [].concat(binding._fnList || binding, value); + return _bindList(fnList); } -Delegate.remove = function(delegate, value) { - if (!delegate) { +function bindSub(binding, value) { + if (!binding) { return null; } if (!value) { - return delegate; + return binding; } - var fnList = delegate._fnList || [delegate]; + var fnList = binding._fnList || [binding]; var index = fnList.indexOf(value); if (index >= 0) { if (fnList.length == 1) { @@ -56,31 +53,32 @@ Delegate.remove = function(delegate, value) { } fnList = index ? fnList.slice(0, index).concat(fnList.slice(index + 1)) : fnList.slice(1); - return _createDelegate(fnList); + return _bindList(fnList); } - return delegate; + return binding; } -Delegate.publish = function(fn, multiUse, name, root) { + +function bindExport(fn, multiUse, name, root) { // Generate a unique name if one is not specified name = name || '__' + (new Date()).valueOf(); - // If unspecified, exported delegates go on the global object + // If unspecified, exported bindings go on the global object // (so they are callable using a simple identifier). root = root || global; var exp = { name: name, - clear: function() { - root[name] = Delegate.Empty; + detach: function() { + root[name] = _nop; }, dispose: function() { try { delete root[name]; } catch (e) { root[name] = undefined; } } }; - // Multi-use delegates are exported directly; for the rest a stub is exported, and the stub - // first deletes, and then invokes the actual delegate. + // Multi-use bindings are exported directly; for the rest a stub is exported, and the stub + // first auto-disposes, and then invokes the actual binding. root[name] = multiUse ? fn : function() { exp.dispose(); return fn.apply(null, arguments); @@ -88,3 +86,4 @@ Delegate.publish = function(fn, multiUse, name, root) { return exp; } + diff --git a/src/Core/Scripts/Runtime/Math.js b/src/Core/Scripts/Runtime/Math.js deleted file mode 100644 index 7cfe128a9..000000000 --- a/src/Core/Scripts/Runtime/Math.js +++ /dev/null @@ -1,6 +0,0 @@ -// Math - -Math.truncate = function(n) { - return (n >= 0) ? Math.floor(n) : Math.ceil(n); -} - diff --git a/src/Core/Scripts/Runtime/Misc.js b/src/Core/Scripts/Runtime/Misc.js new file mode 100644 index 000000000..4d2c0a1dc --- /dev/null +++ b/src/Core/Scripts/Runtime/Misc.js @@ -0,0 +1,35 @@ +// Various Helpers/Utilities + +// TODO: Inline and remove +function isUndefined(o) { + return (o === undefined); +} + +// TODO: Inline and remove +function isNull(o) { + return (o === null); +} + +// TODO: Use !isValue +function isNullOrUndefined(o) { + return (o === null) || (o === undefined); +} + +function isValue(o) { + return (o !== null) && (o !== undefined); +} + +function extend(o, items) { + for (var n in items) { + o[n] = items[n]; + } + return o; +} + +Math.truncate = function(n) { + return (n >= 0) ? Math.floor(n) : Math.ceil(n); +} + +function _nop() { +} + diff --git a/src/Core/Scripts/Scripts.csproj b/src/Core/Scripts/Scripts.csproj index d6ecad61a..d1efbaa9c 100644 --- a/src/Core/Scripts/Scripts.csproj +++ b/src/Core/Scripts/Scripts.csproj @@ -20,7 +20,7 @@ - + diff --git a/tests/TestCases/Basic/DocComments/Baseline.txt b/tests/TestCases/Basic/DocComments/Baseline.txt index ccd9f49ba..a1fdd343b 100644 --- a/tests/TestCases/Basic/DocComments/Baseline.txt +++ b/tests/TestCases/Basic/DocComments/Baseline.txt @@ -119,14 +119,14 @@ define('test', ['ss'], function(ss) { /// Adds or removes a delegate for the Initialized event. ///
                                      /// - this.__initialized = ss.Delegate.combine(this.__initialized, value); + this.__initialized = ss.bindAdd(this.__initialized, value); }, remove_initialized: function(value) { /// /// Adds or removes a delegate for the Initialized event. /// /// - this.__initialized = ss.Delegate.remove(this.__initialized, value); + this.__initialized = ss.bindSub(this.__initialized, value); }, method1: function() { /// diff --git a/tests/TestCases/Basic/Metadata/Baseline.txt b/tests/TestCases/Basic/Metadata/Baseline.txt index 07b2efd51..b78392266 100644 --- a/tests/TestCases/Basic/Metadata/Baseline.txt +++ b/tests/TestCases/Basic/Metadata/Baseline.txt @@ -789,29 +789,25 @@ Types: Global Methods: False BaseClass: Object Members: - Field: Empty - AssociatedType: Delegate - Visibility: Public, Static - Generated Name: Empty Method: Combine AssociatedType: Delegate Visibility: Public, Static - Generated Name: combine + Generated Name: ss.bindAdd Abstract: False Method: Create AssociatedType: Delegate Visibility: Public, Static - Generated Name: create + Generated Name: ss.bind Abstract: False Method: Export AssociatedType: Export Visibility: Public, Static - Generated Name: publish + Generated Name: ss.bindExport Abstract: False Method: Remove AssociatedType: Delegate Visibility: Public, Static - Generated Name: remove + Generated Name: ss.bindSub Abstract: False Class: Double @@ -925,10 +921,10 @@ Types: AssociatedType: String Visibility: Public Generated Name: name - Method: Clear + Method: Detach AssociatedType: Void Visibility: Public - Generated Name: clear + Generated Name: detach Abstract: False Method: Dispose AssociatedType: Void @@ -4032,10 +4028,10 @@ define('test', ['ss'], function(ss) { } var BasicTests$App$ = { add_event1: function(value) { - this.__event1 = ss.Delegate.combine(this.__event1, value); + this.__event1 = ss.bindAdd(this.__event1, value); }, remove_event1: function(value) { - this.__event1 = ss.Delegate.remove(this.__event1, value); + this.__event1 = ss.bindSub(this.__event1, value); }, add_event2: function(value) { }, diff --git a/tests/TestCases/Basic/Minimization/Baseline.txt b/tests/TestCases/Basic/Minimization/Baseline.txt index 77d5e08b7..6bffc8fa1 100644 --- a/tests/TestCases/Basic/Minimization/Baseline.txt +++ b/tests/TestCases/Basic/Minimization/Baseline.txt @@ -181,7 +181,7 @@ define('test', ['ss', 'lib'], function(ss, lib) { var numericValue = $p0 + 1; var stringValue = $p0.toString(); var value = 0; - this.$1(ss.Delegate.create(this, function($p1_0, $p1_1) { + this.$1(ss.bind(function($p1_0, $p1_1) { this.$1(function($p2_0, $p2_1) { var value = 11; return $p2_0; @@ -189,7 +189,7 @@ define('test', ['ss', 'lib'], function(ss, lib) { var value = 10; var value2 = 11; return numericValue + $p1_0 + stringValue + $p1_1 + value; - })); + }, this)); }, get_$5: function() { return 0; @@ -199,7 +199,7 @@ define('test', ['ss', 'lib'], function(ss, lib) { return $p0; }, get_$6: function() { - this.$1(ss.Delegate.create(this, function($p1_0, $p1_1) { + this.$1(ss.bind(function($p1_0, $p1_1) { this.$1(function($p2_0, $p2_1) { var value = 11; return $p2_0; @@ -207,13 +207,13 @@ define('test', ['ss', 'lib'], function(ss, lib) { var value = 10; var value2 = 11; return $p1_0 + $p1_1 + value; - })); + }, this)); return 0; }, set_$6: function($p0) { var numericValue = $p0 + 1; var stringValue = $p0.toString(); - this.$1(ss.Delegate.create(this, function($p1_0, $p1_1) { + this.$1(ss.bind(function($p1_0, $p1_1) { this.$1(function($p2_0, $p2_1) { var value1 = 11; return $p2_0; @@ -221,7 +221,7 @@ define('test', ['ss', 'lib'], function(ss, lib) { var value2 = 10; var value3 = 11; return numericValue + $p1_0 + stringValue + $p1_1 + $p0 + value3; - })); + }, this)); return $p0; } }; @@ -257,10 +257,10 @@ define('test', ['ss', 'lib'], function(ss, lib) { } var BasicTests$FooBehavior$ = { add_c$4: function(value) { - this.c$5 = ss.Delegate.combine(this.c$5, value); + this.c$5 = ss.bindAdd(this.c$5, value); }, remove_c$4: function(value) { - this.c$5 = ss.Delegate.remove(this.c$5, value); + this.c$5 = ss.bindSub(this.c$5, value); }, dispose: function() { this.c$0 = 0; diff --git a/tests/TestCases/Basic/Simple/Baseline.txt b/tests/TestCases/Basic/Simple/Baseline.txt index 5c043b344..ecc03065e 100644 --- a/tests/TestCases/Basic/Simple/Baseline.txt +++ b/tests/TestCases/Basic/Simple/Baseline.txt @@ -17,10 +17,10 @@ define('basic', ['ss'], function(ss) { } var Basic$Button$ = { add_click: function(value) { - this.__click = ss.Delegate.combine(this.__click, value); + this.__click = ss.bindAdd(this.__click, value); }, remove_click: function(value) { - this.__click = ss.Delegate.remove(this.__click, value); + this.__click = ss.bindSub(this.__click, value); }, get_text: function() { return this._text; @@ -37,10 +37,10 @@ define('basic', ['ss'], function(ss) { function Basic$App() { this._btn1 = new Basic$Button('OK'); - this._btn1.add_click(ss.Delegate.create(this, this.onClickButton)); - this._btn1.add_click(ss.Delegate.create(this, this.onClickButtonDup)); + this._btn1.add_click(ss.bind(this.onClickButton, this)); + this._btn1.add_click(ss.bind(this.onClickButtonDup, this)); this._btn2 = new Basic$Button('Cancel'); - this._btn2.add_click(ss.Delegate.create(this, this.onClickButton)); + this._btn2.add_click(ss.bind(this.onClickButton, this)); } Basic$App.main = function(args) { var theApp = new Basic$App(); diff --git a/tests/TestCases/Expression/AnonymousMethods/Baseline.txt b/tests/TestCases/Expression/AnonymousMethods/Baseline.txt index 4c50dbf00..cf5317004 100644 --- a/tests/TestCases/Expression/AnonymousMethods/Baseline.txt +++ b/tests/TestCases/Expression/AnonymousMethods/Baseline.txt @@ -27,9 +27,9 @@ define('test', ['ss'], function(ss) { var ExpressionTests$Test$ = { AAA: function() { var o = {}; - this.doStuff(o, ss.Delegate.create(this, function(i, s, b) { + this.doStuff(o, ss.bind(function(i, s, b) { this._n = i; - })); + }, this)); var s = new ExpressionTests$SomeClass(function() { }); for (var i = 0; i < 10; i++) { @@ -37,18 +37,18 @@ define('test', ['ss'], function(ss) { this.doStuff(o, function(i, s, b) { foo = i + s; }); - this.doStuff(o, ss.Delegate.create(this, function(i, s, b) { + this.doStuff(o, ss.bind(function(i, s, b) { this._n += i; - })); + }, this)); ExpressionTests$Test.doStuffStatic(o, function() { }); - ExpressionTests$Test.doStuffStatic(o, ss.Delegate.create(this, function() { + ExpressionTests$Test.doStuffStatic(o, ss.bind(function() { this._n++; - })); + }, this)); } - var s2 = new ExpressionTests$SomeClass(ss.Delegate.create(this, function() { + var s2 = new ExpressionTests$SomeClass(ss.bind(function() { var numbers = [ this._n ]; - })); + }, this)); }, doStuff: function(o, callback) { } diff --git a/tests/TestCases/Expression/Delegates/Baseline.txt b/tests/TestCases/Expression/Delegates/Baseline.txt index efbdadabc..fbc8b707f 100644 --- a/tests/TestCases/Expression/Delegates/Baseline.txt +++ b/tests/TestCases/Expression/Delegates/Baseline.txt @@ -22,12 +22,14 @@ define('test', ['ss'], function(ss) { // ExpressionTests.Test function ExpressionTests$Test() { - this._handler = ss.Delegate.create(this, this.onEvent); - this._handler = ss.Delegate.create(this, this.onEvent); - this._handler = ss.Delegate.create(this, this.onEvent); + this._handler = ss.bind(this.onEvent, this); + this._handler = ss.bind(this.onEvent, this); + this._handler = ss.bind(this.onEvent, this); this._handler = ExpressionTests$Test2.onGlobalEvent; - var s1 = new ExpressionTests$SomeClass(ss.Delegate.create(this, this.onEvent)); + var s1 = new ExpressionTests$SomeClass(ss.bind(this.onEvent, this)); var s2 = new ExpressionTests$SomeClass(this._handler); + var e = ss.bindExport(this._handler); + e.dispose(); } var ExpressionTests$Test$ = { doStuff: function() { diff --git a/tests/TestCases/Expression/Delegates/Code.cs b/tests/TestCases/Expression/Delegates/Code.cs index bf316d08b..4c1e70576 100644 --- a/tests/TestCases/Expression/Delegates/Code.cs +++ b/tests/TestCases/Expression/Delegates/Code.cs @@ -30,6 +30,9 @@ public Test() { SomeClass s1 = new SomeClass(OnEvent); SomeClass s2 = new SomeClass(_handler); + + Export e = Delegate.Export(_handler); + e.Dispose(); } public void DoStuff() { diff --git a/tests/TestCases/Expression/Events/Baseline.txt b/tests/TestCases/Expression/Events/Baseline.txt index 866559378..829650512 100644 --- a/tests/TestCases/Expression/Events/Baseline.txt +++ b/tests/TestCases/Expression/Events/Baseline.txt @@ -6,39 +6,39 @@ define('test', ['ss'], function(ss) { function ExpressionTests$Button() { } ExpressionTests$Button.add_test = function(value) { - ExpressionTests$Button.__test = ss.Delegate.combine(ExpressionTests$Button.__test, value); + ExpressionTests$Button.__test = ss.bindAdd(ExpressionTests$Button.__test, value); } ExpressionTests$Button.remove_test = function(value) { - ExpressionTests$Button.__test = ss.Delegate.remove(ExpressionTests$Button.__test, value); + ExpressionTests$Button.__test = ss.bindSub(ExpressionTests$Button.__test, value); } var ExpressionTests$Button$ = { add_click: function(value) { - this.__click = ss.Delegate.combine(this.__click, value); + this.__click = ss.bindAdd(this.__click, value); }, remove_click: function(value) { - this.__click = ss.Delegate.remove(this.__click, value); + this.__click = ss.bindSub(this.__click, value); }, add_aaa: function(value) { if (this._aaa == null) { this._aaa = value; } else { - this._aaa = ss.Delegate.combine(this._aaa, value); + this._aaa = ss.bindAdd(this._aaa, value); } }, remove_aaa: function(value) { - this._aaa = ss.Delegate.remove(this._aaa, value); + this._aaa = ss.bindSub(this._aaa, value); }, add_bbb: function(value) { if (this._bbb == null) { this._bbb = value; } else { - this._bbb = ss.Delegate.combine(this._bbb, value); + this._bbb = ss.bindAdd(this._bbb, value); } }, remove_bbb: function(value) { - this._bbb = ss.Delegate.remove(this._bbb, value); + this._bbb = ss.bindSub(this._bbb, value); } }; @@ -46,24 +46,24 @@ define('test', ['ss'], function(ss) { // ExpressionTests.App function ExpressionTests$App() { - this._btn.add_click(ss.Delegate.create(this, this.onClickButton)); - this._btn.add_click(ss.Delegate.create(this, this.onClickButton)); - this._btn.add_click(ss.Delegate.create(this, this.onClickButton)); - this._btn.remove_click(ss.Delegate.create(this, this.onClickButton)); - this._btn.remove_click(ss.Delegate.create(this, this.onClickButton)); - this._btn.remove_click(ss.Delegate.create(this, this.onClickButton)); + this._btn.add_click(ss.bind(this.onClickButton, this)); + this._btn.add_click(ss.bind(this.onClickButton, this)); + this._btn.add_click(ss.bind(this.onClickButton, this)); + this._btn.remove_click(ss.bind(this.onClickButton, this)); + this._btn.remove_click(ss.bind(this.onClickButton, this)); + this._btn.remove_click(ss.bind(this.onClickButton, this)); ExpressionTests$Button.add_test(ExpressionTests$App.onTestButton); ExpressionTests$Button.add_test(ExpressionTests$App.onTestButton); ExpressionTests$Button.add_test(ExpressionTests$App.onTestButton); ExpressionTests$Button.remove_test(ExpressionTests$App.onTestButton); ExpressionTests$Button.remove_test(ExpressionTests$App.onTestButton); ExpressionTests$Button.remove_test(ExpressionTests$App.onTestButton); - this._btn.add_aaa(ss.Delegate.create(this, this.onAAAButton)); - this._btn.add_aaa(ss.Delegate.create(this, this.onAAAButton)); - this._btn.add_aaa(ss.Delegate.create(this, this.onAAAButton)); - this._btn.remove_aaa(ss.Delegate.create(this, this.onAAAButton)); - this._btn.remove_aaa(ss.Delegate.create(this, this.onAAAButton)); - this._btn.remove_aaa(ss.Delegate.create(this, this.onAAAButton)); + this._btn.add_aaa(ss.bind(this.onAAAButton, this)); + this._btn.add_aaa(ss.bind(this.onAAAButton, this)); + this._btn.add_aaa(ss.bind(this.onAAAButton, this)); + this._btn.remove_aaa(ss.bind(this.onAAAButton, this)); + this._btn.remove_aaa(ss.bind(this.onAAAButton, this)); + this._btn.remove_aaa(ss.bind(this.onAAAButton, this)); } ExpressionTests$App.onTestButton = function(sender, e) { } diff --git a/tests/TestCases/Member/Events/Baseline.txt b/tests/TestCases/Member/Events/Baseline.txt index c4a23a963..f8e812567 100644 --- a/tests/TestCases/Member/Events/Baseline.txt +++ b/tests/TestCases/Member/Events/Baseline.txt @@ -15,28 +15,28 @@ define('test', ['ss'], function(ss) { function MemberTests$Button() { } MemberTests$Button.add_test = function(value) { - MemberTests$Button.__test = ss.Delegate.combine(MemberTests$Button.__test, value); + MemberTests$Button.__test = ss.bindAdd(MemberTests$Button.__test, value); } MemberTests$Button.remove_test = function(value) { - MemberTests$Button.__test = ss.Delegate.remove(MemberTests$Button.__test, value); + MemberTests$Button.__test = ss.bindSub(MemberTests$Button.__test, value); } var MemberTests$Button$ = { add_click: function(value) { - this.__click = ss.Delegate.combine(this.__click, value); + this.__click = ss.bindAdd(this.__click, value); }, remove_click: function(value) { - this.__click = ss.Delegate.remove(this.__click, value); + this.__click = ss.bindSub(this.__click, value); }, add_aaa: function(value) { if (this._aaa == null) { this._aaa = value; } else { - this._aaa = ss.Delegate.combine(this._aaa, value); + this._aaa = ss.bindAdd(this._aaa, value); } }, remove_aaa: function(value) { - this._aaa = ss.Delegate.remove(this._aaa, value); + this._aaa = ss.bindSub(this._aaa, value); }, performClick: function() { if (this.__click != null) { diff --git a/tests/TestSite/TestDelegates.htm b/tests/TestSite/TestDelegates.htm index cdf825ff6..aa7c1d289 100644 --- a/tests/TestSite/TestDelegates.htm +++ b/tests/TestSite/TestDelegates.htm @@ -36,8 +36,8 @@

                                      TargetClass.complexCallback1 = function(delegate) { log('ComplexCallback1 invoked'); - var delegate2 = ss.Delegate.create(null, TargetClass.complexCallback2); - ss.Delegate.remove(delegate, delegate2); + var delegate2 = ss.bind(TargetClass.complexCallback2, null); + ss.bindSub(delegate, delegate2); } TargetClass.complexCallback2 = function(delegate) { log('ComplexCallback2 invoked'); @@ -65,7 +65,7 @@

                                      var logs = setupLog(); var tc = new TargetClass(); - var delegate = ss.Delegate.create(tc, tc.instanceCallback1); + var delegate = ss.bind(tc.instanceCallback1, tc); delegate(); QUnit.equal(logs.length, 1); @@ -73,8 +73,8 @@

                                      test('testEmpty', function() { var tc = new TargetClass(); - var delegate = ss.Delegate.create(tc, tc.instanceCallback1); - delegate = ss.Delegate.remove(delegate, delegate); + var delegate = ss.bind(tc.instanceCallback1, tc); + delegate = ss.bindSub(delegate, delegate); QUnit.equal(delegate, null); }); @@ -83,8 +83,8 @@

                                      var logs = setupLog(); var tc = new TargetClass(); - var delegate = ss.Delegate.create(tc, tc.instanceCallback1); - delegate = ss.Delegate.combine(delegate, ss.Delegate.create(tc, tc.instanceCallback1)); + var delegate = ss.bind(tc.instanceCallback1, tc); + delegate = ss.bindAdd(delegate, ss.bind(tc.instanceCallback1, tc)); delegate(); QUnit.equal(logs.length, 2); @@ -94,7 +94,7 @@

                                      var logs = setupLog(); var tc = new TargetClass(); - var delegate = ss.Delegate.create(null, TargetClass.staticCallback2); + var delegate = ss.bind(TargetClass.staticCallback2); delegate('abc'); var delegate2 = staticGlobalCallback; @@ -107,9 +107,9 @@

                                      var logs = setupLog(); var tc = new TargetClass(); - var delegate = ss.Delegate.create(tc, tc.instanceCallback1); - delegate = ss.Delegate.combine(delegate, ss.Delegate.create(tc, tc.instanceCallback2)); - delegate = ss.Delegate.combine(delegate, ss.Delegate.create(null, TargetClass.staticCallback1)); + var delegate = ss.bind(tc.instanceCallback1, tc); + delegate = ss.bindAdd(delegate, ss.bind(tc.instanceCallback2, tc)); + delegate = ss.bindAdd(delegate, ss.bind(TargetClass.staticCallback1)); delegate(); QUnit.equal(logs.length, 3); @@ -118,11 +118,11 @@

                                      test('testWithRemoval', function() { var logs = setupLog(); - var delegate1 = ss.Delegate.create(null, TargetClass.complexCallback1); - var delegate2 = ss.Delegate.create(null, TargetClass.complexCallback2); - var delegate3 = ss.Delegate.create(null, TargetClass.complexCallback3); + var delegate1 = ss.bind(TargetClass.complexCallback1); + var delegate2 = ss.bind(TargetClass.complexCallback2); + var delegate3 = ss.bind(TargetClass.complexCallback3); - var delegate = ss.Delegate.combine(delegate1, ss.Delegate.combine(delegate2, delegate3)); + var delegate = ss.bindAdd(delegate1, ss.bindAdd(delegate2, delegate3)); delegate(delegate); // delegate1 removes delegate2 from the delegate it is passed in. @@ -136,21 +136,21 @@

                                      test('testPublish', function() { var logs = setupLog(); - var delegate = ss.Delegate.create(null, function() { log('delegate invoked') }); + var delegate = ss.bind(function() { log('delegate invoked') }, null); - var api = ss.Delegate.publish(delegate, /* multiUse */ true, 'xyz'); + var api = ss.bindExport(delegate, /* multiUse */ true, 'xyz'); QUnit.equal(api.name, 'xyz', 'Expected published delegate to be named "xyz"'); QUnit.equal(window[api.name] !== null, true, 'Expected window member'); window[api.name](); QUnit.equal(window[api.name] !== null, true, 'Expected window member since it was multiuse'); - api.clear(); + api.detach(); QUnit.equal(window[api.name] !== null, true, 'Expected window member'); api.dispose(); QUnit.equal(!window[api.name], true, 'Did not expect window member since it was deleted'); // Test single use delegate - api = ss.Delegate.publish(delegate); + api = ss.bindExport(delegate); QUnit.equal(window[api.name] !== null, true, 'Expected window member'); window[api.name](); QUnit.equal(!window[api.name], true, 'Did not expect window member since it was deleted'); From 277fa8fd8fcf61f8b063fac2b6595b3c0df5ccdb Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sat, 15 Sep 2012 14:48:27 -0700 Subject: [PATCH 023/251] Stop transforming parameter identifiers for minimization --- .../Compiler/Generator/ExpressionGenerator.cs | 9 ---- .../Compiler/Generator/MemberGenerator.cs | 23 -------- .../TestCases/Basic/Minimization/Baseline.txt | 52 +++++++++---------- .../Expression/EnumToString/MinBaseline.txt | 10 ++-- 4 files changed, 31 insertions(+), 63 deletions(-) diff --git a/src/Core/Compiler/Generator/ExpressionGenerator.cs b/src/Core/Compiler/Generator/ExpressionGenerator.cs index 7f085ed52..2cb52ba13 100644 --- a/src/Core/Compiler/Generator/ExpressionGenerator.cs +++ b/src/Core/Compiler/Generator/ExpressionGenerator.cs @@ -264,20 +264,11 @@ private static void GenerateDelegateExpression(ScriptGenerator generator, Member else { writer.Write("function("); if ((anonymousMethod.Parameters != null) && (anonymousMethod.Parameters.Count != 0)) { - bool obfuscateParams = generator.Options.Minimize; - string obfuscationPrefix = null; - int paramIndex = 0; foreach (ParameterSymbol parameterSymbol in anonymousMethod.Parameters) { if (paramIndex > 0) { writer.Write(", "); } - if (obfuscateParams) { - if (paramIndex == 0) { - obfuscationPrefix = "$p" + anonymousMethod.Depth.ToString(CultureInfo.InvariantCulture) + "_"; - } - parameterSymbol.SetTransformedName(obfuscationPrefix + paramIndex); - } writer.Write(parameterSymbol.GeneratedName); paramIndex++; diff --git a/src/Core/Compiler/Generator/MemberGenerator.cs b/src/Core/Compiler/Generator/MemberGenerator.cs index 245edfd70..0a2f17847 100644 --- a/src/Core/Compiler/Generator/MemberGenerator.cs +++ b/src/Core/Compiler/Generator/MemberGenerator.cs @@ -163,14 +163,6 @@ private static void GenerateIndexer(ScriptGenerator generator, string typeName, writer.Write("."); } - bool obfuscateParams = !indexerSymbol.IsPublic; - if (obfuscateParams && generator.Options.Minimize) { - for (int i = 0; i < indexerSymbol.Parameters.Count; i++) { - ParameterSymbol parameterSymbol = indexerSymbol.Parameters[i]; - parameterSymbol.SetTransformedName("$p" + i); - } - } - writer.Write("get_"); writer.Write(indexerSymbol.GeneratedName); if (instanceMember) { @@ -287,19 +279,11 @@ private static void GenerateMethod(ScriptGenerator generator, string typeName, M writer.Write("function("); if (methodSymbol.Parameters != null) { - bool obfuscateParams = false; - if (generator.Options.Minimize) { - obfuscateParams = !methodSymbol.IsPublic; - } - int paramIndex = 0; foreach (ParameterSymbol parameterSymbol in methodSymbol.Parameters) { if (paramIndex > 0) { writer.Write(", "); } - if (obfuscateParams) { - parameterSymbol.SetTransformedName("$p" + paramIndex); - } writer.Write(parameterSymbol.GeneratedName); paramIndex++; @@ -360,13 +344,6 @@ private static void GenerateProperty(ScriptGenerator generator, string typeName, if (propertySymbol.IsReadOnly == false) { ParameterSymbol valueParameter = propertySymbol.Parameters[0]; - if (generator.Options.Minimize) { - bool obfuscateParams = !propertySymbol.IsPublic; - if (obfuscateParams) { - valueParameter.SetTransformedName("$p0"); - } - } - if (instanceMember) { writer.WriteLine(","); } diff --git a/tests/TestCases/Basic/Minimization/Baseline.txt b/tests/TestCases/Basic/Minimization/Baseline.txt index 6bffc8fa1..9cd605adb 100644 --- a/tests/TestCases/Basic/Minimization/Baseline.txt +++ b/tests/TestCases/Basic/Minimization/Baseline.txt @@ -123,7 +123,7 @@ define('test', ['ss', 'lib'], function(ss, lib) { toString: function() { return null; }, - $1: function($p0) { + $1: function(handler) { } }; @@ -174,55 +174,55 @@ define('test', ['ss', 'lib'], function(ss, lib) { var d = BasicTests$MyData('a', 'b'); d.$0 = d.$1; }, - $3: function($p0) { - $p0 = $p0 + 2; + $3: function(blah) { + blah = blah + 2; }, - $4: function($p0) { - var numericValue = $p0 + 1; - var stringValue = $p0.toString(); + $4: function(currentValue) { + var numericValue = currentValue + 1; + var stringValue = currentValue.toString(); var value = 0; - this.$1(ss.bind(function($p1_0, $p1_1) { - this.$1(function($p2_0, $p2_1) { + this.$1(ss.bind(function(indexValue, textValue) { + this.$1(function(indexValue, textValue) { var value = 11; - return $p2_0; + return indexValue; }); var value = 10; var value2 = 11; - return numericValue + $p1_0 + stringValue + $p1_1 + value; + return numericValue + indexValue + stringValue + textValue + value; }, this)); }, get_$5: function() { return 0; }, - set_$5: function($p0) { - var x = $p0; - return $p0; + set_$5: function(value) { + var x = value; + return value; }, get_$6: function() { - this.$1(ss.bind(function($p1_0, $p1_1) { - this.$1(function($p2_0, $p2_1) { + this.$1(ss.bind(function(indexValue, textValue) { + this.$1(function(indexValue, textValue) { var value = 11; - return $p2_0; + return indexValue; }); var value = 10; var value2 = 11; - return $p1_0 + $p1_1 + value; + return indexValue + textValue + value; }, this)); return 0; }, - set_$6: function($p0) { - var numericValue = $p0 + 1; - var stringValue = $p0.toString(); - this.$1(ss.bind(function($p1_0, $p1_1) { - this.$1(function($p2_0, $p2_1) { + set_$6: function(value) { + var numericValue = value + 1; + var stringValue = value.toString(); + this.$1(ss.bind(function(indexValue, textValue) { + this.$1(function(indexValue, textValue) { var value1 = 11; - return $p2_0; + return indexValue; }); var value2 = 10; var value3 = 11; - return numericValue + $p1_0 + stringValue + $p1_1 + $p0 + value3; + return numericValue + indexValue + stringValue + textValue + value + value3; }, this)); - return $p0; + return value; } }; @@ -271,7 +271,7 @@ define('test', ['ss', 'lib'], function(ss, lib) { get_c$7: function() { return null; }, - get_item: function($p0) { + get_item: function(name) { return 0; } }; diff --git a/tests/TestCases/Expression/EnumToString/MinBaseline.txt b/tests/TestCases/Expression/EnumToString/MinBaseline.txt index 5d1ec9410..b21b0168b 100644 --- a/tests/TestCases/Expression/EnumToString/MinBaseline.txt +++ b/tests/TestCases/Expression/EnumToString/MinBaseline.txt @@ -12,11 +12,11 @@ define('test', ['ss'], function(ss) { var s3 = '$0'; var s4 = (0).toString(); }, - $0: function($p0, $p1, $p2, $p3) { - var mstr = $p0.toString(); - var cstr = $p1.toString(); - var sstr = $p2; - var tstr = $p3.toString(); + $0: function(m, c, s, t) { + var mstr = m.toString(); + var cstr = c.toString(); + var sstr = s; + var tstr = t.toString(); } }; From c39e021a18f1c7e96c91a8ce94bee687ae0accc6 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sat, 15 Sep 2012 22:03:04 -0700 Subject: [PATCH 024/251] Capture this in local scope for simpler anonymous method generation --- .../Compiler/ImplementationBuilder.cs | 9 +++- src/Core/Compiler/Generator/CodeGenerator.cs | 31 +++++++++++- .../Compiler/Generator/ExpressionGenerator.cs | 33 ++++++++----- .../Compiler/Generator/ScriptGenerator.cs | 20 ++++++++ .../Symbols/SymbolImplementation.cs | 22 ++++++--- .../TestCases/Basic/Minimization/Baseline.txt | 24 ++++++---- .../Expression/AnonymousMethods/Baseline.txt | 48 ++++++++++++++----- .../Expression/AnonymousMethods/Code.cs | 23 +++++++++ 8 files changed, 166 insertions(+), 44 deletions(-) diff --git a/src/Core/Compiler/Compiler/ImplementationBuilder.cs b/src/Core/Compiler/Compiler/ImplementationBuilder.cs index ab6eb5f62..6324e65ba 100644 --- a/src/Core/Compiler/Compiler/ImplementationBuilder.cs +++ b/src/Core/Compiler/Compiler/ImplementationBuilder.cs @@ -81,7 +81,12 @@ private SymbolImplementation BuildImplementation(ISymbolTable symbolTable, CodeM } } - return new SymbolImplementation(statements, _rootScope); + string thisIdentifier = "this"; + if (symbolContext.Type == SymbolType.AnonymousMethod) { + thisIdentifier = "$this"; + } + + return new SymbolImplementation(statements, _rootScope, thisIdentifier); } public SymbolImplementation BuildEventAdd(EventSymbol eventSymbol) { @@ -162,7 +167,7 @@ public SymbolImplementation BuildField(FieldSymbol fieldSymbol) { List statements = new List(); statements.Add(new ExpressionStatement(initializerExpression, /* isFragment */ true)); - return new SymbolImplementation(statements, null); + return new SymbolImplementation(statements, null, "this"); } return null; diff --git a/src/Core/Compiler/Generator/CodeGenerator.cs b/src/Core/Compiler/Generator/CodeGenerator.cs index f237dc2f4..b12792592 100644 --- a/src/Core/Compiler/Generator/CodeGenerator.cs +++ b/src/Core/Compiler/Generator/CodeGenerator.cs @@ -15,8 +15,35 @@ namespace ScriptSharp.Generator { internal static class CodeGenerator { private static void GenerateImplementationScript(ScriptGenerator generator, MemberSymbol symbol, SymbolImplementation implementation) { - foreach (Statement statement in implementation.Statements) { - StatementGenerator.GenerateStatement(generator, symbol, statement); + generator.StartImplementation(implementation); + try { + bool generateThisCacheStatement = false; + + if ((symbol.Visibility & MemberVisibility.Static) == 0) { + CodeMemberSymbol codeMemberSymbol = symbol as CodeMemberSymbol; + if ((codeMemberSymbol != null) && (codeMemberSymbol.AnonymousMethods != null)) { + foreach (AnonymousMethodSymbol anonymousMethod in codeMemberSymbol.AnonymousMethods) { + if ((anonymousMethod.Visibility & MemberVisibility.Static) == 0) { + generateThisCacheStatement = true; + break; + } + } + } + } + + if (generateThisCacheStatement) { + ScriptTextWriter writer = generator.Writer; + + writer.WriteLine("var $this = this;"); + writer.WriteLine(); + } + + foreach (Statement statement in implementation.Statements) { + StatementGenerator.GenerateStatement(generator, symbol, statement); + } + } + finally { + generator.EndImplementation(); } } diff --git a/src/Core/Compiler/Generator/ExpressionGenerator.cs b/src/Core/Compiler/Generator/ExpressionGenerator.cs index 2cb52ba13..9ecbb8e09 100644 --- a/src/Core/Compiler/Generator/ExpressionGenerator.cs +++ b/src/Core/Compiler/Generator/ExpressionGenerator.cs @@ -57,7 +57,9 @@ private static void GenerateBinaryExpression(ScriptGenerator generator, MemberSy } writer.Write("set_"); writer.Write(propExpression.Property.GeneratedName); - writer.Write(".call(this, "); + writer.Write(".call("); + writer.Write(generator.CurrentImplementation.ThisIdentifier); + writer.Write(", "); GenerateExpression(generator, symbol, expression.RightOperand); writer.Write(")"); } @@ -93,7 +95,9 @@ private static void GenerateBinaryExpression(ScriptGenerator generator, MemberSy } writer.Write("set_"); writer.Write(indexExpression.Indexer.GeneratedName); - writer.Write(".call(this, "); + writer.Write(".call("); + writer.Write(generator.CurrentImplementation.ThisIdentifier); + writer.Write(", "); GenerateExpressionList(generator, symbol, indexExpression.Indices); writer.Write(", "); GenerateExpression(generator, symbol, expression.RightOperand); @@ -244,15 +248,15 @@ private static void GenerateConditionalExpression(ScriptGenerator generator, Mem private static void GenerateDelegateExpression(ScriptGenerator generator, MemberSymbol symbol, DelegateExpression expression) { ScriptTextWriter writer = generator.Writer; + AnonymousMethodSymbol anonymousMethod = expression.Method as AnonymousMethodSymbol; bool createDelegate = false; - if ((expression.Method.Visibility & MemberVisibility.Static) == 0) { - createDelegate = true; - writer.Write("ss.bind("); - } - - AnonymousMethodSymbol anonymousMethod = expression.Method as AnonymousMethodSymbol; if (anonymousMethod == null) { + if ((expression.Method.Visibility & MemberVisibility.Static) == 0) { + createDelegate = true; + writer.Write("ss.bind("); + } + // TODO: This probably needs to handle global method roots... if (expression.Method.IsGlobalMethod == false) { @@ -484,7 +488,9 @@ private static void GenerateIndexerExpression(ScriptGenerator generator, MemberS } writer.Write("get_"); writer.Write(expression.Indexer.GeneratedName); - writer.Write(".call(this, "); + writer.Write(".call("); + writer.Write(generator.CurrentImplementation.ThisIdentifier); + writer.Write(", "); GenerateExpressionList(generator, symbol, expression.Indices); writer.Write(")"); } @@ -721,7 +727,8 @@ private static void GenerateMethodExpression(ScriptGenerator generator, MemberSy writer.Write(".prototype."); } writer.Write(expression.Method.GeneratedName); - writer.Write(".call(this"); + writer.Write(".call("); + writer.Write(generator.CurrentImplementation.ThisIdentifier); if ((expression.Parameters != null) && (expression.Parameters.Count != 0)) { writer.Write(", "); GenerateExpressionList(generator, symbol, expression.Parameters); @@ -834,7 +841,9 @@ private static void GeneratePropertyExpression(ScriptGenerator generator, Member } writer.Write("get_"); writer.Write(expression.Property.GeneratedName); - writer.Write(".call(this)"); + writer.Write(".call("); + writer.Write(generator.CurrentImplementation.ThisIdentifier); + writer.Write(")"); } else { ExpressionGenerator.GenerateExpression(generator, symbol, expression.ObjectReference); @@ -846,7 +855,7 @@ private static void GeneratePropertyExpression(ScriptGenerator generator, Member private static void GenerateThisExpression(ScriptGenerator generator, MemberSymbol symbol, ThisExpression expression) { ScriptTextWriter writer = generator.Writer; - writer.Write("this"); + writer.Write(generator.CurrentImplementation.ThisIdentifier); } private static void GenerateTypeExpression(ScriptGenerator generator, MemberSymbol symbol, TypeExpression expression) { diff --git a/src/Core/Compiler/Generator/ScriptGenerator.cs b/src/Core/Compiler/Generator/ScriptGenerator.cs index a6aa1d33e..4b5d37b58 100644 --- a/src/Core/Compiler/Generator/ScriptGenerator.cs +++ b/src/Core/Compiler/Generator/ScriptGenerator.cs @@ -20,12 +20,22 @@ internal sealed class ScriptGenerator { private CompilerOptions _options; private SymbolSet _symbols; + private Stack _implementationStack; + public ScriptGenerator(TextWriter writer, CompilerOptions options, SymbolSet symbols) { Debug.Assert(writer != null); _writer = new ScriptTextWriter(writer); _options = options; _symbols = symbols; + + _implementationStack = new Stack(); + } + + public SymbolImplementation CurrentImplementation { + get { + return _implementationStack.Peek(); + } } public CompilerOptions Options { @@ -40,6 +50,11 @@ public ScriptTextWriter Writer { } } + public void EndImplementation() { + Debug.Assert(_implementationStack.Count != 0); + _implementationStack.Pop(); + } + public void GenerateScript(SymbolSet symbolSet) { Debug.Assert(symbolSet != null); @@ -202,6 +217,11 @@ public void GenerateScript(SymbolSet symbolSet) { _writer.WriteLine("});"); } + public void StartImplementation(SymbolImplementation implementation) { + Debug.Assert(implementation != null); + _implementationStack.Push(implementation); + } + private sealed class TypeComparer : IComparer { diff --git a/src/Core/Compiler/ScriptModel/Symbols/SymbolImplementation.cs b/src/Core/Compiler/ScriptModel/Symbols/SymbolImplementation.cs index 848a23cce..7bd9553f0 100644 --- a/src/Core/Compiler/ScriptModel/Symbols/SymbolImplementation.cs +++ b/src/Core/Compiler/ScriptModel/Symbols/SymbolImplementation.cs @@ -15,10 +15,12 @@ internal sealed class SymbolImplementation { private SymbolScope _scope; private ICollection _statements; + private string _thisIdentifier; - public SymbolImplementation(ICollection statements, SymbolScope scope) { + public SymbolImplementation(ICollection statements, SymbolScope scope, string thisIdentifier) { _scope = scope; _statements = statements; + _thisIdentifier = thisIdentifier; } public bool DeclaresVariables { @@ -32,12 +34,6 @@ public bool DeclaresVariables { } } - public SymbolScope Scope { - get { - return _scope; - } - } - public bool RequiresThisContext { get { foreach (Statement statement in _statements) { @@ -49,10 +45,22 @@ public bool RequiresThisContext { } } + public SymbolScope Scope { + get { + return _scope; + } + } + public ICollection Statements { get { return _statements; } } + + public string ThisIdentifier { + get { + return _thisIdentifier; + } + } } } diff --git a/tests/TestCases/Basic/Minimization/Baseline.txt b/tests/TestCases/Basic/Minimization/Baseline.txt index 9cd605adb..8a501400d 100644 --- a/tests/TestCases/Basic/Minimization/Baseline.txt +++ b/tests/TestCases/Basic/Minimization/Baseline.txt @@ -178,18 +178,20 @@ define('test', ['ss', 'lib'], function(ss, lib) { blah = blah + 2; }, $4: function(currentValue) { + var $this = this; + var numericValue = currentValue + 1; var stringValue = currentValue.toString(); var value = 0; - this.$1(ss.bind(function(indexValue, textValue) { - this.$1(function(indexValue, textValue) { + this.$1(function(indexValue, textValue) { + $this.$1(function(indexValue, textValue) { var value = 11; return indexValue; }); var value = 10; var value2 = 11; return numericValue + indexValue + stringValue + textValue + value; - }, this)); + }); }, get_$5: function() { return 0; @@ -199,29 +201,33 @@ define('test', ['ss', 'lib'], function(ss, lib) { return value; }, get_$6: function() { - this.$1(ss.bind(function(indexValue, textValue) { - this.$1(function(indexValue, textValue) { + var $this = this; + + this.$1(function(indexValue, textValue) { + $this.$1(function(indexValue, textValue) { var value = 11; return indexValue; }); var value = 10; var value2 = 11; return indexValue + textValue + value; - }, this)); + }); return 0; }, set_$6: function(value) { + var $this = this; + var numericValue = value + 1; var stringValue = value.toString(); - this.$1(ss.bind(function(indexValue, textValue) { - this.$1(function(indexValue, textValue) { + this.$1(function(indexValue, textValue) { + $this.$1(function(indexValue, textValue) { var value1 = 11; return indexValue; }); var value2 = 10; var value3 = 11; return numericValue + indexValue + stringValue + textValue + value + value3; - }, this)); + }); return value; } }; diff --git a/tests/TestCases/Expression/AnonymousMethods/Baseline.txt b/tests/TestCases/Expression/AnonymousMethods/Baseline.txt index cf5317004..2fbeb8691 100644 --- a/tests/TestCases/Expression/AnonymousMethods/Baseline.txt +++ b/tests/TestCases/Expression/AnonymousMethods/Baseline.txt @@ -23,13 +23,18 @@ define('test', ['ss'], function(ss) { }); } ExpressionTests$Test.doStuffStatic = function(o, callback) { + var s = new ExpressionTests$SomeClass(function() { + var temp = o; + }); } var ExpressionTests$Test$ = { AAA: function() { + var $this = this; + var o = {}; - this.doStuff(o, ss.bind(function(i, s, b) { - this._n = i; - }, this)); + this.doStuff(o, function(i, s, b) { + $this._n = i; + }); var s = new ExpressionTests$SomeClass(function() { }); for (var i = 0; i < 10; i++) { @@ -37,18 +42,37 @@ define('test', ['ss'], function(ss) { this.doStuff(o, function(i, s, b) { foo = i + s; }); - this.doStuff(o, ss.bind(function(i, s, b) { - this._n += i; - }, this)); + this.doStuff(o, function(i, s, b) { + $this._n += i; + }); ExpressionTests$Test.doStuffStatic(o, function() { }); - ExpressionTests$Test.doStuffStatic(o, ss.bind(function() { - this._n++; - }, this)); + ExpressionTests$Test.doStuffStatic(o, function() { + $this._n++; + }); } - var s2 = new ExpressionTests$SomeClass(ss.bind(function() { - var numbers = [ this._n ]; - }, this)); + var s2 = new ExpressionTests$SomeClass(function() { + var numbers = [ $this._n ]; + }); + var s3 = new ExpressionTests$SomeClass(function() { + var s4 = new ExpressionTests$SomeClass(function() { + var numbers = [ $this._n * 2 ]; + }); + }); + }, + BBB: function(o) { + var s = new ExpressionTests$SomeClass(function() { + var temp = o; + }); + }, + CCC: function(o) { + var $this = this; + + var s = new ExpressionTests$SomeClass(function() { + var s = new ExpressionTests$SomeClass(function() { + var numbers = [ $this._n * 2 ]; + }); + }); }, doStuff: function(o, callback) { } diff --git a/tests/TestCases/Expression/AnonymousMethods/Code.cs b/tests/TestCases/Expression/AnonymousMethods/Code.cs index ec0855c8b..b8b16befa 100644 --- a/tests/TestCases/Expression/AnonymousMethods/Code.cs +++ b/tests/TestCases/Expression/AnonymousMethods/Code.cs @@ -52,9 +52,32 @@ public void AAA() { SomeClass s2 = new SomeClass(delegate { int[] numbers = new int[] { _n }; }); + + SomeClass s3 = new SomeClass(delegate { + SomeClass s4 = new SomeClass(delegate { + int[] numbers = new int[] { _n * 2 }; + }); + }); + } + + public void BBB(object o) { + SomeClass s = new SomeClass(delegate { + object temp = o; + }); + } + + public void CCC(object o) { + SomeClass s = new SomeClass(delegate { + SomeClass s = new SomeClass(delegate { + int[] numbers = new int[] { _n * 2 }; + }); + }); } public static void DoStuffStatic(object o, Foo callback) { + SomeClass s = new SomeClass(delegate { + object temp = o; + }); } public void DoStuff(object o, Foo callback) { From 6fe6b5870b64c203b7fdc830843099d729537e32 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sat, 15 Sep 2012 22:30:37 -0700 Subject: [PATCH 025/251] Avoid minimizing members of enums marked as named values --- .../Compiler/ScriptModel/Symbols/SymbolObfuscator.cs | 9 +++++++++ tests/TestCases/Expression/EnumToString/MinBaseline.txt | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Core/Compiler/ScriptModel/Symbols/SymbolObfuscator.cs b/src/Core/Compiler/ScriptModel/Symbols/SymbolObfuscator.cs index 8abaa720e..0818cd421 100644 --- a/src/Core/Compiler/ScriptModel/Symbols/SymbolObfuscator.cs +++ b/src/Core/Compiler/ScriptModel/Symbols/SymbolObfuscator.cs @@ -98,6 +98,15 @@ string ISymbolTransformer.TransformSymbol(Symbol symbol, out bool transformChild if (symbol is TypeSymbol) { transformChildren = (symbol.Type != SymbolType.Interface) && (symbol.Type != SymbolType.Delegate); + + if ((symbol.Type == SymbolType.Enumeration) && + ((EnumerationSymbol)symbol).UseNamedValues) { + // If the enum uses named values, then don't transform, as its + // unlikely the code wants to use some random generated name as the + // named value. + transformChildren = false; + } + return null; } else if (symbol is MemberSymbol) { diff --git a/tests/TestCases/Expression/EnumToString/MinBaseline.txt b/tests/TestCases/Expression/EnumToString/MinBaseline.txt index b21b0168b..8f339efb3 100644 --- a/tests/TestCases/Expression/EnumToString/MinBaseline.txt +++ b/tests/TestCases/Expression/EnumToString/MinBaseline.txt @@ -9,7 +9,7 @@ define('test', ['ss'], function(ss) { test: function(arg) { var s1 = (0).toString(); var s2 = (2).toString(); - var s3 = '$0'; + var s3 = 'starting'; var s4 = (0).toString(); }, $0: function(m, c, s, t) { From ab279f88b72c8b165c98e0f40e652a19e9c9375e Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sat, 15 Sep 2012 22:31:17 -0700 Subject: [PATCH 026/251] Don't generate methods for internal records w/o explicit ctor. --- .../Compiler/Generator/ExpressionGenerator.cs | 6 +++ .../Compiler/Generator/ScriptGenerator.cs | 49 ++++++++++--------- src/Core/Compiler/Generator/TypeGenerator.cs | 15 ++++-- .../TestCases/Basic/Minimization/Baseline.txt | 49 ++++++++++--------- tests/TestCases/Basic/Minimization/Code.cs | 10 ++++ 5 files changed, 79 insertions(+), 50 deletions(-) diff --git a/src/Core/Compiler/Generator/ExpressionGenerator.cs b/src/Core/Compiler/Generator/ExpressionGenerator.cs index 9ecbb8e09..94ce779bd 100644 --- a/src/Core/Compiler/Generator/ExpressionGenerator.cs +++ b/src/Core/Compiler/Generator/ExpressionGenerator.cs @@ -797,6 +797,12 @@ private static void GenerateNewExpression(ScriptGenerator generator, MemberSymbo return; } else if (expression.AssociatedType.Type == SymbolType.Record) { + if (expression.AssociatedType.IsApplicationType && + ((RecordSymbol)expression.AssociatedType).Constructor == null) { + writer.Write("{ }"); + return; + } + writer.Write(expression.AssociatedType.FullGeneratedName); writer.Write("("); if (expression.Parameters != null) { diff --git a/src/Core/Compiler/Generator/ScriptGenerator.cs b/src/Core/Compiler/Generator/ScriptGenerator.cs index 4b5d37b58..eeb179937 100644 --- a/src/Core/Compiler/Generator/ScriptGenerator.cs +++ b/src/Core/Compiler/Generator/ScriptGenerator.cs @@ -96,7 +96,10 @@ public void GenerateScript(SymbolSet symbolSet) { // Sort the types, so similar types of types are grouped, and parent classes // come before derived classes. - types.Sort(new TypeComparer()); + IComparer typeComparer = new TypeComparer(); + types.Sort(typeComparer); + publicTypes.Sort(typeComparer); + internalTypes.Sort(typeComparer); string moduleName = symbolSet.ScriptName; @@ -142,19 +145,21 @@ public void GenerateScript(SymbolSet symbolSet) { _writer.WriteLine("{"); _writer.Indent++; bool firstType = true; - foreach (TypeSymbol type in types) { - if (type.IsPublic == false) { - if ((type.Type == SymbolType.Class) && - ((ClassSymbol)type).HasGlobalMethods) { - continue; - } + foreach (TypeSymbol type in internalTypes) { + if ((type.Type == SymbolType.Class) && + ((ClassSymbol)type).HasGlobalMethods) { + continue; + } + if ((type.Type == SymbolType.Record) && + ((RecordSymbol)type).Constructor == null) { + continue; + } - if (firstType == false) { - _writer.WriteLine(","); - } - TypeGenerator.GenerateRegistrationScript(this, type); - firstType = false; + if (firstType == false) { + _writer.WriteLine(","); } + TypeGenerator.GenerateRegistrationScript(this, type); + firstType = false; } _writer.Indent--; _writer.WriteLine(); @@ -170,19 +175,17 @@ public void GenerateScript(SymbolSet symbolSet) { _writer.WriteLine("{"); _writer.Indent++; bool firstType = true; - foreach (TypeSymbol type in types) { - if (type.IsPublic) { - if ((type.Type == SymbolType.Class) && - ((ClassSymbol)type).HasGlobalMethods) { - continue; - } + foreach (TypeSymbol type in publicTypes) { + if ((type.Type == SymbolType.Class) && + ((ClassSymbol)type).HasGlobalMethods) { + continue; + } - if (firstType == false) { - _writer.WriteLine(","); - } - TypeGenerator.GenerateRegistrationScript(this, type); - firstType = false; + if (firstType == false) { + _writer.WriteLine(","); } + TypeGenerator.GenerateRegistrationScript(this, type); + firstType = false; } _writer.Indent--; _writer.WriteLine(); diff --git a/src/Core/Compiler/Generator/TypeGenerator.cs b/src/Core/Compiler/Generator/TypeGenerator.cs index b18454777..201818cb6 100644 --- a/src/Core/Compiler/Generator/TypeGenerator.cs +++ b/src/Core/Compiler/Generator/TypeGenerator.cs @@ -328,6 +328,18 @@ public static void GenerateScript(ScriptGenerator generator, TypeSymbol typeSymb Debug.Assert(typeSymbol != null); Debug.Assert(typeSymbol.IsApplicationType); + if (typeSymbol.Type == SymbolType.Delegate) { + // No-op ... there is currently nothing to generate for a particular delegate type + return; + } + + if ((typeSymbol.Type == SymbolType.Record) && + (typeSymbol.IsPublic == false) && + (((RecordSymbol)typeSymbol).Constructor == null)) { + // Nothing to generate for internal records with no explicit ctor + return; + } + ScriptTextWriter writer = generator.Writer; writer.WriteLine("// " + typeSymbol.FullName); @@ -348,9 +360,6 @@ public static void GenerateScript(ScriptGenerator generator, TypeSymbol typeSymb case SymbolType.Enumeration: GenerateEnumeration(generator, (EnumerationSymbol)typeSymbol); break; - case SymbolType.Delegate: - // No-op ... there is currently nothing to generate for a particular delegate type - break; case SymbolType.Record: GenerateRecord(generator, (RecordSymbol)typeSymbol); break; diff --git a/tests/TestCases/Basic/Minimization/Baseline.txt b/tests/TestCases/Basic/Minimization/Baseline.txt index 8a501400d..247783278 100644 --- a/tests/TestCases/Basic/Minimization/Baseline.txt +++ b/tests/TestCases/Basic/Minimization/Baseline.txt @@ -19,8 +19,8 @@ Minimization Map Member 'Initialize' renamed to '$0' Member 'Numeric' renamed to '$1' Member 'OnClicked' renamed to 'e$1' - Member 'OnValueChanged' renamed to 'e$0' Member 'OnValueChanged' renamed to 'c$6' + Member 'OnValueChanged' renamed to 'e$0' Member 'Property1' renamed to 'c$7' Member 'Setup' renamed to '$2' Member 'ShowHelp' renamed to '$0' @@ -81,12 +81,28 @@ define('test', ['ss', 'lib'], function(ss, lib) { // BasicTests.ABC function BasicTests$ABC() { + var d = { }; } var BasicTests$ABC$ = { }; + // BasicTests.Bar + + function BasicTests$Bar() { + } + var BasicTests$Bar$ = { + $0: function() { + }, + toString: function() { + return null; + }, + $1: function(handler) { + } + }; + + // BasicTests.AppHelper function BasicTests$AppHelper() { @@ -113,17 +129,13 @@ define('test', ['ss', 'lib'], function(ss, lib) { }; - // BasicTests.Bar + // BasicTests.BaseClass - function BasicTests$Bar() { + function BasicTests$BaseClass() { + BasicTests$BaseBaseClass.call(this); } - var BasicTests$Bar$ = { - $0: function() { - }, - toString: function() { - return null; - }, - $1: function(handler) { + var BasicTests$BaseClass$ = { + $1: function() { } }; @@ -138,17 +150,6 @@ define('test', ['ss', 'lib'], function(ss, lib) { }; - // BasicTests.BaseClass - - function BasicTests$BaseClass() { - BasicTests$BaseBaseClass.call(this); - } - var BasicTests$BaseClass$ = { - $1: function() { - } - }; - - // BasicTests.BarCustom function BasicTests$BarCustom() { @@ -311,13 +312,13 @@ define('test', ['ss', 'lib'], function(ss, lib) { { IApp: [ BasicTests$IApp ], MyData: BasicTests$MyData, - BaseBaseClass: [ BasicTests$BaseBaseClass, BasicTests$BaseBaseClass$, null ], - ABC: [ BasicTests$ABC, BasicTests$ABC$, null ], AppHelper: [ BasicTests$AppHelper, BasicTests$AppHelper$, null ], Bar: [ BasicTests$Bar, BasicTests$Bar$, null ], + BaseBaseClass: [ BasicTests$BaseBaseClass, BasicTests$BaseBaseClass$, null ], + ABC: [ BasicTests$ABC, BasicTests$ABC$, null ], Bar2: [ BasicTests$Bar2, BasicTests$Bar2$, BasicTests$Bar ], - BaseClass: [ BasicTests$BaseClass, BasicTests$BaseClass$, BasicTests$BaseBaseClass ], BarCustom: [ BasicTests$BarCustom, BasicTests$BarCustom$, BasicTests$Bar ], + BaseClass: [ BasicTests$BaseClass, BasicTests$BaseClass$, BasicTests$BaseBaseClass ], BarEx: [ BasicTests$BarEx, BasicTests$BarEx$, BasicTests$Bar2 ], BarCustom2: [ BasicTests$BarCustom2, BasicTests$BarCustom2$, BasicTests$BarCustom ], DerivedClass: [ BasicTests$DerivedClass, BasicTests$DerivedClass$, BasicTests$BaseClass ], diff --git a/tests/TestCases/Basic/Minimization/Code.cs b/tests/TestCases/Basic/Minimization/Code.cs index 670b0c518..bd778253b 100644 --- a/tests/TestCases/Basic/Minimization/Code.cs +++ b/tests/TestCases/Basic/Minimization/Code.cs @@ -220,6 +220,16 @@ public MyData(string a, string b) { } } + internal sealed class DataHolder : Record { + + public string s1; + public string s2; + } + internal class ABC { + + public ABC() { + DataHolder d = new DataHolder(); + } } } From fce02107e13061625e780b3f060406e0712ae612 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sat, 15 Sep 2012 22:53:00 -0700 Subject: [PATCH 027/251] Simplify generation of Tuples. Remove special runtime type. --- .../Compiler/Generator/ExpressionGenerator.cs | 21 ++++++ src/Core/CoreLib/Tuple.cs | 64 +++++++++++++++++-- src/Core/Scripts/Runtime.js | 2 - src/Core/Scripts/Runtime/Tuple.js | 10 --- src/Core/Scripts/Scripts.csproj | 1 - tests/ScriptSharp/ExpressionTests.cs | 7 ++ tests/TestCases/Basic/Metadata/Baseline.txt | 44 ++++++++++--- .../TestCases/Expression/Tuples/Baseline.txt | 25 ++++++++ tests/TestCases/Expression/Tuples/Code.cs | 18 ++++++ 9 files changed, 162 insertions(+), 30 deletions(-) delete mode 100644 src/Core/Scripts/Runtime/Tuple.js create mode 100644 tests/TestCases/Expression/Tuples/Baseline.txt create mode 100644 tests/TestCases/Expression/Tuples/Code.cs diff --git a/src/Core/Compiler/Generator/ExpressionGenerator.cs b/src/Core/Compiler/Generator/ExpressionGenerator.cs index 94ce779bd..29e19994c 100644 --- a/src/Core/Compiler/Generator/ExpressionGenerator.cs +++ b/src/Core/Compiler/Generator/ExpressionGenerator.cs @@ -796,6 +796,27 @@ private static void GenerateNewExpression(ScriptGenerator generator, MemberSymbo } return; } + else if (type.Equals("Tuple")) { + if ((expression.Parameters == null) || (expression.Parameters.Count == 0)) { + writer.Write("{ }"); + } + else { + writer.Write("{ "); + for (int i = 0; i < expression.Parameters.Count; i++) { + if (i != 0) { + writer.Write(", "); + } + + writer.Write("item"); + writer.Write(i + 1); + writer.Write(": "); + GenerateExpression(generator, symbol, expression.Parameters[i]); + } + writer.Write(" }"); + } + + return; + } else if (expression.AssociatedType.Type == SymbolType.Record) { if (expression.AssociatedType.IsApplicationType && ((RecordSymbol)expression.AssociatedType).Constructor == null) { diff --git a/src/Core/CoreLib/Tuple.cs b/src/Core/CoreLib/Tuple.cs index 79f7852d1..7698749f0 100644 --- a/src/Core/CoreLib/Tuple.cs +++ b/src/Core/CoreLib/Tuple.cs @@ -9,17 +9,18 @@ namespace System { [Imported] + [IgnoreNamespace] [ScriptName("Tuple")] public sealed class Tuple { public Tuple() { } - public Tuple(T1 first, T2 second) { + public Tuple(T1 item1, T2 item2) { } [IntrinsicProperty] - public T1 First { + public T1 Item1 { get { return default(T1); } @@ -28,7 +29,7 @@ public T1 First { } [IntrinsicProperty] - public T2 Second { + public T2 Item2 { get { return default(T2); } @@ -38,17 +39,18 @@ public T2 Second { } [Imported] + [IgnoreNamespace] [ScriptName("Tuple")] public sealed class Tuple { public Tuple() { } - public Tuple(T1 first, T2 second, T3 third) { + public Tuple(T1 item1, T2 item2, T3 item3) { } [IntrinsicProperty] - public T1 First { + public T1 Item1 { get { return default(T1); } @@ -57,7 +59,7 @@ public T1 First { } [IntrinsicProperty] - public T2 Second { + public T2 Item2 { get { return default(T2); } @@ -66,7 +68,7 @@ public T2 Second { } [IntrinsicProperty] - public T3 Third { + public T3 Item3 { get { return default(T3); } @@ -74,4 +76,52 @@ public T3 Third { } } } + + [Imported] + [IgnoreNamespace] + [ScriptName("Tuple")] + public sealed class Tuple { + + public Tuple() { + } + + public Tuple(T1 item1, T2 item2, T3 item3, T4 item4) { + } + + [IntrinsicProperty] + public T1 Item1 { + get { + return default(T1); + } + set { + } + } + + [IntrinsicProperty] + public T2 Item2 { + get { + return default(T2); + } + set { + } + } + + [IntrinsicProperty] + public T3 Item3 { + get { + return default(T3); + } + set { + } + } + + [IntrinsicProperty] + public T4 Item4 { + get { + return default(T4); + } + set { + } + } + } } diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js index 8c9acc357..8809bc6c0 100644 --- a/src/Core/Scripts/Runtime.js +++ b/src/Core/Scripts/Runtime.js @@ -23,7 +23,6 @@ var global = this; #include "Runtime\Enumerator.js" #include "Runtime\StringBuilder.js" #include "Runtime\Observable.js" -#include "Runtime\Tuple.js" #include "Runtime\Task.js" #include "Runtime\Culture.js" #include "Runtime\Parse.js" @@ -45,7 +44,6 @@ var ss = module('ss', null, { StringBuilder: [ StringBuilder, StringBuilder$ ], Observable: [ Observable, Observable$ ], ObservableCollection: [ ObservableCollection, ObservableCollection$, null, IEnumerable ], - Tuple: [ Tuple, { } ], Task: [ Task, Task$ ], Deferred: [ Deferred, Deferred$ ] }); diff --git a/src/Core/Scripts/Runtime/Tuple.js b/src/Core/Scripts/Runtime/Tuple.js deleted file mode 100644 index b2b61d4cb..000000000 --- a/src/Core/Scripts/Runtime/Tuple.js +++ /dev/null @@ -1,10 +0,0 @@ -// Tuple - -function Tuple(first, second, third) { - this.first = first; - this.second = second; - if (arguments.length == 3) { - this.third = third; - } -} - diff --git a/src/Core/Scripts/Scripts.csproj b/src/Core/Scripts/Scripts.csproj index d1efbaa9c..a767a0656 100644 --- a/src/Core/Scripts/Scripts.csproj +++ b/src/Core/Scripts/Scripts.csproj @@ -36,7 +36,6 @@ - diff --git a/tests/ScriptSharp/ExpressionTests.cs b/tests/ScriptSharp/ExpressionTests.cs index 77e3eaa89..37a24a620 100644 --- a/tests/ScriptSharp/ExpressionTests.cs +++ b/tests/ScriptSharp/ExpressionTests.cs @@ -181,6 +181,13 @@ public void TestTruthy() { }); } + [TestMethod] + public void TestTuples() { + RunTest((c) => { + c.AddSource("Code.cs"); + }); + } + [TestMethod] public void TestUnary() { RunTest((c) => { diff --git a/tests/TestCases/Basic/Metadata/Baseline.txt b/tests/TestCases/Basic/Metadata/Baseline.txt index b78392266..47920fa99 100644 --- a/tests/TestCases/Basic/Metadata/Baseline.txt +++ b/tests/TestCases/Basic/Metadata/Baseline.txt @@ -1917,14 +1917,14 @@ Types: Global Methods: False BaseClass: Object Members: - Field: First + Field: Item1 AssociatedType: T1 Visibility: Public - Generated Name: first - Field: Second + Generated Name: item1 + Field: Item2 AssociatedType: T2 Visibility: Public - Generated Name: second + Generated Name: item2 Class: Tuple`3 Application Type: False @@ -1933,18 +1933,42 @@ Types: Global Methods: False BaseClass: Object Members: - Field: First + Field: Item1 AssociatedType: T1 Visibility: Public - Generated Name: first - Field: Second + Generated Name: item1 + Field: Item2 AssociatedType: T2 Visibility: Public - Generated Name: second - Field: Third + Generated Name: item2 + Field: Item3 AssociatedType: T3 Visibility: Public - Generated Name: third + Generated Name: item3 + + Class: Tuple`4 + Application Type: False + Public: True + Generated Name: Tuple + Global Methods: False + BaseClass: Object + Members: + Field: Item1 + AssociatedType: T1 + Visibility: Public + Generated Name: item1 + Field: Item2 + AssociatedType: T2 + Visibility: Public + Generated Name: item2 + Field: Item3 + AssociatedType: T3 + Visibility: Public + Generated Name: item3 + Field: Item4 + AssociatedType: T4 + Visibility: Public + Generated Name: item4 Class: Type Application Type: False diff --git a/tests/TestCases/Expression/Tuples/Baseline.txt b/tests/TestCases/Expression/Tuples/Baseline.txt new file mode 100644 index 000000000..1921186c7 --- /dev/null +++ b/tests/TestCases/Expression/Tuples/Baseline.txt @@ -0,0 +1,25 @@ +define('test', ['ss'], function(ss) { + 'use strict'; + + // ExpressionTests.App + + function ExpressionTests$App() { + } + var ExpressionTests$App$ = { + test: function(arg) { + var t1 = { }; + var t2 = { item1: 1, item2: 2 }; + var t3 = { }; + var t4 = { item1: 1, item2: 22, item3: '333' }; + } + }; + + + var $test = ss.module('test', null, + { + App: [ ExpressionTests$App, ExpressionTests$App$, null ] + }); + + + return $test; +}); diff --git a/tests/TestCases/Expression/Tuples/Code.cs b/tests/TestCases/Expression/Tuples/Code.cs new file mode 100644 index 000000000..85725fad4 --- /dev/null +++ b/tests/TestCases/Expression/Tuples/Code.cs @@ -0,0 +1,18 @@ +using System; +using System.Runtime.CompilerServices; + +[assembly: ScriptAssembly("test")] + +namespace ExpressionTests { + + public class App { + + public void Test(int arg) { + Tuple t1 = new Tuple(); + Tuple t2 = new Tuple(1, 2); + + Tuple t3 = new Tuple(); + Tuple t4 = new Tuple(1, 22, "333"); + } + } +} From fd5bc06d13575b4ced6078719bc66dbc126cc214 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 16 Sep 2012 00:46:15 -0700 Subject: [PATCH 028/251] Script class metadata update using ScriptAlias attr --- .../Compiler/Importer/MetadataImporter.cs | 10 ++++---- src/Core/CoreLib/Script.cs | 24 ++++++++++--------- tests/TestCases/Basic/Metadata/Baseline.txt | 7 +----- .../TestCases/Expression/Script/Baseline.txt | 12 ++++++++++ tests/TestCases/Expression/Script/Code.cs | 17 +++++++++++++ 5 files changed, 49 insertions(+), 21 deletions(-) diff --git a/src/Core/Compiler/Importer/MetadataImporter.cs b/src/Core/Compiler/Importer/MetadataImporter.cs index 86146d8e9..db17d1969 100644 --- a/src/Core/Compiler/Importer/MetadataImporter.cs +++ b/src/Core/Compiler/Importer/MetadataImporter.cs @@ -533,25 +533,27 @@ private void ImportPseudoMembers(PseudoClassMembers memberSet, ClassSymbol class // Define the Escape, Unescape, encodeURI, decodeURI, encodeURIComponent, decodeURIComponent methods MethodSymbol escapeMethod = new MethodSymbol("Escape", classSymbol, stringType, MemberVisibility.Public | MemberVisibility.Static); + escapeMethod.SetAlias("escape"); classSymbol.AddMember(escapeMethod); MethodSymbol unescapeMethod = new MethodSymbol("Unescape", classSymbol, stringType, MemberVisibility.Public | MemberVisibility.Static); + unescapeMethod.SetAlias("unescape"); classSymbol.AddMember(unescapeMethod); MethodSymbol encodeURIMethod = new MethodSymbol("EncodeUri", classSymbol, stringType, MemberVisibility.Public | MemberVisibility.Static); - encodeURIMethod.SetTransformedName("encodeURI"); + encodeURIMethod.SetAlias("encodeURI"); classSymbol.AddMember(encodeURIMethod); MethodSymbol decodeURIMethod = new MethodSymbol("DecodeUri", classSymbol, stringType, MemberVisibility.Public | MemberVisibility.Static); - decodeURIMethod.SetTransformedName("decodeURI"); + decodeURIMethod.SetAlias("decodeURI"); classSymbol.AddMember(decodeURIMethod); MethodSymbol encodeURIComponentMethod = new MethodSymbol("EncodeUriComponent", classSymbol, stringType, MemberVisibility.Public | MemberVisibility.Static); - encodeURIComponentMethod.SetTransformedName("encodeURIComponent"); + encodeURIComponentMethod.SetAlias("encodeURIComponent"); classSymbol.AddMember(encodeURIComponentMethod); MethodSymbol decodeURIComponentMethod = new MethodSymbol("DecodeUriComponent", classSymbol, stringType, MemberVisibility.Public | MemberVisibility.Static); - decodeURIComponentMethod.SetTransformedName("decodeURIComponent"); + decodeURIComponentMethod.SetAlias("decodeURIComponent"); classSymbol.AddMember(decodeURIComponentMethod); // GetType diff --git a/src/Core/CoreLib/Script.cs b/src/Core/CoreLib/Script.cs index 09e63423e..71f41b47e 100644 --- a/src/Core/CoreLib/Script.cs +++ b/src/Core/CoreLib/Script.cs @@ -11,7 +11,6 @@ namespace System { /// The Script class contains various methods that represent global /// methods present in the underlying script engine. ///
                                      - [GlobalMethods] [IgnoreNamespace] [Imported] public static class Script { @@ -25,22 +24,14 @@ public static bool Boolean(object o) { return false; } + [ScriptAlias("clearInterval")] public static void ClearInterval(int intervalID) { } + [ScriptAlias("clearTimeout")] public static void ClearTimeout(int timeoutID) { } - /// - /// Prompts the user with a yes/no question. - /// - /// The text of the question. - /// true if the user chooses yes; false otherwise. - [Obsolete("Use Window.Confirm instead.", true)] - public static bool Confirm(string message) { - return false; - } - public static object CreateInstance(Type type, params object[] arguments) { return null; } @@ -58,6 +49,7 @@ public static void DeleteField(Type type, string name) { ///
                                      /// The script to be evaluated. /// The result of the evaluation. + [ScriptAlias("eval")] public static object Eval(string s) { return null; } @@ -177,42 +169,52 @@ public static void SetField(object instance, string name, object value) { public static void SetField(Type type, string name, object value) { } + [ScriptAlias("setInterval")] public static int SetInterval(string code, int milliseconds) { return 0; } + [ScriptAlias("setInterval")] public static int SetInterval(Action callback, int milliseconds) { return 0; } + [ScriptAlias("setInterval")] public static int SetInterval(Action callback, int milliseconds, T arg) { return 0; } + [ScriptAlias("setInterval")] public static int SetInterval(Action callback, int milliseconds, T1 arg1, T2 arg2) { return 0; } + [ScriptAlias("setInterval")] public static int SetInterval(Delegate d, int milliseconds, params object[] args) { return 0; } + [ScriptAlias("setTimeout")] public static int SetTimeout(string code, int milliseconds) { return 0; } + [ScriptAlias("setTimeout")] public static int SetTimeout(Action callback, int milliseconds) { return 0; } + [ScriptAlias("setTimeout")] public static int SetTimeout(Action callback, int milliseconds, T arg) { return 0; } + [ScriptAlias("setTimeout")] public static int SetTimeout(Action callback, int milliseconds, T1 arg1, T2 arg2) { return 0; } + [ScriptAlias("setTimeout")] public static int SetTimeout(Delegate d, int milliseconds, params object[] args) { return 0; } diff --git a/tests/TestCases/Basic/Metadata/Baseline.txt b/tests/TestCases/Basic/Metadata/Baseline.txt index 47920fa99..801d5341a 100644 --- a/tests/TestCases/Basic/Metadata/Baseline.txt +++ b/tests/TestCases/Basic/Metadata/Baseline.txt @@ -1435,7 +1435,7 @@ Types: Application Type: False Public: True Generated Name: Script - Global Methods: True + Global Methods: False BaseClass: Object Members: Method: Boolean @@ -1453,11 +1453,6 @@ Types: Visibility: Public, Static Generated Name: clearTimeout Abstract: False - Method: Confirm - AssociatedType: Boolean - Visibility: Public, Static - Generated Name: confirm - Abstract: False Method: CreateInstance AssociatedType: Object Visibility: Public, Static diff --git a/tests/TestCases/Expression/Script/Baseline.txt b/tests/TestCases/Expression/Script/Baseline.txt index 07b784599..244444edc 100644 --- a/tests/TestCases/Expression/Script/Baseline.txt +++ b/tests/TestCases/Expression/Script/Baseline.txt @@ -11,6 +11,18 @@ define('test', ['ss'], function(ss) { arg = (arg || 10 || 100); var s = (arg || 10).toString(10); var b = !!arg; + var sb = new ss.StringBuilder(); + sb = new ss.StringBuilder('aaa'); + var i; + var tick = function() { + i = 10; + }; + var cookie = setInterval(tick, 500); + clearInterval(cookie); + var isSet = !ss.isNullOrUndefined(i); + var addition = eval('2 + 2'); + addition = 2 + 2; + addition = 2 + 3; } }; diff --git a/tests/TestCases/Expression/Script/Code.cs b/tests/TestCases/Expression/Script/Code.cs index df208a69c..4217bb025 100644 --- a/tests/TestCases/Expression/Script/Code.cs +++ b/tests/TestCases/Expression/Script/Code.cs @@ -12,6 +12,23 @@ public void Test(int arg) { arg = Script.Value(arg, 10, 100); string s = Script.Value(arg, 10).ToString(10); bool b = Script.Boolean(arg); + + StringBuilder sb = (StringBuilder)Script.CreateInstance(typeof(StringBuilder)); + sb = (StringBuilder)Script.CreateInstance(typeof(StringBuilder), "aaa"); + + int i; + Action tick = delegate() { + i = 10; + }; + int cookie = Script.SetInterval(tick, 500); + Script.ClearInterval(cookie); + + bool isSet = Script.IsNullOrUndefined(i) == false; + + int addition = (int)Script.Eval("2 + 2"); + + addition = (int)Script.Literal("2 + 2"); + addition = (int)Script.Literal("{0} + {1}", 2, 3); } } } From e031b17e0060257c6fd1e6dfdc78fe86f823df16 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 16 Sep 2012 10:33:33 -0700 Subject: [PATCH 029/251] Remove GlobalMethods and replace Mixin with ScriptExtension --- src/Core/Compiler/Compiler/MetadataBuilder.cs | 25 +-- .../Compiler/Generator/ExpressionGenerator.cs | 12 +- .../Compiler/Generator/MemberGenerator.cs | 12 +- .../Compiler/Generator/ScriptGenerator.cs | 4 +- src/Core/Compiler/Generator/TypeGenerator.cs | 8 +- src/Core/Compiler/Importer/MetadataHelpers.cs | 20 ++- .../Compiler/Importer/MetadataImporter.cs | 6 +- .../ScriptModel/Symbols/ClassSymbol.cs | 43 +++--- .../ScriptModel/Symbols/MethodSymbol.cs | 20 +-- .../ScriptModel/Symbols/SymbolSetDumper.cs | 4 +- .../Validator/CustomTypeNodeValidator.cs | 24 ++- src/Core/CoreLib/Script.cs | 8 + src/Core/CoreLib/ScriptMetadata.cs | 16 +- tests/ScriptSharp/ValidationTests.cs | 25 +++ .../TestCases/Basic/DocComments/Baseline.txt | 2 +- tests/TestCases/Basic/DocComments/Code.cs | 4 +- tests/TestCases/Basic/Metadata/Baseline.txt | 144 +++++++++--------- tests/TestCases/Basic/Metadata/Code.cs | 2 +- .../TestCases/Basic/Minimization/Baseline.txt | 2 +- tests/TestCases/Basic/Minimization/Code.cs | 2 +- .../Expression/GlobalMethods/Baseline.txt | 4 +- .../Expression/GlobalMethods/Code.cs | 2 +- .../TestCases/Expression/Script/Baseline.txt | 1 + tests/TestCases/Expression/Script/Code.cs | 2 + tests/TestCases/Member/Methods/Baseline.txt | 17 +-- tests/TestCases/Member/Methods/Code.cs | 26 +--- .../Validation/ScriptExtension/Code.cs | 19 +++ 27 files changed, 230 insertions(+), 224 deletions(-) create mode 100644 tests/TestCases/Validation/ScriptExtension/Code.cs diff --git a/src/Core/Compiler/Compiler/MetadataBuilder.cs b/src/Core/Compiler/Compiler/MetadataBuilder.cs index ee3d1271d..21c1d0212 100644 --- a/src/Core/Compiler/Compiler/MetadataBuilder.cs +++ b/src/Core/Compiler/Compiler/MetadataBuilder.cs @@ -726,26 +726,15 @@ private void BuildType(TypeSymbol typeSymbol, UserTypeNode typeNode) { } if (typeNode.Type == TokenType.Class) { - bool globalizeMembers = false; - string mixinRoot = null; + AttributeNode extensionAttribute = AttributeNode.FindAttribute(attributes, "ScriptExtension"); + if (extensionAttribute != null) { + Debug.Assert(extensionAttribute.Arguments[0] is LiteralNode); + Debug.Assert(((LiteralNode)extensionAttribute.Arguments[0]).Value is string); - AttributeNode globalMethodsAttribute = AttributeNode.FindAttribute(attributes, "GlobalMethods"); - if (globalMethodsAttribute != null) { - globalizeMembers = true; - } - else { - AttributeNode mixinAttribute = AttributeNode.FindAttribute(attributes, "Mixin"); - if (mixinAttribute != null) { - Debug.Assert(mixinAttribute.Arguments[0] is LiteralNode); - Debug.Assert(((LiteralNode)mixinAttribute.Arguments[0]).Value is string); - - mixinRoot = (string)((LiteralNode)mixinAttribute.Arguments[0]).Value; - globalizeMembers = true; - } - } + string extendee = (string)((LiteralNode)extensionAttribute.Arguments[0]).Value; + Debug.Assert(String.IsNullOrEmpty(extendee) == false); - if (globalizeMembers) { - ((ClassSymbol)typeSymbol).SetGlobalMethods(mixinRoot); + ((ClassSymbol)typeSymbol).SetExtenderClass(extendee); } } diff --git a/src/Core/Compiler/Generator/ExpressionGenerator.cs b/src/Core/Compiler/Generator/ExpressionGenerator.cs index 29e19994c..5214210f2 100644 --- a/src/Core/Compiler/Generator/ExpressionGenerator.cs +++ b/src/Core/Compiler/Generator/ExpressionGenerator.cs @@ -259,7 +259,7 @@ private static void GenerateDelegateExpression(ScriptGenerator generator, Member // TODO: This probably needs to handle global method roots... - if (expression.Method.IsGlobalMethod == false) { + if (expression.Method.IsExtension == false) { ExpressionGenerator.GenerateExpression(generator, symbol, expression.ObjectReference); writer.Write("."); } @@ -714,7 +714,7 @@ private static void GenerateMethodExpression(ScriptGenerator generator, MemberSy if (expression.ObjectReference is BaseExpression) { Debug.Assert(symbol.Parent is ClassSymbol); - Debug.Assert(expression.Method.IsGlobalMethod == false); + Debug.Assert(expression.Method.IsExtension == false); ClassSymbol baseClass = ((ClassSymbol)symbol.Parent).BaseClass; Debug.Assert(baseClass != null); @@ -736,11 +736,11 @@ private static void GenerateMethodExpression(ScriptGenerator generator, MemberSy writer.Write(")"); } else { - if (expression.Method.IsGlobalMethod) { + if (expression.Method.IsExtension) { if (expression.Method.Parent is ClassSymbol) { - string mixinRoot = ((ClassSymbol)expression.Method.Parent).MixinRoot; - if (String.IsNullOrEmpty(mixinRoot) == false) { - writer.Write(mixinRoot); + string extendee = ((ClassSymbol)expression.Method.Parent).Extendee; + if (String.IsNullOrEmpty(extendee) == false) { + writer.Write(extendee); writer.Write("."); } } diff --git a/src/Core/Compiler/Generator/MemberGenerator.cs b/src/Core/Compiler/Generator/MemberGenerator.cs index 0a2f17847..4f4bf8fb2 100644 --- a/src/Core/Compiler/Generator/MemberGenerator.cs +++ b/src/Core/Compiler/Generator/MemberGenerator.cs @@ -251,16 +251,16 @@ private static void GenerateMethod(ScriptGenerator generator, string typeName, M bool instanceMember = ((methodSymbol.Visibility & MemberVisibility.Static) == 0); if (instanceMember == false) { - if (methodSymbol.IsGlobalMethod) { - string mixinRoot = null; + if (methodSymbol.IsExtension) { + string extendee = null; if (methodSymbol.Parent.Type == SymbolType.Class) { - mixinRoot = ((ClassSymbol)methodSymbol.Parent).MixinRoot; + extendee = ((ClassSymbol)methodSymbol.Parent).Extendee; } - if (String.IsNullOrEmpty(mixinRoot)) { - mixinRoot = "this"; + if (String.IsNullOrEmpty(extendee)) { + extendee = "this"; } - writer.Write(mixinRoot); + writer.Write(extendee); } else { writer.Write(typeName); diff --git a/src/Core/Compiler/Generator/ScriptGenerator.cs b/src/Core/Compiler/Generator/ScriptGenerator.cs index eeb179937..8c8313120 100644 --- a/src/Core/Compiler/Generator/ScriptGenerator.cs +++ b/src/Core/Compiler/Generator/ScriptGenerator.cs @@ -147,7 +147,7 @@ public void GenerateScript(SymbolSet symbolSet) { bool firstType = true; foreach (TypeSymbol type in internalTypes) { if ((type.Type == SymbolType.Class) && - ((ClassSymbol)type).HasGlobalMethods) { + ((ClassSymbol)type).IsExtenderClass) { continue; } if ((type.Type == SymbolType.Record) && @@ -177,7 +177,7 @@ public void GenerateScript(SymbolSet symbolSet) { bool firstType = true; foreach (TypeSymbol type in publicTypes) { if ((type.Type == SymbolType.Class) && - ((ClassSymbol)type).HasGlobalMethods) { + ((ClassSymbol)type).IsExtenderClass) { continue; } diff --git a/src/Core/Compiler/Generator/TypeGenerator.cs b/src/Core/Compiler/Generator/TypeGenerator.cs index 201818cb6..994357a4a 100644 --- a/src/Core/Compiler/Generator/TypeGenerator.cs +++ b/src/Core/Compiler/Generator/TypeGenerator.cs @@ -196,7 +196,7 @@ public static void GenerateClassConstructorScript(ScriptGenerator generator, Cla } } - private static void GenerateGlobalMethods(ScriptGenerator generator, ClassSymbol classSymbol) { + private static void GenerateExtensionMethods(ScriptGenerator generator, ClassSymbol classSymbol) { foreach (MemberSymbol memberSymbol in classSymbol.Members) { Debug.Assert(memberSymbol.Type == SymbolType.Method); Debug.Assert((memberSymbol.Visibility & MemberVisibility.Static) != 0); @@ -246,7 +246,7 @@ private static void GenerateRecord(ScriptGenerator generator, RecordSymbol recor public static void GenerateRegistrationScript(ScriptGenerator generator, TypeSymbol typeSymbol) { ClassSymbol classSymbol = typeSymbol as ClassSymbol; - if ((classSymbol != null) && classSymbol.HasGlobalMethods) { + if ((classSymbol != null) && classSymbol.IsExtenderClass) { return; } @@ -347,8 +347,8 @@ public static void GenerateScript(ScriptGenerator generator, TypeSymbol typeSymb switch (typeSymbol.Type) { case SymbolType.Class: - if (((ClassSymbol)typeSymbol).HasGlobalMethods) { - GenerateGlobalMethods(generator, (ClassSymbol)typeSymbol); + if (((ClassSymbol)typeSymbol).IsExtenderClass) { + GenerateExtensionMethods(generator, (ClassSymbol)typeSymbol); } else { GenerateClass(generator, (ClassSymbol)typeSymbol); diff --git a/src/Core/Compiler/Importer/MetadataHelpers.cs b/src/Core/Compiler/Importer/MetadataHelpers.cs index 9daa71472..9ed72d6d0 100644 --- a/src/Core/Compiler/Importer/MetadataHelpers.cs +++ b/src/Core/Compiler/Importer/MetadataHelpers.cs @@ -89,17 +89,15 @@ public static bool IsEnum(TypeDefinition type) { return (String.CompareOrdinal(type.BaseType.FullName, "System.Enum") == 0); } - public static bool ShouldGlobalizeMembers(TypeDefinition type, out string mixinRoot) { - mixinRoot = null; - - CustomAttribute globalMethodsAttribute = GetAttribute(type, "System.Runtime.CompilerServices.GlobalMethodsAttribute"); - if (globalMethodsAttribute != null) { - return true; - } - - CustomAttribute mixinAttribute = GetAttribute(type, "System.Runtime.CompilerServices.MixinAttribute"); - if (mixinAttribute != null) { - mixinRoot = GetAttributeArgument(mixinAttribute); + public static bool IsScriptExtension(TypeDefinition type, out string extendee) { + extendee = null; + + CustomAttribute extensionAttribute = GetAttribute(type, "System.Runtime.CompilerServices.ScriptExtensionAttribute"); + if (extensionAttribute != null) { + extendee = GetAttributeArgument(extensionAttribute); + if (String.IsNullOrEmpty(extendee) == false) { + return true; + } } return false; diff --git a/src/Core/Compiler/Importer/MetadataImporter.cs b/src/Core/Compiler/Importer/MetadataImporter.cs index db17d1969..f34859321 100644 --- a/src/Core/Compiler/Importer/MetadataImporter.cs +++ b/src/Core/Compiler/Importer/MetadataImporter.cs @@ -726,9 +726,9 @@ private void ImportType(MetadataSource mdSource, TypeDefinition type, bool inScr else { typeSymbol = new ClassSymbol(name, namespaceSymbol); - string mixinRoot; - if (MetadataHelpers.ShouldGlobalizeMembers(type, out mixinRoot)) { - ((ClassSymbol)typeSymbol).SetGlobalMethods(mixinRoot); + string extendee; + if (MetadataHelpers.IsScriptExtension(type, out extendee)) { + ((ClassSymbol)typeSymbol).SetExtenderClass(extendee); } } } diff --git a/src/Core/Compiler/ScriptModel/Symbols/ClassSymbol.cs b/src/Core/Compiler/ScriptModel/Symbols/ClassSymbol.cs index 1cebbf747..e6d2a6263 100644 --- a/src/Core/Compiler/ScriptModel/Symbols/ClassSymbol.cs +++ b/src/Core/Compiler/ScriptModel/Symbols/ClassSymbol.cs @@ -23,8 +23,7 @@ internal class ClassSymbol : TypeSymbol { private ConstructorSymbol _staticConstructor; private IndexerSymbol _indexer; - private bool _globalMethods; - private string _mixinRoot; + private string _extendee; private bool _testClass; private ClassSymbol _primaryPartialClass; @@ -58,6 +57,12 @@ public ConstructorSymbol Constructor { } } + public string Extendee { + get { + return _extendee; + } + } + public override string GeneratedName { get { if (_primaryPartialClass != null) { @@ -67,12 +72,6 @@ public override string GeneratedName { } } - public bool HasGlobalMethods { - get { - return _globalMethods; - } - } - public IndexerSymbol Indexer { get { if (_primaryPartialClass != null) { @@ -108,6 +107,16 @@ public ICollection Interfaces { } } + public bool IsExtenderClass { + get { + if (_primaryPartialClass != null) { + return _primaryPartialClass.IsExtenderClass; + } + + return (String.IsNullOrEmpty(_extendee) == false); + } + } + public bool IsTestClass { get { if (_primaryPartialClass != null) { @@ -150,12 +159,6 @@ public int MinimizationDepth { } } - public string MixinRoot { - get { - return _mixinRoot; - } - } - public ClassSymbol PrimaryPartialClass { get { if (_primaryPartialClass != null) { @@ -263,9 +266,15 @@ public override MemberSymbol GetMember(string name) { return base.GetMember(name); } - public void SetGlobalMethods(string mixinRoot) { - _globalMethods = true; - _mixinRoot = mixinRoot; + public void SetExtenderClass(string extendee) { + Debug.Assert(String.IsNullOrEmpty(extendee) == false); + + if (_primaryPartialClass != null) { + _primaryPartialClass.SetExtenderClass(extendee); + return; + } + + _extendee = extendee; } public void SetInheritance(ClassSymbol baseClass, ICollection interfaces) { diff --git a/src/Core/Compiler/ScriptModel/Symbols/MethodSymbol.cs b/src/Core/Compiler/ScriptModel/Symbols/MethodSymbol.cs index eaa3ab92e..1ee081dac 100644 --- a/src/Core/Compiler/ScriptModel/Symbols/MethodSymbol.cs +++ b/src/Core/Compiler/ScriptModel/Symbols/MethodSymbol.cs @@ -82,26 +82,26 @@ public SymbolImplementation Implementation { } } - public bool IsGeneric { - get { - return (_genericArguments != null) && - (_genericArguments.Count != 0); - } - } - - public bool IsGlobalMethod { + public bool IsExtension { get { if (_aliased) { - // Methods with a script alias are considered global methods. + // Methods with a script alias are considered extension methods. return true; } if (Parent.Type == SymbolType.Class) { - return ((ClassSymbol)Parent).HasGlobalMethods; + return ((ClassSymbol)Parent).IsExtenderClass; } return false; } } + public bool IsGeneric { + get { + return (_genericArguments != null) && + (_genericArguments.Count != 0); + } + } + public bool SkipGeneration { get { return _skipGeneration; diff --git a/src/Core/Compiler/ScriptModel/Symbols/SymbolSetDumper.cs b/src/Core/Compiler/ScriptModel/Symbols/SymbolSetDumper.cs index db1e860bc..08b6bedc2 100644 --- a/src/Core/Compiler/ScriptModel/Symbols/SymbolSetDumper.cs +++ b/src/Core/Compiler/ScriptModel/Symbols/SymbolSetDumper.cs @@ -23,8 +23,8 @@ public SymbolSetDumper(TextWriter writer) { } private void DumpClass(ClassSymbol classSymbol) { - _writer.Write("Global Methods: "); - _writer.WriteLine(classSymbol.HasGlobalMethods); + _writer.Write("Extension Methods: "); + _writer.WriteLine(classSymbol.IsExtenderClass); if (classSymbol.BaseClass != null) { _writer.Write("BaseClass: "); diff --git a/src/Core/Compiler/Validator/CustomTypeNodeValidator.cs b/src/Core/Compiler/Validator/CustomTypeNodeValidator.cs index 7b0682487..a8da8d5e5 100644 --- a/src/Core/Compiler/Validator/CustomTypeNodeValidator.cs +++ b/src/Core/Compiler/Validator/CustomTypeNodeValidator.cs @@ -98,22 +98,20 @@ bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErro } } - AttributeNode globalMethodsAttribute = AttributeNode.FindAttribute(typeNode.Attributes, "GlobalMethods"); - if (globalMethodsAttribute != null) { + AttributeNode extensionAttribute = AttributeNode.FindAttribute(typeNode.Attributes, "ScriptExtension"); + if (extensionAttribute != null) { restrictToMethodMembers = true; if ((typeNode.Modifiers & Modifiers.Static) == 0) { - errorHandler.ReportError("GlobalMethods attribute can only be set on static classes.", + errorHandler.ReportError("ScriptExtension attribute can only be set on static classes.", typeNode.Token.Location); } - } - - AttributeNode mixinAttribute = AttributeNode.FindAttribute(typeNode.Attributes, "Mixin"); - if (mixinAttribute != null) { - restrictToMethodMembers = true; - if ((typeNode.Modifiers & Modifiers.Static) == 0) { - errorHandler.ReportError("Mixin attribute can only be set on static classes.", + if ((extensionAttribute.Arguments.Count != 1) || + !(extensionAttribute.Arguments[0] is LiteralNode) || + !(((LiteralNode)extensionAttribute.Arguments[0]).Value is string) || + String.IsNullOrEmpty((string)((LiteralNode)extensionAttribute.Arguments[0]).Value)) { + errorHandler.ReportError("ScriptExtension attribute declaration must specify the object being extended.", typeNode.Token.Location); } } @@ -137,10 +135,8 @@ bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErro continue; } - if (restrictToMethodMembers && - (memberNode.NodeType != ParseNodeType.MethodDeclaration) && - (memberNode.NodeType != ParseNodeType.ConstructorDeclaration)) { - errorHandler.ReportError("Classes marked with GlobalMethods or Mixin attribute should only have methods.", + if (restrictToMethodMembers && (memberNode.NodeType != ParseNodeType.MethodDeclaration)) { + errorHandler.ReportError("Classes marked with ScriptExtension attribute should only have methods.", memberNode.Token.Location); } diff --git a/src/Core/CoreLib/Script.cs b/src/Core/CoreLib/Script.cs index 71f41b47e..9c8dcf7fa 100644 --- a/src/Core/CoreLib/Script.cs +++ b/src/Core/CoreLib/Script.cs @@ -15,6 +15,14 @@ namespace System { [Imported] public static class Script { + [IntrinsicProperty] + [ScriptAlias("$global")] + public static object Global { + get { + return null; + } + } + /// /// Converts an object into a boolean. /// diff --git a/src/Core/CoreLib/ScriptMetadata.cs b/src/Core/CoreLib/ScriptMetadata.cs index f5a04a27e..487ad444e 100644 --- a/src/Core/CoreLib/ScriptMetadata.cs +++ b/src/Core/CoreLib/ScriptMetadata.cs @@ -99,25 +99,15 @@ public sealed class IgnoreNamespaceAttribute : Attribute { public sealed class ResourcesAttribute : Attribute { } - /// - /// This attribute turns methods on a static class as global methods in the generated - /// script. Note that the class must be static, and must contain only methods. - /// - [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)] - [NonScriptable] - [Imported] - public sealed class GlobalMethodsAttribute : Attribute { - } - [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [NonScriptable] [Imported] - public sealed class MixinAttribute : Attribute { + public sealed class ScriptExtensionAttribute : Attribute { private string _expression; - public MixinAttribute(string expression) { - _expression = expression; + public ScriptExtensionAttribute(string extendeeExpression) { + _expression = extendeeExpression; } public string Expression { diff --git a/tests/ScriptSharp/ValidationTests.cs b/tests/ScriptSharp/ValidationTests.cs index f9b1432e7..b7463b2b7 100644 --- a/tests/ScriptSharp/ValidationTests.cs +++ b/tests/ScriptSharp/ValidationTests.cs @@ -235,6 +235,31 @@ public void TestProperties() { } } + [TestMethod] + public void TestScriptExtension() { + string expectedErrors1 = + "ScriptExtension attribute declaration must specify the object being extended. Code.cs(9, 5)" + Environment.NewLine + + "Classes marked with ScriptExtension attribute should only have methods. Code.cs(16, 9)"; + + Compilation compilation = CreateCompilation(); + compilation.AddSource("Code.cs"); + + bool result = compilation.Execute(); + Assert.IsFalse(result, "Expected compilation to fail."); + + Assert.IsTrue(compilation.HasErrors, "Expected compilation to fail with errors."); + if (String.CompareOrdinal(compilation.ErrorMessages, expectedErrors1) != 0) { + Console.WriteLine("Expected Errors:"); + Console.WriteLine(expectedErrors1); + Console.WriteLine(); + Console.WriteLine("Actual Errors:"); + Console.WriteLine(compilation.ErrorMessages); + Console.WriteLine(); + + Assert.Fail("Unexpected errors."); + } + } + [TestMethod] public void TestUnsupported() { string expectedErrors1 = diff --git a/tests/TestCases/Basic/DocComments/Baseline.txt b/tests/TestCases/Basic/DocComments/Baseline.txt index a1fdd343b..be17ec337 100644 --- a/tests/TestCases/Basic/DocComments/Baseline.txt +++ b/tests/TestCases/Basic/DocComments/Baseline.txt @@ -214,7 +214,7 @@ define('test', ['ss'], function(ss) { // BasicTests.GlobalMethodsClass - this.run = function() { + $global.run = function() { /// /// Runs. /// diff --git a/tests/TestCases/Basic/DocComments/Code.cs b/tests/TestCases/Basic/DocComments/Code.cs index 981788a6f..57a894f91 100644 --- a/tests/TestCases/Basic/DocComments/Code.cs +++ b/tests/TestCases/Basic/DocComments/Code.cs @@ -247,9 +247,9 @@ public interface IInterface { } /// - /// Class with global methods. + /// Class with extension methods. /// - [GlobalMethods] + [ScriptExtension("$global")] public static class GlobalMethodsClass { /// diff --git a/tests/TestCases/Basic/Metadata/Baseline.txt b/tests/TestCases/Basic/Metadata/Baseline.txt index 801d5341a..a531cf4c9 100644 --- a/tests/TestCases/Basic/Metadata/Baseline.txt +++ b/tests/TestCases/Basic/Metadata/Baseline.txt @@ -11,7 +11,7 @@ Types: Application Type: True Public: True Generated Name: App - Global Methods: False + Extension Methods: False Interfaces: IApp Constructor: @@ -63,7 +63,7 @@ Types: Application Type: True Public: False Generated Name: AppHelper - Global Methods: False + Extension Methods: False Indexer: Indexer: Item AssociatedType: Int32 @@ -137,7 +137,7 @@ Types: Application Type: True Public: False Generated Name: Point - Global Methods: False + Extension Methods: False Constructor: Constructor: AssociatedType: Point @@ -163,7 +163,7 @@ Types: Application Type: True Public: False Generated Name: Util - Global Methods: True + Extension Methods: True Members: Method: ShowHelp AssociatedType: Void @@ -278,7 +278,7 @@ Types: Application Type: False Public: True Generated Name: arguments - Global Methods: False + Extension Methods: False BaseClass: Object Indexer: Indexer: Item @@ -311,7 +311,7 @@ Types: Application Type: False Public: True Generated Name: Array - Global Methods: False + Extension Methods: False BaseClass: Object Indexer: Indexer: Item @@ -455,7 +455,7 @@ Types: Application Type: False Public: True Generated Name: Boolean - Global Methods: False + Extension Methods: False Members: Method: Parse AssociatedType: Boolean @@ -467,7 +467,7 @@ Types: Application Type: False Public: True Generated Name: Number - Global Methods: False + Extension Methods: False Members: Method: ToString AssociatedType: String @@ -490,7 +490,7 @@ Types: Application Type: False Public: True Generated Name: CancelEventArgs - Global Methods: False + Extension Methods: False BaseClass: EventArgs Members: Field: Cancel @@ -502,7 +502,7 @@ Types: Application Type: False Public: True Generated Name: String - Global Methods: False + Extension Methods: False Members: Delegate: CompareCallback @@ -520,7 +520,7 @@ Types: Application Type: False Public: True Generated Name: Date - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: Empty @@ -759,7 +759,7 @@ Types: Application Type: False Public: True Generated Name: Number - Global Methods: False + Extension Methods: False Members: Method: Format AssociatedType: String @@ -786,7 +786,7 @@ Types: Application Type: False Public: True Generated Name: Delegate - Global Methods: False + Extension Methods: False BaseClass: Object Members: Method: Combine @@ -814,7 +814,7 @@ Types: Application Type: False Public: True Generated Name: Number - Global Methods: False + Extension Methods: False Members: Method: Parse AssociatedType: Double @@ -841,14 +841,14 @@ Types: Application Type: False Public: True Generated Name: Enum - Global Methods: False + Extension Methods: False Members: Class: EventArgs Application Type: False Public: True Generated Name: EventArgs - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: Empty @@ -882,7 +882,7 @@ Types: Application Type: False Public: True Generated Name: Error - Global Methods: False + Extension Methods: False BaseClass: Object Indexer: Indexer: Item @@ -914,7 +914,7 @@ Types: Application Type: False Public: True Generated Name: Export - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: Name @@ -1035,7 +1035,7 @@ Types: Application Type: False Public: True Generated Name: Function - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: Length @@ -1068,7 +1068,7 @@ Types: Application Type: False Public: True Generated Name: Number - Global Methods: False + Extension Methods: False Members: Method: ToString AssociatedType: String @@ -1080,7 +1080,7 @@ Types: Application Type: False Public: True Generated Name: Number - Global Methods: False + Extension Methods: False Members: Method: Parse AssociatedType: Int32 @@ -1097,7 +1097,7 @@ Types: Application Type: False Public: True Generated Name: Number - Global Methods: False + Extension Methods: False Members: Method: ToString AssociatedType: String @@ -1109,7 +1109,7 @@ Types: Application Type: False Public: True Generated Name: Math - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: E @@ -1244,7 +1244,7 @@ Types: Application Type: False Public: True Generated Name: Nullable`1 - Global Methods: False + Extension Methods: False Members: Property: HasValue AssociatedType: Boolean @@ -1268,7 +1268,7 @@ Types: Application Type: False Public: True Generated Name: Number - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: MAX_VALUE @@ -1346,7 +1346,7 @@ Types: Application Type: False Public: True Generated Name: Object - Global Methods: False + Extension Methods: False Members: Method: GetType AssociatedType: Type @@ -1368,7 +1368,7 @@ Types: Application Type: False Public: True Generated Name: Record - Global Methods: False + Extension Methods: False BaseClass: Object Members: @@ -1376,7 +1376,7 @@ Types: Application Type: False Public: True Generated Name: RegExp - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: LastIndex @@ -1423,7 +1423,7 @@ Types: Application Type: False Public: True Generated Name: Number - Global Methods: False + Extension Methods: False Members: Method: ToString AssociatedType: String @@ -1435,9 +1435,13 @@ Types: Application Type: False Public: True Generated Name: Script - Global Methods: False + Extension Methods: False BaseClass: Object Members: + Field: Global + AssociatedType: Object + Visibility: Public, Static + Generated Name: $global Method: Boolean AssociatedType: Boolean Visibility: Public, Static @@ -1606,7 +1610,7 @@ Types: Application Type: False Public: True Generated Name: Number - Global Methods: False + Extension Methods: False Members: Method: Parse AssociatedType: Single @@ -1633,7 +1637,7 @@ Types: Application Type: False Public: True Generated Name: String - Global Methods: False + Extension Methods: False BaseClass: Object Indexer: Indexer: Item @@ -1866,7 +1870,7 @@ Types: Application Type: False Public: True Generated Name: StringBuilder - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: IsEmpty @@ -1909,7 +1913,7 @@ Types: Application Type: False Public: True Generated Name: Tuple - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: Item1 @@ -1925,7 +1929,7 @@ Types: Application Type: False Public: True Generated Name: Tuple - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: Item1 @@ -1945,7 +1949,7 @@ Types: Application Type: False Public: True Generated Name: Tuple - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: Item1 @@ -1969,7 +1973,7 @@ Types: Application Type: False Public: True Generated Name: Type - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: BaseType @@ -2019,7 +2023,7 @@ Types: Application Type: False Public: True Generated Name: Number - Global Methods: False + Extension Methods: False Members: Method: ToString AssociatedType: String @@ -2031,7 +2035,7 @@ Types: Application Type: False Public: True Generated Name: Number - Global Methods: False + Extension Methods: False Members: Method: ToString AssociatedType: String @@ -2043,7 +2047,7 @@ Types: Application Type: False Public: True Generated Name: Number - Global Methods: False + Extension Methods: False Members: Method: ToString AssociatedType: String @@ -2055,7 +2059,7 @@ Types: Application Type: False Public: True Generated Name: Void - Global Methods: False + Extension Methods: False Members: @@ -2088,7 +2092,7 @@ Types: Application Type: False Public: True Generated Name: Array - Global Methods: False + Extension Methods: False BaseClass: Object Indexer: Indexer: Item @@ -2251,7 +2255,7 @@ Types: Application Type: False Public: True Generated Name: Array - Global Methods: False + Extension Methods: False BaseClass: Object Indexer: Indexer: Item @@ -2452,7 +2456,7 @@ Types: Application Type: False Public: True Generated Name: Object - Global Methods: False + Extension Methods: False BaseClass: Object Indexer: Indexer: Item @@ -2524,7 +2528,7 @@ Types: Application Type: False Public: True Generated Name: DictionaryEntry - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: Key @@ -2591,7 +2595,7 @@ Types: Application Type: False Public: True Generated Name: ObservableCollection - Global Methods: False + Extension Methods: False BaseClass: Object Indexer: Indexer: Item @@ -2657,7 +2661,7 @@ Types: Application Type: False Public: True Generated Name: Array - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: Count @@ -2694,7 +2698,7 @@ Types: Application Type: False Public: True Generated Name: Array - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: Count @@ -2746,7 +2750,7 @@ Types: Application Type: False Public: True Generated Name: Object - Global Methods: False + Extension Methods: False BaseClass: Object Indexer: Indexer: Item @@ -2859,7 +2863,7 @@ Types: Application Type: False Public: True Generated Name: Object - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: Key @@ -2875,7 +2879,7 @@ Types: Application Type: False Public: True Generated Name: Array - Global Methods: False + Extension Methods: False BaseClass: Object Indexer: Indexer: Item @@ -3066,7 +3070,7 @@ Types: Application Type: False Public: True Generated Name: Array - Global Methods: False + Extension Methods: False BaseClass: Object Indexer: Indexer: Item @@ -3231,7 +3235,7 @@ Types: Application Type: False Public: True Generated Name: ObservableCollection - Global Methods: False + Extension Methods: False BaseClass: Object Indexer: Indexer: Item @@ -3297,7 +3301,7 @@ Types: Application Type: False Public: True Generated Name: Array - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: Count @@ -3334,7 +3338,7 @@ Types: Application Type: False Public: True Generated Name: Array - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: Count @@ -3455,7 +3459,7 @@ Types: Application Type: False Public: True Generated Name: Observable - Global Methods: False + Extension Methods: False BaseClass: Object Members: Method: GetValue @@ -3473,7 +3477,7 @@ Types: Application Type: False Public: True Generated Name: Observable - Global Methods: False + Extension Methods: False BaseClass: Object Members: Method: RegisterObserver @@ -3490,7 +3494,7 @@ Types: Application Type: False Public: True Generated Name: console - Global Methods: False + Extension Methods: False BaseClass: Object Members: Method: Assert @@ -3523,7 +3527,7 @@ Types: Application Type: False Public: True Generated Name: culture - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: CurrentCulture @@ -3551,7 +3555,7 @@ Types: Application Type: False Public: True Generated Name: DateFormatInfo - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: AMDesignator @@ -3631,7 +3635,7 @@ Types: Application Type: False Public: True Generated Name: NumberFormatInfo - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: NaNSymbol @@ -3735,7 +3739,7 @@ Types: Application Type: False Public: True Generated Name: JSON - Global Methods: False + Extension Methods: False BaseClass: Object Members: Method: Parse @@ -3784,7 +3788,7 @@ Types: Application Type: False Public: True Generated Name: Assert - Global Methods: False + Extension Methods: False BaseClass: Object Members: Method: AreEqual @@ -3812,7 +3816,7 @@ Types: Application Type: False Public: True Generated Name: TestClass - Global Methods: False + Extension Methods: False BaseClass: Object Members: Method: Cleanup @@ -3830,7 +3834,7 @@ Types: Application Type: False Public: True Generated Name: TestEngine - Global Methods: False + Extension Methods: False BaseClass: Object Members: Method: Log @@ -3862,7 +3866,7 @@ Types: Application Type: False Public: True Generated Name: Deferred - Global Methods: False + Extension Methods: False BaseClass: Object Members: Field: Task @@ -3884,7 +3888,7 @@ Types: Application Type: False Public: True Generated Name: Deferred - Global Methods: False + Extension Methods: False BaseClass: Deferred Members: Field: Task @@ -3901,7 +3905,7 @@ Types: Application Type: False Public: True Generated Name: Task - Global Methods: False + Extension Methods: False BaseClass: Object Members: Property: Completed @@ -3958,7 +3962,7 @@ Types: Application Type: False Public: True Generated Name: Task - Global Methods: False + Extension Methods: False BaseClass: Task Members: Field: Result @@ -4087,7 +4091,7 @@ define('test', ['ss'], function(ss) { // BasicTests.Util - this._showHelp = function() { + $global._showHelp = function() { } diff --git a/tests/TestCases/Basic/Metadata/Code.cs b/tests/TestCases/Basic/Metadata/Code.cs index a9883b908..79830be36 100644 --- a/tests/TestCases/Basic/Metadata/Code.cs +++ b/tests/TestCases/Basic/Metadata/Code.cs @@ -61,7 +61,7 @@ public interface IApp { void Run(); } - [GlobalMethods] + [ScriptExtension("$global")] internal static class Util { internal static void ShowHelp() { } diff --git a/tests/TestCases/Basic/Minimization/Baseline.txt b/tests/TestCases/Basic/Minimization/Baseline.txt index 247783278..394dd10eb 100644 --- a/tests/TestCases/Basic/Minimization/Baseline.txt +++ b/tests/TestCases/Basic/Minimization/Baseline.txt @@ -64,7 +64,7 @@ define('test', ['ss', 'lib'], function(ss, lib) { // BasicTests.GlobalMethodsClass - this.run = function() { + $global.run = function() { } diff --git a/tests/TestCases/Basic/Minimization/Code.cs b/tests/TestCases/Basic/Minimization/Code.cs index bd778253b..7b7c97a17 100644 --- a/tests/TestCases/Basic/Minimization/Code.cs +++ b/tests/TestCases/Basic/Minimization/Code.cs @@ -7,7 +7,7 @@ namespace BasicTests { - [GlobalMethods] + [ScriptExtension("$global")] public static class GlobalMethodsClass { public static void Run() { diff --git a/tests/TestCases/Expression/GlobalMethods/Baseline.txt b/tests/TestCases/Expression/GlobalMethods/Baseline.txt index 34cc160a5..55a3a3631 100644 --- a/tests/TestCases/Expression/GlobalMethods/Baseline.txt +++ b/tests/TestCases/Expression/GlobalMethods/Baseline.txt @@ -8,7 +8,7 @@ define('test', ['ss'], function(ss) { var ExpressionTests$App$ = { test: function(arg) { eval('[ 1, 2 ]'); - foo(); + $global.foo(); setTimeout(foo, 0); } }; @@ -16,7 +16,7 @@ define('test', ['ss'], function(ss) { // ExpressionTests.Util - this.foo = function() { + $global.foo = function() { } diff --git a/tests/TestCases/Expression/GlobalMethods/Code.cs b/tests/TestCases/Expression/GlobalMethods/Code.cs index e746096b4..8332e153a 100644 --- a/tests/TestCases/Expression/GlobalMethods/Code.cs +++ b/tests/TestCases/Expression/GlobalMethods/Code.cs @@ -14,7 +14,7 @@ public void Test(int arg) { } } - [GlobalMethods] + [ScriptExtension("$global")] public static class Util { public static void Foo() { diff --git a/tests/TestCases/Expression/Script/Baseline.txt b/tests/TestCases/Expression/Script/Baseline.txt index 244444edc..124bf7c32 100644 --- a/tests/TestCases/Expression/Script/Baseline.txt +++ b/tests/TestCases/Expression/Script/Baseline.txt @@ -23,6 +23,7 @@ define('test', ['ss'], function(ss) { var addition = eval('2 + 2'); addition = 2 + 2; addition = 2 + 3; + var g = $global; } }; diff --git a/tests/TestCases/Expression/Script/Code.cs b/tests/TestCases/Expression/Script/Code.cs index 4217bb025..13dd5cbee 100644 --- a/tests/TestCases/Expression/Script/Code.cs +++ b/tests/TestCases/Expression/Script/Code.cs @@ -29,6 +29,8 @@ public void Test(int arg) { addition = (int)Script.Literal("2 + 2"); addition = (int)Script.Literal("{0} + {1}", 2, 3); + + object g = Script.Global; } } } diff --git a/tests/TestCases/Member/Methods/Baseline.txt b/tests/TestCases/Member/Methods/Baseline.txt index 79f8759fd..68d185e58 100644 --- a/tests/TestCases/Member/Methods/Baseline.txt +++ b/tests/TestCases/Member/Methods/Baseline.txt @@ -33,7 +33,7 @@ define('test', ['ss'], function(ss) { // MemberTests.Foo - this.doStuff = function() { + $global.doStuff = function() { } @@ -45,16 +45,6 @@ define('test', ['ss'], function(ss) { } - // MemberTests.FooBar - - this.doStuff2 = function() { - } - - - // MemberTests.FooBar2 - - - // MemberTests.X function MemberTests$X() { @@ -79,11 +69,6 @@ define('test', ['ss'], function(ss) { X: [ MemberTests$X, MemberTests$X$, null ] }); - alert('Startup code in FooBar'); - (function() { - var timeStamp = new Date().getMilliseconds(); - alert('Startup code in FooBar: ' + timeStamp); - })(); return $test; }); diff --git a/tests/TestCases/Member/Methods/Code.cs b/tests/TestCases/Member/Methods/Code.cs index 09ac405b5..e53c50da3 100644 --- a/tests/TestCases/Member/Methods/Code.cs +++ b/tests/TestCases/Member/Methods/Code.cs @@ -41,14 +41,14 @@ public override string ToString() { } } - [GlobalMethods] + [ScriptExtension("$global")] public static class Foo { public static void DoStuff() { } } - [Mixin("window")] + [ScriptExtension("window")] public static class Bar { public static void M1() { @@ -58,32 +58,12 @@ public static void M2() { } } - [GlobalMethods] - public static class FooBar { - - static FooBar() { - Window.Alert("Startup code in FooBar"); - } - - public static void DoStuff2() { - } - } - - [GlobalMethods] - public static class FooBar2 { - - static FooBar2() { - int timeStamp = (new Date()).GetMilliseconds(); - Window.Alert("Startup code in FooBar: " + timeStamp); - } - } - public class X { public void Update(int i) { } } - [Mixin("$.fn")] + [ScriptExtension("$.fn")] public static class Plugin { public static X Extend(X x, int i) { diff --git a/tests/TestCases/Validation/ScriptExtension/Code.cs b/tests/TestCases/Validation/ScriptExtension/Code.cs new file mode 100644 index 000000000..366d8891d --- /dev/null +++ b/tests/TestCases/Validation/ScriptExtension/Code.cs @@ -0,0 +1,19 @@ +using System; +using System.Runtime.CompilerServices; + +[assembly: ScriptAssembly("test")] + + +namespace ValidationTests { + + [ScriptExtension("")] + public static class A { + } + + [ScriptExtension("$global")] + public static class A { + + static A() { + } + } +} From 43bd867f6ecb890b9b204cb712e16280cbd30af1 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 16 Sep 2012 10:48:54 -0700 Subject: [PATCH 030/251] Capture global scope for use in module code. --- src/Core/Compiler/Generator/ScriptGenerator.cs | 1 + tests/TestCases/Basic/Conditionals/DebugBaseline.txt | 1 + tests/TestCases/Basic/Conditionals/TraceBaseline.txt | 1 + tests/TestCases/Basic/Dependencies/Code1Baseline.txt | 1 + tests/TestCases/Basic/Dependencies/Code2Baseline.txt | 1 + tests/TestCases/Basic/DocComments/Baseline.txt | 1 + tests/TestCases/Basic/Flags/Baseline.txt | 1 + tests/TestCases/Basic/Metadata/Baseline.txt | 1 + tests/TestCases/Basic/Minimization/Baseline.txt | 1 + tests/TestCases/Basic/Resources/Baseline.txt | 1 + tests/TestCases/Basic/Simple/Baseline.txt | 1 + tests/TestCases/Basic/Template/Baseline.txt | 1 + tests/TestCases/Basic/UnitTest/NonTestBaseline.txt | 1 + tests/TestCases/Basic/UnitTest/TestBaseline.txt | 1 + tests/TestCases/Expression/AnonymousMethods/Baseline.txt | 1 + tests/TestCases/Expression/Arguments/Baseline.txt | 1 + tests/TestCases/Expression/Base/Baseline.txt | 1 + tests/TestCases/Expression/Binary/Baseline.txt | 1 + tests/TestCases/Expression/Cast/Baseline.txt | 1 + tests/TestCases/Expression/Conditional/Baseline.txt | 1 + tests/TestCases/Expression/Delegates/Baseline.txt | 1 + tests/TestCases/Expression/Dictionary/Baseline.txt | 1 + tests/TestCases/Expression/EnumToString/MinBaseline.txt | 1 + tests/TestCases/Expression/EnumToString/NormalBaseline.txt | 1 + tests/TestCases/Expression/Events/Baseline.txt | 1 + tests/TestCases/Expression/Generics/Baseline.txt | 1 + tests/TestCases/Expression/GetType/Baseline.txt | 1 + tests/TestCases/Expression/GlobalMethods/Baseline.txt | 1 + tests/TestCases/Expression/InlineScript/Baseline.txt | 1 + tests/TestCases/Expression/LateBound/Baseline.txt | 1 + tests/TestCases/Expression/Literals/Baseline.txt | 1 + tests/TestCases/Expression/Locals/Baseline.txt | 1 + tests/TestCases/Expression/Members/Baseline.txt | 1 + tests/TestCases/Expression/New/Baseline.txt | 1 + tests/TestCases/Expression/Number/Baseline.txt | 1 + tests/TestCases/Expression/Script/Baseline.txt | 1 + tests/TestCases/Expression/String/Baseline.txt | 1 + tests/TestCases/Expression/Truthy/Baseline.txt | 1 + tests/TestCases/Expression/Tuples/Baseline.txt | 1 + tests/TestCases/Expression/Unary/Baseline.txt | 1 + tests/TestCases/Library/jQuery/Baseline.txt | 1 + tests/TestCases/Member/Constructors/Baseline.txt | 1 + tests/TestCases/Member/Events/Baseline.txt | 1 + tests/TestCases/Member/Fields/Baseline.txt | 1 + tests/TestCases/Member/Indexers/Baseline.txt | 1 + tests/TestCases/Member/Methods/Baseline.txt | 1 + tests/TestCases/Member/Overloads/Baseline.txt | 1 + tests/TestCases/Member/Properties/Baseline.txt | 1 + tests/TestCases/Member/StaticConstructors/Baseline.txt | 1 + tests/TestCases/Statement/Exceptions/Baseline.txt | 1 + tests/TestCases/Statement/Expression/Baseline.txt | 1 + tests/TestCases/Statement/For/Baseline.txt | 1 + tests/TestCases/Statement/Foreach/Baseline.txt | 1 + tests/TestCases/Statement/IfElse/Baseline.txt | 1 + tests/TestCases/Statement/Return/Baseline.txt | 1 + tests/TestCases/Statement/Switch/Baseline.txt | 1 + tests/TestCases/Statement/Variables/Baseline.txt | 1 + tests/TestCases/Statement/While/Baseline.txt | 1 + tests/TestCases/Type/Classes/Baseline.txt | 1 + tests/TestCases/Type/Delegates/Baseline.txt | 1 + tests/TestCases/Type/Enumerator/Baseline.txt | 1 + tests/TestCases/Type/Enums/Baseline.txt | 1 + tests/TestCases/Type/Globals/Baseline.txt | 1 + tests/TestCases/Type/Imported/Baseline.txt | 1 + tests/TestCases/Type/Interfaces/Baseline.txt | 1 + tests/TestCases/Type/Namespaces/Baseline.txt | 1 + tests/TestCases/Type/Nullable/Baseline.txt | 1 + tests/TestCases/Type/Partials/Baseline.txt | 1 + tests/TestCases/Type/Records/Baseline.txt | 1 + tests/TestCases/Type/UsingAlias/Baseline.txt | 1 + 70 files changed, 70 insertions(+) diff --git a/src/Core/Compiler/Generator/ScriptGenerator.cs b/src/Core/Compiler/Generator/ScriptGenerator.cs index 8c8313120..2efe3e7bd 100644 --- a/src/Core/Compiler/Generator/ScriptGenerator.cs +++ b/src/Core/Compiler/Generator/ScriptGenerator.cs @@ -130,6 +130,7 @@ public void GenerateScript(SymbolSet symbolSet) { _writer.WriteLine(") {"); _writer.Indent++; _writer.WriteLine("\'use strict';"); + _writer.WriteLine("var $global = this;"); _writer.WriteLine(); foreach (TypeSymbol type in types) { diff --git a/tests/TestCases/Basic/Conditionals/DebugBaseline.txt b/tests/TestCases/Basic/Conditionals/DebugBaseline.txt index 252ee44b0..cf43966e1 100644 --- a/tests/TestCases/Basic/Conditionals/DebugBaseline.txt +++ b/tests/TestCases/Basic/Conditionals/DebugBaseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // BasicTests.MyDebug diff --git a/tests/TestCases/Basic/Conditionals/TraceBaseline.txt b/tests/TestCases/Basic/Conditionals/TraceBaseline.txt index 4937c90dd..1bf2f7941 100644 --- a/tests/TestCases/Basic/Conditionals/TraceBaseline.txt +++ b/tests/TestCases/Basic/Conditionals/TraceBaseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // BasicTests.MyDebug diff --git a/tests/TestCases/Basic/Dependencies/Code1Baseline.txt b/tests/TestCases/Basic/Dependencies/Code1Baseline.txt index dae1dcada..77195c2b3 100644 --- a/tests/TestCases/Basic/Dependencies/Code1Baseline.txt +++ b/tests/TestCases/Basic/Dependencies/Code1Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss', 'lib1'], function(ss, lib1) { 'use strict'; + var $global = this; // BasicTests.App diff --git a/tests/TestCases/Basic/Dependencies/Code2Baseline.txt b/tests/TestCases/Basic/Dependencies/Code2Baseline.txt index c1e5d1988..3a7bd760f 100644 --- a/tests/TestCases/Basic/Dependencies/Code2Baseline.txt +++ b/tests/TestCases/Basic/Dependencies/Code2Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss', 'lib1', 'comp3', 'comp4'], function(ss, lib1, comp3, comp4) { 'use strict'; + var $global = this; // BasicTests.App diff --git a/tests/TestCases/Basic/DocComments/Baseline.txt b/tests/TestCases/Basic/DocComments/Baseline.txt index be17ec337..436398192 100644 --- a/tests/TestCases/Basic/DocComments/Baseline.txt +++ b/tests/TestCases/Basic/DocComments/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // BasicTests.Suit diff --git a/tests/TestCases/Basic/Flags/Baseline.txt b/tests/TestCases/Basic/Flags/Baseline.txt index 81d37d8ce..b708aa048 100644 --- a/tests/TestCases/Basic/Flags/Baseline.txt +++ b/tests/TestCases/Basic/Flags/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // BasicTests.App diff --git a/tests/TestCases/Basic/Metadata/Baseline.txt b/tests/TestCases/Basic/Metadata/Baseline.txt index a531cf4c9..fc501296a 100644 --- a/tests/TestCases/Basic/Metadata/Baseline.txt +++ b/tests/TestCases/Basic/Metadata/Baseline.txt @@ -4008,6 +4008,7 @@ Script define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // BasicTests.AppFlags diff --git a/tests/TestCases/Basic/Minimization/Baseline.txt b/tests/TestCases/Basic/Minimization/Baseline.txt index 394dd10eb..b897065e4 100644 --- a/tests/TestCases/Basic/Minimization/Baseline.txt +++ b/tests/TestCases/Basic/Minimization/Baseline.txt @@ -38,6 +38,7 @@ Script define('test', ['ss', 'lib'], function(ss, lib) { 'use strict'; + var $global = this; // BasicTests.AppFlags diff --git a/tests/TestCases/Basic/Resources/Baseline.txt b/tests/TestCases/Basic/Resources/Baseline.txt index fa61b3edd..30505f47c 100644 --- a/tests/TestCases/Basic/Resources/Baseline.txt +++ b/tests/TestCases/Basic/Resources/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // Resources.Strings1 diff --git a/tests/TestCases/Basic/Simple/Baseline.txt b/tests/TestCases/Basic/Simple/Baseline.txt index ecc03065e..8ec01cd53 100644 --- a/tests/TestCases/Basic/Simple/Baseline.txt +++ b/tests/TestCases/Basic/Simple/Baseline.txt @@ -1,5 +1,6 @@ define('basic', ['ss'], function(ss) { 'use strict'; + var $global = this; // Basic.EventArgs diff --git a/tests/TestCases/Basic/Template/Baseline.txt b/tests/TestCases/Basic/Template/Baseline.txt index 749a4ee36..77b6e8869 100644 --- a/tests/TestCases/Basic/Template/Baseline.txt +++ b/tests/TestCases/Basic/Template/Baseline.txt @@ -4,6 +4,7 @@ alert('some static script'); define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // BasicTests.App diff --git a/tests/TestCases/Basic/UnitTest/NonTestBaseline.txt b/tests/TestCases/Basic/UnitTest/NonTestBaseline.txt index 5fc1e7f94..7efcd9dc3 100644 --- a/tests/TestCases/Basic/UnitTest/NonTestBaseline.txt +++ b/tests/TestCases/Basic/UnitTest/NonTestBaseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // BasicTests.PublicClass diff --git a/tests/TestCases/Basic/UnitTest/TestBaseline.txt b/tests/TestCases/Basic/UnitTest/TestBaseline.txt index b9546d41b..f765b4c06 100644 --- a/tests/TestCases/Basic/UnitTest/TestBaseline.txt +++ b/tests/TestCases/Basic/UnitTest/TestBaseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // BasicTests.PublicClass diff --git a/tests/TestCases/Expression/AnonymousMethods/Baseline.txt b/tests/TestCases/Expression/AnonymousMethods/Baseline.txt index 2fbeb8691..117543c92 100644 --- a/tests/TestCases/Expression/AnonymousMethods/Baseline.txt +++ b/tests/TestCases/Expression/AnonymousMethods/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.SomeClass diff --git a/tests/TestCases/Expression/Arguments/Baseline.txt b/tests/TestCases/Expression/Arguments/Baseline.txt index 40a756d12..f963edc90 100644 --- a/tests/TestCases/Expression/Arguments/Baseline.txt +++ b/tests/TestCases/Expression/Arguments/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/Base/Baseline.txt b/tests/TestCases/Expression/Base/Baseline.txt index 747bb5a07..7c16ed218 100644 --- a/tests/TestCases/Expression/Base/Baseline.txt +++ b/tests/TestCases/Expression/Base/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.Foo diff --git a/tests/TestCases/Expression/Binary/Baseline.txt b/tests/TestCases/Expression/Binary/Baseline.txt index 6b62681d7..58a0b1ec7 100644 --- a/tests/TestCases/Expression/Binary/Baseline.txt +++ b/tests/TestCases/Expression/Binary/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.Data diff --git a/tests/TestCases/Expression/Cast/Baseline.txt b/tests/TestCases/Expression/Cast/Baseline.txt index 6e6116f69..6ad64414f 100644 --- a/tests/TestCases/Expression/Cast/Baseline.txt +++ b/tests/TestCases/Expression/Cast/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/Conditional/Baseline.txt b/tests/TestCases/Expression/Conditional/Baseline.txt index c8d1a3d50..18943aefc 100644 --- a/tests/TestCases/Expression/Conditional/Baseline.txt +++ b/tests/TestCases/Expression/Conditional/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/Delegates/Baseline.txt b/tests/TestCases/Expression/Delegates/Baseline.txt index fbc8b707f..02a6403b1 100644 --- a/tests/TestCases/Expression/Delegates/Baseline.txt +++ b/tests/TestCases/Expression/Delegates/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.EventArgs diff --git a/tests/TestCases/Expression/Dictionary/Baseline.txt b/tests/TestCases/Expression/Dictionary/Baseline.txt index f435d89ac..7ed628de8 100644 --- a/tests/TestCases/Expression/Dictionary/Baseline.txt +++ b/tests/TestCases/Expression/Dictionary/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/EnumToString/MinBaseline.txt b/tests/TestCases/Expression/EnumToString/MinBaseline.txt index 8f339efb3..c43831deb 100644 --- a/tests/TestCases/Expression/EnumToString/MinBaseline.txt +++ b/tests/TestCases/Expression/EnumToString/MinBaseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/EnumToString/NormalBaseline.txt b/tests/TestCases/Expression/EnumToString/NormalBaseline.txt index beb65ce8b..c490b5961 100644 --- a/tests/TestCases/Expression/EnumToString/NormalBaseline.txt +++ b/tests/TestCases/Expression/EnumToString/NormalBaseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.Color diff --git a/tests/TestCases/Expression/Events/Baseline.txt b/tests/TestCases/Expression/Events/Baseline.txt index 829650512..3b003902f 100644 --- a/tests/TestCases/Expression/Events/Baseline.txt +++ b/tests/TestCases/Expression/Events/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.Button diff --git a/tests/TestCases/Expression/Generics/Baseline.txt b/tests/TestCases/Expression/Generics/Baseline.txt index 6d82700d4..5292d62e2 100644 --- a/tests/TestCases/Expression/Generics/Baseline.txt +++ b/tests/TestCases/Expression/Generics/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss', 'jQuery'], function(ss, jQuery) { 'use strict'; + var $global = this; // ExpressionTests.Foo diff --git a/tests/TestCases/Expression/GetType/Baseline.txt b/tests/TestCases/Expression/GetType/Baseline.txt index f174f4f38..fba3f3dd6 100644 --- a/tests/TestCases/Expression/GetType/Baseline.txt +++ b/tests/TestCases/Expression/GetType/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/GlobalMethods/Baseline.txt b/tests/TestCases/Expression/GlobalMethods/Baseline.txt index 55a3a3631..716ae2796 100644 --- a/tests/TestCases/Expression/GlobalMethods/Baseline.txt +++ b/tests/TestCases/Expression/GlobalMethods/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/InlineScript/Baseline.txt b/tests/TestCases/Expression/InlineScript/Baseline.txt index e12a95318..c1d1f6e64 100644 --- a/tests/TestCases/Expression/InlineScript/Baseline.txt +++ b/tests/TestCases/Expression/InlineScript/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/LateBound/Baseline.txt b/tests/TestCases/Expression/LateBound/Baseline.txt index e493861bb..6c6e51a25 100644 --- a/tests/TestCases/Expression/LateBound/Baseline.txt +++ b/tests/TestCases/Expression/LateBound/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/Literals/Baseline.txt b/tests/TestCases/Expression/Literals/Baseline.txt index 999dcc99d..fc5cf705c 100644 --- a/tests/TestCases/Expression/Literals/Baseline.txt +++ b/tests/TestCases/Expression/Literals/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/Locals/Baseline.txt b/tests/TestCases/Expression/Locals/Baseline.txt index 3a7eeaac7..e8d9696ba 100644 --- a/tests/TestCases/Expression/Locals/Baseline.txt +++ b/tests/TestCases/Expression/Locals/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/Members/Baseline.txt b/tests/TestCases/Expression/Members/Baseline.txt index d3968982e..de201b3ac 100644 --- a/tests/TestCases/Expression/Members/Baseline.txt +++ b/tests/TestCases/Expression/Members/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.IFoo diff --git a/tests/TestCases/Expression/New/Baseline.txt b/tests/TestCases/Expression/New/Baseline.txt index ba2fb6f50..d20862983 100644 --- a/tests/TestCases/Expression/New/Baseline.txt +++ b/tests/TestCases/Expression/New/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.Point diff --git a/tests/TestCases/Expression/Number/Baseline.txt b/tests/TestCases/Expression/Number/Baseline.txt index b10e085e8..77cb511fc 100644 --- a/tests/TestCases/Expression/Number/Baseline.txt +++ b/tests/TestCases/Expression/Number/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/Script/Baseline.txt b/tests/TestCases/Expression/Script/Baseline.txt index 124bf7c32..d40baa10c 100644 --- a/tests/TestCases/Expression/Script/Baseline.txt +++ b/tests/TestCases/Expression/Script/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/String/Baseline.txt b/tests/TestCases/Expression/String/Baseline.txt index 4514fc463..c2558950f 100644 --- a/tests/TestCases/Expression/String/Baseline.txt +++ b/tests/TestCases/Expression/String/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/Truthy/Baseline.txt b/tests/TestCases/Expression/Truthy/Baseline.txt index 0d986b6c3..e7665a5bd 100644 --- a/tests/TestCases/Expression/Truthy/Baseline.txt +++ b/tests/TestCases/Expression/Truthy/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/Tuples/Baseline.txt b/tests/TestCases/Expression/Tuples/Baseline.txt index 1921186c7..020b734a4 100644 --- a/tests/TestCases/Expression/Tuples/Baseline.txt +++ b/tests/TestCases/Expression/Tuples/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.App diff --git a/tests/TestCases/Expression/Unary/Baseline.txt b/tests/TestCases/Expression/Unary/Baseline.txt index 530b249f6..a17dfb488 100644 --- a/tests/TestCases/Expression/Unary/Baseline.txt +++ b/tests/TestCases/Expression/Unary/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // ExpressionTests.Data diff --git a/tests/TestCases/Library/jQuery/Baseline.txt b/tests/TestCases/Library/jQuery/Baseline.txt index 83f221328..09b6f1738 100644 --- a/tests/TestCases/Library/jQuery/Baseline.txt +++ b/tests/TestCases/Library/jQuery/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss', 'jQuery'], function(ss, jQuery) { 'use strict'; + var $global = this; // MyApp diff --git a/tests/TestCases/Member/Constructors/Baseline.txt b/tests/TestCases/Member/Constructors/Baseline.txt index 1020f6a4e..c13832548 100644 --- a/tests/TestCases/Member/Constructors/Baseline.txt +++ b/tests/TestCases/Member/Constructors/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // MemberTests.MyClass diff --git a/tests/TestCases/Member/Events/Baseline.txt b/tests/TestCases/Member/Events/Baseline.txt index f8e812567..678ffc65b 100644 --- a/tests/TestCases/Member/Events/Baseline.txt +++ b/tests/TestCases/Member/Events/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // MemberTests.EventArgs diff --git a/tests/TestCases/Member/Fields/Baseline.txt b/tests/TestCases/Member/Fields/Baseline.txt index 61e368176..a936fe168 100644 --- a/tests/TestCases/Member/Fields/Baseline.txt +++ b/tests/TestCases/Member/Fields/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // MemberTests.Mode diff --git a/tests/TestCases/Member/Indexers/Baseline.txt b/tests/TestCases/Member/Indexers/Baseline.txt index 1a72c9264..82f893424 100644 --- a/tests/TestCases/Member/Indexers/Baseline.txt +++ b/tests/TestCases/Member/Indexers/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // MemberTests.IIndexable diff --git a/tests/TestCases/Member/Methods/Baseline.txt b/tests/TestCases/Member/Methods/Baseline.txt index 68d185e58..37e572e2b 100644 --- a/tests/TestCases/Member/Methods/Baseline.txt +++ b/tests/TestCases/Member/Methods/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // MemberTests.Test diff --git a/tests/TestCases/Member/Overloads/Baseline.txt b/tests/TestCases/Member/Overloads/Baseline.txt index 607cbf52c..38bb28ec0 100644 --- a/tests/TestCases/Member/Overloads/Baseline.txt +++ b/tests/TestCases/Member/Overloads/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // MemberTests.Test diff --git a/tests/TestCases/Member/Properties/Baseline.txt b/tests/TestCases/Member/Properties/Baseline.txt index 5f88c6179..697b058d1 100644 --- a/tests/TestCases/Member/Properties/Baseline.txt +++ b/tests/TestCases/Member/Properties/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // MemberTests.Test diff --git a/tests/TestCases/Member/StaticConstructors/Baseline.txt b/tests/TestCases/Member/StaticConstructors/Baseline.txt index d08192974..1b898c9e0 100644 --- a/tests/TestCases/Member/StaticConstructors/Baseline.txt +++ b/tests/TestCases/Member/StaticConstructors/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // MemberTests.Behavior diff --git a/tests/TestCases/Statement/Exceptions/Baseline.txt b/tests/TestCases/Statement/Exceptions/Baseline.txt index 3683b795d..85802c9a3 100644 --- a/tests/TestCases/Statement/Exceptions/Baseline.txt +++ b/tests/TestCases/Statement/Exceptions/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // StatementTests.App diff --git a/tests/TestCases/Statement/Expression/Baseline.txt b/tests/TestCases/Statement/Expression/Baseline.txt index 027f21103..5ff279fa2 100644 --- a/tests/TestCases/Statement/Expression/Baseline.txt +++ b/tests/TestCases/Statement/Expression/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // StatementTests.App diff --git a/tests/TestCases/Statement/For/Baseline.txt b/tests/TestCases/Statement/For/Baseline.txt index 15bc96ffd..23e76bd77 100644 --- a/tests/TestCases/Statement/For/Baseline.txt +++ b/tests/TestCases/Statement/For/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // StatementTests.App diff --git a/tests/TestCases/Statement/Foreach/Baseline.txt b/tests/TestCases/Statement/Foreach/Baseline.txt index 24a4a3dd1..c583faca7 100644 --- a/tests/TestCases/Statement/Foreach/Baseline.txt +++ b/tests/TestCases/Statement/Foreach/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // StatementTests.Set diff --git a/tests/TestCases/Statement/IfElse/Baseline.txt b/tests/TestCases/Statement/IfElse/Baseline.txt index 90f79571e..c34a70d91 100644 --- a/tests/TestCases/Statement/IfElse/Baseline.txt +++ b/tests/TestCases/Statement/IfElse/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // StatementTests.App diff --git a/tests/TestCases/Statement/Return/Baseline.txt b/tests/TestCases/Statement/Return/Baseline.txt index b3ea0ecb9..24f836e25 100644 --- a/tests/TestCases/Statement/Return/Baseline.txt +++ b/tests/TestCases/Statement/Return/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // StatementTests.App diff --git a/tests/TestCases/Statement/Switch/Baseline.txt b/tests/TestCases/Statement/Switch/Baseline.txt index 78e3b9139..7c46e3920 100644 --- a/tests/TestCases/Statement/Switch/Baseline.txt +++ b/tests/TestCases/Statement/Switch/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // StatementTests.Mode diff --git a/tests/TestCases/Statement/Variables/Baseline.txt b/tests/TestCases/Statement/Variables/Baseline.txt index c0cc76410..ed5a65aba 100644 --- a/tests/TestCases/Statement/Variables/Baseline.txt +++ b/tests/TestCases/Statement/Variables/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // StatementTests.App diff --git a/tests/TestCases/Statement/While/Baseline.txt b/tests/TestCases/Statement/While/Baseline.txt index 232c6cace..065440736 100644 --- a/tests/TestCases/Statement/While/Baseline.txt +++ b/tests/TestCases/Statement/While/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // StatementTests.App diff --git a/tests/TestCases/Type/Classes/Baseline.txt b/tests/TestCases/Type/Classes/Baseline.txt index 05cd958a6..82de56c56 100644 --- a/tests/TestCases/Type/Classes/Baseline.txt +++ b/tests/TestCases/Type/Classes/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // TypeTests.Foo diff --git a/tests/TestCases/Type/Delegates/Baseline.txt b/tests/TestCases/Type/Delegates/Baseline.txt index bf7be2836..9823d2081 100644 --- a/tests/TestCases/Type/Delegates/Baseline.txt +++ b/tests/TestCases/Type/Delegates/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // TypeTests.EventArgs diff --git a/tests/TestCases/Type/Enumerator/Baseline.txt b/tests/TestCases/Type/Enumerator/Baseline.txt index 76c892a59..d1e676997 100644 --- a/tests/TestCases/Type/Enumerator/Baseline.txt +++ b/tests/TestCases/Type/Enumerator/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // TypeTests.App1 diff --git a/tests/TestCases/Type/Enums/Baseline.txt b/tests/TestCases/Type/Enums/Baseline.txt index 4124c4084..eff25c3dd 100644 --- a/tests/TestCases/Type/Enums/Baseline.txt +++ b/tests/TestCases/Type/Enums/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // TypeTests.Colors diff --git a/tests/TestCases/Type/Globals/Baseline.txt b/tests/TestCases/Type/Globals/Baseline.txt index 5d0927f9f..48c41463a 100644 --- a/tests/TestCases/Type/Globals/Baseline.txt +++ b/tests/TestCases/Type/Globals/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // MyEnum diff --git a/tests/TestCases/Type/Imported/Baseline.txt b/tests/TestCases/Type/Imported/Baseline.txt index b916da9cf..adfc6d1c6 100644 --- a/tests/TestCases/Type/Imported/Baseline.txt +++ b/tests/TestCases/Type/Imported/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // TypeTests.App diff --git a/tests/TestCases/Type/Interfaces/Baseline.txt b/tests/TestCases/Type/Interfaces/Baseline.txt index b7478f116..51e312fa9 100644 --- a/tests/TestCases/Type/Interfaces/Baseline.txt +++ b/tests/TestCases/Type/Interfaces/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // TypeTests.IMarker diff --git a/tests/TestCases/Type/Namespaces/Baseline.txt b/tests/TestCases/Type/Namespaces/Baseline.txt index 3e9726616..f78036678 100644 --- a/tests/TestCases/Type/Namespaces/Baseline.txt +++ b/tests/TestCases/Type/Namespaces/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // TypeTests.Sub1.Sub2.MyClass diff --git a/tests/TestCases/Type/Nullable/Baseline.txt b/tests/TestCases/Type/Nullable/Baseline.txt index c4ad80d25..328721e2d 100644 --- a/tests/TestCases/Type/Nullable/Baseline.txt +++ b/tests/TestCases/Type/Nullable/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // TypeTests.App diff --git a/tests/TestCases/Type/Partials/Baseline.txt b/tests/TestCases/Type/Partials/Baseline.txt index f3f0a81bd..01714b2c7 100644 --- a/tests/TestCases/Type/Partials/Baseline.txt +++ b/tests/TestCases/Type/Partials/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // TypeTests.IMyInterface diff --git a/tests/TestCases/Type/Records/Baseline.txt b/tests/TestCases/Type/Records/Baseline.txt index 5a35f1736..e3262a92c 100644 --- a/tests/TestCases/Type/Records/Baseline.txt +++ b/tests/TestCases/Type/Records/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // TypeTests.Point diff --git a/tests/TestCases/Type/UsingAlias/Baseline.txt b/tests/TestCases/Type/UsingAlias/Baseline.txt index 8908a027e..a1fc2057f 100644 --- a/tests/TestCases/Type/UsingAlias/Baseline.txt +++ b/tests/TestCases/Type/UsingAlias/Baseline.txt @@ -1,5 +1,6 @@ define('test', ['ss'], function(ss) { 'use strict'; + var $global = this; // TypeTests.MyClass From 3f0145caa4375e03c4fd3b3e90fc7e2fe6973ee4 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 16 Sep 2012 11:23:44 -0700 Subject: [PATCH 031/251] Changes related to global methods and extension classes. --- src/Core/Compiler/Utility.cs | 2 +- tests/ScriptSharp/ExpressionTests.cs | 14 +++++++------- .../Baseline.txt | 0 .../{GlobalMethods => ExtensionMethods}/Code.cs | 0 tests/TestCases/Validation/ScriptExtension/Code.cs | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) rename tests/TestCases/Expression/{GlobalMethods => ExtensionMethods}/Baseline.txt (100%) rename tests/TestCases/Expression/{GlobalMethods => ExtensionMethods}/Code.cs (100%) diff --git a/src/Core/Compiler/Utility.cs b/src/Core/Compiler/Utility.cs index 43ac5f924..a63978eed 100644 --- a/src/Core/Compiler/Utility.cs +++ b/src/Core/Compiler/Utility.cs @@ -32,7 +32,7 @@ internal static class Utility { "protected", "throws", "class", "final", "interface", "public", "transient", "const", "float", "long", "short", "volatile", // Script#-specific words - "ss" + "ss", "global" }; private static Hashtable _keywordTable; diff --git a/tests/ScriptSharp/ExpressionTests.cs b/tests/ScriptSharp/ExpressionTests.cs index 37a24a620..55f7db85a 100644 --- a/tests/ScriptSharp/ExpressionTests.cs +++ b/tests/ScriptSharp/ExpressionTests.cs @@ -89,23 +89,23 @@ public void TestEvents() { } [TestMethod] - public void TestGenerics() { + public void TestExtensionMethods() { RunTest((c) => { - c.AddReference("Script.Web.dll"). - AddReference("Script.jQuery.dll"). - AddSource("Code.cs"); + c.AddSource("Code.cs"); }); } [TestMethod] - public void TestGetType() { + public void TestGenerics() { RunTest((c) => { - c.AddSource("Code.cs"); + c.AddReference("Script.Web.dll"). + AddReference("Script.jQuery.dll"). + AddSource("Code.cs"); }); } [TestMethod] - public void TestGlobalMethods() { + public void TestGetType() { RunTest((c) => { c.AddSource("Code.cs"); }); diff --git a/tests/TestCases/Expression/GlobalMethods/Baseline.txt b/tests/TestCases/Expression/ExtensionMethods/Baseline.txt similarity index 100% rename from tests/TestCases/Expression/GlobalMethods/Baseline.txt rename to tests/TestCases/Expression/ExtensionMethods/Baseline.txt diff --git a/tests/TestCases/Expression/GlobalMethods/Code.cs b/tests/TestCases/Expression/ExtensionMethods/Code.cs similarity index 100% rename from tests/TestCases/Expression/GlobalMethods/Code.cs rename to tests/TestCases/Expression/ExtensionMethods/Code.cs diff --git a/tests/TestCases/Validation/ScriptExtension/Code.cs b/tests/TestCases/Validation/ScriptExtension/Code.cs index 366d8891d..2702ff49c 100644 --- a/tests/TestCases/Validation/ScriptExtension/Code.cs +++ b/tests/TestCases/Validation/ScriptExtension/Code.cs @@ -11,9 +11,9 @@ public static class A { } [ScriptExtension("$global")] - public static class A { + public static class B { - static A() { + static B() { } } } From d71ab2ffcd32bcbfed9386110793aac3f42566ee Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 16 Sep 2012 11:26:36 -0700 Subject: [PATCH 032/251] Added ScriptModule functionality --- src/Core/Compiler/Compiler/MetadataBuilder.cs | 5 +++ .../Compiler/Generator/ScriptGenerator.cs | 10 ++++-- src/Core/Compiler/Generator/TypeGenerator.cs | 6 ++++ .../ScriptModel/Symbols/ClassSymbol.cs | 11 +++++++ .../Validator/CustomTypeNodeValidator.cs | 27 ++++++++++------ src/Core/CoreLib/ScriptMetadata.cs | 6 ++++ src/ZipX/ItemTemplates/Page/Page.cs | 13 +++----- src/ZipX/ItemTemplates/jQueryPage/Page.cs | 17 +++++----- tests/ScriptSharp/TypeTests.cs | 8 +++++ tests/ScriptSharp/ValidationTests.cs | 31 +++++++++++++++++-- tests/TestCases/Type/Modules/Baseline.txt | 13 ++++++++ tests/TestCases/Type/Modules/Code.cs | 26 ++++++++++++++++ tests/TestCases/Validation/Modules/Code.cs | 22 +++++++++++++ 13 files changed, 162 insertions(+), 33 deletions(-) create mode 100644 tests/TestCases/Type/Modules/Baseline.txt create mode 100644 tests/TestCases/Type/Modules/Code.cs create mode 100644 tests/TestCases/Validation/Modules/Code.cs diff --git a/src/Core/Compiler/Compiler/MetadataBuilder.cs b/src/Core/Compiler/Compiler/MetadataBuilder.cs index 21c1d0212..0154bf8da 100644 --- a/src/Core/Compiler/Compiler/MetadataBuilder.cs +++ b/src/Core/Compiler/Compiler/MetadataBuilder.cs @@ -736,6 +736,11 @@ private void BuildType(TypeSymbol typeSymbol, UserTypeNode typeNode) { ((ClassSymbol)typeSymbol).SetExtenderClass(extendee); } + + AttributeNode moduleAttribute = AttributeNode.FindAttribute(attributes, "ScriptModule"); + if (moduleAttribute != null) { + ((ClassSymbol)typeSymbol).SetModuleClass(); + } } if (typeNode.Type == TokenType.Enum) { diff --git a/src/Core/Compiler/Generator/ScriptGenerator.cs b/src/Core/Compiler/Generator/ScriptGenerator.cs index 2efe3e7bd..c347a1f60 100644 --- a/src/Core/Compiler/Generator/ScriptGenerator.cs +++ b/src/Core/Compiler/Generator/ScriptGenerator.cs @@ -62,6 +62,8 @@ public void GenerateScript(SymbolSet symbolSet) { List publicTypes = new List(); List internalTypes = new List(); + bool hasNonModuleInternalTypes = false; + foreach (NamespaceSymbol namespaceSymbol in symbolSet.Namespaces) { if (namespaceSymbol.HasApplicationTypes) { foreach (TypeSymbol type in namespaceSymbol.Types) { @@ -88,6 +90,10 @@ public void GenerateScript(SymbolSet symbolSet) { publicTypes.Add(type); } else { + if ((type.Type != SymbolType.Class) || + (((ClassSymbol)type).IsModuleClass == false)) { + hasNonModuleInternalTypes = true; + } internalTypes.Add(type); } } @@ -140,7 +146,7 @@ public void GenerateScript(SymbolSet symbolSet) { _writer.Write("var $" + moduleName + " = ss.module('"); _writer.Write(symbolSet.ScriptName); _writer.Write("',"); - if (internalTypes.Count != 0) { + if ((internalTypes.Count != 0) && hasNonModuleInternalTypes) { _writer.WriteLine(); _writer.Indent++; _writer.WriteLine("{"); @@ -148,7 +154,7 @@ public void GenerateScript(SymbolSet symbolSet) { bool firstType = true; foreach (TypeSymbol type in internalTypes) { if ((type.Type == SymbolType.Class) && - ((ClassSymbol)type).IsExtenderClass) { + (((ClassSymbol)type).IsExtenderClass || ((ClassSymbol)type).IsModuleClass)) { continue; } if ((type.Type == SymbolType.Record) && diff --git a/src/Core/Compiler/Generator/TypeGenerator.cs b/src/Core/Compiler/Generator/TypeGenerator.cs index 994357a4a..9bad6b18b 100644 --- a/src/Core/Compiler/Generator/TypeGenerator.cs +++ b/src/Core/Compiler/Generator/TypeGenerator.cs @@ -340,6 +340,12 @@ public static void GenerateScript(ScriptGenerator generator, TypeSymbol typeSymb return; } + if ((typeSymbol.Type == SymbolType.Class) && + ((ClassSymbol)typeSymbol).IsModuleClass) { + // No members on script modules, which only contain startup code + return; + } + ScriptTextWriter writer = generator.Writer; writer.WriteLine("// " + typeSymbol.FullName); diff --git a/src/Core/Compiler/ScriptModel/Symbols/ClassSymbol.cs b/src/Core/Compiler/ScriptModel/Symbols/ClassSymbol.cs index e6d2a6263..5db1ecd27 100644 --- a/src/Core/Compiler/ScriptModel/Symbols/ClassSymbol.cs +++ b/src/Core/Compiler/ScriptModel/Symbols/ClassSymbol.cs @@ -25,6 +25,7 @@ internal class ClassSymbol : TypeSymbol { private string _extendee; private bool _testClass; + private bool _moduleClass; private ClassSymbol _primaryPartialClass; @@ -117,6 +118,12 @@ public bool IsExtenderClass { } } + public bool IsModuleClass { + get { + return _moduleClass; + } + } + public bool IsTestClass { get { if (_primaryPartialClass != null) { @@ -285,6 +292,10 @@ public void SetInheritance(ClassSymbol baseClass, ICollection i _interfaces = interfaces; } + public void SetModuleClass() { + _moduleClass = true; + } + public void SetPrimaryPartialClass(ClassSymbol primaryPartialClass) { Debug.Assert(_primaryPartialClass == null); Debug.Assert(primaryPartialClass != null); diff --git a/src/Core/Compiler/Validator/CustomTypeNodeValidator.cs b/src/Core/Compiler/Validator/CustomTypeNodeValidator.cs index a8da8d5e5..ec4bc90eb 100644 --- a/src/Core/Compiler/Validator/CustomTypeNodeValidator.cs +++ b/src/Core/Compiler/Validator/CustomTypeNodeValidator.cs @@ -19,6 +19,7 @@ bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErro CustomTypeNode typeNode = (CustomTypeNode)node; bool restrictToMethodMembers = false; + bool restrictToCtors = false; bool hasCodeMembers = false; ParseNode codeMemberNode = null; @@ -31,16 +32,6 @@ bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErro return false; } - AttributeNode scriptNamespaceNode = AttributeNode.FindAttribute(typeNode.Attributes, "ScriptNamespace"); - if (scriptNamespaceNode != null) { - string scriptNamespace = (string)((LiteralNode)scriptNamespaceNode.Arguments[0]).Value; - - if (Utility.IsValidScriptNamespace(scriptNamespace) == false) { - errorHandler.ReportError("A script namespace must be a valid script identifier.", - scriptNamespaceNode.Token.Location); - } - } - if (typeNode.Type == TokenType.Struct) { errorHandler.ReportError("Struct types are not supported. Use classes annotated with the Record metadata attribute.", typeNode.Token.Location); @@ -115,6 +106,17 @@ bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErro typeNode.Token.Location); } } + + AttributeNode moduleAttribute = AttributeNode.FindAttribute(typeNode.Attributes, "ScriptModule"); + if (moduleAttribute != null) { + restrictToCtors = true; + + if (((typeNode.Modifiers & Modifiers.Static) == 0) || + ((typeNode.Modifiers & Modifiers.Internal) == 0)) { + errorHandler.ReportError("ScriptModule attribute can only be set on internal static classes.", + typeNode.Token.Location); + } + } } if ((typeNode.Members != null) && (typeNode.Members.Count != 0)) { @@ -140,6 +142,11 @@ bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErro memberNode.Token.Location); } + if (restrictToCtors && (memberNode.NodeType != ParseNodeType.ConstructorDeclaration)) { + errorHandler.ReportError("Classes marked with ScriptModule attribute should only have a static constructor.", + memberNode.Token.Location); + } + if (memberNode.NodeType == ParseNodeType.ConstructorDeclaration) { if ((memberNode.Modifiers & Modifiers.Static) == 0) { if (hasCtor) { diff --git a/src/Core/CoreLib/ScriptMetadata.cs b/src/Core/CoreLib/ScriptMetadata.cs index 487ad444e..c847c48d1 100644 --- a/src/Core/CoreLib/ScriptMetadata.cs +++ b/src/Core/CoreLib/ScriptMetadata.cs @@ -117,6 +117,12 @@ public string Expression { } } + [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + [NonScriptable] + [Imported] + public sealed class ScriptModuleAttribute : Attribute { + } + /// /// This attribute marks an enumeration type within a system assembly as as a set of /// names. Rather than the specific value, the name of the enumeration field is diff --git a/src/ZipX/ItemTemplates/Page/Page.cs b/src/ZipX/ItemTemplates/Page/Page.cs index 280d9c34c..e277bc687 100644 --- a/src/ZipX/ItemTemplates/Page/Page.cs +++ b/src/ZipX/ItemTemplates/Page/Page.cs @@ -6,15 +6,12 @@ using System.Html; using System.Runtime.CompilerServices; -namespace $rootnamespace$ +[ScriptModule] +internal static class $safeitemrootname$ { - [GlobalMethods] - internal static class $safeitemrootname$ + static $safeitemrootname$() { - static $safeitemrootname$() - { - // Add script that runs on startup as the script is loaded into - // the page - } + // Add script that runs on startup as the script is loaded into + // the page } } diff --git a/src/ZipX/ItemTemplates/jQueryPage/Page.cs b/src/ZipX/ItemTemplates/jQueryPage/Page.cs index 4857fa966..8530a6c66 100644 --- a/src/ZipX/ItemTemplates/jQueryPage/Page.cs +++ b/src/ZipX/ItemTemplates/jQueryPage/Page.cs @@ -7,17 +7,14 @@ using System.Runtime.CompilerServices; using jQueryApi; -namespace $rootnamespace$ +[ScriptModule] +internal static class $safeitemrootname$ { - [GlobalMethods] - internal static class $safeitemrootname$ + static $safeitemrootname$() { - static $safeitemrootname$() - { - jQuery.OnDocumentReady(delegate() { - // Add script that runs once the document is ready for being - // consumed by script. - }); - } + jQuery.OnDocumentReady(delegate() { + // Add script that runs once the document is ready for being + // consumed by script. + }); } } diff --git a/tests/ScriptSharp/TypeTests.cs b/tests/ScriptSharp/TypeTests.cs index 15af0e2d8..c2e842fd8 100644 --- a/tests/ScriptSharp/TypeTests.cs +++ b/tests/ScriptSharp/TypeTests.cs @@ -76,6 +76,14 @@ public void TestNamespaces() { }); } + [TestMethod] + public void TestModules() { + RunTest((c) => { + c.AddReference("Script.Web.dll"). + AddSource("Code.cs"); + }); + } + [TestMethod] public void TestNullable() { RunTest((c) => { diff --git a/tests/ScriptSharp/ValidationTests.cs b/tests/ScriptSharp/ValidationTests.cs index b7463b2b7..e6196ca93 100644 --- a/tests/ScriptSharp/ValidationTests.cs +++ b/tests/ScriptSharp/ValidationTests.cs @@ -160,6 +160,31 @@ public void TestKeywords() { } } + [TestMethod] + public void TestModules() { + string expectedErrors = + "ScriptModule attribute can only be set on internal static classes. Code.cs(9, 5)" + Environment.NewLine + + "Classes marked with ScriptModule attribute should only have a static constructor. Code.cs(19, 9)"; + + Compilation compilation = CreateCompilation(); + compilation.AddSource("Code.cs"); + + bool result = compilation.Execute(); + Assert.IsFalse(result, "Expected compilation to fail."); + + Assert.IsTrue(compilation.HasErrors, "Expected compilation to fail with errors."); + if (String.CompareOrdinal(compilation.ErrorMessages, expectedErrors) != 0) { + Console.WriteLine("Expected Errors:"); + Console.WriteLine(expectedErrors); + Console.WriteLine(); + Console.WriteLine("Actual Errors:"); + Console.WriteLine(compilation.ErrorMessages); + Console.WriteLine(); + + Assert.Fail("Unexpected errors."); + } + } + [TestMethod] public void TestNestedTypes() { string expectedErrors = @@ -237,7 +262,7 @@ public void TestProperties() { [TestMethod] public void TestScriptExtension() { - string expectedErrors1 = + string expectedErrors = "ScriptExtension attribute declaration must specify the object being extended. Code.cs(9, 5)" + Environment.NewLine + "Classes marked with ScriptExtension attribute should only have methods. Code.cs(16, 9)"; @@ -248,9 +273,9 @@ public void TestScriptExtension() { Assert.IsFalse(result, "Expected compilation to fail."); Assert.IsTrue(compilation.HasErrors, "Expected compilation to fail with errors."); - if (String.CompareOrdinal(compilation.ErrorMessages, expectedErrors1) != 0) { + if (String.CompareOrdinal(compilation.ErrorMessages, expectedErrors) != 0) { Console.WriteLine("Expected Errors:"); - Console.WriteLine(expectedErrors1); + Console.WriteLine(expectedErrors); Console.WriteLine(); Console.WriteLine("Actual Errors:"); Console.WriteLine(compilation.ErrorMessages); diff --git a/tests/TestCases/Type/Modules/Baseline.txt b/tests/TestCases/Type/Modules/Baseline.txt new file mode 100644 index 000000000..3ea4b5078 --- /dev/null +++ b/tests/TestCases/Type/Modules/Baseline.txt @@ -0,0 +1,13 @@ +define('test', ['ss'], function(ss) { + 'use strict'; + var $global = this; + + var $test = ss.module('test', null, null); + + alert('Hello Startup'); + window.addEventListener('load', function(e) { + alert('Loaded'); + }, false); + + return $test; +}); diff --git a/tests/TestCases/Type/Modules/Code.cs b/tests/TestCases/Type/Modules/Code.cs new file mode 100644 index 000000000..b62b829ff --- /dev/null +++ b/tests/TestCases/Type/Modules/Code.cs @@ -0,0 +1,26 @@ +using System; +using System.Html; +using System.Runtime.CompilerServices; + +[assembly: ScriptAssembly("test")] + +[ScriptModule] +internal static class Startup { + + static Startup() { + Window.Alert("Hello Startup"); + } +} + +namespace App { + + [ScriptModule] + internal static class Main { + + static Main() { + Window.AddEventListener("load", delegate(ElementEvent e) { + Window.Alert("Loaded"); + }, false); + } + } +} diff --git a/tests/TestCases/Validation/Modules/Code.cs b/tests/TestCases/Validation/Modules/Code.cs new file mode 100644 index 000000000..be804c28a --- /dev/null +++ b/tests/TestCases/Validation/Modules/Code.cs @@ -0,0 +1,22 @@ +using System; +using System.Runtime.CompilerServices; + +[assembly: ScriptAssembly("test")] + + +namespace ValidationTests { + + [ScriptModule] + public static class A { + } + + [ScriptModule] + internal static class B { + + static B() { + } + + public static void Foo() { + } + } +} From 823adfb57c152ba72dbc7e12fb12eafbd3bfa72d Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 16 Sep 2012 17:29:34 -0700 Subject: [PATCH 033/251] Support for using jQuery as a module. --- src/Core/Compiler/Generator/ScriptGenerator.cs | 12 +++++++++++- src/Core/Scripts/Loader.js | 8 ++++++-- .../jQuery/jQuery.Core/Properties/AssemblyInfo.cs | 2 +- .../jQuery/jQuery.History/Properties/AssemblyInfo.cs | 2 +- .../jQuery.Templating/Properties/AssemblyInfo.cs | 2 +- .../jQuery/jQuery.UI/Properties/AssemblyInfo.cs | 2 +- .../jQuery.Validation/Properties/AssemblyInfo.cs | 2 +- tests/TestCases/Library/jQuery/Baseline.txt | 2 +- 8 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/Core/Compiler/Generator/ScriptGenerator.cs b/src/Core/Compiler/Generator/ScriptGenerator.cs index c347a1f60..1b6643f62 100644 --- a/src/Core/Compiler/Generator/ScriptGenerator.cs +++ b/src/Core/Compiler/Generator/ScriptGenerator.cs @@ -129,7 +129,17 @@ public void GenerateScript(SymbolSet symbolSet) { if (firstDependency == false) { _writer.Write(", "); } - _writer.Write(dependency); + + if (String.Compare(dependency, "jquery", StringComparison.OrdinalIgnoreCase) == 0) { + // TODO: This is a hack ... may want to generalize + // to allow module name and associated variable + // to differ. + _writer.Write("$"); + } + else { + _writer.Write(dependency); + } + firstDependency = false; } diff --git a/src/Core/Scripts/Loader.js b/src/Core/Scripts/Loader.js index 391122d88..52f4faf22 100644 --- a/src/Core/Scripts/Loader.js +++ b/src/Core/Scripts/Loader.js @@ -269,13 +269,17 @@ }); } - global.require = require; - global.define = function(name, dependencyNames, callback) { + function define(name, dependencyNames, callback) { require(dependencyNames, function() { _completeModule(name, callback.apply(global, arguments)); }); } + // Enable using this loader to load jQuery (1.7+) as well. + define.amd = { jquery: true }; + + global.require = require; + global.define = define; // Bootstrapping // If the document has already loaded (i.e. when this script was diff --git a/src/Libraries/jQuery/jQuery.Core/Properties/AssemblyInfo.cs b/src/Libraries/jQuery/jQuery.Core/Properties/AssemblyInfo.cs index 4eaeaee8d..df6006f82 100644 --- a/src/Libraries/jQuery/jQuery.Core/Properties/AssemblyInfo.cs +++ b/src/Libraries/jQuery/jQuery.Core/Properties/AssemblyInfo.cs @@ -9,4 +9,4 @@ [assembly: AssemblyTitle("Script.jQuery")] [assembly: AssemblyDescription("Script# jQuery Core API")] -[assembly: ScriptAssembly("jQuery")] +[assembly: ScriptAssembly("jquery")] diff --git a/src/Libraries/jQuery/jQuery.History/Properties/AssemblyInfo.cs b/src/Libraries/jQuery/jQuery.History/Properties/AssemblyInfo.cs index 7b02d552c..5ae28f0a4 100644 --- a/src/Libraries/jQuery/jQuery.History/Properties/AssemblyInfo.cs +++ b/src/Libraries/jQuery/jQuery.History/Properties/AssemblyInfo.cs @@ -9,4 +9,4 @@ [assembly: AssemblyTitle("Script.jQuery.History")] [assembly: AssemblyDescription("Script# jQuery BBQ/History Plugin")] -[assembly: ScriptAssembly("jQueryBBQ")] +[assembly: ScriptAssembly("jqueryBBQ")] diff --git a/src/Libraries/jQuery/jQuery.Templating/Properties/AssemblyInfo.cs b/src/Libraries/jQuery/jQuery.Templating/Properties/AssemblyInfo.cs index b7b55b0d7..28d063181 100644 --- a/src/Libraries/jQuery/jQuery.Templating/Properties/AssemblyInfo.cs +++ b/src/Libraries/jQuery/jQuery.Templating/Properties/AssemblyInfo.cs @@ -9,4 +9,4 @@ [assembly: AssemblyTitle("Script.jQuery.Templating")] [assembly: AssemblyDescription("Script# jQuery Templates Plugin")] -[assembly: ScriptAssembly("jQueryTmpl")] +[assembly: ScriptAssembly("jqueryTmpl")] diff --git a/src/Libraries/jQuery/jQuery.UI/Properties/AssemblyInfo.cs b/src/Libraries/jQuery/jQuery.UI/Properties/AssemblyInfo.cs index 4850b6396..1194f2294 100644 --- a/src/Libraries/jQuery/jQuery.UI/Properties/AssemblyInfo.cs +++ b/src/Libraries/jQuery/jQuery.UI/Properties/AssemblyInfo.cs @@ -10,4 +10,4 @@ [assembly: AssemblyTitle("Script.jQuery.UI")] [assembly: AssemblyDescription("Script# jQuery UI Plugin")] -[assembly: ScriptAssembly("jQueryUI")] +[assembly: ScriptAssembly("jqueryUI")] diff --git a/src/Libraries/jQuery/jQuery.Validation/Properties/AssemblyInfo.cs b/src/Libraries/jQuery/jQuery.Validation/Properties/AssemblyInfo.cs index 08aff32e5..26755acc7 100644 --- a/src/Libraries/jQuery/jQuery.Validation/Properties/AssemblyInfo.cs +++ b/src/Libraries/jQuery/jQuery.Validation/Properties/AssemblyInfo.cs @@ -9,4 +9,4 @@ [assembly: AssemblyTitle("Script.jQuery.Validation")] [assembly: AssemblyDescription("Script# jQuery Validation Plugin")] -[assembly: ScriptAssembly("jQueryValidation")] +[assembly: ScriptAssembly("jqueryValidation")] diff --git a/tests/TestCases/Library/jQuery/Baseline.txt b/tests/TestCases/Library/jQuery/Baseline.txt index 09b6f1738..e1e9f1878 100644 --- a/tests/TestCases/Library/jQuery/Baseline.txt +++ b/tests/TestCases/Library/jQuery/Baseline.txt @@ -1,4 +1,4 @@ -define('test', ['ss', 'jQuery'], function(ss, jQuery) { +define('test', ['ss', 'jquery'], function(ss, $) { 'use strict'; var $global = this; From 459ff963f5fc0554674e2c1c55ef209fca38ec0a Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 16 Sep 2012 18:07:19 -0700 Subject: [PATCH 034/251] Update version to 0.8 --- src/Core/Build/ScriptSharp.targets | 4 +--- src/Core/Scripts/Runtime.js | 2 +- src/ScriptSharp.cs | 4 ++-- src/ScriptSharp.sln | 16 ---------------- src/ZipX/ItemTemplates/Class/Class.vstemplate | 4 ++-- src/ZipX/ItemTemplates/Page/Page.vstemplate | 4 ++-- .../ItemTemplates/Resource/Resource.vstemplate | 2 +- .../ItemTemplates/TestClass/TestClass.vstemplate | 4 ++-- .../jQueryPage/jQueryPage.vstemplate | 6 +++--- .../jQueryPlugin/jQueryPlugin.vstemplate | 6 +++--- src/ZipX/Packages/Core.nuspec | 2 +- src/ZipX/Packages/FxCop.nuspec | 2 +- src/ZipX/Packages/Lib.BingMaps.nuspec | 6 +++--- src/ZipX/Packages/Lib.HTML.nuspec | 4 ++-- src/ZipX/Packages/Lib.Knockout.nuspec | 6 +++--- src/ZipX/Packages/Lib.jQuery.History.nuspec | 8 ++++---- src/ZipX/Packages/Lib.jQuery.Templating.nuspec | 8 ++++---- src/ZipX/Packages/Lib.jQuery.UI.nuspec | 8 ++++---- src/ZipX/Packages/Lib.jQuery.Validation.nuspec | 8 ++++---- src/ZipX/Packages/Lib.jQuery.nuspec | 6 +++--- src/ZipX/Packages/Runtime.nuspec | 2 +- src/ZipX/Packages/Testing.nuspec | 2 +- .../ClassLibrary/ClassLibrary.vstemplate | 4 ++-- .../ImportLibrary/ImportLibrary.vstemplate | 4 ++-- .../jQueryClassLibrary.vstemplate | 6 +++--- src/ZipX/VSIX/Extension.vsixmanifest | 2 +- 26 files changed, 56 insertions(+), 74 deletions(-) diff --git a/src/Core/Build/ScriptSharp.targets b/src/Core/Build/ScriptSharp.targets index bc79c2d90..626f1f722 100644 --- a/src/Core/Build/ScriptSharp.targets +++ b/src/Core/Build/ScriptSharp.targets @@ -25,7 +25,7 @@ Copyright (C) 2012. Script# Project. All rights reserved. - + $(MSBuildThisFileDirectory)mscorlib.dll @@ -39,8 +39,6 @@ Copyright (C) 2012. Script# Project. All rights reserved. Defines="$(DefineConstants)" OutputPath="$(OutputPath)" DeploymentPath="$(DeploymentPath)" - LocaleSubFolders="$(LocaleSubFolders)" - ConfigSubFolders="$(ConfigSubFolders)" Template="$(ScriptTemplate)" CSharpAssembly="@(IntermediateAssembly)" DocumentationFile="$(DocumentationFile)" diff --git a/src/Core/Scripts/Runtime.js b/src/Core/Scripts/Runtime.js index 8809bc6c0..16e5478c7 100644 --- a/src/Core/Scripts/Runtime.js +++ b/src/Core/Scripts/Runtime.js @@ -51,7 +51,7 @@ var ss = module('ss', null, { EventArgs.Empty = new EventArgs(); return extend(ss, { - version: '0.7.6.0', + version: '0.8', isUndefined: isUndefined, isNull: isNull, diff --git a/src/ScriptSharp.cs b/src/ScriptSharp.cs index 12a97f09c..245a06b2d 100644 --- a/src/ScriptSharp.cs +++ b/src/ScriptSharp.cs @@ -12,6 +12,6 @@ [assembly: AssemblyCopyright("Copyright © 2012")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("0.7.0.0")] -[assembly: AssemblyFileVersion("0.7.6.0")] +[assembly: AssemblyVersion("0.8.0.0")] +[assembly: AssemblyFileVersion("0.8.0.0")] [assembly: CLSCompliant(true)] diff --git a/src/ScriptSharp.sln b/src/ScriptSharp.sln index ed90c47b3..498ce19fb 100644 --- a/src/ScriptSharp.sln +++ b/src/ScriptSharp.sln @@ -36,7 +36,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZipX", "ZipX\ZipX.csproj", {36D4B098-A21C-4725-ACD3-400922885F38} = {36D4B098-A21C-4725-ACD3-400922885F38} {4A9F7CE0-5A45-4B28-AD01-05528709B6E4} = {4A9F7CE0-5A45-4B28-AD01-05528709B6E4} {824C1FEC-2455-4183-AFC6-891EDB88213A} = {824C1FEC-2455-4183-AFC6-891EDB88213A} - {8780581F-7C26-4B64-9235-BA1C458DF36E} = {8780581F-7C26-4B64-9235-BA1C458DF36E} {9600C55B-E14E-45EA-92C6-F453B19F5D7F} = {9600C55B-E14E-45EA-92C6-F453B19F5D7F} {967A6FD7-E14B-4DB0-81D9-86E0DC12291A} = {967A6FD7-E14B-4DB0-81D9-86E0DC12291A} {B87E403B-354D-47A1-9876-14C618A80A41} = {B87E403B-354D-47A1-9876-14C618A80A41} @@ -49,8 +48,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jQuery.Validation", "Librar EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{D1DF352A-45B6-4130-9A8B-A24C20257B7D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreScript", "Core\CoreScript\CoreScript.csproj", "{8780581F-7C26-4B64-9235-BA1C458DF36E}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jQuery.UI", "Libraries\jQuery\jQuery.UI\jQuery.UI.csproj", "{824C1FEC-2455-4183-AFC6-891EDB88213A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Other", "Other", "{BB2DB888-0F52-4CB5-9625-9D99A33DCE4F}" @@ -227,18 +224,6 @@ Global {967A6FD7-E14B-4DB0-81D9-86E0DC12291A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {967A6FD7-E14B-4DB0-81D9-86E0DC12291A}.Release|Mixed Platforms.Build.0 = Release|Any CPU {967A6FD7-E14B-4DB0-81D9-86E0DC12291A}.Release|x86.ActiveCfg = Release|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|.NET.ActiveCfg = Debug|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Debug|x86.ActiveCfg = Debug|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|.NET.ActiveCfg = Release|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|Any CPU.Build.0 = Release|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {8780581F-7C26-4B64-9235-BA1C458DF36E}.Release|x86.ActiveCfg = Release|Any CPU {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|.NET.ActiveCfg = Debug|Any CPU {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {824C1FEC-2455-4183-AFC6-891EDB88213A}.Debug|Any CPU.Build.0 = Debug|Any CPU @@ -291,7 +276,6 @@ Global {1772A38C-7204-42DC-B81D-6C74D17A4F66} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} {BE1E0A21-F6C0-4698-B405-66FC2BB289F4} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} {36D4B098-A21C-4725-ACD3-400922885F38} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} - {8780581F-7C26-4B64-9235-BA1C458DF36E} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} {9F14036F-673F-418E-B817-7E2289D7F3F6} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} {8780581F-7C26-4B64-9236-BA1C458DF36E} = {D1DF352A-45B6-4130-9A8B-A24C20257B7D} {31456150-1093-407F-9231-58D0F663945D} = {37239BB8-2FA4-4831-A7EA-AF89D74EA10E} diff --git a/src/ZipX/ItemTemplates/Class/Class.vstemplate b/src/ZipX/ItemTemplates/Class/Class.vstemplate index a42726b37..60283a6d0 100644 --- a/src/ZipX/ItemTemplates/Class/Class.vstemplate +++ b/src/ZipX/ItemTemplates/Class/Class.vstemplate @@ -16,8 +16,8 @@ - - + + diff --git a/src/ZipX/ItemTemplates/Page/Page.vstemplate b/src/ZipX/ItemTemplates/Page/Page.vstemplate index 2453c27dd..1f3c53851 100644 --- a/src/ZipX/ItemTemplates/Page/Page.vstemplate +++ b/src/ZipX/ItemTemplates/Page/Page.vstemplate @@ -16,8 +16,8 @@ - - + + diff --git a/src/ZipX/ItemTemplates/Resource/Resource.vstemplate b/src/ZipX/ItemTemplates/Resource/Resource.vstemplate index 85348ed33..1f742bf00 100644 --- a/src/ZipX/ItemTemplates/Resource/Resource.vstemplate +++ b/src/ZipX/ItemTemplates/Resource/Resource.vstemplate @@ -21,7 +21,7 @@ - + diff --git a/src/ZipX/ItemTemplates/TestClass/TestClass.vstemplate b/src/ZipX/ItemTemplates/TestClass/TestClass.vstemplate index 857f9edeb..eb9530e43 100644 --- a/src/ZipX/ItemTemplates/TestClass/TestClass.vstemplate +++ b/src/ZipX/ItemTemplates/TestClass/TestClass.vstemplate @@ -16,8 +16,8 @@ - - + + diff --git a/src/ZipX/ItemTemplates/jQueryPage/jQueryPage.vstemplate b/src/ZipX/ItemTemplates/jQueryPage/jQueryPage.vstemplate index 3b15dc4c7..3a06a21aa 100644 --- a/src/ZipX/ItemTemplates/jQueryPage/jQueryPage.vstemplate +++ b/src/ZipX/ItemTemplates/jQueryPage/jQueryPage.vstemplate @@ -16,9 +16,9 @@ - - - + + + diff --git a/src/ZipX/ItemTemplates/jQueryPlugin/jQueryPlugin.vstemplate b/src/ZipX/ItemTemplates/jQueryPlugin/jQueryPlugin.vstemplate index d68b576b1..e9baaf51d 100644 --- a/src/ZipX/ItemTemplates/jQueryPlugin/jQueryPlugin.vstemplate +++ b/src/ZipX/ItemTemplates/jQueryPlugin/jQueryPlugin.vstemplate @@ -16,9 +16,9 @@ - - - + + + diff --git a/src/ZipX/Packages/Core.nuspec b/src/ZipX/Packages/Core.nuspec index 235503e7c..564de16ff 100644 --- a/src/ZipX/Packages/Core.nuspec +++ b/src/ZipX/Packages/Core.nuspec @@ -2,7 +2,7 @@ ScriptSharp - 0.7.6.0 + 0.8 Script# Nikhil Kothari Copyright (c) 2012, Nikhil Kothari diff --git a/src/ZipX/Packages/FxCop.nuspec b/src/ZipX/Packages/FxCop.nuspec index 3cc91c2e7..bf059e382 100644 --- a/src/ZipX/Packages/FxCop.nuspec +++ b/src/ZipX/Packages/FxCop.nuspec @@ -2,7 +2,7 @@ ScriptSharp.FxCop - 0.7.6.0 + 0.8 Script# FxCop Rules Nikhil Kothari Copyright (c) 2012, Nikhil Kothari diff --git a/src/ZipX/Packages/Lib.BingMaps.nuspec b/src/ZipX/Packages/Lib.BingMaps.nuspec index 569955241..c39b1171e 100644 --- a/src/ZipX/Packages/Lib.BingMaps.nuspec +++ b/src/ZipX/Packages/Lib.BingMaps.nuspec @@ -2,7 +2,7 @@ ScriptSharp.Lib.BingMaps - 0.7.6.0 + 0.8 Script# Bing Maps Reference Assembly Nikhil Kothari Copyright (c) 2012, Nikhil Kothari @@ -17,8 +17,8 @@ en-US false - - + + diff --git a/src/ZipX/Packages/Lib.HTML.nuspec b/src/ZipX/Packages/Lib.HTML.nuspec index 7a2a0a662..2b0cb6dfe 100644 --- a/src/ZipX/Packages/Lib.HTML.nuspec +++ b/src/ZipX/Packages/Lib.HTML.nuspec @@ -2,7 +2,7 @@ ScriptSharp.Lib.HTML - 0.7.6.0 + 0.8 Script# HTML5 Reference Assembly Nikhil Kothari Copyright (c) 2012, Nikhil Kothari @@ -17,7 +17,7 @@ en-US false - + diff --git a/src/ZipX/Packages/Lib.Knockout.nuspec b/src/ZipX/Packages/Lib.Knockout.nuspec index 15fe9e218..653eea6b8 100644 --- a/src/ZipX/Packages/Lib.Knockout.nuspec +++ b/src/ZipX/Packages/Lib.Knockout.nuspec @@ -2,7 +2,7 @@ ScriptSharp.Lib.Knockout - 0.7.6.0 + 0.8 Script# Knockout Reference Assembly Nikhil Kothari Copyright (c) 2012, Nikhil Kothari @@ -17,8 +17,8 @@ en-US false - - + + diff --git a/src/ZipX/Packages/Lib.jQuery.History.nuspec b/src/ZipX/Packages/Lib.jQuery.History.nuspec index 3b2b4fed9..d6e5cd4d8 100644 --- a/src/ZipX/Packages/Lib.jQuery.History.nuspec +++ b/src/ZipX/Packages/Lib.jQuery.History.nuspec @@ -2,7 +2,7 @@ ScriptSharp.Lib.jQuery.History - 0.7.6.0 + 0.8 Script# jQuery History (BBQ plugin) Reference Assembly Nikhil Kothari Copyright (c) 2012, Nikhil Kothari @@ -17,9 +17,9 @@ en-US false - - - + + + diff --git a/src/ZipX/Packages/Lib.jQuery.Templating.nuspec b/src/ZipX/Packages/Lib.jQuery.Templating.nuspec index 1fecf0eae..8c0bc7bb1 100644 --- a/src/ZipX/Packages/Lib.jQuery.Templating.nuspec +++ b/src/ZipX/Packages/Lib.jQuery.Templating.nuspec @@ -2,7 +2,7 @@ ScriptSharp.Lib.jQuery.Templating - 0.7.6.0 + 0.8 Script# jQuery Templating Reference Assembly Nikhil Kothari Copyright (c) 2012, Nikhil Kothari @@ -17,9 +17,9 @@ en-US false - - - + + + diff --git a/src/ZipX/Packages/Lib.jQuery.UI.nuspec b/src/ZipX/Packages/Lib.jQuery.UI.nuspec index e824d65d9..26b9e51ea 100644 --- a/src/ZipX/Packages/Lib.jQuery.UI.nuspec +++ b/src/ZipX/Packages/Lib.jQuery.UI.nuspec @@ -2,7 +2,7 @@ ScriptSharp.Lib.jQuery.UI - 0.7.6.0 + 0.8 Script# jQueryUI Reference Assembly Nikhil Kothari Copyright (c) 2012, Nikhil Kothari @@ -17,9 +17,9 @@ en-US false - - - + + + diff --git a/src/ZipX/Packages/Lib.jQuery.Validation.nuspec b/src/ZipX/Packages/Lib.jQuery.Validation.nuspec index 57d57c5b2..691a922bf 100644 --- a/src/ZipX/Packages/Lib.jQuery.Validation.nuspec +++ b/src/ZipX/Packages/Lib.jQuery.Validation.nuspec @@ -2,7 +2,7 @@ ScriptSharp.Lib.jQuery.Validation - 0.7.6.0 + 0.8 Script# jQuery Validation Reference Assembly Nikhil Kothari Copyright (c) 2012, Nikhil Kothari @@ -17,9 +17,9 @@ en-US false - - - + + + diff --git a/src/ZipX/Packages/Lib.jQuery.nuspec b/src/ZipX/Packages/Lib.jQuery.nuspec index 7ded6a14a..128fa53fe 100644 --- a/src/ZipX/Packages/Lib.jQuery.nuspec +++ b/src/ZipX/Packages/Lib.jQuery.nuspec @@ -2,7 +2,7 @@ ScriptSharp.Lib.jQuery - 0.7.6.0 + 0.8 Script# jQuery Reference Assembly Nikhil Kothari Copyright (c) 2012, Nikhil Kothari @@ -17,8 +17,8 @@ en-US false - - + + diff --git a/src/ZipX/Packages/Runtime.nuspec b/src/ZipX/Packages/Runtime.nuspec index 19320dfe4..5b4b35100 100644 --- a/src/ZipX/Packages/Runtime.nuspec +++ b/src/ZipX/Packages/Runtime.nuspec @@ -2,7 +2,7 @@ ScriptSharp.Runtime - 0.7.6.0 + 0.8 Script# Runtime Scripts Nikhil Kothari Copyright (c) 2012, Nikhil Kothari diff --git a/src/ZipX/Packages/Testing.nuspec b/src/ZipX/Packages/Testing.nuspec index b16011f10..beaed3f70 100644 --- a/src/ZipX/Packages/Testing.nuspec +++ b/src/ZipX/Packages/Testing.nuspec @@ -2,7 +2,7 @@ ScriptSharp.Testing - 0.7.6.0 + 0.8 Script# Unit Testing Helpers Nikhil Kothari Copyright (c) 2012, Nikhil Kothari diff --git a/src/ZipX/ProjectTemplates/ClassLibrary/ClassLibrary.vstemplate b/src/ZipX/ProjectTemplates/ClassLibrary/ClassLibrary.vstemplate index f4fcb7b34..7eb3cc7bd 100644 --- a/src/ZipX/ProjectTemplates/ClassLibrary/ClassLibrary.vstemplate +++ b/src/ZipX/ProjectTemplates/ClassLibrary/ClassLibrary.vstemplate @@ -23,8 +23,8 @@ - - + + diff --git a/src/ZipX/ProjectTemplates/ImportLibrary/ImportLibrary.vstemplate b/src/ZipX/ProjectTemplates/ImportLibrary/ImportLibrary.vstemplate index bf9b55f62..7e965508b 100644 --- a/src/ZipX/ProjectTemplates/ImportLibrary/ImportLibrary.vstemplate +++ b/src/ZipX/ProjectTemplates/ImportLibrary/ImportLibrary.vstemplate @@ -22,8 +22,8 @@ - - + + diff --git a/src/ZipX/ProjectTemplates/jQueryClassLibrary/jQueryClassLibrary.vstemplate b/src/ZipX/ProjectTemplates/jQueryClassLibrary/jQueryClassLibrary.vstemplate index 94dd8e96f..569718575 100644 --- a/src/ZipX/ProjectTemplates/jQueryClassLibrary/jQueryClassLibrary.vstemplate +++ b/src/ZipX/ProjectTemplates/jQueryClassLibrary/jQueryClassLibrary.vstemplate @@ -23,9 +23,9 @@ - - - + + + diff --git a/src/ZipX/VSIX/Extension.vsixmanifest b/src/ZipX/VSIX/Extension.vsixmanifest index 6f5e5e6ab..d8ed80ae0 100644 --- a/src/ZipX/VSIX/Extension.vsixmanifest +++ b/src/ZipX/VSIX/Extension.vsixmanifest @@ -7,7 +7,7 @@ Script# Nikhil Kothari - 0.7.6 + 0.8 Script# lets you author your HTML5 apps in C# and compile them into JavaScript. 1033 http://www.scriptsharp.com/ From 5961beceace7f5cd38d15c4b0ce09bf501052949 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 16 Sep 2012 18:08:46 -0700 Subject: [PATCH 035/251] Remove webapp mode and unused options in msbuild task. --- src/Core/Build/Tasks/ScriptCompilerTask.cs | 201 +++------------------ src/Core/Compiler/CompilerOptions.cs | 10 - src/Core/Compiler/ScriptCompiler.cs | 3 - 3 files changed, 30 insertions(+), 184 deletions(-) diff --git a/src/Core/Build/Tasks/ScriptCompilerTask.cs b/src/Core/Build/Tasks/ScriptCompilerTask.cs index b15015889..af7c0fd34 100644 --- a/src/Core/Build/Tasks/ScriptCompilerTask.cs +++ b/src/Core/Build/Tasks/ScriptCompilerTask.cs @@ -34,8 +34,6 @@ public sealed class ScriptCompilerTask : Task, IErrorHandler { private string _outputPath; private string _deploymentPath; - private bool _localeSubFolders; - private bool _configSubFolders; private List _scripts; private bool _hasErrors; @@ -87,24 +85,6 @@ public string DeploymentPath { } } - public bool LocaleSubFolders { - get { - return _localeSubFolders; - } - set { - _localeSubFolders = value; - } - } - - public bool ConfigSubFolders { - get { - return _configSubFolders; - } - set { - _configSubFolders = value; - } - } - public ITaskItem Template { get { return _template; @@ -193,11 +173,11 @@ public bool SuppressDocumentation { } } - private bool Compile(string name, IEnumerable sourceItems, IEnumerable resourceItems, string locale) { + private bool Compile(IEnumerable sourceItems, IEnumerable resourceItems, string locale) { ITaskItem scriptTaskItem; CompilerOptions debugOptions = - CreateOptions(name, sourceItems, resourceItems, locale, + CreateOptions(sourceItems, resourceItems, locale, /* debug */ true, /* includeTests */ false, /* minimize */ false, out scriptTaskItem); @@ -224,7 +204,7 @@ private bool Compile(string name, IEnumerable sourceItems, IEnumerabl if (debugOptions.HasTestTypes) { CompilerOptions testOptions = - CreateOptions(name, sourceItems, resourceItems, locale, + CreateOptions(sourceItems, resourceItems, locale, /* debug */ true, /* includeTests */ true, /* minimize */ false, out scriptTaskItem); ScriptCompiler testCompiler = new ScriptCompiler(this); @@ -238,7 +218,7 @@ private bool Compile(string name, IEnumerable sourceItems, IEnumerabl } CompilerOptions releaseOptions = - CreateOptions(name, sourceItems, resourceItems, locale, + CreateOptions(sourceItems, resourceItems, locale, /* debug */ false, /* includeTests */ false, /* minimize */ true, out scriptTaskItem); ScriptCompiler releaseCompiler = new ScriptCompiler(this); @@ -253,7 +233,7 @@ private bool Compile(string name, IEnumerable sourceItems, IEnumerabl return true; } - private CompilerOptions CreateOptions(string name, IEnumerable sourceItems, IEnumerable resourceItems, + private CompilerOptions CreateOptions(IEnumerable sourceItems, IEnumerable resourceItems, string locale, bool debug, bool includeTests, bool minimize, out ITaskItem outputScriptItem) { @@ -261,8 +241,7 @@ private CompilerOptions CreateOptions(string name, IEnumerable source options.DebugFlavor = debug; options.IncludeTests = includeTests; options.Minimize = minimize; - options.ScriptNameSuffix = name; - options.Defines = GetDefines(name, !debug); + options.Defines = GetDefines(); options.References = GetReferences(); options.Sources = GetSources(sourceItems); options.Resources = GetResources(resourceItems, locale); @@ -273,7 +252,7 @@ private CompilerOptions CreateOptions(string name, IEnumerable source options.DocCommentFile = new TaskItemInputStreamSource(_docCommentFile, "DocComment"); } - string scriptFilePath = GetScriptFilePath(name, locale, debug, includeTests); + string scriptFilePath = GetScriptFilePath(locale, debug, includeTests); outputScriptItem = new TaskItem(scriptFilePath); options.ScriptFile = new TaskItemOutputStreamSource(outputScriptItem); @@ -283,107 +262,43 @@ private CompilerOptions CreateOptions(string name, IEnumerable source public override bool Execute() { _scripts = new List(); -#if PARTITIONING - if (_webAppPartitioning == false) { -#endif - return ExecuteCore(String.Empty, _sources, _resources); -#if PARTITIONING + bool success; + try { + success = ExecuteCore(_sources, _resources); + } + catch (Exception) { + success = false; } - else { - CompilationGroup sharedGroup = new CompilationGroup(); - Dictionary compilationGroups = - new Dictionary(StringComparer.OrdinalIgnoreCase); - - if (_sources != null) { - foreach (ITaskItem sourceItem in _sources) { - string groupName = CompilationGroup.GetGroupName(sourceItem); - - CompilationGroup group; - if (groupName == CompilationGroup.SharedGroupName) { - group = sharedGroup; - } - else if (compilationGroups.TryGetValue(groupName, out group) == false) { - group = new CompilationGroup(); - compilationGroups[groupName] = group; - } - - group.Sources.Add(sourceItem); - } - } - - if (_resources != null) { - foreach (ITaskItem resourceItem in _resources) { - string groupName = CompilationGroup.GetGroupName(resourceItem); - CompilationGroup group; - if (groupName == CompilationGroup.SharedGroupName) { - group = sharedGroup; - } - else if (compilationGroups.TryGetValue(groupName, out group) == false) { - group = new CompilationGroup(); - compilationGroups[groupName] = group; - } + return success; + } - group.Resources.Add(resourceItem); - } - } + private bool ExecuteCore(IEnumerable sources, IEnumerable resources) { + // Create the neutral culture scripts first, and if that + // succeeds, compile any localized variants that are supposed + // to be generated. - foreach (KeyValuePair group in compilationGroups) { - group.Value.Sources.AddRange(sharedGroup.Sources); - group.Value.Resources.AddRange(sharedGroup.Resources); + if (Compile(sources, resources, /* locale */ String.Empty)) { + ICollection locales = GetLocales(resources); - bool success = ExecuteCore(group.Key, group.Value.Sources, group.Value.Resources); - if (success == false) { + foreach (string locale in locales) { + if (Compile(sources, resources, locale) == false) { return false; } } return true; } -#endif // PARTITIONING - } - - private bool ExecuteCore(string name, IEnumerable sources, IEnumerable resources) { - bool success = false; - try { - // Create the neutral culture scripts first - success = Compile(name, sources, resources, /* locale */ String.Empty); - - if (success) { - ICollection locales = GetLocales(resources); - foreach (string locale in locales) { - success = Compile(name, sources, resources, locale); - if (success == false) { - break; - } - } - } - } - catch { - success = false; - } - - return success; + return false; } - private ICollection GetDefines(string name, bool removeDebug) { - if ((Defines.Length == 0) && String.IsNullOrEmpty(name)) { + private ICollection GetDefines() { + if (Defines.Length == 0) { return new string[0]; } - string[] defines = Defines.Split(';'); - if (String.IsNullOrEmpty(name) && (removeDebug == false)) { - return defines; - } - - List definesList = new List(defines); - definesList.Add(name); - - if (removeDebug) { - definesList.Remove("DEBUG"); - } - return definesList; + return Defines.Split(';'); } private ICollection GetLocales(IEnumerable resourceItems) { @@ -446,12 +361,11 @@ private ICollection GetResources(IEnumerable allResour return resources; } - private string GetScriptFilePath(string name, string locale, bool debug, bool includeTests) { + private string GetScriptFilePath(string locale, bool debug, bool includeTests) { if ((_csharpAssembly != null) && (OutputPath.Length != 0)) { string assemblyPath = _csharpAssembly.ItemSpec; string assemblyFile = Path.GetFileName(assemblyPath); string outputPath = OutputPath; - string extension = "js"; if ((assemblyFile.Length > 7) && assemblyFile.StartsWith("Script.", StringComparison.OrdinalIgnoreCase)) { // Resulting script files don't need a "Script." prefix, since that @@ -460,24 +374,9 @@ private string GetScriptFilePath(string name, string locale, bool debug, bool in assemblyFile = assemblyFile.Substring(7); } - if (_configSubFolders == false) { - extension = includeTests ? "test.js" : (debug ? "debug.js" : "js"); - } - else { - outputPath = Path.Combine(outputPath, includeTests ? "test" : (debug ? "debug" : "release")); - } - + string extension = includeTests ? "test.js" : (debug ? "debug.js" : "js"); if (String.IsNullOrEmpty(locale) == false) { - if (_localeSubFolders == false) { - extension = locale + "." + extension; - } - else { - outputPath = Path.Combine(outputPath, locale); - } - } - - if (String.IsNullOrEmpty(name) == false) { - extension = name + "." + extension; + extension = locale + "." + extension; } if (Directory.Exists(outputPath) == false) { @@ -627,46 +526,6 @@ void IErrorHandler.ReportError(string errorMessage, string location) { #endregion - private sealed class CompilationGroup { - - public static readonly string SharedGroupName = "Shared"; - - public List Sources; - public List Resources; - - public CompilationGroup() { - Sources = new List(); - Resources = new List(); - } - - public static string GetGroupName(ITaskItem taskItem) { - string groupName = null; - - string itemPath = taskItem.GetMetadata("Link"); - if (String.IsNullOrEmpty(itemPath)) { - itemPath = taskItem.ItemSpec; - } - - if (Path.IsPathRooted(itemPath) || - (itemPath.IndexOf(Path.DirectorySeparatorChar) < 0)) { - groupName = SharedGroupName; - } - else { - string path = itemPath; - while (String.IsNullOrEmpty(path) == false) { - groupName = path; - path = Path.GetDirectoryName(path); - } - } - - if (groupName.Equals("Properties", StringComparison.Ordinal)) { - groupName = CompilationGroup.SharedGroupName; - } - - return groupName; - } - } - private sealed class TaskItemInputStreamSource : FileInputStreamSource { public TaskItemInputStreamSource(ITaskItem taskItem) diff --git a/src/Core/Compiler/CompilerOptions.cs b/src/Core/Compiler/CompilerOptions.cs index 3cb26efca..fc2cc621f 100644 --- a/src/Core/Compiler/CompilerOptions.cs +++ b/src/Core/Compiler/CompilerOptions.cs @@ -23,7 +23,6 @@ public sealed class CompilerOptions { private IStreamSource _templateFile; private IStreamSource _scriptFile; private IStreamSource _docCommentFile; - private string _scriptNameSuffix; private bool _debugFlavor; private bool _includeTests; private bool _minimize; @@ -151,15 +150,6 @@ public IStreamSource ScriptFile { } } - public string ScriptNameSuffix { - get { - return _scriptNameSuffix ?? String.Empty; - } - set { - _scriptNameSuffix = value; - } - } - public ICollection Sources { get { return _sources; diff --git a/src/Core/Compiler/ScriptCompiler.cs b/src/Core/Compiler/ScriptCompiler.cs index f24785d32..cfdd12c6a 100644 --- a/src/Core/Compiler/ScriptCompiler.cs +++ b/src/Core/Compiler/ScriptCompiler.cs @@ -337,9 +337,6 @@ string IScriptInfo.GetValue(string name) { } if (String.CompareOrdinal(name, "Name") == 0) { - if (String.IsNullOrEmpty(_options.ScriptNameSuffix) == false) { - return _symbols.ScriptName + "." + _options.ScriptNameSuffix; - } return _symbols.ScriptName; } if (String.CompareOrdinal(name, "DependencyNames") == 0) { From f74666ab7ea0535aebb5ebc284988305d293d9b7 Mon Sep 17 00:00:00 2001 From: nikhilk Date: Sun, 16 Sep 2012 18:23:05 -0700 Subject: [PATCH 036/251] Remove script template feature --- src/Core/App/Application.cs | 13 - src/Core/Build/Build.csproj | 1 - src/Core/Build/ScriptSharp.targets | 1 - .../Build/Tasks/ScriptCompilerExecTask.cs | 3 - src/Core/Build/Tasks/ScriptCompilerTask.cs | 13 - .../Build/Tasks/ScriptPreprocessorTask.cs | 292 --------- src/Core/Compiler/Compiler.csproj | 9 - src/Core/Compiler/CompilerOptions.cs | 10 - src/Core/Compiler/IScriptInfo.cs | 15 - src/Core/Compiler/IStreamResolver.cs | 15 - .../Preprocessor/CondenserTextReader.cs | 210 ------ .../Preprocessor/PreprocessorException.cs | 48 -- .../Preprocessor/PreprocessorTextReader.cs | 614 ------------------ src/Core/Compiler/PreprocessorOptions.cs | 93 --- src/Core/Compiler/ScriptCompiler.cs | 188 +----- src/Core/Compiler/ScriptPreprocessor.cs | 85 --- .../ClassLibrary/ClassLibrary.csproj | 1 - .../ClassLibrary/ClassLibrary.vstemplate | 1 - .../ClassLibrary/Script.template | 8 - .../jQueryClassLibrary/ClassLibrary.csproj | 1 - .../jQueryClassLibrary/Script.template | 8 - .../jQueryClassLibrary.vstemplate | 1 - tests/ScriptSharp/BasicTests.cs | 11 - tests/ScriptSharp/Core/Compilation.cs | 9 - tests/TestCases/Basic/Template/Baseline.txt | 33 - tests/TestCases/Basic/Template/Code.cs | 15 - tests/TestCases/Basic/Template/Static.js | 1 - tests/TestCases/Basic/Template/Template.js | 13 - 28 files changed, 31 insertions(+), 1681 deletions(-) delete mode 100644 src/Core/Build/Tasks/ScriptPreprocessorTask.cs delete mode 100644 src/Core/Compiler/IScriptInfo.cs delete mode 100644 src/Core/Compiler/IStreamResolver.cs delete mode 100644 src/Core/Compiler/Preprocessor/CondenserTextReader.cs delete mode 100644 src/Core/Compiler/Preprocessor/PreprocessorException.cs delete mode 100644 src/Core/Compiler/Preprocessor/PreprocessorTextReader.cs delete mode 100644 src/Core/Compiler/PreprocessorOptions.cs delete mode 100644 src/Core/Compiler/ScriptPreprocessor.cs delete mode 100644 src/ZipX/ProjectTemplates/ClassLibrary/Script.template delete mode 100644 src/ZipX/ProjectTemplates/jQueryClassLibrary/Script.template delete mode 100644 tests/TestCases/Basic/Template/Baseline.txt delete mode 100644 tests/TestCases/Basic/Template/Code.cs delete mode 100644 tests/TestCases/Basic/Template/Static.js delete mode 100644 tests/TestCases/Basic/Template/Template.js diff --git a/src/Core/App/Application.cs b/src/Core/App/Application.cs index b614c6b2d..2164a540b 100644 --- a/src/Core/App/Application.cs +++ b/src/Core/App/Application.cs @@ -27,7 +27,6 @@ ssc [/nologo] [/?] [/tests] [/minimize] [/D:] - [/template: