소스 검색

Vector.h: fix static asserts | BindingGenerator: add nobind support for global variables

1vanK 3 년 전
부모
커밋
b774914f18

+ 12 - 0
Source/Tools/BindingGenerator/ASGlobalVariableBinder.cpp

@@ -13,6 +13,11 @@ using namespace std;
 namespace ASBindingGenerator
 namespace ASBindingGenerator
 {
 {
 
 
+static bool HaveMark(const GlobalVariableAnalyzer& varAnalyzer, const string& mark)
+{
+    return Contains(varAnalyzer.GetComment(), mark);
+}
+
 static void ProcessGlobalVariable(GlobalVariableAnalyzer varAnalyzer)
 static void ProcessGlobalVariable(GlobalVariableAnalyzer varAnalyzer)
 {
 {
     string header = varAnalyzer.GetHeaderFile();
     string header = varAnalyzer.GetHeaderFile();
@@ -34,6 +39,13 @@ static void ProcessGlobalVariable(GlobalVariableAnalyzer varAnalyzer)
         return;
         return;
     }
     }
 
 
+    if (HaveMark(varAnalyzer, "NO_BIND"))
+    {
+        processedGlobalVariable.registration_ = "// Not registered because have @nobind mark";
+        Result::globalVariables_.push_back(processedGlobalVariable);
+        return;
+    }
+
     TypeAnalyzer typeAnalyzer = varAnalyzer.GetType();
     TypeAnalyzer typeAnalyzer = varAnalyzer.GetType();
 
 
     string asType;
     string asType;

+ 1 - 0
Source/Tools/BindingGenerator/XmlAnalyzer.h

@@ -228,6 +228,7 @@ public:
 
 
     std::string GetName() const { return ExtractName(memberdef_); }
     std::string GetName() const { return ExtractName(memberdef_); }
     std::string GetHeaderFile() const { return ExtractHeaderFile(memberdef_); }
     std::string GetHeaderFile() const { return ExtractHeaderFile(memberdef_); }
+    std::string GetComment() const { return ExtractComment(memberdef_); }
     bool IsStatic() const { return ::IsStatic(memberdef_); }
     bool IsStatic() const { return ::IsStatic(memberdef_); }
     TypeAnalyzer GetType() const { return ExtractType(memberdef_); }
     TypeAnalyzer GetType() const { return ExtractType(memberdef_); }
     bool IsArray() const { return StartsWith(ExtractArgsstring(memberdef_), "["); }
     bool IsArray() const { return StartsWith(ExtractArgsstring(memberdef_), "["); }

+ 3 - 0
Source/Urho3D/AngelScript/Generated_GlobalVariables.cpp

@@ -631,6 +631,9 @@ void ASRegisterGeneratedGlobalVariables(asIScriptEngine* engine)
     // constexpr i32 WI_MAX_PRIORITY | File: ../Core/WorkQueue.h
     // constexpr i32 WI_MAX_PRIORITY | File: ../Core/WorkQueue.h
     engine->RegisterGlobalProperty("const int WI_MAX_PRIORITY", (void*)&WI_MAX_PRIORITY);
     engine->RegisterGlobalProperty("const int WI_MAX_PRIORITY", (void*)&WI_MAX_PRIORITY);
 
 
+    // constexpr bool always_false | File: ../Container/Vector.h
+    // Not registered because have @nobind mark
+
 #ifdef URHO3D_NETWORK
 #ifdef URHO3D_NETWORK
     // static const unsigned CONTROLS_CONTENT_ID | File: ../Network/Protocol.h
     // static const unsigned CONTROLS_CONTENT_ID | File: ../Network/Protocol.h
     engine->RegisterGlobalProperty("const uint CONTROLS_CONTENT_ID", (void*)&CONTROLS_CONTENT_ID);
     engine->RegisterGlobalProperty("const uint CONTROLS_CONTENT_ID", (void*)&CONTROLS_CONTENT_ID);

+ 8 - 2
Source/Urho3D/Container/Vector.h

@@ -22,6 +22,10 @@ inline constexpr i32 NINDEX = -1;
 /// End position.
 /// End position.
 inline constexpr i32 ENDPOS = -1;
 inline constexpr i32 ENDPOS = -1;
 
 
+/// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2593r0.html
+/// @nobindtemp
+template <typename...> inline constexpr bool always_false = false;
+
 /// %Vector template class.
 /// %Vector template class.
 template <class T> class Vector : public VectorBase
 template <class T> class Vector : public VectorBase
 {
 {
@@ -925,7 +929,8 @@ private:
         }
         }
         else
         else
         {
         {
-            static_assert(true);
+            // https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2593r0.html
+            static_assert(always_false<T>); // static_assert(false);
         }
         }
     }
     }
 
 
@@ -941,7 +946,8 @@ private:
         }
         }
         else
         else
         {
         {
-            static_assert(true);
+            // https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2593r0.html
+            static_assert(always_false<T>); // static_assert(false);
         }
         }
     }
     }
 };
 };