瀏覽代碼

Atomic C# cleanups, splitting NETScript out from NETCore

Josh Engebretson 10 年之前
父節點
當前提交
e6a266497a
共有 37 個文件被更改,包括 248 次插入171 次删除
  1. 0 0
      Attic/NETNative/AtomicSharpAPI.cpp
  2. 0 0
      Attic/NETNative/AtomicSharpAPI.h
  3. 0 0
      Attic/NETNative/AtomicSharpApp.cpp
  4. 0 0
      Attic/NETNative/AtomicSharpApp.h
  5. 0 0
      Attic/NETNative/CMakeLists.txt
  6. 2 1
      CMake/Modules/AtomicNET.cmake
  7. 1 1
      Script/AtomicEditor/ui/frames/inspector/AssemblyInspector.ts
  8. 2 1
      Script/AtomicNET/AtomicNET/AtomicNETEngine/AtomicNET.cs
  9. 0 6
      Script/Packages/AtomicNET/AtomicNET.json
  10. 6 0
      Script/Packages/AtomicNET/NETCore.json
  11. 6 0
      Script/Packages/AtomicNET/NETScript.json
  12. 1 1
      Script/Packages/AtomicNET/Package.json
  13. 3 0
      Source/AtomicEditor/Application/AEEditorCommon.cpp
  14. 7 4
      Source/AtomicEditor/Application/AEPlayerApp.cpp
  15. 4 3
      Source/AtomicEditor/CMakeLists.txt
  16. 1 0
      Source/AtomicNET/CMakeLists.txt
  17. 1 3
      Source/AtomicNET/NETCore/CMakeLists.txt
  18. 5 95
      Source/AtomicNET/NETCore/NETCore.cpp
  19. 0 1
      Source/AtomicNET/NETCore/NETCore.h
  20. 1 1
      Source/AtomicNET/NETJS/CMakeLists.txt
  21. 7 0
      Source/AtomicNET/NETScript/CMakeLists.txt
  22. 9 10
      Source/AtomicNET/NETScript/CSComponent.cpp
  23. 4 4
      Source/AtomicNET/NETScript/CSComponent.h
  24. 14 14
      Source/AtomicNET/NETScript/CSComponentAssembly.cpp
  25. 5 5
      Source/AtomicNET/NETScript/CSComponentAssembly.h
  26. 0 0
      Source/AtomicNET/NETScript/CSEventHelper.cpp
  27. 0 0
      Source/AtomicNET/NETScript/CSEventHelper.h
  28. 10 11
      Source/AtomicNET/NETScript/CSManaged.cpp
  29. 4 4
      Source/AtomicNET/NETScript/CSManaged.h
  30. 0 0
      Source/AtomicNET/NETScript/CSScriptObject.cpp
  31. 0 0
      Source/AtomicNET/NETScript/CSScriptObject.h
  32. 113 0
      Source/AtomicNET/NETScript/NETScript.cpp
  33. 36 0
      Source/AtomicNET/NETScript/NETScript.h
  34. 0 0
      Source/AtomicNET/NETScript/NETScriptEvents.h
  35. 1 1
      Source/AtomicPlayer/Application/CMakeLists.txt
  36. 1 1
      Source/AtomicTool/CMakeLists.txt
  37. 4 4
      Source/ToolCore/Assets/NETAssemblyImporter.cpp

+ 0 - 0
Source/AtomicNET/NETNative/AtomicSharpAPI.cpp → Attic/NETNative/AtomicSharpAPI.cpp


+ 0 - 0
Source/AtomicNET/NETNative/AtomicSharpAPI.h → Attic/NETNative/AtomicSharpAPI.h


+ 0 - 0
Source/AtomicNET/NETNative/AtomicSharpApp.cpp → Attic/NETNative/AtomicSharpApp.cpp


+ 0 - 0
Source/AtomicNET/NETNative/AtomicSharpApp.h → Attic/NETNative/AtomicSharpApp.h


+ 0 - 0
Source/AtomicNET/NETNative/CMakeLists.txt → Attic/NETNative/CMakeLists.txt


+ 2 - 1
CMake/Modules/AtomicNET.cmake

