mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
structs
This commit is contained in:
parent
672f62cb87
commit
e9cbc1a2ae
@ -15,24 +15,29 @@
|
||||
#define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx
|
||||
|
||||
#define SOURCES \
|
||||
dcAtomicField.h dcClass.h dcField.h dcFile.h dcLexer.lxx \
|
||||
dcAtomicField.h dcClass.h \
|
||||
dcDeclaration.h \
|
||||
dcField.h dcFile.h dcLexer.lxx \
|
||||
dcLexerDefs.h dcMolecularField.h dcParser.yxx dcParserDefs.h \
|
||||
dcSubatomicType.h \
|
||||
dcPackData.h dcPackData.I \
|
||||
dcPacker.h dcPacker.I \
|
||||
dcPackerInterface.h dcPackerInterface.I \
|
||||
dcParameter.h dcArrayParameter.h dcSimpleParameter.h \
|
||||
dcParameter.h dcClassParameter.h dcArrayParameter.h dcSimpleParameter.h \
|
||||
dcTypedef.h \
|
||||
dcbase.h dcindent.h hashGenerator.h \
|
||||
primeNumberGenerator.h
|
||||
|
||||
#define INCLUDED_SOURCES \
|
||||
dcAtomicField.cxx dcClass.cxx dcField.cxx dcFile.cxx \
|
||||
dcAtomicField.cxx dcClass.cxx \
|
||||
dcDeclaration.cxx \
|
||||
dcField.cxx dcFile.cxx \
|
||||
dcMolecularField.cxx dcSubatomicType.cxx \
|
||||
dcPackData.cxx \
|
||||
dcPacker.cxx \
|
||||
dcPackerInterface.cxx \
|
||||
dcParameter.cxx dcArrayParameter.cxx dcSimpleParameter.cxx \
|
||||
dcParameter.cxx dcClassParameter.cxx \
|
||||
dcArrayParameter.cxx dcSimpleParameter.cxx \
|
||||
dcTypedef.cxx \
|
||||
dcindent.cxx \
|
||||
hashGenerator.cxx primeNumberGenerator.cxx
|
||||
|
@ -29,7 +29,8 @@ DCArrayParameter(DCParameter *element_type, int array_size) :
|
||||
_element_type(element_type),
|
||||
_array_size(array_size)
|
||||
{
|
||||
set_name(element_type->get_name());
|
||||
set_name(_element_type->get_name());
|
||||
_element_type->set_name(string());
|
||||
|
||||
if (_array_size >= 0 && _element_type->has_fixed_byte_size()) {
|
||||
_has_fixed_byte_size = true;
|
||||
@ -57,7 +58,7 @@ DCArrayParameter(const DCArrayParameter ©) :
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCArrayParameter::Destructor
|
||||
// Access: Public
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DCArrayParameter::
|
||||
|
@ -33,7 +33,7 @@ class EXPCL_DIRECT DCArrayParameter : public DCParameter {
|
||||
public:
|
||||
DCArrayParameter(DCParameter *element_type, int array_size = -1);
|
||||
DCArrayParameter(const DCArrayParameter ©);
|
||||
~DCArrayParameter();
|
||||
virtual ~DCArrayParameter();
|
||||
|
||||
PUBLISHED:
|
||||
virtual DCArrayParameter *as_array_parameter();
|
||||
|
@ -17,6 +17,7 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dcClass.h"
|
||||
#include "dcParameter.h"
|
||||
#include "hashGenerator.h"
|
||||
#include "dcindent.h"
|
||||
#include "dcmsgtypes.h"
|
||||
@ -151,6 +152,109 @@ get_inherited_field(int n) const {
|
||||
return get_field(n);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClass::get_num_parameters
|
||||
// Access: Published
|
||||
// Description: Returns the number of parameters defined directly in
|
||||
// this class, ignoring inheritance.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int DCClass::
|
||||
get_num_parameters() const {
|
||||
return _parameters.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClass::get_parameter
|
||||
// Access: Published
|
||||
// Description: Returns the nth parameter in the class. This is not
|
||||
// necessarily the parameter with index n; this is the
|
||||
// nth parameter defined in the class directly, ignoring
|
||||
// inheritance.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DCParameter *DCClass::
|
||||
get_parameter(int n) const {
|
||||
nassertr_always(n >= 0 && n < (int)_parameters.size(), NULL);
|
||||
return _parameters[n];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClass::get_parameter_by_name
|
||||
// Access: Published
|
||||
// Description: Returns a pointer to the DCParameter that shares the
|
||||
// indicated name. If the named parameter is not found
|
||||
// in the current class, the parent classes will be
|
||||
// searched, so the value returned may not actually be a
|
||||
// parameter within this class. Returns NULL if there
|
||||
// is no such parameter defined.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DCParameter *DCClass::
|
||||
get_parameter_by_name(const string &name) const {
|
||||
ParametersByName::const_iterator ni;
|
||||
ni = _parameters_by_name.find(name);
|
||||
if (ni != _parameters_by_name.end()) {
|
||||
return (*ni).second;
|
||||
}
|
||||
|
||||
// We didn't have such a parameter, so check our parents.
|
||||
Parents::const_iterator pi;
|
||||
for (pi = _parents.begin(); pi != _parents.end(); ++pi) {
|
||||
DCParameter *result = (*pi)->get_parameter_by_name(name);
|
||||
if (result != (DCParameter *)NULL) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// Nobody knew what this parameter is.
|
||||
return (DCParameter *)NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClass::get_num_inherited_parameters
|
||||
// Access: Published
|
||||
// Description: Returns the total number of parameters defined in
|
||||
// this class and all ancestor classes.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int DCClass::
|
||||
get_num_inherited_parameters() const {
|
||||
if (!_parents.empty()) {
|
||||
// This won't work for multiple dclass inheritance.
|
||||
return _parents.front()->get_num_inherited_parameters() + get_num_parameters();
|
||||
}
|
||||
return get_num_parameters();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClass::get_inherited_parameter
|
||||
// Access: Published
|
||||
// Description: Returns the nth parameter parameter in the class and
|
||||
// all of its ancestors.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DCParameter *DCClass::
|
||||
get_inherited_parameter(int n) const {
|
||||
if (!_parents.empty()) {
|
||||
// This won't work for multiple dclass inheritance.
|
||||
int psize = _parents.front()->get_num_inherited_parameters();
|
||||
if (n < psize) {
|
||||
return _parents.front()->get_inherited_parameter(n);
|
||||
}
|
||||
|
||||
n -= psize;
|
||||
}
|
||||
return get_parameter(n);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClass::is_struct
|
||||
// Access: Public
|
||||
// Description: Returns true if the class has been identified with
|
||||
// the "struct" keyword in the dc file, false if it was
|
||||
// declared with "dclass".
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool DCClass::
|
||||
is_struct() const {
|
||||
return _is_struct;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClass::is_bogus_class
|
||||
// Access: Public
|
||||
@ -523,8 +627,9 @@ ai_format_generate(PyObject *distobj, int do_id,
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DCClass::
|
||||
DCClass(const string &name, bool bogus_class) :
|
||||
DCClass(const string &name, bool is_struct, bool bogus_class) :
|
||||
DCPackerInterface(name),
|
||||
_is_struct(is_struct),
|
||||
_bogus_class(bogus_class)
|
||||
{
|
||||
#ifdef HAVE_PYTHON
|
||||
@ -551,14 +656,18 @@ DCClass::
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClass::write
|
||||
// Access: Public
|
||||
// Access: Public, Virtual
|
||||
// Description: Generates a parseable description of the object to
|
||||
// the indicated output stream.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DCClass::
|
||||
write(ostream &out, bool brief, int indent_level) const {
|
||||
indent(out, indent_level)
|
||||
<< "dclass " << _name;
|
||||
indent(out, indent_level);
|
||||
if (_is_struct) {
|
||||
out << "struct " << _name;
|
||||
} else {
|
||||
out << "dclass " << _name;
|
||||
}
|
||||
|
||||
if (!_parents.empty()) {
|
||||
Parents::const_iterator pi = _parents.begin();
|
||||
@ -581,6 +690,15 @@ write(ostream &out, bool brief, int indent_level) const {
|
||||
(*fi)->write(out, brief, indent_level + 2);
|
||||
}
|
||||
|
||||
if (!_fields.empty() && !_parameters.empty()) {
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
Parameters::const_iterator pi;
|
||||
for (pi = _parameters.begin(); pi != _parameters.end(); ++pi) {
|
||||
(*pi)->write(out, brief, indent_level + 2);
|
||||
}
|
||||
|
||||
indent(out, indent_level) << "};\n";
|
||||
}
|
||||
|
||||
@ -605,6 +723,14 @@ generate_hash(HashGenerator &hashgen) const {
|
||||
for (fi = _fields.begin(); fi != _fields.end(); ++fi) {
|
||||
(*fi)->generate_hash(hashgen);
|
||||
}
|
||||
|
||||
if (!_parameters.empty()) {
|
||||
hashgen.add_int(_parameters.size());
|
||||
Parameters::const_iterator pi;
|
||||
for (pi = _parameters.begin(); pi != _parameters.end(); ++pi) {
|
||||
(*pi)->generate_hash(hashgen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -619,17 +745,43 @@ generate_hash(HashGenerator &hashgen) const {
|
||||
bool DCClass::
|
||||
add_field(DCField *field) {
|
||||
bool inserted = _fields_by_name.insert
|
||||
(FieldsByName::value_type(field->_name, field)).second;
|
||||
(FieldsByName::value_type(field->get_name(), field)).second;
|
||||
|
||||
if (!inserted) {
|
||||
return false;
|
||||
}
|
||||
|
||||
field->_number = get_num_inherited_fields();
|
||||
field->set_number(get_num_inherited_fields());
|
||||
_fields.push_back(field);
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClass::add_parameter
|
||||
// Access: Public
|
||||
// Description: Adds the newly-allocated parameter to the class. The
|
||||
// class becomes the owner of the pointer and will
|
||||
// delete it when it destructs.
|
||||
//
|
||||
// The parameters are only useful for classes that will
|
||||
// themselves be used as parameters; DistributedObjects
|
||||
// in their own right cannot use free parameters.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool DCClass::
|
||||
add_parameter(DCParameter *parameter) {
|
||||
if (!parameter->get_name().empty()) {
|
||||
bool inserted = _parameters_by_name.insert
|
||||
(ParametersByName::value_type(parameter->get_name(), parameter)).second;
|
||||
|
||||
if (!inserted) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_parameters.push_back(parameter);
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClass::add_parent
|
||||
// Access: Public
|
||||
|
@ -22,15 +22,17 @@
|
||||
#include "dcbase.h"
|
||||
#include "dcField.h"
|
||||
#include "dcPackerInterface.h"
|
||||
#include "dcDeclaration.h"
|
||||
|
||||
class HashGenerator;
|
||||
class DCParameter;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : DCClass
|
||||
// Description : Defines a particular DistributedClass as read from an
|
||||
// input .dc file.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_DIRECT DCClass : public DCPackerInterface {
|
||||
class EXPCL_DIRECT DCClass : public DCPackerInterface, public DCDeclaration {
|
||||
PUBLISHED:
|
||||
int get_number() const;
|
||||
|
||||
@ -44,6 +46,14 @@ PUBLISHED:
|
||||
int get_num_inherited_fields() const;
|
||||
DCField *get_inherited_field(int n) const;
|
||||
|
||||
int get_num_parameters() const;
|
||||
DCParameter *get_parameter(int n) const;
|
||||
DCParameter *get_parameter_by_name(const string &name) const;
|
||||
|
||||
int get_num_inherited_parameters() const;
|
||||
DCParameter *get_inherited_parameter(int n) const;
|
||||
|
||||
bool is_struct() const;
|
||||
bool is_bogus_class() const;
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
@ -72,17 +82,19 @@ PUBLISHED:
|
||||
#endif
|
||||
|
||||
public:
|
||||
DCClass(const string &name, bool bogus_class = false);
|
||||
DCClass(const string &name, bool is_struct, bool bogus_class);
|
||||
~DCClass();
|
||||
|
||||
void write(ostream &out, bool brief, int indent_level) const;
|
||||
virtual void write(ostream &out, bool brief, int indent_level) const;
|
||||
void generate_hash(HashGenerator &hash) const;
|
||||
|
||||
bool add_field(DCField *field);
|
||||
bool add_parameter(DCParameter *parameter);
|
||||
void add_parent(DCClass *parent);
|
||||
void set_number(int number);
|
||||
|
||||
private:
|
||||
bool _is_struct;
|
||||
bool _bogus_class;
|
||||
int _number;
|
||||
|
||||
@ -95,6 +107,12 @@ private:
|
||||
typedef pmap<string, DCField *> FieldsByName;
|
||||
FieldsByName _fields_by_name;
|
||||
|
||||
typedef pvector<DCParameter *> Parameters;
|
||||
Parameters _parameters;
|
||||
|
||||
typedef pmap<string, DCParameter *> ParametersByName;
|
||||
ParametersByName _parameters_by_name;
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
PyObject *_class_def;
|
||||
#endif
|
||||
|
142
direct/src/dcparser/dcClassParameter.cxx
Normal file
142
direct/src/dcparser/dcClassParameter.cxx
Normal file
@ -0,0 +1,142 @@
|
||||
// Filename: dcClassParameter.cxx
|
||||
// Created by: drose (18Jun04)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dcClassParameter.h"
|
||||
#include "dcClass.h"
|
||||
#include "hashGenerator.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClassParameter::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DCClassParameter::
|
||||
DCClassParameter(DCClass *dclass) :
|
||||
_dclass(dclass)
|
||||
{
|
||||
set_name(dclass->get_name());
|
||||
|
||||
_has_nested_fields = true;
|
||||
_num_fields = _dclass->get_num_inherited_fields();
|
||||
_num_nested_fields = _num_fields + _dclass->get_num_inherited_parameters();
|
||||
_pack_type = PT_class;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClassParameter::Copy Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DCClassParameter::
|
||||
DCClassParameter(const DCClassParameter ©) :
|
||||
DCParameter(copy),
|
||||
_dclass(copy._dclass),
|
||||
_num_fields(copy._num_fields)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClassParameter::as_class_parameter
|
||||
// Access: Published, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DCClassParameter *DCClassParameter::
|
||||
as_class_parameter() {
|
||||
return this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClassParameter::make_copy
|
||||
// Access: Published, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DCParameter *DCClassParameter::
|
||||
make_copy() const {
|
||||
return new DCClassParameter(*this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClassParameter::is_valid
|
||||
// Access: Published, Virtual
|
||||
// Description: Returns false if the type is an invalid type
|
||||
// (e.g. declared from an undefined typedef), true if
|
||||
// it is valid.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool DCClassParameter::
|
||||
is_valid() const {
|
||||
return !_dclass->is_bogus_class();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClassParameter::get_class
|
||||
// Access: Published
|
||||
// Description: Returns the class object this parameter represents.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DCClass *DCClassParameter::
|
||||
get_class() const {
|
||||
return _dclass;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClassParameter::get_nested_field
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns the DCPackerInterface object that represents
|
||||
// the nth nested field. This may return NULL if there
|
||||
// is no such field (but it shouldn't do this if n is in
|
||||
// the range 0 <= n < get_num_nested_fields()).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DCPackerInterface *DCClassParameter::
|
||||
get_nested_field(int n) const {
|
||||
if (n < _num_fields) {
|
||||
return _dclass->get_inherited_field(n);
|
||||
} else {
|
||||
return _dclass->get_inherited_parameter(n - _num_fields);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClassParameter::output_instance
|
||||
// Access: Public, Virtual
|
||||
// Description: Formats the parameter in the C++-like dc syntax as a
|
||||
// typename and identifier.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DCClassParameter::
|
||||
output_instance(ostream &out, const string &prename, const string &name,
|
||||
const string &postname) const {
|
||||
if (get_typedef() != (DCTypedef *)NULL) {
|
||||
output_typedef_name(out, prename, name, postname);
|
||||
|
||||
} else {
|
||||
out << get_name();
|
||||
if (!prename.empty() || !name.empty() || !postname.empty()) {
|
||||
out << " " << prename << name << postname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCClassParameter::generate_hash
|
||||
// Access: Public, Virtual
|
||||
// Description: Accumulates the properties of this type into the
|
||||
// hash.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DCClassParameter::
|
||||
generate_hash(HashGenerator &hashgen) const {
|
||||
DCParameter::generate_hash(hashgen);
|
||||
_dclass->generate_hash(hashgen);
|
||||
}
|
57
direct/src/dcparser/dcClassParameter.h
Normal file
57
direct/src/dcparser/dcClassParameter.h
Normal file
@ -0,0 +1,57 @@
|
||||
// Filename: dcClassParameter.h
|
||||
// Created by: drose (18Jun04)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef DCCLASSPARAMETER_H
|
||||
#define DCCLASSPARAMETER_H
|
||||
|
||||
#include "dcbase.h"
|
||||
#include "dcParameter.h"
|
||||
|
||||
class DCClass;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : DCClassParameter
|
||||
// Description : This represents a class (or struct) object used as a
|
||||
// parameter itself. This means that all the fields of
|
||||
// the class get packed into the message.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_DIRECT DCClassParameter : public DCParameter {
|
||||
public:
|
||||
DCClassParameter(DCClass *dclass);
|
||||
DCClassParameter(const DCClassParameter ©);
|
||||
|
||||
PUBLISHED:
|
||||
virtual DCClassParameter *as_class_parameter();
|
||||
virtual DCParameter *make_copy() const;
|
||||
virtual bool is_valid() const;
|
||||
|
||||
DCClass *get_class() const;
|
||||
|
||||
public:
|
||||
virtual DCPackerInterface *get_nested_field(int n) const;
|
||||
|
||||
virtual void output_instance(ostream &out, const string &prename,
|
||||
const string &name, const string &postname) const;
|
||||
virtual void generate_hash(HashGenerator &hash) const;
|
||||
|
||||
private:
|
||||
DCClass *_dclass;
|
||||
int _num_fields;
|
||||
};
|
||||
|
||||
#endif
|
29
direct/src/dcparser/dcDeclaration.cxx
Normal file
29
direct/src/dcparser/dcDeclaration.cxx
Normal file
@ -0,0 +1,29 @@
|
||||
// Filename: dcDeclaration.cxx
|
||||
// Created by: drose (18Jun04)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dcDeclaration.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCDeclaration::Destructor
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DCDeclaration::
|
||||
~DCDeclaration() {
|
||||
}
|
41
direct/src/dcparser/dcDeclaration.h
Normal file
41
direct/src/dcparser/dcDeclaration.h
Normal file
@ -0,0 +1,41 @@
|
||||
// Filename: dcDeclaration.h
|
||||
// Created by: drose (18Jun04)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef DCDECLARATION_H
|
||||
#define DCDECLARATION_H
|
||||
|
||||
#include "dcbase.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : DCDeclaration
|
||||
// Description : This is a common interface for a declaration in a DC
|
||||
// file. Currently, this is either a class or a typedef
|
||||
// declaration (import declarations are still collected
|
||||
// together at the top, and don't inherit from this
|
||||
// object). Its only purpose is so that classes and
|
||||
// typedefs can be stored in one list together so they
|
||||
// can be ordered correctly on output.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_DIRECT DCDeclaration {
|
||||
public:
|
||||
virtual ~DCDeclaration();
|
||||
virtual void write(ostream &out, bool brief, int indent_level) const=0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -282,3 +282,16 @@ generate_hash(HashGenerator &hashgen) const {
|
||||
// redundant. However, the field name is significant.
|
||||
hashgen.add_string(_name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCField::set_number
|
||||
// Access: Public
|
||||
// Description: Assigns the unique number to this field. This is
|
||||
// normally called only by the DCClass interface as the
|
||||
// field is added.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DCField::
|
||||
set_number(int number) {
|
||||
_number = number;
|
||||
}
|
||||
|
||||
|
@ -68,10 +68,10 @@ public:
|
||||
virtual void write(ostream &out, bool brief, int indent_level) const=0;
|
||||
virtual void generate_hash(HashGenerator &hash) const;
|
||||
|
||||
void set_number(int number);
|
||||
|
||||
protected:
|
||||
int _number;
|
||||
|
||||
friend class DCClass;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -234,21 +234,9 @@ write(ostream &out, bool brief) const {
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
if (!_typedefs.empty()) {
|
||||
Typedefs::const_iterator ti;
|
||||
for (ti = _typedefs.begin(); ti != _typedefs.end(); ++ti) {
|
||||
if (!(*ti)->is_bogus_typedef()) {
|
||||
(*ti)->write(out, brief, 0);
|
||||
}
|
||||
}
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
Classes::const_iterator ci;
|
||||
for (ci = _classes.begin(); ci != _classes.end(); ++ci) {
|
||||
if (!(*ci)->is_bogus_class()) {
|
||||
(*ci)->write(out, brief, 0);
|
||||
}
|
||||
Declarations::const_iterator di;
|
||||
for (di = _declarations.begin(); di != _declarations.end(); ++di) {
|
||||
(*di)->write(out, brief, 0);
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
@ -452,6 +440,10 @@ add_class(DCClass *dclass) {
|
||||
_all_objects_valid = false;
|
||||
}
|
||||
|
||||
if (!dclass->is_bogus_class()) {
|
||||
_declarations.push_back(dclass);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -510,5 +502,9 @@ add_typedef(DCTypedef *dtypedef) {
|
||||
_all_objects_valid = false;
|
||||
}
|
||||
|
||||
if (!dtypedef->is_bogus_typedef() && !dtypedef->is_implicit_typedef()) {
|
||||
_declarations.push_back(dtypedef);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
class HashGenerator;
|
||||
class DCTypedef;
|
||||
class DCDeclaration;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : DCFile
|
||||
@ -94,6 +95,9 @@ private:
|
||||
typedef pmap<string, DCTypedef *> TypedefsByName;
|
||||
TypedefsByName _typedefs_by_name;
|
||||
|
||||
typedef pvector<DCDeclaration *> Declarations;
|
||||
Declarations _declarations;
|
||||
|
||||
bool _all_objects_valid;
|
||||
};
|
||||
|
||||
|
@ -302,27 +302,27 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
|
||||
|
||||
#define YY_NUM_RULES 45
|
||||
#define YY_END_OF_BUFFER 46
|
||||
static yyconst short int yy_accept[180] =
|
||||
static yyconst short int yy_accept[179] =
|
||||
{ 0,
|
||||
0, 0, 46, 44, 2, 1, 41, 44, 44, 44,
|
||||
38, 38, 42, 43, 43, 43, 43, 43, 43, 43,
|
||||
43, 43, 43, 43, 43, 43, 43, 1, 0, 38,
|
||||
40, 4, 3, 40, 39, 43, 43, 43, 43, 43,
|
||||
33, 43, 43, 43, 43, 43, 43, 43, 43, 43,
|
||||
43, 43, 43, 43, 0, 3, 39, 43, 43, 43,
|
||||
43, 43, 43, 43, 43, 43, 43, 43, 43, 31,
|
||||
32, 43, 43, 43, 43, 0, 40, 43, 19, 43,
|
||||
43, 43, 43, 43, 6, 43, 43, 43, 43, 9,
|
||||
28, 43, 43, 43, 43, 43, 43, 43, 43, 43,
|
||||
43, 43, 43, 43, 43, 43, 1, 0, 38, 40,
|
||||
4, 3, 40, 39, 43, 43, 43, 43, 43, 33,
|
||||
43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
|
||||
43, 43, 0, 3, 39, 43, 43, 43, 43, 43,
|
||||
43, 43, 43, 43, 43, 43, 31, 32, 43, 43,
|
||||
43, 43, 0, 40, 43, 20, 43, 43, 43, 43,
|
||||
43, 7, 43, 43, 43, 43, 10, 43, 43, 43,
|
||||
43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
|
||||
|
||||
43, 43, 43, 43, 10, 11, 12, 43, 43, 43,
|
||||
43, 43, 43, 43, 43, 13, 37, 20, 43, 35,
|
||||
34, 5, 43, 7, 43, 43, 43, 43, 43, 18,
|
||||
43, 14, 15, 16, 43, 43, 17, 43, 43, 43,
|
||||
36, 43, 8, 43, 43, 43, 43, 43, 43, 43,
|
||||
43, 29, 43, 43, 43, 43, 30, 43, 43, 21,
|
||||
43, 43, 43, 43, 22, 23, 43, 43, 43, 24,
|
||||
25, 26, 43, 43, 43, 43, 43, 27, 0
|
||||
43, 11, 12, 13, 43, 43, 43, 43, 43, 43,
|
||||
43, 43, 43, 14, 37, 21, 43, 35, 34, 5,
|
||||
43, 8, 43, 43, 43, 43, 43, 19, 6, 43,
|
||||
15, 16, 17, 43, 43, 18, 43, 43, 43, 36,
|
||||
43, 9, 43, 43, 43, 43, 43, 43, 43, 43,
|
||||
29, 43, 43, 43, 43, 30, 43, 43, 22, 43,
|
||||
43, 43, 43, 23, 24, 43, 43, 43, 25, 26,
|
||||
27, 43, 43, 43, 43, 43, 28, 0
|
||||
} ;
|
||||
|
||||
static yyconst int yy_ec[256] =
|
||||
@ -366,118 +366,116 @@ static yyconst int yy_meta[43] =
|
||||
7, 7
|
||||
} ;
|
||||
|
||||
static yyconst short int yy_base[187] =
|
||||
static yyconst short int yy_base[186] =
|
||||
{ 0,
|
||||
0, 0, 221, 222, 222, 0, 222, 213, 0, 38,
|
||||
37, 212, 222, 0, 190, 16, 188, 25, 20, 22,
|
||||
184, 175, 203, 29, 176, 170, 183, 0, 0, 203,
|
||||
37, 222, 0, 0, 0, 0, 174, 176, 175, 22,
|
||||
0, 177, 173, 172, 170, 165, 172, 169, 166, 168,
|
||||
163, 161, 162, 163, 187, 0, 0, 167, 169, 169,
|
||||
164, 163, 166, 165, 155, 152, 49, 70, 147, 0,
|
||||
0, 144, 153, 155, 142, 172, 171, 153, 163, 150,
|
||||
150, 141, 135, 133, 0, 134, 153, 156, 153, 144,
|
||||
0, 139, 135, 131, 137, 56, 121, 148, 135, 118,
|
||||
0, 0, 214, 215, 215, 0, 215, 206, 0, 38,
|
||||
37, 205, 215, 0, 183, 16, 181, 25, 20, 22,
|
||||
169, 197, 29, 170, 164, 177, 0, 0, 197, 37,
|
||||
215, 0, 0, 0, 0, 168, 170, 169, 22, 0,
|
||||
171, 167, 166, 164, 159, 164, 161, 163, 158, 156,
|
||||
157, 158, 182, 0, 0, 162, 164, 164, 159, 158,
|
||||
161, 160, 150, 147, 49, 142, 0, 0, 139, 32,
|
||||
151, 138, 168, 167, 149, 159, 146, 146, 137, 131,
|
||||
129, 0, 130, 149, 152, 149, 140, 135, 131, 127,
|
||||
134, 132, 56, 116, 143, 130, 113, 127, 114, 134,
|
||||
|
||||
132, 119, 139, 116, 131, 130, 0, 115, 118, 113,
|
||||
120, 121, 130, 133, 130, 121, 0, 0, 120, 0,
|
||||
0, 0, 127, 0, 104, 103, 102, 112, 110, 0,
|
||||
108, 112, 39, 0, 97, 95, 0, 95, 94, 107,
|
||||
0, 103, 0, 91, 90, 96, 88, 85, 100, 99,
|
||||
77, 0, 83, 82, 85, 94, 0, 72, 71, 0,
|
||||
91, 90, 72, 58, 0, 0, 46, 34, 59, 0,
|
||||
0, 0, 53, 38, 35, 48, 25, 0, 222, 86,
|
||||
90, 58, 91, 98, 101, 105
|
||||
111, 126, 125, 0, 110, 113, 108, 115, 104, 115,
|
||||
124, 127, 124, 115, 0, 0, 114, 0, 0, 0,
|
||||
121, 0, 98, 97, 96, 106, 104, 0, 0, 102,
|
||||
106, 42, 0, 91, 89, 0, 89, 88, 101, 0,
|
||||
97, 0, 85, 84, 90, 82, 79, 94, 93, 71,
|
||||
0, 77, 76, 79, 88, 0, 66, 65, 0, 85,
|
||||
84, 66, 52, 0, 0, 40, 37, 61, 0, 0,
|
||||
0, 55, 40, 39, 52, 27, 0, 215, 80, 84,
|
||||
62, 85, 92, 95, 99
|
||||
} ;
|
||||
|
||||
static yyconst short int yy_def[187] =
|
||||
static yyconst short int yy_def[186] =
|
||||
{ 0,
|
||||
179, 1, 179, 179, 179, 180, 179, 181, 182, 179,
|
||||
181, 181, 179, 183, 183, 183, 183, 183, 183, 183,
|
||||
183, 183, 183, 183, 183, 183, 183, 180, 182, 181,
|
||||
182, 179, 184, 31, 185, 183, 183, 183, 183, 183,
|
||||
183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
|
||||
183, 183, 183, 183, 186, 184, 185, 183, 183, 183,
|
||||
183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
|
||||
183, 183, 183, 183, 183, 186, 186, 183, 183, 183,
|
||||
183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
|
||||
68, 183, 183, 183, 183, 183, 183, 183, 183, 183,
|
||||
178, 1, 178, 178, 178, 179, 178, 180, 181, 178,
|
||||
180, 180, 178, 182, 182, 182, 182, 182, 182, 182,
|
||||
182, 182, 182, 182, 182, 182, 179, 181, 180, 181,
|
||||
178, 183, 30, 184, 182, 182, 182, 182, 182, 182,
|
||||
182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
|
||||
182, 182, 185, 183, 184, 182, 182, 182, 182, 182,
|
||||
182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
|
||||
182, 182, 185, 185, 182, 182, 182, 182, 182, 182,
|
||||
182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
|
||||
182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
|
||||
|
||||
183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
|
||||
183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
|
||||
183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
|
||||
183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
|
||||
183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
|
||||
183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
|
||||
183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
|
||||
183, 183, 183, 183, 183, 183, 183, 183, 0, 179,
|
||||
179, 179, 179, 179, 179, 179
|
||||
182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
|
||||
182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
|
||||
182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
|
||||
182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
|
||||
182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
|
||||
182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
|
||||
182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
|
||||
182, 182, 182, 182, 182, 182, 182, 0, 178, 178,
|
||||
178, 178, 178, 178, 178
|
||||
} ;
|
||||
|
||||
static yyconst short int yy_nxt[265] =
|
||||
static yyconst short int yy_nxt[258] =
|
||||
{ 0,
|
||||
4, 5, 6, 7, 4, 8, 9, 10, 11, 12,
|
||||
12, 12, 12, 12, 12, 12, 13, 14, 14, 14,
|
||||
15, 16, 17, 18, 14, 19, 14, 20, 14, 21,
|
||||
14, 22, 23, 14, 24, 25, 26, 27, 14, 14,
|
||||
14, 14, 32, 34, 38, 33, 41, 42, 43, 50,
|
||||
39, 45, 46, 51, 44, 55, 61, 62, 87, 145,
|
||||
88, 55, 31, 89, 90, 113, 178, 114, 177, 176,
|
||||
115, 116, 175, 174, 173, 172, 146, 35, 91, 91,
|
||||
91, 91, 91, 91, 91, 91, 28, 171, 28, 28,
|
||||
28, 28, 28, 30, 30, 36, 36, 36, 56, 170,
|
||||
15, 16, 17, 18, 14, 19, 14, 20, 14, 14,
|
||||
14, 21, 22, 14, 23, 24, 25, 26, 14, 14,
|
||||
14, 14, 31, 33, 37, 32, 40, 41, 42, 48,
|
||||
38, 44, 45, 49, 43, 53, 59, 60, 84, 90,
|
||||
85, 53, 144, 86, 87, 111, 30, 112, 177, 91,
|
||||
113, 114, 176, 175, 174, 173, 172, 34, 171, 145,
|
||||
27, 170, 27, 27, 27, 27, 27, 29, 29, 35,
|
||||
35, 35, 54, 169, 54, 54, 54, 54, 54, 55,
|
||||
|
||||
56, 56, 56, 56, 56, 57, 57, 77, 169, 77,
|
||||
168, 167, 166, 165, 164, 163, 162, 161, 160, 159,
|
||||
158, 157, 156, 155, 154, 153, 152, 151, 150, 149,
|
||||
148, 147, 144, 143, 142, 141, 140, 139, 138, 137,
|
||||
136, 135, 134, 133, 132, 131, 130, 129, 128, 127,
|
||||
126, 125, 124, 123, 122, 121, 120, 119, 118, 117,
|
||||
112, 111, 110, 109, 108, 107, 106, 105, 104, 103,
|
||||
102, 101, 100, 99, 98, 97, 179, 179, 96, 95,
|
||||
94, 93, 92, 86, 85, 84, 83, 82, 81, 80,
|
||||
79, 78, 76, 75, 74, 73, 72, 71, 70, 69,
|
||||
55, 74, 168, 74, 167, 166, 165, 164, 163, 162,
|
||||
161, 160, 159, 158, 157, 156, 155, 154, 153, 152,
|
||||
151, 150, 149, 148, 147, 146, 143, 142, 141, 140,
|
||||
139, 138, 137, 136, 135, 134, 133, 132, 131, 130,
|
||||
129, 128, 127, 126, 125, 124, 123, 122, 121, 120,
|
||||
119, 118, 117, 116, 115, 110, 109, 108, 107, 106,
|
||||
105, 104, 103, 102, 101, 100, 99, 98, 97, 96,
|
||||
95, 94, 178, 178, 93, 92, 89, 88, 83, 82,
|
||||
81, 80, 79, 78, 77, 76, 75, 73, 72, 71,
|
||||
70, 69, 68, 67, 66, 65, 64, 63, 62, 61,
|
||||
|
||||
68, 67, 66, 65, 64, 63, 60, 59, 58, 34,
|
||||
54, 53, 52, 49, 48, 47, 40, 37, 34, 29,
|
||||
179, 3, 179, 179, 179, 179, 179, 179, 179, 179,
|
||||
179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
|
||||
179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
|
||||
179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
|
||||
179, 179, 179, 179
|
||||
58, 57, 56, 33, 52, 51, 50, 47, 46, 39,
|
||||
36, 33, 28, 178, 3, 178, 178, 178, 178, 178,
|
||||
178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
|
||||
178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
|
||||
178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
|
||||
178, 178, 178, 178, 178, 178, 178
|
||||
} ;
|
||||
|
||||
static yyconst short int yy_chk[265] =
|
||||
static yyconst short int yy_chk[258] =
|
||||
{ 0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 10, 11, 16, 10, 18, 18, 19, 24,
|
||||
16, 20, 20, 24, 19, 31, 40, 40, 67, 133,
|
||||
67, 31, 182, 67, 67, 96, 177, 96, 176, 175,
|
||||
96, 96, 174, 173, 169, 168, 133, 11, 68, 68,
|
||||
68, 68, 68, 68, 68, 68, 180, 167, 180, 180,
|
||||
180, 180, 180, 181, 181, 183, 183, 183, 184, 164,
|
||||
1, 1, 10, 11, 16, 10, 18, 18, 19, 23,
|
||||
16, 20, 20, 23, 19, 30, 39, 39, 65, 70,
|
||||
65, 30, 132, 65, 65, 93, 181, 93, 176, 70,
|
||||
93, 93, 175, 174, 173, 172, 168, 11, 167, 132,
|
||||
179, 166, 179, 179, 179, 179, 179, 180, 180, 182,
|
||||
182, 182, 183, 163, 183, 183, 183, 183, 183, 184,
|
||||
|
||||
184, 184, 184, 184, 184, 185, 185, 186, 163, 186,
|
||||
162, 161, 159, 158, 156, 155, 154, 153, 151, 150,
|
||||
149, 148, 147, 146, 145, 144, 142, 140, 139, 138,
|
||||
136, 135, 132, 131, 129, 128, 127, 126, 125, 123,
|
||||
119, 116, 115, 114, 113, 112, 111, 110, 109, 108,
|
||||
106, 105, 104, 103, 102, 101, 100, 99, 98, 97,
|
||||
95, 94, 93, 92, 90, 89, 88, 87, 86, 84,
|
||||
83, 82, 81, 80, 79, 78, 77, 76, 75, 74,
|
||||
73, 72, 69, 66, 65, 64, 63, 62, 61, 60,
|
||||
59, 58, 55, 54, 53, 52, 51, 50, 49, 48,
|
||||
184, 185, 162, 185, 161, 160, 158, 157, 155, 154,
|
||||
153, 152, 150, 149, 148, 147, 146, 145, 144, 143,
|
||||
141, 139, 138, 137, 135, 134, 131, 130, 127, 126,
|
||||
125, 124, 123, 121, 117, 114, 113, 112, 111, 110,
|
||||
109, 108, 107, 106, 105, 103, 102, 101, 100, 99,
|
||||
98, 97, 96, 95, 94, 92, 91, 90, 89, 88,
|
||||
87, 86, 85, 84, 83, 81, 80, 79, 78, 77,
|
||||
76, 75, 74, 73, 72, 71, 69, 66, 64, 63,
|
||||
62, 61, 60, 59, 58, 57, 56, 53, 52, 51,
|
||||
50, 49, 48, 47, 46, 45, 44, 43, 42, 41,
|
||||
|
||||
47, 46, 45, 44, 43, 42, 39, 38, 37, 30,
|
||||
27, 26, 25, 23, 22, 21, 17, 15, 12, 8,
|
||||
3, 179, 179, 179, 179, 179, 179, 179, 179, 179,
|
||||
179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
|
||||
179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
|
||||
179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
|
||||
179, 179, 179, 179
|
||||
38, 37, 36, 29, 26, 25, 24, 22, 21, 17,
|
||||
15, 12, 8, 3, 178, 178, 178, 178, 178, 178,
|
||||
178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
|
||||
178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
|
||||
178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
|
||||
178, 178, 178, 178, 178, 178, 178
|
||||
} ;
|
||||
|
||||
static yy_state_type yy_last_accepting_state;
|
||||
@ -624,7 +622,7 @@ input_chars(char *buffer, int &result, int max_size) {
|
||||
// from the stream, copy it into the current_line array. This
|
||||
// is because the \n.* rule below, which fills current_line
|
||||
// normally, doesn't catch the first line.
|
||||
strncpy(current_line, yytext, max_error_width);
|
||||
strncpy(current_line, dcyytext, max_error_width);
|
||||
current_line[max_error_width] = '\0';
|
||||
line_number++;
|
||||
col_number = 0;
|
||||
@ -792,7 +790,7 @@ inline void accept() {
|
||||
col_number += yyleng;
|
||||
}
|
||||
|
||||
#line 797 "lex.yy.c"
|
||||
#line 795 "lex.yy.c"
|
||||
|
||||
/* Macros after this point can all be overridden by user definitions in
|
||||
* section 1.
|
||||
@ -954,7 +952,7 @@ YY_DECL
|
||||
}
|
||||
|
||||
|
||||
#line 959 "lex.yy.c"
|
||||
#line 957 "lex.yy.c"
|
||||
|
||||
if ( yy_init )
|
||||
{
|
||||
@ -1005,13 +1003,13 @@ yy_match:
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 180 )
|
||||
if ( yy_current_state >= 179 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
++yy_cp;
|
||||
}
|
||||
while ( yy_base[yy_current_state] != 222 );
|
||||
while ( yy_base[yy_current_state] != 215 );
|
||||
|
||||
yy_find_action:
|
||||
yy_act = yy_accept[yy_current_state];
|
||||
@ -1044,7 +1042,7 @@ YY_RULE_SETUP
|
||||
// New line. Save a copy of the line so we can print it out for the
|
||||
// benefit of the user in case we get an error.
|
||||
|
||||
strncpy(current_line, yytext+1, max_error_width);
|
||||
strncpy(current_line, dcyytext+1, max_error_width);
|
||||
current_line[max_error_width] = '\0';
|
||||
line_number++;
|
||||
col_number=0;
|
||||
@ -1092,7 +1090,7 @@ YY_RULE_SETUP
|
||||
#line 353 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_FROM;
|
||||
return KW_STRUCT;
|
||||
}
|
||||
YY_BREAK
|
||||
case 7:
|
||||
@ -1100,7 +1098,7 @@ YY_RULE_SETUP
|
||||
#line 358 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_IMPORT;
|
||||
return KW_FROM;
|
||||
}
|
||||
YY_BREAK
|
||||
case 8:
|
||||
@ -1108,7 +1106,7 @@ YY_RULE_SETUP
|
||||
#line 363 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_TYPEDEF;
|
||||
return KW_IMPORT;
|
||||
}
|
||||
YY_BREAK
|
||||
case 9:
|
||||
@ -1116,7 +1114,7 @@ YY_RULE_SETUP
|
||||
#line 368 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_INT8;
|
||||
return KW_TYPEDEF;
|
||||
}
|
||||
YY_BREAK
|
||||
case 10:
|
||||
@ -1124,7 +1122,7 @@ YY_RULE_SETUP
|
||||
#line 373 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_INT16;
|
||||
return KW_INT8;
|
||||
}
|
||||
YY_BREAK
|
||||
case 11:
|
||||
@ -1132,7 +1130,7 @@ YY_RULE_SETUP
|
||||
#line 378 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_INT32;
|
||||
return KW_INT16;
|
||||
}
|
||||
YY_BREAK
|
||||
case 12:
|
||||
@ -1140,7 +1138,7 @@ YY_RULE_SETUP
|
||||
#line 383 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_INT64;
|
||||
return KW_INT32;
|
||||
}
|
||||
YY_BREAK
|
||||
case 13:
|
||||
@ -1148,7 +1146,7 @@ YY_RULE_SETUP
|
||||
#line 388 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_UINT8;
|
||||
return KW_INT64;
|
||||
}
|
||||
YY_BREAK
|
||||
case 14:
|
||||
@ -1156,7 +1154,7 @@ YY_RULE_SETUP
|
||||
#line 393 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_UINT16;
|
||||
return KW_UINT8;
|
||||
}
|
||||
YY_BREAK
|
||||
case 15:
|
||||
@ -1164,7 +1162,7 @@ YY_RULE_SETUP
|
||||
#line 398 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_UINT32;
|
||||
return KW_UINT16;
|
||||
}
|
||||
YY_BREAK
|
||||
case 16:
|
||||
@ -1172,7 +1170,7 @@ YY_RULE_SETUP
|
||||
#line 403 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_UINT64;
|
||||
return KW_UINT32;
|
||||
}
|
||||
YY_BREAK
|
||||
case 17:
|
||||
@ -1180,7 +1178,7 @@ YY_RULE_SETUP
|
||||
#line 408 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_FLOAT64;
|
||||
return KW_UINT64;
|
||||
}
|
||||
YY_BREAK
|
||||
case 18:
|
||||
@ -1188,7 +1186,7 @@ YY_RULE_SETUP
|
||||
#line 413 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_STRING;
|
||||
return KW_FLOAT64;
|
||||
}
|
||||
YY_BREAK
|
||||
case 19:
|
||||
@ -1196,7 +1194,7 @@ YY_RULE_SETUP
|
||||
#line 418 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_BLOB;
|
||||
return KW_STRING;
|
||||
}
|
||||
YY_BREAK
|
||||
case 20:
|
||||
@ -1204,7 +1202,7 @@ YY_RULE_SETUP
|
||||
#line 423 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_BLOB32;
|
||||
return KW_BLOB;
|
||||
}
|
||||
YY_BREAK
|
||||
case 21:
|
||||
@ -1212,7 +1210,7 @@ YY_RULE_SETUP
|
||||
#line 428 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_INT8ARRAY;
|
||||
return KW_BLOB32;
|
||||
}
|
||||
YY_BREAK
|
||||
case 22:
|
||||
@ -1220,7 +1218,7 @@ YY_RULE_SETUP
|
||||
#line 433 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_INT16ARRAY;
|
||||
return KW_INT8ARRAY;
|
||||
}
|
||||
YY_BREAK
|
||||
case 23:
|
||||
@ -1228,7 +1226,7 @@ YY_RULE_SETUP
|
||||
#line 438 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_INT32ARRAY;
|
||||
return KW_INT16ARRAY;
|
||||
}
|
||||
YY_BREAK
|
||||
case 24:
|
||||
@ -1236,7 +1234,7 @@ YY_RULE_SETUP
|
||||
#line 443 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_UINT8ARRAY;
|
||||
return KW_INT32ARRAY;
|
||||
}
|
||||
YY_BREAK
|
||||
case 25:
|
||||
@ -1244,7 +1242,7 @@ YY_RULE_SETUP
|
||||
#line 448 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_UINT16ARRAY;
|
||||
return KW_UINT8ARRAY;
|
||||
}
|
||||
YY_BREAK
|
||||
case 26:
|
||||
@ -1252,7 +1250,7 @@ YY_RULE_SETUP
|
||||
#line 453 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_UINT32ARRAY;
|
||||
return KW_UINT16ARRAY;
|
||||
}
|
||||
YY_BREAK
|
||||
case 27:
|
||||
@ -1260,23 +1258,20 @@ YY_RULE_SETUP
|
||||
#line 458 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_UINT32UINT8ARRAY;
|
||||
return KW_UINT32ARRAY;
|
||||
}
|
||||
YY_BREAK
|
||||
case 28:
|
||||
YY_RULE_SETUP
|
||||
#line 463 "dcLexer.lxx"
|
||||
{
|
||||
// A molecular keyword.
|
||||
accept();
|
||||
dcyylval.u.integer = atoi(dcyytext + 3);
|
||||
dcyylval.str = yytext;
|
||||
return KW_MOL;
|
||||
return KW_UINT32UINT8ARRAY;
|
||||
}
|
||||
YY_BREAK
|
||||
case 29:
|
||||
YY_RULE_SETUP
|
||||
#line 471 "dcLexer.lxx"
|
||||
#line 468 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_REQUIRED;
|
||||
@ -1284,7 +1279,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 30:
|
||||
YY_RULE_SETUP
|
||||
#line 476 "dcLexer.lxx"
|
||||
#line 473 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_BROADCAST;
|
||||
@ -1292,7 +1287,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 31:
|
||||
YY_RULE_SETUP
|
||||
#line 481 "dcLexer.lxx"
|
||||
#line 478 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_P2P;
|
||||
@ -1300,7 +1295,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 32:
|
||||
YY_RULE_SETUP
|
||||
#line 486 "dcLexer.lxx"
|
||||
#line 483 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_RAM;
|
||||
@ -1308,7 +1303,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 33:
|
||||
YY_RULE_SETUP
|
||||
#line 491 "dcLexer.lxx"
|
||||
#line 488 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_DB;
|
||||
@ -1316,7 +1311,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 34:
|
||||
YY_RULE_SETUP
|
||||
#line 496 "dcLexer.lxx"
|
||||
#line 493 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_CLSEND;
|
||||
@ -1324,7 +1319,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 35:
|
||||
YY_RULE_SETUP
|
||||
#line 501 "dcLexer.lxx"
|
||||
#line 498 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_CLRECV;
|
||||
@ -1332,7 +1327,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 36:
|
||||
YY_RULE_SETUP
|
||||
#line 506 "dcLexer.lxx"
|
||||
#line 503 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_OWNSEND;
|
||||
@ -1340,7 +1335,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 37:
|
||||
YY_RULE_SETUP
|
||||
#line 511 "dcLexer.lxx"
|
||||
#line 508 "dcLexer.lxx"
|
||||
{
|
||||
accept();
|
||||
return KW_AIRECV;
|
||||
@ -1348,40 +1343,70 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 38:
|
||||
YY_RULE_SETUP
|
||||
#line 516 "dcLexer.lxx"
|
||||
#line 513 "dcLexer.lxx"
|
||||
{
|
||||
// An integer number.
|
||||
accept();
|
||||
dcyylval.u.integer = atoi(dcyytext);
|
||||
dcyylval.str = yytext;
|
||||
accept();
|
||||
|
||||
// atoll isn't fully portable, so we'll decode the integer by hand.
|
||||
dcyylval.u.integer = 0;
|
||||
bool neg = false;
|
||||
const char *p = dcyytext;
|
||||
if (*p == '-') {
|
||||
neg = true;
|
||||
++p;
|
||||
} else if (*p == '+') {
|
||||
++p;
|
||||
}
|
||||
while (*p != '\0') {
|
||||
dcyylval.u.integer = dcyylval.u.integer * 10 + (*p - '0');
|
||||
++p;
|
||||
}
|
||||
if (neg) {
|
||||
dcyylval.u.integer = -dcyylval.u.integer;
|
||||
}
|
||||
|
||||
dcyylval.str = dcyytext;
|
||||
return INTEGER;
|
||||
}
|
||||
YY_BREAK
|
||||
case 39:
|
||||
YY_RULE_SETUP
|
||||
#line 524 "dcLexer.lxx"
|
||||
#line 539 "dcLexer.lxx"
|
||||
{
|
||||
// A hexadecimal integer number.
|
||||
accept();
|
||||
dcyylval.u.integer = strtoul(yytext+2, NULL, 16);
|
||||
dcyylval.str = yytext;
|
||||
|
||||
// As above, we'll decode the hex string by hand.
|
||||
dcyylval.u.integer = 0;
|
||||
const char *p = dcyytext + 2;
|
||||
while (*p != '\0') {
|
||||
if (isalpha(*p)) {
|
||||
dcyylval.u.integer = dcyylval.u.integer * 16 + (tolower(*p) - 'a' + 10);
|
||||
} else {
|
||||
dcyylval.u.integer = dcyylval.u.integer * 16 + (*p - '0');
|
||||
}
|
||||
++p;
|
||||
}
|
||||
|
||||
dcyylval.str = dcyytext;
|
||||
return INTEGER;
|
||||
}
|
||||
YY_BREAK
|
||||
case 40:
|
||||
YY_RULE_SETUP
|
||||
#line 532 "dcLexer.lxx"
|
||||
#line 559 "dcLexer.lxx"
|
||||
{
|
||||
// A floating-point number.
|
||||
accept();
|
||||
dcyylval.u.real = atof(dcyytext);
|
||||
dcyylval.str = yytext;
|
||||
dcyylval.str = dcyytext;
|
||||
return REAL;
|
||||
}
|
||||
YY_BREAK
|
||||
case 41:
|
||||
YY_RULE_SETUP
|
||||
#line 540 "dcLexer.lxx"
|
||||
#line 567 "dcLexer.lxx"
|
||||
{
|
||||
// Quoted string.
|
||||
accept();
|
||||
@ -1391,7 +1416,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 42:
|
||||
YY_RULE_SETUP
|
||||
#line 547 "dcLexer.lxx"
|
||||
#line 574 "dcLexer.lxx"
|
||||
{
|
||||
// Long hex string.
|
||||
accept();
|
||||
@ -1401,17 +1426,17 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 43:
|
||||
YY_RULE_SETUP
|
||||
#line 554 "dcLexer.lxx"
|
||||
#line 581 "dcLexer.lxx"
|
||||
{
|
||||
// Identifier.
|
||||
accept();
|
||||
dcyylval.str = yytext;
|
||||
dcyylval.str = dcyytext;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
YY_BREAK
|
||||
case 44:
|
||||
YY_RULE_SETUP
|
||||
#line 562 "dcLexer.lxx"
|
||||
#line 589 "dcLexer.lxx"
|
||||
{
|
||||
// Send any other printable character as itself.
|
||||
accept();
|
||||
@ -1420,10 +1445,10 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 45:
|
||||
YY_RULE_SETUP
|
||||
#line 568 "dcLexer.lxx"
|
||||
#line 595 "dcLexer.lxx"
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
#line 1428 "lex.yy.c"
|
||||
#line 1453 "lex.yy.c"
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
yyterminate();
|
||||
|
||||
@ -1715,7 +1740,7 @@ static yy_state_type yy_get_previous_state()
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 180 )
|
||||
if ( yy_current_state >= 179 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
@ -1750,11 +1775,11 @@ yy_state_type yy_current_state;
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 180 )
|
||||
if ( yy_current_state >= 179 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_is_jam = (yy_current_state == 179);
|
||||
yy_is_jam = (yy_current_state == 178);
|
||||
|
||||
return yy_is_jam ? 0 : yy_current_state;
|
||||
}
|
||||
@ -2304,4 +2329,4 @@ int main()
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#line 568 "dcLexer.lxx"
|
||||
#line 595 "dcLexer.lxx"
|
||||
|
@ -350,6 +350,11 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?)
|
||||
return KW_DCLASS;
|
||||
}
|
||||
|
||||
"struct" {
|
||||
accept();
|
||||
return KW_STRUCT;
|
||||
}
|
||||
|
||||
"from" {
|
||||
accept();
|
||||
return KW_FROM;
|
||||
@ -460,14 +465,6 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?)
|
||||
return KW_UINT32UINT8ARRAY;
|
||||
}
|
||||
|
||||
mol[0-9]+ {
|
||||
// A molecular keyword.
|
||||
accept();
|
||||
dcyylval.u.integer = atoi(dcyytext + 3);
|
||||
dcyylval.str = dcyytext;
|
||||
return KW_MOL;
|
||||
}
|
||||
|
||||
"required" {
|
||||
accept();
|
||||
return KW_REQUIRED;
|
||||
|
@ -532,10 +532,9 @@ unpack_and_format(ostream &out) {
|
||||
out << '(';
|
||||
break;
|
||||
|
||||
case PT_struct:
|
||||
case PT_class:
|
||||
default:
|
||||
out << '{';
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -558,7 +557,7 @@ unpack_and_format(ostream &out) {
|
||||
out << ')';
|
||||
break;
|
||||
|
||||
case PT_struct:
|
||||
case PT_class:
|
||||
default:
|
||||
out << '}';
|
||||
break;
|
||||
|
@ -46,7 +46,7 @@ enum DCPackType {
|
||||
// but the PackType provides a bit of a semantic context.
|
||||
PT_array,
|
||||
PT_field,
|
||||
PT_struct,
|
||||
PT_class,
|
||||
};
|
||||
END_PUBLISH
|
||||
|
||||
|
@ -121,6 +121,18 @@ output(ostream &out, bool brief) const {
|
||||
output_instance(out, "", name, "");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCParameter::write
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DCParameter::
|
||||
write(ostream &out, bool brief, int indent_level) const {
|
||||
indent(out, indent_level);
|
||||
output(out, brief);
|
||||
out << ";\n";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCParameter::output_typedef_name
|
||||
// Access: Public
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
void set_typedef(const DCTypedef *dtypedef);
|
||||
|
||||
void output(ostream &out, bool brief) const;
|
||||
void write(ostream &out, bool brief, int indent_level) const;
|
||||
virtual void output_instance(ostream &out, const string &prename,
|
||||
const string &name, const string &postname) const=0;
|
||||
void output_typedef_name(ostream &out, const string &prename,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,29 +7,29 @@
|
||||
# define HEX_STRING 260
|
||||
# define IDENTIFIER 261
|
||||
# define KW_DCLASS 262
|
||||
# define KW_FROM 263
|
||||
# define KW_IMPORT 264
|
||||
# define KW_TYPEDEF 265
|
||||
# define KW_INT8 266
|
||||
# define KW_INT16 267
|
||||
# define KW_INT32 268
|
||||
# define KW_INT64 269
|
||||
# define KW_UINT8 270
|
||||
# define KW_UINT16 271
|
||||
# define KW_UINT32 272
|
||||
# define KW_UINT64 273
|
||||
# define KW_FLOAT64 274
|
||||
# define KW_STRING 275
|
||||
# define KW_BLOB 276
|
||||
# define KW_BLOB32 277
|
||||
# define KW_INT8ARRAY 278
|
||||
# define KW_INT16ARRAY 279
|
||||
# define KW_INT32ARRAY 280
|
||||
# define KW_UINT8ARRAY 281
|
||||
# define KW_UINT16ARRAY 282
|
||||
# define KW_UINT32ARRAY 283
|
||||
# define KW_UINT32UINT8ARRAY 284
|
||||
# define KW_MOL 285
|
||||
# define KW_STRUCT 263
|
||||
# define KW_FROM 264
|
||||
# define KW_IMPORT 265
|
||||
# define KW_TYPEDEF 266
|
||||
# define KW_INT8 267
|
||||
# define KW_INT16 268
|
||||
# define KW_INT32 269
|
||||
# define KW_INT64 270
|
||||
# define KW_UINT8 271
|
||||
# define KW_UINT16 272
|
||||
# define KW_UINT32 273
|
||||
# define KW_UINT64 274
|
||||
# define KW_FLOAT64 275
|
||||
# define KW_STRING 276
|
||||
# define KW_BLOB 277
|
||||
# define KW_BLOB32 278
|
||||
# define KW_INT8ARRAY 279
|
||||
# define KW_INT16ARRAY 280
|
||||
# define KW_INT32ARRAY 281
|
||||
# define KW_UINT8ARRAY 282
|
||||
# define KW_UINT16ARRAY 283
|
||||
# define KW_UINT32ARRAY 284
|
||||
# define KW_UINT32UINT8ARRAY 285
|
||||
# define KW_REQUIRED 286
|
||||
# define KW_BROADCAST 287
|
||||
# define KW_P2P 288
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "dcClass.h"
|
||||
#include "dcAtomicField.h"
|
||||
#include "dcMolecularField.h"
|
||||
#include "dcClassParameter.h"
|
||||
#include "dcArrayParameter.h"
|
||||
#include "dcSimpleParameter.h"
|
||||
#include "dcTypedef.h"
|
||||
@ -63,6 +64,7 @@ dc_cleanup_parser() {
|
||||
%token <str> STRING HEX_STRING IDENTIFIER
|
||||
|
||||
%token KW_DCLASS
|
||||
%token KW_STRUCT
|
||||
%token KW_FROM
|
||||
%token KW_IMPORT
|
||||
%token KW_TYPEDEF
|
||||
@ -87,8 +89,6 @@ dc_cleanup_parser() {
|
||||
%token KW_UINT32ARRAY
|
||||
%token KW_UINT32UINT8ARRAY
|
||||
|
||||
%token KW_MOL
|
||||
|
||||
%token KW_REQUIRED
|
||||
%token KW_BROADCAST
|
||||
%token KW_P2P
|
||||
@ -105,11 +105,14 @@ dc_cleanup_parser() {
|
||||
%token START_DC
|
||||
%token START_PARAMETER_VALUE
|
||||
|
||||
%type <u.flag> kw_struct_or_kw_dclass
|
||||
%type <u.dclass> dclass_name
|
||||
%type <u.atomic> atomic_name
|
||||
%type <u.subatomic> type_token
|
||||
%type <u.parameter> type_name
|
||||
%type <u.parameter> type_definition
|
||||
%type <u.parameter> named_parameter
|
||||
%type <u.parameter> unnamed_parameter
|
||||
%type <u.parameter> parameter
|
||||
%type <u.parameter> parameter_definition
|
||||
%type <str> import_identifier
|
||||
@ -131,9 +134,9 @@ dc:
|
||||
;
|
||||
|
||||
dclass:
|
||||
KW_DCLASS IDENTIFIER
|
||||
kw_struct_or_kw_dclass IDENTIFIER
|
||||
{
|
||||
current_class = new DCClass($2);
|
||||
current_class = new DCClass($2, $1, false);
|
||||
if (!dc_file->add_class(current_class)) {
|
||||
DCClass *old_class = dc_file->get_class_by_name(current_class->get_name());
|
||||
if (old_class->is_bogus_class()) {
|
||||
@ -146,12 +149,23 @@ dclass:
|
||||
dclass_derivation '{' dclass_fields '}'
|
||||
;
|
||||
|
||||
kw_struct_or_kw_dclass:
|
||||
KW_STRUCT
|
||||
{
|
||||
$$ = true;
|
||||
}
|
||||
| KW_DCLASS
|
||||
{
|
||||
$$ = false;
|
||||
}
|
||||
;
|
||||
|
||||
dclass_name:
|
||||
IDENTIFIER
|
||||
{
|
||||
DCClass *dclass = dc_file->get_class_by_name($1);
|
||||
if (dclass == (DCClass *)NULL) {
|
||||
dclass = new DCClass($1, true);
|
||||
dclass = new DCClass($1, false, true);
|
||||
dc_file->add_class(dclass);
|
||||
}
|
||||
|
||||
@ -247,6 +261,16 @@ dclass_fields:
|
||||
| dclass_fields ';'
|
||||
| dclass_fields atomic_field
|
||||
| dclass_fields molecular_field
|
||||
| dclass_fields unnamed_parameter ';'
|
||||
{
|
||||
current_class->add_parameter($2);
|
||||
}
|
||||
| dclass_fields named_parameter
|
||||
{
|
||||
if (!current_class->add_parameter($2)) {
|
||||
yyerror("Duplicate parameter name: " + $2->get_name());
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
atomic_field:
|
||||
@ -316,7 +340,7 @@ atomic_element:
|
||||
}
|
||||
;
|
||||
|
||||
parameter:
|
||||
named_parameter:
|
||||
type_definition
|
||||
{
|
||||
current_parameter = $1;
|
||||
@ -325,7 +349,15 @@ parameter:
|
||||
{
|
||||
$$ = $3;
|
||||
}
|
||||
| type_definition
|
||||
;
|
||||
|
||||
unnamed_parameter:
|
||||
type_definition
|
||||
;
|
||||
|
||||
parameter:
|
||||
named_parameter
|
||||
| unnamed_parameter
|
||||
;
|
||||
|
||||
type_name:
|
||||
@ -348,7 +380,16 @@ type_name:
|
||||
{
|
||||
DCTypedef *dtypedef = dc_file->get_typedef_by_name($1);
|
||||
if (dtypedef == (DCTypedef *)NULL) {
|
||||
dtypedef = new DCTypedef($1);
|
||||
// Maybe it's a class name.
|
||||
DCClass *dclass = dc_file->get_class_by_name($1);
|
||||
if (dclass != (DCClass *)NULL) {
|
||||
// Create an implicit typedef for this.
|
||||
dtypedef = new DCTypedef(new DCClassParameter(dclass), true);
|
||||
} else {
|
||||
// It's an undefined typedef. Create a bogus forward reference.
|
||||
dtypedef = new DCTypedef($1);
|
||||
}
|
||||
|
||||
dc_file->add_typedef(dtypedef);
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
union U {
|
||||
PN_int64 integer;
|
||||
double real;
|
||||
bool flag;
|
||||
DCClass *dclass;
|
||||
DCAtomicField *atomic;
|
||||
DCSubatomicType subatomic;
|
||||
|
@ -1202,7 +1202,7 @@ Uint32Uint8Type() {
|
||||
_uint8_type = new DCSimpleParameter(ST_uint8);
|
||||
_has_nested_fields = true;
|
||||
_num_nested_fields = 2;
|
||||
_pack_type = PT_struct;
|
||||
_pack_type = PT_class;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -27,9 +27,10 @@
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DCTypedef::
|
||||
DCTypedef(DCParameter *parameter) :
|
||||
DCTypedef(DCParameter *parameter, bool implicit) :
|
||||
_parameter(parameter),
|
||||
_bogus_typedef(false),
|
||||
_implicit_typedef(implicit),
|
||||
_number(-1)
|
||||
{
|
||||
}
|
||||
@ -43,6 +44,7 @@ DCTypedef::
|
||||
DCTypedef(const string &name) :
|
||||
_parameter(new DCSimpleParameter(ST_invalid)),
|
||||
_bogus_typedef(true),
|
||||
_implicit_typedef(false),
|
||||
_number(-1)
|
||||
{
|
||||
_parameter->set_name(name);
|
||||
@ -107,6 +109,18 @@ is_bogus_typedef() const {
|
||||
return _bogus_typedef;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCTypedef::is_implicit_typedef
|
||||
// Access: Public
|
||||
// Description: Returns true if the typedef has been flagged as an
|
||||
// implicit typedef, meaning it was created for a
|
||||
// DCClass that was referenced inline as a type.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool DCTypedef::
|
||||
is_implicit_typedef() const {
|
||||
return _implicit_typedef;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCTypedef::make_new_parameter
|
||||
// Access: Public
|
||||
@ -135,7 +149,7 @@ set_number(int number) {
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DCTypedef::write
|
||||
// Access: Public
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DCTypedef::
|
||||
@ -153,4 +167,3 @@ write(ostream &out, bool brief, int indent_level) const {
|
||||
}
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define DCTYPEDEF_H
|
||||
|
||||
#include "dcbase.h"
|
||||
#include "dcDeclaration.h"
|
||||
|
||||
class DCParameter;
|
||||
|
||||
@ -29,11 +30,11 @@ class DCParameter;
|
||||
// dc file. It assigns a particular type to a new name,
|
||||
// just like a C typedef.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_DIRECT DCTypedef {
|
||||
class EXPCL_DIRECT DCTypedef : public DCDeclaration {
|
||||
public:
|
||||
DCTypedef(DCParameter *parameter);
|
||||
DCTypedef(DCParameter *parameter, bool implicit = false);
|
||||
DCTypedef(const string &name);
|
||||
~DCTypedef();
|
||||
virtual ~DCTypedef();
|
||||
|
||||
PUBLISHED:
|
||||
int get_number() const;
|
||||
@ -41,16 +42,18 @@ PUBLISHED:
|
||||
string get_description() const;
|
||||
|
||||
bool is_bogus_typedef() const;
|
||||
bool is_implicit_typedef() const;
|
||||
|
||||
public:
|
||||
DCParameter *make_new_parameter() const;
|
||||
|
||||
void set_number(int number);
|
||||
void write(ostream &out, bool brief, int indent_level) const;
|
||||
virtual void write(ostream &out, bool brief, int indent_level) const;
|
||||
|
||||
private:
|
||||
DCParameter *_parameter;
|
||||
bool _bogus_typedef;
|
||||
bool _implicit_typedef;
|
||||
int _number;
|
||||
};
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "hashGenerator.cxx"
|
||||
#include "dcAtomicField.cxx"
|
||||
#include "dcClass.cxx"
|
||||
#include "dcDeclaration.cxx"
|
||||
#include "dcPackData.cxx"
|
||||
#include "dcPacker.cxx"
|
||||
#include "dcPackerInterface.cxx"
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
#include "dcParameter.cxx"
|
||||
#include "dcClassParameter.cxx"
|
||||
#include "dcArrayParameter.cxx"
|
||||
#include "dcSimpleParameter.cxx"
|
||||
#include "dcField.cxx"
|
||||
|
Loading…
x
Reference in New Issue
Block a user