mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 20:57:55 +00:00
Merge pull request #877 from nasa/char_sized_enums
Add support for char-sized enums
This commit is contained in:
commit
5e11a40a69
@ -9,7 +9,7 @@ EnumDataType::EnumDataType( EnumDictionary * enumDictionary,
|
||||
std::string name,
|
||||
size_t enumSize) {
|
||||
|
||||
if ((enumSize == sizeof(int)) || (enumSize == sizeof(short))) {
|
||||
if ((enumSize == sizeof(int)) || (enumSize == sizeof(short) || (enumSize == sizeof(char))) {
|
||||
this->enumSize = enumSize;
|
||||
} // FIXME: else throw?
|
||||
|
||||
@ -107,6 +107,8 @@ void EnumDataType::clearValue(void * address) const {
|
||||
*(int*)address = 0;
|
||||
} else if (enumSize == sizeof(short)) {
|
||||
*(short*)address = 0;
|
||||
} else if (enumSize == sizeof(char)) {
|
||||
*(char*)address = 0;
|
||||
} else {
|
||||
std::cerr << "ERROR: Enumeration of size " << enumSize << "is not supported.";
|
||||
}
|
||||
@ -121,6 +123,8 @@ void EnumDataType::assignValue(void * address, Value * value) const {
|
||||
*(int*)address = numeric_value_p->getIntegerValue();
|
||||
} else if (enumSize == sizeof(short)) {
|
||||
*(short*)address = numeric_value_p->getIntegerValue();
|
||||
} else if (enumSize == sizeof(char)) {
|
||||
*(char*)address = numeric_value_p->getIntegerValue();
|
||||
} else {
|
||||
std::cerr << "ERROR: Enumeration of size " << enumSize << "is not supported.";
|
||||
}
|
||||
@ -137,6 +141,8 @@ void EnumDataType::printValue(std::ostream &s, void *address) const {
|
||||
value = *(int*)address;
|
||||
} else if (enumSize == sizeof(short)) {
|
||||
value = *(short*)address;
|
||||
} else if (enumSize == sizeof(char)) {
|
||||
value = *(char*)address;
|
||||
} else {
|
||||
std::cerr << "ERROR: Enumeration of size " << enumSize << "is not supported.";
|
||||
}
|
||||
|
@ -114,6 +114,14 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
|
||||
<< " = " << *(short*)assign_addr << ";" << std::endl;
|
||||
std::cout.flush();
|
||||
}
|
||||
} else if ((size_t)attr->size == sizeof(char)) {
|
||||
assign_addr = (char*)base_addr + offset * sizeof(char);
|
||||
*(char *)assign_addr = vval_char(v_tree->v_data);
|
||||
if (debug_level) {
|
||||
std::cout << std::endl << "Assignment (Enum): *(char*)" << (void*)assign_addr
|
||||
<< " = " << *(char*)assign_addr << ";" << std::endl;
|
||||
std::cout.flush();
|
||||
}
|
||||
} else {
|
||||
std::stringstream message;
|
||||
message << "Enumeration of size " << attr->size << " is not supported.";
|
||||
|
Loading…
Reference in New Issue
Block a user