Browse Source

C# Vector support (WIP)

Josh Engebretson 9 năm trước cách đây
mục cha
commit
57cc6fb7de

+ 9 - 1
Script/AtomicNET/AtomicNET/Core/RefCounted.cs

@@ -17,6 +17,14 @@ namespace AtomicEngine
             nativeInstance = native;
         }
 
+        public static implicit operator IntPtr(RefCounted refCounted)
+        {
+            if (refCounted == null)
+                return IntPtr.Zero;
+                
+            return refCounted.nativeInstance;
+        }
+
         public IntPtr nativeInstance = IntPtr.Zero;
 
         [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
@@ -25,4 +33,4 @@ namespace AtomicEngine
     }
 
 
-}
+}

+ 39 - 0
Script/AtomicNET/AtomicNET/Core/Vector.cs

@@ -0,0 +1,39 @@
+
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace AtomicEngine
+{
+	// Type safe wrapper around ScriptVector
+    public class Vector<T> where T : RefCounted
+    {
+
+		public uint Size
+		{
+			get
+			{
+				return scriptVector.GetSize();
+			}
+		}
+
+		public T At(uint index)
+		{
+			return (T) scriptVector.At(index);	
+		}
+
+
+		public static implicit operator IntPtr(Vector<T> vector)
+		{
+			if (vector == null)
+				return IntPtr.Zero;
+
+			return vector.scriptVector.nativeInstance;
+		}
+
+
+		ScriptVector scriptVector = new ScriptVector();
+    }
+}
+

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

@@ -1,5 +1,5 @@
 {
 	"name" : "Script",
 	"sources" : ["Source/Atomic/Script"],
-	"classes" : ["ScriptVariantMap", "ScriptComponent", "ScriptComponentFile"]
+	"classes" : ["ScriptVariantMap", "ScriptVector", "ScriptComponent", "ScriptComponentFile"]
 }

+ 9 - 0
Source/Atomic/Script/ScriptVector.cpp

@@ -0,0 +1,9 @@
+
+#include "ScriptVector.h"
+
+namespace Atomic
+{
+
+
+
+}

+ 101 - 0
Source/Atomic/Script/ScriptVector.h

@@ -0,0 +1,101 @@
+
+#include "ScriptSystem.h"
+
+#pragma once
+
+namespace Atomic
+{
+
+class ScriptVector : public RefCounted
+{
+    ATOMIC_REFCOUNTED(ScriptVector)
+
+public:
+
+    ScriptVector() : RefCounted()
+    {
+
+    }
+
+    virtual ~ScriptVector()
+    {
+
+    }
+
+    RefCounted* At(unsigned index) const
+    {
+        if (index >= refVector_.Size())
+            return 0;
+
+        return refVector_[index];
+    }
+
+    unsigned GetSize() const
+    {
+        return refVector_.Size();
+    }
+
+    template <class T>
+    bool AdaptToPODVector(PODVector<T> vectorOut)
+    {
+        vectorOut.Clear();
+
+        for (unsigned i = 0; i < refVector_.Size(); i++)
+        {
+            vectorOut.Push(static_cast<T>(refVector_[i].Get()));
+        }
+
+        return true;
+
+    }
+
+    template <class T>
+    bool AdaptToVector(Vector<T> vectorOut)
+    {
+        vectorOut.Clear();
+
+        for (unsigned i = 0; i < refVector_.Size(); i++)
+        {
+            vectorOut.Push((T) refVector_[i]);
+        }
+
+    }
+
+    template <class T>
+    bool AdaptFromPODVector(PODVector<T> vectorIn)
+    {
+
+        Vector<SharedPtr<RefCounted>> keepAlive = refVector_;
+
+        refVector_.Clear();
+
+        for (unsigned i = 0; i < vectorIn.Size(); i++)
+        {
+            refVector_.Push(SharedPtr<RefCounted>(vectorIn[i]));
+        }
+
+        return true;
+    }
+
+    template <class T>
+    bool AdaptFromVector(Vector<T> vectorIn)
+    {
+        Vector<SharedPtr<RefCounted>> keepAlive = refVector_;
+
+        refVector_.Clear();
+
+        for (unsigned i = 0; i < vectorIn.Size(); i++)
+        {
+            refVector_.Push((T) vectorIn[i]);
+        }
+
+    }
+
+
+private:
+
+    Vector<SharedPtr<RefCounted>> refVector_;
+
+};
+
+}

+ 6 - 2
Source/ToolCore/JSBind/CSharp/CSClassWriter.cpp

