Browse Source

Merge pull request #935 from AtomicGameEngine/JME-ATOMIC-NETPROJECTIMPROVEMENTS

NET Project Improvements (WIP)
JoshEngebretson 9 years ago
parent
commit
8f52845ecd
56 changed files with 814 additions and 3498 deletions
  1. 0 0
      Data/AtomicEditor/ProjectTemplates/EmptyProject/CSharp/EmptyProject.atomic
  2. 0 0
      Data/AtomicEditor/ProjectTemplates/EmptyProject/CSharp/Resources/Components/.gitkeep
  3. 56 0
      Data/AtomicEditor/ProjectTemplates/EmptyProject/CSharp/Resources/Scenes/Scene.scene
  4. 8 0
      Data/AtomicEditor/ProjectTemplates/EmptyProject/CSharp/Resources/Scenes/Scene.scene.asset
  5. 16 0
      Data/AtomicEditor/ProjectTemplates/EmptyProject/CSharp/Resources/Scripts/Program.cs
  6. 5 0
      Data/AtomicEditor/ProjectTemplates/EmptyProject/CSharp/Resources/Scripts/Program.cs.asset
  7. 0 0
      Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Project2D.atomic
  8. 15 0
      Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Resources/Components/Spinner.cs
  9. 5 0
      Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Resources/Components/Spinner.cs.asset
  10. 63 0
      Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Resources/Scenes/Scene.scene
  11. 8 0
      Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Resources/Scenes/Scene.scene.asset
  12. 16 0
      Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Resources/Scripts/Program.cs
  13. 5 0
      Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Resources/Scripts/Program.cs.asset
  14. BIN
      Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Resources/Sprites/star.png
  15. 0 0
      Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Project3D.atomic
  16. 15 0
      Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Components/Spinner.cs
  17. 5 0
      Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Components/Spinner.cs.asset
  18. BIN
      Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Models/Chest.fbx
  19. 9 0
      Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Models/Chest.fbx.asset
  20. 15 0
      Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Models/Materials/DefaultMaterial.material
  21. 78 0
      Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Scenes/Scene.scene
  22. 8 0
      Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Scenes/Scene.scene.asset
  23. 16 0
      Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Scripts/Program.cs
  24. 5 0
      Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Scripts/Program.cs.asset
  25. BIN
      Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Textures/Chest.png
  26. 12 0
      Data/AtomicEditor/ProjectTemplates/ProjectTemplates.json
  27. 6 0
      Resources/EditorData/AtomicEditor/templates/file_template_definitions.json
  28. 3 0
      Resources/EditorData/AtomicEditor/templates/template_cs_script.cs
  29. 3 0
      Script/AtomicEditor/ui/ResourceEditorProvider.ts
  30. 5 0
      Script/AtomicEditor/ui/resourceEditors/CSharpResourceEditorBuilder.ts
  31. 16 21
      Script/AtomicEditor/ui/resourceEditors/VisualStudioResourceEditorBuilder.ts
  32. 2 0
      Script/AtomicWebViewEditor/tsconfig.json
  33. 2 1
      Script/Packages/ToolCore/ToolCore.json
  34. 1 0
      Script/TypeScript/AtomicWork.d.ts
  35. 1 0
      Script/tsconfig.json
  36. 3 1
      Source/AtomicEditor/EditorMode/AEEditorNETService.cpp
  37. 0 977
      Source/AtomicEditor/Javascript/JSAST.cpp
  38. 0 983
      Source/AtomicEditor/Javascript/JSAST.h
  39. 0 23
      Source/AtomicEditor/Javascript/JSASTSyntaxColorVisitor.cpp
  40. 0 377
      Source/AtomicEditor/Javascript/JSASTSyntaxColorVisitor.h
  41. 0 23
      Source/AtomicEditor/Javascript/JSASTVisitor.cpp
  42. 0 398
      Source/AtomicEditor/Javascript/JSASTVisitor.h
  43. 0 43
      Source/AtomicEditor/Javascript/JSErrorChecker.cpp
  44. 0 320
      Source/AtomicEditor/Javascript/JSSpiderMonkeyVM.cpp
  45. 0 74
      Source/AtomicEditor/Javascript/JSSpiderMonkeyVM.h
  46. 0 21
      Source/AtomicEditor/Javascript/JSTheme.cpp
  47. 0 200
      Source/AtomicEditor/Javascript/JSTheme.h
  48. 0 9
      Source/ToolCore/Assets/CSharpImporter.cpp
  49. 10 24
      Source/ToolCore/NETTools/NETBuildSystem.cpp
  50. 48 2
      Source/ToolCore/NETTools/NETProjectGen.cpp
  51. 3 0
      Source/ToolCore/NETTools/NETProjectGen.h
  52. 253 0
      Source/ToolCore/NETTools/NETProjectSystem.cpp
  53. 90 0
      Source/ToolCore/NETTools/NETProjectSystem.h
  54. 1 1
      Source/ToolCore/ToolEnvironment.cpp
  55. 2 0
      Source/ToolCore/ToolEnvironment.h
  56. 5 0
      Source/ToolCoreJS/ToolCoreJS.cpp

+ 0 - 0
Data/AtomicEditor/ProjectTemplates/EmptyProject/CSharp/EmptyProject.atomic


+ 0 - 0
Data/AtomicEditor/ProjectTemplates/EmptyProject/CSharp/Resources/Components/.gitkeep


+ 56 - 0
Data/AtomicEditor/ProjectTemplates/EmptyProject/CSharp/Resources/Scenes/Scene.scene

@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<scene id="1">
+	<attribute name="Name" value="" />
+	<attribute name="Time Scale" value="1" />
+	<attribute name="Smoothing Constant" value="50" />
+	<attribute name="Snap Threshold" value="5" />
+	<attribute name="Elapsed Time" value="0" />
+	<attribute name="Next Replicated Node ID" value="363" />
+	<attribute name="Next Replicated Component ID" value="1975" />
+	<attribute name="Next Local Node ID" value="16778496" />
+	<attribute name="Next Local Component ID" value="16777216" />
+	<attribute name="Variables" />
+	<attribute name="Variable Names" value="" />
+	<component type="PhysicsWorld" id="1" />
+	<component type="Octree" id="2" />
+	<component type="DebugRenderer" id="3" />
+	<node id="2">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Zone" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Zone" id="4">
+			<attribute name="Bounding Box Min" value="-10000 -10000 -10000" />
+			<attribute name="Bounding Box Max" value="10000 10000 10000" />
+			<attribute name="Ambient Color" value="0.4 0.4 0.4 1" />
+		</component>
+	</node>
+	<node id="3">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="GlobalLight" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="0.888074 0.325058 -0.325058 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Light" id="5">
+			<attribute name="Light Type" value="Directional" />
+			<attribute name="Cast Shadows" value="true" />
+			<attribute name="CSM Splits" value="10 20 50 0" />
+			<attribute name="View Size Quantize" value="1" />
+			<attribute name="View Size Minimum" value="5" />
+			<attribute name="Depth Constant Bias" value="0.00025" />
+			<attribute name="Depth Slope Bias" value="0.001" />
+		</component>
+	</node>
+	<node id="361">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Camera" />
+		<attribute name="Position" value="0 0 -5" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Camera" id="1973" />
+	</node>
+</scene>

+ 8 - 0
Data/AtomicEditor/ProjectTemplates/EmptyProject/CSharp/Resources/Scenes/Scene.scene.asset

@@ -0,0 +1,8 @@
+{
+	"version": 1,
+	"guid": "58b95d1cf8f15de679c37faf51fe2f70",
+	"SceneImporter": {
+		"sceneCamRotation": "1 0 0 0",
+		"sceneCamPosition": "0 0 0"
+	}
+}

+ 16 - 0
Data/AtomicEditor/ProjectTemplates/EmptyProject/CSharp/Resources/Scripts/Program.cs

@@ -0,0 +1,16 @@
+using AtomicEngine;
+using AtomicPlayer;
+
+public static class AtomicMain
+{
+    /// <summary>
+    /// The main entry point for the application.
+    /// </summary>
+    static void Main(string[] args)
+    {
+
+        AtomicNET.GetSubsystem<Player>().LoadScene("Scenes/Scene.scene");
+
+    }
+    
+}

+ 5 - 0
Data/AtomicEditor/ProjectTemplates/EmptyProject/CSharp/Resources/Scripts/Program.cs.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "c7b1ed8a45b7704ba0fdffc94b582b55",
+	"CSharpImporter": null
+}

+ 0 - 0
Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Project2D.atomic


+ 15 - 0
Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Resources/Components/Spinner.cs

@@ -0,0 +1,15 @@
+using System;
+using AtomicEngine;
+
+public class Spinner : CSComponent
+{
+
+    [Inspector]
+    float speed = 1.0f;    
+
+    void Update(float timeStep)
+    {
+        Node.Roll(speed * timeStep * 75.0f);
+    }
+
+}

+ 5 - 0
Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Resources/Components/Spinner.cs.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "7d2197a4d7e117426aefe04d33c041bc",
+	"CSharpImporter": null
+}

+ 63 - 0
Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Resources/Scenes/Scene.scene

@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<scene id="1">
+	<attribute name="Name" value="" />
+	<attribute name="Time Scale" value="1" />
+	<attribute name="Smoothing Constant" value="50" />
+	<attribute name="Snap Threshold" value="5" />
+	<attribute name="Elapsed Time" value="0" />
+	<attribute name="Next Replicated Node ID" value="371" />
+	<attribute name="Next Replicated Component ID" value="1989" />
+	<attribute name="Next Local Node ID" value="16778496" />
+	<attribute name="Next Local Component ID" value="16777216" />
+	<attribute name="Variables" />
+	<attribute name="Variable Names" value="" />
+	<component type="PhysicsWorld" id="1" />
+	<component type="Octree" id="2" />
+	<component type="DebugRenderer" id="3" />
+	<component type="Renderer2D" id="1980" />
+	<node id="2">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Zone" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Zone" id="4">
+			<attribute name="Bounding Box Min" value="-10000 -10000 -10000" />
+			<attribute name="Bounding Box Max" value="10000 10000 10000" />
+			<attribute name="Ambient Color" value="0.4 0.4 0.4 1" />
+		</component>
+	</node>
+	<node id="361">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Camera" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Camera" id="1973">
+			<attribute name="Near Clip" value="0" />
+			<attribute name="Orthographic" value="true" />
+			<attribute name="Orthographic Size" value="5" />
+		</component>
+	</node>
+	<node id="363">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Star" />
+		<attribute name="Position" value="0 0 3.4" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticSprite2D" id="1979">
+			<attribute name="Layer" value="-100" />
+			<attribute name="Sprite" value="Sprite2D;Sprites/star.png" />
+		</component>
+		<component type="CSComponent" id="1988">
+			<attribute name="FieldValues">
+				<variant hash="273365031" type="Float" value="3" />
+			</attribute>
+			<attribute name="Assembly" value="CSComponentAssembly;AtomicProject.dll" />
+			<attribute name="Class" value="Spinner" />
+		</component>
+	</node>
+</scene>

+ 8 - 0
Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Resources/Scenes/Scene.scene.asset

@@ -0,0 +1,8 @@
+{
+	"version": 1,
+	"guid": "2a57513e778e118da7da6c222caf4d66",
+	"SceneImporter": {
+		"sceneCamRotation": "1 0 0 0",
+		"sceneCamPosition": "0 0 0"
+	}
+}

+ 16 - 0
Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Resources/Scripts/Program.cs

@@ -0,0 +1,16 @@
+using AtomicEngine;
+using AtomicPlayer;
+
+public static class AtomicMain
+{
+    /// <summary>
+    /// The main entry point for the application.
+    /// </summary>
+    static void Main(string[] args)
+    {
+
+        AtomicNET.GetSubsystem<Player>().LoadScene("Scenes/Scene.scene");
+
+    }
+    
+}

+ 5 - 0
Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Resources/Scripts/Program.cs.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "c7b1ed8a45b7704ba0fdffc94b582b55",
+	"CSharpImporter": null
+}

BIN
Data/AtomicEditor/ProjectTemplates/Project2D/CSharp/Resources/Sprites/star.png


+ 0 - 0
Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Project3D.atomic


+ 15 - 0
Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Components/Spinner.cs

@@ -0,0 +1,15 @@
+using System;
+using AtomicEngine;
+
+public class Spinner : CSComponent
+{
+
+    [Inspector]
+    float speed = 1.0f;    
+
+    void Update(float timeStep)
+    {
+        Node.Yaw(speed * timeStep * 75.0f);
+    }
+
+}

+ 5 - 0
Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Components/Spinner.cs.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "7d2197a4d7e117426aefe04d33c041bc",
+	"CSharpImporter": null
+}

BIN
Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Models/Chest.fbx


+ 9 - 0
Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Models/Chest.fbx.asset

@@ -0,0 +1,9 @@
+{
+	"version": 1,
+	"guid": "2788364e8ff6f81f4b566a9d58e3fb5b",
+	"ModelImporter": {
+		"scale": 0.01,
+		"importAnimations": false,
+		"animInfo": []
+	}
+}

+ 15 - 0
Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Models/Materials/DefaultMaterial.material

@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/Diff.xml" quality="0" loddistance="0" />
+	<texture unit="diffuse" name="Textures/Chest.png" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="0.8 0.8 0.8 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0 1" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="0.5 0.5 0.5 16" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+</material>

+ 78 - 0
Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Scenes/Scene.scene

@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<scene id="1">
+	<attribute name="Name" value="" />
+	<attribute name="Time Scale" value="1" />
+	<attribute name="Smoothing Constant" value="50" />
+	<attribute name="Snap Threshold" value="5" />
+	<attribute name="Elapsed Time" value="0" />
+	<attribute name="Next Replicated Node ID" value="365" />
+	<attribute name="Next Replicated Component ID" value="1979" />
+	<attribute name="Next Local Node ID" value="16778496" />
+	<attribute name="Next Local Component ID" value="16777216" />
+	<attribute name="Variables" />
+	<attribute name="Variable Names" value="" />
+	<component type="PhysicsWorld" id="1" />
+	<component type="Octree" id="2" />
+	<component type="DebugRenderer" id="3" />
+	<node id="2">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Zone" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Zone" id="4">
+			<attribute name="Bounding Box Min" value="-10000 -10000 -10000" />
+			<attribute name="Bounding Box Max" value="10000 10000 10000" />
+			<attribute name="Ambient Color" value="0.4 0.4 0.4 1" />
+		</component>
+	</node>
+	<node id="3">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="GlobalLight" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="0.888074 0.325058 -0.325058 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Light" id="5">
+			<attribute name="Light Type" value="Directional" />
+			<attribute name="Cast Shadows" value="true" />
+			<attribute name="CSM Splits" value="10 20 50 0" />
+			<attribute name="View Size Quantize" value="1" />
+			<attribute name="View Size Minimum" value="5" />
+			<attribute name="Depth Constant Bias" value="0.00025" />
+			<attribute name="Depth Slope Bias" value="0.001" />
+		</component>
+	</node>
+	<node id="361">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Camera" />
+		<attribute name="Position" value="0 0 -2" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Camera" id="1973" />
+	</node>
+	<node id="363">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Chest" />
+		<attribute name="Position" value="0 -0.374877 2" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="1975">
+			<attribute name="Model" value="Model;2788364e8ff6f81f4b566a9d58e3fb5b.mdl" />
+			<attribute name="Material" value="Material;Models/Materials/DefaultMaterial.material" />
+			<attribute name="Geometry Enabled">
+				<variant type="Bool" value="true" />
+			</attribute>
+		</component>
+		<component type="CSComponent" id="1978">
+			<attribute name="FieldValues">
+				<variant hash="273365031" type="Float" value="3" />
+			</attribute>
+			<attribute name="Assembly" value="CSComponentAssembly;AtomicProject.dll" />
+			<attribute name="Class" value="Spinner" />
+		</component>
+	</node>
+</scene>

+ 8 - 0
Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Scenes/Scene.scene.asset

@@ -0,0 +1,8 @@
+{
+	"version": 1,
+	"guid": "98e007a9cb157345b1887ea30fa9cd06",
+	"SceneImporter": {
+		"sceneCamRotation": "1 0 0 0",
+		"sceneCamPosition": "0 0 0"
+	}
+}

+ 16 - 0
Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Scripts/Program.cs

@@ -0,0 +1,16 @@
+using AtomicEngine;
+using AtomicPlayer;
+
+public static class AtomicMain
+{
+    /// <summary>
+    /// The main entry point for the application.
+    /// </summary>
+    static void Main(string[] args)
+    {
+
+        AtomicNET.GetSubsystem<Player>().LoadScene("Scenes/Scene.scene");
+
+    }
+    
+}

+ 5 - 0
Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Scripts/Program.cs.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "c7b1ed8a45b7704ba0fdffc94b582b55",
+	"CSharpImporter": null
+}

BIN
Data/AtomicEditor/ProjectTemplates/Project3D/CSharp/Resources/Textures/Chest.png


+ 12 - 0
Data/AtomicEditor/ProjectTemplates/ProjectTemplates.json

@@ -12,6 +12,10 @@
             {
                 "folder": "Project2D/TypeScript",
                 "language": "TypeScript"
+            },
+            {
+                "folder": "Project2D/CSharp",
+                "language": "CSharp"
             }
         ]
     },
@@ -28,6 +32,10 @@
             {
                 "folder": "Project3D/TypeScript",
                 "language": "TypeScript"
+            },
+            {
+                "folder": "Project3D/CSharp",
+                "language": "CSharp"
             }
         ]
     },
@@ -44,6 +52,10 @@
             {
                 "folder": "EmptyProject/TypeScript",
                 "language": "TypeScript"
+            },
+            {
+                "folder": "EmptyProject/CSharp",
+                "language": "CSharp"
             }
         ]
     }

+ 6 - 0
Resources/EditorData/AtomicEditor/templates/file_template_definitions.json

@@ -31,5 +31,11 @@
         "templateType": "script",
         "ext": ".ts",
         "filename": "AtomicEditor/templates/template_ts_script.ts"
+    }, {
+        "name": "Basic (CSharp)",
+        "desc": "An empty script for CSharp",
+        "templateType": "script",
+        "ext": ".cs",
+        "filename": "AtomicEditor/templates/template_cs_script.cs"
     }]
 }

+ 3 - 0
Resources/EditorData/AtomicEditor/templates/template_cs_script.cs

@@ -0,0 +1,3 @@
+
+using System;
+using AtomicEngine;

+ 3 - 0
Script/AtomicEditor/ui/ResourceEditorProvider.ts

@@ -29,6 +29,7 @@ import TypescriptResourceEditorBuilder from "./resourceEditors/TypescriptResourc
 import CSharpResourceEditorBuilder from "./resourceEditors/CSharpResourceEditorBuilder";
 import XMLResourceEditorBuilder from "./resourceEditors/XMLResourceEditorBuilder";
 import ShaderResourceEditorBuilder from "./resourceEditors/ShaderResourceEditorBuilder";
+import VisualStudioResourceEditorBuilder from "./resourceEditors/VisualStudioResourceEditorBuilder";
 
 export default class ResourceEditorProvider {
     private standardEditorRegistry: Editor.Extensions.ResourceEditorBuilder[] = [];
@@ -108,5 +109,7 @@ export default class ResourceEditorProvider {
 
         // this overrides the test resource editor so need to put it in the custom bucket
         this.registerCustomEditor(new TurboBadgerResourceEditorBuilder());
+
+        this.registerCustomEditor(new VisualStudioResourceEditorBuilder());
     }
 }

+ 5 - 0
Script/AtomicEditor/ui/resourceEditors/CSharpResourceEditorBuilder.ts

@@ -29,6 +29,11 @@ export default class CSharpResourceEditorBuilder extends AbstractTextResourceEdi
     }
 
     canHandleResource(resourcePath: string) : boolean {
+
+        /// Handled externally by VS, TODO: make this a preference
+        if (ToolCore.netProjectSystem.visualStudioAvailable)
+            return false;
+
         var ext = Atomic.getExtension(resourcePath).toLowerCase();
         return ext == ".cs";
     }

+ 16 - 21
Source/AtomicEditor/Javascript/JSErrorChecker.h → Script/AtomicEditor/ui/resourceEditors/VisualStudioResourceEditorBuilder.ts

@@ -20,32 +20,27 @@
 // THE SOFTWARE.
 //
 
-#pragma once
+import {AbstractTextResourceEditorBuilder} from "./AbstractTextResourceEditorBuilder";
 
