Browse Source

add references

David Rose 21 years ago
parent
commit
5ca8fa4a23

+ 2 - 0
pandatool/src/xfile/Sources.pp

@@ -24,6 +24,8 @@
      xFileDataObjectDouble.cxx xFileDataObjectDouble.I xFileDataObjectDouble.h \
      xFileDataObjectDouble.cxx xFileDataObjectDouble.I xFileDataObjectDouble.h \
      xFileDataObjectInteger.cxx xFileDataObjectInteger.I xFileDataObjectInteger.h \
      xFileDataObjectInteger.cxx xFileDataObjectInteger.I xFileDataObjectInteger.h \
      xFileDataObjectTemplate.cxx xFileDataObjectTemplate.I xFileDataObjectTemplate.h \
      xFileDataObjectTemplate.cxx xFileDataObjectTemplate.I xFileDataObjectTemplate.h \
+     xFileDataNode.cxx xFileDataNode.I xFileDataNode.h \
+     xFileDataNodeReference.cxx xFileDataNodeReference.I xFileDataNodeReference.h \
      xFileNode.cxx xFileNode.I xFileNode.h \
      xFileNode.cxx xFileNode.I xFileNode.h \
      xFileParseData.cxx xFileParseData.I xFileParseData.h \
      xFileParseData.cxx xFileParseData.I xFileParseData.h \
      xFileTemplate.cxx xFileTemplate.I xFileTemplate.h
      xFileTemplate.cxx xFileTemplate.I xFileTemplate.h

+ 4 - 0
pandatool/src/xfile/config_xfile.cxx

@@ -24,6 +24,8 @@
 #include "xFileDataObjectDouble.h"
 #include "xFileDataObjectDouble.h"
 #include "xFileDataObjectInteger.h"
 #include "xFileDataObjectInteger.h"
 #include "xFileDataObjectTemplate.h"
 #include "xFileDataObjectTemplate.h"
+#include "xFileDataNode.h"
+#include "xFileDataNodeReference.h"
 #include "xFileNode.h"
 #include "xFileNode.h"
 #include "xFileTemplate.h"
 #include "xFileTemplate.h"
 
 
@@ -65,6 +67,8 @@ init_libxfile() {
   XFileDataObjectDouble::init_type();
   XFileDataObjectDouble::init_type();
   XFileDataObjectInteger::init_type();
   XFileDataObjectInteger::init_type();
   XFileDataObjectTemplate::init_type();
   XFileDataObjectTemplate::init_type();
+  XFileDataNode::init_type();
+  XFileDataNodeReference::init_type();
   XFileNode::init_type();
   XFileNode::init_type();
   XFileTemplate::init_type();
   XFileTemplate::init_type();
 }
 }

+ 18 - 0
pandatool/src/xfile/xFileDataNode.I

@@ -0,0 +1,18 @@
+// Filename: xFileDataNode.I
+// Created by:  drose (08Oct04)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+

+ 33 - 0
pandatool/src/xfile/xFileDataNode.cxx

@@ -0,0 +1,33 @@
+// Filename: xFileDataNode.cxx
+// Created by:  drose (08Oct04)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "xFileDataNode.h"
+#include "indent.h"
+
+TypeHandle XFileDataNode::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: XFileDataNode::Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+XFileDataNode::
+XFileDataNode(XFile *x_file, const string &name) :
+  XFileNode(x_file, name)
+{
+}

+ 67 - 0
pandatool/src/xfile/xFileDataNode.h

@@ -0,0 +1,67 @@
+// Filename: xFileDataNode.h
+// Created by:  drose (08Oct04)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef XFILEDATANODE_H
+#define XFILEDATANODE_H
+
+#include "pandatoolbase.h"
+#include "xFileNode.h"
+#include "xFileDataObject.h"
+#include "pointerTo.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : XFileDataNode
+// Description : This is an XFileNode which is also an
+//               XFileDataObject.  Specifically, this is the base
+//               class of XFileDataNodeTemplate and
+//               XFileDataNodeReference, both of which have a similar
+//               interface--they can both appear as the child of a
+//               XFileNode, and they both contain additional nodes and
+//               data objects.
+////////////////////////////////////////////////////////////////////
+class XFileDataNode : public XFileNode, public XFileDataObject {
+public:
+  XFileDataNode(XFile *x_file, const string &name);
+
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    XFileNode::init_type();
+    XFileDataObject::init_type();
+    register_type(_type_handle, "XFileDataNode",
+                  XFileNode::get_class_type(),
+                  XFileDataObject::get_class_type());
+  }
+  virtual TypeHandle get_type() const {
+    return get_class_type();
+  }
+  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
+
+private:
+  static TypeHandle _type_handle;
+};
+
+#include "xFileDataNode.I"
+
+#endif
+  
+
+
+

+ 38 - 0
pandatool/src/xfile/xFileDataNodeReference.I

@@ -0,0 +1,38 @@
+// Filename: xFileDataNodeReference.I
+// Created by:  drose (08Oct04)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: XFileDataNodeReference::get_template
+//       Access: Public
+//  Description: Returns the template used to define this data object.
+////////////////////////////////////////////////////////////////////
+INLINE XFileTemplate *XFileDataNodeReference::
+get_template() const {
+  return _object->get_template();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: XFileDataNodeReference::get_object
+//       Access: Public
+//  Description: Returns the actual data object being referenced.
+////////////////////////////////////////////////////////////////////
+INLINE XFileDataObjectTemplate *XFileDataNodeReference::
+get_object() const {
+  return _object;
+}

+ 92 - 0
pandatool/src/xfile/xFileDataNodeReference.cxx

@@ -0,0 +1,92 @@
+// Filename: xFileDataNodeReference.cxx
+// Created by:  drose (08Oct04)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "xFileDataNodeReference.h"
+#include "indent.h"
+
+TypeHandle XFileDataNodeReference::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: XFileDataNodeReference::Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+XFileDataNodeReference::
+XFileDataNodeReference(XFileDataObjectTemplate *object) :
+  XFileDataNode(object->get_x_file(), object->get_name()),
+  _object(object)
+{
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: XFileDataNodeReference::is_complex_object
+//       Access: Public, Virtual
+//  Description: Returns true if this kind of data object is a complex
+//               object that can hold nested data elements, false
+//               otherwise.
+////////////////////////////////////////////////////////////////////
+bool XFileDataNodeReference::
+is_complex_object() const {
+  return true;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: XFileDataNodeReference::write_text
+//       Access: Public, Virtual
+//  Description: Writes a suitable representation of this node to an
+//               .x file in text mode.
+////////////////////////////////////////////////////////////////////
+void XFileDataNodeReference::
+write_text(ostream &out, int indent_level) const {
+  indent(out, indent_level)
+    << "{ " << _object->get_name() << " }\n";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: XFileDataNodeReference::get_num_elements
+//       Access: Protected, Virtual
+//  Description: Returns the number of nested data elements within the
+//               object.  This may be, e.g. the size of the array, if
+//               it is an array.
+////////////////////////////////////////////////////////////////////
+int XFileDataNodeReference::
+get_num_elements() const {
+  return _object->size();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: XFileDataNodeReference::get_element
+//       Access: Protected, Virtual
+//  Description: Returns the nth nested data element within the
+//               object.
+////////////////////////////////////////////////////////////////////
+const XFileDataObject *XFileDataNodeReference::
+get_element(int n) const {
+  return &((*_object)[n]);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: XFileDataNodeReference::get_element
+//       Access: Protected, Virtual
+//  Description: Returns the nested data element within the
+//               object that has the indicated name.
+////////////////////////////////////////////////////////////////////
+const XFileDataObject *XFileDataNodeReference::
+get_element(const string &name) const {
+  return &((*_object)[name]);
+}

+ 74 - 0
pandatool/src/xfile/xFileDataNodeReference.h

@@ -0,0 +1,74 @@
+// Filename: xFileDataNodeReference.h
+// Created by:  drose (08Oct04)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef XFILEDATANODEREFERENCE_H
+#define XFILEDATANODEREFERENCE_H
+
+#include "pandatoolbase.h"
+#include "xFileDataObjectTemplate.h"
+#include "pointerTo.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : XFileDataNodeReference
+// Description : This is a nested reference to a template object,
+//               declared via { ObjectName } in the X File.
+////////////////////////////////////////////////////////////////////
+class XFileDataNodeReference : public XFileDataNode {
+public:
+  XFileDataNodeReference(XFileDataObjectTemplate *object);
+
+  INLINE XFileTemplate *get_template() const;
+  INLINE XFileDataObjectTemplate *get_object() const;
+
+  virtual bool is_complex_object() const;
+
+  virtual void write_text(ostream &out, int indent_level) const;
+
+protected:
+  virtual int get_num_elements() const;
+  virtual const XFileDataObject *get_element(int n) const;
+  virtual const XFileDataObject *get_element(const string &name) const;
+
+private:
+  PT(XFileDataObjectTemplate) _object;
+
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    XFileDataNode::init_type();
+    register_type(_type_handle, "XFileDataNodeReference",
+                  XFileDataNode::get_class_type());
+  }
+  virtual TypeHandle get_type() const {
+    return get_class_type();
+  }
+  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
+
+private:
+  static TypeHandle _type_handle;
+};
+
+#include "xFileDataNodeReference.I"
+
+#endif
+  
+
+
+

+ 32 - 10
pandatool/src/xfile/xFileDataObjectArray.cxx

@@ -57,20 +57,42 @@ add_element(XFileDataObject *element) {
 void XFileDataObjectArray::
 void XFileDataObjectArray::
 write_data(ostream &out, int indent_level, const char *separator) const {
 write_data(ostream &out, int indent_level, const char *separator) const {
   if (!_nested_elements.empty()) {
   if (!_nested_elements.empty()) {
-    if (_nested_elements.front()->is_complex_object()) {
-      // If we have a complex nested structure, output one per line.
-      for (size_t i = 0; i < _nested_elements.size() - 1; i++) {
-        _nested_elements[i]->write_data(out, indent_level, ",");
+    bool indented = false;
+    for (size_t i = 0; i < _nested_elements.size() - 1; i++) {
+      XFileDataObject *object = _nested_elements[i];
+      if (object->is_complex_object()) {
+        // If we have a "complex" nested object, output it on its own
+        // line.
+        if (indented) {
+          out << "\n";
+          indented = false;
+        }
+        object->write_data(out, indent_level, ",");
+
+      } else {
+        // Otherwise, output them all on the same line.
+        if (!indented) {
+          indent(out, indent_level);
+          indented = true;
+        }
+        out << *object << ", ";
+      }
+    }
+
+    // The last object is the set is different, because it gets
+    // separator instead of a semicolon, and it always gets a newline.
+    XFileDataObject *object = _nested_elements.back();
+    if (object->is_complex_object()) {
+      if (indented) {
+        out << "\n";
       }
       }
-      _nested_elements.back()->write_data(out, indent_level, separator);
+      object->write_data(out, indent_level, separator);
 
 
     } else {
     } else {
-      // Otherwise, output them all on the same line.
-      indent(out, indent_level);
-      for (size_t i = 0; i < _nested_elements.size() - 1; i++) {
-        out << *_nested_elements[i] << ", ";
+      if (!indented) {
+        indent(out, indent_level);
       }
       }
-      out << *_nested_elements.back() << separator << "\n";
+      out << *object << separator << "\n";
     }
     }
   }
   }
 }
 }

+ 33 - 12
pandatool/src/xfile/xFileDataObjectTemplate.cxx

@@ -31,7 +31,7 @@ TypeHandle XFileDataObjectTemplate::_type_handle;
 XFileDataObjectTemplate::
 XFileDataObjectTemplate::
 XFileDataObjectTemplate(XFile *x_file, const string &name,
 XFileDataObjectTemplate(XFile *x_file, const string &name,
                         XFileTemplate *xtemplate) :
                         XFileTemplate *xtemplate) :
-  XFileNode(x_file, name),
+  XFileDataNode(x_file, name),
   _template(xtemplate)
   _template(xtemplate)
 {
 {
 }
 }
@@ -175,22 +175,43 @@ write_text(ostream &out, int indent_level) const {
 void XFileDataObjectTemplate::
 void XFileDataObjectTemplate::
 write_data(ostream &out, int indent_level, const char *separator) const {
 write_data(ostream &out, int indent_level, const char *separator) const {
   if (!_nested_elements.empty()) {
   if (!_nested_elements.empty()) {
-    if (_nested_elements.front()->is_complex_object()) {
-      // If we have a complex nested structure, output one per line.
-      for (size_t i = 0; i < _nested_elements.size() - 1; i++) {
-        _nested_elements[i]->write_data(out, indent_level, ";");
+    bool indented = false;
+    for (size_t i = 0; i < _nested_elements.size() - 1; i++) {
+      XFileDataObject *object = _nested_elements[i];
+      if (object->is_complex_object()) {
+        // If we have a "complex" nested object, output it on its own
+        // line.
+        if (indented) {
+          out << "\n";
+          indented = false;
+        }
+        object->write_data(out, indent_level, ";");
+
+      } else {
+        // Otherwise, output them all on the same line.
+        if (!indented) {
+          indent(out, indent_level);
+          indented = true;
+        }
+        out << *object << "; ";
+      }
+    }
+
+    // The last object is the set is different, because it gets
+    // separator appended to it, and it always gets a newline.
+    XFileDataObject *object = _nested_elements.back();
+    if (object->is_complex_object()) {
+      if (indented) {
+        out << "\n";
       }
       }
       string combined_separator = string(";") + string(separator);
       string combined_separator = string(";") + string(separator);
-      _nested_elements.back()->write_data(out, indent_level, 
-                                          combined_separator.c_str());
+      object->write_data(out, indent_level, combined_separator.c_str());
 
 
     } else {
     } else {
-      // Otherwise, output them all on the same line.
-      indent(out, indent_level);
-      for (size_t i = 0; i < _nested_elements.size() - 1; i++) {
-        out << *_nested_elements[i] << "; ";
+      if (!indented) {
+        indent(out, indent_level);
       }
       }
-      out << *_nested_elements.back() << ";" << separator << "\n";
+      out << *object << ";" << separator << "\n";
     }
     }
   }
   }
 }
 }

+ 4 - 7
pandatool/src/xfile/xFileDataObjectTemplate.h

@@ -20,8 +20,7 @@
 #define XFILEDATAOBJECTTEMPLATE_H
 #define XFILEDATAOBJECTTEMPLATE_H
 
 
 #include "pandatoolbase.h"
 #include "pandatoolbase.h"
-#include "xFileNode.h"
-#include "xFileDataObject.h"
+#include "xFileDataNode.h"
 #include "xFileTemplate.h"
 #include "xFileTemplate.h"
 #include "xFileParseData.h"
 #include "xFileParseData.h"
 #include "pointerTo.h"
 #include "pointerTo.h"
@@ -36,7 +35,7 @@
 //               obtained by walking through the children of this
 //               obtained by walking through the children of this
 //               object.
 //               object.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class XFileDataObjectTemplate : public XFileNode, public XFileDataObject {
+class XFileDataObjectTemplate : public XFileDataNode {
 public:
 public:
   XFileDataObjectTemplate(XFile *x_file, const string &name,
   XFileDataObjectTemplate(XFile *x_file, const string &name,
                           XFileTemplate *xtemplate);
                           XFileTemplate *xtemplate);
@@ -74,11 +73,9 @@ public:
     return _type_handle;
     return _type_handle;
   }
   }
   static void init_type() {
   static void init_type() {
-    XFileNode::init_type();
-    XFileDataObject::init_type();
+    XFileDataNode::init_type();
     register_type(_type_handle, "XFileDataObjectTemplate",
     register_type(_type_handle, "XFileDataObjectTemplate",
-                  XFileNode::get_class_type(),
-                  XFileDataObject::get_class_type());
+                  XFileDataNode::get_class_type());
   }
   }
   virtual TypeHandle get_type() const {
   virtual TypeHandle get_type() const {
     return get_class_type();
     return get_class_type();

+ 48 - 46
pandatool/src/xfile/xParser.cxx.prebuilt

@@ -51,6 +51,7 @@
 #include "xFileDataDef.h"
 #include "xFileDataDef.h"
 #include "xFileArrayDef.h"
 #include "xFileArrayDef.h"
 #include "xFileDataObjectTemplate.h"
 #include "xFileDataObjectTemplate.h"
+#include "xFileDataNodeReference.h"
 #include "pointerTo.h"
 #include "pointerTo.h"
 #include "dcast.h"
 #include "dcast.h"
 
 
@@ -165,13 +166,13 @@ static const short yyrhs[] =
 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
 static const short yyrline[] =
 static const short yyrline[] =
 {
 {
-       0,   105,   107,   108,   111,   111,   126,   128,   131,   133,
-     136,   141,   144,   146,   149,   151,   152,   155,   163,   167,
-     180,   185,   189,   193,   197,   201,   205,   209,   213,   217,
-     221,   227,   233,   245,   247,   250,   254,   259,   270,   274,
-     279,   289,   304,   308,   313,   316,   320,   325,   328,   332,
-     332,   358,   360,   363,   368,   372,   378,   384,   390,   395,
-     399,   403,   407,   409,   412,   422,   438
+       0,   106,   108,   109,   112,   112,   127,   129,   132,   134,
+     137,   142,   145,   147,   150,   152,   153,   156,   164,   168,
+     181,   186,   190,   194,   198,   202,   206,   210,   214,   218,
+     222,   228,   234,   246,   248,   251,   255,   260,   271,   275,
+     280,   290,   305,   309,   314,   317,   321,   326,   329,   333,
+     333,   359,   361,   364,   370,   374,   380,   386,   392,   397,
+     401,   405,   409,   411,   414,   424,   440
 };
 };
 #endif
 #endif
 
 
@@ -1015,7 +1016,7 @@ yyreduce:
   switch (yyn) {
   switch (yyn) {
 
 
 case 4:
 case 4:
-#line 113 "xParser.yxx"
+#line 114 "xParser.yxx"
 {
 {
   yyval.u.node = current_node;
   yyval.u.node = current_node;
   XFileTemplate *templ = new XFileTemplate(x_file, yyvsp[-2].str, yyvsp[0].guid);
   XFileTemplate *templ = new XFileTemplate(x_file, yyvsp[-2].str, yyvsp[0].guid);
@@ -1024,27 +1025,27 @@ case 4:
 }
 }
     break;
     break;
 case 5:
 case 5:
-#line 120 "xParser.yxx"
+#line 121 "xParser.yxx"
 {
 {
   yyval.u.node = current_node;
   yyval.u.node = current_node;
   current_node = yyvsp[-2].u.node;
   current_node = yyvsp[-2].u.node;
 }
 }
     break;
     break;
 case 10:
 case 10:
-#line 138 "xParser.yxx"
+#line 139 "xParser.yxx"
 {
 {
   DCAST(XFileTemplate, current_node)->set_open(true);
   DCAST(XFileTemplate, current_node)->set_open(true);
 }
 }
     break;
     break;
 case 17:
 case 17:
-#line 157 "xParser.yxx"
+#line 158 "xParser.yxx"
 {
 {
   current_data_def = new XFileDataDef(x_file, yyvsp[-1].str, yyvsp[-2].u.primitive_type);
   current_data_def = new XFileDataDef(x_file, yyvsp[-1].str, yyvsp[-2].u.primitive_type);
   current_node->add_child(current_data_def);
   current_node->add_child(current_data_def);
 }
 }
     break;
     break;
 case 19:
 case 19:
-#line 169 "xParser.yxx"
+#line 170 "xParser.yxx"
 {
 {
   XFileTemplate *xtemplate = x_file->find_template(yyvsp[-2].str);
   XFileTemplate *xtemplate = x_file->find_template(yyvsp[-2].str);
   if (xtemplate == (XFileTemplate *)NULL) {
   if (xtemplate == (XFileTemplate *)NULL) {
@@ -1056,80 +1057,80 @@ case 19:
 }
 }
     break;
     break;
 case 20:
 case 20:
-#line 182 "xParser.yxx"
+#line 183 "xParser.yxx"
 {
 {
   yyval.u.primitive_type = XFileDataDef::T_word;
   yyval.u.primitive_type = XFileDataDef::T_word;
 }
 }
     break;
     break;
 case 21:
 case 21:
-#line 186 "xParser.yxx"
+#line 187 "xParser.yxx"
 {
 {
   yyval.u.primitive_type = XFileDataDef::T_dword;
   yyval.u.primitive_type = XFileDataDef::T_dword;
 }
 }
     break;
     break;
 case 22:
 case 22:
-#line 190 "xParser.yxx"
+#line 191 "xParser.yxx"
 {
 {
   yyval.u.primitive_type = XFileDataDef::T_float;
   yyval.u.primitive_type = XFileDataDef::T_float;
 }
 }
     break;
     break;
 case 23:
 case 23:
-#line 194 "xParser.yxx"
+#line 195 "xParser.yxx"
 {
 {
   yyval.u.primitive_type = XFileDataDef::T_double;
   yyval.u.primitive_type = XFileDataDef::T_double;
 }
 }
     break;
     break;
 case 24:
 case 24:
-#line 198 "xParser.yxx"
+#line 199 "xParser.yxx"
 {
 {
   yyval.u.primitive_type = XFileDataDef::T_char;
   yyval.u.primitive_type = XFileDataDef::T_char;
 }
 }
     break;
     break;
 case 25:
 case 25:
-#line 202 "xParser.yxx"
+#line 203 "xParser.yxx"
 {
 {
   yyval.u.primitive_type = XFileDataDef::T_uchar;
   yyval.u.primitive_type = XFileDataDef::T_uchar;
 }
 }
     break;
     break;
 case 26:
 case 26:
-#line 206 "xParser.yxx"
+#line 207 "xParser.yxx"
 {
 {
   yyval.u.primitive_type = XFileDataDef::T_sword;
   yyval.u.primitive_type = XFileDataDef::T_sword;
 }
 }
     break;
     break;
 case 27:
 case 27:
-#line 210 "xParser.yxx"
+#line 211 "xParser.yxx"
 {
 {
   yyval.u.primitive_type = XFileDataDef::T_sdword;
   yyval.u.primitive_type = XFileDataDef::T_sdword;
 }
 }
     break;
     break;
 case 28:
 case 28:
-#line 214 "xParser.yxx"
+#line 215 "xParser.yxx"
 {
 {
   yyval.u.primitive_type = XFileDataDef::T_string;
   yyval.u.primitive_type = XFileDataDef::T_string;
 }
 }
     break;
     break;
 case 29:
 case 29:
-#line 218 "xParser.yxx"
+#line 219 "xParser.yxx"
 {
 {
   yyval.u.primitive_type = XFileDataDef::T_unicode;
   yyval.u.primitive_type = XFileDataDef::T_unicode;
 }
 }
     break;
     break;
 case 30:
 case 30:
-#line 222 "xParser.yxx"
+#line 223 "xParser.yxx"
 {
 {
   yyval.u.primitive_type = XFileDataDef::T_cstring;
   yyval.u.primitive_type = XFileDataDef::T_cstring;
 }
 }
     break;
     break;
 case 31:
 case 31:
-#line 229 "xParser.yxx"
+#line 230 "xParser.yxx"
 {
 {
   current_data_def = new XFileDataDef(x_file, yyvsp[0].str, yyvsp[-1].u.primitive_type);
   current_data_def = new XFileDataDef(x_file, yyvsp[0].str, yyvsp[-1].u.primitive_type);
   current_node->add_child(current_data_def);
   current_node->add_child(current_data_def);
 }
 }
     break;
     break;
 case 32:
 case 32:
-#line 234 "xParser.yxx"
+#line 235 "xParser.yxx"
 {
 {
   XFileTemplate *xtemplate = x_file->find_template(yyvsp[-1].str);
   XFileTemplate *xtemplate = x_file->find_template(yyvsp[-1].str);
   if (xtemplate == (XFileTemplate *)NULL) {
   if (xtemplate == (XFileTemplate *)NULL) {
@@ -1141,13 +1142,13 @@ case 32:
 }
 }
     break;
     break;
 case 36:
 case 36:
-#line 256 "xParser.yxx"
+#line 257 "xParser.yxx"
 {
 {
   current_data_def->add_array_def(XFileArrayDef(yyvsp[0].u.number));
   current_data_def->add_array_def(XFileArrayDef(yyvsp[0].u.number));
 }
 }
     break;
     break;
 case 37:
 case 37:
-#line 260 "xParser.yxx"
+#line 261 "xParser.yxx"
 {
 {
   XFileNode *data_def = current_node->find_child(yyvsp[0].str);
   XFileNode *data_def = current_node->find_child(yyvsp[0].str);
   if (data_def == (XFileNode *)NULL) {
   if (data_def == (XFileNode *)NULL) {
@@ -1158,17 +1159,17 @@ case 37:
 }
 }
     break;
     break;
 case 38:
 case 38:
-#line 272 "xParser.yxx"
+#line 273 "xParser.yxx"
 {
 {
 }
 }
     break;
     break;
 case 39:
 case 39:
-#line 275 "xParser.yxx"
+#line 276 "xParser.yxx"
 {
 {
 }
 }
     break;
     break;
 case 40:
 case 40:
-#line 281 "xParser.yxx"
+#line 282 "xParser.yxx"
 {
 {
   XFileTemplate *xtemplate = x_file->find_template(yyvsp[0].str);
   XFileTemplate *xtemplate = x_file->find_template(yyvsp[0].str);
   if (xtemplate == (XFileTemplate *)NULL) {
   if (xtemplate == (XFileTemplate *)NULL) {
@@ -1179,7 +1180,7 @@ case 40:
 }
 }
     break;
     break;
 case 41:
 case 41:
-#line 290 "xParser.yxx"
+#line 291 "xParser.yxx"
 {
 {
   XFileTemplate *xtemplate = x_file->find_template(yyvsp[0].guid);
   XFileTemplate *xtemplate = x_file->find_template(yyvsp[0].guid);
   if (xtemplate == (XFileTemplate *)NULL) {
   if (xtemplate == (XFileTemplate *)NULL) {
@@ -1194,19 +1195,19 @@ case 41:
 }
 }
     break;
     break;
 case 43:
 case 43:
-#line 310 "xParser.yxx"
+#line 311 "xParser.yxx"
 {
 {
   yyval.str = string();
   yyval.str = string();
 }
 }
     break;
     break;
 case 46:
 case 46:
-#line 322 "xParser.yxx"
+#line 323 "xParser.yxx"
 {
 {
   yyval.guid = WindowsGuid();
   yyval.guid = WindowsGuid();
 }
 }
     break;
     break;
 case 49:
 case 49:
-#line 334 "xParser.yxx"
+#line 335 "xParser.yxx"
 {
 {
   XFileTemplate *xtemplate = x_file->find_template(yyvsp[-2].str);
   XFileTemplate *xtemplate = x_file->find_template(yyvsp[-2].str);
   yyval.u.node = current_node;
   yyval.u.node = current_node;
@@ -1222,7 +1223,7 @@ case 49:
 }
 }
     break;
     break;
 case 50:
 case 50:
-#line 348 "xParser.yxx"
+#line 349 "xParser.yxx"
 {
 {
   XFileDataObjectTemplate *current_template = 
   XFileDataObjectTemplate *current_template = 
     DCAST(XFileDataObjectTemplate, current_node);
     DCAST(XFileDataObjectTemplate, current_node);
@@ -1233,19 +1234,20 @@ case 50:
 }
 }
     break;
     break;
 case 53:
 case 53:
-#line 365 "xParser.yxx"
+#line 366 "xParser.yxx"
 {
 {
   // nested references should be added as children too.
   // nested references should be added as children too.
+  current_node->add_child(yyvsp[-1].u.node);
 }
 }
     break;
     break;
 case 54:
 case 54:
-#line 369 "xParser.yxx"
+#line 371 "xParser.yxx"
 {
 {
   // nested objects are just quietly added as children.
   // nested objects are just quietly added as children.
 }
 }
     break;
     break;
 case 55:
 case 55:
-#line 373 "xParser.yxx"
+#line 375 "xParser.yxx"
 {
 {
   XFileDataObjectTemplate *current_template = 
   XFileDataObjectTemplate *current_template = 
     DCAST(XFileDataObjectTemplate, current_node);
     DCAST(XFileDataObjectTemplate, current_node);
@@ -1253,7 +1255,7 @@ case 55:
 }
 }
     break;
     break;
 case 56:
 case 56:
-#line 379 "xParser.yxx"
+#line 381 "xParser.yxx"
 {
 {
   XFileDataObjectTemplate *current_template = 
   XFileDataObjectTemplate *current_template = 
     DCAST(XFileDataObjectTemplate, current_node);
     DCAST(XFileDataObjectTemplate, current_node);
@@ -1261,7 +1263,7 @@ case 56:
 }
 }
     break;
     break;
 case 57:
 case 57:
-#line 385 "xParser.yxx"
+#line 387 "xParser.yxx"
 {
 {
   XFileDataObjectTemplate *current_template = 
   XFileDataObjectTemplate *current_template = 
     DCAST(XFileDataObjectTemplate, current_node);
     DCAST(XFileDataObjectTemplate, current_node);
@@ -1269,23 +1271,23 @@ case 57:
 }
 }
     break;
     break;
 case 58:
 case 58:
-#line 391 "xParser.yxx"
+#line 393 "xParser.yxx"
 {
 {
 }
 }
     break;
     break;
 case 64:
 case 64:
-#line 414 "xParser.yxx"
+#line 416 "xParser.yxx"
 {
 {
   XFileDataObjectTemplate *data_object = x_file->find_data_object(yyvsp[0].str);
   XFileDataObjectTemplate *data_object = x_file->find_data_object(yyvsp[0].str);
   if (data_object == (XFileDataObject *)NULL) {
   if (data_object == (XFileDataObject *)NULL) {
     yyerror("Unknown data_object: " + yyvsp[0].str);
     yyerror("Unknown data_object: " + yyvsp[0].str);
   }
   }
 
 
-  yyval.u.node = data_object;
+  yyval.u.node = new XFileDataNodeReference(data_object);
 }
 }
     break;
     break;
 case 65:
 case 65:
-#line 423 "xParser.yxx"
+#line 425 "xParser.yxx"
 {
 {
   XFileDataObjectTemplate *data_object = x_file->find_data_object(yyvsp[0].guid);
   XFileDataObjectTemplate *data_object = x_file->find_data_object(yyvsp[0].guid);
   if (data_object == (XFileDataObject *)NULL) {
   if (data_object == (XFileDataObject *)NULL) {
@@ -1297,7 +1299,7 @@ case 65:
     }
     }
   }
   }
 
 
-  yyval.u.node = data_object;
+  yyval.u.node = new XFileDataNodeReference(data_object);
 }
 }
     break;
     break;
 }
 }
@@ -1533,4 +1535,4 @@ yyreturn:
 #endif
 #endif
   return yyresult;
   return yyresult;
 }
 }
-#line 440 "xParser.yxx"
+#line 442 "xParser.yxx"

+ 4 - 2
pandatool/src/xfile/xParser.yxx

@@ -17,6 +17,7 @@
 #include "xFileDataDef.h"
 #include "xFileDataDef.h"
 #include "xFileArrayDef.h"
 #include "xFileArrayDef.h"
 #include "xFileDataObjectTemplate.h"
 #include "xFileDataObjectTemplate.h"
+#include "xFileDataNodeReference.h"
 #include "pointerTo.h"
 #include "pointerTo.h"
 #include "dcast.h"
 #include "dcast.h"
 
 
@@ -364,6 +365,7 @@ data_part:
         TOKEN_OBRACE data_reference TOKEN_CBRACE
         TOKEN_OBRACE data_reference TOKEN_CBRACE
 {
 {
   // nested references should be added as children too.
   // nested references should be added as children too.
+  current_node->add_child($2);
 }
 }
 	| object
 	| object
 {
 {
@@ -417,7 +419,7 @@ data_reference:
     yyerror("Unknown data_object: " + $1);
     yyerror("Unknown data_object: " + $1);
   }
   }
 
 
-  $$ = data_object;
+  $$ = new XFileDataNodeReference(data_object);
 }
 }
 	| name class_id
 	| name class_id
 {
 {
@@ -431,7 +433,7 @@ data_reference:
     }
     }
   }
   }
 
 
-  $$ = data_object;
+  $$ = new XFileDataNodeReference(data_object);
 }
 }
         ;
         ;