@@ -188,9 +188,13 @@ void CSClassWriter::GenerateManagedSource(String& sourceOut)
     String line;
 
     if (klass_->GetBaseClass())
-        line = "public partial class " + klass_->GetName() + " : " + klass_->GetBaseClass()->GetName() + "\n";
+    {
+        line = ToString("public partial class %s%s : %s\n", klass_->GetName().CString(), klass_->IsGeneric() ? "<T>" : "", klass_->GetBaseClass()->GetName().CString());
+    }
     else
-        line = "public partial class " + klass_->GetName() + "\n";
+    {
+        line = ToString("public partial class %s%s\n", klass_->GetName().CString(), klass_->IsGeneric() ? "<T>" : "");
+    }
 
 
     source += IndentLine(line);

+ 96 - 2
Source/ToolCore/JSBind/CSharp/CSFunctionWriter.cpp

@@ -158,6 +158,10 @@ void CSFunctionWriter::GenNativeCallParameters(String& sig)
                     args.Push(ToString("%s", ptype->name_.CString()));
 
             }
+            else if (ptype->type_->asVectorType())
+            {
+                args.Push(ToString("%s__vector", ptype->name_.CString()));
+            }
             else
             {
                 args.Push(ToString("%s", ptype->name_.CString()));
@@ -189,9 +193,52 @@ void CSFunctionWriter::WriteNativeFunction(String& source)
 
     Indent();
 
-
     source += "\n";
 
+    // vector marshal
+
+    bool hasVectorMarshal = false;
+    Vector<JSBFunctionType*>& fparams = function_->GetParameters();
+
+    for (unsigned i = 0; i < fparams.Size(); i++)
+    {
+        JSBFunctionType* ftype = fparams[i];
+
+        JSBVectorType* vtype = ftype->type_->asVectorType();
+
+        if (!vtype)
+            continue;
+
+        JSBClassType* classType = vtype->vectorType_->asClassType();
+
+        if (!classType)
+            continue;
+
+        String className = classType->class_->GetName();
+
+        String vectorMarshal;
+
+        hasVectorMarshal = true;
+
+        if (vtype->isPODVector_)
+        {
+            const String& pname = ftype->name_;
+            source += IndentLine(ToString("PODVector<%s*> %s__vector;\n", className.CString(), pname.CString()));
+            source += IndentLine(ToString("if (%s) %s->AdaptToPODVector<%s*>(%s__vector);\n", pname.CString(), pname.CString(), className.CString(), pname.CString()));
+        }
+        else
+        {
+            // vectorMarshal = ToString("PODVector<%s*> %s__vector", className.CString(), ftype->name_.CString());
+        }
+
+        if (vectorMarshal.Length())
+        {
+            source += IndentLine(vectorMarshal);
+            vectorMarshal = String::EMPTY;
+        }
+    }
+
+
     bool returnValue = false;
     bool sharedPtrReturn = false;
 
@@ -214,10 +261,14 @@ void CSFunctionWriter::WriteNativeFunction(String& source)
     }
     else
     {
-        if (returnType != "void")
+        if (returnType != "void" && !hasVectorMarshal)
         {
             returnStatement = "return ";
         }
+        else if (returnType != "void")
+        {
+            returnStatement = ToString("%s returnValue = ", returnType.CString());
+        }
     }
 
     String callSig;
@@ -255,6 +306,44 @@ void CSFunctionWriter::WriteNativeFunction(String& source)
 
     source += IndentLine(line);
 
+    // Vector marshaling
+
+    for (unsigned i = 0; i < fparams.Size(); i++)
+    {
+        JSBFunctionType* ftype = fparams[i];
+
+        JSBVectorType* vtype = ftype->type_->asVectorType();
+
+        if (!vtype)
+            continue;
+
+        JSBClassType* classType = vtype->vectorType_->asClassType();
+
+        if (!classType)
+            continue;
+
+        String className = classType->class_->GetName();
+
+        String vectorMarshal;
+
+        if (vtype->isPODVector_)
+        {
+            const String& pname = ftype->name_;
+            source += IndentLine(ToString("if (%s) %s->AdaptFromPODVector<%s*>(%s__vector);\n", pname.CString(), pname.CString(), className.CString(), pname.CString()));
+        }
+        else
+        {
+            // vectorMarshal = ToString("PODVector<%s*> %s__vector", className.CString(), ftype->name_.CString());
+        }
+
+        if (vectorMarshal.Length())
+        {
+            source += IndentLine(vectorMarshal);
+            vectorMarshal = String::EMPTY;
+        }
+    }
+
+
     if (sharedPtrReturn)
     {
         source += IndentLine("if (returnValue.NotNull()) returnValue->AddRef();\n");
@@ -264,6 +353,10 @@ void CSFunctionWriter::WriteNativeFunction(String& source)
     {
         source += IndentLine("return returnValue.CString();\n");
     }
+    else if (returnType != "void" && hasVectorMarshal)
+    {
+        source += IndentLine("return returnValue;\n");
+    }
 
     Dedent();
 
@@ -588,6 +681,7 @@ void CSFunctionWriter::GenPInvokeCallParameters(String& sig)
 
 void CSFunctionWriter::WriteManagedFunction(String& source)
 {
+
     JSBClass* klass = function_->GetClass();
     JSBPackage* package = klass->GetPackage();
 

+ 2 - 0
Source/ToolCore/JSBind/CSharp/CSModuleWriter.cpp

@@ -92,6 +92,8 @@ void CSModuleWriter::WriteIncludes(String& source)
         included.Push(header);
     }
 
+    source += "\n#include <Atomic/Script/ScriptVector.h>\n";
+
     source += ToString("\n#include \"CSPackage%s.h\"\n", module_->GetPackage()->GetName().CString());
 
 }

+ 25 - 9
Source/ToolCore/JSBind/CSharp/CSTypeHelper.cpp

@@ -179,9 +179,8 @@ String CSTypeHelper::GetManagedTypeString(JSBType* type)
     }
     else if (type->asVectorType())
     {
-        JSBVectorType* vectorType = type->asVectorType();
 
-        value = GetManagedTypeString(vectorType->vectorType_) + "[]";
+        value = ToString("Vector<%s>", type->asVectorType()->vectorType_->asClassType()->class_->GetName().CString());
     }
 
     return value;
@@ -255,7 +254,7 @@ String CSTypeHelper::GetNativeTypeString(JSBType* type)
     }
     else if (type->asVectorType())
     {
-        assert(0);
+        value = "ScriptVector*";//type->asVectorType()->ToString();
     }
 
     return value;
@@ -298,9 +297,8 @@ String CSTypeHelper::GetPInvokeTypeString(JSBType* type)
     }
     else if (type->asVectorType())
     {
-        JSBVectorType* vectorType = type->asVectorType();
-
-        value = GetManagedTypeString(vectorType->vectorType_) + "[]";
+        // ScriptVector
+        value = "IntPtr";
     }
 
     return value;
@@ -357,26 +355,44 @@ bool CSTypeHelper::OmitFunction(JSBFunction* function)
     if (!function)
         return false;
 
-    if (function->Skip())
+
+    if (function->GetSkipLanguage(BINDINGLANGUAGE_CSHARP))
         return true;
 
     if (function->IsDestructor())
+    {
+        function->SetSkipLanguage(BINDINGLANGUAGE_CSHARP);
         return true;
+    }
 
     // We need to rename GetType
     if (function->GetName() == "GetType")
+    {
+        function->SetSkipLanguage(BINDINGLANGUAGE_CSHARP);
         return true;
+    }
 
     // avoid vector type for now
     if (function->GetReturnType() && function->GetReturnType()->type_->asVectorType())
+    {
+        function->SetSkipLanguage(BINDINGLANGUAGE_CSHARP);
         return true;
+    }
 
     Vector<JSBFunctionType*>& parameters = function->GetParameters();
 
     for (unsigned i = 0; i < parameters.Size(); i++)
     {
-        if (parameters[i]->type_->asVectorType())
-            return true;
+        if (JSBVectorType* vtype = parameters[i]->type_->asVectorType())
+        {
+            if (!vtype->vectorType_->asClassType() || vtype->vectorType_->asClassType()->class_->IsNumberArray())
+            {
+                function->SetSkipLanguage(BINDINGLANGUAGE_CSHARP);
+                return true;
+            }
+
+        }
+
     }
 
     return false;

+ 1 - 1
Source/ToolCore/JSBind/JSBClass.cpp

@@ -125,7 +125,7 @@ bool JSBFunctionSignature::Match(JSBFunction* function)
 
 JSBClass::JSBClass(Context* context, JSBModule *module, const String& name, const String& nativeName) : Object(context),
     module_(module), name_(name), nativeName_(nativeName),