-#include <Duktape/duktape.h>
+export default class VisualStudioResourceEditorBuilder extends AbstractTextResourceEditorBuilder {
 
-#include <Atomic/Core/Object.h>
+    constructor() {
+        super();
+    }
 
-using namespace Atomic;
+    getEditor(resourceFrame: Atomic.UIWidget, resourcePath: string, tabContainer: Atomic.UITabContainer): Editor.ResourceEditor {
 
-namespace AtomicEditor
-{
+        ToolCore.netProjectSystem.openSourceFile(resourcePath);
+        return null;
+    }
 
-class JSErrorChecker : public Object
-{
-    OBJECT(JSErrorChecker);
+    canHandleResource(resourcePath: string) : boolean {
 
-public:
-
-    /// Construct.
-    JSErrorChecker(Context* context, duk_context* ctx);
-    /// Destruct.
-    ~JSErrorChecker();
-
-private:
-
-    duk_context* ctx_;
-
-};
+        /// Handled externally by VS, TODO: make this a preference
+        if (!ToolCore.netProjectSystem.visualStudioAvailable)
+            return false;
 
+        var ext = Atomic.getExtension(resourcePath).toLowerCase();
+        return ext == ".cs";
+    }
 }

+ 2 - 0
Script/AtomicWebViewEditor/tsconfig.json

@@ -40,6 +40,8 @@
         "./typings/webworkers.d.ts",
         "./typings/WindowExt.d.ts",
         "../TypeScript/Atomic.d.ts",
+        "../TypeScript/AtomicApp.d.ts",
+        "../TypeScript/AtomicNETScript.d.ts",
         "../TypeScript/AtomicPlayer.d.ts",
         "../TypeScript/AtomicWork.d.ts",
         "../TypeScript/duktape.d.ts",

+ 2 - 1
Script/Packages/ToolCore/ToolCore.json

@@ -2,7 +2,7 @@
 	"name" : "ToolCore",
 	"sources" : ["Source/ToolCore", "Source/ToolCore/Project", "Source/ToolCore/Platform", "Source/ToolCore/Command",
 							 "Source/ToolCore/Import", "Source/ToolCore/Assets", "Source/ToolCore/License", "Source/ToolCore/Build",
-						 	 "Source/ToolCore/Subprocess"],
+						 	 "Source/ToolCore/Subprocess", "Source/ToolCore/NETTools"],
 	"classes" : ["ToolEnvironment", "ToolSystem", "ToolPrefs", "SubprocessSystem", "Subprocess",
 								"Project", "ProjectFile", "Platform", "PlatformMac", "PlatformWeb",
 							 "PlatformWindows", "PlatformAndroid", "PlatformIOS", "Command", "PlayCmd", "OpenAssetImporter",
@@ -11,6 +11,7 @@
 							 "TextureImporter", "SpriterImporter", "PEXImporter", "CSharpImporter", "NETAssemblyImporter",
 							 "LicenseSystem",
 						 	 "ProjectUserPrefs", "ProjectBuildSettings",
+							 "NETProjectSystem",
 						 	 "BuildBase", "BuildSystem", "BuildMac", "BuildWeb", "BuildWindows", "BuildAndroid", "BuildIOS",
 						 	 "ProjectBuildSettings", "MacBuildSettings", "WindowsBuildSettings", "WebBuildSettings", "AndroidBuildSettings", "IOSBuildSettings"],
 	"typescript_decl" : {

+ 1 - 0
Script/TypeScript/AtomicWork.d.ts

@@ -377,6 +377,7 @@ declare module ToolCore {
     export var assetDatabase: AssetDatabase;
     export var licenseSystem: LicenseSystem;
     export var buildSystem: BuildSystem;
+    export var netProjectSystem: NETProjectSystem;
 
     export function getToolEnvironment(): ToolEnvironment;
     export function getToolSystem(): ToolSystem;

+ 1 - 0
Script/tsconfig.json

@@ -104,6 +104,7 @@
         "./AtomicEditor/ui/resourceEditors/TextFileResourceEditorBuilder.ts",
         "./AtomicEditor/ui/resourceEditors/TurboBadgerResourceEditorBuilder.ts",
         "./AtomicEditor/ui/resourceEditors/TypescriptResourceEditorBuilder.ts",
+        "./AtomicEditor/ui/resourceEditors/VisualStudioResourceEditorBuilder.ts",
         "./AtomicEditor/ui/resourceEditors/XMLResourceEditorBuilder.ts",
         "./AtomicEditor/ui/ScriptWidget.ts",
         "./AtomicEditor/ui/Shortcuts.ts",

+ 3 - 1
Source/AtomicEditor/EditorMode/AEEditorNETService.cpp

@@ -25,7 +25,7 @@
 
 #include <AtomicNET/NETScript/NETScript.h>
 
-
+#include <ToolCore/NETTools/NETProjectSystem.h>
 #include <ToolCore/NETTools/AtomicNETService.h>
 #include "AEEditorNETService.h"
 
@@ -49,6 +49,8 @@ namespace AtomicEditor
     {
         RegisterNETScriptLibrary(context_);
 
+        context_->RegisterSubsystem(new NETProjectSystem(context_));
+
         netService_ = new AtomicNETService(context_);
 
         if (!netService_->Start())

+ 0 - 977
Source/AtomicEditor/Javascript/JSAST.cpp

@@ -1,977 +0,0 @@
-//
-// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include <rapidjson/document.h>
-#include <rapidjson/stringbuffer.h>
-#include <rapidjson/prettywriter.h>
-
-#include <Atomic/IO/Log.h>
-#include "JSAST.h"
-#include "JSASTVisitor.h"
-
-using namespace rapidjson;
-
-namespace AtomicEditor
-{
-
-JSASTNode::JSASTNode(JSASTType type) : type_(type), rangeStart_(0), rangeEnd_(0)
-{
-
-}
-
-bool JSASTNode::Parse(const rapidjson::Value& value)
-{
-    assert(value.IsObject());
-
-    for (Value::ConstMemberIterator itr = value.MemberBegin();
-         itr != value.MemberEnd(); ++itr)
-    {
-        String name = itr->name.GetString();
-
-        if (name == "loc")
-        {
-            ParseLoc(itr->value);
-        }
-        else if (name == "type")
-        {
-            // TODO: Verify type
-        }
-        else if (name == "range")
-        {
-            ParseRange(itr->value);
-        }
-
-    }
-
-    return true;
-
-}
-
-bool JSASTNode::ParseLoc(const rapidjson::Value& value)
-{
-    // SpiderMonkey can have this for loc :/
-    if (value.IsNull())
-        return true;
-
-    assert(value.IsObject());
-
-    const Value::Member* mstart = value.FindMember("start");
-    assert(mstart);
-
-    const Value::Member* mend = value.FindMember("end");
-    assert(mend);
-
-    loc_.startLine_ = mstart->value["line"].GetInt();
-    loc_.startColumn_ = mstart->value["column"].GetInt();
-    loc_.endLine_ = mend->value["line"].GetInt();
-    loc_.endColumn_ = mend->value["column"].GetInt();
-
-    return true;
-}
-
-bool JSASTNode::ParseRange(const rapidjson::Value& value)
-{
-    assert(value.IsArray() && value.Size() == 2);
-
-    rangeStart_ = value[SizeType(0)].GetInt();
-    rangeEnd_ = value[SizeType(1)].GetInt();
-
-    return true;
-
-}
-
-JSASTStatement* JSASTNode::ParseStatement(const rapidjson::Value &value)
-{
-    assert(value.IsObject());
-
-    JSASTStatement* statement = NULL;
-
-    const Value::Member* mtype = value.FindMember("type");
-    assert(mtype);
-
-    String type = mtype->value.GetString();
-
-    if (type == "ExpressionStatement")
-    {
-        statement = new JSASTExpressionStatement();
-    }
-    else if (type == "VariableDeclaration")
-    {
-        statement = new JSASTVariableDeclaration();
-    }
-    else if (type == "ReturnStatement")
-    {
-        statement = new JSASTReturnStatement();
-    }
-    else if (type == "FunctionDeclaration")
-    {
-        statement = new JSASTFunctionDeclaration();
-    }
-    else if (type == "IfStatement")
-    {
-        statement = new JSASTIfStatement();
-    }
-    else if (type == "BlockStatement")
-    {
-        statement = new JSASTBlockStatement();
-    }
-    else if (type == "EmptyStatement")
-    {
-        statement = new JSASTBlockStatement();
-    }
-    else if (type == "ForStatement")
-    {
-        statement = new JSASTForStatement();
-    }
-    else if (type == "LabeledStatement")
-    {
-        statement = new JSASTLabeledStatement();
-    }
-
-    if (!statement)
-    {
-        LOGWARNINGF("Unknown JSASTStatement: %s", type.CString());
-    }
-    else
-    {
-        statement->Parse(value);
-    }
-
-    return statement;
-
-}
-
-JSASTExpression* JSASTNode::ParseExpression(const rapidjson::Value &value, JSASTType astType)
-{
-    if (!value.IsObject())
-        return NULL;
-
-    JSASTExpression* expr = NULL;
-
-    const Value::Member* mtype = value.FindMember("type");
-    assert(mtype);
-
-    String type = mtype->value.GetString();
-    if (type == "Identifier" && (astType == JSAST_UNDEFINED || astType == JSAST_IDENTIFIER))
-    {
-        expr = new JSASTIdentifier();
-    }
-    else if (type == "Literal" && (astType == JSAST_UNDEFINED || astType == JSAST_LITERAL))
-    {
-        expr = new JSASTLiteral();
-    }
-    else if (type == "UnaryExpression" && (astType == JSAST_UNDEFINED || astType == JSAST_UNARYEXPRESSION))
-    {
-        expr = new JSASTUnaryExpression();
-    }
-    else if (type == "UpdateExpression" && (astType == JSAST_UNDEFINED || astType == JSAST_UPDATEEXPRESSION))
-    {
-        expr = new JSASTUpdateExpression();
-    }
-    else if (type == "NewExpression" && (astType == JSAST_UNDEFINED || astType == JSAST_NEWEXPRESSION))
-    {
-        expr = new JSASTNewExpression();
-    }
-    else if (type == "FunctionExpression" && (astType == JSAST_UNDEFINED || astType == JSAST_FUNCTIONEXPRESSION))
-    {
-        expr = new JSASTFunctionExpression();
-    }
-    else if (type == "BinaryExpression" && (astType == JSAST_UNDEFINED || astType == JSAST_BINARYEXPRESSION))
-    {
-        expr = new JSASTBinaryExpression();
-    }
-    else if (type == "AssignmentExpression" && (astType == JSAST_UNDEFINED || astType == JSAST_ASSIGNMENTEXPRESSION))
-    {
-        expr = new JSASTAssignmentExpression();
-    }
-    else if (type == "LogicalExpression" && (astType == JSAST_UNDEFINED || astType == JSAST_LOGICALEXPRESSION))
-    {
-        expr = new JSASTAssignmentExpression();
-    }
-    else if (type == "CallExpression" && (astType == JSAST_UNDEFINED || astType == JSAST_CALLEXPRESSION))
-    {
-        expr = new JSASTCallExpression();
-    }
-    else if (type == "VariableDeclarator" && (astType == JSAST_UNDEFINED || astType == JSAST_VARIABLEDECLARATOR))
-    {
-        expr = new JSASTVariableDeclarator();
-    }
-    else if (type == "MemberExpression" && (astType == JSAST_UNDEFINED || astType == JSAST_MEMBEREXPRESSION))
-    {
-        expr = new JSASTMemberExpression();
-    }
-    else if (type == "ArrayExpression" && (astType == JSAST_UNDEFINED || astType == JSAST_ARRAYEXPRESSION))
-    {
-        expr = new JSASTArrayExpression();
-    }
-    else if (type == "ObjectExpression" && (astType == JSAST_UNDEFINED || astType == JSAST_OBJECTEXPRESSION))
-    {
-        expr = new JSASTObjectExpression();
-    }
-    else if (type == "ConditionalExpression" && (astType == JSAST_UNDEFINED || astType == JSAST_CONDITIONALEXPRESSION))
-    {
-        expr = new JSASTConditionalExpression();
-    }
-    else if (type == "ThisExpression" && (astType == JSAST_UNDEFINED || astType == JSAST_THISEXPRESSION))
-    {
-        expr = new JSASTThisExpression();
-    }
-
-    if (!expr)
-    {
-        LOGWARNINGF("Unknown JSASTExpression: %s", type.CString());
-    }
-    else
-    {
-        expr->Parse(value);
-    }
-
-    return expr;
-
-}
-
-bool JSASTNode::ParseExpressionArray(const rapidjson::Value &value, Vector<JSASTExpression *> &expressions)
-{
-
-    assert(value.IsArray());
-
-    for (Value::ConstValueIterator itr = value.Begin(); itr != value.End(); itr++)
-    {
-        JSASTExpression* expr = ParseExpression(*itr);
-        //assert(expr);
-        expressions.Push(expr);
-
-    }
-
-    return true;
-}
-
-
-bool JSASTNode::ParseStatementArray(const rapidjson::Value &value, Vector<JSASTStatement *> &statements)
-{
-
-    assert(value.IsArray());
-
-    for (Value::ConstValueIterator itr = value.Begin(); itr != value.End(); itr++)
-    {
-        JSASTStatement* stmt = ParseStatement(*itr);
-        //assert(stmt);
-        statements.Push(stmt);
-
-    }
-
-    return true;
-}
-
-bool JSASTThisExpression::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    return true;
-}
-
-void JSASTThisExpression::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-bool JSASTIdentifier::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    if (value.FindMember("name"))
-        name_ = value["name"].GetString();
-    return true;
-}
-
-void JSASTIdentifier::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-bool JSASTAssignmentExpression::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    operator_ = value["operator"].GetString();
-
-    leftExpression_ = ParseExpression(value["left"]);
-    rightExpression_ = ParseExpression(value["right"]);
-
-    return true;
-}
-
-void JSASTAssignmentExpression::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-bool JSASTLogicalExpression::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    operator_ = value["operator"].GetString();
-
-    leftExpression_ = ParseExpression(value["left"]);
-    rightExpression_ = ParseExpression(value["right"]);
-
-    return true;
-}
-
-void JSASTLogicalExpression::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-
-bool JSASTBinaryExpression::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    operator_ = value["operator"].GetString();
-
-    leftExpression_ = ParseExpression(value["left"]);
-    rightExpression_ = ParseExpression(value["right"]);
-
-    return true;
-}
-
-void JSASTBinaryExpression::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-bool JSASTLiteral::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    if (!value.FindMember("value") || !value.FindMember("raw"))
-    {
-        literalType_ = LITERAL_UNKNOWN;
-        return false;
-    }
-
-    const rapidjson::Value& v = value["value"];
-
-    raw_ = value["raw"].GetString();;
-
-    if (v.IsNull())
-        literalType_ = LITERAL_NULL;
-    else if (v.IsString())
-        literalType_ = LITERAL_STRING;
-    else if (v.IsNumber())
-        literalType_ = LITERAL_NUMBER;
-    else if (v.IsBool())
-        literalType_ = LITERAL_BOOLEAN;
-
-
-
-    return true;
-}
-
-void JSASTLiteral::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-bool JSASTArrayExpression::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    ParseExpressionArray(value["elements"], elements_);
-
-    return true;
-}
-
-void JSASTArrayExpression::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-bool JSASTProperty::Parse(const rapidjson::Value& value)
-{
-    key_ = ParseExpression(value["key"]);
-    assert(key_);
-
-    value_ = ParseExpression(value["value"]);
-    assert(value_);
-
-    return true;
-}
-
-void JSASTProperty::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-bool JSASTObjectExpression::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    const rapidjson::Value& jprops = value["properties"];
-
-    assert(jprops.IsArray());
-
-    for (Value::ConstValueIterator itr = jprops.Begin(); itr != jprops.End(); itr++)
-    {
-
-        JSASTProperty* property = new JSASTProperty();
-        property->Parse(*itr);
-        properties_.Push(property);
-
-    }
-
-
-    return true;
-}
-
-void JSASTObjectExpression::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-bool JSASTMemberExpression::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    computed_ = value["computed"].GetBool();
-    object_ = ParseExpression(value["object"]);
-    property_ = ParseExpression(value["property"]);
-
-    return true;
-}
-
-void JSASTMemberExpression::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-
-bool JSASTCallExpression::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    callee_ = ParseExpression(value["callee"]);
-
-    ParseExpressionArray(value["arguments"], arguments_);
-
-    return true;
-
-}
-
-void JSASTCallExpression::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-bool JSASTNewExpression::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    callee_ = ParseExpression(value["callee"]);
-
-    ParseExpressionArray(value["arguments"], arguments_);
-
-    return true;
-
-}
-
-void JSASTNewExpression::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-bool JSASTVariableDeclarator::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    id_ = ParseExpression(value["id"]);
-
-    const Value::Member* init = value.FindMember("init");
-    if (init && init->value.IsObject())
-    {
-        init_ = ParseExpression(init->value);
-    }
-
-    return true;
-
-}
-
-void JSASTVariableDeclarator::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-bool JSASTUnaryExpression::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    argument_ = ParseExpression(value["argument"]);
-
-    prefix_ = value["prefix"].IsTrue();
-
-    operator_ = value["operator"].GetString();
-
-    return true;
-
-}
-
-void JSASTUnaryExpression::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-bool JSASTUpdateExpression::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    argument_ = ParseExpression(value["argument"]);
-
-    prefix_ = value["prefix"].IsTrue();
-
-    operator_ = value["operator"].GetString();
-
-    return true;
-
-}
-
-void JSASTUpdateExpression::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-bool JSASTConditionalExpression::Parse(const rapidjson::Value& value)
-{
-    JSASTExpression::Parse(value);
-
-    test_ = ParseExpression(value["test"]);
-    consequent_ = ParseExpression(value["consequent"]);
-    alternate_ = ParseExpression(value["alternate"]);
-
-    return true;
-}
-
-void JSASTConditionalExpression::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-
-bool JSASTFunctionExpression::Parse(const rapidjson::Value& value)
-{
-
-    JSASTExpression::Parse(value);
-
-    if (!value["id"].IsNull())
-    {
-        id_ = (JSASTIdentifier*) ParseExpression(value["id"],  JSAST_IDENTIFIER);
-    }
-
-    ParseExpressionArray(value["params"], params_);
-
-    const rapidjson::Value& body = value["body"];
-
-    String type = body["type"].GetString();
-
-    if (type == "BlockStatement")
-    {
-        body_ = (JSASTBlockStatement*) ParseStatement(body);
-    }
-    else
-    {
-        return true;
-    }
-
-
-    return true;
-}
-
-void JSASTFunctionExpression::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-JSASTFunctionExpression::~JSASTFunctionExpression()
-{
-    if (id_)
-        delete id_;
-    if (rest_)
-        delete rest_;
-    if (body_)
-        delete body_;
-
-
-
-    for (unsigned i = 0; i < params_.Size(); i++)
-        delete params_[i];
-    for (unsigned i = 0; i < defaults_.Size(); i++)
-        delete defaults_[i];
-
-    params_.Clear();
-    defaults_.Clear();
-}
-
-// STATEMENTS
-
-bool JSASTExpressionStatement::Parse(const rapidjson::Value& value)
-{
-    JSASTStatement::Parse(value);
-
-    const Value::Member* expr = value.FindMember("expression");
-    assert(expr);
-
-    expression_ = ParseExpression(expr->value);
-
-    return expression_ != NULL;
-
-}
-
-void JSASTLabeledStatement::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-bool JSASTLabeledStatement::Parse(const rapidjson::Value& value)
-{
-    JSASTStatement::Parse(value);
-
-    const Value::Member* body = value.FindMember("body");
-    assert(body);
-
-    const Value::Member* label = value.FindMember("label");
-    assert(label);
-
-
-    body_ = ParseStatement(body->value);
-    label_ = (JSASTIdentifier*) ParseExpression(label->value,  JSAST_IDENTIFIER);
-
-    return body_ && label_;
-
-}
-
-void JSASTExpressionStatement::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-bool JSASTReturnStatement::Parse(const rapidjson::Value& value)
-{
-    JSASTStatement::Parse(value);
-
-    if (!value["argument"].IsNull())
-    {
-        argument_ = ParseExpression(value["argument"]);
-    }
-
-
-    return true;
-}
-
-void JSASTReturnStatement::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-
-bool JSASTVariableDeclaration::Parse(const rapidjson::Value& value)
-{
-    JSASTDeclaration::Parse(value);
-
-    kind_ = value["kind"].GetString();
-
-    ParseExpressionArray(value["declarations"], declarations_);
-
-    return true;
-
-}
-
-void JSASTVariableDeclaration::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-JSASTComment::JSASTComment() : JSASTNode(JSAST_COMMENT) , isBlock_(false)
-{
-
-}
-
-JSASTComment::~JSASTComment()
-{
-
-}
-
-bool JSASTComment::Parse(const rapidjson::Value& value)
-{
-    JSASTNode::Parse(value);
-
-    // Block or Line
-    if (value.FindMember("type"))
-    {
-        String type = value["type"].GetString();
-        isBlock_ = type == "Block";
-    }
-
-    if (value.FindMember("value"))
-    {
-        value_ = value["value"].GetString();
-    }
-
-    return true;
-}
-
-void JSASTComment::Accept(JSASTVisitor *visitor)
-{
-    visitor->visit(this);
-}
-
-
-
-JSASTProgram::JSASTProgram(const String &path, const String &json) : JSASTNode(JSAST_PROGRAM)
-  , document_(new Document())
-{
-
-    if (document_->Parse<0>(json.CString()).HasParseError())
-    {
-        LOGERRORF("Could not parse JSON data from %s", path.CString());
-        return;
-    }
-    else
-    {
-        //StringBuffer buffer;
-        //PrettyWriter<StringBuffer> writer(buffer, &(document_->GetAllocator()));
-        //writer.SetIndent(' ', 3);
-        //document_->Accept(writer);
-        //LOGINFOF("%s", buffer.GetString());
-    }
-
-    Parse(*document_);
-
-}
-
-
-
-bool JSASTProgram::Parse(const rapidjson::Value& value)
-{
-    JSASTNode::Parse(value);
-
-    for (Value::ConstMemberIterator itr = value.MemberBegin();
-         itr != value.MemberEnd(); ++itr)
-    {
-        String name = itr->name.GetString();
-
-        if (name == "body")
-        {
-            ParseStatementArray(itr->value, body_);
-        }
-
-        if (name == "comments")
-        {
-            if (itr->value.IsArray())
-            {
-                for (Value::ConstValueIterator citr = itr->value.Begin();
-                     citr != itr->value.End();
-                     citr++)
-                {
-                    JSASTComment* comment = new JSASTComment();
-                    assert(citr->IsObject());
-                    comment->Parse(*citr);
-                    comments_.Push(comment);
-                }
-            }
-        }
-
-    }
-
-    return true;
-
-}
-
-JSASTProgram::~JSASTProgram()
-{
-    for (unsigned i = 0; i < comments_.Size(); i++)
-        delete comments_[i];
-
-    comments_.Clear();
-
-    delete document_;
-    document_ = 0;
-}
-
-void JSASTProgram::Accept(JSASTVisitor *visitor)
-{
-    visitor->visit(this);
-}
-
-
-JSASTProgram* JSASTProgram::ParseFromJSON(const String& path, const String& json)
-{
-    JSASTProgram* cunit = new JSASTProgram(path, json);
-
-    return cunit;
-}
-
-bool JSASTIfStatement::Parse(const rapidjson::Value& value)
-{
-    JSASTStatement::Parse(value);
-
-    test_ = ParseExpression(value["test"]);
-    consequent_ = ParseStatement(value["consequent"]);
-
-    if (!value["alternate"].IsNull())
-        alternate_ = ParseStatement(value["alternate"]);
-
-    return true;
-}
-
-void JSASTIfStatement::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-bool JSASTFunctionDeclaration::Parse(const rapidjson::Value& value)
-{
-    JSASTDeclaration::Parse(value);
-
-    if (!value["id"].IsNull())
-    {
-        id_ = (JSASTIdentifier*) ParseExpression(value["id"],  JSAST_IDENTIFIER);
-    }
-
-    ParseExpressionArray(value["params"], params_);
-
-    const rapidjson::Value& body = value["body"];
-
-    String type = body["type"].GetString();
-
-    if (type == "BlockStatement")
-    {
-        body_ = (JSASTBlockStatement*) ParseStatement(body);
-    }
-    else
-    {
-
-    }
-
-
-    return true;
-}
-
-void JSASTFunctionDeclaration::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-JSASTFunctionDeclaration::~JSASTFunctionDeclaration()
-{
-    if (id_)
-        delete id_;
-    if (rest_)
-        delete rest_;
-    if (body_)
-        delete body_;
-
-    for (unsigned i = 0; i < params_.Size(); i++)
-        delete params_[i];
-    for (unsigned i = 0; i < defaults_.Size(); i++)
-        delete defaults_[i];
-
-    params_.Clear();
-    defaults_.Clear();
-}
-
-bool JSASTBlockStatement::Parse(const rapidjson::Value& value)
-{
-    if (value.FindMember("body"))
-    {
-        ParseStatementArray(value["body"], body_);
-
-    }
-
-    return true;
-
-}
-
-void JSASTBlockStatement::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-bool JSASTForStatement::Parse(const rapidjson::Value& value)
-{
-    JSASTStatement::Parse(value);
-
-    if (value.FindMember("init") && !value.FindMember("init")->value.IsNull())
-    {
-        const Value::Member* member = value.FindMember("init");
-
-        String type = member->value.FindMember("type")->value.GetString();
-        if (type == "VariableDeclaration")
-        {
-            initVariable_ = (JSASTVariableDeclaration*) ParseStatement(member->value);
-        }
-        else
-        {
-            initExpression_ = ParseExpression(member->value);
-        }
-    }
-
-    if (value.FindMember("test") && !value.FindMember("test")->value.IsNull())
-    {
-        test_ = ParseExpression(value["test"]);
-    }
-
-    if (value.FindMember("update") && !value.FindMember("update")->value.IsNull())
-    {
-        update_ = ParseExpression(value["update"]);
-    }
-
-    if (value.FindMember("body"))
-    {
-        body_ = ParseStatement(value["body"]);
-    }
-
-    return true;
-}
-
-void JSASTForStatement::Accept(JSASTVisitor* visitor)
-{
-    visitor->visit(this);
-}
-
-
-}

+ 0 - 983
Source/AtomicEditor/Javascript/JSAST.h

