mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
switch parameter -> key parameter
This commit is contained in:
parent
19e98401f1
commit
03951a3b1f
@ -1993,7 +1993,7 @@ case 148:
|
|||||||
#line 918 "dcParser.yxx"
|
#line 918 "dcParser.yxx"
|
||||||
{
|
{
|
||||||
current_packer = &default_packer;
|
current_packer = &default_packer;
|
||||||
current_packer->begin_pack(current_switch->get_switch_parameter());
|
current_packer->begin_pack(current_switch->get_key_parameter());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 149:
|
case 149:
|
||||||
|
@ -917,7 +917,7 @@ switch_case:
|
|||||||
KW_CASE
|
KW_CASE
|
||||||
{
|
{
|
||||||
current_packer = &default_packer;
|
current_packer = &default_packer;
|
||||||
current_packer->begin_pack(current_switch->get_switch_parameter());
|
current_packer->begin_pack(current_switch->get_key_parameter());
|
||||||
}
|
}
|
||||||
parameter_value ':'
|
parameter_value ':'
|
||||||
{
|
{
|
||||||
|
@ -23,21 +23,21 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DCSwitch::Constructor
|
// Function: DCSwitch::Constructor
|
||||||
// Access: Public
|
// Access: Public
|
||||||
// Description: The switch_parameter must be recently allocated via
|
// Description: The key_parameter must be recently allocated via
|
||||||
// new; it will be deleted via delete when the switch
|
// new; it will be deleted via delete when the switch
|
||||||
// destructs.
|
// destructs.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
DCSwitch::
|
DCSwitch::
|
||||||
DCSwitch(const string &name, DCParameter *switch_parameter) :
|
DCSwitch(const string &name, DCParameter *key_parameter) :
|
||||||
DCField(name),
|
DCField(name),
|
||||||
_switch_parameter(switch_parameter)
|
_key_parameter(key_parameter)
|
||||||
{
|
{
|
||||||
_has_fixed_byte_size = _switch_parameter->has_fixed_byte_size();
|
_has_fixed_byte_size = _key_parameter->has_fixed_byte_size();
|
||||||
_fixed_byte_size = _switch_parameter->get_fixed_byte_size();
|
_fixed_byte_size = _key_parameter->get_fixed_byte_size();
|
||||||
_has_fixed_structure = false;
|
_has_fixed_structure = false;
|
||||||
|
|
||||||
// The DCSwitch presents just one nested field initially, which is
|
// The DCSwitch presents just one nested field initially, which is
|
||||||
// the switch parameter. When we pack or unpack that, the DCPacker
|
// the key parameter. When we pack or unpack that, the DCPacker
|
||||||
// calls apply_switch(), which returns a new record that presents
|
// calls apply_switch(), which returns a new record that presents
|
||||||
// the remaining nested fields.
|
// the remaining nested fields.
|
||||||
_has_nested_fields = true;
|
_has_nested_fields = true;
|
||||||
@ -53,7 +53,7 @@ DCSwitch(const string &name, DCParameter *switch_parameter) :
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
DCSwitch::
|
DCSwitch::
|
||||||
~DCSwitch() {
|
~DCSwitch() {
|
||||||
delete _switch_parameter;
|
delete _key_parameter;
|
||||||
|
|
||||||
Cases::iterator ci;
|
Cases::iterator ci;
|
||||||
for (ci = _cases.begin(); ci != _cases.end(); ++ci) {
|
for (ci = _cases.begin(); ci != _cases.end(); ++ci) {
|
||||||
@ -73,7 +73,7 @@ as_switch() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DCSwitch::get_switch_parameter
|
// Function: DCSwitch::get_key_parameter
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description: Returns the key parameter on which the switch is
|
// Description: Returns the key parameter on which the switch is
|
||||||
// based. The value of this parameter in the record
|
// based. The value of this parameter in the record
|
||||||
@ -81,8 +81,8 @@ as_switch() {
|
|||||||
// switch will be used.
|
// switch will be used.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
DCParameter *DCSwitch::
|
DCParameter *DCSwitch::
|
||||||
get_switch_parameter() const {
|
get_key_parameter() const {
|
||||||
return _switch_parameter;
|
return _key_parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -181,10 +181,10 @@ get_field_by_name(int case_index, const string &name) const {
|
|||||||
DCPackerInterface *DCSwitch::
|
DCPackerInterface *DCSwitch::
|
||||||
get_nested_field(int) const {
|
get_nested_field(int) const {
|
||||||
// The DCSwitch presents just one nested field initially, which is
|
// The DCSwitch presents just one nested field initially, which is
|
||||||
// the switch parameter. When we pack or unpack that, the DCPacker
|
// the key parameter. When we pack or unpack that, the DCPacker
|
||||||
// calls apply_switch(), which returns a new record that presents
|
// calls apply_switch(), which returns a new record that presents
|
||||||
// the remaining nested fields.
|
// the remaining nested fields.
|
||||||
return _switch_parameter;
|
return _key_parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -203,7 +203,7 @@ add_case(const string &value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SwitchCase *dcase = new SwitchCase(_name, value);
|
SwitchCase *dcase = new SwitchCase(_name, value);
|
||||||
dcase->add_field(_switch_parameter);
|
dcase->add_field(_key_parameter);
|
||||||
_cases.push_back(dcase);
|
_cases.push_back(dcase);
|
||||||
return case_index;
|
return case_index;
|
||||||
}
|
}
|
||||||
@ -282,14 +282,14 @@ write(ostream &out, bool brief, int indent_level) const {
|
|||||||
out << " " << _name;
|
out << " " << _name;
|
||||||
}
|
}
|
||||||
out << " (";
|
out << " (";
|
||||||
_switch_parameter->output(out, brief);
|
_key_parameter->output(out, brief);
|
||||||
out << ") {\n";
|
out << ") {\n";
|
||||||
|
|
||||||
Cases::const_iterator ci;
|
Cases::const_iterator ci;
|
||||||
for (ci = _cases.begin(); ci != _cases.end(); ++ci) {
|
for (ci = _cases.begin(); ci != _cases.end(); ++ci) {
|
||||||
const SwitchCase *dcase = (*ci);
|
const SwitchCase *dcase = (*ci);
|
||||||
indent(out, indent_level)
|
indent(out, indent_level)
|
||||||
<< "case " << _switch_parameter->format_data(dcase->_value) << ":\n";
|
<< "case " << _key_parameter->format_data(dcase->_value) << ":\n";
|
||||||
|
|
||||||
Fields::const_iterator fi;
|
Fields::const_iterator fi;
|
||||||
if (!dcase->_fields.empty()) {
|
if (!dcase->_fields.empty()) {
|
||||||
@ -315,7 +315,7 @@ void DCSwitch::
|
|||||||
generate_hash(HashGenerator &hashgen) const {
|
generate_hash(HashGenerator &hashgen) const {
|
||||||
DCField::generate_hash(hashgen);
|
DCField::generate_hash(hashgen);
|
||||||
|
|
||||||
_switch_parameter->generate_hash(hashgen);
|
_key_parameter->generate_hash(hashgen);
|
||||||
|
|
||||||
hashgen.add_int(_cases.size());
|
hashgen.add_int(_cases.size());
|
||||||
Cases::const_iterator ci;
|
Cases::const_iterator ci;
|
||||||
|
@ -31,13 +31,13 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class EXPCL_DIRECT DCSwitch : public DCField {
|
class EXPCL_DIRECT DCSwitch : public DCField {
|
||||||
public:
|
public:
|
||||||
DCSwitch(const string &name, DCParameter *switch_parameter);
|
DCSwitch(const string &name, DCParameter *key_parameter);
|
||||||
virtual ~DCSwitch();
|
virtual ~DCSwitch();
|
||||||
|
|
||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
virtual DCSwitch *as_switch();
|
virtual DCSwitch *as_switch();
|
||||||
|
|
||||||
DCParameter *get_switch_parameter() const;
|
DCParameter *get_key_parameter() const;
|
||||||
|
|
||||||
int get_num_cases() const;
|
int get_num_cases() const;
|
||||||
int get_case_by_value(const string &case_value) const;
|
int get_case_by_value(const string &case_value) const;
|
||||||
@ -59,7 +59,7 @@ public:
|
|||||||
virtual void generate_hash(HashGenerator &hashgen) const;
|
virtual void generate_hash(HashGenerator &hashgen) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DCParameter *_switch_parameter;
|
DCParameter *_key_parameter;
|
||||||
|
|
||||||
typedef pvector<DCField *> Fields;
|
typedef pvector<DCField *> Fields;
|
||||||
typedef pmap<string, DCField *> FieldsByName;
|
typedef pmap<string, DCField *> FieldsByName;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user