From e0ea1912533d04bddb7b08742b6b873a9d3e7a4e Mon Sep 17 00:00:00 2001 From: Josh Engebretson Date: Tue, 20 Jun 2017 10:55:21 -0700 Subject: [PATCH] Static methods now generate static properties, with error checking for static mismatch --- Script/AtomicNET/AtomicNET/Core/AtomicNET.cs | 2 +- .../ToolCore/JSBind/CSharp/CSClassWriter.cpp | 23 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Script/AtomicNET/AtomicNET/Core/AtomicNET.cs b/Script/AtomicNET/AtomicNET/Core/AtomicNET.cs index e44e2014e3..7856704196 100644 --- a/Script/AtomicNET/AtomicNET/Core/AtomicNET.cs +++ b/Script/AtomicNET/AtomicNET/Core/AtomicNET.cs @@ -123,7 +123,7 @@ public static void Initialize() if (core != null) AtomicNET.RegisterSubsystem(core); - context = core.Context; + context = NETCore.Context; NativeCore.Initialize(); CSComponentCore.Initialize(); diff --git a/Source/ToolCore/JSBind/CSharp/CSClassWriter.cpp b/Source/ToolCore/JSBind/CSharp/CSClassWriter.cpp index 634edd71e0..db64435744 100644 --- a/Source/ToolCore/JSBind/CSharp/CSClassWriter.cpp +++ b/Source/ToolCore/JSBind/CSharp/CSClassWriter.cpp @@ -101,6 +101,8 @@ void CSClassWriter::WriteManagedProperties(String& sourceOut) JSBFunctionType* fType = NULL; JSBFunctionType* getType = NULL; JSBFunctionType* setType = NULL; + bool getStatic = false; + bool setStatic = false; if (CSTypeHelper::OmitFunction(prop->getter_) || CSTypeHelper::OmitFunction(prop->setter_)) continue; @@ -118,22 +120,39 @@ void CSClassWriter::WriteManagedProperties(String& sourceOut) if (prop->getter_ && !prop->getter_->Skip()) { - fType = getType = prop->getter_->GetReturnType(); + getStatic = prop->getter_->IsStatic(); + fType = getType = prop->getter_->GetReturnType(); } + if (prop->setter_ && !prop->setter_->Skip()) { + setStatic = prop->setter_->IsStatic(); setType = prop->setter_->GetParameters()[0]; if (!fType) + { fType = setType; + } else if (fType->type_->ToString() != setType->type_->ToString()) + { + continue; + } + else if (getStatic != setStatic) + { + ATOMIC_LOGWARNINGF("CSClassWriter::WriteManagedProperties : mismatched static qualifier on property %s:%s", + klass_->GetName().CString(), prop->name_.CString()); + continue; + } } if (!fType) continue; - String line = klass_->IsInterface() ? "" : "public "; + String line = (klass_->IsInterface() ? "" : "public "); + + if (getStatic) + line += "static "; JSBClass* baseClass = klass_->GetBaseClass(); if (baseClass)