@@ -3,6 +3,7 @@ set (CSATOMICPLAYERNATIVEDIR "${CMAKE_SOURCE_DIR}/Build/Source/Generated/${JAVAS
 set (CSATOMICNETNATIVEDIR "${CMAKE_SOURCE_DIR}/Build/Source/Generated/${JAVASCRIPT_BINDINGS_PLATFORM}/CSharp/Packages/AtomicNET/Native")
 
 # Create the JSBind files ahead of time, so they are picked up with glob
+
 set (CSFILES CSModuleAtomic2D.cpp;CSModuleAtomic3D.cpp;CSModuleAudio.cpp;CSModuleContainer.cpp;CSModuleCore.cpp;
              CSModuleEngine.cpp;CSModuleEnvironment.cpp;CSModuleGraphics.cpp;CSModuleInput.cpp;
              CSModuleIO.cpp;CSModuleJavascript.cpp;CSModuleMath.cpp;CSModuleNavigation.cpp;
@@ -11,7 +12,7 @@ set (CSFILES CSModuleAtomic2D.cpp;CSModuleAtomic3D.cpp;CSModuleAudio.cpp;CSModul
 
 set (CSATOMICPLAYERFILES CSModulePlayer.cpp;CSPackageAtomicPlayer.cpp;CSPackageAtomicPlayer.h)
 
-set (CSATOMICNETFILES CSModuleAtomicNET.cpp;CSPackageAtomicNET.cpp;CSPackageAtomicNET.h)
+set (CSATOMICNETFILES CSModuleNETCore.cpp;CSModuleNETScript.cpp;CSPackageAtomicNET.cpp;CSPackageAtomicNET.h)
 
 foreach(CSFILE ${CSFILES})
 

+ 1 - 1
Script/AtomicEditor/ui/frames/inspector/AssemblyInspector.ts

@@ -34,7 +34,7 @@ class AssemblyInspector extends InspectorWidget {
         // Assembly Section
         var assemblyLayout = this.createSection(rootLayout, "NETAssembly", 1);
 
-        var assemblyFile = <AtomicNET.NETAssemblyFile> asset.importer.getResource();
+        var assemblyFile = <AtomicNET.CSComponentAssembly> asset.importer.getResource();
 
         var container = InspectorUtils.createContainer();
         container.gravity = Atomic.UI_GRAVITY_ALL;

+ 2 - 1
Script/AtomicNET/AtomicNET/AtomicNETEngine/AtomicNET.cs

@@ -28,7 +28,8 @@ public static class Atomic
     PhysicsModule.Initialize ();
     EnvironmentModule.Initialize ();
     UIModule.Initialize ();
-    AtomicNETModule.Initialize();
+    NETCoreModule.Initialize();
+    NETScriptModule.Initialize();
     AtomicPlayer.PlayerModule.Initialize ();
   }
 

+ 0 - 6
Script/Packages/AtomicNET/AtomicNET.json

@@ -1,6 +0,0 @@
-{
-	"name" : "AtomicNET",
-	"sources" : ["Source/AtomicNET/NETCore"],
-	"classes" : ["NETCore", "NETManaged", "NETAssemblyFile", "NETVariantMap", "CSScriptObject", "CSComponent"]
-
-}

+ 6 - 0
Script/Packages/AtomicNET/NETCore.json

@@ -0,0 +1,6 @@
+{
+	"name" : "NETCore",
+	"sources" : ["Source/AtomicNET/NETCore"],
+	"classes" : ["NETCore", "NETVariantMap"]
+
+}

+ 6 - 0
Script/Packages/AtomicNET/NETScript.json

@@ -0,0 +1,6 @@
+{
+	"name" : "NETScript",
+	"sources" : ["Source/AtomicNET/NETScript"],
+	"classes" : ["CSManaged", "CSComponentAssembly", "CSScriptObject", "CSComponent"]
+
+}

+ 1 - 1
Script/Packages/AtomicNET/Package.json

@@ -3,5 +3,5 @@
   "name" : "AtomicNET",
   "namespace" : "Atomic",
   "dependencies" : ["Script/Packages/Atomic"],
-  "modules" : ["AtomicNET"]
+  "modules" : ["NETCore", "NETScript"]
 }

+ 3 - 0
Source/AtomicEditor/Application/AEEditorCommon.cpp

@@ -22,6 +22,7 @@
 #ifdef ATOMIC_DOTNET
 #include <AtomicNET/NETCore/NETHost.h>
 #include <AtomicNET/NETCore/NETCore.h>
+#include <AtomicNET/NETScript/NETScript.h>
 #endif
 
 #include "AEEditorCommon.h"
@@ -72,6 +73,8 @@ void AEEditorCommon::Setup()
     RegisterEnvironmentLibrary(context_);
 #endif
 
+    RegisterNETScriptLibrary(context_);
+
     // Register IPC system
     context_->RegisterSubsystem(new IPC(context_));
 

+ 7 - 4
Source/AtomicEditor/Application/AEPlayerApp.cpp

@@ -24,6 +24,7 @@
 
 #ifdef ATOMIC_DOTNET
 #include <AtomicNET/NETCore/NETCore.h>
+#include <AtomicNET/NETScript/NETScript.h>
 #endif
 
 
@@ -186,15 +187,17 @@ void AEPlayerApplication::Start()
         {
             SendEvent(E_EXITREQUESTED);
         }
-
     }
 
 #ifdef ATOMIC_DOTNET
-    NETCore* netCore = GetSubsystem<NETCore>();
-    if (netCore)
-        netCore->Start();
+    // Initialize Scripting Subsystem
+    NETScript* netScript = new NETScript(context_);
+    context_->RegisterSubsystem(netScript);
+    netScript->Initialize();
+    netScript->ExecMainAssembly();
 #endif
 
+
     return;
 }
 

+ 4 - 3
Source/AtomicEditor/CMakeLists.txt

@@ -24,7 +24,7 @@ file (GLOB JAVASCRIPT_BINDINGS_SOURCE ${CMAKE_SOURCE_DIR}/Build/Source/Generated
 
 set (SOURCE_FILES ${SOURCE_FILES} ${JAVASCRIPT_BINDINGS_SOURCE})
 
-set (SOURCE_FILES ${SOURCE_FILES} ${CSHARP_BINDINGS_SOURCE} ${CSHARPATOMICPLAYER_BINDINGS_SOURCE}  ${CSHARPATOMICNET_BINDINGS_SOURCE})
+set (SOURCE_FILES ${SOURCE_FILES} ${CSHARP_BINDINGS_SOURCE} ${CSHARPATOMICPLAYER_BINDINGS_SOURCE} ${CSHARPATOMICNET_BINDINGS_SOURCE})
 
 if (APPLE)
 
@@ -57,7 +57,8 @@ target_link_libraries(AtomicEditor ToolCore AtomicJS AtomicPlayerJS AtomicNETJS
 
 if (APPLE)
     set (TARGET_PROPERTIES MACOSX_BUNDLE_INFO_PLIST MacOSXBundleInfo.plist.template)
-    target_link_libraries(AtomicEditor NETCore curl)
+
+    target_link_libraries(AtomicEditor NETCore NETScript curl)
 
     # compile the editor scripts
     add_custom_command (TARGET AtomicEditor POST_BUILD
@@ -88,7 +89,7 @@ elseif(LINUX)
         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
     endif()
 else()
-    target_link_libraries(AtomicEditor NETCore libcurl Iphlpapi Wldap32)
+    target_link_libraries(AtomicEditor NETCore NETScript libcurl Iphlpapi Wldap32)
 
     # compile the editor scripts
     add_custom_command (TARGET AtomicEditor POST_BUILD

+ 1 - 0
Source/AtomicNET/CMakeLists.txt

@@ -1,3 +1,4 @@
 
 add_subdirectory(NETCore)
+add_subdirectory(NETScript)
 add_subdirectory(NETJS)

+ 1 - 3
Source/AtomicNET/NETCore/CMakeLists.txt

@@ -1,8 +1,6 @@
 
 include_directories (${CMAKE_SOURCE_DIR}/Source/ThirdParty/rapidjson/include
-                     ${CMAKE_SOURCE_DIR}/Source/ThirdParty
-                     ${CMAKE_SOURCE_DIR}/Source/ThirdParty/Assimp/include
-                     ${CMAKE_SOURCE_DIR}/Source/ThirdParty/nativefiledialog)
+                     ${CMAKE_SOURCE_DIR}/Source/ThirdParty )
 
 file (GLOB SOURCE_FILES *.cpp *.h)
 

+ 5 - 95
Source/AtomicNET/NETCore/NETCore.cpp

@@ -5,11 +5,7 @@
 #include <Atomic/IO/Log.h>
 #include <Atomic/Resource/ResourceCache.h>
 
-#include "CSEventHelper.h"
-#include "CSComponent.h"
 #include "NETCore.h"
-#include "NETManaged.h"
-#include "NETAssemblyFile.h"
 
 #ifdef ATOMIC_PLATFORM_WINDOWS
 #include "Platforms/Windows/NETHostWindows.h"
@@ -20,17 +16,12 @@
 namespace Atomic
 {
 
-/// Register NETCore library objects.
-void ATOMIC_API RegisterNETCoreLibrary(Context* context);
-
 WeakPtr<Context> NETCore::csContext_;
 WeakPtr<NETCore> NETCore::instance_;
 
 NETCore::NETCore(Context* context) :
     Object(context)
 {
-    RegisterNETCoreLibrary(context_);
-
     assert(!instance_);
     instance_ = this;
     csContext_ = context;
@@ -39,10 +30,6 @@ NETCore::NETCore(Context* context) :
 NETCore::~NETCore()
 {
     Shutdown();
-    context_->RemoveGlobalEventListener(context_->GetSubsystem<CSEventDispatcher>());
-    context_->RemoveSubsystem(CSEventDispatcher::GetTypeStatic());
-    context_->RemoveSubsystem(NETManaged::GetTypeStatic());
-
     instance_ = NULL;
 }
 
@@ -125,49 +112,6 @@ bool NETCore::CreateDelegate(const String& assemblyName, const String& qualified
     return netHost_->CreateDelegate(assemblyName, qualifiedClassName, methodName, funcOut);
 }
 
-bool NETCore::Start()
-{
-    if (context_->GetEditorContext())
-        return true;
-
-    typedef void (*StartFunction)();
-    StartFunction start;
-
-    bool result = netHost_->CreateDelegate(
-                    "AtomicNETEngine",
-                    "AtomicEngine.Atomic",
-                    "Start",
-                    (void**) &start);
-
-    if (!result)
-        return false;
-
-    if (result)
-    {
-        start();
-
-        // Load Project Assemblies
-
-        typedef void (*ExecMainAssemblyFunction)();
-        ExecMainAssemblyFunction execMainAssembly;
-
-        result = netHost_->CreateDelegate(
-                        "AtomicNETEngine",
-                        "AtomicEngine.Atomic",
-                        "ExecMainAssembly",
-                        (void**) &execMainAssembly);
-
-        if (!result)
-            return false;
-
-        execMainAssembly();
-
-    }
-
-    return true;
-
-}
-
 bool NETCore::Initialize(String& errorMsg)
 {
 
@@ -203,39 +147,12 @@ bool NETCore::Initialize(String& errorMsg)
                     "Startup",
                     (void**) &startup);
 
-    if (result)
-    {
-        startup(netHost_->GetCoreCLRAssemblyLoadPaths().CString());
-    }
-
-    // MOVE THIS!
-    typedef void (*InitializeFunction)();
-    InitializeFunction init;
-
-    result = netHost_->CreateDelegate(
-                    "AtomicNETEngine",
-                    "AtomicEngine.Atomic",
-                    "Initialize",
-                    (void**) &init);
-
-    if (result)
-    {
-        init();
-    }
-
-    SharedPtr<NETManaged> managed(new NETManaged(context_));
-    context_->RegisterSubsystem(managed);
-
-    SharedPtr<CSEventDispatcher> dispatcher(new CSEventDispatcher(context_));
-    context_->RegisterSubsystem(dispatcher);
-    context_->AddGlobalEventListener(dispatcher);
+    if (!result)
+        return false;
 
-    if (!context_->GetEditorContext())
-    {
-        SubscribeToEvent(E_UPDATE, HANDLER(NETCore, HandleUpdate));
-    }
+    startup(netHost_->GetCoreCLRAssemblyLoadPaths().CString());
 
-    return managed->Initialize();
+    return true;
 
 }
 
@@ -243,14 +160,7 @@ void NETCore::HandleUpdate(StringHash eventType, VariantMap& eventData)
 {
     using namespace Update;
 
-    GetSubsystem<NETManaged>()->NETUpdate(eventData[P_TIMESTEP].GetFloat());
-}
-
-
-void RegisterNETCoreLibrary(Context* context)
-{
-    NETAssemblyFile::RegisterObject(context);
-    CSComponent::RegisterObject(context);
+    //GetSubsystem<NETManaged>()->NETUpdate(eventData[P_TIMESTEP].GetFloat());
 }
 
 

+ 0 - 1
Source/AtomicNET/NETCore/NETCore.h

@@ -42,7 +42,6 @@ public:
     virtual ~NETCore();
 
     bool Initialize(String &errorMsg);
-    bool Start();
     void Shutdown();
 
     void AddAssemblyLoadPath(const String& assemblyPath);

+ 1 - 1
Source/AtomicNET/NETJS/CMakeLists.txt

@@ -3,7 +3,7 @@ include_directories (${CMAKE_SOURCE_DIR}/Source/ThirdParty)
 file (GLOB_RECURSE SOURCE_FILES *.cpp *.h)
 
 # Create the JSBind files ahead of time, so they are picked up with glob
-set (JSFILES JSPackageAtomicNET.cpp;JSModuleAtomicNET.cpp)
+set (JSFILES JSPackageAtomicNET.cpp;JSModuleNETCore.cpp;JSModuleNETScript.cpp)
 
 foreach(JSFILE ${JSFILES})
 

+ 7 - 0
Source/AtomicNET/NETScript/CMakeLists.txt

@@ -0,0 +1,7 @@
+
+include_directories (${CMAKE_SOURCE_DIR}/Source/ThirdParty/rapidjson/include
+                     ${CMAKE_SOURCE_DIR}/Source/ThirdParty )
+
+file (GLOB SOURCE_FILES *.cpp *.h)
+
+add_library(NETScript ${SOURCE_FILES})

+ 9 - 10
Source/AtomicNET/NETCore/CSComponent.cpp → Source/AtomicNET/NETScript/CSComponent.cpp

@@ -33,12 +33,11 @@
 #include <Atomic/Scene/Scene.h>
 #include <Atomic/Scene/SceneEvents.h>
 
-#include "NETEvents.h"
-#include "NETVariant.h"
-#include "NETManaged.h"
+#include "../NETCore/NETVariant.h"
+#include "NETScriptEvents.h"
+#include "CSManaged.h"
 #include "CSComponent.h"
 
-
 namespace Atomic
 {
 
@@ -102,7 +101,7 @@ public:
             if (split.Size() == 2)
             {
                 ResourceCache* cache = context_->GetSubsystem<ResourceCache>();
-                NETAssemblyFile* componentFile = cache->GetResource<NETAssemblyFile>(split[1]);
+                CSComponentAssembly* componentFile = cache->GetResource<CSComponentAssembly>(split[1]);
                 if (componentFile)
                     ptr = componentFile->CreateCSComponent(managedClass);
                 else
@@ -140,7 +139,7 @@ void CSComponent::RegisterObject(Context* context)
 
     ATTRIBUTE("FieldValues", VariantMap, fieldValues_, Variant::emptyVariantMap, AM_FILE);
 
-    MIXED_ACCESSOR_ATTRIBUTE("Assembly", GetAssemblyFileAttr, SetAssemblyFileAttr, ResourceRef, ResourceRef(NETAssemblyFile::GetTypeStatic()), AM_DEFAULT);
+    MIXED_ACCESSOR_ATTRIBUTE("Assembly", GetAssemblyFileAttr, SetAssemblyFileAttr, ResourceRef, ResourceRef(CSComponentAssembly::GetTypeStatic()), AM_DEFAULT);
 
     ACCESSOR_ATTRIBUTE("Class", GetComponentClassName, SetComponentClassName, String, String::EMPTY, AM_DEFAULT);
 
@@ -162,7 +161,7 @@ void CSComponent::ApplyFieldValues()
     SharedPtr<NETVariantMap> vmap(new NETVariantMap());
     vmap->CopySourceVariantMap(fieldValues_);
 
-    NETManaged* managed = GetSubsystem<NETManaged>();
+    CSManaged* managed = GetSubsystem<CSManaged>();
 
     managed->CSComponentApplyFields(this, vmap);
 
@@ -212,20 +211,20 @@ bool CSComponent::LoadXML(const XMLElement& source, bool setInstanceDefault)
     return success;
 }
 
-void CSComponent::SetAssemblyFile(NETAssemblyFile* assemblyFile)
+void CSComponent::SetAssemblyFile(CSComponentAssembly* assemblyFile)
 {
     assemblyFile_ = assemblyFile;
 }
 
 ResourceRef CSComponent::GetAssemblyFileAttr() const
 {
-    return GetResourceRef(assemblyFile_, NETAssemblyFile::GetTypeStatic());
+    return GetResourceRef(assemblyFile_, CSComponentAssembly::GetTypeStatic());
 }
 
 void CSComponent::SetAssemblyFileAttr(const ResourceRef& value)
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    SetAssemblyFile(cache->GetResource<NETAssemblyFile>(value.name_));
+    SetAssemblyFile(cache->GetResource<CSComponentAssembly>(value.name_));
 }
 
 

+ 4 - 4
Source/AtomicNET/NETCore/CSComponent.h → Source/AtomicNET/NETScript/CSComponent.h

@@ -25,7 +25,7 @@
 
 #include <Atomic/Script/ScriptComponent.h>
 
-#include "NETAssemblyFile.h"
+#include "CSComponentAssembly.h"
 
 namespace Atomic
 {
@@ -81,8 +81,8 @@ public:
 
     virtual ScriptComponentFile* GetComponentFile() { return assemblyFile_; }
 
-    NETAssemblyFile* GetAssemblyFile() { return assemblyFile_; }
-    void SetAssemblyFile(NETAssemblyFile* assemblyFile);
+    CSComponentAssembly* GetAssemblyFile() { return assemblyFile_; }
+    void SetAssemblyFile(CSComponentAssembly* assemblyFile);
 
     ResourceRef GetAssemblyFileAttr() const;
     void SetAssemblyFileAttr(const ResourceRef& value);
@@ -96,7 +96,7 @@ protected:
 private:
 
     String componentClassName_;
-    SharedPtr<NETAssemblyFile> assemblyFile_;
+    SharedPtr<CSComponentAssembly> assemblyFile_;
 
 };
 

+ 14 - 14
Source/AtomicNET/NETCore/NETAssemblyFile.cpp → Source/AtomicNET/NETScript/CSComponentAssembly.cpp

@@ -28,26 +28,26 @@
 #include <Atomic/Resource/ResourceCache.h>
 #include <Atomic/IO/Serializer.h>
 
-#include "NETManaged.h"
-#include "NETAssemblyFile.h"
+#include "CSManaged.h"
+#include "CSComponentAssembly.h"
 
 namespace Atomic
 {
 
-HashMap<StringHash, VariantType> NETAssemblyFile::typeMap_;
+HashMap<StringHash, VariantType> CSComponentAssembly::typeMap_;
 
-NETAssemblyFile::NETAssemblyFile(Context* context) :
+CSComponentAssembly::CSComponentAssembly(Context* context) :
     ScriptComponentFile(context)
 {
 
 }
 
-NETAssemblyFile::~NETAssemblyFile()
+CSComponentAssembly::~CSComponentAssembly()
 {
 
 }
 
-void NETAssemblyFile::InitTypeMap()
+void CSComponentAssembly::InitTypeMap()
 {
     typeMap_["Boolean"] = VAR_BOOL;
     typeMap_["Int32"] = VAR_INT;
@@ -61,7 +61,7 @@ void NETAssemblyFile::InitTypeMap()
 
 }
 
-CSComponent* NETAssemblyFile::CreateCSComponent(const String& classname)
+CSComponent* CSComponentAssembly::CreateCSComponent(const String& classname)
 {
     const String& name = GetName();
 
@@ -69,12 +69,12 @@ CSComponent* NETAssemblyFile::CreateCSComponent(const String& classname)
     String pathName, fileName, ext;
     SplitPath(name, pathName, fileName, ext);
 
-    NETManaged* managed = GetSubsystem<NETManaged>();
+    CSManaged* managed = GetSubsystem<CSManaged>();
 
     return managed->CSComponentCreate(fileName, classname);
 }
 
-bool NETAssemblyFile::ParseComponentClassJSON(const JSONValue& json)
+bool CSComponentAssembly::ParseComponentClassJSON(const JSONValue& json)
 {
     if (!typeMap_.Size())
         InitTypeMap();
@@ -185,7 +185,7 @@ bool NETAssemblyFile::ParseComponentClassJSON(const JSONValue& json)
     return true;
 }
 
-bool NETAssemblyFile::ParseAssemblyJSON(const JSONValue& json)
+bool CSComponentAssembly::ParseAssemblyJSON(const JSONValue& json)
 {
     Clear();
     assemblyEnums_.Clear();
@@ -230,17 +230,17 @@ bool NETAssemblyFile::ParseAssemblyJSON(const JSONValue& json)
     return true;
 }
 
-void NETAssemblyFile::RegisterObject(Context* context)
+void CSComponentAssembly::RegisterObject(Context* context)
 {
-    context->RegisterFactory<NETAssemblyFile>();
+    context->RegisterFactory<CSComponentAssembly>();
 }
 
-bool NETAssemblyFile::BeginLoad(Deserializer& source)
+bool CSComponentAssembly::BeginLoad(Deserializer& source)
 {
     return true;
 }
 
-bool NETAssemblyFile::Save(Serializer& dest) const
+bool CSComponentAssembly::Save(Serializer& dest) const
 {
     return true;
 }

+ 5 - 5
Source/AtomicNET/NETCore/NETAssemblyFile.h → Source/AtomicNET/NETScript/CSComponentAssembly.h

@@ -37,17 +37,17 @@ class NETVariantMap;
 
 // At runtime we need to load the assembly, in the editor we use metadata
 /// NET Assembly resource.
-class ATOMIC_API NETAssemblyFile : public ScriptComponentFile
+class ATOMIC_API CSComponentAssembly : public ScriptComponentFile
 {
-    OBJECT(NETAssemblyFile);
-    BASEOBJECT(ScriptComponentFile);
+    OBJECT(CSComponentAssembly);
+    BASEOBJECT(CSComponentAssembly);
 
 public:
 
     /// Construct.
-    NETAssemblyFile(Context* context);
+    CSComponentAssembly(Context* context);
     /// Destruct.
-    virtual ~NETAssemblyFile();
+    virtual ~CSComponentAssembly();
 
     bool ParseAssemblyJSON(const JSONValue& json);
 

+ 0 - 0
Source/AtomicNET/NETCore/CSEventHelper.cpp → Source/AtomicNET/NETScript/CSEventHelper.cpp


+ 0 - 0
Source/AtomicNET/NETCore/CSEventHelper.h → Source/AtomicNET/NETScript/CSEventHelper.h


+ 10 - 11
Source/AtomicNET/NETCore/NETManaged.cpp → Source/AtomicNET/NETScript/CSManaged.cpp

@@ -5,17 +5,16 @@
 #include <Atomic/IO/Log.h>
 #include <Atomic/Core/StringUtils.h>
 
-#include "NETCore.h"
-#include "NETManaged.h"
+#include "../NETCore/NETCore.h"
 
-#include "CSEventHelper.h"
+#include "CSManaged.h"
 #include "CSComponent.h"
 
 namespace Atomic
 {
 
 
-NETManaged::NETManaged(Context* context) :
+CSManaged::CSManaged(Context* context) :
     Object(context),
     CSComponentCreate_(0),
     CSComponentApplyFields_(0),
@@ -26,12 +25,12 @@ NETManaged::NETManaged(Context* context) :
 
 }
 
-NETManaged::~NETManaged()
+CSManaged::~CSManaged()
 {
 
 }
 
-bool NETManaged::Initialize()
+bool CSManaged::Initialize()
 {
     NETCore* core = GetSubsystem<NETCore>();
     core->CreateDelegate("AtomicNETEngine", "AtomicEngine.ComponentCore", "CSComponentCreate", (void**) &CSComponentCreate_);
@@ -41,7 +40,7 @@ bool NETManaged::Initialize()
     return true;
 }
 
-void NETManaged::NETUpdate(float timeStep)
+void CSManaged::NETUpdate(float timeStep)
 {
     if (!NETUpdate_)
         return;
@@ -49,7 +48,7 @@ void NETManaged::NETUpdate(float timeStep)
     NETUpdate_(timeStep);
 }
 
-CSComponent* NETManaged::CSComponentCreate(const String& assemblyName, const String& componentName)
+CSComponent* CSManaged::CSComponentCreate(const String& assemblyName, const String& componentName)
 {
     if (!CSComponentCreate_)
         return 0;
@@ -58,7 +57,7 @@ CSComponent* NETManaged::CSComponentCreate(const String& assemblyName, const Str
 
 }
 
-void NETManaged::CSComponentApplyFields(CSComponent* component, NETVariantMap* fieldMapPtr)
+void CSManaged::CSComponentApplyFields(CSComponent* component, NETVariantMap* fieldMapPtr)
 {
     if (!CSComponentApplyFields_ || !component || !fieldMapPtr)
         return;
@@ -67,7 +66,7 @@ void NETManaged::CSComponentApplyFields(CSComponent* component, NETVariantMap* f
 
 }
 
-void NETManaged::CSComponentCallMethod(unsigned id, CSComponentMethod methodID, float value)
+void CSManaged::CSComponentCallMethod(unsigned id, CSComponentMethod methodID, float value)
 {
     if (!CSComponentCallMethod_)
         return;
@@ -76,7 +75,7 @@ void NETManaged::CSComponentCallMethod(unsigned id, CSComponentMethod methodID,
 
 }
 
-void NETManaged::CSBeginSendEvent(unsigned senderRefID, unsigned eventType, VariantMap* eventData)
+void CSManaged::CSBeginSendEvent(unsigned senderRefID, unsigned eventType, VariantMap* eventData)
 {
     if (!CSBeginSendEvent_)
         return;

+ 4 - 4
Source/AtomicNET/NETCore/NETManaged.h → Source/AtomicNET/NETScript/CSManaged.h

@@ -41,15 +41,15 @@ typedef void (*CSComponentApplyFieldsPtr)(CSComponent* componentPtr, NETVariantM
 typedef void (*CSComponentCallMethodFunctionPtr)(unsigned id, CSComponentMethod method, float value);
 typedef void (*CSBeginSendEventFunctionPtr)(unsigned senderRefID, unsigned eventType, VariantMap* eventData);
 
-class ATOMIC_API NETManaged : public Object
+class ATOMIC_API CSManaged : public Object
 {
-    OBJECT(NETManaged);
+    OBJECT(CSManaged);
 
 public:
     /// Construct.
-    NETManaged(Context* context);
+    CSManaged(Context* context);
     /// Destruct.
-    virtual ~NETManaged();
+    virtual ~CSManaged();
 
     bool Initialize();
 

+ 0 - 0
Source/AtomicNET/NETCore/CSScriptObject.cpp → Source/AtomicNET/NETScript/CSScriptObject.cpp


+ 0 - 0
Source/AtomicNET/NETCore/CSScriptObject.h → Source/AtomicNET/NETScript/CSScriptObject.h


+ 113 - 0
Source/AtomicNET/NETScript/NETScript.cpp

@@ -0,0 +1,113 @@
+
+#include "../NETCore/NETCore.h"
+
+#include "CSComponent.h"
+#include "CSComponentAssembly.h"
+#include "CSManaged.h"
+#include "NETScript.h"
+
+namespace Atomic
+{
+
+void RegisterNETScriptLibrary(Context* context);
+
+NETScript::NETScript(Context* context) :
+    Object(context)
+{
+    // NETScript subsystem should not be instantiated in editor context
+    assert(!context->GetEditorContext());
+
+    netCore_ = GetSubsystem<NETCore>();
+
+    assert(netCore_.NotNull());
+}
+
+NETScript::~NETScript()
+{
+    //context_->RemoveGlobalEventListener(context_->GetSubsystem<CSEventDispatcher>());
+    //context_->RemoveSubsystem(CSEventDispatcher::GetTypeStatic());
+
+    context_->RemoveSubsystem(CSManaged::GetTypeStatic());
+
+}
+
+bool NETScript::ExecMainAssembly()
+{
+    typedef void (*StartFunction)();
+    StartFunction start;
+
+    bool result = netCore_->CreateDelegate(
+                "AtomicNETEngine",
+                "AtomicEngine.Atomic",
+                "Start",
+                (void**) &start);
+
+    if (!result)
+        return false;
+
+    if (result)
+    {
+        start();
+
+        // Load Project Assemblies
+
+        typedef void (*ExecMainAssemblyFunction)();
+        ExecMainAssemblyFunction execMainAssembly;
+
+        result = netCore_->CreateDelegate(
+                    "AtomicNETEngine",
+                    "AtomicEngine.Atomic",
+                    "ExecMainAssembly",
+                    (void**) &execMainAssembly);
+
+        if (!result)
+            return false;
+
+        execMainAssembly();
+
+    }
+
+    return true;
+
+}
+
+bool NETScript::Initialize()
+{
+    // MOVE THIS!
+    typedef void (*InitializeFunction)();
+    InitializeFunction init;
+
+    bool result = netCore_->CreateDelegate(
+                "AtomicNETEngine",
+                "AtomicEngine.Atomic",
+                "Initialize",
+                (void**) &init);
+
+    if (!result)
+        return false;
+
+    init();
+
+    csManaged_ = new CSManaged(context_);
+    context_->RegisterSubsystem(csManaged_);
+
+    //SharedPtr<CSEventDispatcher> dispatcher(new CSEventDispatcher(context_));
+    //context_->RegisterSubsystem(dispatcher);
+    //context_->AddGlobalEventListener(dispatcher);
+
+    //if (!context_->GetEditorContext())
+    //{
+    //SubscribeToEvent(E_UPDATE, HANDLER(NETCore, HandleUpdate));
+    //}
+
+    return csManaged_->Initialize();
+
+}
+
+void RegisterNETScriptLibrary(Context* context)
+{
+    CSComponentAssembly::RegisterObject(context);
+    CSComponent::RegisterObject(context);
+}
+
+}

+ 36 - 0
Source/AtomicNET/NETScript/NETScript.h

@@ -0,0 +1,36 @@
+#pragma once
+
+#include <Atomic/Core/Context.h>
+#include <Atomic/Core/Object.h>
+
+namespace Atomic
+{
+
+class NETCore;
+class CSManaged;
+
+class ATOMIC_API NETScript : public Object
+{
+
+    OBJECT(NETScript);
+
+public:
+    /// Construct.
+    NETScript(Context* context);
+    /// Destruct.
+    virtual ~NETScript();
+
+    bool Initialize();
+
+    bool ExecMainAssembly();
+
+private:
+
+    WeakPtr<NETCore> netCore_;
+    WeakPtr<CSManaged> csManaged_;
+
+};
+
+void RegisterNETScriptLibrary(Context* context);
+
+}

+ 0 - 0
Source/AtomicNET/NETCore/NETEvents.h → Source/AtomicNET/NETScript/NETScriptEvents.h


+ 1 - 1
Source/AtomicPlayer/Application/CMakeLists.txt

@@ -47,7 +47,7 @@ if (APPLE)
 
 if (NOT IOS)
 
-    target_link_libraries(AtomicPlayer NETCore)
+    target_link_libraries(AtomicPlayer NETCore NETScript)
 
     set (TARGET_PROPERTIES MACOSX_BUNDLE_INFO_PLIST MacOSXBundleInfo.plist.template)
 

+ 1 - 1
Source/AtomicTool/CMakeLists.txt

@@ -6,7 +6,7 @@ endif()
 
 add_executable(AtomicTool ${ATOMIC_TOOL_SOURCES})
 
-target_link_libraries(AtomicTool ToolCore NETCore Poco ${ATOMIC_LINK_LIBRARIES})
+target_link_libraries(AtomicTool ToolCore NETCore NETScript Poco ${ATOMIC_LINK_LIBRARIES})
 
 # add_dependencies(AtomicTool AtomicEditor)
 

+ 4 - 4
Source/ToolCore/Assets/NETAssemblyImporter.cpp

@@ -10,7 +10,7 @@
 #include <Atomic/Resource/ResourceCache.h>
 #include <Atomic/Resource/Image.h>
 
-#include <AtomicNET/NETCore/NETAssemblyFile.h>
+#include <AtomicNET/NETScript/CSComponentAssembly.h>
 
 #include "../NETTools/NETToolSystem.h"
 
@@ -51,7 +51,7 @@ bool NETAssemblyImporter::Import()
         else
         {
             ResourceCache* cache = GetSubsystem<ResourceCache>();
-            NETAssemblyFile* assemblyFile = cache->GetResource<NETAssemblyFile>(asset_->GetPath());
+            CSComponentAssembly* assemblyFile = cache->GetResource<CSComponentAssembly>(asset_->GetPath());
             if (assemblyFile)
                 assemblyFile->ParseAssemblyJSON(assemblyJSON_);
         }
@@ -77,7 +77,7 @@ bool NETAssemblyImporter::LoadSettingsInternal(JSONValue& jsonRoot)
         assemblyJSON_ = ajson.GetObject();
 
         ResourceCache* cache = GetSubsystem<ResourceCache>();
-        NETAssemblyFile* assemblyFile = cache->GetResource<NETAssemblyFile>(asset_->GetPath());
+        CSComponentAssembly* assemblyFile = cache->GetResource<CSComponentAssembly>(asset_->GetPath());
         if (assemblyFile)
             assemblyFile->ParseAssemblyJSON(assemblyJSON_);
     }
@@ -102,7 +102,7 @@ Resource* NETAssemblyImporter::GetResource(const String& typeName)
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
 
-    NETAssemblyFile* assemblyFile = cache->GetResource<NETAssemblyFile>(asset_->GetPath());
+    CSComponentAssembly* assemblyFile = cache->GetResource<CSComponentAssembly>(asset_->GetPath());
 
     return assemblyFile;