Преглед изворни кода

interrogatedb v2.3: elements can have comments

rdb пре 11 година
родитељ
комит
8afd8b1f57

+ 6 - 0
dtool/src/interrogate/interrogateBuilder.cxx

@@ -1357,6 +1357,11 @@ scan_element(CPPInstance *element, CPPStructType *struct_type,
   ielement._name = element->get_local_name(scope);
   ielement._scoped_name = descope(element->get_local_name(&parser));
 
+  // See if there happens to be a comment before the element.
+  if (element->_leading_comment != (CPPCommentBlock *)NULL) {
+    ielement._comment = trim_blanks(element->_leading_comment->_comment);
+  }
+
   ielement._type = get_type(TypeManager::unwrap_reference(element_type), false);
   if (ielement._type == 0) {
     // If we can't understand what type it is, forget it.
@@ -1641,6 +1646,7 @@ get_function(CPPInstance *function, string description,
              CPPStructType *struct_type,
              CPPScope *scope, int flags,
              const string &expression) {
+
   // Get a unique function signature.  Make sure we tell the function
   // where its native scope is, so we get a fully-scoped signature.
 

+ 1 - 1
dtool/src/interrogatedb/interrogateDatabase.cxx

@@ -21,7 +21,7 @@ InterrogateDatabase *InterrogateDatabase::_global_ptr = NULL;
 int InterrogateDatabase::_file_major_version = 0;
 int InterrogateDatabase::_file_minor_version = 0;
 int InterrogateDatabase::_current_major_version = 2;
-int InterrogateDatabase::_current_minor_version = 2;
+int InterrogateDatabase::_current_minor_version = 3;
 
 ////////////////////////////////////////////////////////////////////
 //     Function: InterrogateDatabase::Constructor

+ 21 - 0
dtool/src/interrogatedb/interrogateElement.I

@@ -48,6 +48,7 @@ operator = (const InterrogateElement &copy) {
   InterrogateComponent::operator = (copy);
   _flags = copy._flags;
   _scoped_name = copy._scoped_name;
+  _comment = copy._comment;
   _type = copy._type;
   _getter = copy._getter;
   _setter = copy._setter;
@@ -85,6 +86,26 @@ get_scoped_name() const {
   return _scoped_name;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: InterrogateElement::has_comment
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE bool InterrogateElement::
+has_comment() const {
+  return !_comment.empty();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: InterrogateElement::get_comment
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE const string &InterrogateElement::
+get_comment() const {
+  return _comment;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Element: InterrogateElement::get_type
 //       Access: Public

+ 5 - 0
dtool/src/interrogatedb/interrogateElement.cxx

@@ -30,6 +30,7 @@ output(ostream &out) const {
       << _getter << " "
       << _setter << " ";
   idf_output_string(out, _scoped_name);
+  idf_output_string(out, _comment, '\n');
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -43,6 +44,10 @@ input(istream &in) {
   InterrogateComponent::input(in);
   in >> _flags >> _type >> _getter >> _setter;
   idf_input_string(in, _scoped_name);
+
+  if (InterrogateDatabase::get_file_minor_version() >= 3) {
+    idf_input_string(in, _comment);
+  }
 }
 
 ////////////////////////////////////////////////////////////////////

+ 4 - 0
dtool/src/interrogatedb/interrogateElement.h

@@ -37,6 +37,9 @@ public:
   INLINE bool has_scoped_name() const;
   INLINE const string &get_scoped_name() const;
 
+  INLINE bool has_comment() const;
+  INLINE const string &get_comment() const;
+
   INLINE TypeIndex get_type() const;
   INLINE bool has_getter() const;
   INLINE FunctionIndex get_getter() const;
@@ -57,6 +60,7 @@ private:
 
   int _flags;
   string _scoped_name;
+  string _comment;
   TypeIndex _type;
   FunctionIndex _getter;
   FunctionIndex _setter;