-    isAbstract_(false), isObject_(false),
+    isAbstract_(false), isObject_(false), isGeneric_(false),
     numberArrayElements_(0), arrayElementType_("float"),
     hasProperties_(false)
 {

+ 3 - 0
Source/ToolCore/JSBind/JSBClass.h

@@ -127,6 +127,7 @@ public:
     PODVector<JSBClass*>& GetBaseClasses() {return baseClasses_; }
     PODVector<JSBFunction*>& GetFunctions() { return functions_; }
 
+    bool IsGeneric() { return isGeneric_; }
     bool IsAbstract() { return isAbstract_; }
 
     /// Note that if we at some point want to generate bindings for JSBClass
@@ -159,6 +160,7 @@ public:
 
     void SetAbstract(bool value = true) { isAbstract_ = value; }
     void SetObject(bool value = true) { isObject_ = value; }
+    void SetGeneric(bool value = true) { isGeneric_ = value; }
     void SetHeader(JSBHeader* header) { header_ = header; }
     void SetBaseClass(JSBClass* baseClass);
 
@@ -203,6 +205,7 @@ private:
 
     bool isAbstract_;
     bool isObject_;
+    bool isGeneric_;
 
     // Vector3, Color, etc are marshalled via arrays
     int numberArrayElements_;

+ 27 - 2
Source/ToolCore/JSBind/JSBFunction.h

@@ -23,6 +23,7 @@
 #pragma once
 
 #include <Atomic/IO/Log.h>
+#include "JSBindTypes.h"
 #include "JSBClass.h"
 #include "JSBType.h"
 #include "JSBSymbol.h"
@@ -150,7 +151,14 @@ public:
     bool IsOverload() { return isOverload_; }
     bool IsVirtual() { return isVirtual_; }
     bool IsStatic() { return isStatic_; }
-    bool Skip() { return skip_; }
+
+    bool Skip(BindingLanguage language = BINDINGLANGUAGE_ANY)
+    {
+        if (skip_ || language == BINDINGLANGUAGE_ANY)
+            return skip_;
+
+        return GetSkipLanguage(language);
+    }
 
     JSBClass* GetClass() { return class_; }
     const String& GetPropertyName() { return propertyName_; }
@@ -175,6 +183,23 @@ public:
     void SetReturnType(JSBFunctionType* retType) { returnType_ = retType; }
     void SetDocString(const String& docString) { docString_ = docString; }
 
+    void SetSkipLanguage(BindingLanguage language, bool skip = true)
+    {
+        bindSkip_[language] = skip;
+    }
+
+    /// Returns true is _skip is set or skip is set for specific binding language
+    bool GetSkipLanguage(BindingLanguage language) const
+    {
+        if (skip_)
+            return true;
+
+        if (bindSkip_.Contains(language))
+            return bindSkip_[language];
+
+        return false;
+    }
+
     int FirstDefaultParameter()
     {
         for (unsigned i = 0; i < parameters_.Size(); i++)
@@ -244,7 +269,7 @@ private:
     bool isVirtual_;
     bool isStatic_;
     bool skip_;
-
+    HashMap<unsigned, bool> bindSkip_;
 };
 
 }

+ 17 - 7
Source/ToolCore/JSBind/JSBHeaderVisitor.h

@@ -92,16 +92,30 @@ public:
             if (classname.StartsWith("Atomic::"))
                 classname.Replace("Atomic::", "");
 
-            if (classname == "Vector")
+            if (classname == "Vector" || classname == "PODVector")
             {
                 if (ntype->name()->asTemplateNameId())
                 {
+                    bool isPointer = false;
+
                     const TemplateNameId* tnid = ntype->name()->asTemplateNameId();
                     FullySpecifiedType pfst = tnid->templateArgumentAt(0);
-                    JSBType* vtype = processTypeConversion(pfst.type());
+
+                    Type* type = pfst.type();
+
+                    // unwrap pointer
+                    if (type->isPointerType())
+                    {
+                        isPointer = true;
+                        pfst = type->asPointerType()->elementType();
+                        type = pfst.type();
+                    }
+
+                    JSBType* vtype = processTypeConversion(type);
+
                     if (vtype)
                     {
-                        jtype = new JSBVectorType(vtype);
+                        jtype = new JSBVectorType(vtype, classname == "PODVector");
                     }
                 }
             }
@@ -214,10 +228,6 @@ public:
         if (!jtype)
             return NULL;
 
-        // read only vectors atm
-        if (!isConst && jtype->asVectorType())
-            return NULL;
-
         bool skip = false;
 
         // no pointers to prim atm

+ 12 - 0
Source/ToolCore/JSBind/JSBModule.cpp

@@ -352,6 +352,11 @@ void JSBModule::RegisterClass(String name)
 
         JSBClass* cls = new JSBClass(context_, this, name, nativeName);
 
+        if (genericClassnames_.Contains(name))
+        {
+            cls->SetGeneric();
+        }
+
         classes_[nativeName] = cls;
 
         package_->RegisterClass(cls);
@@ -446,6 +451,13 @@ bool JSBModule::Load(const String& jsonFilename)
         classnames_.Push(classes[i].GetString());
     }
 
+    JSONArray classesGeneric = root.Get("classes_generic").GetArray();
+
+    for (unsigned i = 0; i < classesGeneric.Size(); i++)
+    {
+        genericClassnames_.Push(classesGeneric[i].GetString());
+    }
+
     JSONValue classes_rename = root.Get("classes_rename");
 
     if (classes_rename.IsObject())

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

@@ -107,6 +107,8 @@ private:
     Vector<String> sourceDirs_;
     Vector<String> classnames_;
 
+    Vector<String> genericClassnames_;
+
     HashMap<String, String> classRenames_;
 
     // native name -> JSBClass

+ 10 - 0
Source/ToolCore/JSBind/JSBType.cpp

@@ -70,4 +70,14 @@ JSBType* JSBType::Parse(const String& value)
 
 }
 
+String JSBVectorType::ToString()
+{
+    if (vectorType_->asClassType())
+    {
+        return isPODVector_ ? "PODVector<" + vectorType_->ToString() + "*>" : "Vector<" + vectorType_->ToString() + "*>";
+    }
+
+    return isPODVector_ ? "PODVector<" + vectorType_->ToString() + ">" : "Vector<" + vectorType_->ToString() + ">";
+}
+
 }

+ 6 - 4
Source/ToolCore/JSBind/JSBType.h

@@ -225,13 +225,11 @@ class JSBVectorType : public JSBType
 
 public:
 
-    JSBType* vectorType_;
-
-    JSBVectorType(JSBType* vtype) : vectorType_(vtype) {}
+    JSBVectorType(JSBType* vtype, bool podVector = false) : vectorType_(vtype), isPODVector_(podVector) {}
 
     virtual JSBVectorType* asVectorType() { return this; }
 
-    String ToString() { return "Vector<" + vectorType_->ToString() + ">"; }
+    String ToString();
 
     virtual bool Match (JSBType* other)
     {
@@ -246,6 +244,10 @@ public:
         return true;
     }
 
+    JSBType* vectorType_;
+
+    bool isPODVector_;
+
 };
 
 

+ 4 - 4
Source/ToolCore/JSBind/JSBTypeScript.cpp

