Browse Source

Script binding compile and link

Josh Engebretson 9 years ago
parent
commit
29584d5796

+ 1 - 0
Script/Packages/Atomic/Atomic2D.json

@@ -12,6 +12,7 @@
 				 "TileMap2D", "PropertySet2D", "Tile2D", "TileMapObject2D", "TileMapLayer2D",
 				 "TmxLayer2D", "TmxTileLayer2D", "TmxObjectGroup2D", "TmxImageLayer2D", "TmxFile2D",
 				 "Light2DGroup", "Light2D", "DirectionalLight2D", "PositionalLight2D", "PointLight2D"],
+	"jsmodulepreamble" : ["using namespace Atomic::Spriter;"],			 
 	"overloads" : {
 		"AnimatedSprite2D" : {
 			"SetAnimation" : ["String", "LoopMode2D"]

+ 15 - 0
Source/Atomic/Graphics/OpenGL/OGLTexture.cpp

@@ -306,4 +306,19 @@ unsigned Texture::GetSRGBFormat(unsigned format)
 #endif
 }
 
+// ATOMIC BEGIN
+// Only used on D3D11, here to satisfy script binding linking
+unsigned Texture::GetSRVFormat(unsigned format)
+{
+        return 0;
+}
+
+// Only used on D3D11, here to satisfy script binding linking
+unsigned Texture::GetDSVFormat(unsigned format)
+{
+        return 0;
+}
+
+// ATOMIC END
+
 }

+ 11 - 3
Source/ToolCore/JSBind/JSBModule.cpp

@@ -405,9 +405,7 @@ void JSBModule::RegisterConstant(const String& constantName, const String& value
 }
 
 bool JSBModule::Load(const String& jsonFilename)
-{
-    JSBind* jsbind = GetSubsystem<JSBind>();
-
+{    
     ATOMIC_LOGINFOF("Loading Module: %s", jsonFilename.CString());
 
     SharedPtr<File> jsonFile(new File(context_, jsonFilename));
@@ -473,6 +471,16 @@ bool JSBModule::Load(const String& jsonFilename)
         }
     }
 
+    JSONValue jsmodulepreamble = root.Get("jsmodulepreamble");
+
+    if (jsmodulepreamble.IsArray())
+    {
+        for (unsigned j = 0; j < jsmodulepreamble.GetArray().Size(); j++)
+        {
+            jsmodulePreamble_.Push(jsmodulepreamble.GetArray()[j].GetString());
+        }
+    }
+
     JSONValue sources = root.Get("sources");
 
     for (unsigned i = 0; i < sources.GetArray().Size(); i++)

+ 1 - 0
Source/ToolCore/JSBind/JSBModule.h

@@ -102,6 +102,7 @@ private:
     SharedPtr<JSBPackage> package_;
     Vector<SharedPtr<JSBHeader>> headers_;
     Vector<String> includes_;
+    Vector<String> jsmodulePreamble_;
 
     Vector<String> sourceDirs_;
     Vector<String> classnames_;

+ 18 - 0
Source/ToolCore/JSBind/JavaScript/JSModuleWriter.cpp

@@ -170,6 +170,22 @@ void JSModuleWriter::WriteIncludes(String& source)
 
 }
 
+void JSModuleWriter::WritePreamble(String& source)
+{
+    if (!module_->jsmodulePreamble_.Size())
+        return;
+
+    source += "\n// Begin Module Preamble\n\n";
+
+    for (unsigned i = 0; i < module_->jsmodulePreamble_.Size(); i++)
+    {
+        source += module_->jsmodulePreamble_[i] + "\n";
+    }
+
+    source += "\n// End Module Preamble\n\n";
+
+}
+
 void JSModuleWriter::WriteClassDefine(String& source)
 {
     Vector<SharedPtr<JSBClass>> classes = module_->classes_.Values();
@@ -264,6 +280,8 @@ void JSModuleWriter::GenerateSource()
 
     WriteIncludes(source);
 
+    WritePreamble(source);
+
     String ns = module_->GetPackage()->GetNamespace();
 
     if (ns != "Atomic")

+ 1 - 0
Source/ToolCore/JSBind/JavaScript/JSModuleWriter.h

@@ -45,6 +45,7 @@ public:
 private:
 
     void WriteIncludes(String& source);
+    void WritePreamble(String& source);
     void WriteForwardDeclarations(String& source);
     void WriteClassDeclaration(String& source);