@@ -1,983 +0,0 @@
-//
-// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-// see https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Parser_API
-
-#include <Atomic/Container/Str.h>
-#include <Atomic/Container/Vector.h>
-
-using namespace Atomic;
-
-namespace rapidjson
-{
-template<typename CharType> struct UTF8;
-class CrtAllocator;
-template <typename BaseAllocator> class MemoryPoolAllocator;
-template <typename Encoding, typename Allocator> class GenericValue;
-typedef GenericValue<UTF8<char>, MemoryPoolAllocator<CrtAllocator> > Value;
-template <typename Encoding, typename Allocator> class GenericDocument;
-typedef GenericDocument<UTF8<char>, MemoryPoolAllocator<CrtAllocator> > Document;
-}
-
-namespace AtomicEditor
-{
-
-enum JSASTType
-{
-    JSAST_UNDEFINED,
-    JSAST_COMMENT,
-    JSAST_PROGRAM,
-    JSAST_PROPERTY,
-    // Expression
-    JSAST_ASSIGNMENTEXPRESSION,
-    JSAST_LOGICALEXPRESSION,
-    JSAST_IDENTIFIER,
-    JSAST_CALLEXPRESSION,
-    JSAST_VARIABLEDECLARATOR,
-    JSAST_BINARYEXPRESSION,
-    JSAST_MEMBEREXPRESSION,
-    JSAST_LITERAL,
-    JSAST_ARRAYEXPRESSION,
-    JSAST_FUNCTIONEXPRESSION,
-    JSAST_NEWEXPRESSION,
-    JSAST_UNARYEXPRESSION,
-    JSAST_UPDATEEXPRESSION,
-    JSAST_CONDITIONALEXPRESSION,
-    JSAST_OBJECTEXPRESSION,
-    JSAST_THISEXPRESSION,
-    // Statements
-    JSAST_RETURNSTATEMENT,
-    JSAST_EMPTYSTATEMENT,
-    JSAST_EXPRESSIONSTATEMENT,
-    JSAST_LABELEDSTATEMENT,
-    JSAST_VARIABLEDECLARATION,
-    JSAST_FUNCTIONDECLARATION,
-    JSAST_IFSTATEMENT,
-    JSAST_BLOCKSTATEMENT
-};
-
-
-class JSASTProgram;
-class JSASTStatement;
-class JSASTEmptyStatement;
-class JSASTExpressionStatement;
-class JSASTExpression;
-class JSASTVisitor;
-class JSASTBlockStatement;
-
-class JSASTNode
-{
-public:
-
-    struct Loc
-    {
-        int startLine_;
-        int startColumn_;
-        int endLine_;
-        int endColumn_;
-
-        Loc()
-        {
-            startLine_ = startColumn_ = -1;
-            endLine_ = endColumn_ = -1;
-        }
-
-        bool Valid() const { return startLine_ != -1 && startColumn_ != -1 &&
-                    endLine_ != -1 && endColumn_ != -1; }
-
-    };
-
-    JSASTNode(JSASTType type);
-    virtual bool Parse(const rapidjson::Value& value);
-
-    JSASTType GetType() { return type_; }
-    const Loc& GetLoc() { return loc_; }
-
-    virtual void Accept(JSASTVisitor* visitor) = 0;
-
-protected:
-
-    bool ParseLoc(const rapidjson::Value &value);
-    bool ParseRange(const rapidjson::Value &value);
-
-    JSASTStatement* ParseStatement(const rapidjson::Value &value);
-    JSASTExpression* ParseExpression(const rapidjson::Value &value, JSASTType astType = JSAST_UNDEFINED);
-
-    bool ParseExpressionArray(const rapidjson::Value &value, Vector<JSASTExpression *> &expressions);
-    bool ParseStatementArray(const rapidjson::Value &value, Vector<JSASTStatement *> &statements);
-
-private:
-
-    Loc loc_;
-    JSASTType type_;
-    // character range
-    int rangeStart_;
-    int rangeEnd_;
-
-
-};
-
-class JSASTComment: public JSASTNode
-{
-public:
-
-    JSASTComment();
-    virtual ~JSASTComment();
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    const String& GetValue() { return value_; }
-    bool IsBlock() { return isBlock_; }
-
-private:
-
-    bool isBlock_;
-    String value_;
-
-};
-
-class JSASTProgram : public JSASTNode
-{
-public:
-
-    JSASTProgram(const String& path, const String& json);
-    virtual ~JSASTProgram();
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    static JSASTProgram* ParseFromJSON(const String& path, const String& json);
-
-    unsigned GetStatementCount() { return body_.Size(); }
-    JSASTStatement* GetStatement(unsigned idx) { return body_[idx]; }
-
-    unsigned GetCommentCount() { return comments_.Size(); }
-    JSASTComment* GetComment(unsigned idx) { return comments_[idx]; }
-
-
-protected:
-
-private:
-
-    Vector<JSASTStatement*> body_;
-    rapidjson::Document* document_;
-
-    Vector<JSASTComment*> comments_;
-
-};
-
-class JSASTExpression : public JSASTNode
-{
-public:
-
-    virtual ~JSASTExpression() {}
-
-    virtual bool Parse(const rapidjson::Value& value)
-    {
-        return JSASTNode::Parse(value);
-    }
-
-protected:
-    JSASTExpression(JSASTType type) :  JSASTNode(type) {}
-
-};
-
-
-class JSASTIdentifier : public JSASTExpression
-{
-
-public:
-    JSASTIdentifier() : JSASTExpression(JSAST_IDENTIFIER) {}
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-private:
-
-    String name_;
-};
-
-class JSASTThisExpression : public JSASTExpression
-{
-
-public:
-    JSASTThisExpression() : JSASTExpression(JSAST_THISEXPRESSION) {}
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-private:
-
-};
-
-
-class JSASTLiteral : public JSASTExpression
-{
-
-public:
-
-    enum LiteralType
-    {
-        LITERAL_UNKNOWN,
-        LITERAL_NULL,
-        LITERAL_STRING,
-        LITERAL_NUMBER,
-        LITERAL_BOOLEAN,
-        LITERAL_REGEX
-    };
-
-    JSASTLiteral() : JSASTExpression(JSAST_LITERAL), literalType_(LITERAL_UNKNOWN) {}
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    LiteralType GetLiteralType() { return literalType_; }
-
-private:
-
-    //value: string | boolean | null | number | RegExp;
-    LiteralType literalType_;
-    String raw_;
-};
-
-class JSASTArrayExpression : public JSASTExpression
-{
-
-public:
-    JSASTArrayExpression() : JSASTExpression(JSAST_ARRAYEXPRESSION) {}
-
-    virtual ~JSASTArrayExpression()
-    {
-        for (unsigned i = 0; i < elements_.Size(); i++)
-            delete elements_[i];
-
-        elements_.Clear();
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    unsigned GetElementCount() { return elements_.Size(); }
-    JSASTExpression* GetElement(unsigned idx) { return elements_[idx]; }
-
-private:
-
-    Vector<JSASTExpression*> elements_;
-
-};
-
-class JSASTProperty: public JSASTNode
-{
-
-public:
-
-    JSASTProperty() : JSASTNode(JSAST_PROPERTY), key_(0), value_(0) {}
-    virtual ~JSASTProperty()
-    {
-        if (key_)
-            delete key_;
-
-        if (value_)
-            delete value_;
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    JSASTExpression* GetKey() { return key_; }
-    JSASTExpression* GetValue() { return value_; }
-
-
-private:
-    JSASTExpression* key_;
-    JSASTExpression* value_;
-
-};
-
-
-class JSASTObjectExpression : public JSASTExpression
-{
-
-public:
-    JSASTObjectExpression() : JSASTExpression(JSAST_OBJECTEXPRESSION) {}
-
-    virtual ~JSASTObjectExpression()
-    {
-        for (unsigned i = 0; i < properties_.Size(); i++)
-            delete properties_[i];
-
-        properties_.Clear();
-    }
-
-    unsigned GetPropertyCount() { return properties_.Size(); }
-    JSASTProperty* GetProperty(unsigned idx) { return properties_[idx]; }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-private:
-
-    Vector<JSASTProperty*> properties_;
-};
-
-
-
-class JSASTAssignmentExpression : public JSASTExpression
-{
-
-public:
-    JSASTAssignmentExpression() : JSASTExpression(JSAST_ASSIGNMENTEXPRESSION),
-        leftExpression_(0), rightExpression_(0) {}
-
-    virtual ~JSASTAssignmentExpression()
-    {
-        if (leftExpression_)
-            delete leftExpression_;
-        if (rightExpression_)
-            delete rightExpression_;
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    const String& GetOperator() { return operator_; }
-    JSASTExpression* GetLeft() { return leftExpression_; }
-    JSASTExpression* GetRight() { return rightExpression_; }
-
-private:
-
-    String operator_;
-    JSASTExpression* leftExpression_;
-    JSASTExpression* rightExpression_;
-
-};
-
-class JSASTLogicalExpression : public JSASTExpression
-{
-
-public:
-    JSASTLogicalExpression() : JSASTExpression(JSAST_LOGICALEXPRESSION),
-        leftExpression_(0), rightExpression_(0) {}
-
-    virtual ~JSASTLogicalExpression()
-    {
-        if (leftExpression_)
-            delete leftExpression_;
-        if (rightExpression_)
-            delete rightExpression_;
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    const String& GetOperator() { return operator_; }
-    JSASTExpression* GetLeft() { return leftExpression_; }
-    JSASTExpression* GetRight() { return rightExpression_; }
-
-private:
-
-    String operator_;
-    JSASTExpression* leftExpression_;
-    JSASTExpression* rightExpression_;
-
-};
-
-
-class JSASTUnaryExpression : public JSASTExpression
-{
-
-public:
-    JSASTUnaryExpression() : JSASTExpression(JSAST_UNARYEXPRESSION),
-        argument_(0), prefix_(false) {}
-
-    virtual ~JSASTUnaryExpression()
-    {
-        if (argument_)
-            delete argument_;
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    const String& GetOperator() { return operator_;}
-
-    JSASTExpression* GetArgument() { return argument_; }
-
-private:
-
-    String operator_;
-    bool prefix_;
-    JSASTExpression* argument_;
-
-};
-
-class JSASTUpdateExpression : public JSASTExpression
-{
-
-public:
-    JSASTUpdateExpression() : JSASTExpression(JSAST_UPDATEEXPRESSION),
-        argument_(0), prefix_(false) {}
-
-    virtual ~JSASTUpdateExpression()
-    {
-        if (argument_)
-            delete argument_;
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    const String& GetOperator() { return operator_;}
-
-    JSASTExpression* GetArgument() { return argument_; }
-
-private:
-
-    String operator_;
-    bool prefix_;
-    JSASTExpression* argument_;
-
-};
-
-class JSASTFunctionExpression : public JSASTExpression
-{
-
-public:
-    JSASTFunctionExpression() : JSASTExpression(JSAST_FUNCTIONEXPRESSION),
-        id_(0), rest_(0), body_(0), generator_(false), expression_(false) {}
-
-    virtual ~JSASTFunctionExpression();
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    JSASTIdentifier* GetID() { return id_; }
-    JSASTBlockStatement* GetBodyStatement() { return body_; }
-
-    unsigned GetParamsCount() { return params_.Size(); }
-    JSASTExpression* GetParam(unsigned idx) { return params_[idx]; }
-
-private:
-
-    JSASTIdentifier* id_;
-    Vector<JSASTExpression*> params_;
-    Vector<JSASTExpression*> defaults_;
-    JSASTIdentifier* rest_;
-
-    JSASTBlockStatement* body_;
-
-    bool generator_;
-    bool expression_;
-
-};
-
-
-class JSASTBinaryExpression : public JSASTExpression
-{
-
-public:
-    JSASTBinaryExpression() : JSASTExpression(JSAST_BINARYEXPRESSION),
-        leftExpression_(0), rightExpression_(0) {}
-
-    virtual ~JSASTBinaryExpression()
-    {
-        if (leftExpression_)
-            delete leftExpression_;
-        if (rightExpression_)
-            delete rightExpression_;
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    JSASTExpression* GetLeft() { return leftExpression_; }
-    JSASTExpression* GetRight() { return rightExpression_; }
-
-    const String& GetOperator() { return operator_;}
-
-private:
-
-    String operator_;
-    JSASTExpression* leftExpression_;
-    JSASTExpression* rightExpression_;
-
-};
-
-class JSASTMemberExpression : public JSASTExpression
-{
-
-public:
-    JSASTMemberExpression() : JSASTExpression(JSAST_MEMBEREXPRESSION),
-        object_(0), property_(0), computed_(false) {}
-
-    virtual ~JSASTMemberExpression()
-    {
-        if (object_)
-            delete object_;
-        if (property_)
-            delete property_;
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    JSASTExpression* GetObject() { return object_;}
-    JSASTExpression* GetProperty() { return property_; }
-
-
-private:
-
-    JSASTExpression* object_;
-    JSASTExpression* property_;
-    bool computed_;
-};
-
-class JSASTConditionalExpression : public JSASTExpression
-{
-public:
-
-    JSASTConditionalExpression() : JSASTExpression(JSAST_CONDITIONALEXPRESSION), test_(0), consequent_(0), alternate_(0) {}
-
-    virtual ~JSASTConditionalExpression()
-    {
-        if (test_)
-            delete test_;
-        if (consequent_)
-            delete consequent_;
-        if (alternate_)
-            delete alternate_;
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    JSASTExpression* GetTest() { return test_; }
-    JSASTExpression* GetConsequent() { return consequent_; }
-    JSASTExpression* GetAlternate() { return alternate_; }
-
-private:
-
-    JSASTExpression* test_;
-    JSASTExpression* consequent_;
-    JSASTExpression* alternate_;
-
-};
-
-class JSASTCallExpression : public JSASTExpression
-{
-
-public:
-    JSASTCallExpression() : JSASTExpression(JSAST_CALLEXPRESSION),
-        callee_(0){}
-
-    virtual ~JSASTCallExpression()
-    {
-        if (callee_)
-            delete callee_;
-
-        for (unsigned i = 0; i < arguments_.Size(); i++)
-        {
-            delete arguments_[i];
-        }
-
-        arguments_.Clear();
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    JSASTExpression* GetCallee() { return callee_; }
-    unsigned GetArgumentCount() { return arguments_.Size(); }
-    JSASTExpression* GetArgument(unsigned idx) { return arguments_[idx]; }
-
-private:
-
-    JSASTExpression* callee_;
-    Vector<JSASTExpression*> arguments_;
-
-};
-
-class JSASTNewExpression : public JSASTExpression
-{
-
-public:
-    JSASTNewExpression() : JSASTExpression(JSAST_NEWEXPRESSION),
-        callee_(0){}
-
-    virtual ~JSASTNewExpression()
-    {
-        if (callee_)
-            delete callee_;
-
-        for (unsigned i = 0; i < arguments_.Size(); i++)
-        {
-            delete arguments_[i];
-        }
-
-        arguments_.Clear();
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    JSASTExpression* GetCallee() { return callee_; }
-    unsigned GetArgumentCount() { return arguments_.Size(); }
-    JSASTExpression* GetArgument(unsigned idx) { return arguments_[idx]; }
-
-
-private:
-
-    JSASTExpression* callee_;
-    Vector<JSASTExpression*> arguments_;
-
-};
-
-class JSASTVariableDeclarator : public JSASTExpression
-{
-public:
-
-    JSASTVariableDeclarator() : JSASTExpression(JSAST_VARIABLEDECLARATOR), id_(0), init_(0) {}
-
-    virtual ~JSASTVariableDeclarator()
-    {
-        if (id_)
-            delete id_;
-        if (init_)
-            delete init_;
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    JSASTExpression* GetID() { return id_; }
-    JSASTExpression* GetInit() { return init_; }
-
-
-private:
-
-    JSASTExpression* id_;
-    JSASTExpression* init_;
-
-};
-
-class JSASTStatement : public JSASTNode
-{
-
-public:
-
-    virtual ~JSASTStatement() {}
-
-    virtual bool Parse(const rapidjson::Value& value)
-    {
-        return JSASTNode::Parse(value);
-    }
-
-protected:
-    JSASTStatement(JSASTType type) :  JSASTNode(type) {}
-
-};
-
-class JSASTEmptyStatement : public JSASTStatement
-{
-
-public:
-    JSASTEmptyStatement() : JSASTStatement(JSAST_EMPTYSTATEMENT) {}
-
-    virtual bool Parse(const rapidjson::Value& value)
-    {
-        return JSASTStatement::Parse(value);
-    }
-    virtual void Accept(JSASTVisitor* visitor);
-
-};
-
-class JSASTExpressionStatement : public JSASTStatement
-{
-
-public:
-    JSASTExpressionStatement(JSASTType type = JSAST_EXPRESSIONSTATEMENT) : JSASTStatement(type),
-        expression_(0) {}
-
-    virtual ~JSASTExpressionStatement()
-    {
-        if (expression_)
-            delete expression_;
-    }
-
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    JSASTExpression* GetExpression() { return expression_; }
-
-protected:
-
-    JSASTExpression* expression_;
-
-};
-
-class JSASTLabeledStatement : public JSASTStatement
-{
-
-public:
-    JSASTLabeledStatement(JSASTType type = JSAST_LABELEDSTATEMENT) : JSASTStatement(type),
-        label_(0), body_(0) {}
-
-    virtual ~JSASTLabeledStatement()
-    {
-        if (label_)
-            delete label_;
-
-        if (body_)
-            delete body_;
-
-    }
-
-    JSASTIdentifier* GetLabel() { return label_; }
-    JSASTStatement* GetBody() { return body_; }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-protected:
-
-    JSASTIdentifier* label_;
-    JSASTStatement* body_;
-
-};
-
-
-class JSASTReturnStatement : public JSASTStatement
-{
-
-public:
-    JSASTReturnStatement(JSASTType type = JSAST_RETURNSTATEMENT) : JSASTStatement(type),
-        argument_(0) {}
-
-    virtual ~JSASTReturnStatement()
-    {
-        if (argument_)
-            delete argument_;
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    JSASTExpression* GetArgument() { return argument_; }
-
-protected:
-
-    JSASTExpression* argument_;
-
-};
-
-
-class JSASTDeclaration : public JSASTStatement
-{
-
-public:
-
-    virtual bool Parse(const rapidjson::Value& value) { return JSASTStatement::Parse(value); }
-
-protected:
-
-    JSASTDeclaration(JSASTType type) : JSASTStatement(type) {}
-
-};
-
-class JSASTBlockStatement : public JSASTStatement
-{
-public:
-    JSASTBlockStatement() : JSASTStatement(JSAST_BLOCKSTATEMENT) {}
-
-    virtual ~JSASTBlockStatement()
-    {
-        for (unsigned i = 0; i < body_.Size(); i++)
-            delete body_[i];
-
-        body_.Clear();
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    unsigned GetStatementCount() { return body_.Size(); }
-    JSASTStatement* GetStatement(unsigned idx) { return body_[idx]; }
-
-
-private:
-
-    Vector<JSASTStatement*> body_;
-
-};
-
-class JSASTIfStatement : public JSASTStatement
-{
-public:
-
-    JSASTIfStatement() : JSASTStatement(JSAST_IFSTATEMENT), test_(0), consequent_(0), alternate_(0) {}
-
-    virtual ~JSASTIfStatement()
-    {
-        if (test_)
-            delete test_;
-        if (consequent_)
-            delete consequent_;
-        if (alternate_)
-            delete alternate_;
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    JSASTExpression* GetTest() { return test_; }
-    JSASTStatement* GetConsequent() { return consequent_; }
-    JSASTStatement* GetAlternate() { return alternate_; }
-
-private:
-
-    JSASTExpression* test_;
-    JSASTStatement* consequent_;
-    JSASTStatement* alternate_;
-
-};
-
-class JSASTVariableDeclaration : public JSASTDeclaration
-{
-
-public:
-
-    JSASTVariableDeclaration() : JSASTDeclaration(JSAST_VARIABLEDECLARATION) {}
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    const String& GetKind()  { return kind_; }
-
-    unsigned GetDeclarationsCount() { return declarations_.Size(); }
-    JSASTExpression* GetDeclaration(unsigned idx) { return declarations_[idx]; }
-
-protected:
-
-    // "var" | "let" | "const";
-    String kind_;
-
-    // Array of JSASTVariableDeclarator
-    Vector<JSASTExpression*> declarations_;
-
-};
-
-
-class JSASTFunctionDeclaration : public JSASTDeclaration
-{
-
-public:
-    JSASTFunctionDeclaration() : JSASTDeclaration(JSAST_FUNCTIONDECLARATION),
-        id_(0), rest_(0), body_(0), generator_(false), expression_(false) {}
-
-    virtual ~JSASTFunctionDeclaration();
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    JSASTIdentifier* GetID() { return id_; }
-    JSASTBlockStatement* GetBodyStatement() { return body_; }
-
-    unsigned GetParamsCount() { return params_.Size(); }
-    JSASTExpression* GetParam(unsigned idx) { return params_[idx]; }
-
-private:
-
-    JSASTIdentifier* id_;
-    Vector<JSASTExpression*> params_;
-    Vector<JSASTExpression*> defaults_;
-    JSASTIdentifier* rest_;
-
-    JSASTBlockStatement* body_;
-
-    bool generator_;
-    bool expression_;
-
-};
-
-/*
-interface ForStatement <: Statement {
-    type: "ForStatement";
-    init: VariableDeclaration | Expression | null;
-    test: Expression | null;
-    update: Expression | null;
-    body: Statement;
-}
-*/
-
-
-class JSASTForStatement : public JSASTStatement
-{
-public:
-
-    JSASTForStatement() : JSASTStatement(JSAST_IFSTATEMENT),
-        initVariable_(0), initExpression_(0), test_(0), update_(0), body_(0)
-    {
-
-    }
-
-    virtual ~JSASTForStatement()
-    {
-        if (initVariable_)
-            delete initVariable_;
-
-        if (initExpression_)
-            delete initExpression_;
-
-        if (test_)
-            delete(test_);
-
-        if(update_)
-            delete update_;
-
-        if (body_)
-            delete body_;
-    }
-
-    virtual bool Parse(const rapidjson::Value& value);
-    virtual void Accept(JSASTVisitor* visitor);
-
-    JSASTExpression* GetTest() { return test_; }
-    JSASTVariableDeclaration* GetInitVariable() { return initVariable_; }
-    JSASTExpression* GetInitExpression() { return initExpression_; }
-    JSASTExpression* GetUpdate() { return update_; }
-    JSASTStatement* GetBody() { return body_; }
-
-private:
-    JSASTVariableDeclaration* initVariable_;
-    JSASTExpression* initExpression_;
-    JSASTExpression* test_;
-    JSASTExpression* update_;
-    JSASTStatement* body_;
-
-};
-
-
-}

+ 0 - 23
Source/AtomicEditor/Javascript/JSASTSyntaxColorVisitor.cpp

@@ -1,23 +0,0 @@
-//
-// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "JSASTSyntaxColorVisitor.h"

+ 0 - 377
Source/AtomicEditor/Javascript/JSASTSyntaxColorVisitor.h

@@ -1,377 +0,0 @@
-//
-// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "JSASTVisitor.h"
-#include "JSTheme.h"
-
-#include <TurboBadger/tb_style_edit.h>
-
-using namespace tb;
-
-namespace AtomicEditor
-{
-
-// TBBlock::InsertText, handle text input, split/layout
-
-class JSASTSyntaxColorVisitor : public JSASTTraversalVisitor
-{
-public:
-
-    JSASTSyntaxColorVisitor(TBStyleEdit* styleEdit) : styleEdit_(styleEdit) {}
-
-    using JSASTTraversalVisitor::visit;
-
-    virtual JSASTExpression* visit(JSASTIdentifier* expr)
-    {
-        //SetLocColor(expr->GetLoc(), 6);
-        return expr;
-    }
-
-    virtual JSASTExpression* visit(JSASTLiteral* expr)
-    {
-        JSThemeColor color = JSTHEME_NORMAL;
-        switch (expr->GetLiteralType())
-        {
-        case JSASTLiteral::LITERAL_BOOLEAN:
-            color = JSTHEME_LITERAL_BOOLEAN;
-            break;
-        case JSASTLiteral::LITERAL_STRING:
-            color = JSTHEME_LITERAL_STRING;
-            break;
-        case JSASTLiteral::LITERAL_NULL:
-            color = JSTHEME_LITERAL_NULL;
-            break;
-        case JSASTLiteral::LITERAL_NUMBER:
-            color = JSTHEME_LITERAL_NUMBER;
-            break;
-        case JSASTLiteral::LITERAL_REGEX:
-            color = JSTHEME_LITERAL_REGEX;
-            break;
-
-        default:
-            break;
-        }
-
-        SetLocColor(expr->GetLoc(), color);
-        return expr;
-    }
-
-    virtual JSASTStatement* visit(JSASTFunctionDeclaration* decl)
-    {
-        SetLocColor(decl->GetLoc(), JSTHEME_FUNCTION, true);
-
-        JSASTNode* id = decl->GetID();
-        if (id)
-            SetLocColor(id->GetLoc(), JSTHEME_CODE, true);
-
-        for (unsigned i = 0; i < decl->GetParamsCount(); i++)
-        {
-            JSASTExpression* p = decl->GetParam(i);
-            SetLocColor(p->GetLoc(), JSTHEME_FUNCTIONDECLARG, true);
-        }
-
-
-        return JSASTTraversalVisitor::visit(decl);
-
-    }
-
-    virtual JSASTStatement* visit(JSASTVariableDeclaration* decl)
-    {
-        SetLocColor(decl->GetLoc(), JSTHEME_VAR, true);
-
-        SetLocColor(decl->GetLoc(), "=", JSTHEME_KEYWORD, true);
-
-        for (unsigned i = 0; i < decl->GetDeclarationsCount(); i++)
-        {
-            JSASTExpression* expr = decl->GetDeclaration(i);
-
-            if (expr->GetType() == JSAST_VARIABLEDECLARATOR)
-            {
-                JSASTVariableDeclarator* v = (JSASTVariableDeclarator*) expr;
-
-                if (JSASTExpression* init = v->GetInit())
-                {
-                    if (init->GetType() == JSAST_FUNCTIONEXPRESSION)
-                    {
-                        if (v->GetID())
-                            SetLocColor(v->GetID()->GetLoc(), JSTHEME_CODE, true);
-                    }
-                }
-            }
-
-        }
-
-        return JSASTTraversalVisitor::visit(decl);
-    }
-
-    virtual JSASTComment* visit(JSASTComment* comment)
-    {
-        SetLocColor(comment->GetLoc(), JSTHEME_COMMENT, false);
-        return comment;
-    }
-
-    virtual JSASTStatement* visit(JSASTIfStatement* stmt)
-    {
-        SetLocColor(stmt->GetLoc(), JSTHEME_KEYWORD, true);
-        return JSASTTraversalVisitor::visit(stmt);
-    }
-
-    virtual JSASTExpression* visit(JSASTConditionalExpression* expr)
-    {
-        return JSASTTraversalVisitor::visit(expr);
-    }
-
-
-    virtual JSASTStatement* visit(JSASTForStatement* stmt)
-    {
-        SetLocColor(stmt->GetLoc(), JSTHEME_KEYWORD, true);
-        return JSASTTraversalVisitor::visit(stmt);
-    }
-
-
-    virtual JSASTExpression* visit(JSASTCallExpression* expr)
-    {
-
-        JSASTNode* locNode = expr->GetCallee();
-        if (locNode->GetType() == JSAST_MEMBEREXPRESSION)
-        {
-            locNode = ((JSASTMemberExpression*) locNode)->GetProperty();
-        }
-
-        //SetLocColor(locNode->GetLoc(), 2);
-
-        return JSASTTraversalVisitor::visit(expr);
-    }
-
-    virtual JSASTStatement* visit(JSASTReturnStatement *stmt)
-    {
-        SetLocColor(stmt->GetLoc(), JSTHEME_KEYWORD, true);
-
-        return JSASTTraversalVisitor::visit(stmt);
-    }
-
-    virtual JSASTExpression* visit(JSASTUnaryExpression* expr)
-    {
-        const String& op = expr->GetOperator();
-
-        SetLocColor(expr->GetLoc(), op, JSTHEME_KEYWORD, false);
-
-        return JSASTTraversalVisitor::visit(expr);
-    }
-
-    virtual JSASTExpression* visit(JSASTUpdateExpression* expr)
-    {
-        const String& op = expr->GetOperator();
-
-        SetLocColor(expr->GetLoc(), op, JSTHEME_KEYWORD, false);
-
-        return JSASTTraversalVisitor::visit(expr);
-    }
-
-
-    virtual JSASTExpression* visit(JSASTBinaryExpression* expr)
-    {
-        const String& op = expr->GetOperator();
-
-        SetLocColor(expr->GetLoc(), op, JSTHEME_KEYWORD, false);
-
-        return JSASTTraversalVisitor::visit(expr);
-    }
-
-    virtual JSASTExpression* visit(JSASTAssignmentExpression* expr)
-    {
-        const String& op = expr->GetOperator();
-
-        SetLocColor(expr->GetLoc(), op, JSTHEME_KEYWORD, false);
-
-        return JSASTTraversalVisitor::visit(expr);
-    }
-
-    virtual JSASTExpression* visit(JSASTLogicalExpression* expr)
-    {
-        const String& op = expr->GetOperator();
-
-        SetLocColor(expr->GetLoc(), op, JSTHEME_KEYWORD, false);
-
-        return JSASTTraversalVisitor::visit(expr);
-    }
-
-
-    virtual JSASTExpression* visit(JSASTNewExpression* expr)
-    {
-        SetLocColor(expr->GetLoc(), JSTHEME_KEYWORD, true);
-
-        JSASTNode* locNode = expr->GetCallee();
-
-        if (locNode->GetType() == JSAST_MEMBEREXPRESSION)
-        {
-            locNode = ((JSASTMemberExpression*) locNode)->GetProperty();
-        }
-
-        return JSASTTraversalVisitor::visit(expr);
-    }
-
-    virtual JSASTExpression* visit(JSASTFunctionExpression* expr)
-    {
-        SetLocColor(expr->GetLoc(), "function", JSTHEME_FUNCTION, true);
-
-        for (unsigned i = 0; i < expr->GetParamsCount(); i++)
-        {
-            JSASTExpression* p = expr->GetParam(i);
-            SetLocColor(p->GetLoc(), JSTHEME_FUNCTIONDECLARG, true);
-        }
-
-        return JSASTTraversalVisitor::visit(expr);
-    }
-
-
-private:
-
-    void SetLocColor(const JSASTNode::Loc& loc, unsigned color, bool single = false)
-    {
-        if (!loc.Valid())
-            return;
-
-        PODVector<TBTextFragment*> fragments;
-        GetTextFragments(loc, fragments);
-        for (unsigned i = 0; i < fragments.Size(); i++)
-        {
-            fragments.At(i)->themeColor = color;
-            if (single)
-                break;
-        }
-    }
-
-    void SetLocColor(const JSASTNode::Loc& loc, const String& value, unsigned color, bool single = false)
-    {
-        if (!loc.Valid())
-            return;
-
-        String substring = value;
-
-        PODVector<TBTextFragment*> fragments;
-        GetTextFragments(loc, fragments);
-        for (unsigned i = 0; i < fragments.Size(); i++)
-        {
-            TBTextFragment* fragment = fragments[i];
-
-            if (!strncmp(substring.CString(), fragment->Str(), substring.Length()))
-            {
-                fragments.At(i)->themeColor = color;
-
-                substring = substring.Substring(fragments.At(i)->len);
-
-                if (single || !substring.Length())
-                    break;
-            }
-        }
-    }
-
-
-    TBTextFragment* GetFragmentAt( const JSASTNode::Loc& loc)
-    {
-        if (!loc.Valid())
-            return NULL;
-
-        int line = loc.startLine_ - 1;
-
-        TBBlock *block = styleEdit_->blocks.GetFirst();
-        int count = 0;
-        while (block && count < line)
-        {
-            block = block->GetNext();
-            count++;
-        }
-
-        if (!block)
-            return NULL;
-
-        for (TBTextFragment* frag = block->fragments.GetFirst(); frag; frag = frag->GetNext())
-        {
-            if (frag->ofs >= loc.startColumn_)
-                return frag;
-        }
-
-        return NULL;
-
-    }
-
-
-    void GetTextFragments( const JSASTNode::Loc& loc,  PODVector<TBTextFragment*>& fragments)
-    {
-        if (!loc.Valid())
-            return;
-
-        for (int lcounter = loc.startLine_; lcounter <= loc.endLine_; lcounter++)
-        {
-            int line = lcounter - 1;
-
-            TBBlock *block = styleEdit_->blocks.GetFirst();
-            int count = 0;
-            while (block && count < line)
-            {
-                block = block->GetNext();
-                count++;
-            }
-
-            if (!block)
-                return;
-
-            for (TBTextFragment* frag = block->fragments.GetFirst(); frag; frag = frag->GetNext())
-            {
-                if (loc.startLine_ == loc.endLine_)
-                {
-                    if (frag->ofs >= loc.startColumn_ && frag->ofs < loc.endColumn_)
-                        fragments.Push(frag);
-                }
-                else
-                {
-                    if (lcounter == loc.startLine_)
-                    {
-                        if (frag->ofs >= loc.startColumn_)
-                            fragments.Push(frag);
-
-                    }
-                    else if (lcounter == loc.endLine_)
-                    {
-                        if (frag->ofs < loc.endColumn_)
-                            fragments.Push(frag);
-
-                    }
-                    else
-                    {
-                        fragments.Push(frag);
-                    }
-                }
-            }
-        }
-
-    }
-
-    TBStyleEdit* styleEdit_;
-
-};
-
-
-}

+ 0 - 23
Source/AtomicEditor/Javascript/JSASTVisitor.cpp

@@ -1,23 +0,0 @@
-//
-// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include "JSASTVisitor.h"

+ 0 - 398
Source/AtomicEditor/Javascript/JSASTVisitor.h

@@ -1,398 +0,0 @@
-//
-// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-#include "JSAST.h"
-
-namespace AtomicEditor
-{
-
-class JSASTVisitor
-{
-public:
-
-    virtual JSASTProgram* visit(JSASTProgram *program) = 0;
-
-    virtual JSASTStatement* visit(JSASTBlockStatement *stmt) = 0;
-    virtual JSASTStatement* visit(JSASTExpressionStatement *stmt) = 0;
-    virtual JSASTStatement* visit(JSASTIfStatement *stmt) = 0;
-    virtual JSASTStatement* visit(JSASTFunctionDeclaration *stmt) = 0;
-    virtual JSASTStatement* visit(JSASTVariableDeclaration *stmt) = 0;
-    virtual JSASTStatement* visit(JSASTReturnStatement *stmt) = 0;
-    virtual JSASTStatement* visit(JSASTEmptyStatement *stmt) = 0;
-    virtual JSASTStatement* visit(JSASTForStatement *stmt) = 0;
-
-    virtual JSASTExpression* visit(JSASTAssignmentExpression* expr) = 0;
-    virtual JSASTExpression* visit(JSASTLogicalExpression* expr) = 0;
-    virtual JSASTExpression* visit(JSASTConditionalExpression* expr) = 0;
-    virtual JSASTExpression* visit(JSASTThisExpression* expr) = 0;
-
-    virtual JSASTExpression* visit(JSASTIdentifier* expr) = 0;
-    virtual JSASTExpression* visit(JSASTCallExpression* expr) = 0;
-    virtual JSASTExpression* visit(JSASTBinaryExpression* expr) = 0;
-    virtual JSASTExpression* visit(JSASTMemberExpression* expr) = 0;
-    virtual JSASTExpression* visit(JSASTLiteral* expr) = 0;
-    virtual JSASTExpression* visit(JSASTArrayExpression* expr) = 0;
-    virtual JSASTExpression* visit(JSASTObjectExpression* expr) = 0;
-    virtual JSASTExpression* visit(JSASTFunctionExpression* expr) = 0;
-    virtual JSASTExpression* visit(JSASTNewExpression* expr) = 0;
-    virtual JSASTExpression* visit(JSASTUnaryExpression* expr) = 0;
-    virtual JSASTExpression* visit(JSASTUpdateExpression* expr) = 0;
-    virtual JSASTExpression* visit(JSASTVariableDeclarator* expr) = 0;
-
-    virtual JSASTProperty* visit(JSASTProperty* property) = 0;
-    virtual JSASTStatement*  visit(JSASTLabeledStatement* property) = 0;
-
-    virtual JSASTComment* visit(JSASTComment* expr) = 0;
-
-};
-
-class JSASTTraversalVisitor : public JSASTVisitor
-{
-public:
-
-    virtual JSASTProgram* visit(JSASTProgram *program)
-    {
-        // this would cause recursion
-        // program->Accept(this);
-
-        unsigned count = program->GetCommentCount();
-        for (unsigned i = 0; i < count; i++)
-        {
-            JSASTComment* cmt = program->GetComment(i);
-            if (cmt)
-                cmt->Accept(this);
-        }
-
-
-        count = program->GetStatementCount();
-        for (unsigned i = 0; i < count; i++)
-        {
-            JSASTStatement* stmt = program->GetStatement(i);
-            if (stmt)
-                stmt->Accept(this);
-        }
-
-        return program;
-
-    }
-
-    virtual JSASTStatement* visit(JSASTForStatement *stmt)
-    {
-        if (stmt->GetInitVariable())
-            stmt->GetInitVariable()->Accept(this);
-        if (stmt->GetInitExpression())
-            stmt->GetInitExpression()->Accept(this);
-
-        if (stmt->GetTest())
-            stmt->GetTest()->Accept(this);
-
-        if (stmt->GetUpdate())
-            stmt->GetUpdate()->Accept(this);
-
-        if (stmt->GetBody())
-            stmt->GetBody()->Accept(this);
-
-        return stmt;
-
-    }
-
-    virtual JSASTStatement* visit(JSASTBlockStatement *block)
-    {
-        unsigned count = block->GetStatementCount();
-
-        for (unsigned i = 0; i < count; i++)
-        {
-            JSASTStatement* stmt = block->GetStatement(i);
-            if (stmt)
-                stmt->Accept(this);
-        }
-
-        return block;
-
-    }
-
-    virtual JSASTStatement* visit(JSASTExpressionStatement *stmt)
-    {
-        if (stmt->GetExpression())
-            stmt->GetExpression()->Accept(this);
-
-        return stmt;
-    }
-
-    virtual JSASTStatement* visit(JSASTIfStatement *stmt)
-    {
-        if (stmt->GetTest())
-            stmt->GetTest()->Accept(this);
-        if (stmt->GetConsequent())
-            stmt->GetConsequent()->Accept(this);
-        if (stmt->GetAlternate())
-            stmt->GetAlternate()->Accept(this);
-
-        return stmt;
-    }
-
-    virtual JSASTStatement* visit(JSASTFunctionDeclaration *stmt)
-    {
-        if (stmt->GetID())
-            stmt->GetID()->Accept(this);
-
-        for (unsigned i = 0; i < stmt->GetParamsCount(); i++)
-            stmt->GetParam(i)->Accept(this);
-
-        JSASTBlockStatement* body = stmt->GetBodyStatement();
-
-        if (body)
-            body->Accept(this);
-
-        return stmt;
-
-    }
-
-    virtual JSASTStatement* visit(JSASTVariableDeclaration *stmt)
-    {
-        for (unsigned i = 0; i < stmt->GetDeclarationsCount(); i++)
-            stmt->GetDeclaration(i)->Accept(this);
-
-        return stmt;
-    }
-
-    virtual JSASTStatement* visit(JSASTReturnStatement *stmt)
-    {
-        if (stmt->GetArgument())
-            stmt->GetArgument()->Accept(this);
-
-        return stmt;
-    }
-
-    virtual JSASTStatement* visit(JSASTEmptyStatement *stmt)
-    {
-        return stmt;
-    }
-
-    virtual JSASTExpression* visit(JSASTAssignmentExpression* expr)
-    {
-        if (expr->GetLeft())
-            expr->GetLeft()->Accept(this);
-
-        if (expr->GetRight())
-            expr->GetRight()->Accept(this);
-
-        return expr;
-
-    }
-
-    virtual JSASTExpression* visit(JSASTConditionalExpression *expr)
-    {
-        if (expr->GetTest())
-            expr->GetTest()->Accept(this);
-        if (expr->GetConsequent())
-            expr->GetConsequent()->Accept(this);
-        if (expr->GetAlternate())
-            expr->GetAlternate()->Accept(this);
-
-        return expr;
-    }
-
-
-    virtual JSASTExpression* visit(JSASTLogicalExpression* expr)
-    {
-        if (expr->GetLeft())
-            expr->GetLeft()->Accept(this);
-
-        if (expr->GetRight())
-            expr->GetRight()->Accept(this);
-
-        return expr;
-
-    }
-
-    virtual JSASTExpression* visit(JSASTIdentifier* expr)
-    {
-        return expr;
-    }
-
-    virtual JSASTExpression* visit(JSASTCallExpression* expr)
-    {
-        if (expr->GetCallee())
-            expr->GetCallee()->Accept(this);
-
-        for (unsigned i = 0; i < expr->GetArgumentCount(); i++)
-        {   if (expr->GetArgument(i))
-                expr->GetArgument(i)->Accept(this);
-        }
-
-        return expr;
-    }
-
-    virtual JSASTExpression* visit(JSASTBinaryExpression* expr)
-    {
-        if (expr->GetLeft())
-            expr->GetLeft()->Accept(this);
-
-        if (expr->GetRight())
-            expr->GetRight()->Accept(this);
-
-        return expr;
-
-    }
-
-    virtual JSASTExpression* visit(JSASTMemberExpression* expr)
-    {
-        if (expr->GetObject())
-            expr->GetObject()->Accept(this);
-
-        if (expr->GetProperty())
-            expr->GetProperty()->Accept(this);
-
-        return expr;
-
-    }
-
-    virtual JSASTExpression* visit(JSASTLiteral* expr)
-    {
-        return expr;
-    }
-
-    virtual JSASTExpression* visit(JSASTArrayExpression* expr)
-    {
-        for (unsigned i = 0; i < expr->GetElementCount(); i++)
-        {
-            JSASTExpression* arrayElement = expr->GetElement(i);
-            if (arrayElement)
-                arrayElement->Accept(this);
-        }
-
-        return expr;
-    }
-
-    virtual JSASTExpression* visit(JSASTObjectExpression* expr)
-    {
-        for (unsigned i = 0; i < expr->GetPropertyCount(); i++)
-        {
-            JSASTProperty* property = expr->GetProperty(i);
-
-            if (property)
-                property->Accept(this);
-        }
-
-        return expr;
-    }
-
-    virtual JSASTExpression* visit(JSASTFunctionExpression* expr)
-    {
-        if (expr->GetID())
-            expr->GetID()->Accept(this);
-
-        for (unsigned i = 0; i < expr->GetParamsCount(); i++)
-            expr->GetParam(i)->Accept(this);
-
-        JSASTBlockStatement* body = expr->GetBodyStatement();
-
-        if (body)
-            body->Accept(this);
-
-        return expr;
-
-    }
-
-    virtual JSASTExpression* visit(JSASTNewExpression* expr)
-    {
-        if (expr->GetCallee())
-            expr->GetCallee()->Accept(this);
-
-        for (unsigned i = 0; i < expr->GetArgumentCount(); i++)
-        {
-            if (expr->GetArgument(i))
-                expr->GetArgument(i)->Accept(this);
-        }
-
-        return expr;
-
-    }
-
-    virtual JSASTExpression* visit(JSASTUnaryExpression* expr)
-    {
-        if (expr->GetArgument())
-            expr->GetArgument()->Accept(this);
-
-        return expr;
-    }
-
-    virtual JSASTExpression* visit(JSASTUpdateExpression* expr)
-    {
-        if (expr->GetArgument())
-            expr->GetArgument()->Accept(this);
-
-        return expr;
-    }
-
-    virtual JSASTExpression* visit(JSASTVariableDeclarator* expr)
-    {
-        if (expr->GetID())
-            expr->GetID()->Accept(this);
-
-        if (expr->GetInit())
-            expr->GetInit()->Accept(this);
-
-
-        return expr;
-    }
-
-    virtual JSASTComment* visit(JSASTComment* comment)
-    {
-        return comment;
-    }
-
-    virtual JSASTProperty* visit(JSASTProperty* property)
-    {
-        if (property->GetKey())
-            property->GetKey()->Accept(this);
-        if (property->GetValue())
-            property->GetValue()->Accept(this);
-
-        return property;
-    }
-
-    virtual JSASTStatement* visit(JSASTLabeledStatement* labeledStatement)
-    {
-        if (labeledStatement->GetLabel())
-            labeledStatement->GetLabel()->Accept(this);
-        if (labeledStatement->GetBody())
-            labeledStatement->GetBody()->Accept(this);
-
-        return labeledStatement;
-    }
-
-
-    virtual JSASTExpression* visit(JSASTThisExpression* expr)
-    {
-        return expr;
-    }
-
-
-};
-
-
-
-}

+ 0 - 43
Source/AtomicEditor/Javascript/JSErrorChecker.cpp

@@ -1,43 +0,0 @@
-//
-// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#include <Atomic/Core/Context.h>
-#include "JSErrorChecker.h"
-
-namespace AtomicEditor
-{
-
-/// Construct.
-JSErrorChecker::JSErrorChecker(Context* context, duk_context *ctx) :
-    Object(context),
-    ctx_(ctx)
-{
-
-}
-
-/// Destruct.
-JSErrorChecker::~JSErrorChecker()
-{
-
-}
-
-}

+ 0 - 320
Source/AtomicEditor/Javascript/JSSpiderMonkeyVM.cpp

@@ -1,320 +0,0 @@
-//
-// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#ifdef USE_SPIDERMONKEY
-
-#include "AtomicEditor.h"
-#include "/Users/josh/Desktop/SpiderMonkey/include/mozjs-37a1/jsapi.h"
-#include "js/RootingAPI.h"
-#include "JSSpiderMonkeyVM.h"
-
-using namespace JS;
-
-#include "Context.h"
-#include "FileSystem.h"
-#include "ResourceCache.h"
-#include "JSFile.h"
-
-static RootedObject* __global = NULL;
-
-// The class of the global object.
-static JSClass globalClass = {
-    "global",
-    JSCLASS_GLOBAL_FLAGS,
-    JS_PropertyStub,
-    JS_DeletePropertyStub,
-    JS_PropertyStub,
-    JS_StrictPropertyStub,
-    JS_EnumerateStub,
-    JS_ResolveStub,
-    JS_ConvertStub,
-    nullptr, nullptr, nullptr, nullptr,
-    JS_GlobalObjectTraceHook
-};
-
-// The error reporter callback.
-void reportError(JSContext *cx, const char *message, JSErrorReport *report) {
-    fprintf(stderr, "%s:%u:%s\n",
-            report->filename ? report->filename : "[no filename]",
-            (unsigned int) report->lineno,
-            message);
-}
-
-
-namespace AtomicEditor
-{
-
-
-
-WeakPtr<JSSpiderMonkeyVM> JSSpiderMonkeyVM::instance_;
-
-static bool
-print(JSContext *cx, unsigned argc, jsval *vp)
-{
-    JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
-
-    for (unsigned i = 0; i < args.length(); i++) {
-        JSString *str = JS::ToString(cx, args[i]);
-        if (!str)
-            return false;
-        char *bytes = JS_EncodeString(cx, str);
-        if (!bytes)
-            return false;
-        printf("%s%s", i ? " " : "", bytes);
-        JS_free(cx, bytes);
-    }
-
-    putchar('\n');
-    fflush(stdout);
-    args.rval().setUndefined();
-    return true;
-}
-
-JSSpiderMonkeyVM::JSSpiderMonkeyVM(Context* context) :
-    Object(context), runtime_(0), jscontext_(0),
-    autorequest_(0), autocompartment_(0)
-{
-    context_->RegisterSubsystem(this);
-    instance_ = this;
-
-    // Initialize the JS engine.
-    if (!JS_Init())
-    {
-        assert(0);
-    }
-
-    // Create a JS runtime.
-    runtime_ = JS_NewRuntime(32L * 1024L * 1024L);
-
-    if (runtime_)
-    {
-        jscontext_ = JS_NewContext(runtime_, 8192);
-        if (jscontext_)
-        {
-            JS_SetErrorReporter(runtime_, reportError);
-        }
-        else
-        {
-            assert(0);
-        }
-
-    }
-    else
-    {
-        assert(0);
-    }
-
-    // Enter a request before running anything in the context.
-    autorequest_ = new JSAutoRequest(jscontext_);
-
-    // Create the global object and a new compartment.
-    __global = new RootedObject(jscontext_);
-    *__global = JS_NewGlobalObject(jscontext_, &globalClass, nullptr,
-                                   JS::DontFireOnNewGlobalHook);
-    // Enter the new global object's compartment.
-    autocompartment_ = new JSAutoCompartment(jscontext_, *__global);
-
-    // Populate the global object with the standard globals, like Object and
-    // Array.
-    if (!JS_InitStandardClasses(jscontext_, *__global))
-    {
-        assert(0);
-    }
-
-    if (!JS_InitReflect(jscontext_, *__global))
-    {
-        assert(0);
-    }
-
-    JS_DefineFunction(jscontext_, *__global, "print", (JSNative) print, 0, 0);
-
-    ExecuteFile("AtomicEditor/javascript/modules/acorn_spidermonkey.js");
-
-}
-
-JSSpiderMonkeyVM::~JSSpiderMonkeyVM()
-{
-    instance_ = NULL;
-
-    if (autocompartment_)
-        delete autocompartment_;
-
-    if (__global)
-    {
-        delete __global;
-        __global = NULL;
-    }
-
-    if (autorequest_)
-        delete autorequest_;
-
-    // Shut everything down.
-    if (context_)
-        JS_DestroyContext(jscontext_);
-    if (runtime_)
-        JS_DestroyRuntime(runtime_);
-
-    JS_ShutDown();
-
-}
-
-bool JSSpiderMonkeyVM::ExecuteFile(const String& path)
-{
-    SharedPtr<JSFile> jsfile;
-    jsfile = GetSubsystem<ResourceCache>()->GetResource<JSFile>(path);
-
-    JS::RootedValue returnValue(jscontext_);
-
-    OwningCompileOptions options(jscontext_);
-
-    options.setFileAndLine(jscontext_, path.CString(), 0);
-    options.setCompileAndGo(true);
-    bool ok = JS::Evaluate(jscontext_, *__global, options,
-                           jsfile->GetSource(), strlen(jsfile->GetSource()), &returnValue);
-
-    return ok;
-
-}
-
-bool JSSpiderMonkeyVM::ParseJavascriptToJSON(const char* source, String& json)
-{
-    json.Clear();
-
-    bool ok = true;
-
-    JS::Rooted<JS::Value> v(jscontext_);
-    JS::RootedValue returnValue(jscontext_);
-    JS::RootedValue jsource(jscontext_, JS::StringValue(JS_NewStringCopyZ(jscontext_, source)));
-    JS_CallFunctionName(jscontext_, *__global, "__atomic_parse_to_json", HandleValueArray(jsource), &returnValue);
-
-    JS::RootedString hm(jscontext_);
-    hm = JS::ToString(jscontext_, returnValue);
-
-    const char* strjson = JS_EncodeStringToUTF8(jscontext_, hm);
-
-    json = strjson;
-
-    //printf("%s\n", strjson);
-
-    JS_free(jscontext_, (void *) strjson);
-
-    return ok;
-
-}
-
-
-bool JSSpiderMonkeyVM::ParseJavascriptToJSONWithSpiderMonkeyReflectAPI(const char* source, String& json)
-{
-    json.Clear();
-
-    bool ok = true;
-
-    JS::Rooted<JS::Value> v(jscontext_);
-    JS::RootedValue returnValue(jscontext_);
-    JS::RootedValue jsource(jscontext_, JS::StringValue(JS_NewStringCopyZ(jscontext_, source)));
-
-    // get the Reflect object
-    if (!JS_GetProperty(jscontext_, *__global, "Reflect", &v))
-        return false;
-
-    JS::RootedObject reflectObject(jscontext_);
-    JS_ValueToObject(jscontext_, v, &reflectObject);
-
-    JS_CallFunctionName(jscontext_, reflectObject, "parse", HandleValueArray(jsource), &returnValue);
-
-    JS::RootedObject jsonObject(jscontext_);
-    if (!JS_GetProperty(jscontext_, *__global, "JSON", &v))
-        return false;
-
-    JS_ValueToObject(jscontext_, v, &jsonObject);
-
-    // pretty printed, can remove for speed
-    JS::AutoValueArray<3> args(jscontext_);
-    args[0].set(returnValue);
-    args[1].set(JS::NullValue());
-    args[2].setNumber(3.0);
-
-    JS::RootedValue jjson(jscontext_);
-    JS_CallFunctionName(jscontext_, jsonObject, "stringify", HandleValueArray(args), &jjson);
-
-    JS::RootedString hm(jscontext_);
-    hm = JS::ToString(jscontext_, jjson);
-
-    const char* strjson = JS_EncodeStringToUTF8(jscontext_, hm);
-
-    json = strjson;
-
-    //printf("%s\n", strjson);
-
-    JS_free(jscontext_, (void *) strjson);
-
-    return ok;
-
-}
-
-bool JSSpiderMonkeyVM::ReadZeroTerminatedSourceFile(const String& path, String& source)
-{
-    File file(instance_->GetContext());
-    file.Open(path);
-
-    unsigned size = file.GetSize();
-
-    SharedArrayPtr<char> data;
-    data = new char[size + 1];
-    data[size] = '\0';
-    file.Read(data, size);
-
-    source = data;
-
-    return true;
-
-}
-
-
-}
-
-int run(JSContext *cx) {
-    // Enter a request before running anything in the context.
-    JSAutoRequest ar(cx);
-
-    // Create the global object and a new compartment.
-    RootedObject global(cx);
-    global = JS_NewGlobalObject(cx, &globalClass, nullptr,
-                                JS::DontFireOnNewGlobalHook);
-    if (!global)
-        return 1;
-
-    // Enter the new global object's compartment.
-    JSAutoCompartment ac(cx, global);
-
-    // Populate the global object with the standard globals, like Object and
-    // Array.
-    if (!JS_InitStandardClasses(cx, global))
-        return 1;
-
-    // Your application code here. This may include JSAPI calls to create your
-    // own custom JS objects and run scripts.
-
-    return 0;
-}
-
-#endif

+ 0 - 74
Source/AtomicEditor/Javascript/JSSpiderMonkeyVM.h

@@ -1,74 +0,0 @@
-//
-// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#ifdef USE_SPIDERMONKEY
-#pragma once
-
-#include "Object.h"
-
-using namespace Atomic;
-
-struct JSRuntime;
-struct JSContext;
-class JSAutoRequest;
-class JSAutoCompartment;
-
-namespace AtomicEditor
-{
-
-// Notes: SpiderMonkey Reflect API is giving some bad loc's, which seems to be an issue with the
-// C++ generator not passing in tokens for some nodes (MemberExpression.property for example)
-// probably should use http://esprima.org/
-class JSSpiderMonkeyVM : public Object
-{
-    OBJECT(JSSpiderMonkeyVM);
-
-public:
-    /// Construct.
-    JSSpiderMonkeyVM(Context* context);
-    /// Destruct.
-    ~JSSpiderMonkeyVM();
-
-    bool ExecuteFile(const String& path);
-
-    bool ParseJavascriptToJSON(const char* source, String& json);
-
-    bool ParseJavascriptToJSONWithSpiderMonkeyReflectAPI(const char* source, String& json);
-
-private:
-
-    bool ReadZeroTerminatedSourceFile(const String& path, String& source);
-
-    // for access within duktape callbacks
-    static WeakPtr<JSSpiderMonkeyVM> instance_;
-
-    JSRuntime* runtime_;
-    JSContext* jscontext_;
-    JSAutoRequest* autorequest_;
-    JSAutoCompartment* autocompartment_;
-
-};
-
-
-}
-
-#endif

+ 0 - 21
Source/AtomicEditor/Javascript/JSTheme.cpp

@@ -1,21 +0,0 @@
-//
-// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//

+ 0 - 200
Source/AtomicEditor/Javascript/JSTheme.h

@@ -1,200 +0,0 @@
-//
-// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#pragma once
-
-namespace AtomicEditor
-{
-
-// //http://hilightjs.org
-
-enum JSThemeColor
-{
-    JSTHEME_NORMAL,
-    JSTHEME_LITERAL_STRING,
-    JSTHEME_LITERAL_BOOLEAN,
-    JSTHEME_LITERAL_NUMBER,
-    JSTHEME_LITERAL_REGEX,
-    JSTHEME_LITERAL_NULL,
-    JSTHEME_KEYWORD,
-    JSTHEME_OPERATOR,
-    JSTHEME_FUNCTION,
-    JSTHEME_VAR,
-    JSTHEME_CODE,
-    JSTHEME_COMMENT,
-    JSTHEME_FUNCTIONDECLARG
-};
-
-
-}
-/*
-
-.hljs {
-  display: block;
-  overflow-x: auto;
-  padding: 0.5em;
-  background: #23241f;
-  -webkit-text-size-adjust: none;
-}
-
-.hljs,
-.hljs-tag,
-.css .hljs-rules,
-.css .hljs-value,
-.aspectj .hljs-function,
-.css .hljs-function
-.hljs-preprocessor,
-.hljs-pragma {
-  color: #f8f8f2;
-}
-
-.hljs-strongemphasis,
-.hljs-strong,
-.hljs-emphasis {
-  color: #a8a8a2;
-}
-
-.hljs-bullet,
-.hljs-blockquote,
-.hljs-horizontal_rule,
-.hljs-number,
-.hljs-regexp,
-.alias .hljs-keyword,
-.hljs-literal,
-.hljs-hexcolor {
-  color: #ae81ff;
-}
-
-.hljs-tag .hljs-value,
-.hljs-code,
-.hljs-title,
-.css .hljs-class,
-.hljs-class .hljs-title:last-child {
-  color: #a6e22e;
-}
-
-.hljs-link_url {
-  font-size: 80%;
-}
-
-.hljs-strong,
-.hljs-strongemphasis {
-  font-weight: bold;
-}
-
-.hljs-emphasis,
-.hljs-strongemphasis,
-.hljs-class .hljs-title:last-child,
-.hljs-typename {
-  font-style: italic;
-}
-
-.hljs-keyword,
-.ruby .hljs-class .hljs-keyword:first-child,
-.ruby .hljs-function .hljs-keyword,
-.hljs-function,
-.hljs-change,
-.hljs-winutils,
-.hljs-flow,
-.nginx .hljs-title,
-.tex .hljs-special,
-.hljs-header,
-.hljs-attribute,
-.hljs-symbol,
-.hljs-symbol .hljs-string,
-.hljs-tag .hljs-title,
-.hljs-value,
-.alias .hljs-keyword:first-child,
-.css .hljs-tag,
-.css .unit,
-.css .hljs-important {
-  color: #f92672;
-}
-
-.hljs-function .hljs-keyword,
-.hljs-class .hljs-keyword:first-child,
-.hljs-aspect .hljs-keyword:first-child,
-.hljs-constant,
-.hljs-typename,
-.css .hljs-attribute {
-  color: #66d9ef;
-}
-
-.hljs-variable,
-.hljs-params,
-.hljs-class .hljs-title,
-.hljs-aspect .hljs-title {
-  color: #f8f8f2;
-}
-
-.hljs-string,
-.css .hljs-id,
-.hljs-subst,
-.hljs-type,
-.ruby .hljs-class .hljs-parent,
-.hljs-built_in,
-.django .hljs-template_tag,
-.django .hljs-variable,
-.smalltalk .hljs-class,
-.django .hljs-filter .hljs-argument,
-.smalltalk .hljs-localvars,
-.smalltalk .hljs-array,
-.hljs-attr_selector,
-.hljs-pseudo,
-.hljs-addition,
-.hljs-stream,
-.hljs-envvar,
-.apache .hljs-tag,
-.apache .hljs-cbracket,
-.tex .hljs-command,
-.hljs-prompt,
-.hljs-link_label,
-.hljs-link_url {
-  color: #e6db74;
-}
-
-.hljs-comment,
-.hljs-javadoc,
-.hljs-annotation,
-.hljs-decorator,
-.hljs-pi,
-.hljs-doctype,
-.hljs-deletion,
-.hljs-shebang,
-.apache .hljs-sqbracket,
-.tex .hljs-formula {
-  color: #75715e;
-}
-
-.coffeescript .javascript,
-.javascript .xml,
-.tex .hljs-formula,
-.xml .javascript,
-.xml .vbscript,
-.xml .css,
-.xml .hljs-cdata,
-.xml .php,
-.php .xml {
-  opacity: 0.5;
-}
-
-*/

+ 0 - 9
Source/ToolCore/Assets/CSharpImporter.cpp

@@ -26,7 +26,6 @@
 
 #include "../ToolSystem.h"
 #include "../Project/Project.h"
-#include "../NETTools/NETBuildSystem.h"
 
 #include "Asset.h"
 #include "AssetDatabase.h"
@@ -53,14 +52,6 @@ namespace ToolCore
 
     bool CSharpImporter::Import()
     {
-        using namespace NETBuildAtomicProject;
-
-        VariantMap eventData;
-        eventData[P_PROJECT] = GetSubsystem<ToolSystem>()->GetProject();
-
-        // We need to rebuild the project assembly
-        SendEvent(E_NETBUILDATOMICPROJECT, eventData);
-
         return true;
     }
 

+ 10 - 24
Source/ToolCore/NETTools/NETBuildSystem.cpp

@@ -33,6 +33,7 @@
 #include "../Subprocess/SubprocessSystem.h"
 #include "../Project/Project.h"
 
+#include "NETProjectSystem.h"
 #include "NETProjectGen.h"
 #include "NETBuildSystem.h"
 
@@ -122,7 +123,7 @@ namespace ToolCore
                 }
 
             }
-            
+
         }
         else
         {
@@ -197,27 +198,12 @@ namespace ToolCore
                     CurrentBuildError(ToString("Error loading project (%s), project expired", solutionPath.CString()));
                 }
 
-                Project* project = curBuild_->project_;
-
-                SharedPtr<NETProjectGen> gen(new NETProjectGen(context_));
-
-                gen->SetScriptPlatform(curBuild_->platform_);
-
-                if (!gen->LoadProject(project))
-                {
-                    CurrentBuildError(ToString("Error loading project (%s)", solutionPath.CString()));
-                    return;
-                }
-
-                if (!gen->Generate())
-                {
-                    CurrentBuildError(ToString("Error generating project (%s)", solutionPath.CString()));
-                    return;
-                }
+                NETProjectSystem* projectSystem = GetSubsystem<NETProjectSystem>();
 
-                solutionPath = gen->GetSolution()->GetOutputFilename();
-                requiresNuGet = gen->GetRequiresNuGet();
+                solutionPath = projectSystem->GetSolutionPath();
 
+                // TODO: handle projects that require nuget
+                requiresNuGet = false;
 
                 if (!fileSystem->FileExists(solutionPath))
                 {
@@ -273,7 +259,7 @@ namespace ToolCore
             }
 
             String vcvars64 = ToString("%s..\\..\\VC\\bin\\amd64\\vcvars64.bat", cmdToolsPath.CString());
-            
+
             const String configuration = curBuild_->configuration_;
 
             String cmd = "cmd";
@@ -323,7 +309,7 @@ namespace ToolCore
     }
 
 
-    NETBuild* NETBuildSystem::GetBuild(const String& solutionPath, const String& platform,  const String& configuration)
+    NETBuild* NETBuildSystem::GetBuild(const String& solutionPath, const String& platform, const String& configuration)
     {
         List<SharedPtr<NETBuild>>::ConstIterator itr = builds_.Begin();
 
@@ -380,7 +366,7 @@ namespace ToolCore
         }
 
         LOGINFOF("Received build for project %s", project->GetProjectFilePath().CString());
-            
+
     }
 
     NETBuild* NETBuildSystem::Build(const String& solutionPath, const String& platform, const String& configuration)
@@ -403,7 +389,7 @@ namespace ToolCore
         // Create a new build
         build = new NETBuild(context_, solutionPath, platform, configuration);
 
-        builds_.Push(build);        
+        builds_.Push(build);
 
         return build;
     }

+ 48 - 2
Source/ToolCore/NETTools/NETProjectGen.cpp

@@ -369,7 +369,9 @@ namespace ToolCore
 
     bool NETCSProject::Generate()
     {
+        FileSystem* fileSystem = GetSubsystem<FileSystem>();
         NETSolution* solution = projectGen_->GetSolution();
+        ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
 
         projectPath_ = solution->GetOutputPath() + name_ + "/";
 
@@ -401,13 +403,56 @@ namespace ToolCore
 
         project.CreateChild("Import").SetAttribute("Project", "$(MSBuildToolsPath)\\Microsoft.CSharp.targets");
 
-        if (name_ == "AtomicProject")
+        Project* atomicProject = projectGen_->GetAtomicProject();
+
+        if (atomicProject)
         {
             XMLElement afterBuild = project.CreateChild("Target");
             afterBuild.SetAttribute("Name", "AfterBuild");
             XMLElement copy = afterBuild.CreateChild("Copy");
             copy.SetAttribute("SourceFiles", "$(TargetPath)");
             copy.SetAttribute("DestinationFolder", projectPath_ + "../../../Resources/");
+
+            // Create the AtomicProject.csproj.user file if it doesn't exist
+            String userSettingsFilename = projectPath_ + name_ + ".csproj.user";
+            if (!fileSystem->FileExists(userSettingsFilename))
+            {
+                SharedPtr<XMLFile> userSettings(new XMLFile(context_));
+
+                XMLElement project = userSettings->CreateRoot("Project");
+                
+                //XMLElement xml = userRoot.CreateChild("?xml");
+                //xml.SetAttribute("version", "1.0");
+                //xml.SetAttribute("encoding", "utf-8");
+
+                project.SetAttribute("ToolsVersion", "14.0");
+                project.SetAttribute("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
+
+                StringVector configs;
+                configs.Push("Debug");
+                configs.Push("Release");
+
+                for (unsigned i = 0; i < configs.Size(); i++)
+                {
+                    String cfg = configs[i];
+
+                    XMLElement propertyGroup = project.CreateChild("PropertyGroup");
+                    propertyGroup.SetAttribute("Condition", ToString("'$(Configuration)|$(Platform)' == '%s|AnyCPU'", cfg.CString()));
+
+                    String playerBin = tenv->GetAtomicNETRootDir() + cfg + "/AtomicPlayer.exe";
+                    propertyGroup.CreateChild("StartAction").SetValue("Program");                    
+                    propertyGroup.CreateChild("StartProgram").SetValue(playerBin );
+                    propertyGroup.CreateChild("StartArguments").SetValue(ToString("--project %s", atomicProject->GetProjectPath().CString()));
+                    
+                }
+
+                String userSettingsSource = userSettings->ToString();
+                SharedPtr<File> output(new File(context_, userSettingsFilename, FILE_WRITE));
+                output->Write(userSettingsSource.CString(), userSettingsSource.Length());
+                output->Close();
+
+            }
+            
         }
 
         String projectSource = xmlFile_->ToString();
@@ -700,8 +745,9 @@ namespace ToolCore
         FileSystem* fileSystem = GetSubsystem<FileSystem>();
         ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
 
-        JSONValue root;
+        atomicProject_ = project;
 
+        JSONValue root;
         JSONValue solution;
 
         solution["name"] = "AtomicProject";

+ 3 - 0
Source/ToolCore/NETTools/NETProjectGen.h

@@ -152,6 +152,8 @@ namespace ToolCore
 
         const Vector<SharedPtr<NETCSProject>>& GetCSProjects() { return projects_; }
 
+        Project* GetAtomicProject() const { return atomicProject_;  }
+
         NETCSProject* GetCSProjectByName(const String& name);
 
         bool GetCSProjectDependencies(NETCSProject * source, PODVector<NETCSProject*>& depends) const;
@@ -173,6 +175,7 @@ namespace ToolCore
 
         String scriptPlatform_;
 
+        SharedPtr<Project> atomicProject_;
         SharedPtr<NETSolution> solution_;
         Vector<SharedPtr<NETCSProject>> projects_;
 

+ 253 - 0
Source/ToolCore/NETTools/NETProjectSystem.cpp

@@ -0,0 +1,253 @@
+//
+// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#include <Poco/Environment.h>
+
+#include <Atomic/Core/CoreEvents.h>
+
+#include <Atomic/IO/Log.h>
+#include <Atomic/IO/FileSystem.h>
+#include <Atomic/Resource/ResourceEvents.h>
+
+#include "../ToolSystem.h"
+#include "../Assets/AssetEvents.h"
+#include "../Project/Project.h"
+#include "../Project/ProjectEvents.h"
+
+#include "../Subprocess/SubprocessSystem.h"
+
+#include "NETProjectGen.h"
+#include "NETBuildSystem.h"
+#include "NETProjectSystem.h"
+
+namespace ToolCore
+{
+
+    NETProjectSystem::NETProjectSystem(Context* context) :
+        Object(context)
+    {
+        Initialize();
+    }
+
+    NETProjectSystem::~NETProjectSystem()
+    {
+
+    }
+
+    void NETProjectSystem::Clear()
+    {
+        quietPeriod_ = 0.0f;
+        solutionPath_.Clear();
+        projectAssemblyPath_.Clear();
+        solutionDirty_ = false;
+        projectAssemblyDirty_ = false;
+    }
+
+    void NETProjectSystem::OpenSourceFile(const String& sourceFilePath)
+    {
+        if (!visualStudioPath_.Length())
+            return;
+
+        StringVector args;
+
+        if (vsSubprocess_.Expired())
+        {
+            SubprocessSystem* subs = GetSubsystem<SubprocessSystem>();
+            vsSubprocess_ = 0;
+
+            args.Push(solutionPath_);
+            args.Push(sourceFilePath);
+
+            try
+            {
+                vsSubprocess_ = subs->Launch(visualStudioPath_, args);
+            }
+            catch (Poco::SystemException)
+            {
+                vsSubprocess_ = 0;
+            }
+
+        }
+        else
+        {
+            try
+            {
+                std::vector<std::string> args;
+                args.push_back("/edit");
+                args.push_back(sourceFilePath.CString());
+                Poco::Process::launch(visualStudioPath_.CString(), args);
+
+            }
+            catch (Poco::SystemException)
+            {
+            }
+
+        }
+
+    }
+
+    void NETProjectSystem::HandleUpdate(StringHash eventType, VariantMap& eventData)
+    {
+        using namespace Update;
+
+        float delta = eventData[P_TIMESTEP].GetFloat();
+
+        quietPeriod_ -= delta;
+
+        if (quietPeriod_ < 0.0f)
+            quietPeriod_ = 0.0f;
+
+        if (quietPeriod_ > 0.0f)
+            return;
+
+        if (solutionDirty_)
+        {
+            ToolSystem* tsystem = GetSubsystem<ToolSystem>();
+            Project* project = tsystem->GetProject();
+
+            SharedPtr<NETProjectGen> gen(new NETProjectGen(context_));
+
+            gen->SetScriptPlatform("WINDOWS");
+
+            if (!gen->LoadProject(project))
+            {
+                return;
+            }
+
+            if (!gen->Generate())
+            {
+                return;
+            }
+
+            solutionDirty_ = false;
+
+        }
+
+        if (projectAssemblyDirty_)
+        {
+            using namespace NETBuildAtomicProject;
+
+            VariantMap eventData;
+            Project* project = GetSubsystem<ToolSystem>()->GetProject();
+            eventData[P_PROJECT] = project;
+
+            // We need to rebuild the project assembly
+            SendEvent(E_NETBUILDATOMICPROJECT, eventData);
+
+            projectAssemblyDirty_ = false;
+
+        }
+
+    }
+
+    void NETProjectSystem::HandleProjectLoaded(StringHash eventType, VariantMap& eventData)
+    {
+        using namespace ProjectLoaded;
+
+        String projectPath = eventData[P_PROJECTPATH].GetString();
+        
+        if (GetExtension(projectPath) == ".atomic")
+            projectPath = GetParentPath(projectPath);
+
+        solutionPath_ = AddTrailingSlash(projectPath) + "AtomicNET/Solution/AtomicProject.sln";
+        projectAssemblyPath_ = AddTrailingSlash(projectPath) + "Resource/AtomicProject.dll";
+
+        FileSystem* fileSystem = GetSubsystem<FileSystem>();
+
+        // if the solution or project assemblies don't exist mark as dirty
+
+        if (!fileSystem->FileExists(solutionPath_))
+            solutionDirty_ = true;
+
+        if (!fileSystem->FileExists(projectAssemblyPath_))
+            projectAssemblyDirty_ = true;
+
+    }
+    
+    void NETProjectSystem::HandleProjectUnloaded(StringHash eventType, VariantMap& eventData)
+    {
+        Clear();
+    }
+
+    void NETProjectSystem::HandleFileChanged(StringHash eventType, VariantMap& eventData)
+    {
+
+    }
+
+    void NETProjectSystem::HandleResourceAdded(StringHash eventType, VariantMap& eventData)
+    {
+
+    }
+
+    void NETProjectSystem::HandleResourceRemoved(StringHash eventType, VariantMap& eventData)
+    {
+
+    }
+
+    void NETProjectSystem::HandleAssetRenamed(StringHash eventType, VariantMap& eventData)
+    {
+
+    }
+
+    void NETProjectSystem::HandleAssetMoved(StringHash eventType, VariantMap& eventData)
+    {
+
+    }
+
+    void NETProjectSystem::Initialize()    
+    {
+        Clear();
+
+#ifdef ATOMIC_PLATFORM_WINDOWS
+
+        SubscribeToEvent(E_UPDATE, HANDLER(NETProjectSystem, HandleUpdate));
+
+        SubscribeToEvent(E_PROJECTLOADED, HANDLER(NETProjectSystem, HandleProjectLoaded));
+        SubscribeToEvent(E_PROJECTUNLOADED, HANDLER(NETProjectSystem, HandleProjectUnloaded));
+
+        SubscribeToEvent(E_FILECHANGED, HANDLER(NETProjectSystem, HandleFileChanged));
+
+        SubscribeToEvent(E_RESOURCEADDED, HANDLER(NETProjectSystem, HandleResourceAdded));
+        SubscribeToEvent(E_RESOURCEREMOVED, HANDLER(NETProjectSystem, HandleResourceRemoved));
+
+        SubscribeToEvent(E_ASSETRENAMED, HANDLER(NETProjectSystem, HandleAssetRenamed));
+        SubscribeToEvent(E_ASSETMOVED, HANDLER(NETProjectSystem, HandleAssetMoved));
+
+        FileSystem* fileSystem = GetSubsystem<FileSystem>();
+
+        // Query for Visual Studio 2015 path
+        visualStudioPath_ = Poco::Environment::get("VS140COMNTOOLS").c_str();
+
+        if (visualStudioPath_.Length())
+        {
+            visualStudioPath_.Replace("Tools\\", "IDE\\devenv.exe");
+
+            if (!fileSystem->FileExists(visualStudioPath_))
+                visualStudioPath_.Clear();
+        }
+
+#endif
+
+    }
+
+
+}

+ 90 - 0
Source/ToolCore/NETTools/NETProjectSystem.h

@@ -0,0 +1,90 @@
+//
+// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#pragma once
+
+#include <Atomic/Core/Object.h>
+
+using namespace Atomic;
+
+namespace ToolCore
+{
+
+    class Project;
+    class Subprocess;
+
+    // AtomicProject.dll state (this shouldn't be in resources too)
+
+    enum NETProjectState
+    {
+        NETPROJECT_CLEAN,
+        NETPROJECT_DIRTY,
+        NETPROJECT_ERROR
+    };
+
+    class NETProjectSystem : public Object
+    {
+        OBJECT(NETProjectSystem)
+
+    public:
+
+        NETProjectSystem(Context* context);
+        virtual ~NETProjectSystem();
+
+        const String& GetSolutionPath() const { return solutionPath_; }
+
+        bool GetVisualStudioAvailable() const { return visualStudioPath_.Length() != 0; }
+
+        void OpenSourceFile(const String& sourceFilePath);
+
+    private:
+
+        void HandleUpdate(StringHash eventType, VariantMap& eventData);
+
+        void HandleFileChanged(StringHash eventType, VariantMap& eventData);
+        void HandleResourceAdded(StringHash eventType, VariantMap& eventData);
+        void HandleResourceRemoved(StringHash eventType, VariantMap& eventData);
+        void HandleAssetRenamed(StringHash eventType, VariantMap& eventData);
+        void HandleAssetMoved(StringHash eventType, VariantMap& eventData);
+
+        void HandleProjectLoaded(StringHash eventType, VariantMap& eventData);
+        void HandleProjectUnloaded(StringHash eventType, VariantMap& eventData);
+
+        void Clear();
+        void Initialize();
+
+        String visualStudioPath_;
+
+        String solutionPath_;
+        String projectAssemblyPath_;
+
+        float quietPeriod_;
+
+        bool solutionDirty_;
+        bool  projectAssemblyDirty_;
+
+        // Visual Studio subprocess
+        WeakPtr<Subprocess> vsSubprocess_;
+
+    };
+
+}

+ 1 - 1
Source/ToolCore/ToolEnvironment.cpp

@@ -168,8 +168,8 @@ void ToolEnvironment::SetRootSourceDir(const String& sourceDir)
 
     atomicNETNuGetBinary_ = ToString("%sBuild/Managed/nuget/nuget.exe", rootSourceDir_.CString());
 
+    atomicNETRootDir_ = rootSourceDir_ + "Artifacts/AtomicNET/";
     atomicNETCoreAssemblyDir_ = rootSourceDir_ + "Artifacts/AtomicNET/" + config + "/";
-
     atomicNETManagedPlayerBinary_ = atomicNETCoreAssemblyDir_ + "AtomicPlayer.exe";
 
 }

+ 2 - 0
Source/ToolCore/ToolEnvironment.h

@@ -81,6 +81,7 @@ public:
 
     // AtomicNET
 
+    const String& GetAtomicNETRootDir() { return atomicNETRootDir_; }
     const String& GetAtomicNETCoreAssemblyDir() { return atomicNETCoreAssemblyDir_; }
     const String& GetAtomicNETNuGetBinary() { return atomicNETNuGetBinary_; }
     const String& GetAtomicNETManagedPlayerBinary() { return atomicNETManagedPlayerBinary_; }
@@ -140,6 +141,7 @@ private:
     String devConfigFilename_;
 
     // AtomicNET
+    String atomicNETRootDir_;
     String atomicNETCoreAssemblyDir_;
     String atomicNETNuGetBinary_;
     String atomicNETManagedPlayerBinary_;

+ 5 - 0
Source/ToolCoreJS/ToolCoreJS.cpp

@@ -30,6 +30,8 @@
 #include <ToolCore/License/LicenseSystem.h>
 #include <ToolCore/Build/BuildSystem.h>
 
+#include <ToolCore/NETTools/NETProjectSystem.h>
+
 #include <ToolCore/Assets/ModelImporter.h>
 
 using namespace Atomic;
@@ -167,6 +169,9 @@ void jsapi_init_toolcore(JSVM* vm)
     js_push_class_object_instance(ctx, vm->GetSubsystem<BuildSystem>(), "BuildSystem");
     duk_put_prop_string(ctx, -2, "buildSystem");
 
+    js_push_class_object_instance(ctx, vm->GetSubsystem<NETProjectSystem>(), "NETProjectSystem");
+    duk_put_prop_string(ctx, -2, "netProjectSystem");
+
     duk_push_c_function(ctx, js_atomic_GetLicenseSystem, 0);
     duk_put_prop_string(ctx, -2, "getLicenseSystem");