@@ -111,7 +111,7 @@ void JSBTypeScript::End()
 
 void JSBTypeScript::ExportFunction(JSBFunction* function)
 {
-    if (function->Skip())
+    if (function->Skip(BINDINGLANGUAGE_JAVASCRIPT))
         return;
 
     String scriptName = "constructor";
@@ -228,11 +228,11 @@ void JSBTypeScript::ExportModuleClasses(JSBModule* module)
 
             JSBFunctionType* ftype = NULL;
 
-            if (prop->getter_ && !prop->getter_->Skip())
+            if (prop->getter_ && !prop->getter_->Skip(BINDINGLANGUAGE_JAVASCRIPT))
             {
                 ftype = prop->getter_->GetReturnType();
             }
-            else if (prop->setter_ && !prop->setter_->Skip())
+            else if (prop->setter_ && !prop->setter_->Skip(BINDINGLANGUAGE_JAVASCRIPT))
                 ftype = prop->setter_->GetParameters()[0];
 
             if (!ftype)
@@ -262,7 +262,7 @@ void JSBTypeScript::ExportModuleClasses(JSBModule* module)
 
             JSBFunction* func = functions[j];
 
-            if (func->IsConstructor() || func->IsDestructor() || func->Skip())
+            if (func->IsConstructor() || func->IsDestructor() || func->Skip(BINDINGLANGUAGE_JAVASCRIPT))
                 continue;
 
             ExportFunction(func);

+ 36 - 0
Source/ToolCore/JSBind/JSBindTypes.h

@@ -0,0 +1,36 @@
+
+//
+// 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 ToolCore
+{
+
+enum BindingLanguage
+{
+    BINDINGLANGUAGE_ANY = 0,
+    BINDINGLANGUAGE_JAVASCRIPT,
+    BINDINGLANGUAGE_CSHARP
+};
+
+}

+ 37 - 3
Source/ToolCore/JSBind/JavaScript/JSClassWriter.cpp

@@ -47,7 +47,7 @@ void JSClassWriter::WriteFunctions(String& source)
     {
         JSBFunction* function = klass_->functions_.At(i);
 
-        if (function->Skip())
+        if (function->Skip(BINDINGLANGUAGE_JAVASCRIPT) || OmitFunction(function))
             continue;
 
         if (function->IsDestructor())
@@ -95,7 +95,7 @@ void JSClassWriter::GenerateStaticFunctionsSource(String& source, String& packag
     {
         JSBFunction* function = klass_->functions_.At(i);
 
-        if (function->Skip())
+        if (function->Skip(BINDINGLANGUAGE_JAVASCRIPT) || OmitFunction(function))
             continue;
 
         if (function->IsConstructor() || function->IsDestructor())
@@ -132,7 +132,7 @@ void JSClassWriter::GenerateNonStaticFunctionsSource(String& source, String& pac
     {
         JSBFunction* function = klass_->functions_.At(i);
 
-        if (function->Skip())
+        if (function->Skip(BINDINGLANGUAGE_JAVASCRIPT) || OmitFunction(function))
             continue;
 
         if (function->IsConstructor() || function->IsDestructor())
@@ -158,5 +158,39 @@ void JSClassWriter::GenerateNonStaticFunctionsSource(String& source, String& pac
     source.Append("duk_pop(ctx);\n");
 }
 
+bool JSClassWriter::OmitFunction(JSBFunction* function)
+{
+
+    if (function->GetSkipLanguage(BINDINGLANGUAGE_JAVASCRIPT))
+        return true;
+
+    Vector<JSBFunctionType*>& parameters = function->GetParameters();
+
+    if (function->GetReturnType() && function->GetReturnType()->type_->asVectorType())
+    {
+        if (!function->GetReturnType()->isConst_ || function->GetReturnType()->type_->asVectorType()->isPODVector_)
+        {
+            function->SetSkipLanguage(BINDINGLANGUAGE_JAVASCRIPT);
+            return true;
+        }
+    }
+
+    for (unsigned i = 0; i < parameters.Size(); i++)
+    {
+        JSBFunctionType* ptype = parameters[i];
+
+        if (ptype->type_->asVectorType())
+        {
+            if (!ptype->isConst_ || ptype->type_->asVectorType()->isPODVector_)
+            {
+                function->SetSkipLanguage(BINDINGLANGUAGE_JAVASCRIPT);
+                return true;
+            }
+        }
+    }
+
+    return false;
+
+}
 
 }

+ 4 - 0
Source/ToolCore/JSBind/JavaScript/JSClassWriter.h

@@ -33,6 +33,7 @@ namespace ToolCore
 
 class JSBPackage;
 class JSBClass;
+class JSBFunction;
 
 class JSClassWriter : public JSBClassWriter
 {
@@ -45,7 +46,10 @@ public:
 
 private:
 
+    bool OmitFunction(JSBFunction* function);
+
     void WriteFunctions(String& source);
+
     void GenerateStaticFunctionsSource(String& source, String& packageName);
     void GenerateNonStaticFunctionsSource(String& source, String& packageName);
 

+ 2 - 2
Source/ToolCore/JSBind/JavaScript/JSModuleWriter.cpp

@@ -91,13 +91,13 @@ void JSModuleWriter::WriteClassDeclaration(String& source)
 
                 source.Append("duk_push_object(ctx);\n");
 
-                if (prop->getter_ && !prop->getter_->Skip())
+                if (prop->getter_ && !prop->getter_->Skip(BINDINGLANGUAGE_JAVASCRIPT))
                 {
                     source.AppendWithFormat("duk_push_c_function(ctx, jsb_class_%s_%s, 0);\n",
                                             klass->GetName().CString(), prop->getter_->GetName().CString());
                     source.Append("duk_put_prop_string(ctx, -2, \"get\");\n");
                 }
-                if (prop->setter_ && !prop->setter_->Skip())
+                if (prop->setter_ && !prop->setter_->Skip(BINDINGLANGUAGE_JAVASCRIPT))
                 {
                     source.AppendWithFormat("duk_push_c_function(ctx, jsb_class_%s_%s, 1);\n",
                                             klass->GetName().CString(), prop->setter_->GetName().CString());