Ver Fonte

Working on Atomic C#

Josh Engebretson há 10 anos atrás
pai
commit
246c46785c

+ 23 - 0
Build/AtomicSharp/AtomicSharpTest/Program.cs

@@ -1,16 +1,39 @@
 using System;
 
 using AtomicSharp;
+using Light = AtomicSharp.Light;
+using Node = AtomicSharp.Node;
 
 namespace AtomicSharpTest
 {
 	class MainClass
 	{
+		static Node CreateNode() {
+
+			return new AtomicSharp.Node ();
+			
+		}
+
+		static void AddLight(Node node) {
+
+			node.AddComponent (new Light (), 0, CreateMode.REPLICATED);
+
+		}
+
 		public static void Main (string[] args)
 		{
 			AtomicSharp.AtomicSharp.Initialize ();
 
+			var node = CreateNode ();
+			AddLight (node);
+
+			node.Name = "MyNode";
+
+			if (node.HasComponent("Light"))
+				Console.Write (node.Name + " has a light");
+
 			while (AtomicSharp.AtomicSharp.RunFrame ()) {
+				
 			}
 		}
 	}

+ 6 - 0
Source/AtomicSharp/AtomicSharpApp.cpp

@@ -158,6 +158,12 @@ namespace AtomicPlayer
     void AtomicPlayerApp::Stop()
     {
 
+        vm_ = 0;
+        context_->RemoveSubsystem<Javascript>();
+        // make sure JSVM is really down and no outstanding refs
+        // as if not, will hold on engine subsystems, which is bad
+        assert(!JSVM::GetJSVM(0));
+
         Application::Stop();
 
 

+ 14 - 1
Source/ToolCore/JSBind/CSharp/CSFunctionWriter.cpp

@@ -337,6 +337,9 @@ void CSFunctionWriter::WriteManagedPInvokeFunctionSignature(String& source)
 
     String returnType = CSTypeHelper::GetPInvokeTypeString(function_->GetReturnType());
 
+    if (returnType == "string")
+        returnType = "IntPtr";
+
     if (function_->IsConstructor())
         returnType = "IntPtr";
 
@@ -584,7 +587,11 @@ void CSFunctionWriter::WriteManagedFunction(String& source)
 
     if (function_->GetReturnType())
     {
-        if (CSTypeHelper::IsSimpleReturn(function_->GetReturnType()))
+        if (function_->GetReturnType()->type_->asStringType() || function_->GetReturnType()->type_->asStringHashType())
+        {
+            line += "return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(";
+        }
+        else if (CSTypeHelper::IsSimpleReturn(function_->GetReturnType()))
             line += "return ";
         else
         {
@@ -607,6 +614,12 @@ void CSFunctionWriter::WriteManagedFunction(String& source)
         line += ", " + callSig;
     }
 
+    if (function_->GetReturnType())
+    {
+        if (function_->GetReturnType()->type_->asStringType() || function_->GetReturnType()->type_->asStringHashType())
+            line += ")";
+    }
+
     line += ");\n";
 
     source += IndentLine(line);