Przeglądaj źródła

AS Autobindings: Rename class registration function to more readable; Add comment before class registration function to allows do not write file name before every class member

1vanK 4 lat temu
rodzic
commit
d7a1578ca2

+ 1 - 1
Source/Tools/BindingGenerator/ASClassBinderNew.cpp

@@ -154,7 +154,7 @@ static void RegisterDestructor(const ClassAnalyzer& classAnalyzer, ProcessedClas
 
     if (thisDestructor)
     {
-        result->comment_ = thisDestructor->GetLocation();
+        result->comment_ = thisDestructor->GetDeclaration();
         processedClass.destructor_ = result;
     }
     else if (!classAnalyzer.HasThisDestructor() && IsDestructorRequired(classAnalyzer))

+ 3 - 2
Source/Tools/BindingGenerator/ASResult.cpp

@@ -574,7 +574,8 @@ namespace Result
             }
 
             ofs <<
-                "static void Register" << processedClass.name_ << "(asIScriptEngine* engine)\n"
+                "// " << processedClass.comment_ << "\n"
+                "static void Register_" << processedClass.name_ << "(asIScriptEngine* engine)\n"
                 "{\n";
 
             /*
@@ -623,7 +624,7 @@ namespace Result
                 openedDefine = processedClass.insideDefine_;
             }
 
-            ofs << "    Register" << processedClass.name_ << "(engine);\n";
+            ofs << "    Register_" << processedClass.name_ << "(engine);\n";
 
             isFirst = false;
         }

+ 1 - 1
Source/Tools/BindingGenerator/ASResult.h

@@ -115,7 +115,7 @@ struct ProcessedGlobalVariable
 struct ClassMemberRegistration
 {
     string name_; // Used for sorting
-    string comment_; // Location
+    string comment_; // Cpp declaration or location
     string glue_; // Can be empty
     string registration_; // Or warning message
 };

+ 6 - 4
Source/Tools/BindingGenerator/XmlAnalyzer.cpp

@@ -886,7 +886,7 @@ string ClassFunctionAnalyzer::GetContainsClassName() const
     return result;
 }
 
-string GetFunctionLocation(xml_node memberdef)
+string GetFunctionDeclaration(xml_node memberdef)
 {
     assert(IsMemberdef(memberdef));
     assert(ExtractKind(memberdef) == "function");
@@ -904,8 +904,6 @@ string GetFunctionLocation(xml_node memberdef)
     if (IsExplicit(memberdef))
         result = "explicit " + result;
 
-    result += " | File: " + ExtractHeaderFile(memberdef);
-
     if (IsTemplate(memberdef))
     {
         string t = "";
@@ -935,6 +933,11 @@ string GetFunctionLocation(xml_node memberdef)
     return result;
 }
 
+string GetFunctionLocation(xml_node memberdef)
+{
+    return GetFunctionDeclaration(memberdef) + " | File: " + ExtractHeaderFile(memberdef);
+}
+
 bool ClassFunctionAnalyzer::IsConst() const
 {
     string constAttr = memberdef_.attribute("const").value();
@@ -1028,7 +1031,6 @@ string ClassVariableAnalyzer::GetLocation() const
     string result =  match[1].str() + match[2].str();
 
     result = BeautifyDefinition(result);
-
     result += " | File: " + GetHeaderFile();
 
     if (!classAnalyzer_.usingLocation_.empty())

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

@@ -161,6 +161,10 @@ vector<ParamAnalyzer> ExtractParams(xml_node memberdef, const TemplateSpecializa
 string JoinParamsTypes(xml_node memberdef, const TemplateSpecialization& specialization = {});
 string JoinParamsNames(xml_node memberdef, bool skipContext = false);
 
+// <memberdef kind="function">
+//     ...
+string GetFunctionDeclaration(xml_node memberdef);
+
 // <memberdef kind="function">
 //     ...
 string GetFunctionLocation(xml_node memberdef);
@@ -365,6 +369,7 @@ public:
     bool IsDeleted() const { return EndsWith(ExtractArgsstring(memberdef_), "=delete"); }
     bool IsConsversionOperator() const { return StartsWith(GetName(), "operator "); }
 
+    string GetDeclaration() const { return JoinNonEmpty({ classAnalyzer_.usingLocation_, GetFunctionDeclaration(memberdef_) }, " | "); }
     string GetLocation() const override { return JoinNonEmpty({ classAnalyzer_.usingLocation_, GetFunctionLocation(memberdef_) }, " | "); }
 };
 

Plik diff jest za duży
+ 270 - 141
Source/Urho3D/AngelScript/GeneratedClasses.cpp


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików