Commit f4f38e43 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

OOP: fixed order of fields in classes, they are no longer rearranged alphabetically (bug 552011)



Change-Id: I57e0c52c56da77fc3dbd636db6e1c6096e54ee27
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent e6c2fb02
......@@ -486,7 +486,7 @@ namespace Common {
virtual size_t get_nof_asss() = 0;
/** Returns the assignment with the given index. Only the uniquely
* named assignments are visible. */
virtual Assignment* get_ass_byIndex(size_t p_i) = 0;
virtual Assignment* get_ass_byIndex(size_t p_i, bool p_reordered = true) = 0;
};
enum param_eval_t {
......
......@@ -717,10 +717,10 @@ namespace Asn {
return asss_m.size();
}
Common::Assignment* Assignments::get_ass_byIndex(size_t p_i)
Common::Assignment* Assignments::get_ass_byIndex(size_t p_i, bool p_reordered)
{
if (!checked) chk_uniq();
return asss_m.get_nth_elem(p_i);
return p_reordered ? asss_m.get_nth_elem(p_i) : asss_v[p_i];
}
void Assignments::add_ass(Assignment *p_ass)
......
......@@ -190,7 +190,7 @@ namespace Asn {
/** Also looks into special assignments. */
virtual Assignment* get_local_ass_byId(const Identifier& p_id);
virtual size_t get_nof_asss();
virtual Common::Assignment* get_ass_byIndex(size_t p_i);
virtual Common::Assignment* get_ass_byIndex(size_t p_i, bool p_reordered = true);
/** Adds the Assignment. If \a checked flag is true and the id of the new
* assignment is not unique it reports the error. */
void add_ass(Assignment *p_ass);
......
......@@ -2146,10 +2146,10 @@ namespace Ttcn {
return ass_v.size();
}
Common::Assignment* Definitions::get_ass_byIndex(size_t p_i)
Common::Assignment* Definitions::get_ass_byIndex(size_t p_i, bool p_reordered)
{
if (!checked) chk_uniq();
return ass_m.get_nth_elem(p_i);
return p_reordered ? ass_m.get_nth_elem(p_i) : ass_v[p_i];
}
Ttcn::Definition* Definitions::get_raw_ass_byIndex(size_t p_i) {
......
......@@ -514,7 +514,7 @@ namespace Ttcn {
virtual bool has_local_ass_withId(const Identifier& p_id);
virtual Common::Assignment* get_local_ass_byId(const Identifier& p_id);
virtual size_t get_nof_asss();
virtual Common::Assignment* get_ass_byIndex(size_t p_i);
virtual Common::Assignment* get_ass_byIndex(size_t p_i, bool p_reordered = true);
size_t get_nof_raw_asss();
Definition *get_raw_ass_byIndex(size_t p_i);
virtual bool is_class_scope() const;
......
......@@ -3373,7 +3373,7 @@ namespace Ttcn {
members->chk();
for (size_t i = 0; i < members->get_nof_asss(); ++i) {
Common::Assignment* ass = members->get_ass_byIndex(i);
Common::Assignment* ass = members->get_ass_byIndex(i, false);
if (ass->get_asstype() == Common::Assignment::A_CONSTRUCTOR) {
// TODO: check for multiple constructors, or is that handled by previous checks?
constructor = dynamic_cast<Def_Constructor*>(ass);
......@@ -3413,7 +3413,9 @@ namespace Ttcn {
}
StatementBlock* block = new StatementBlock();
for (size_t i = 0; i < members->get_nof_asss(); ++i) {
Common::Assignment* member = members->get_ass_byIndex(i);
// note: the Definitions class rearranges its element alphabetically;
// here the members must be accessed in their original order
Common::Assignment* member = members->get_ass_byIndex(i, false);
bool is_template = false;
switch (member->get_asstype()) {
case Common::Assignment::A_TEMPLATE:
......@@ -3463,7 +3465,7 @@ namespace Ttcn {
}
for (size_t i = 0; i < members->get_nof_asss(); ++i) {
Common::Assignment* def = members->get_ass_byIndex(i);
Common::Assignment* def = members->get_ass_byIndex(i, false);
switch (def->get_asstype()) {
case Common::Assignment::A_VAR:
if (def->get_Type()->get_type_refd_last()->get_typetype() == Common::Type::T_CLASS) {
......@@ -3600,7 +3602,7 @@ namespace Ttcn {
first_logged = true;
}
for (size_t i = 0; i < members->get_nof_asss(); ++i) {
Common::Assignment* member = members->get_ass_byIndex(i);
Common::Assignment* member = members->get_ass_byIndex(i, false);
switch (member->get_asstype()) {
case Common::Assignment::A_CONST:
case Common::Assignment::A_VAR:
......
......@@ -6,3 +6,5 @@ compile
*.gcno
*.log
result.txt
Text_EncDec
Text_EncDec.exe
......@@ -6,3 +6,5 @@ compile
*.gcno
*.log
result.txt
XER_EncDec
XER_EncDec.exe
......@@ -5,3 +5,4 @@ TintOper_se[qt]of.cc
TintOper_union.cc
TintOper.hh
intOper.log
result.txt
......@@ -224,9 +224,9 @@ testcase tc_logging() runs on CT {
log(v_sub);
log(v_final);
var charstring v_base_str := "BaseClass: { m_const := 2, m_const2 := { 1, 2, 1 }, m_temp := *, m_timer := timer: { name: m_timer, default duration: none, state: inactive }, m_timer_array := { timer: { name: m_timer_array[0], default duration: none, state: inactive }, timer: { name: m_timer_array[1], default duration: none, state: inactive }, timer: { name: m_timer_array[2], default duration: none, state: inactive } }, m_var := \"a\", m_var_temp := (0.000000 .. 10.000000) }";
var charstring v_sub_str := "SubClass: { BaseClass: { m_const := 2, m_const2 := { 1, 2, 1 }, m_temp := *, m_timer := timer: { name: m_timer, default duration: none, state: inactive }, m_timer_array := { timer: { name: m_timer_array[0], default duration: none, state: inactive }, timer: { name: m_timer_array[1], default duration: none, state: inactive }, timer: { name: m_timer_array[2], default duration: none, state: inactive } }, m_var := \"ax\", m_var_temp := (0.000000 .. 10.000000) }, m_const3 := 'FFFF'O }";
var charstring v_final_str := "FinalClass: { SubClass: { BaseClass: { m_const := 2, m_const2 := { 1, 2, 1 }, m_temp := *, m_timer := timer: { name: m_timer, default duration: none, state: inactive }, m_timer_array := { timer: { name: m_timer_array[0], default duration: none, state: inactive }, timer: { name: m_timer_array[1], default duration: none, state: inactive }, timer: { name: m_timer_array[2], default duration: none, state: inactive } }, m_var := \"ax\", m_var_temp := (0.000000 .. 10.000000) }, m_const3 := 'FFFF'O }, m_final_const := 8, m_final_temp := \"x\", m_final_var := -1.500000, m_final_var_temp := * }";
var charstring v_base_str := "BaseClass: { m_const := 2, m_const2 := { 1, 2, 1 }, m_var := \"a\", m_temp := *, m_var_temp := (0.000000 .. 10.000000), m_timer := timer: { name: m_timer, default duration: none, state: inactive }, m_timer_array := { timer: { name: m_timer_array[0], default duration: none, state: inactive }, timer: { name: m_timer_array[1], default duration: none, state: inactive }, timer: { name: m_timer_array[2], default duration: none, state: inactive } } }";
var charstring v_sub_str := "SubClass: { BaseClass: { m_const := 2, m_const2 := { 1, 2, 1 }, m_var := \"ax\", m_temp := *, m_var_temp := (0.000000 .. 10.000000), m_timer := timer: { name: m_timer, default duration: none, state: inactive }, m_timer_array := { timer: { name: m_timer_array[0], default duration: none, state: inactive }, timer: { name: m_timer_array[1], default duration: none, state: inactive }, timer: { name: m_timer_array[2], default duration: none, state: inactive } } }, m_const3 := 'FFFF'O }";
var charstring v_final_str := "FinalClass: { SubClass: { BaseClass: { m_const := 2, m_const2 := { 1, 2, 1 }, m_var := \"ax\", m_temp := *, m_var_temp := (0.000000 .. 10.000000), m_timer := timer: { name: m_timer, default duration: none, state: inactive }, m_timer_array := { timer: { name: m_timer_array[0], default duration: none, state: inactive }, timer: { name: m_timer_array[1], default duration: none, state: inactive }, timer: { name: m_timer_array[2], default duration: none, state: inactive } } }, m_const3 := 'FFFF'O }, m_final_const := 8, m_final_temp := \"x\", m_final_var := -1.500000, m_final_var_temp := * }";
if (log2str(v_base) != v_base_str) {
setverdict(fail, "v_base: ", v_base);
......@@ -443,6 +443,23 @@ testcase tc_object() runs on CT {
setverdict(pass);
}
type class Order {
var integer b;
var integer d;
var integer c;
var integer a;
}
testcase tc_order() runs on CT {
var Order x := Order.create(1, 2, 3, 4);
if (log2str(x) == "Order: { b := 1, d := 2, c := 3, a := 4 }") {
setverdict(pass);
}
else {
setverdict(fail, x);
}
}
control {
execute(tc_members_and_methods());
......@@ -453,6 +470,7 @@ control {
execute(tc_references());
execute(tc_function_pars_and_retval());
execute(tc_object());
execute(tc_order());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment